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