@ledgerhq/coin-evm 2.28.0-nightly.3 → 2.28.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/.eslintrc.js +0 -1
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +20 -32
- package/{lib-es/__fixtures__/ethereum-erc20-weth.json → lib/__fixtures__/ethereum-erc20-usd_tether__erc20_.json} +8 -8
- package/lib/__fixtures__/{optimism-erc20-usd_coin.json → scroll_sepolia-erc20-new_token_mock.json} +20 -21
- package/lib/__tests__/fixtures/accounts.fixtures.d.ts +1 -1
- package/lib/__tests__/fixtures/accounts.fixtures.d.ts.map +1 -1
- package/lib/__tests__/fixtures/accounts.fixtures.js +19 -2
- package/lib/__tests__/fixtures/accounts.fixtures.js.map +1 -1
- package/lib/__tests__/fixtures/common.fixtures.d.ts +0 -1
- package/lib/__tests__/fixtures/common.fixtures.d.ts.map +1 -1
- package/lib/__tests__/fixtures/common.fixtures.js +0 -1
- package/lib/__tests__/fixtures/common.fixtures.js.map +1 -1
- package/lib/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -1
- package/lib/__tests__/fixtures/prepareTransaction.fixtures.js +2 -3
- package/lib/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -1
- package/lib/__tests__/fixtures/synchronization.fixtures.d.ts +1 -1
- package/lib/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -1
- package/lib/__tests__/fixtures/synchronization.fixtures.js +18 -3
- package/lib/__tests__/fixtures/synchronization.fixtures.js.map +1 -1
- package/lib/__tests__/fixtures/transaction.fixtures.d.ts +2 -2
- package/lib/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -1
- package/lib/__tests__/fixtures/transaction.fixtures.js +2 -3
- package/lib/__tests__/fixtures/transaction.fixtures.js.map +1 -1
- package/lib/__tests__/unit/accounts.unit.test.js +27 -0
- package/lib/__tests__/unit/accounts.unit.test.js.map +1 -1
- package/lib/__tests__/unit/adapters/etherscan.unit.test.js +7 -72
- package/lib/__tests__/unit/adapters/etherscan.unit.test.js.map +1 -1
- package/lib/__tests__/unit/adapters/ledger.unit.test.js +2 -15
- package/lib/__tests__/unit/adapters/ledger.unit.test.js.map +1 -1
- package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js +0 -8
- package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -1
- package/lib/__tests__/unit/api/explorer/ledger.unit.test.js +0 -12
- package/lib/__tests__/unit/api/explorer/ledger.unit.test.js.map +1 -1
- package/lib/__tests__/unit/broadcast.unit.test.js +1 -3
- package/lib/__tests__/unit/broadcast.unit.test.js.map +1 -1
- package/lib/__tests__/unit/buildOptimisticOperation.unit.test.js +1 -3
- package/lib/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -1
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts +1 -1
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -1
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js +0 -1
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -1
- package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js +1 -3
- package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -1
- package/lib/__tests__/unit/getTransactionStatus.unit.test.js +1 -3
- package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -1
- package/lib/__tests__/unit/logic.unit.test.js +18 -22
- package/lib/__tests__/unit/logic.unit.test.js.map +1 -1
- package/lib/__tests__/unit/operation.test.js +2 -6
- package/lib/__tests__/unit/operation.test.js.map +1 -1
- package/lib/__tests__/unit/prepareTransaction.unit.test.js +17 -4
- package/lib/__tests__/unit/prepareTransaction.unit.test.js.map +1 -1
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +2 -2
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +2 -2
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +4 -2
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/js.d.ts +1 -2
- package/lib/bridge/js.d.ts.map +1 -1
- package/lib/bridge/js.js +1 -3
- package/lib/bridge/js.js.map +1 -1
- package/lib/bridge/preload.d.ts +0 -1
- package/lib/bridge/preload.d.ts.map +1 -1
- package/lib/bridge/preload.js +1 -10
- package/lib/bridge/preload.js.map +1 -1
- package/lib/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/deviceTransactionConfig.js +2 -2
- package/lib/deviceTransactionConfig.js.map +1 -1
- package/lib/logic/common.d.ts +0 -18
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +1 -35
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +12 -25
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/estimateFees.test.js +41 -93
- package/lib/logic/estimateFees.test.js.map +1 -1
- package/lib/logic/index.d.ts +0 -1
- package/lib/logic/index.d.ts.map +1 -1
- package/lib/logic/index.js +0 -1
- package/lib/logic/index.js.map +1 -1
- package/lib/types/transaction.d.ts +0 -9
- package/lib/types/transaction.d.ts.map +1 -1
- package/{lib/__fixtures__/ethereum-erc20-weth.json → lib-es/__fixtures__/ethereum-erc20-usd_tether__erc20_.json} +8 -8
- package/lib-es/__fixtures__/{optimism-erc20-usd_coin.json → scroll_sepolia-erc20-new_token_mock.json} +20 -21
- package/lib-es/__tests__/fixtures/accounts.fixtures.d.ts +1 -1
- package/lib-es/__tests__/fixtures/accounts.fixtures.d.ts.map +1 -1
- package/lib-es/__tests__/fixtures/accounts.fixtures.js +18 -1
- package/lib-es/__tests__/fixtures/accounts.fixtures.js.map +1 -1
- package/lib-es/__tests__/fixtures/common.fixtures.d.ts +0 -1
- package/lib-es/__tests__/fixtures/common.fixtures.d.ts.map +1 -1
- package/lib-es/__tests__/fixtures/common.fixtures.js +0 -1
- package/lib-es/__tests__/fixtures/common.fixtures.js.map +1 -1
- package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -1
- package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js +2 -3
- package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -1
- package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts +1 -1
- package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -1
- package/lib-es/__tests__/fixtures/synchronization.fixtures.js +18 -3
- package/lib-es/__tests__/fixtures/synchronization.fixtures.js.map +1 -1
- package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts +2 -2
- package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -1
- package/lib-es/__tests__/fixtures/transaction.fixtures.js +2 -3
- package/lib-es/__tests__/fixtures/transaction.fixtures.js.map +1 -1
- package/lib-es/__tests__/unit/accounts.unit.test.js +27 -0
- package/lib-es/__tests__/unit/accounts.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/adapters/etherscan.unit.test.js +7 -72
- package/lib-es/__tests__/unit/adapters/etherscan.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/adapters/ledger.unit.test.js +2 -15
- package/lib-es/__tests__/unit/adapters/ledger.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js +0 -8
- package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/api/explorer/ledger.unit.test.js +0 -12
- package/lib-es/__tests__/unit/api/explorer/ledger.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/broadcast.unit.test.js +2 -4
- package/lib-es/__tests__/unit/broadcast.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.js +2 -4
- package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts +1 -1
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -1
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js +0 -1
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js +2 -4
- package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js +2 -4
- package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/logic.unit.test.js +19 -23
- package/lib-es/__tests__/unit/logic.unit.test.js.map +1 -1
- package/lib-es/__tests__/unit/operation.test.js +3 -7
- package/lib-es/__tests__/unit/operation.test.js.map +1 -1
- package/lib-es/__tests__/unit/prepareTransaction.unit.test.js +17 -4
- package/lib-es/__tests__/unit/prepareTransaction.unit.test.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +2 -2
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +2 -2
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +5 -3
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/js.d.ts +1 -2
- package/lib-es/bridge/js.d.ts.map +1 -1
- package/lib-es/bridge/js.js +1 -3
- package/lib-es/bridge/js.js.map +1 -1
- package/lib-es/bridge/preload.d.ts +0 -1
- package/lib-es/bridge/preload.d.ts.map +1 -1
- package/lib-es/bridge/preload.js +0 -8
- package/lib-es/bridge/preload.js.map +1 -1
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/deviceTransactionConfig.js +2 -2
- package/lib-es/deviceTransactionConfig.js.map +1 -1
- package/lib-es/logic/common.d.ts +0 -18
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +0 -30
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +12 -25
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/estimateFees.test.js +41 -93
- package/lib-es/logic/estimateFees.test.js.map +1 -1
- package/lib-es/logic/index.d.ts +0 -1
- package/lib-es/logic/index.d.ts.map +1 -1
- package/lib-es/logic/index.js +0 -1
- package/lib-es/logic/index.js.map +1 -1
- package/lib-es/types/transaction.d.ts +0 -9
- package/lib-es/types/transaction.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/__tests__/fixtures/accounts.fixtures.ts +23 -1
- package/src/__tests__/fixtures/common.fixtures.ts +0 -1
- package/src/__tests__/fixtures/prepareTransaction.fixtures.ts +4 -4
- package/src/__tests__/fixtures/synchronization.fixtures.ts +20 -3
- package/src/__tests__/fixtures/transaction.fixtures.ts +3 -4
- package/src/__tests__/unit/accounts.unit.test.ts +36 -0
- package/src/__tests__/unit/adapters/etherscan.unit.test.ts +7 -87
- package/src/__tests__/unit/adapters/ledger.unit.test.ts +2 -20
- package/src/__tests__/unit/api/explorer/etherscan.unit.test.ts +0 -12
- package/src/__tests__/unit/api/explorer/ledger.unit.test.ts +0 -16
- package/src/__tests__/unit/broadcast.unit.test.ts +3 -5
- package/src/__tests__/unit/buildOptimisticOperation.unit.test.ts +2 -5
- package/src/__tests__/unit/deviceTransactionConfig.unit.test.ts +0 -1
- package/src/__tests__/unit/estimateMaxSpendable.unit.test.ts +3 -5
- package/src/__tests__/unit/getTransactionStatus.unit.test.ts +2 -5
- package/src/__tests__/unit/logic.unit.test.ts +29 -41
- package/src/__tests__/unit/operation.test.ts +5 -9
- package/src/__tests__/unit/prepareTransaction.unit.test.ts +18 -4
- package/src/adapters/etherscan.ts +2 -5
- package/src/adapters/ledger.ts +2 -5
- package/src/api/index.ts +5 -4
- package/src/bridge/js.ts +0 -4
- package/src/bridge/preload.ts +0 -8
- package/src/deviceTransactionConfig.ts +2 -3
- package/src/logic/common.ts +0 -52
- package/src/logic/estimateFees.test.ts +57 -98
- package/src/logic/estimateFees.ts +18 -28
- package/src/logic/index.ts +0 -1
- package/src/types/transaction.ts +0 -12
- package/lib/__fixtures__/cardano-native-8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552.json +0 -52
- package/lib/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0.json +0 -20
- package/lib/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0.json +0 -19
- package/lib/__tests__/fixtures/cryptoAssetsStore.fixtures.d.ts +0 -2
- package/lib/__tests__/fixtures/cryptoAssetsStore.fixtures.d.ts.map +0 -1
- package/lib/__tests__/fixtures/cryptoAssetsStore.fixtures.js +0 -44
- package/lib/__tests__/fixtures/cryptoAssetsStore.fixtures.js.map +0 -1
- package/lib/cryptoAssetsStore.d.ts +0 -5
- package/lib/cryptoAssetsStore.d.ts.map +0 -1
- package/lib/cryptoAssetsStore.js +0 -17
- package/lib/cryptoAssetsStore.js.map +0 -1
- package/lib/cryptoAssetsStore.test.d.ts +0 -2
- package/lib/cryptoAssetsStore.test.d.ts.map +0 -1
- package/lib/cryptoAssetsStore.test.js +0 -15
- package/lib/cryptoAssetsStore.test.js.map +0 -1
- package/lib/logic/validateIntent.d.ts +0 -4
- package/lib/logic/validateIntent.d.ts.map +0 -1
- package/lib/logic/validateIntent.js +0 -192
- package/lib/logic/validateIntent.js.map +0 -1
- package/lib/logic/validateIntent.test.d.ts +0 -2
- package/lib/logic/validateIntent.test.d.ts.map +0 -1
- package/lib/logic/validateIntent.test.js +0 -485
- package/lib/logic/validateIntent.test.js.map +0 -1
- package/lib-es/__fixtures__/cardano-native-8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552.json +0 -52
- package/lib-es/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0.json +0 -20
- package/lib-es/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0.json +0 -19
- package/lib-es/__tests__/fixtures/cryptoAssetsStore.fixtures.d.ts +0 -2
- package/lib-es/__tests__/fixtures/cryptoAssetsStore.fixtures.d.ts.map +0 -1
- package/lib-es/__tests__/fixtures/cryptoAssetsStore.fixtures.js +0 -19
- package/lib-es/__tests__/fixtures/cryptoAssetsStore.fixtures.js.map +0 -1
- package/lib-es/cryptoAssetsStore.d.ts +0 -5
- package/lib-es/cryptoAssetsStore.d.ts.map +0 -1
- package/lib-es/cryptoAssetsStore.js +0 -12
- package/lib-es/cryptoAssetsStore.js.map +0 -1
- package/lib-es/cryptoAssetsStore.test.d.ts +0 -2
- package/lib-es/cryptoAssetsStore.test.d.ts.map +0 -1
- package/lib-es/cryptoAssetsStore.test.js +0 -13
- package/lib-es/cryptoAssetsStore.test.js.map +0 -1
- package/lib-es/logic/validateIntent.d.ts +0 -4
- package/lib-es/logic/validateIntent.d.ts.map +0 -1
- package/lib-es/logic/validateIntent.js +0 -185
- package/lib-es/logic/validateIntent.js.map +0 -1
- package/lib-es/logic/validateIntent.test.d.ts +0 -2
- package/lib-es/logic/validateIntent.test.d.ts.map +0 -1
- package/lib-es/logic/validateIntent.test.js +0 -480
- package/lib-es/logic/validateIntent.test.js.map +0 -1
- package/src/__fixtures__/cardano-native-8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc34c4f4253544552.json +0 -52
- package/src/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0.json +0 -20
- package/src/__fixtures__/ethereum-erc20-usd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0.json +0 -19
- package/src/__fixtures__/ethereum-erc20-usd__coin-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48.json +0 -73
- package/src/__fixtures__/ethereum-erc20-weth.json +0 -73
- package/src/__fixtures__/optimism-erc20-usd_coin.json +0 -69
- package/src/__tests__/fixtures/cryptoAssetsStore.fixtures.ts +0 -24
- package/src/cryptoAssetsStore.test.ts +0 -19
- package/src/cryptoAssetsStore.ts +0 -16
- package/src/logic/validateIntent.test.ts +0 -659
- package/src/logic/validateIntent.ts +0 -274
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import { getNodeApi } from "../network/node";
|
|
3
|
-
import ledgerGasTracker from "../network/gasTracker/ledger";
|
|
4
|
-
import { setCoinConfig } from "../config";
|
|
5
3
|
import { estimateFees } from "./estimateFees";
|
|
6
4
|
jest.mock("../network/node", () => ({ getNodeApi: jest.fn() }));
|
|
7
5
|
describe("estimateFees", () => {
|
|
@@ -36,66 +34,20 @@ describe("estimateFees", () => {
|
|
|
36
34
|
mockNodeApi.getGasEstimation.mockResolvedValue(mockGasLimit);
|
|
37
35
|
mockNodeApi.getFeeData.mockResolvedValue(mockFeeData);
|
|
38
36
|
jest.mocked(getNodeApi).mockReturnValue(mockNodeApi);
|
|
39
|
-
setCoinConfig(() => ({
|
|
40
|
-
info: {
|
|
41
|
-
gasTracker: { type: "ledger", explorerId: "eth" },
|
|
42
|
-
},
|
|
43
|
-
}));
|
|
44
37
|
});
|
|
45
38
|
it("should estimate fees for native asset", async () => {
|
|
46
|
-
jest.spyOn(ledgerGasTracker, "getGasOptions").mockResolvedValue({
|
|
47
|
-
fast: {
|
|
48
|
-
maxFeePerGas: new BigNumber("30000000000"),
|
|
49
|
-
maxPriorityFeePerGas: new BigNumber("3000000000"),
|
|
50
|
-
gasPrice: new BigNumber("30000000000"),
|
|
51
|
-
nextBaseFee: null,
|
|
52
|
-
},
|
|
53
|
-
medium: {
|
|
54
|
-
maxFeePerGas: new BigNumber("20000000000"),
|
|
55
|
-
maxPriorityFeePerGas: new BigNumber("2000000000"),
|
|
56
|
-
gasPrice: new BigNumber("20000000000"),
|
|
57
|
-
nextBaseFee: null,
|
|
58
|
-
},
|
|
59
|
-
slow: {
|
|
60
|
-
maxFeePerGas: new BigNumber("10000000000"),
|
|
61
|
-
maxPriorityFeePerGas: new BigNumber("1000000000"),
|
|
62
|
-
gasPrice: new BigNumber("10000000000"),
|
|
63
|
-
nextBaseFee: null,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
39
|
const result = await estimateFees(mockCurrency, mockIntent);
|
|
67
40
|
expect(mockNodeApi.getFeeData).toHaveBeenCalledWith(mockCurrency, {
|
|
68
41
|
feesStrategy: "fast",
|
|
69
42
|
type: 0,
|
|
70
43
|
});
|
|
71
44
|
expect(result).toEqual({
|
|
72
|
-
value:
|
|
45
|
+
value: BigInt(mockGasLimit.multipliedBy(mockFeeData.gasPrice).toFixed()),
|
|
73
46
|
parameters: {
|
|
74
47
|
gasPrice: 20000000000n,
|
|
75
48
|
maxFeePerGas: 20000000000n,
|
|
76
49
|
maxPriorityFeePerGas: 2000000000n,
|
|
77
50
|
nextBaseFee: null,
|
|
78
|
-
gasLimit: 21000n,
|
|
79
|
-
gasOptions: {
|
|
80
|
-
fast: {
|
|
81
|
-
maxFeePerGas: 30000000000n,
|
|
82
|
-
maxPriorityFeePerGas: 3000000000n,
|
|
83
|
-
gasPrice: 30000000000n,
|
|
84
|
-
nextBaseFee: null,
|
|
85
|
-
},
|
|
86
|
-
medium: {
|
|
87
|
-
gasPrice: 20000000000n,
|
|
88
|
-
maxFeePerGas: 20000000000n,
|
|
89
|
-
maxPriorityFeePerGas: 2000000000n,
|
|
90
|
-
nextBaseFee: null,
|
|
91
|
-
},
|
|
92
|
-
slow: {
|
|
93
|
-
gasPrice: 10000000000n,
|
|
94
|
-
maxFeePerGas: 10000000000n,
|
|
95
|
-
maxPriorityFeePerGas: 1000000000n,
|
|
96
|
-
nextBaseFee: null,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
51
|
},
|
|
100
52
|
});
|
|
101
53
|
});
|
|
@@ -107,33 +59,12 @@ describe("estimateFees", () => {
|
|
|
107
59
|
type: 0,
|
|
108
60
|
});
|
|
109
61
|
expect(result).toEqual({
|
|
110
|
-
value:
|
|
62
|
+
value: BigInt(mockGasLimit.multipliedBy(mockFeeData.gasPrice).toFixed()),
|
|
111
63
|
parameters: {
|
|
112
64
|
gasPrice: 20000000000n,
|
|
113
65
|
maxFeePerGas: 20000000000n,
|
|
114
66
|
maxPriorityFeePerGas: 2000000000n,
|
|
115
67
|
nextBaseFee: null,
|
|
116
|
-
gasLimit: 21000n,
|
|
117
|
-
gasOptions: {
|
|
118
|
-
fast: {
|
|
119
|
-
maxFeePerGas: 30000000000n,
|
|
120
|
-
maxPriorityFeePerGas: 3000000000n,
|
|
121
|
-
gasPrice: 30000000000n,
|
|
122
|
-
nextBaseFee: null,
|
|
123
|
-
},
|
|
124
|
-
medium: {
|
|
125
|
-
gasPrice: 20000000000n,
|
|
126
|
-
maxFeePerGas: 20000000000n,
|
|
127
|
-
maxPriorityFeePerGas: 2000000000n,
|
|
128
|
-
nextBaseFee: null,
|
|
129
|
-
},
|
|
130
|
-
slow: {
|
|
131
|
-
gasPrice: 10000000000n,
|
|
132
|
-
maxFeePerGas: 10000000000n,
|
|
133
|
-
maxPriorityFeePerGas: 1000000000n,
|
|
134
|
-
nextBaseFee: null,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
68
|
},
|
|
138
69
|
});
|
|
139
70
|
});
|
|
@@ -141,35 +72,52 @@ describe("estimateFees", () => {
|
|
|
141
72
|
mockNodeApi.getFeeData.mockResolvedValue({ ...mockFeeData, gasPrice: null });
|
|
142
73
|
const result = await estimateFees(mockCurrency, mockIntent);
|
|
143
74
|
expect(result).toEqual({
|
|
144
|
-
value:
|
|
75
|
+
value: BigInt(0),
|
|
145
76
|
parameters: {
|
|
146
77
|
gasPrice: null,
|
|
147
78
|
maxFeePerGas: 20000000000n,
|
|
148
79
|
maxPriorityFeePerGas: 2000000000n,
|
|
149
80
|
nextBaseFee: null,
|
|
150
|
-
gasLimit: 21000n,
|
|
151
|
-
gasOptions: {
|
|
152
|
-
fast: {
|
|
153
|
-
maxFeePerGas: 30000000000n,
|
|
154
|
-
maxPriorityFeePerGas: 3000000000n,
|
|
155
|
-
gasPrice: 30000000000n,
|
|
156
|
-
nextBaseFee: null,
|
|
157
|
-
},
|
|
158
|
-
medium: {
|
|
159
|
-
gasPrice: 20000000000n,
|
|
160
|
-
maxFeePerGas: 20000000000n,
|
|
161
|
-
maxPriorityFeePerGas: 2000000000n,
|
|
162
|
-
nextBaseFee: null,
|
|
163
|
-
},
|
|
164
|
-
slow: {
|
|
165
|
-
gasPrice: 10000000000n,
|
|
166
|
-
maxFeePerGas: 10000000000n,
|
|
167
|
-
maxPriorityFeePerGas: 1000000000n,
|
|
168
|
-
nextBaseFee: null,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
81
|
},
|
|
172
82
|
});
|
|
173
83
|
});
|
|
84
|
+
it.each([
|
|
85
|
+
[
|
|
86
|
+
"legacy",
|
|
87
|
+
{
|
|
88
|
+
value: 8n,
|
|
89
|
+
parameters: {
|
|
90
|
+
gasPrice: 5n,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
"eip1559",
|
|
96
|
+
{
|
|
97
|
+
value: 8n,
|
|
98
|
+
parameters: {
|
|
99
|
+
maxFeePerGas: 2n,
|
|
100
|
+
maxPriorityFeePerGas: 3n,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
])("uses the given fees for a %s transaction type", async (type, customFees) => {
|
|
105
|
+
const getFeeData = jest.spyOn(mockNodeApi, "getFeeData");
|
|
106
|
+
const getGasEstimation = jest.spyOn(mockNodeApi, "getGasEstimation");
|
|
107
|
+
expect(await estimateFees({}, { type: `send-${type}` }, customFees)).toEqual(customFees);
|
|
108
|
+
expect(getFeeData).not.toHaveBeenCalled();
|
|
109
|
+
expect(getGasEstimation).not.toHaveBeenCalled();
|
|
110
|
+
});
|
|
111
|
+
it("ignores malformed or irrelevant custom fees", async () => {
|
|
112
|
+
const getFeeData = jest.spyOn(mockNodeApi, "getFeeData");
|
|
113
|
+
const getGasEstimation = jest.spyOn(mockNodeApi, "getGasEstimation");
|
|
114
|
+
expect(await estimateFees({}, {
|
|
115
|
+
type: "send-eip1559",
|
|
116
|
+
amount: 3n,
|
|
117
|
+
asset: { type: "native" },
|
|
118
|
+
}, { value: 8n, parameters: { gasPrice: 5n } })).not.toEqual({ value: 8n, parameters: { gasPrice: 5n } });
|
|
119
|
+
expect(getFeeData).toHaveBeenCalled();
|
|
120
|
+
expect(getGasEstimation).toHaveBeenCalled();
|
|
121
|
+
});
|
|
174
122
|
});
|
|
175
123
|
//# sourceMappingURL=estimateFees.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.test.js","sourceRoot":"","sources":["../../src/logic/estimateFees.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAOrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,
|
|
1
|
+
{"version":3,"file":"estimateFees.test.js","sourceRoot":"","sources":["../../src/logic/estimateFees.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAOrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,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,CAAC;AACnC,cAAc,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
|
package/lib-es/logic/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
|
|
@@ -85,12 +85,6 @@ export type FeeHistory = {
|
|
|
85
85
|
oldestBlock: string;
|
|
86
86
|
reward: string[][];
|
|
87
87
|
};
|
|
88
|
-
export type ApiFeeData = {
|
|
89
|
-
maxFeePerGas: bigint | null;
|
|
90
|
-
maxPriorityFeePerGas: bigint | null;
|
|
91
|
-
gasPrice: bigint | null;
|
|
92
|
-
nextBaseFee: bigint | null;
|
|
93
|
-
};
|
|
94
88
|
export type FeeData = {
|
|
95
89
|
maxFeePerGas: BigNumber | null;
|
|
96
90
|
maxPriorityFeePerGas: BigNumber | null;
|
|
@@ -104,9 +98,6 @@ export type FeeDataRaw = {
|
|
|
104
98
|
nextBaseFee: string | null;
|
|
105
99
|
};
|
|
106
100
|
export type Strategy = "slow" | "medium" | "fast";
|
|
107
|
-
export type ApiGasOptions = {
|
|
108
|
-
[key in Strategy]: ApiFeeData;
|
|
109
|
-
};
|
|
110
101
|
export type GasOptions = {
|
|
111
102
|
[key in Strategy]: FeeData;
|
|
112
103
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/types/transaction.ts"],"names":[],"mappings":";;AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EACL,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE/D,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACnD,MAAM,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,kBAAkB,CAAC;IAEzB,KAAK,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,SAAS,CAAC;IAEpB,cAAc,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAEvC,OAAO,EAAE,MAAM,CAAC;IAEhB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAEjC,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,cAAc,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAEvC,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB,GAAG,CAAC,EAAE,sBAAsB,CAAC;CAC9B,CAAC;AAGF,KAAK,kBAAkB,GAAG,kBAAkB,GAAG;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,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B,GAAG,IAAI,QAAQ,GAAG,UAAU;CAC9B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAChC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAClC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-evm",
|
|
3
|
-
"version": "2.28.0
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"description": "Ledger EVM Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
56
|
"react-native-get-random-values": "^1.8.0",
|
|
57
57
|
"rxjs": "^7.8.1",
|
|
58
|
-
"@ledgerhq/coin-framework": "^6.2.0
|
|
59
|
-
"@ledgerhq/cryptoassets": "^13.26.0
|
|
60
|
-
"@ledgerhq/devices": "8.5.
|
|
61
|
-
"@ledgerhq/domain-service": "^1.2.41
|
|
62
|
-
"@ledgerhq/errors": "^6.
|
|
63
|
-
"@ledgerhq/evm-tools": "^1.7.4
|
|
64
|
-
"@ledgerhq/live-env": "^2.
|
|
65
|
-
"@ledgerhq/live-network": "^2.0.
|
|
58
|
+
"@ledgerhq/coin-framework": "^6.2.0",
|
|
59
|
+
"@ledgerhq/cryptoassets": "^13.26.0",
|
|
60
|
+
"@ledgerhq/devices": "8.5.0",
|
|
61
|
+
"@ledgerhq/domain-service": "^1.2.41",
|
|
62
|
+
"@ledgerhq/errors": "^6.24.0",
|
|
63
|
+
"@ledgerhq/evm-tools": "^1.7.4",
|
|
64
|
+
"@ledgerhq/live-env": "^2.14.0",
|
|
65
|
+
"@ledgerhq/live-network": "^2.0.15",
|
|
66
66
|
"@ledgerhq/live-promise": "^0.1.1",
|
|
67
67
|
"@ledgerhq/logs": "^6.13.0"
|
|
68
68
|
},
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"prando": "^6.0.1",
|
|
83
83
|
"ts-jest": "^29.1.1",
|
|
84
84
|
"@ledgerhq/disable-network-setup": "^0.0.0",
|
|
85
|
-
"@ledgerhq/hw-app-eth": "^6.45.16
|
|
86
|
-
"@ledgerhq/types-cryptoassets": "^7.
|
|
87
|
-
"@ledgerhq/types-live": "^6.82.0
|
|
85
|
+
"@ledgerhq/hw-app-eth": "^6.45.16",
|
|
86
|
+
"@ledgerhq/types-cryptoassets": "^7.25.0",
|
|
87
|
+
"@ledgerhq/types-live": "^6.82.0"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"clean": "rimraf lib lib-es",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"lint:fix": "pnpm lint --fix",
|
|
99
99
|
"typecheck": "tsc --noEmit",
|
|
100
100
|
"test": "jest",
|
|
101
|
-
"test:debug": "node --inspect-
|
|
101
|
+
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand",
|
|
102
102
|
"test-integ": "jest --config=jest.integ.config.js",
|
|
103
103
|
"unimported": "unimported"
|
|
104
104
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
+
import { hashes as localTokensHashesByChainId } from "@ledgerhq/cryptoassets/data/evm/index";
|
|
2
3
|
import { ERC20Token } from "@ledgerhq/cryptoassets/types";
|
|
3
4
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
4
5
|
import { AccountShapeInfo } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
6
|
+
import { CryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/type";
|
|
7
|
+
import { setCryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/index";
|
|
8
|
+
import usdtTokenData from "../../__fixtures__/scroll_sepolia-erc20-mock_usdt.json";
|
|
9
|
+
import newTokenData from "../../__fixtures__/scroll_sepolia-erc20-new_token_mock.json";
|
|
5
10
|
import { makeOperation } from "./common.fixtures";
|
|
6
|
-
import "./cryptoAssetsStore.fixtures";
|
|
7
11
|
|
|
8
12
|
export const currency = getCryptoCurrencyById("scroll_sepolia");
|
|
9
13
|
export const fakeToken: ERC20Token = [
|
|
@@ -18,6 +22,10 @@ export const fakeToken: ERC20Token = [
|
|
|
18
22
|
false, // delisted
|
|
19
23
|
];
|
|
20
24
|
|
|
25
|
+
export const localCALHash =
|
|
26
|
+
localTokensHashesByChainId[
|
|
27
|
+
currency.ethereumLikeInfo!.chainId as keyof typeof localTokensHashesByChainId
|
|
28
|
+
];
|
|
21
29
|
export const getAccountShapeParameters: AccountShapeInfo = {
|
|
22
30
|
address: "0xkvn",
|
|
23
31
|
currency,
|
|
@@ -26,6 +34,20 @@ export const getAccountShapeParameters: AccountShapeInfo = {
|
|
|
26
34
|
index: 0,
|
|
27
35
|
};
|
|
28
36
|
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
38
|
+
setCryptoAssetsStore({
|
|
39
|
+
findTokenById: (id: string) => {
|
|
40
|
+
if (id === "scroll_sepolia/erc20/mock_usdt") {
|
|
41
|
+
return usdtTokenData;
|
|
42
|
+
} else if (id === "scroll_sepolia/erc20/new_token_mock") {
|
|
43
|
+
return newTokenData;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return undefined;
|
|
47
|
+
},
|
|
48
|
+
findTokenByAddressInCurrency: (_address: string, _currencyId: string) => undefined,
|
|
49
|
+
} as CryptoAssetsStore);
|
|
50
|
+
|
|
29
51
|
export const TMUSDTTransaction = makeOperation({
|
|
30
52
|
hash: "anyHash",
|
|
31
53
|
accountId:
|
|
@@ -15,7 +15,6 @@ import { encodeNftId } from "@ledgerhq/coin-framework/nft/nftId";
|
|
|
15
15
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
16
16
|
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
17
17
|
import { Account, DerivationMode, Operation, ProtoNFT, TokenAccount } from "@ledgerhq/types-live";
|
|
18
|
-
import "./cryptoAssetsStore.fixtures";
|
|
19
18
|
|
|
20
19
|
export const makeAccount = (
|
|
21
20
|
address: string,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
4
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
5
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
5
6
|
import { Account } from "@ledgerhq/types-live";
|
|
7
|
+
|
|
6
8
|
import { EvmNftTransaction, Transaction as EvmTransaction } from "../../types";
|
|
7
9
|
import ERC1155ABI from "../../abis/erc1155.abi.json";
|
|
8
10
|
import ERC721ABI from "../../abis/erc721.abi.json";
|
|
9
11
|
import ERC20ABI from "../../abis/erc20.abi.json";
|
|
10
|
-
import usdtTokenData from "../../__fixtures__/scroll_sepolia-erc20-mock_usdt.json";
|
|
11
12
|
|
|
12
13
|
import { makeAccount, makeTokenAccount } from "./common.fixtures";
|
|
13
14
|
|
|
@@ -18,8 +19,7 @@ const currency: CryptoCurrency = {
|
|
|
18
19
|
},
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
export const tokenAccount = makeTokenAccount("0xkvn", usdtTokenData as unknown as TokenCurrency);
|
|
22
|
+
export const tokenAccount = makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin"));
|
|
23
23
|
export const account = makeAccount("0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d", currency, [
|
|
24
24
|
tokenAccount,
|
|
25
25
|
]);
|
|
@@ -4,9 +4,12 @@ import BigNumber from "bignumber.js";
|
|
|
4
4
|
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
5
5
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
6
6
|
import { encodeSubOperationId } from "@ledgerhq/coin-framework/operation";
|
|
7
|
+
import { setCryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/index";
|
|
8
|
+
import { CryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/type";
|
|
7
9
|
import * as logic from "../../logic";
|
|
8
10
|
import { getCoinConfig } from "../../config";
|
|
9
|
-
import
|
|
11
|
+
import usdCoinTokenData from "../../__fixtures__/ethereum-erc20-usd__coin.json";
|
|
12
|
+
import usdTetherTokenData from "../../__fixtures__/ethereum-erc20-usd_tether__erc20_.json";
|
|
10
13
|
import {
|
|
11
14
|
makeAccount,
|
|
12
15
|
makeNft,
|
|
@@ -56,9 +59,9 @@ export const swapHistory = [
|
|
|
56
59
|
|
|
57
60
|
export const tokenCurrencies = [
|
|
58
61
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
59
|
-
|
|
62
|
+
Object.freeze(usdCoinTokenData as TokenCurrency),
|
|
60
63
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
61
|
-
|
|
64
|
+
Object.freeze(usdTetherTokenData as TokenCurrency),
|
|
62
65
|
];
|
|
63
66
|
|
|
64
67
|
export const tokenAccount = {
|
|
@@ -96,6 +99,20 @@ export const coinOperations = [
|
|
|
96
99
|
}),
|
|
97
100
|
];
|
|
98
101
|
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
103
|
+
setCryptoAssetsStore({
|
|
104
|
+
findTokenById: (id: string) => {
|
|
105
|
+
if (id === "ethereum/erc20/usd__coin") {
|
|
106
|
+
return usdCoinTokenData;
|
|
107
|
+
} else if (id === "ethereum/erc20/usd_tether__erc20_") {
|
|
108
|
+
return usdTetherTokenData;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return undefined;
|
|
112
|
+
},
|
|
113
|
+
findTokenByAddressInCurrency: (_address: string, _currencyId: string) => undefined,
|
|
114
|
+
} as CryptoAssetsStore);
|
|
115
|
+
|
|
99
116
|
export const tokenOperations = [
|
|
100
117
|
makeOperation({
|
|
101
118
|
hash: coinOperations[0].hash, // on purpose to make this token op a subOp of coinOp 1
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getTokenById } from "@ledgerhq/cryptoassets/tokens";
|
|
3
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
4
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
4
5
|
|
|
5
6
|
import {
|
|
@@ -11,7 +12,6 @@ import {
|
|
|
11
12
|
EvmNftTransactionRaw,
|
|
12
13
|
EvmNftTransaction,
|
|
13
14
|
} from "../../types";
|
|
14
|
-
import usdtTokenData from "../../__fixtures__/ethereum-erc20-usd__coin.json";
|
|
15
15
|
import { makeAccount, makeTokenAccount } from "./common.fixtures";
|
|
16
16
|
|
|
17
17
|
export const testData = Object.freeze(Buffer.from("testBufferString").toString("hex"));
|
|
@@ -217,8 +217,7 @@ export const currency: CryptoCurrency = Object.freeze({
|
|
|
217
217
|
},
|
|
218
218
|
});
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
export const tokenCurrency = Object.freeze(usdtTokenData as TokenCurrency);
|
|
220
|
+
export const tokenCurrency = Object.freeze(getTokenById("ethereum/erc20/usd__coin"));
|
|
222
221
|
export const tokenAccount = makeTokenAccount(
|
|
223
222
|
"0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d",
|
|
224
223
|
tokenCurrency,
|
|
@@ -4,6 +4,8 @@ import { tokens as localTokensByChainId } from "@ledgerhq/cryptoassets/data/evm/
|
|
|
4
4
|
import { fromAccountRaw, toAccountRaw } from "@ledgerhq/coin-framework/serialization/account";
|
|
5
5
|
import { decodeTokenAccountId } from "@ledgerhq/coin-framework/account";
|
|
6
6
|
import { __clearAllLists } from "@ledgerhq/cryptoassets/tokens";
|
|
7
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
8
|
+
import { getCryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/index";
|
|
7
9
|
import * as etherscanAPI from "../../network/explorer/etherscan";
|
|
8
10
|
import { __resetCALHash, getCALHash } from "../../logic";
|
|
9
11
|
import { getAccountShape } from "../../bridge/synchronization";
|
|
@@ -17,6 +19,10 @@ import {
|
|
|
17
19
|
NTMTransaction,
|
|
18
20
|
TMUSDTTransaction,
|
|
19
21
|
} from "../fixtures/accounts.fixtures";
|
|
22
|
+
import usdtTokenData from "../../__fixtures__/scroll_sepolia-erc20-mock_usdt.json";
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
25
|
+
const USDT_TOKEN = usdtTokenData as TokenCurrency;
|
|
20
26
|
|
|
21
27
|
jest.mock("axios");
|
|
22
28
|
const mockedAxios = jest.mocked(axios);
|
|
@@ -67,6 +73,9 @@ describe("EVM Family", () => {
|
|
|
67
73
|
});
|
|
68
74
|
|
|
69
75
|
it("should add an account and find no token account without a preload first", async () => {
|
|
76
|
+
const store = getCryptoAssetsStore();
|
|
77
|
+
jest.spyOn(store, "findTokenById").mockImplementation((_id: string) => undefined);
|
|
78
|
+
|
|
70
79
|
const { subAccounts } = await getAccountShape(getAccountShapeParameters, {
|
|
71
80
|
paginationConfig: {},
|
|
72
81
|
});
|
|
@@ -75,6 +84,15 @@ describe("EVM Family", () => {
|
|
|
75
84
|
});
|
|
76
85
|
|
|
77
86
|
it("should preload currency and add an account with 1 token account in it when there is nothing new in remote CAL", async () => {
|
|
87
|
+
const store = getCryptoAssetsStore();
|
|
88
|
+
jest.spyOn(store, "findTokenById").mockImplementation((id: string) => {
|
|
89
|
+
if (id === "scroll_sepolia/erc20/mock_usdt") {
|
|
90
|
+
return USDT_TOKEN;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return undefined;
|
|
94
|
+
});
|
|
95
|
+
|
|
78
96
|
mockedAxios.get.mockImplementationOnce(() => {
|
|
79
97
|
throw new axios.AxiosError("", "", undefined, undefined, { status: 304 } as AxiosResponse);
|
|
80
98
|
});
|
|
@@ -190,6 +208,15 @@ describe("EVM Family", () => {
|
|
|
190
208
|
});
|
|
191
209
|
|
|
192
210
|
it("should preload again a currency and get the same account with 2 tokens accounts even with a failing CAL service", async () => {
|
|
211
|
+
const store = getCryptoAssetsStore();
|
|
212
|
+
jest.spyOn(store, "findTokenById").mockImplementation((id: string) => {
|
|
213
|
+
if (id === "scroll_sepolia/erc20/mock_usdt") {
|
|
214
|
+
return USDT_TOKEN;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return undefined;
|
|
218
|
+
});
|
|
219
|
+
|
|
193
220
|
mockedAxios.get.mockImplementationOnce(async (url, { params } = {}) => {
|
|
194
221
|
if (
|
|
195
222
|
url === "https://crypto-assets-service.api.ledger.com/v1/tokens" &&
|
|
@@ -240,6 +267,15 @@ describe("EVM Family", () => {
|
|
|
240
267
|
});
|
|
241
268
|
|
|
242
269
|
it("should hydrate the tokens necessary to deserialize an account with 1 token account when there is nothing new in remote CAL", async () => {
|
|
270
|
+
const store = getCryptoAssetsStore();
|
|
271
|
+
jest.spyOn(store, "findTokenById").mockImplementation((id: string) => {
|
|
272
|
+
if (id === "scroll_sepolia/erc20/mock_usdt") {
|
|
273
|
+
return USDT_TOKEN;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return undefined;
|
|
277
|
+
});
|
|
278
|
+
|
|
243
279
|
const preloaded = await preload(currency);
|
|
244
280
|
await hydrate(preloaded, currency);
|
|
245
281
|
const account = await getAccountShape(getAccountShapeParameters, {
|