@ledgerhq/coin-tester-evm 1.11.1-nightly.20251204023901 → 1.12.0-nightly.20251205023918
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 +12 -9
- package/lib/src/helpers.d.ts +1 -2
- package/lib/src/helpers.d.ts.map +1 -1
- package/lib/src/helpers.js +1 -11
- 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 -12
- package/lib/src/scenarii/blast.js.map +1 -1
- package/lib/src/scenarii/core.js +2 -2
- package/lib/src/scenarii/core.js.map +1 -1
- package/lib/src/scenarii/ethereum.d.ts.map +1 -1
- package/lib/src/scenarii/ethereum.js +9 -89
- 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 +9 -86
- 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 +1 -11
- 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 +2 -3
- package/lib/src/scenarii/sonic.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-es/src/helpers.d.ts +1 -2
- package/lib-es/src/helpers.d.ts.map +1 -1
- package/lib-es/src/helpers.js +1 -11
- 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 -9
- package/lib-es/src/scenarii/blast.js.map +1 -1
- package/lib-es/src/scenarii/core.js +2 -2
- package/lib-es/src/scenarii/core.js.map +1 -1
- package/lib-es/src/scenarii/ethereum.d.ts.map +1 -1
- package/lib-es/src/scenarii/ethereum.js +9 -89
- 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 -86
- 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 -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 +2 -3
- package/lib-es/src/scenarii/sonic.js.map +1 -1
- package/lib-es/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -8
- package/src/helpers.ts +0 -15
- package/src/scenarii/blast.ts +2 -11
- package/src/scenarii/core.ts +2 -2
- package/src/scenarii/ethereum.ts +9 -109
- package/src/scenarii/polygon.ts +9 -101
- package/src/scenarii/scroll.ts +2 -11
- package/src/scenarii/sonic.ts +2 -3
- package/src/scenarii.test.ts +56 -59
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-tester-evm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0-nightly.20251205023918",
|
|
4
4
|
"description": "Ledger EVM Coin Tester",
|
|
5
5
|
"main": "src/scenarii.test.ts",
|
|
6
6
|
"keywords": [
|
|
@@ -51,15 +51,14 @@
|
|
|
51
51
|
"dotenv": "^16.4.5",
|
|
52
52
|
"ethers": "6.15.0",
|
|
53
53
|
"msw": "^2.2.1",
|
|
54
|
-
"@ledgerhq/coin-evm": "^2.36.0-nightly.
|
|
55
|
-
"@ledgerhq/coin-framework": "^6.10.0-nightly.
|
|
56
|
-
"@ledgerhq/coin-tester": "^0.13.0-nightly.
|
|
57
|
-
"@ledgerhq/cryptoassets": "^13.34.0-nightly.
|
|
58
|
-
"@ledgerhq/live-common": "^34.54.0-nightly.
|
|
54
|
+
"@ledgerhq/coin-evm": "^2.36.0-nightly.20251205023918",
|
|
55
|
+
"@ledgerhq/coin-framework": "^6.10.0-nightly.20251205023918",
|
|
56
|
+
"@ledgerhq/coin-tester": "^0.13.0-nightly.20251205023918",
|
|
57
|
+
"@ledgerhq/cryptoassets": "^13.34.0-nightly.20251205023918",
|
|
58
|
+
"@ledgerhq/live-common": "^34.54.0-nightly.20251205023918",
|
|
59
59
|
"@ledgerhq/live-config": "^3.2.0",
|
|
60
|
-
"@ledgerhq/live-signer-evm": "^0.10.2-nightly.20251204023901",
|
|
61
60
|
"@ledgerhq/types-cryptoassets": "^7.30.0",
|
|
62
|
-
"@ledgerhq/types-live": "^6.90.0-nightly.
|
|
61
|
+
"@ledgerhq/types-live": "^6.90.0-nightly.20251205023918"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
64
|
"@swc/core": "1.4.11",
|
package/src/helpers.ts
CHANGED
|
@@ -4,13 +4,9 @@ import { AccountBridge, CurrencyBridge, NFTStandard } from "@ledgerhq/types-live
|
|
|
4
4
|
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
5
5
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
6
6
|
import { ERC20_ABI, ERC721_ABI, ERC1155_ABI } from "@ledgerhq/coin-evm/abis/index";
|
|
7
|
-
import { BridgeStrategy } from "@ledgerhq/coin-tester/types";
|
|
8
7
|
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
|
9
8
|
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
9
|
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
13
|
-
import { buildAccountBridge, buildCurrencyBridge } from "@ledgerhq/coin-evm/bridge/js";
|
|
14
10
|
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
15
11
|
import { Signer, createSigner } from "@ledgerhq/live-common/bridge/generic-alpaca/signer/Eth";
|
|
16
12
|
import { getAlpacaCurrencyBridge } from "@ledgerhq/live-common/bridge/generic-alpaca/currencyBridge";
|
|
@@ -28,7 +24,6 @@ export const ERC1155Interface = new ethers.Interface(ERC1155_ABI);
|
|
|
28
24
|
export const VITALIK = "0x6bfD74C0996F269Bcece59191EFf667b3dFD73b9";
|
|
29
25
|
|
|
30
26
|
export function getBridges(
|
|
31
|
-
strategy: BridgeStrategy,
|
|
32
27
|
transport: Transport,
|
|
33
28
|
network: string,
|
|
34
29
|
): {
|
|
@@ -36,16 +31,6 @@ export function getBridges(
|
|
|
36
31
|
accountBridge: AccountBridge<EvmTransaction>;
|
|
37
32
|
getAddress: GetAddressFn;
|
|
38
33
|
} {
|
|
39
|
-
if (strategy === "legacy") {
|
|
40
|
-
const context: SignerContext<EvmSigner> = (_, fn) => fn(new LegacySignerEth(transport));
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
currencyBridge: buildCurrencyBridge(context),
|
|
44
|
-
accountBridge: buildAccountBridge(context),
|
|
45
|
-
getAddress: resolver(context),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
34
|
const context: SignerContext<Signer> = (_, fn) => fn(createSigner(transport));
|
|
50
35
|
const getAddress = resolver(context);
|
|
51
36
|
|
package/src/scenarii/blast.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";
|
|
@@ -6,16 +5,12 @@ import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
|
6
5
|
import { encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
7
6
|
import { killSpeculos, spawnSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
8
7
|
import { resetIndexer, setBlock, indexBlocks, initMswHandlers } from "../indexer";
|
|
9
|
-
import { buildAccountBridge, buildCurrencyBridge } from "@ledgerhq/coin-evm/bridge/js";
|
|
10
8
|
import { getCoinConfig, setCoinConfig } from "@ledgerhq/coin-evm/config";
|
|
11
9
|
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
|
12
10
|
import { makeAccount } from "../fixtures";
|
|
13
|
-
import { blast, callMyDealer, VITALIK } from "../helpers";
|
|
14
11
|
import { defaultNanoApp } from "../constants";
|
|
12
|
+
import { blast, callMyDealer, getBridges, VITALIK } from "../helpers";
|
|
15
13
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
16
|
-
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
17
|
-
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
18
|
-
import { EvmSigner } from "@ledgerhq/coin-evm/types/signer";
|
|
19
14
|
import { MIM_ON_BLAST } from "../tokenFixtures";
|
|
20
15
|
|
|
21
16
|
type BlastScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
@@ -68,7 +63,6 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
68
63
|
]);
|
|
69
64
|
|
|
70
65
|
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
71
|
-
const signerContext: SignerContext<EvmSigner> = (_, fn) => fn(new LegacySignerEth(transport));
|
|
72
66
|
|
|
73
67
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
74
68
|
// start indexing at next block
|
|
@@ -93,10 +87,7 @@ export const scenarioBlast: Scenario<EvmTransaction, Account> = {
|
|
|
93
87
|
initMswHandlers(getCoinConfig(blast).info);
|
|
94
88
|
|
|
95
89
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
96
|
-
const currencyBridge =
|
|
97
|
-
await currencyBridge.preload(blast);
|
|
98
|
-
const accountBridge = buildAccountBridge(signerContext);
|
|
99
|
-
const getAddress = resolver(signerContext);
|
|
90
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(transport, "blast");
|
|
100
91
|
const { address } = await getAddress("", {
|
|
101
92
|
path: "44'/60'/0'/0/0",
|
|
102
93
|
currency: blast,
|
package/src/scenarii/core.ts
CHANGED
|
@@ -58,7 +58,7 @@ const makeScenarioTransactions = ({ address }: { address: string }): CoreScenari
|
|
|
58
58
|
|
|
59
59
|
export const scenarioCore: Scenario<EvmTransaction, Account> = {
|
|
60
60
|
name: "Ledger Live Basic CORE Transactions",
|
|
61
|
-
setup: async
|
|
61
|
+
setup: async () => {
|
|
62
62
|
const [{ transport, getOnSpeculosConfirmation }] = await Promise.all([
|
|
63
63
|
spawnSpeculos(`/${defaultNanoApp.firmware}/Ethereum/app_${defaultNanoApp.version}.elf`),
|
|
64
64
|
spawnAnvil("https://rpc.ankr.com/core"),
|
|
@@ -102,7 +102,7 @@ export const scenarioCore: Scenario<EvmTransaction, Account> = {
|
|
|
102
102
|
initMswHandlers(getCoinConfig(core).info);
|
|
103
103
|
|
|
104
104
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
105
|
-
const { currencyBridge, accountBridge, getAddress } = getBridges(
|
|
105
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(transport, "core");
|
|
106
106
|
const { address } = await getAddress("", {
|
|
107
107
|
path: "44'/60'/0'/0/0",
|
|
108
108
|
currency: core,
|
package/src/scenarii/ethereum.ts
CHANGED
|
@@ -6,30 +6,20 @@ import { BigNumber } from "bignumber.js";
|
|
|
6
6
|
import { ethers } from "ethers";
|
|
7
7
|
import { makeAccount } from "../fixtures";
|
|
8
8
|
import { getCoinConfig, setCoinConfig } from "@ledgerhq/coin-evm/config";
|
|
9
|
-
import {
|
|
10
|
-
EvmNftTransaction,
|
|
11
|
-
Transaction as EvmTransaction,
|
|
12
|
-
} from "@ledgerhq/coin-evm/types/transaction";
|
|
9
|
+
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
|
13
10
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
14
11
|
import { callMyDealer, ethereum, VITALIK, getBridges } from "../helpers";
|
|
15
12
|
import { indexBlocks, initMswHandlers, resetIndexer, setBlock } from "../indexer";
|
|
16
13
|
import { defaultNanoApp } from "../constants";
|
|
17
14
|
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
18
|
-
import { BridgeStrategy } from "@ledgerhq/coin-tester/types";
|
|
19
15
|
import { USDC_ON_ETHEREUM } from "../tokenFixtures";
|
|
20
16
|
|
|
21
17
|
type EthereumScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
22
|
-
const boredApeContract = "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D";
|
|
23
|
-
const boredApeTokenId = "3368";
|
|
24
|
-
const cloneXContract = "0x348FC118bcC65a92dC033A951aF153d14D945312";
|
|
25
|
-
const cloneXTokenId = "951";
|
|
26
18
|
|
|
27
19
|
const makeScenarioTransactions = ({
|
|
28
20
|
address,
|
|
29
|
-
strategy,
|
|
30
21
|
}: {
|
|
31
22
|
address: string;
|
|
32
|
-
strategy: BridgeStrategy;
|
|
33
23
|
}): EthereumScenarioTransaction[] => {
|
|
34
24
|
const scenarioSendEthTransaction: EthereumScenarioTransaction = {
|
|
35
25
|
name: "Send 1 ETH",
|
|
@@ -66,72 +56,12 @@ const makeScenarioTransactions = ({
|
|
|
66
56
|
},
|
|
67
57
|
};
|
|
68
58
|
|
|
69
|
-
|
|
70
|
-
EvmTransaction & EvmNftTransaction,
|
|
71
|
-
Account
|
|
72
|
-
> = {
|
|
73
|
-
name: "Send ERC721",
|
|
74
|
-
recipient: VITALIK,
|
|
75
|
-
mode: "erc721",
|
|
76
|
-
nft: {
|
|
77
|
-
tokenId: boredApeTokenId,
|
|
78
|
-
contract: boredApeContract,
|
|
79
|
-
quantity: new BigNumber(1),
|
|
80
|
-
collectionName: "Bored Ape",
|
|
81
|
-
},
|
|
82
|
-
expect: (previousAccount, currentAccount) => {
|
|
83
|
-
const [latestOperation] = currentAccount.operations;
|
|
84
|
-
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
85
|
-
expect(currentAccount.nfts?.every(nft => nft.contract !== boredApeContract)).toBe(true);
|
|
86
|
-
expect(latestOperation.type).toBe("FEES");
|
|
87
|
-
const lastNftOperation = latestOperation.nftOperations?.[0];
|
|
88
|
-
expect(lastNftOperation).toMatchObject({
|
|
89
|
-
contract: boredApeContract,
|
|
90
|
-
tokenId: boredApeTokenId,
|
|
91
|
-
value: new BigNumber(1),
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const scenarioSendERC1155Transaction: ScenarioTransaction<
|
|
97
|
-
EvmTransaction & EvmNftTransaction,
|
|
98
|
-
Account
|
|
99
|
-
> = {
|
|
100
|
-
name: "Send ERC1155",
|
|
101
|
-
recipient: VITALIK,
|
|
102
|
-
mode: "erc1155",
|
|
103
|
-
nft: {
|
|
104
|
-
tokenId: "951",
|
|
105
|
-
contract: cloneXContract,
|
|
106
|
-
collectionName: "Clone X",
|
|
107
|
-
quantity: new BigNumber(2),
|
|
108
|
-
},
|
|
109
|
-
expect: (previousAccount, currentAccount) => {
|
|
110
|
-
const [latestOperation] = currentAccount.operations;
|
|
111
|
-
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
112
|
-
expect(currentAccount.nfts?.every(nft => nft.contract !== cloneXContract)).toBe(true);
|
|
113
|
-
expect(latestOperation.type).toBe("FEES");
|
|
114
|
-
const lastNftOperation = latestOperation.nftOperations?.[0];
|
|
115
|
-
expect(lastNftOperation).toMatchObject({
|
|
116
|
-
contract: cloneXContract,
|
|
117
|
-
tokenId: cloneXTokenId,
|
|
118
|
-
value: new BigNumber(2),
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
return [
|
|
124
|
-
scenarioSendEthTransaction,
|
|
125
|
-
scenarioSendUSDCTransaction,
|
|
126
|
-
...(strategy === "legacy"
|
|
127
|
-
? [scenarioSendERC721Transaction, scenarioSendERC1155Transaction]
|
|
128
|
-
: []),
|
|
129
|
-
];
|
|
59
|
+
return [scenarioSendEthTransaction, scenarioSendUSDCTransaction];
|
|
130
60
|
};
|
|
131
61
|
|
|
132
62
|
export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
133
63
|
name: "Ledger Live Basic ETH Transactions",
|
|
134
|
-
setup: async
|
|
64
|
+
setup: async () => {
|
|
135
65
|
const [{ transport, getOnSpeculosConfirmation }] = await Promise.all([
|
|
136
66
|
spawnSpeculos(`/${defaultNanoApp.firmware}/Ethereum/app_${defaultNanoApp.version}.elf`),
|
|
137
67
|
spawnAnvil("https://ethereum-rpc.publicnode.com"),
|
|
@@ -184,11 +114,7 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
184
114
|
initMswHandlers(getCoinConfig(ethereum).info);
|
|
185
115
|
|
|
186
116
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
187
|
-
const { currencyBridge, accountBridge, getAddress } = getBridges(
|
|
188
|
-
strategy,
|
|
189
|
-
transport,
|
|
190
|
-
"ethereum",
|
|
191
|
-
);
|
|
117
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(transport, "ethereum");
|
|
192
118
|
const { address } = await getAddress("", {
|
|
193
119
|
path: "44'/60'/0'/0/0",
|
|
194
120
|
currency: ethereum,
|
|
@@ -211,32 +137,6 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
211
137
|
dose: ethers.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude),
|
|
212
138
|
});
|
|
213
139
|
|
|
214
|
-
// Get a Bored Ape
|
|
215
|
-
await callMyDealer({
|
|
216
|
-
provider,
|
|
217
|
-
drug: {
|
|
218
|
-
type: "Nft",
|
|
219
|
-
tokenId: boredApeTokenId,
|
|
220
|
-
contractAddress: boredApeContract,
|
|
221
|
-
standard: "ERC721",
|
|
222
|
-
},
|
|
223
|
-
junkie: address,
|
|
224
|
-
dose: 1n,
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// Get 2 CloneX
|
|
228
|
-
await callMyDealer({
|
|
229
|
-
provider,
|
|
230
|
-
drug: {
|
|
231
|
-
type: "Nft",
|
|
232
|
-
tokenId: cloneXTokenId,
|
|
233
|
-
contractAddress: cloneXContract,
|
|
234
|
-
standard: "ERC1155",
|
|
235
|
-
},
|
|
236
|
-
junkie: address,
|
|
237
|
-
dose: 2n,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
140
|
return {
|
|
241
141
|
currencyBridge,
|
|
242
142
|
accountBridge,
|
|
@@ -244,25 +144,25 @@ export const scenarioEthereum: Scenario<EvmTransaction, Account> = {
|
|
|
244
144
|
onSignerConfirmation,
|
|
245
145
|
};
|
|
246
146
|
},
|
|
247
|
-
beforeAll:
|
|
147
|
+
beforeAll: account => {
|
|
248
148
|
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
249
149
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
250
150
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
251
151
|
ethers.parseUnits("100", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
252
152
|
);
|
|
253
|
-
expect(account.nfts?.length).toBe(
|
|
153
|
+
expect(account.nfts?.length).toBe(0);
|
|
254
154
|
},
|
|
255
|
-
getTransactions:
|
|
155
|
+
getTransactions: address => makeScenarioTransactions({ address }),
|
|
256
156
|
beforeSync: async () => {
|
|
257
157
|
await indexBlocks();
|
|
258
158
|
},
|
|
259
|
-
afterAll:
|
|
159
|
+
afterAll: account => {
|
|
260
160
|
expect(account.subAccounts?.length).toBe(1);
|
|
261
161
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
262
162
|
ethers.parseUnits("20", USDC_ON_ETHEREUM.units[0].magnitude).toString(),
|
|
263
163
|
);
|
|
264
164
|
expect(account.nfts?.length).toBe(0);
|
|
265
|
-
expect(account.operations.length).toBe(
|
|
165
|
+
expect(account.operations.length).toBe(3);
|
|
266
166
|
},
|
|
267
167
|
teardown: async () => {
|
|
268
168
|
resetIndexer();
|
package/src/scenarii/polygon.ts
CHANGED
|
@@ -12,22 +12,11 @@ import { callMyDealer, getBridges, polygon, VITALIK } from "../helpers";
|
|
|
12
12
|
import { defaultNanoApp } from "../constants";
|
|
13
13
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
14
14
|
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
15
|
-
import { BridgeStrategy } from "@ledgerhq/coin-tester/types";
|
|
16
15
|
import { USDC_ON_POLYGON } from "../tokenFixtures";
|
|
17
16
|
|
|
18
17
|
type PolygonScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
19
|
-
const yootContract = "0x670fd103b1a08628e9557cD66B87DeD841115190";
|
|
20
|
-
const yootTokenId = "1953";
|
|
21
|
-
const emberContract = "0xa5511E9941E303101b50675926Fd4d9c1A8a8805";
|
|
22
|
-
const platinumTokenId = "4";
|
|
23
18
|
|
|
24
|
-
const makeScenarioTransactions = ({
|
|
25
|
-
address,
|
|
26
|
-
strategy,
|
|
27
|
-
}: {
|
|
28
|
-
address: string;
|
|
29
|
-
strategy: BridgeStrategy;
|
|
30
|
-
}) => {
|
|
19
|
+
const makeScenarioTransactions = ({ address }: { address: string }) => {
|
|
31
20
|
const send1MaticTransaction: PolygonScenarioTransaction = {
|
|
32
21
|
name: "Send 1 POL",
|
|
33
22
|
amount: new BigNumber(ethers.parseEther("1").toString()),
|
|
@@ -64,64 +53,12 @@ const makeScenarioTransactions = ({
|
|
|
64
53
|
},
|
|
65
54
|
};
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
name: "Send ERC721",
|
|
69
|
-
recipient: VITALIK,
|
|
70
|
-
mode: "erc721",
|
|
71
|
-
nft: {
|
|
72
|
-
tokenId: yootTokenId,
|
|
73
|
-
contract: yootContract,
|
|
74
|
-
quantity: new BigNumber(1),
|
|
75
|
-
collectionName: "Courtyard.io",
|
|
76
|
-
},
|
|
77
|
-
expect: (previousAccount, currentAccount) => {
|
|
78
|
-
const [latestOperation] = currentAccount.operations;
|
|
79
|
-
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
80
|
-
expect(currentAccount.nfts?.every(nft => nft.contract !== yootContract)).toBe(true);
|
|
81
|
-
expect(latestOperation.type).toBe("FEES");
|
|
82
|
-
const lastNftOperation = latestOperation.nftOperations?.[0];
|
|
83
|
-
expect(lastNftOperation).toMatchObject({
|
|
84
|
-
contract: yootContract,
|
|
85
|
-
tokenId: yootTokenId,
|
|
86
|
-
value: new BigNumber(1),
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const sendERC1155Transaction: PolygonScenarioTransaction = {
|
|
92
|
-
name: "Send ERC1155",
|
|
93
|
-
recipient: VITALIK,
|
|
94
|
-
mode: "erc1155",
|
|
95
|
-
nft: {
|
|
96
|
-
contract: emberContract,
|
|
97
|
-
tokenId: platinumTokenId,
|
|
98
|
-
quantity: new BigNumber(10),
|
|
99
|
-
collectionName: "Ember Sword Badge",
|
|
100
|
-
},
|
|
101
|
-
expect: (previousAccount, currentAccount) => {
|
|
102
|
-
const [latestOperation] = currentAccount.operations;
|
|
103
|
-
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
104
|
-
expect(currentAccount.nfts?.every(nft => nft.contract !== emberContract)).toBe(true);
|
|
105
|
-
expect(latestOperation.type).toBe("FEES");
|
|
106
|
-
const lastNftOperation = latestOperation.nftOperations?.[0];
|
|
107
|
-
expect(lastNftOperation).toMatchObject({
|
|
108
|
-
contract: emberContract,
|
|
109
|
-
tokenId: platinumTokenId,
|
|
110
|
-
value: new BigNumber(10),
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
return [
|
|
116
|
-
send1MaticTransaction,
|
|
117
|
-
send80USDCTransaction,
|
|
118
|
-
...(strategy === "legacy" ? [sendERC721Transaction, sendERC1155Transaction] : []),
|
|
119
|
-
];
|
|
56
|
+
return [send1MaticTransaction, send80USDCTransaction];
|
|
120
57
|
};
|
|
121
58
|
|
|
122
59
|
export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
123
60
|
name: "Ledger Live Basic Polygon Transactions",
|
|
124
|
-
setup: async
|
|
61
|
+
setup: async () => {
|
|
125
62
|
const [{ transport, getOnSpeculosConfirmation }] = await Promise.all([
|
|
126
63
|
spawnSpeculos(`/${defaultNanoApp.firmware}/Ethereum/app_${defaultNanoApp.version}.elf`),
|
|
127
64
|
spawnAnvil("https://polygon-bor-rpc.publicnode.com"),
|
|
@@ -179,11 +116,7 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
179
116
|
initMswHandlers(getCoinConfig(polygon).info);
|
|
180
117
|
|
|
181
118
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
182
|
-
const { currencyBridge, accountBridge, getAddress } = getBridges(
|
|
183
|
-
strategy,
|
|
184
|
-
transport,
|
|
185
|
-
"polygon",
|
|
186
|
-
);
|
|
119
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(transport, "polygon");
|
|
187
120
|
const { address } = await getAddress("", {
|
|
188
121
|
path: "44'/60'/0'/0/0",
|
|
189
122
|
currency: polygon,
|
|
@@ -202,52 +135,27 @@ export const scenarioPolygon: Scenario<EvmTransaction, Account> = {
|
|
|
202
135
|
dose: ethers.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude),
|
|
203
136
|
});
|
|
204
137
|
|
|
205
|
-
// Get 1 yoot
|
|
206
|
-
await callMyDealer({
|
|
207
|
-
provider,
|
|
208
|
-
drug: {
|
|
209
|
-
type: "Nft",
|
|
210
|
-
tokenId: yootTokenId,
|
|
211
|
-
contractAddress: yootContract,
|
|
212
|
-
standard: "ERC721",
|
|
213
|
-
},
|
|
214
|
-
junkie: address,
|
|
215
|
-
dose: 1n,
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
await callMyDealer({
|
|
219
|
-
provider,
|
|
220
|
-
drug: {
|
|
221
|
-
type: "Nft",
|
|
222
|
-
tokenId: platinumTokenId,
|
|
223
|
-
contractAddress: emberContract,
|
|
224
|
-
standard: "ERC1155",
|
|
225
|
-
},
|
|
226
|
-
junkie: address,
|
|
227
|
-
dose: 10n,
|
|
228
|
-
});
|
|
229
|
-
|
|
230
138
|
return { currencyBridge, accountBridge, account: scenarioAccount, onSignerConfirmation };
|
|
231
139
|
},
|
|
232
|
-
getTransactions:
|
|
140
|
+
getTransactions: address => makeScenarioTransactions({ address }),
|
|
233
141
|
beforeSync: async () => {
|
|
234
142
|
await indexBlocks();
|
|
235
143
|
},
|
|
236
|
-
beforeAll:
|
|
144
|
+
beforeAll: account => {
|
|
237
145
|
expect(account.balance.toFixed()).toBe(ethers.parseEther("10000").toString());
|
|
238
146
|
expect(account.subAccounts?.[0].type).toBe("TokenAccount");
|
|
239
147
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
240
148
|
ethers.parseUnits("100", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
241
149
|
);
|
|
242
|
-
expect(account.nfts?.length).toBe(
|
|
150
|
+
expect(account.nfts?.length).toBe(0);
|
|
243
151
|
},
|
|
244
|
-
afterAll:
|
|
152
|
+
afterAll: account => {
|
|
245
153
|
expect(account.subAccounts?.length).toBe(1);
|
|
246
154
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
247
155
|
ethers.parseUnits("20", USDC_ON_POLYGON.units[0].magnitude).toString(),
|
|
248
156
|
);
|
|
249
157
|
expect(account.nfts?.length).toBe(0);
|
|
250
|
-
expect(account.operations.length).toBe(
|
|
158
|
+
expect(account.operations.length).toBe(3);
|
|
251
159
|
},
|
|
252
160
|
teardown: async () => {
|
|
253
161
|
resetIndexer();
|
package/src/scenarii/scroll.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";
|
|
@@ -6,16 +5,12 @@ import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
|
6
5
|
import { encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
7
6
|
import { killSpeculos, spawnSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
8
7
|
import { resetIndexer, setBlock, indexBlocks, initMswHandlers } from "../indexer";
|
|
9
|
-
import { buildAccountBridge, buildCurrencyBridge } from "@ledgerhq/coin-evm/bridge/js";
|
|
10
8
|
import { getCoinConfig, setCoinConfig } from "@ledgerhq/coin-evm/config";
|
|
11
9
|
import { Transaction as EvmTransaction } from "@ledgerhq/coin-evm/types/transaction";
|
|
12
10
|
import { makeAccount } from "../fixtures";
|
|
13
|
-
import { callMyDealer, scroll, VITALIK } from "../helpers";
|
|
11
|
+
import { callMyDealer, getBridges, scroll, VITALIK } from "../helpers";
|
|
14
12
|
import { defaultNanoApp } from "../constants";
|
|
15
13
|
import { killAnvil, spawnAnvil } from "../anvil";
|
|
16
|
-
import resolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
17
|
-
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
18
|
-
import { EvmSigner } from "@ledgerhq/coin-evm/types/signer";
|
|
19
14
|
import { USDC_ON_SCROLL } from "../tokenFixtures";
|
|
20
15
|
|
|
21
16
|
type ScrollScenarioTransaction = ScenarioTransaction<EvmTransaction, Account>;
|
|
@@ -72,7 +67,6 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
72
67
|
]);
|
|
73
68
|
|
|
74
69
|
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
|
|
75
|
-
const signerContext: SignerContext<EvmSigner> = (_, fn) => fn(new LegacySignerEth(transport));
|
|
76
70
|
|
|
77
71
|
const lastBlockNumber = await provider.getBlockNumber();
|
|
78
72
|
// start indexing at next block
|
|
@@ -97,10 +91,7 @@ export const scenarioScroll: Scenario<EvmTransaction, Account> = {
|
|
|
97
91
|
initMswHandlers(getCoinConfig(scroll).info);
|
|
98
92
|
|
|
99
93
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
100
|
-
const currencyBridge =
|
|
101
|
-
await currencyBridge.preload(scroll);
|
|
102
|
-
const accountBridge = buildAccountBridge(signerContext);
|
|
103
|
-
const getAddress = resolver(signerContext);
|
|
94
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(transport, "scroll");
|
|
104
95
|
const { address } = await getAddress("", {
|
|
105
96
|
path: "44'/60'/0'/0/0",
|
|
106
97
|
currency: scroll,
|
package/src/scenarii/sonic.ts
CHANGED
|
@@ -59,7 +59,7 @@ const makeScenarioTransactions = ({ address }: { address: string }): SonicScenar
|
|
|
59
59
|
|
|
60
60
|
export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
61
61
|
name: "Ledger Live Basic S Transactions",
|
|
62
|
-
setup: async
|
|
62
|
+
setup: async () => {
|
|
63
63
|
const [{ transport, getOnSpeculosConfirmation }] = await Promise.all([
|
|
64
64
|
spawnSpeculos(`/${defaultNanoApp.firmware}/Sonic/app_${defaultNanoApp.version}.elf`, {
|
|
65
65
|
libraries: [
|
|
@@ -111,7 +111,7 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
111
111
|
initMswHandlers(getCoinConfig(sonic).info);
|
|
112
112
|
|
|
113
113
|
const onSignerConfirmation = getOnSpeculosConfirmation();
|
|
114
|
-
const { currencyBridge, accountBridge, getAddress } = getBridges(
|
|
114
|
+
const { currencyBridge, accountBridge, getAddress } = getBridges(transport, "sonic");
|
|
115
115
|
const { address } = await getAddress("", {
|
|
116
116
|
path: "44'/60'/0'/0/0",
|
|
117
117
|
currency: sonic,
|
|
@@ -157,7 +157,6 @@ export const scenarioSonic: Scenario<EvmTransaction, Account> = {
|
|
|
157
157
|
expect(account.subAccounts?.[0].balance.toFixed()).toBe(
|
|
158
158
|
ethers.parseUnits("20", USDC_ON_SONIC.units[0].magnitude).toString(),
|
|
159
159
|
);
|
|
160
|
-
// expect(account.operations.length).toBe(3);
|
|
161
160
|
},
|
|
162
161
|
teardown: async () => {
|
|
163
162
|
resetIndexer();
|