Skip to content

Commit bfe35cb

Browse files
authored
Merge pull request #24 from trustwallet/feat/refactor-simulation-result
refactor: convert amount to an array to allow slippage extraction logic
2 parents fe65a61 + 2c905ac commit bfe35cb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/simulator/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class Simulator {
9090
type: NATIVE,
9191
from: call.from,
9292
to: call.to,
93-
amount: BigInt(call.value).toString(),
93+
amounts: [BigInt(call.value).toString()],
9494
id: "",
9595
});
9696
}
@@ -114,7 +114,7 @@ export default class Simulator {
114114
type: ERC20,
115115
from,
116116
to,
117-
amount,
117+
amounts: [amount],
118118
});
119119
} else {
120120
/**
@@ -149,7 +149,7 @@ export default class Simulator {
149149
type: ERC20,
150150
owner,
151151
operator,
152-
amount,
152+
amounts: [amount],
153153
});
154154
}
155155
// ERC721 Approval event have a topics array of 4 elements (eventHash, and 2 indexed addresses and an indexed tokenId)
@@ -197,7 +197,7 @@ export default class Simulator {
197197
from,
198198
to,
199199
operator,
200-
amount: BigInt(amount).toString(),
200+
amounts: [BigInt(amount).toString()],
201201
id: BigInt(id).toString(),
202202
});
203203
}
@@ -219,7 +219,7 @@ export default class Simulator {
219219
from,
220220
to,
221221
operator,
222-
amount: BigInt(amount).toString(),
222+
amounts: [BigInt(amount).toString()],
223223
id: BigInt(id).toString(),
224224
});
225225
});

src/types/simulator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export type DebugCallTracerWithLogs = DebugCallTracerWithLog[];
3535
export type Approval = {
3636
owner: string;
3737
operator: string;
38-
amount?: string;
38+
amounts?: string[];
3939
approveForAllStatus?: boolean;
4040
} & Asset;
4141

4242
export type Transfer = {
4343
from: string;
4444
to: string;
45-
amount?: string;
45+
amounts?: string[];
4646
operator?: string;
4747
} & Asset;
4848

0 commit comments

Comments
 (0)