@ledgerhq/coin-tester-evm 1.7.1 → 1.7.2-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 +13 -0
- package/lib/src/helpers.d.ts +10 -1
- package/lib/src/helpers.d.ts.map +1 -1
- package/lib/src/helpers.js +27 -0
- package/lib/src/helpers.js.map +1 -1
- package/lib/src/scenarii/blast.d.ts.map +1 -1
- package/lib/src/scenarii/blast.js +2 -2
- 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 -24
- 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 +8 -24
- 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 +2 -2
- 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 +1 -16
- package/lib/src/scenarii/sonic.js.map +1 -1
- package/lib/src/scenarii.test.js +4 -4
- package/lib/src/scenarii.test.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-es/src/helpers.d.ts +10 -1
- package/lib-es/src/helpers.d.ts.map +1 -1
- package/lib-es/src/helpers.js +23 -0
- package/lib-es/src/helpers.js.map +1 -1
- package/lib-es/src/scenarii/blast.d.ts.map +1 -1
- package/lib-es/src/scenarii/blast.js +2 -2
- 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 -22
- 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 +9 -22
- 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 +2 -2
- 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 +2 -14
- package/lib-es/src/scenarii/sonic.js.map +1 -1
- package/lib-es/src/scenarii.test.js +4 -4
- package/lib-es/src/scenarii.test.js.map +1 -1
- package/lib-es/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -10
- package/src/helpers.ts +42 -1
- package/src/scenarii/blast.ts +4 -3
- package/src/scenarii/ethereum.ts +17 -25
- package/src/scenarii/polygon.ts +20 -25
- package/src/scenarii/scroll.ts +4 -3
- package/src/scenarii/sonic.ts +2 -18
- package/src/scenarii.test.ts +50 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-tester-evm",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2-nightly.0",
|
|
4
4
|
"description": "Ledger EVM Coin Tester",
|
|
5
5
|
"main": "src/scenarii.test.ts",
|
|
6
6
|
"keywords": [
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"dotenv": "^16.4.5",
|
|
52
52
|
"ethers": "6.15.0",
|
|
53
53
|
"msw": "^2.2.1",
|
|
54
|
-
"@ledgerhq/coin-evm": "^2.
|
|
55
|
-
"@ledgerhq/coin-framework": "^6.4.0",
|
|
56
|
-
"@ledgerhq/coin-tester": "^0.9.
|
|
57
|
-
"@ledgerhq/cryptoassets": "^13.28.0",
|
|
58
|
-
"@ledgerhq/live-common": "^34.
|
|
54
|
+
"@ledgerhq/coin-evm": "^2.31.0-nightly.0",
|
|
55
|
+
"@ledgerhq/coin-framework": "^6.4.1-nightly.0",
|
|
56
|
+
"@ledgerhq/coin-tester": "^0.9.4-nightly.0",
|
|
57
|
+
"@ledgerhq/cryptoassets": "^13.28.1-nightly.0",
|
|
58
|
+
"@ledgerhq/live-common": "^34.49.0-nightly.0",
|
|
59
59
|
"@ledgerhq/live-config": "^3.2.0",
|
|
60
|
-
"@ledgerhq/live-signer-evm": "^0.7.
|
|
61
|
-
"@ledgerhq/types-cryptoassets": "^7.
|
|
62
|
-
"@ledgerhq/types-live": "^6.
|
|
60
|
+
"@ledgerhq/live-signer-evm": "^0.7.6-nightly.0",
|
|
61
|
+
"@ledgerhq/types-cryptoassets": "^7.27.0-nightly.0",
|
|
62
|
+
"@ledgerhq/types-live": "^6.85.0-nightly.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@swc/core": "1.4.11",
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
"rimraf": "^5.0.5",
|
|
72
72
|
"ts-jest": "^29.1.2",
|
|
73
73
|
"ts-node": "^10.9.2",
|
|
74
|
-
"typescript": "^5.3.3"
|
|
74
|
+
"typescript": "^5.3.3",
|
|
75
|
+
"@ledgerhq/hw-transport": "^6.31.11-nightly.0"
|
|
75
76
|
},
|
|
76
77
|
"scripts": {
|
|
77
78
|
"clean": "rimraf lib lib-es",
|
package/src/helpers.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
import type Transport from "@ledgerhq/hw-transport";
|
|
1
2
|
import { ethers } from "ethers";
|
|
2
|
-
import { NFTStandard } from "@ledgerhq/types-live";
|
|
3
|
+
import { AccountBridge, CurrencyBridge, NFTStandard } from "@ledgerhq/types-live";
|
|
3
4
|
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
5
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
5
6
|
import { ERC20_ABI, ERC721_ABI, ERC1155_ABI } from "@ledgerhq/coin-evm/abis/index";
|
|
7
|
+
import { BridgeStrategy } from "@ledgerhq/coin-tester/types";
|
|
8
|
+
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
|
9
|
+
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
10
|
+
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
11
|
+
import { EvmSigner } from "@ledgerhq/coin-evm/types/signer";
|
|
12
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
13
|
+
import { buildAccountBridge, buildCurrencyBridge } from "@ledgerhq/coin-evm/bridge/js";
|
|
14
|
+
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
15
|
+
import { Signer, createSigner } from "@ledgerhq/live-common/bridge/generic-alpaca/signer/Eth";
|
|
16
|
+
import { getAlpacaCurrencyBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/currencyBridge";
|
|
17
|
+
import { getAlpacaAccountBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/accountBridge";
|
|
6
18
|
|
|
7
19
|
export const ethereum = getCryptoCurrencyById("ethereum");
|
|
8
20
|
export const sonic = getCryptoCurrencyById("sonic");
|
|
@@ -14,6 +26,35 @@ export const ERC721Interface = new ethers.Interface(ERC721_ABI);
|
|
|
14
26
|
export const ERC1155Interface = new ethers.Interface(ERC1155_ABI);
|
|
15
27
|
export const VITALIK = "0x6bfD74C0996F269Bcece59191EFf667b3dFD73b9";
|
|
16
28
|
|
|
29
|
+
export function getBridges(
|
|
30
|
+
strategy: BridgeStrategy,
|
|
31
|
+
transport: Transport,
|
|
32
|
+
network: string,
|
|
33
|
+
): {
|
|
34
|
+
currencyBridge: CurrencyBridge;
|
|
35
|
+
accountBridge: AccountBridge<EvmTransaction>;
|
|
36
|
+
getAddress: GetAddressFn;
|
|
37
|
+
} {
|
|
38
|
+
if (strategy === "legacy") {
|
|
39
|
+
const context: SignerContext<EvmSigner> = (_, fn) => fn(new LegacySignerEth(transport));
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
currencyBridge: buildCurrencyBridge(context),
|
|
43
|
+
accountBridge: buildAccountBridge(context),
|
|
44
|
+
getAddress: resolver(context),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const context: SignerContext<Signer> = (_, fn) => fn(createSigner(transport));
|
|
49
|
+
const getAddress = resolver(context);
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
currencyBridge: getAlpacaCurrencyBridge(network, "local", { context, getAddress }),
|
|
53
|
+
accountBridge: getAlpacaAccountBridge(network, "local", { context, getAddress }),
|
|
54
|
+
getAddress,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
17
58
|
export const impersonnateAccount = async ({
|
|
18
59
|
provider,
|
|
19
60
|
addressToImpersonnate,
|
package/src/scenarii/blast.ts
CHANGED
|
@@ -15,6 +15,8 @@ import { blast, callMyDealer, VITALIK } from "../helpers";
|
|
|
15
15
|
import { defaultNanoApp } from "../scenarii.test";
|
|
16
16
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
17
17
|
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
18
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
19
|
+
import { EvmSigner } from "@ledgerhq/coin-evm/types/signer";
|
|
18
20
|
|
|
19
21
|
type BlastScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
20
22
|
|
|
@@ -70,12 +72,11 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
70
72
|
]);
|
|
71
73
|
|
|
72
74
|
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
73
|
-
const signerContext:
|
|
74
|
-
fn(new LegacySignerEth(transport));
|
|
75
|
+
const signerContext: SignerContext<EvmSigner> = (_, fn) => fn(new LegacySignerEth(transport));
|
|
75
76
|
|
|
76
77
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
77
78
|
// start indexing at next block
|
|
78
|
-
|
|
79
|
+
setBlock(lastBlockNumber + 1);
|
|
79
80
|
|
|
80
81
|
setCoinConfig(() => ({
|
|
81
82
|
info: {
|
package/src/scenarii/ethereum.ts
CHANGED
|
@@ -2,25 +2,21 @@ import { encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
|
2
2
|
import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
3
3
|
import { killSpeculos, spawnSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
4
4
|
import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
5
|
-
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
6
5
|
import { Account } from "@ledgerhq/types-live";
|
|
7
6
|
import { BigNumber } from "bignumber.js";
|
|
8
7
|
import { ethers } from "ethers";
|
|
9
8
|
import { makeAccount } from "@ledgerhq/coin-evm/__tests__/fixtures/common.fixtures";
|
|
10
|
-
import { buildAccountBridge, buildCurrencyBridge } from "@ledgerhq/coin-evm/bridge/js";
|
|
11
9
|
import { getCoinConfig, setCoinConfig } from "@ledgerhq/coin-evm/config";
|
|
12
|
-
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
13
10
|
import {
|
|
14
11
|
EvmNftTransaction,
|
|
15
12
|
Transaction as EvmTransaction,
|
|
16
13
|
} from "@ledgerhq/coin-evm/types/transaction";
|
|
17
14
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
18
|
-
import { callMyDealer, ethereum, VITALIK } from "../helpers";
|
|
15
|
+
import { callMyDealer, ethereum, VITALIK, getBridges } from "../helpers";
|
|
19
16
|
import { indexBlocks, initMswHandlers, resetIndexer, setBlock } from "../indexer";
|
|
20
17
|
import { defaultNanoApp } from "../scenarii.test";
|
|
21
|
-
import { getAlpacaCurrencyBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/currencyBridge";
|
|
22
|
-
import { getAlpacaAccountBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/accountBridge";
|
|
23
18
|
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
19
|
+
import { BridgeStrategy } from "@ledgerhq/coin-tester/types";
|
|
24
20
|
|
|
25
21
|
type EthereumScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
26
22
|
|
|
@@ -32,8 +28,10 @@ const cloneXTokenId = "951";
|
|
|
32
28
|
|
|
33
29
|
const makeScenarioTransactions = ({
|
|
34
30
|
address,
|
|
31
|
+
strategy,
|
|
35
32
|
}: {
|
|
36
33
|
address: string;
|
|
34
|
+
strategy: BridgeStrategy;
|
|
37
35
|
}): EthereumScenarioTransaction[] => {
|
|
38
36
|
const scenarioSendEthTransaction: EthereumScenarioTransaction = {
|
|
39
37
|
name: "Send 1 ETH",
|
|
@@ -127,8 +125,9 @@ const makeScenarioTransactions = ({
|
|
|
127
125
|
return [
|
|
128
126
|
scenarioSendEthTransaction,
|
|
129
127
|
scenarioSendUSDCTransaction,
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
...(strategy === "legacy"
|
|
129
|
+
? [scenarioSendERC721Transaction, scenarioSendERC1155Transaction]
|
|
130
|
+
: []),
|
|
132
131
|
];
|
|
133
132
|
};
|
|
134
133
|
|
|
@@ -140,9 +139,6 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
140
139
|
spawnAnvil("https://ethereum-rpc.publicnode.com"),
|
|
141
140
|
]);
|
|
142
141
|
|
|
143
|
-
const signerContext: Parameters<typeof resolver>[0] = (_, fn) =>
|
|
144
|
-
fn(new LegacySignerEth(transport));
|
|
145
|
-
|
|
146
142
|
setCoinConfig(() => ({
|
|
147
143
|
info: {
|
|
148
144
|
status: {
|
|
@@ -190,15 +186,11 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
190
186
|
initMswHandlers(getCoinConfig(ethereum).info);
|
|
191
187
|
|
|
192
188
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
193
|
-
const currencyBridge =
|
|
194
|
-
strategy
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
strategy === "legacy"
|
|
199
|
-
? buildAccountBridge(signerContext)
|
|
200
|
-
: getAlpacaAccountBridge("ethereum", "local");
|
|
201
|
-
const getAddress = resolver(signerContext);
|
|
189
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(
|
|
190
|
+
strategy,
|
|
191
|
+
transport,
|
|
192
|
+
"ethereum",
|
|
193
|
+
);
|
|
202
194
|
const { address } = await getAddress("", {
|
|
203
195
|
path: "44'/60'/0'/0/0",
|
|
204
196
|
currency: ethereum,
|
|
@@ -254,25 +246,25 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
254
246
|
onSignerConfirmation,
|
|
255
247
|
};
|
|
256
248
|
},
|
|
257
|
-
beforeAll: account => {
|
|
249
|
+
beforeAll: (account, strategy) => {
|
|
258
250
|
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
259
251
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
260
252
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
261
253
|
ethers.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
262
254
|
);
|
|
263
|
-
expect(account.nfts?.length).toBe(2);
|
|
255
|
+
expect(account.nfts?.length).toBe(strategy === "legacy" ? 2 : 0);
|
|
264
256
|
},
|
|
265
|
-
getTransactions: address => makeScenarioTransactions({ address }),
|
|
257
|
+
getTransactions: (address, strategy) => makeScenarioTransactions({ address, strategy }),
|
|
266
258
|
beforeSync: async () => {
|
|
267
259
|
await indexBlocks();
|
|
268
260
|
},
|
|
269
|
-
afterAll: account => {
|
|
261
|
+
afterAll: (account, strategy) => {
|
|
270
262
|
expect(account.subAccounts?.length).toBe(1);
|
|
271
263
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
272
264
|
ethers.parseUnits("20", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
273
265
|
);
|
|
274
266
|
expect(account.nfts?.length).toBe(0);
|
|
275
|
-
expect(account.operations.length).toBe(7);
|
|
267
|
+
expect(account.operations.length).toBe(strategy === "legacy" ? 7 : 3);
|
|
276
268
|
},
|
|
277
269
|
teardown: async () => {
|
|
278
270
|
resetIndexer();
|
package/src/scenarii/polygon.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
2
1
|
import { BigNumber } from "bignumber.js";
|
|
3
2
|
import { ethers } from "ethers";
|
|
4
3
|
import { Account } from "@ledgerhq/types-live";
|
|
@@ -7,17 +6,14 @@ import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
|
7
6
|
import { encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
8
7
|
import { killSpeculos, spawnSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
9
8
|
import { resetIndexer, initMswHandlers, setBlock, indexBlocks } from "../indexer";
|
|
10
|
-
import { buildAccountBridge, buildCurrencyBridge } from "@ledgerhq/coin-evm/bridge/js";
|
|
11
9
|
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
|
12
10
|
import { getCoinConfig, setCoinConfig } from "@ledgerhq/coin-evm/config";
|
|
13
11
|
import { makeAccount } from "@ledgerhq/coin-evm/__tests__/fixtures/common.fixtures";
|
|
14
|
-
import { callMyDealer, polygon, VITALIK } from "../helpers";
|
|
12
|
+
import { callMyDealer, getBridges, polygon, VITALIK } from "../helpers";
|
|
15
13
|
import { defaultNanoApp } from "../scenarii.test";
|
|
16
14
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
17
|
-
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
18
|
-
import { getAlpacaCurrencyBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/currencyBridge";
|
|
19
|
-
import { getAlpacaAccountBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/accountBridge";
|
|
20
15
|
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
16
|
+
import { BridgeStrategy } from "@ledgerhq/coin-tester/types";
|
|
21
17
|
|
|
22
18
|
type PolygonScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
23
19
|
|
|
@@ -27,7 +23,13 @@ const yootTokenId = "1988";
|
|
|
27
23
|
const emberContract = "0xa5511E9941E303101b50675926Fd4d9c1A8a8805";
|
|
28
24
|
const platinumTokenId = "4";
|
|
29
25
|
|
|
30
|
-
const makeScenarioTransactions = ({
|
|
26
|
+
const makeScenarioTransactions = ({
|
|
27
|
+
address,
|
|
28
|
+
strategy,
|
|
29
|
+
}: {
|
|
30
|
+
address: string;
|
|
31
|
+
strategy: BridgeStrategy;
|
|
32
|
+
}) => {
|
|
31
33
|
const send1MaticTransaction: PolygonScenarioTransaction = {
|
|
32
34
|
name: "Send 1 POL",
|
|
33
35
|
amount: new BigNumber(ethers.parseEther("1").toString()),
|
|
@@ -115,8 +117,7 @@ const makeScenarioTransactions = ({ address }: { address: string }) => {
|
|
|
115
117
|
return [
|
|
116
118
|
send1MaticTransaction,
|
|
117
119
|
send80USDCTransaction,
|
|
118
|
-
sendERC721Transaction,
|
|
119
|
-
sendERC1155Transaction,
|
|
120
|
+
...(strategy === "legacy" ? [sendERC721Transaction, sendERC1155Transaction] : []),
|
|
120
121
|
];
|
|
121
122
|
};
|
|
122
123
|
|
|
@@ -129,8 +130,6 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
129
130
|
]);
|
|
130
131
|
|
|
131
132
|
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
132
|
-
const signerContext: Parameters<typeof resolver>[0] = (_, fn) =>
|
|
133
|
-
fn(new LegacySignerEth(transport));
|
|
134
133
|
|
|
135
134
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
136
135
|
// start indexing at next block
|
|
@@ -182,15 +181,11 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
182
181
|
initMswHandlers(getCoinConfig(polygon).info);
|
|
183
182
|
|
|
184
183
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
185
|
-
const currencyBridge =
|
|
186
|
-
strategy
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
strategy === "legacy"
|
|
191
|
-
? buildAccountBridge(signerContext)
|
|
192
|
-
: getAlpacaAccountBridge("ethereum", "local");
|
|
193
|
-
const getAddress = resolver(signerContext);
|
|
184
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(
|
|
185
|
+
strategy,
|
|
186
|
+
transport,
|
|
187
|
+
"polygon",
|
|
188
|
+
);
|
|
194
189
|
const { address } = await getAddress("", {
|
|
195
190
|
path: "44'/60'/0'/0/0",
|
|
196
191
|
currency: polygon,
|
|
@@ -236,25 +231,25 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
236
231
|
|
|
237
232
|
return { currencyBridge, accountBridge, account: scenarioAccount, onSignerConfirmation };
|
|
238
233
|
},
|
|
239
|
-
getTransactions: address => makeScenarioTransactions({ address }),
|
|
234
|
+
getTransactions: (address, strategy) => makeScenarioTransactions({ address, strategy }),
|
|
240
235
|
beforeSync: async () => {
|
|
241
236
|
await indexBlocks();
|
|
242
237
|
},
|
|
243
|
-
beforeAll: account => {
|
|
238
|
+
beforeAll: (account, strategy) => {
|
|
244
239
|
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
245
240
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
246
241
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
247
242
|
ethers.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
248
243
|
);
|
|
249
|
-
expect(account.nfts?.length).toBe(2);
|
|
244
|
+
expect(account.nfts?.length).toBe(strategy === "legacy" ? 2 : 0);
|
|
250
245
|
},
|
|
251
|
-
afterAll: account => {
|
|
246
|
+
afterAll: (account, strategy) => {
|
|
252
247
|
expect(account.subAccounts?.length).toBe(1);
|
|
253
248
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
254
249
|
ethers.parseUnits("20", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
255
250
|
);
|
|
256
251
|
expect(account.nfts?.length).toBe(0);
|
|
257
|
-
expect(account.operations.length).toBe(7);
|
|
252
|
+
expect(account.operations.length).toBe(strategy === "legacy" ? 7 : 3);
|
|
258
253
|
},
|
|
259
254
|
teardown: async () => {
|
|
260
255
|
resetIndexer();
|
package/src/scenarii/scroll.ts
CHANGED
|
@@ -15,6 +15,8 @@ import { callMyDealer, scroll, VITALIK } from "../helpers";
|
|
|
15
15
|
import { defaultNanoApp } from "../scenarii.test";
|
|
16
16
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
17
17
|
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
18
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
19
|
+
import { EvmSigner } from "@ledgerhq/coin-evm/types/signer";
|
|
18
20
|
|
|
19
21
|
type ScrollScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
20
22
|
|
|
@@ -74,12 +76,11 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
74
76
|
]);
|
|
75
77
|
|
|
76
78
|
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
77
|
-
const signerContext:
|
|
78
|
-
fn(new LegacySignerEth(transport));
|
|
79
|
+
const signerContext: SignerContext<EvmSigner> = (_, fn) => fn(new LegacySignerEth(transport));
|
|
79
80
|
|
|
80
81
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
81
82
|
// start indexing at next block
|
|
82
|
-
|
|
83
|
+
setBlock(lastBlockNumber + 1);
|
|
83
84
|
|
|
84
85
|
setCoinConfig(() => ({
|
|
85
86
|
info: {
|
package/src/scenarii/sonic.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
2
1
|
import { BigNumber } from "bignumber.js";
|
|
3
2
|
import { ethers } from "ethers";
|
|
4
3
|
import { Account } from "@ledgerhq/types-live";
|
|
@@ -8,15 +7,11 @@ import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
|
8
7
|
import { killSpeculos, spawnSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
9
8
|
import { resetIndexer, indexBlocks, initMswHandlers, setBlock } from "../indexer";
|
|
10
9
|
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
|
11
|
-
import { buildAccountBridge, buildCurrencyBridge } from "@ledgerhq/coin-evm/bridge/js";
|
|
12
10
|
import { getCoinConfig, setCoinConfig } from "@ledgerhq/coin-evm/config";
|
|
13
11
|
import { makeAccount } from "@ledgerhq/coin-evm/__tests__/fixtures/common.fixtures";
|
|
14
|
-
import { VITALIK, callMyDealer, sonic } from "../helpers";
|
|
12
|
+
import { VITALIK, callMyDealer, getBridges, sonic } from "../helpers";
|
|
15
13
|
import { defaultNanoApp } from "../scenarii.test";
|
|
16
14
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
17
|
-
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
18
|
-
import { getAlpacaCurrencyBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/currencyBridge";
|
|
19
|
-
import { getAlpacaAccountBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/accountBridge";
|
|
20
15
|
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
21
16
|
|
|
22
17
|
type SonicScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
@@ -79,9 +74,6 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
79
74
|
spawnAnvil("https://sonic-rpc.publicnode.com"),
|
|
80
75
|
]);
|
|
81
76
|
|
|
82
|
-
const signerContext: Parameters<typeof resolver>[0] = (_, fn) =>
|
|
83
|
-
fn(new LegacySignerEth(transport));
|
|
84
|
-
|
|
85
77
|
setCoinConfig(() => ({
|
|
86
78
|
info: {
|
|
87
79
|
status: {
|
|
@@ -121,15 +113,7 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
121
113
|
initMswHandlers(getCoinConfig(sonic).info);
|
|
122
114
|
|
|
123
115
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
124
|
-
const currencyBridge =
|
|
125
|
-
strategy === "legacy"
|
|
126
|
-
? buildCurrencyBridge(signerContext)
|
|
127
|
-
: getAlpacaCurrencyBridge("sonic", "local");
|
|
128
|
-
const accountBridge =
|
|
129
|
-
strategy === "legacy"
|
|
130
|
-
? buildAccountBridge(signerContext)
|
|
131
|
-
: getAlpacaAccountBridge("sonic", "local");
|
|
132
|
-
const getAddress = resolver(signerContext);
|
|
116
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(strategy, transport, "sonic");
|
|
133
117
|
const { address } = await getAddress("", {
|
|
134
118
|
path: "44'/60'/0'/0/0",
|
|
135
119
|
currency: sonic,
|
package/src/scenarii.test.ts
CHANGED
|
@@ -27,62 +27,65 @@ setCryptoAssetsStoreForCoinFramework({
|
|
|
27
27
|
// https://github.com/LedgerHQ/ledger-live/blob/develop/libs/coin-tester/docker-compose.yml
|
|
28
28
|
export const defaultNanoApp = { firmware: "2.4.2" as const, version: "1.17.0" as const };
|
|
29
29
|
|
|
30
|
-
describe("
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
describe.each([["legacy"], ["generic-adapter"]] as const)(
|
|
31
|
+
"EVM Deterministic Tester (%s strategy)",
|
|
32
|
+
strategy => {
|
|
33
|
+
it("scenario Ethereum", async () => {
|
|
34
|
+
try {
|
|
35
|
+
await executeScenario(scenarioEthereum, strategy);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
if (e != "done") {
|
|
38
|
+
await Promise.all([killSpeculos(), killAnvil()]);
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
42
|
+
});
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
it("scenario Sonic", async () => {
|
|
45
|
+
try {
|
|
46
|
+
await executeScenario(scenarioSonic, strategy);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
if (e != "done") {
|
|
49
|
+
await Promise.all([killSpeculos(), killAnvil()]);
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
53
|
+
});
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
it("scenario polygon", async () => {
|
|
56
|
+
try {
|
|
57
|
+
await executeScenario(scenarioPolygon, strategy);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
if (e != "done") {
|
|
60
|
+
await Promise.all([killSpeculos(), killAnvil()]);
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
64
|
+
});
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
it.skip("scenario scroll", async () => {
|
|
67
|
+
try {
|
|
68
|
+
await executeScenario(scenarioScroll);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
if (e != "done") {
|
|
71
|
+
await Promise.all([killSpeculos(), killAnvil()]);
|
|
72
|
+
throw e;
|
|
73
|
+
}
|
|
71
74
|
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
75
|
+
});
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
it.skip("scenario blast", async () => {
|
|
78
|
+
try {
|
|
79
|
+
await executeScenario(scenarioBlast);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
if (e != "done") {
|
|
82
|
+
await Promise.all([killSpeculos(), killAnvil()]);
|
|
83
|
+
throw e;
|
|
84
|
+
}
|
|
82
85
|
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
);
|
|
86
89
|
|
|
87
90
|
["exit", "SIGINT", "SIGQUIT", "SIGTERM", "SIGUSR1", "SIGUSR2", "uncaughtException"].map(e =>
|
|
88
91
|
process.on(e, async () => {
|