@ledgerhq/coin-tester-evm 1.6.0-nightly.8 → 1.6.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +41 -59
- package/lib/src/helpers.d.ts +6 -6
- package/lib/src/helpers.d.ts.map +1 -1
- package/lib/src/helpers.js +11 -12
- package/lib/src/helpers.js.map +1 -1
- package/lib/src/indexer.d.ts.map +1 -1
- package/lib/src/indexer.js +184 -193
- 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 +11 -12
- 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 +185 -194
- 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 +11 -11
- package/src/helpers.ts +14 -15
- package/src/indexer.ts +205 -200
- package/src/scenarii/blast.ts +11 -9
- package/src/scenarii/ethereum.ts +13 -11
- package/src/scenarii/polygon.ts +14 -12
- package/src/scenarii/scroll.ts +11 -9
- package/src/scenarii/sonic.ts +11 -9
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 } from "ethers";
|
|
3
|
+
import { ethers, providers } 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,7 +40,9 @@ 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(
|
|
43
|
+
amount: new BigNumber(
|
|
44
|
+
ethers.utils.parseUnits("80", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
45
|
+
),
|
|
44
46
|
recipient: VITALIK,
|
|
45
47
|
subAccountId: encodeTokenAccountId(`js:2:blast:${address}:`, MIM_ON_BLAST),
|
|
46
48
|
expect: (previousAccount, currentAccount) => {
|
|
@@ -50,10 +52,10 @@ const makeScenarioTransactions = ({ address }: { address: string }): BlastScenar
|
|
|
50
52
|
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.toFixed());
|
|
51
53
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
52
54
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
53
|
-
ethers.parseUnits("80", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
55
|
+
ethers.utils.parseUnits("80", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
54
56
|
);
|
|
55
57
|
expect(currentAccount.subAccounts?.[0].balance.toFixed()).toBe(
|
|
56
|
-
ethers.parseUnits("20", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
58
|
+
ethers.utils.parseUnits("20", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
57
59
|
);
|
|
58
60
|
},
|
|
59
61
|
};
|
|
@@ -69,7 +71,7 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
69
71
|
spawnAnvil("https://rpc.blast.io"),
|
|
70
72
|
]);
|
|
71
73
|
|
|
72
|
-
const provider = new
|
|
74
|
+
const provider = new providers.StaticJsonRpcProvider("http://127.0.0.1:8545");
|
|
73
75
|
const signerContext: Parameters<typeof resolver>[0] = (deviceId, fn) =>
|
|
74
76
|
fn(new LegacySignerEth(transport));
|
|
75
77
|
|
|
@@ -113,7 +115,7 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
113
115
|
provider,
|
|
114
116
|
drug: MIM_ON_BLAST,
|
|
115
117
|
junkie: address,
|
|
116
|
-
dose: ethers.parseUnits("100", MIM_ON_BLAST.units[0].magnitude),
|
|
118
|
+
dose: ethers.utils.parseUnits("100", MIM_ON_BLAST.units[0].magnitude),
|
|
117
119
|
});
|
|
118
120
|
|
|
119
121
|
return {
|
|
@@ -130,17 +132,17 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
130
132
|
},
|
|
131
133
|
beforeAll: account => {
|
|
132
134
|
const MIM_ON_BLAST = getTokenById(TOKEN_ID);
|
|
133
|
-
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
135
|
+
expect(account.balance.toFixed()).toBe(ethers.utils.parseEther("10000").toString());
|
|
134
136
|
expect(account.subAccounts?.[0]?.type).toBe("TokenAccount");
|
|
135
137
|
expect(account.subAccounts?.[0]?.balance?.toFixed()).toBe(
|
|
136
|
-
ethers.parseUnits("100", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
138
|
+
ethers.utils.parseUnits("100", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
137
139
|
);
|
|
138
140
|
},
|
|
139
141
|
afterAll: account => {
|
|
140
142
|
const MIM_ON_BLAST = getTokenById(TOKEN_ID);
|
|
141
143
|
expect(account.subAccounts?.length).toBe(1);
|
|
142
144
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
143
|
-
ethers.parseUnits("20", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
145
|
+
ethers.utils.parseUnits("20", MIM_ON_BLAST.units[0].magnitude).toString(),
|
|
144
146
|
);
|
|
145
147
|
expect(account.operations.length).toBe(3);
|
|
146
148
|
},
|
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 } from "ethers";
|
|
8
|
+
import { ethers, providers } 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,7 +52,9 @@ const makeScenarioTransactions = ({
|
|
|
52
52
|
|
|
53
53
|
const scenarioSendUSDCTransaction: EthereumScenarioTransaction = {
|
|
54
54
|
name: "Send USDC",
|
|
55
|
-
amount: new BigNumber(
|
|
55
|
+
amount: new BigNumber(
|
|
56
|
+
ethers.utils.parseUnits("80", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
57
|
+
),
|
|
56
58
|
recipient: VITALIK,
|
|
57
59
|
subAccountId: encodeTokenAccountId(`js:2:ethereum:${address}:`, USDC_ON_ETHEREUM),
|
|
58
60
|
expect: (previousAccount, currentAccount) => {
|
|
@@ -62,10 +64,10 @@ const makeScenarioTransactions = ({
|
|
|
62
64
|
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.toFixed());
|
|
63
65
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
64
66
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
65
|
-
ethers.parseUnits("80", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
67
|
+
ethers.utils.parseUnits("80", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
66
68
|
);
|
|
67
69
|
expect(currentAccount.subAccounts?.[0].balance.toFixed()).toBe(
|
|
68
|
-
ethers.parseUnits("20", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
70
|
+
ethers.utils.parseUnits("20", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
69
71
|
);
|
|
70
72
|
},
|
|
71
73
|
};
|
|
@@ -207,7 +209,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
207
209
|
|
|
208
210
|
const scenarioAccount = makeAccount(address, ethereum);
|
|
209
211
|
|
|
210
|
-
const provider = new
|
|
212
|
+
const provider = new providers.StaticJsonRpcProvider("http://127.0.0.1:8545");
|
|
211
213
|
|
|
212
214
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
213
215
|
// start indexing at next block
|
|
@@ -218,7 +220,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
218
220
|
provider,
|
|
219
221
|
drug: USDC_ON_ETHEREUM,
|
|
220
222
|
junkie: address,
|
|
221
|
-
dose: ethers.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude),
|
|
223
|
+
dose: ethers.utils.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude),
|
|
222
224
|
});
|
|
223
225
|
|
|
224
226
|
// Get a Bored Ape
|
|
@@ -231,7 +233,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
231
233
|
standard: "ERC721",
|
|
232
234
|
},
|
|
233
235
|
junkie: address,
|
|
234
|
-
dose:
|
|
236
|
+
dose: ethers.BigNumber.from(1),
|
|
235
237
|
});
|
|
236
238
|
|
|
237
239
|
// Get 2 CloneX
|
|
@@ -244,7 +246,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
244
246
|
standard: "ERC1155",
|
|
245
247
|
},
|
|
246
248
|
junkie: address,
|
|
247
|
-
dose:
|
|
249
|
+
dose: ethers.BigNumber.from(2),
|
|
248
250
|
});
|
|
249
251
|
|
|
250
252
|
return {
|
|
@@ -255,10 +257,10 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
255
257
|
};
|
|
256
258
|
},
|
|
257
259
|
beforeAll: account => {
|
|
258
|
-
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
260
|
+
expect(account.balance.toFixed()).toBe(ethers.utils.parseEther("10000").toString());
|
|
259
261
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
260
262
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
261
|
-
ethers.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
263
|
+
ethers.utils.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
262
264
|
);
|
|
263
265
|
expect(account.nfts?.length).toBe(2);
|
|
264
266
|
},
|
|
@@ -269,7 +271,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
269
271
|
afterAll: account => {
|
|
270
272
|
expect(account.subAccounts?.length).toBe(1);
|
|
271
273
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
272
|
-
ethers.parseUnits("20", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
274
|
+
ethers.utils.parseUnits("20", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
273
275
|
);
|
|
274
276
|
expect(account.nfts?.length).toBe(0);
|
|
275
277
|
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 } from "ethers";
|
|
3
|
+
import { ethers, providers } 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.parseEther("1").toString()),
|
|
34
|
-
recipient: ethers.
|
|
33
|
+
amount: new BigNumber(ethers.utils.parseEther("1").toString()),
|
|
34
|
+
recipient: ethers.constants.AddressZero,
|
|
35
35
|
expect: (previousAccount, currentAccount) => {
|
|
36
36
|
const [latestOperation] = currentAccount.operations;
|
|
37
37
|
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
@@ -51,7 +51,9 @@ const makeScenarioTransactions = ({ address }: { address: string }) => {
|
|
|
51
51
|
const send80USDCTransaction: PolygonScenarioTransaction = {
|
|
52
52
|
name: "Send 80 USDC",
|
|
53
53
|
recipient: VITALIK,
|
|
54
|
-
amount: new BigNumber(
|
|
54
|
+
amount: new BigNumber(
|
|
55
|
+
ethers.utils.parseUnits("80", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
56
|
+
),
|
|
55
57
|
subAccountId: encodeTokenAccountId(`js:2:polygon:${address}:`, USDC_ON_POLYGON),
|
|
56
58
|
expect: (previousAccount, currentAccount) => {
|
|
57
59
|
const [latestOperation] = currentAccount.operations;
|
|
@@ -59,7 +61,7 @@ const makeScenarioTransactions = ({ address }: { address: string }) => {
|
|
|
59
61
|
expect(latestOperation.type).toBe("FEES");
|
|
60
62
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
61
63
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
62
|
-
ethers.parseUnits("80", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
64
|
+
ethers.utils.parseUnits("80", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
63
65
|
);
|
|
64
66
|
},
|
|
65
67
|
};
|
|
@@ -128,7 +130,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
128
130
|
spawnAnvil("https://polygon-bor-rpc.publicnode.com"),
|
|
129
131
|
]);
|
|
130
132
|
|
|
131
|
-
const provider = new
|
|
133
|
+
const provider = new providers.StaticJsonRpcProvider("http://127.0.0.1:8545");
|
|
132
134
|
const signerContext: Parameters<typeof resolver>[0] = (_, fn) =>
|
|
133
135
|
fn(new LegacySignerEth(transport));
|
|
134
136
|
|
|
@@ -206,7 +208,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
206
208
|
provider,
|
|
207
209
|
drug: USDC_ON_POLYGON,
|
|
208
210
|
junkie: address,
|
|
209
|
-
dose: ethers.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude),
|
|
211
|
+
dose: ethers.utils.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude),
|
|
210
212
|
});
|
|
211
213
|
|
|
212
214
|
// Get 1 yoot
|
|
@@ -219,7 +221,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
219
221
|
standard: "ERC721",
|
|
220
222
|
},
|
|
221
223
|
junkie: address,
|
|
222
|
-
dose:
|
|
224
|
+
dose: ethers.BigNumber.from(1),
|
|
223
225
|
});
|
|
224
226
|
|
|
225
227
|
await callMyDealer({
|
|
@@ -231,7 +233,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
231
233
|
standard: "ERC1155",
|
|
232
234
|
},
|
|
233
235
|
junkie: address,
|
|
234
|
-
dose:
|
|
236
|
+
dose: ethers.BigNumber.from(10),
|
|
235
237
|
});
|
|
236
238
|
|
|
237
239
|
return { currencyBridge, accountBridge, account: scenarioAccount, onSignerConfirmation };
|
|
@@ -241,17 +243,17 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
241
243
|
await indexBlocks();
|
|
242
244
|
},
|
|
243
245
|
beforeAll: account => {
|
|
244
|
-
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
246
|
+
expect(account.balance.toFixed()).toBe(ethers.utils.parseEther("10000").toString());
|
|
245
247
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
246
248
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
247
|
-
ethers.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
249
|
+
ethers.utils.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
248
250
|
);
|
|
249
251
|
expect(account.nfts?.length).toBe(2);
|
|
250
252
|
},
|
|
251
253
|
afterAll: account => {
|
|
252
254
|
expect(account.subAccounts?.length).toBe(1);
|
|
253
255
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
254
|
-
ethers.parseUnits("20", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
256
|
+
ethers.utils.parseUnits("20", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
255
257
|
);
|
|
256
258
|
expect(account.nfts?.length).toBe(0);
|
|
257
259
|
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 } from "ethers";
|
|
3
|
+
import { ethers, providers } 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,7 +44,9 @@ 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(
|
|
47
|
+
amount: new BigNumber(
|
|
48
|
+
ethers.utils.parseUnits("80", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
49
|
+
),
|
|
48
50
|
recipient: VITALIK,
|
|
49
51
|
subAccountId: encodeTokenAccountId(`js:2:scroll:${address}:`, USDC_ON_SCROLL),
|
|
50
52
|
expect: (previousAccount, currentAccount) => {
|
|
@@ -54,10 +56,10 @@ const makeScenarioTransactions = ({
|
|
|
54
56
|
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.toFixed());
|
|
55
57
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
56
58
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
57
|
-
ethers.parseUnits("80", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
59
|
+
ethers.utils.parseUnits("80", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
58
60
|
);
|
|
59
61
|
expect(currentAccount.subAccounts?.[0].balance.toFixed()).toBe(
|
|
60
|
-
ethers.parseUnits("20", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
62
|
+
ethers.utils.parseUnits("20", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
61
63
|
);
|
|
62
64
|
},
|
|
63
65
|
};
|
|
@@ -73,7 +75,7 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
73
75
|
spawnAnvil("https://rpc.scroll.io"),
|
|
74
76
|
]);
|
|
75
77
|
|
|
76
|
-
const provider = new
|
|
78
|
+
const provider = new providers.StaticJsonRpcProvider("http://127.0.0.1:8545");
|
|
77
79
|
const signerContext: Parameters<typeof resolver>[0] = (deviceId, fn) =>
|
|
78
80
|
fn(new LegacySignerEth(transport));
|
|
79
81
|
|
|
@@ -117,7 +119,7 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
117
119
|
provider,
|
|
118
120
|
drug: USDC_ON_SCROLL,
|
|
119
121
|
junkie: address,
|
|
120
|
-
dose: ethers.parseUnits("100", USDC_ON_SCROLL.units[0].magnitude),
|
|
122
|
+
dose: ethers.utils.parseUnits("100", USDC_ON_SCROLL.units[0].magnitude),
|
|
121
123
|
});
|
|
122
124
|
|
|
123
125
|
return {
|
|
@@ -134,17 +136,17 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
134
136
|
},
|
|
135
137
|
beforeAll: account => {
|
|
136
138
|
const USDC_ON_SCROLL = getTokenById(TOKEN_ID);
|
|
137
|
-
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
139
|
+
expect(account.balance.toFixed()).toBe(ethers.utils.parseEther("10000").toString());
|
|
138
140
|
expect(account.subAccounts?.[0]?.type).toBe("TokenAccount");
|
|
139
141
|
expect(account.subAccounts?.[0]?.balance?.toFixed()).toBe(
|
|
140
|
-
ethers.parseUnits("100", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
142
|
+
ethers.utils.parseUnits("100", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
141
143
|
);
|
|
142
144
|
},
|
|
143
145
|
afterAll: account => {
|
|
144
146
|
const USDC_ON_SCROLL = getTokenById(TOKEN_ID);
|
|
145
147
|
expect(account.subAccounts?.length).toBe(1);
|
|
146
148
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
147
|
-
ethers.parseUnits("20", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
149
|
+
ethers.utils.parseUnits("20", USDC_ON_SCROLL.units[0].magnitude).toString(),
|
|
148
150
|
);
|
|
149
151
|
expect(account.operations.length).toBe(3);
|
|
150
152
|
},
|
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 } from "ethers";
|
|
3
|
+
import { ethers, providers } 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,7 +43,9 @@ const makeScenarioTransactions = ({ address }: { address: string }): SonicScenar
|
|
|
43
43
|
|
|
44
44
|
const scenarioSendUSDCTransaction: SonicScenarioTransaction = {
|
|
45
45
|
name: "Send USDC",
|
|
46
|
-
amount: new BigNumber(
|
|
46
|
+
amount: new BigNumber(
|
|
47
|
+
ethers.utils.parseUnits("80", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
48
|
+
),
|
|
47
49
|
recipient: VITALIK,
|
|
48
50
|
subAccountId: encodeTokenAccountId(`js:2:sonic:${address}:`, USDC_ON_SONIC),
|
|
49
51
|
expect: (previousAccount, currentAccount) => {
|
|
@@ -53,10 +55,10 @@ const makeScenarioTransactions = ({ address }: { address: string }): SonicScenar
|
|
|
53
55
|
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.toFixed());
|
|
54
56
|
expect(latestOperation.subOperations?.[0].type).toBe("OUT");
|
|
55
57
|
expect(latestOperation.subOperations?.[0].value.toFixed()).toBe(
|
|
56
|
-
ethers.parseUnits("80", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
58
|
+
ethers.utils.parseUnits("80", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
57
59
|
);
|
|
58
60
|
expect(currentAccount.subAccounts?.[0].balance.toFixed()).toBe(
|
|
59
|
-
ethers.parseUnits("20", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
61
|
+
ethers.utils.parseUnits("20", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
60
62
|
);
|
|
61
63
|
},
|
|
62
64
|
};
|
|
@@ -138,7 +140,7 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
138
140
|
|
|
139
141
|
const scenarioAccount = makeAccount(address, sonic);
|
|
140
142
|
|
|
141
|
-
const provider = new
|
|
143
|
+
const provider = new providers.StaticJsonRpcProvider("http://127.0.0.1:8545");
|
|
142
144
|
|
|
143
145
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
144
146
|
// start indexing at next block
|
|
@@ -149,7 +151,7 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
149
151
|
provider,
|
|
150
152
|
drug: USDC_ON_SONIC,
|
|
151
153
|
junkie: address,
|
|
152
|
-
dose: ethers.parseUnits("100", USDC_ON_SONIC.units[0].magnitude),
|
|
154
|
+
dose: ethers.utils.parseUnits("100", USDC_ON_SONIC.units[0].magnitude),
|
|
153
155
|
});
|
|
154
156
|
|
|
155
157
|
return {
|
|
@@ -160,10 +162,10 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
160
162
|
};
|
|
161
163
|
},
|
|
162
164
|
beforeAll: account => {
|
|
163
|
-
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
165
|
+
expect(account.balance.toFixed()).toBe(ethers.utils.parseEther("10000").toString());
|
|
164
166
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
165
167
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
166
|
-
ethers.parseUnits("100", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
168
|
+
ethers.utils.parseUnits("100", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
167
169
|
);
|
|
168
170
|
},
|
|
169
171
|
getTransactions: address => makeScenarioTransactions({ address }),
|
|
@@ -173,7 +175,7 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
173
175
|
afterAll: account => {
|
|
174
176
|
expect(account.subAccounts?.length).toBe(1);
|
|
175
177
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
176
|
-
ethers.parseUnits("20", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
178
|
+
ethers.utils.parseUnits("20", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
177
179
|
);
|
|
178
180
|
// expect(account.operations.length).toBe(3);
|
|
179
181
|
},
|