@ledgerhq/coin-tester-evm 1.6.0 → 1.6.1-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/lib/src/helpers.d.ts +6 -6
- package/lib/src/helpers.d.ts.map +1 -1
- package/lib/src/helpers.js +12 -11
- package/lib/src/helpers.js.map +1 -1
- package/lib/src/indexer.d.ts.map +1 -1
- package/lib/src/indexer.js +193 -184
- package/lib/src/indexer.js.map +1 -1
- package/lib/src/scenarii/blast.d.ts.map +1 -1
- package/lib/src/scenarii/blast.js +8 -8
- package/lib/src/scenarii/blast.js.map +1 -1
- package/lib/src/scenarii/ethereum.d.ts.map +1 -1
- package/lib/src/scenarii/ethereum.js +10 -10
- package/lib/src/scenarii/ethereum.js.map +1 -1
- package/lib/src/scenarii/polygon.d.ts.map +1 -1
- package/lib/src/scenarii/polygon.js +11 -11
- package/lib/src/scenarii/polygon.js.map +1 -1
- package/lib/src/scenarii/scroll.d.ts.map +1 -1
- package/lib/src/scenarii/scroll.js +8 -8
- package/lib/src/scenarii/scroll.js.map +1 -1
- package/lib/src/scenarii/sonic.d.ts.map +1 -1
- package/lib/src/scenarii/sonic.js +8 -8
- package/lib/src/scenarii/sonic.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-es/src/helpers.d.ts +6 -6
- package/lib-es/src/helpers.d.ts.map +1 -1
- package/lib-es/src/helpers.js +12 -11
- package/lib-es/src/helpers.js.map +1 -1
- package/lib-es/src/indexer.d.ts.map +1 -1
- package/lib-es/src/indexer.js +194 -185
- package/lib-es/src/indexer.js.map +1 -1
- package/lib-es/src/scenarii/blast.d.ts.map +1 -1
- package/lib-es/src/scenarii/blast.js +9 -9
- package/lib-es/src/scenarii/blast.js.map +1 -1
- package/lib-es/src/scenarii/ethereum.d.ts.map +1 -1
- package/lib-es/src/scenarii/ethereum.js +11 -11
- package/lib-es/src/scenarii/ethereum.js.map +1 -1
- package/lib-es/src/scenarii/polygon.d.ts.map +1 -1
- package/lib-es/src/scenarii/polygon.js +12 -12
- package/lib-es/src/scenarii/polygon.js.map +1 -1
- package/lib-es/src/scenarii/scroll.d.ts.map +1 -1
- package/lib-es/src/scenarii/scroll.js +9 -9
- package/lib-es/src/scenarii/scroll.js.map +1 -1
- package/lib-es/src/scenarii/sonic.d.ts.map +1 -1
- package/lib-es/src/scenarii/sonic.js +9 -9
- package/lib-es/src/scenarii/sonic.js.map +1 -1
- package/lib-es/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/helpers.ts +15 -14
- package/src/indexer.ts +200 -205
- package/src/scenarii/blast.ts +9 -11
- package/src/scenarii/ethereum.ts +11 -13
- package/src/scenarii/polygon.ts +12 -14
- package/src/scenarii/scroll.ts +9 -11
- package/src/scenarii/sonic.ts +9 -11
package/src/scenarii/blast.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
2
2
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import { ethers
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
4
|
import { Account } from "@ledgerhq/types-live";
|
|
5
5
|
import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
6
6
|
import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
@@ -40,9 +40,7 @@ const makeScenarioTransactions = ({ address }: { address: string }): BlastScenar
|
|
|
40
40
|
const MIM_ON_BLAST = getTokenById(TOKEN_ID);
|
|
41
41
|
const scenarioSendMIMTransaction: BlastScenarioTransaction = {
|
|
42
42
|
name: "Send 80 MIM",
|
|
43
|
-
amount: new BigNumber(
|
|
44
|
-
ethers.utils.parseUnits("80", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
45
|
-
),
|
|
43
|
+
amount: new BigNumber(ethers.parseUnits("80", MIM_ON_BLAST.units[0].magnitude).toString()),
|
|
46
44
|
recipient: VITALIK,
|
|
47
45
|
subAccountId: encodeTokenAccountId(`js:2:blast:${address}:`, MIM_ON_BLAST),
|
|
48
46
|
expect: (previousAccount, currentAccount) => {
|
|
@@ -52,10 +50,10 @@ const makeScenarioTransactions = ({ address }: { address: string }): BlastScenar
|
|
|
52
50
|
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.toFixed());
|
|
53
51
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
54
52
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
55
|
-
ethers.
|
|
53
|
+
ethers.parseUnits("80", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
56
54
|
);
|
|
57
55
|
expect(currentAccount.subAccounts?.[0].balance.toFixed()).toBe(
|
|
58
|
-
ethers.
|
|
56
|
+
ethers.parseUnits("20", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
59
57
|
);
|
|
60
58
|
},
|
|
61
59
|
};
|
|
@@ -71,7 +69,7 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
71
69
|
spawnAnvil("https://rpc.blast.io"),
|
|
72
70
|
]);
|
|
73
71
|
|
|
74
|
-
const provider = new
|
|
72
|
+
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
75
73
|
const signerContext: Parameters<typeof resolver>[0] = (deviceId, fn) =>
|
|
76
74
|
fn(new LegacySignerEth(transport));
|
|
77
75
|
|
|
@@ -115,7 +113,7 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
115
113
|
provider,
|
|
116
114
|
drug: MIM_ON_BLAST,
|
|
117
115
|
junkie: address,
|
|
118
|
-
dose: ethers.
|
|
116
|
+
dose: ethers.parseUnits("100", MIM_ON_BLAST.units[0].magnitude),
|
|
119
117
|
});
|
|
120
118
|
|
|
121
119
|
return {
|
|
@@ -132,17 +130,17 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
132
130
|
},
|
|
133
131
|
beforeAll: account => {
|
|
134
132
|
const MIM_ON_BLAST = getTokenById(TOKEN_ID);
|
|
135
|
-
expect(account.balance.toFixed()).toBe(ethers.
|
|
133
|
+
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
136
134
|
expect(account.subAccounts?.[0]?.type).toBe("TokenAccount");
|
|
137
135
|
expect(account.subAccounts?.[0]?.balance?.toFixed()).toBe(
|
|
138
|
-
ethers.
|
|
136
|
+
ethers.parseUnits("100", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
139
137
|
);
|
|
140
138
|
},
|
|
141
139
|
afterAll: account => {
|
|
142
140
|
const MIM_ON_BLAST = getTokenById(TOKEN_ID);
|
|
143
141
|
expect(account.subAccounts?.length).toBe(1);
|
|
144
142
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
145
|
-
ethers.
|
|
143
|
+
ethers.parseUnits("20", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
146
144
|
);
|
|
147
145
|
expect(account.operations.length).toBe(3);
|
|
148
146
|
},
|
package/src/scenarii/ethereum.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
|
5
5
|
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
6
6
|
import { Account } from "@ledgerhq/types-live";
|
|
7
7
|
import { BigNumber } from "bignumber.js";
|
|
8
|
-
import { ethers
|
|
8
|
+
import { ethers } from "ethers";
|
|
9
9
|
import { makeAccount } from "@ledgerhq/coin-evm/__tests__/fixtures/common.fixtures";
|
|
10
10
|
import { buildAccountBridge, buildCurrencyBridge } from "@ledgerhq/coin-evm/bridge/js";
|
|
11
11
|
import { getCoinConfig, setCoinConfig } from "@ledgerhq/coin-evm/config";
|
|
@@ -52,9 +52,7 @@ const makeScenarioTransactions = ({
|
|
|
52
52
|
|
|
53
53
|
const scenarioSendUSDCTransaction: EthereumScenarioTransaction = {
|
|
54
54
|
name: "Send USDC",
|
|
55
|
-
amount: new BigNumber(
|
|
56
|
-
ethers.utils.parseUnits("80", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
57
|
-
),
|
|
55
|
+
amount: new BigNumber(ethers.parseUnits("80", USDC_ON_ETHEREUM.units[0].magnitude).toString()),
|
|
58
56
|
recipient: VITALIK,
|
|
59
57
|
subAccountId: encodeTokenAccountId(`js:2:ethereum:${address}:`, USDC_ON_ETHEREUM),
|
|
60
58
|
expect: (previousAccount, currentAccount) => {
|
|
@@ -64,10 +62,10 @@ const makeScenarioTransactions = ({
|
|
|
64
62
|
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.toFixed());
|
|
65
63
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
66
64
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
67
|
-
ethers.
|
|
65
|
+
ethers.parseUnits("80", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
68
66
|
);
|
|
69
67
|
expect(currentAccount.subAccounts?.[0].balance.toFixed()).toBe(
|
|
70
|
-
ethers.
|
|
68
|
+
ethers.parseUnits("20", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
71
69
|
);
|
|
72
70
|
},
|
|
73
71
|
};
|
|
@@ -209,7 +207,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
209
207
|
|
|
210
208
|
const scenarioAccount = makeAccount(address, ethereum);
|
|
211
209
|
|
|
212
|
-
const provider = new
|
|
210
|
+
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
213
211
|
|
|
214
212
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
215
213
|
// start indexing at next block
|
|
@@ -220,7 +218,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
220
218
|
provider,
|
|
221
219
|
drug: USDC_ON_ETHEREUM,
|
|
222
220
|
junkie: address,
|
|
223
|
-
dose: ethers.
|
|
221
|
+
dose: ethers.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude),
|
|
224
222
|
});
|
|
225
223
|
|
|
226
224
|
// Get a Bored Ape
|
|
@@ -233,7 +231,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
233
231
|
standard: "ERC721",
|
|
234
232
|
},
|
|
235
233
|
junkie: address,
|
|
236
|
-
dose:
|
|
234
|
+
dose: 1n,
|
|
237
235
|
});
|
|
238
236
|
|
|
239
237
|
// Get 2 CloneX
|
|
@@ -246,7 +244,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
246
244
|
standard: "ERC1155",
|
|
247
245
|
},
|
|
248
246
|
junkie: address,
|
|
249
|
-
dose:
|
|
247
|
+
dose: 2n,
|
|
250
248
|
});
|
|
251
249
|
|
|
252
250
|
return {
|
|
@@ -257,10 +255,10 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
257
255
|
};
|
|
258
256
|
},
|
|
259
257
|
beforeAll: account => {
|
|
260
|
-
expect(account.balance.toFixed()).toBe(ethers.
|
|
258
|
+
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
261
259
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
262
260
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
263
|
-
ethers.
|
|
261
|
+
ethers.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
264
262
|
);
|
|
265
263
|
expect(account.nfts?.length).toBe(2);
|
|
266
264
|
},
|
|
@@ -271,7 +269,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
271
269
|
afterAll: account => {
|
|
272
270
|
expect(account.subAccounts?.length).toBe(1);
|
|
273
271
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
274
|
-
ethers.
|
|
272
|
+
ethers.parseUnits("20", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
275
273
|
);
|
|
276
274
|
expect(account.nfts?.length).toBe(0);
|
|
277
275
|
expect(account.operations.length).toBe(7);
|
package/src/scenarii/polygon.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
2
2
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import { ethers
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
4
|
import { Account } from "@ledgerhq/types-live";
|
|
5
5
|
import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
6
6
|
import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
@@ -30,8 +30,8 @@ const platinumTokenId = "4";
|
|
|
30
30
|
const makeScenarioTransactions = ({ address }: { address: string }) => {
|
|
31
31
|
const send1MaticTransaction: PolygonScenarioTransaction = {
|
|
32
32
|
name: "Send 1 POL",
|
|
33
|
-
amount: new BigNumber(ethers.
|
|
34
|
-
recipient: ethers.
|
|
33
|
+
amount: new BigNumber(ethers.parseEther("1").toString()),
|
|
34
|
+
recipient: ethers.ZeroAddress,
|
|
35
35
|
expect: (previousAccount, currentAccount) => {
|
|
36
36
|
const [latestOperation] = currentAccount.operations;
|
|
37
37
|
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
@@ -51,9 +51,7 @@ const makeScenarioTransactions = ({ address }: { address: string }) => {
|
|
|
51
51
|
const send80USDCTransaction: PolygonScenarioTransaction = {
|
|
52
52
|
name: "Send 80 USDC",
|
|
53
53
|
recipient: VITALIK,
|
|
54
|
-
amount: new BigNumber(
|
|
55
|
-
ethers.utils.parseUnits("80", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
56
|
-
),
|
|
54
|
+
amount: new BigNumber(ethers.parseUnits("80", USDC_ON_POLYGON.units[0].magnitude).toString()),
|
|
57
55
|
subAccountId: encodeTokenAccountId(`js:2:polygon:${address}:`, USDC_ON_POLYGON),
|
|
58
56
|
expect: (previousAccount, currentAccount) => {
|
|
59
57
|
const [latestOperation] = currentAccount.operations;
|
|
@@ -61,7 +59,7 @@ const makeScenarioTransactions = ({ address }: { address: string }) => {
|
|
|
61
59
|
expect(latestOperation.type).toBe("FEES");
|
|
62
60
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
63
61
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
64
|
-
ethers.
|
|
62
|
+
ethers.parseUnits("80", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
65
63
|
);
|
|
66
64
|
},
|
|
67
65
|
};
|
|
@@ -130,7 +128,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
130
128
|
spawnAnvil("https://polygon-bor-rpc.publicnode.com"),
|
|
131
129
|
]);
|
|
132
130
|
|
|
133
|
-
const provider = new
|
|
131
|
+
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
134
132
|
const signerContext: Parameters<typeof resolver>[0] = (_, fn) =>
|
|
135
133
|
fn(new LegacySignerEth(transport));
|
|
136
134
|
|
|
@@ -208,7 +206,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
208
206
|
provider,
|
|
209
207
|
drug: USDC_ON_POLYGON,
|
|
210
208
|
junkie: address,
|
|
211
|
-
dose: ethers.
|
|
209
|
+
dose: ethers.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude),
|
|
212
210
|
});
|
|
213
211
|
|
|
214
212
|
// Get 1 yoot
|
|
@@ -221,7 +219,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
221
219
|
standard: "ERC721",
|
|
222
220
|
},
|
|
223
221
|
junkie: address,
|
|
224
|
-
dose:
|
|
222
|
+
dose: 1n,
|
|
225
223
|
});
|
|
226
224
|
|
|
227
225
|
await callMyDealer({
|
|
@@ -233,7 +231,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
233
231
|
standard: "ERC1155",
|
|
234
232
|
},
|
|
235
233
|
junkie: address,
|
|
236
|
-
dose:
|
|
234
|
+
dose: 10n,
|
|
237
235
|
});
|
|
238
236
|
|
|
239
237
|
return { currencyBridge, accountBridge, account: scenarioAccount, onSignerConfirmation };
|
|
@@ -243,17 +241,17 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
243
241
|
await indexBlocks();
|
|
244
242
|
},
|
|
245
243
|
beforeAll: account => {
|
|
246
|
-
expect(account.balance.toFixed()).toBe(ethers.
|
|
244
|
+
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
247
245
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
248
246
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
249
|
-
ethers.
|
|
247
|
+
ethers.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
250
248
|
);
|
|
251
249
|
expect(account.nfts?.length).toBe(2);
|
|
252
250
|
},
|
|
253
251
|
afterAll: account => {
|
|
254
252
|
expect(account.subAccounts?.length).toBe(1);
|
|
255
253
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
256
|
-
ethers.
|
|
254
|
+
ethers.parseUnits("20", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
257
255
|
);
|
|
258
256
|
expect(account.nfts?.length).toBe(0);
|
|
259
257
|
expect(account.operations.length).toBe(7);
|
package/src/scenarii/scroll.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
2
2
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import { ethers
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
4
|
import { Account } from "@ledgerhq/types-live";
|
|
5
5
|
import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
6
6
|
import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
@@ -44,9 +44,7 @@ const makeScenarioTransactions = ({
|
|
|
44
44
|
const USDC_ON_SCROLL = getTokenById("scroll/erc20/usd_coin");
|
|
45
45
|
const scenarioSendUSDCTransaction: ScrollScenarioTransaction = {
|
|
46
46
|
name: "Send USDC",
|
|
47
|
-
amount: new BigNumber(
|
|
48
|
-
ethers.utils.parseUnits("80", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
49
|
-
),
|
|
47
|
+
amount: new BigNumber(ethers.parseUnits("80", USDC_ON_SCROLL.units[0].magnitude).toString()),
|
|
50
48
|
recipient: VITALIK,
|
|
51
49
|
subAccountId: encodeTokenAccountId(`js:2:scroll:${address}:`, USDC_ON_SCROLL),
|
|
52
50
|
expect: (previousAccount, currentAccount) => {
|
|
@@ -56,10 +54,10 @@ const makeScenarioTransactions = ({
|
|
|
56
54
|
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.toFixed());
|
|
57
55
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
58
56
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
59
|
-
ethers.
|
|
57
|
+
ethers.parseUnits("80", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
60
58
|
);
|
|
61
59
|
expect(currentAccount.subAccounts?.[0].balance.toFixed()).toBe(
|
|
62
|
-
ethers.
|
|
60
|
+
ethers.parseUnits("20", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
63
61
|
);
|
|
64
62
|
},
|
|
65
63
|
};
|
|
@@ -75,7 +73,7 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
75
73
|
spawnAnvil("https://rpc.scroll.io"),
|
|
76
74
|
]);
|
|
77
75
|
|
|
78
|
-
const provider = new
|
|
76
|
+
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
79
77
|
const signerContext: Parameters<typeof resolver>[0] = (deviceId, fn) =>
|
|
80
78
|
fn(new LegacySignerEth(transport));
|
|
81
79
|
|
|
@@ -119,7 +117,7 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
119
117
|
provider,
|
|
120
118
|
drug: USDC_ON_SCROLL,
|
|
121
119
|
junkie: address,
|
|
122
|
-
dose: ethers.
|
|
120
|
+
dose: ethers.parseUnits("100", USDC_ON_SCROLL.units[0].magnitude),
|
|
123
121
|
});
|
|
124
122
|
|
|
125
123
|
return {
|
|
@@ -136,17 +134,17 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
136
134
|
},
|
|
137
135
|
beforeAll: account => {
|
|
138
136
|
const USDC_ON_SCROLL = getTokenById(TOKEN_ID);
|
|
139
|
-
expect(account.balance.toFixed()).toBe(ethers.
|
|
137
|
+
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
140
138
|
expect(account.subAccounts?.[0]?.type).toBe("TokenAccount");
|
|
141
139
|
expect(account.subAccounts?.[0]?.balance?.toFixed()).toBe(
|
|
142
|
-
ethers.
|
|
140
|
+
ethers.parseUnits("100", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
143
141
|
);
|
|
144
142
|
},
|
|
145
143
|
afterAll: account => {
|
|
146
144
|
const USDC_ON_SCROLL = getTokenById(TOKEN_ID);
|
|
147
145
|
expect(account.subAccounts?.length).toBe(1);
|
|
148
146
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
149
|
-
ethers.
|
|
147
|
+
ethers.parseUnits("20", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
150
148
|
);
|
|
151
149
|
expect(account.operations.length).toBe(3);
|
|
152
150
|
},
|
package/src/scenarii/sonic.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
2
2
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import { ethers
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
4
|
import { Account } from "@ledgerhq/types-live";
|
|
5
5
|
import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
6
6
|
import { encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
@@ -43,9 +43,7 @@ const makeScenarioTransactions = ({ address }: { address: string }): SonicScenar
|
|
|
43
43
|
|
|
44
44
|
const scenarioSendUSDCTransaction: SonicScenarioTransaction = {
|
|
45
45
|
name: "Send USDC",
|
|
46
|
-
amount: new BigNumber(
|
|
47
|
-
ethers.utils.parseUnits("80", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
48
|
-
),
|
|
46
|
+
amount: new BigNumber(ethers.parseUnits("80", USDC_ON_SONIC.units[0].magnitude).toString()),
|
|
49
47
|
recipient: VITALIK,
|
|
50
48
|
subAccountId: encodeTokenAccountId(`js:2:sonic:${address}:`, USDC_ON_SONIC),
|
|
51
49
|
expect: (previousAccount, currentAccount) => {
|
|
@@ -55,10 +53,10 @@ const makeScenarioTransactions = ({ address }: { address: string }): SonicScenar
|
|
|
55
53
|
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.toFixed());
|
|
56
54
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
57
55
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
58
|
-
ethers.
|
|
56
|
+
ethers.parseUnits("80", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
59
57
|
);
|
|
60
58
|
expect(currentAccount.subAccounts?.[0].balance.toFixed()).toBe(
|
|
61
|
-
ethers.
|
|
59
|
+
ethers.parseUnits("20", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
62
60
|
);
|
|
63
61
|
},
|
|
64
62
|
};
|
|
@@ -140,7 +138,7 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
140
138
|
|
|
141
139
|
const scenarioAccount = makeAccount(address, sonic);
|
|
142
140
|
|
|
143
|
-
const provider = new
|
|
141
|
+
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
144
142
|
|
|
145
143
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
146
144
|
// start indexing at next block
|
|
@@ -151,7 +149,7 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
151
149
|
provider,
|
|
152
150
|
drug: USDC_ON_SONIC,
|
|
153
151
|
junkie: address,
|
|
154
|
-
dose: ethers.
|
|
152
|
+
dose: ethers.parseUnits("100", USDC_ON_SONIC.units[0].magnitude),
|
|
155
153
|
});
|
|
156
154
|
|
|
157
155
|
return {
|
|
@@ -162,10 +160,10 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
162
160
|
};
|
|
163
161
|
},
|
|
164
162
|
beforeAll: account => {
|
|
165
|
-
expect(account.balance.toFixed()).toBe(ethers.
|
|
163
|
+
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
166
164
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
167
165
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
168
|
-
ethers.
|
|
166
|
+
ethers.parseUnits("100", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
169
167
|
);
|
|
170
168
|
},
|
|
171
169
|
getTransactions: address => makeScenarioTransactions({ address }),
|
|
@@ -175,7 +173,7 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
175
173
|
afterAll: account => {
|
|
176
174
|
expect(account.subAccounts?.length).toBe(1);
|
|
177
175
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
178
|
-
ethers.
|
|
176
|
+
ethers.parseUnits("20", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
179
177
|
);
|
|
180
178
|
// expect(account.operations.length).toBe(3);
|
|
181
179
|
},
|