@ledgerhq/coin-evm 5.4.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +191 -0
- package/docs/evm-family-integration-process/README.md +1 -1
- package/knip.json +2 -3
- package/lib/adapters/blockOperations.js +6 -6
- package/lib/adapters/blockOperations.js.map +1 -1
- package/lib/adapters/etherscan.js +23 -23
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.js +17 -17
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.js +4 -4
- package/lib/api/index.js.map +1 -1
- package/lib/config.d.ts +21 -15
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +5 -25
- package/lib/config.js.map +1 -1
- package/lib/errors.d.ts +9 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +15 -1
- package/lib/errors.js.map +1 -1
- package/lib/logic/broadcast.js +1 -1
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/common.d.ts +2 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +4 -4
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +2 -2
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +9 -9
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +50 -16
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +19 -11
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.js +1 -1
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +1 -1
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/index.d.ts +2 -0
- package/lib/logic/index.d.ts.map +1 -1
- package/lib/logic/index.js +4 -0
- package/lib/logic/index.js.map +1 -1
- package/lib/logic/lastBlock.js +1 -1
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +10 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +12 -12
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic-public/index.d.ts +3 -0
- package/lib/logic-public/index.d.ts.map +1 -0
- package/lib/logic-public/index.js +19 -0
- package/lib/logic-public/index.js.map +1 -0
- package/lib/{utils.d.ts → logic-public/utils.d.ts} +0 -44
- package/lib/logic-public/utils.d.ts.map +1 -0
- package/lib/logic-public/utils.js +166 -0
- package/lib/logic-public/utils.js.map +1 -0
- package/lib/logic.d.ts +2 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +3 -3
- package/lib/logic.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +16 -3
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +61 -6
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts +50 -4
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +286 -37
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/none.d.ts +1 -0
- package/lib/network/explorer/none.d.ts.map +1 -1
- package/lib/network/explorer/none.js +4 -1
- package/lib/network/explorer/none.js.map +1 -1
- package/lib/network/explorer/types.d.ts +15 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/index.d.ts +5 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +23 -0
- package/lib/network/index.js.map +1 -0
- package/lib/network/node/explorerProxy.d.ts +27 -0
- package/lib/network/node/explorerProxy.d.ts.map +1 -0
- package/lib/network/node/explorerProxy.js +262 -0
- package/lib/network/node/explorerProxy.js.map +1 -0
- package/lib/network/node/index.d.ts +2 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +11 -10
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.js +7 -7
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +2 -2
- package/lib/network/node/rpc.common.js +19 -19
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/withNodeSources.d.ts +21 -0
- package/lib/network/node/withNodeSources.d.ts.map +1 -0
- package/lib/network/node/withNodeSources.js +78 -0
- package/lib/network/node/withNodeSources.js.map +1 -0
- package/lib/nodeSources.d.ts +15 -0
- package/lib/nodeSources.d.ts.map +1 -0
- package/lib/nodeSources.js +33 -0
- package/lib/nodeSources.js.map +1 -0
- package/lib/staking/contracts.js +1 -1
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/fetchers.js +1 -1
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/operations/sei.js +1 -1
- package/lib/staking/operations/sei.js.map +1 -1
- package/lib/staking/prepareIntents.js +3 -3
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/rewards.js +1 -1
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/transactionData.js +2 -2
- package/lib/staking/transactionData.js.map +1 -1
- package/lib/staking/utils.d.ts +45 -0
- package/lib/staking/utils.d.ts.map +1 -0
- package/lib/{utils.js → staking/utils.js} +5 -164
- package/lib/staking/utils.js.map +1 -0
- package/lib/staking/validators/sei.js +1 -1
- package/lib/staking/validators/sei.js.map +1 -1
- package/lib/types/staking.d.ts +2 -2
- package/lib-es/adapters/blockOperations.js +1 -1
- package/lib-es/adapters/blockOperations.js.map +1 -1
- package/lib-es/adapters/etherscan.js +1 -1
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.js +1 -1
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.js +2 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/config.d.ts +21 -15
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -21
- package/lib-es/config.js.map +1 -1
- package/lib-es/errors.d.ts +9 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +13 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/logic/broadcast.js +1 -1
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/common.d.ts +2 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +3 -3
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +2 -2
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +6 -6
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +50 -16
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +16 -8
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.js +1 -1
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +1 -1
- package/lib-es/logic/getNextSequence.js.map +1 -1
- package/lib-es/logic/index.d.ts +2 -0
- package/lib-es/logic/index.d.ts.map +1 -1
- package/lib-es/logic/index.js +4 -0
- package/lib-es/logic/index.js.map +1 -1
- package/lib-es/logic/lastBlock.js +1 -1
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +10 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +4 -4
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic-public/index.d.ts +3 -0
- package/lib-es/logic-public/index.d.ts.map +1 -0
- package/lib-es/logic-public/index.js +4 -0
- package/lib-es/logic-public/index.js.map +1 -0
- package/lib-es/{utils.d.ts → logic-public/utils.d.ts} +0 -44
- package/lib-es/logic-public/utils.d.ts.map +1 -0
- package/lib-es/logic-public/utils.js +150 -0
- package/lib-es/logic-public/utils.js.map +1 -0
- package/lib-es/logic.d.ts +2 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +3 -3
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +16 -3
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +60 -5
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts +50 -4
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +283 -37
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/none.d.ts +1 -0
- package/lib-es/network/explorer/none.d.ts.map +1 -1
- package/lib-es/network/explorer/none.js +2 -0
- package/lib-es/network/explorer/none.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +15 -2
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/index.d.ts +5 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.js +7 -0
- package/lib-es/network/index.js.map +1 -0
- package/lib-es/network/node/explorerProxy.d.ts +27 -0
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -0
- package/lib-es/network/node/explorerProxy.js +254 -0
- package/lib-es/network/node/explorerProxy.js.map +1 -0
- package/lib-es/network/node/index.d.ts +2 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +11 -10
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.js +1 -1
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +2 -2
- package/lib-es/network/node/rpc.common.js +3 -3
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/withNodeSources.d.ts +21 -0
- package/lib-es/network/node/withNodeSources.d.ts.map +1 -0
- package/lib-es/network/node/withNodeSources.js +74 -0
- package/lib-es/network/node/withNodeSources.js.map +1 -0
- package/lib-es/nodeSources.d.ts +15 -0
- package/lib-es/nodeSources.d.ts.map +1 -0
- package/lib-es/nodeSources.js +28 -0
- package/lib-es/nodeSources.js.map +1 -0
- package/lib-es/staking/contracts.js +1 -1
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/fetchers.js +1 -1
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/operations/sei.js +1 -1
- package/lib-es/staking/operations/sei.js.map +1 -1
- package/lib-es/staking/prepareIntents.js +1 -1
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/rewards.js +1 -1
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/transactionData.js +1 -1
- package/lib-es/staking/transactionData.js.map +1 -1
- package/lib-es/staking/utils.d.ts +45 -0
- package/lib-es/staking/utils.d.ts.map +1 -0
- package/lib-es/{utils.js → staking/utils.js} +1 -147
- package/lib-es/staking/utils.js.map +1 -0
- package/lib-es/staking/validators/sei.js +1 -1
- package/lib-es/staking/validators/sei.js.map +1 -1
- package/lib-es/types/staking.d.ts +2 -2
- package/package.json +72 -7
- package/src/adapters/blockOperations.ts +1 -1
- package/src/adapters/etherscan.ts +1 -1
- package/src/adapters/ledger.ts +1 -1
- package/src/api/index.monad_testnet.integ.test.ts +95 -4
- package/src/api/index.ts +2 -2
- package/src/config.ts +22 -34
- package/src/errors.ts +13 -0
- package/src/fixtures/context.fixtures.ts +6 -1
- package/src/logic/broadcast.ts +1 -1
- package/src/logic/common.ts +4 -2
- package/src/logic/craftTransaction.ts +2 -1
- package/src/logic/estimateFees.ts +20 -6
- package/src/logic/getBalance.ts +72 -26
- package/src/logic/getBlock.ts +26 -14
- package/src/logic/getBlockInfo.ts +1 -1
- package/src/logic/getNextSequence.ts +4 -1
- package/src/logic/index.ts +4 -0
- package/src/logic/lastBlock.ts +1 -1
- package/src/logic/listOperations.ts +14 -1
- package/src/logic/tests/broadcast.integ.test.ts +53 -0
- package/src/logic/{broadcast.test.ts → tests/broadcast.test.ts} +7 -7
- package/src/logic/{broadcastSource.test.ts → tests/broadcastSource.test.ts} +6 -6
- package/src/logic/{combine.test.ts → tests/combine.test.ts} +1 -1
- package/src/logic/{common.test.ts → tests/common.test.ts} +45 -21
- package/src/logic/{computeGasLimit.test.ts → tests/computeGasLimit.test.ts} +2 -2
- package/src/logic/{craftTransaction.test.ts → tests/craftTransaction.test.ts} +7 -7
- package/src/logic/{craftTransactionData.test.ts → tests/craftTransactionData.test.ts} +4 -4
- package/src/logic/{estimateFees.test.ts → tests/estimateFees.test.ts} +12 -12
- package/src/logic/tests/getBalance.test.ts +602 -0
- package/src/logic/{getBlock.test.ts → tests/getBlock.test.ts} +182 -89
- package/src/logic/{getBlockInfo.test.ts → tests/getBlockInfo.test.ts} +8 -8
- package/src/logic/{getErc20Data.test.ts → tests/getErc20Data.test.ts} +1 -1
- package/src/logic/{getNextSequence.test.ts → tests/getNextSequence.test.ts} +7 -7
- package/src/logic/{getStakes.test.ts → tests/getStakes.test.ts} +13 -13
- package/src/logic/{internalTransactionsFetcher.test.ts → tests/internalTransactionsFetcher.test.ts} +8 -8
- package/src/logic/{lastBlock.test.ts → tests/lastBlock.test.ts} +7 -7
- package/src/logic/{listOperations.test.ts → tests/listOperations.test.ts} +125 -6
- package/src/logic/{validateAddress.test.ts → tests/validateAddress.test.ts} +1 -1
- package/src/logic/{validateIntent.test.ts → tests/validateIntent.test.ts} +80 -78
- package/src/logic/validateIntent.ts +7 -4
- package/src/logic-public/index.ts +18 -0
- package/src/{utils.test.ts → logic-public/tests/utils.test.ts} +1 -27
- package/src/logic-public/utils.ts +184 -0
- package/src/logic.test.ts +5 -59
- package/src/logic.ts +5 -3
- package/src/network/explorer/etherscan.test.ts +403 -195
- package/src/network/explorer/etherscan.ts +99 -10
- package/src/network/explorer/index.test.ts +27 -0
- package/src/network/explorer/ledger.test.ts +791 -62
- package/src/network/explorer/ledger.ts +426 -54
- package/src/network/explorer/none.ts +3 -0
- package/src/network/explorer/types.ts +29 -5
- package/src/network/index.ts +7 -0
- package/src/network/node/explorerProxy.test.ts +673 -0
- package/src/network/node/explorerProxy.ts +308 -0
- package/src/network/node/index.memoization.test.ts +22 -10
- package/src/network/node/index.test.ts +6 -3
- package/src/network/node/index.ts +11 -7
- package/src/network/node/ledger.ts +1 -1
- package/src/network/node/rpc.common.ts +3 -3
- package/src/network/node/rpc.test.ts +66 -105
- package/src/network/node/withNodeSources.test.ts +240 -0
- package/src/network/node/withNodeSources.ts +95 -0
- package/src/nodeSources.ts +38 -0
- package/src/staking/contracts.ts +1 -1
- package/src/staking/encoder.test.ts +1 -1
- package/src/staking/fetchers.ts +1 -1
- package/src/staking/operations/sei.ts +1 -1
- package/src/staking/prepareIntents.ts +1 -1
- package/src/staking/redelegations.test.ts +1 -1
- package/src/staking/rewards.test.ts +1 -1
- package/src/staking/rewards.ts +1 -1
- package/src/staking/transactionData.ts +1 -1
- package/src/staking/unbondings.test.ts +1 -1
- package/src/staking/utils.test.ts +25 -0
- package/src/{utils.ts → staking/utils.ts} +2 -182
- package/src/staking/validators/sei.ts +1 -1
- package/src/types/staking.ts +2 -2
- package/lib/constants.d.ts +0 -2
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js +0 -11
- package/lib/constants.js.map +0 -1
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js.map +0 -1
- package/lib-es/constants.d.ts +0 -2
- package/lib-es/constants.d.ts.map +0 -1
- package/lib-es/constants.js +0 -7
- package/lib-es/constants.js.map +0 -1
- package/lib-es/utils.d.ts.map +0 -1
- package/lib-es/utils.js.map +0 -1
- package/src/constants.ts +0 -9
- package/src/logic/broadcast.integ.test.ts +0 -46
- package/src/logic/getBalance.test.ts +0 -362
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
5
|
-
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '
|
|
6
|
-
import { getNodeApi } from '
|
|
7
|
-
import { mockNodeApi } from '
|
|
8
|
-
import { getBlockInfo } from '
|
|
9
|
-
|
|
10
|
-
jest.mock('
|
|
11
|
-
...jest.requireActual('
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
6
|
+
import { getNodeApi } from '../../network/node'
|
|
7
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
8
|
+
import { getBlockInfo } from '../getBlockInfo'
|
|
9
|
+
|
|
10
|
+
jest.mock('../../network/node', () => ({
|
|
11
|
+
...jest.requireActual('../../network/node'),
|
|
12
12
|
getNodeApi: jest.fn(),
|
|
13
13
|
}))
|
|
14
14
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
5
|
-
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '
|
|
6
|
-
import { getNodeApi } from '
|
|
7
|
-
import { mockNodeApi } from '
|
|
8
|
-
import { getNextSequence } from '
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
6
|
+
import { getNodeApi } from '../../network/node'
|
|
7
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
8
|
+
import { getNextSequence } from '../getNextSequence'
|
|
9
9
|
|
|
10
|
-
jest.mock('
|
|
11
|
-
...jest.requireActual('
|
|
10
|
+
jest.mock('../../network/node', () => ({
|
|
11
|
+
...jest.requireActual('../../network/node'),
|
|
12
12
|
getNodeApi: jest.fn(),
|
|
13
13
|
}))
|
|
14
14
|
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { createMockEvmContext } from '
|
|
5
|
-
import { mkJsonRpcProvider, mkResult } from '
|
|
6
|
-
import { withApi } from '
|
|
7
|
-
import { encodeStakingData, decodeStakingResult } from '
|
|
8
|
-
import { fetchUnbondings } from '
|
|
9
|
-
import { getValidators } from '
|
|
10
|
-
import { getStakes } from '
|
|
11
|
-
|
|
12
|
-
jest.mock('
|
|
13
|
-
...jest.requireActual('
|
|
4
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
5
|
+
import { mkJsonRpcProvider, mkResult } from '../../fixtures/ethers.fixtures'
|
|
6
|
+
import { withApi } from '../../network/node/rpc.common'
|
|
7
|
+
import { encodeStakingData, decodeStakingResult } from '../../staking/encoder'
|
|
8
|
+
import { fetchUnbondings } from '../../staking/unbondings'
|
|
9
|
+
import { getValidators } from '../../staking/validators'
|
|
10
|
+
import { getStakes } from '../getStakes'
|
|
11
|
+
|
|
12
|
+
jest.mock('../../network/node/rpc.common', () => ({
|
|
13
|
+
...jest.requireActual('../../network/node/rpc.common'),
|
|
14
14
|
withApi: jest.fn(),
|
|
15
15
|
}))
|
|
16
16
|
|
|
17
|
-
jest.mock('
|
|
17
|
+
jest.mock('../../staking/encoder', () => ({
|
|
18
18
|
encodeStakingData: jest.fn(),
|
|
19
19
|
decodeStakingResult: jest.fn(),
|
|
20
20
|
}))
|
|
21
21
|
|
|
22
|
-
jest.mock('
|
|
22
|
+
jest.mock('../../staking/validators', () => ({
|
|
23
23
|
getValidators: jest.fn(),
|
|
24
24
|
}))
|
|
25
25
|
|
|
26
|
-
jest.mock('
|
|
26
|
+
jest.mock('../../staking/unbondings', () => ({
|
|
27
27
|
fetchUnbondings: jest.fn(),
|
|
28
28
|
}))
|
|
29
29
|
|
package/src/logic/{internalTransactionsFetcher.test.ts → tests/internalTransactionsFetcher.test.ts}
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { SourceFetcher } from '
|
|
4
|
+
import type { SourceFetcher } from '../internalTransactionsFetcher'
|
|
5
5
|
import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
|
|
6
|
-
import { internalTxSourcesFromList } from '
|
|
7
|
-
import { SourceUnavailableError } from '
|
|
6
|
+
import { internalTxSourcesFromList } from '../../config'
|
|
7
|
+
import { SourceUnavailableError } from '../../errors'
|
|
8
8
|
import {
|
|
9
9
|
createMockEvmConfigInfo,
|
|
10
10
|
mkEtherscanExplorer,
|
|
11
11
|
mkExternalNode,
|
|
12
12
|
mkLedgerExplorer,
|
|
13
|
-
} from '
|
|
14
|
-
import { getInternalTransactionsByBlock } from '
|
|
15
|
-
import { mockNodeApi } from '
|
|
16
|
-
import { composeInternalTxsFetcher, makeSourceFetchers } from '
|
|
13
|
+
} from '../../fixtures/context.fixtures'
|
|
14
|
+
import { getInternalTransactionsByBlock } from '../../network/explorer/etherscan'
|
|
15
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
16
|
+
import { composeInternalTxsFetcher, makeSourceFetchers } from '../internalTransactionsFetcher'
|
|
17
17
|
|
|
18
|
-
jest.mock('
|
|
18
|
+
jest.mock('../../network/explorer/etherscan', () => ({
|
|
19
19
|
getInternalTransactionsByBlock: jest.fn().mockResolvedValue([]),
|
|
20
20
|
}))
|
|
21
21
|
|
|
@@ -6,14 +6,14 @@ import type {
|
|
|
6
6
|
EvmConfigInfo,
|
|
7
7
|
ExternalNodeConfig,
|
|
8
8
|
LedgerNodeConfig,
|
|
9
|
-
} from '
|
|
10
|
-
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '
|
|
11
|
-
import { getNodeApi } from '
|
|
12
|
-
import { mockNodeApi } from '
|
|
13
|
-
import { lastBlock } from '
|
|
9
|
+
} from '../../config'
|
|
10
|
+
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
11
|
+
import { getNodeApi } from '../../network/node'
|
|
12
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
13
|
+
import { lastBlock } from '../lastBlock'
|
|
14
14
|
|
|
15
|
-
jest.mock('
|
|
16
|
-
...jest.requireActual('
|
|
15
|
+
jest.mock('../../network/node', () => ({
|
|
16
|
+
...jest.requireActual('../../network/node'),
|
|
17
17
|
getNodeApi: jest.fn(),
|
|
18
18
|
}))
|
|
19
19
|
|
|
@@ -1,23 +1,53 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfig, EvmContext } from '
|
|
5
|
-
import type { ExplorerApi } from '
|
|
4
|
+
import type { EvmConfig, EvmContext } from '../../config'
|
|
5
|
+
import type { ExplorerApi } from '../../network/explorer/types'
|
|
6
|
+
import type { LedgerExplorerOperation } from '../../types'
|
|
6
7
|
import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
8
|
+
import type { AxiosRequestConfig } from 'axios'
|
|
9
|
+
import { InvalidParameterError } from '@ledgerhq/coin-module-framework/errors'
|
|
10
|
+
import axios from 'axios'
|
|
7
11
|
import BigNumber from 'bignumber.js'
|
|
8
12
|
import {
|
|
9
13
|
createMockEvmContext,
|
|
10
14
|
mkEtherscanExplorer,
|
|
11
15
|
mkLedgerExplorer,
|
|
12
|
-
} from '
|
|
13
|
-
import etherscanExplorer from '
|
|
14
|
-
import ledgerExplorer from '
|
|
15
|
-
import { listOperations } from '
|
|
16
|
+
} from '../../fixtures/context.fixtures'
|
|
17
|
+
import etherscanExplorer from '../../network/explorer/etherscan'
|
|
18
|
+
import ledgerExplorer from '../../network/explorer/ledger'
|
|
19
|
+
import { listOperations } from '../listOperations'
|
|
16
20
|
|
|
17
21
|
describe('listOperations', () => {
|
|
18
22
|
const currency = ''
|
|
19
23
|
const address = 'address'
|
|
20
24
|
|
|
25
|
+
describe('limit validation', () => {
|
|
26
|
+
it.each([[0], [-1]])(
|
|
27
|
+
'rejects the non-positive limit %i instead of walking on it',
|
|
28
|
+
async (limit) => {
|
|
29
|
+
const request = jest
|
|
30
|
+
.spyOn(axios, 'request')
|
|
31
|
+
.mockResolvedValue({ data: { data: [], token: '' } })
|
|
32
|
+
|
|
33
|
+
await expect(
|
|
34
|
+
listOperations(
|
|
35
|
+
ctxWithExplorer(mkLedgerExplorer({ explorerId: 'eth' })),
|
|
36
|
+
currency,
|
|
37
|
+
address,
|
|
38
|
+
{
|
|
39
|
+
minHeight: 0,
|
|
40
|
+
limit,
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
).rejects.toBeInstanceOf(InvalidParameterError)
|
|
44
|
+
// Nothing reaches the explorer: a zero page size used to make the paged walk double a
|
|
45
|
+
// zero forever, so this has to be caught before the first request.
|
|
46
|
+
expect(request).not.toHaveBeenCalled()
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
})
|
|
50
|
+
|
|
21
51
|
// The logic layer resolves config from the threaded context, so tests carry their explorer
|
|
22
52
|
// config on the context instead of seeding the module-level singleton.
|
|
23
53
|
const ctxWithExplorer = (explorer: EvmConfig['explorer']): EvmContext =>
|
|
@@ -545,6 +575,7 @@ describe('listOperations', () => {
|
|
|
545
575
|
// defaults to "desc" without limit
|
|
546
576
|
undefinedLimit,
|
|
547
577
|
'desc',
|
|
578
|
+
testContext.logger,
|
|
548
579
|
],
|
|
549
580
|
],
|
|
550
581
|
})
|
|
@@ -1193,6 +1224,94 @@ describe('listOperations', () => {
|
|
|
1193
1224
|
}
|
|
1194
1225
|
)
|
|
1195
1226
|
|
|
1227
|
+
describe('ledger explorer pagination parameters reach the real arm', () => {
|
|
1228
|
+
const address = '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d'
|
|
1229
|
+
|
|
1230
|
+
// Minimal record: `from` is the requested address so it maps to exactly one operation.
|
|
1231
|
+
const record = (height: number, hash: string): LedgerExplorerOperation => ({
|
|
1232
|
+
hash,
|
|
1233
|
+
transaction_type: 2,
|
|
1234
|
+
nonce: '0x0',
|
|
1235
|
+
nonce_value: 0,
|
|
1236
|
+
value: '0',
|
|
1237
|
+
gas: '0',
|
|
1238
|
+
gas_price: '0',
|
|
1239
|
+
max_fee_per_gas: null,
|
|
1240
|
+
max_priority_fee_per_gas: null,
|
|
1241
|
+
from: address,
|
|
1242
|
+
to: '0x0000000000000000000000000000000000000009',
|
|
1243
|
+
transfer_events: [],
|
|
1244
|
+
erc721_transfer_events: [],
|
|
1245
|
+
erc1155_transfer_events: [],
|
|
1246
|
+
approval_events: [],
|
|
1247
|
+
actions: [],
|
|
1248
|
+
confirmations: 1,
|
|
1249
|
+
input: null,
|
|
1250
|
+
gas_used: '0',
|
|
1251
|
+
cumulative_gas_used: '0',
|
|
1252
|
+
status: 1,
|
|
1253
|
+
received_at: '2023-01-01T00:00:00Z',
|
|
1254
|
+
block: { hash: '0xblock', height, time: '2023-01-01T00:00:00Z' },
|
|
1255
|
+
})
|
|
1256
|
+
|
|
1257
|
+
// A prior test in this file may have left `ledgerExplorer.getOperations` spied with
|
|
1258
|
+
// `mockResolvedValue` (the outer `afterEach` only clears call state, it does not restore the
|
|
1259
|
+
// original implementation) — restore it so this suite drives the real arm.
|
|
1260
|
+
beforeEach(() => {
|
|
1261
|
+
jest.restoreAllMocks()
|
|
1262
|
+
})
|
|
1263
|
+
|
|
1264
|
+
afterEach(() => {
|
|
1265
|
+
jest.restoreAllMocks()
|
|
1266
|
+
})
|
|
1267
|
+
|
|
1268
|
+
it.each([['asc'], ['desc']] as const)(
|
|
1269
|
+
'forwards options.limit/cursor/order to the ledger explorer request and returns its cursor as `next` (%s)',
|
|
1270
|
+
async (order) => {
|
|
1271
|
+
// The boundary record (height 11) stands for one already delivered by a previous page;
|
|
1272
|
+
// the explorer is expected to hand it back again (skip-through-hash territory), followed
|
|
1273
|
+
// by the two genuinely new records.
|
|
1274
|
+
const allRecords = [record(11, '0xh11'), record(10, '0xh10'), record(9, '0xh9')]
|
|
1275
|
+
const testContext = ctxWithExplorer({ type: 'ledger', explorerId: 'eth' })
|
|
1276
|
+
const request = jest
|
|
1277
|
+
.spyOn(axios, 'request')
|
|
1278
|
+
.mockImplementation(async ({ params }: AxiosRequestConfig) => {
|
|
1279
|
+
if (params.token !== undefined) {
|
|
1280
|
+
throw new Error('the paged path must not use the explorer continuation token')
|
|
1281
|
+
}
|
|
1282
|
+
return { data: { data: allRecords.slice(0, params.batch_size), token: '' } }
|
|
1283
|
+
})
|
|
1284
|
+
|
|
1285
|
+
const { next } = await listOperations(testContext, '', address, {
|
|
1286
|
+
minHeight: 0,
|
|
1287
|
+
limit: 3,
|
|
1288
|
+
cursor: '11:0xh11',
|
|
1289
|
+
order,
|
|
1290
|
+
})
|
|
1291
|
+
|
|
1292
|
+
expect(request).toHaveBeenCalledWith(
|
|
1293
|
+
expect.objectContaining({
|
|
1294
|
+
params: expect.objectContaining({
|
|
1295
|
+
batch_size: 3,
|
|
1296
|
+
order: order === 'asc' ? 'ascending' : 'descending',
|
|
1297
|
+
}),
|
|
1298
|
+
})
|
|
1299
|
+
)
|
|
1300
|
+
// The cursor forwarded by `listOperations` reached the explorer as the resumed window's
|
|
1301
|
+
// bound: descending caps at to_height, ascending floors at from_height.
|
|
1302
|
+
expect(request).toHaveBeenCalledWith(
|
|
1303
|
+
expect.objectContaining({
|
|
1304
|
+
params: expect.objectContaining(
|
|
1305
|
+
order === 'asc' ? { from_height: 11 } : { to_height: 11 }
|
|
1306
|
+
),
|
|
1307
|
+
})
|
|
1308
|
+
)
|
|
1309
|
+
// The arm's own cursor (height:hash of the last record), not the explorer's token.
|
|
1310
|
+
expect(next).toBe('9:0xh9')
|
|
1311
|
+
}
|
|
1312
|
+
)
|
|
1313
|
+
})
|
|
1314
|
+
|
|
1196
1315
|
it('should not enrich feePayer with ambiguous sender', async () => {
|
|
1197
1316
|
const address = 'address'
|
|
1198
1317
|
const parentTx = {
|