@ledgerhq/coin-evm 10.1.0 → 15.2.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 +58 -0
- package/docs/getBlock-internal-txs-schema.md +2 -2
- package/docs/network/node/index.md +1 -1
- package/lib/adapters/etherscan.d.ts +2 -1
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +16 -2
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts +2 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +4 -2
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -2
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +95 -0
- package/lib/chains.d.ts.map +1 -0
- package/lib/chains.js +99 -0
- package/lib/chains.js.map +1 -0
- package/lib/config.d.ts +4 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -1
- package/lib/config.js.map +1 -1
- package/lib/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/common.d.ts +1 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +11 -11
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +3 -3
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +7 -7
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +9 -9
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +38 -21
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -2
- 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/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +10 -10
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js +8 -8
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +3 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +9 -9
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +14 -13
- package/lib/logic.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +2 -3
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +6 -8
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +5 -5
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/types.d.ts +2 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +14 -12
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/index.d.ts +1 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +7 -7
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.d.ts +3 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +32 -22
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +67 -39
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +18 -16
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/network/node/withNodeSources.d.ts.map +1 -1
- package/lib/network/node/withNodeSources.js +15 -15
- package/lib/network/node/withNodeSources.js.map +1 -1
- package/lib/staking/abis.d.ts +3 -2
- package/lib/staking/abis.d.ts.map +1 -1
- package/lib/staking/abis.js +10 -9
- package/lib/staking/abis.js.map +1 -1
- package/lib/staking/contracts.d.ts +3 -2
- package/lib/staking/contracts.d.ts.map +1 -1
- package/lib/staking/contracts.js +11 -10
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/detectOperationType.d.ts +2 -1
- package/lib/staking/detectOperationType.d.ts.map +1 -1
- package/lib/staking/detectOperationType.js +7 -7
- package/lib/staking/detectOperationType.js.map +1 -1
- package/lib/staking/encoder.d.ts +2 -1
- package/lib/staking/encoder.d.ts.map +1 -1
- package/lib/staking/encoder.js +8 -8
- package/lib/staking/encoder.js.map +1 -1
- package/lib/staking/fetchers.d.ts +2 -1
- package/lib/staking/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +27 -27
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/logic.d.ts +6 -6
- package/lib/staking/logic.d.ts.map +1 -1
- package/lib/staking/logic.js +14 -13
- package/lib/staking/logic.js.map +1 -1
- package/lib/staking/operations/index.d.ts +2 -1
- package/lib/staking/operations/index.d.ts.map +1 -1
- package/lib/staking/operations/index.js +30 -28
- package/lib/staking/operations/index.js.map +1 -1
- package/lib/staking/prepareIntents.d.ts +1 -1
- package/lib/staking/prepareIntents.d.ts.map +1 -1
- package/lib/staking/prepareIntents.js +11 -10
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/redelegations.d.ts +4 -4
- package/lib/staking/redelegations.d.ts.map +1 -1
- package/lib/staking/redelegations.js +18 -20
- package/lib/staking/redelegations.js.map +1 -1
- package/lib/staking/rewards.d.ts +1 -1
- package/lib/staking/rewards.d.ts.map +1 -1
- package/lib/staking/rewards.js +2 -2
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib/staking/rewardsFromReceipt.js +2 -2
- package/lib/staking/rewardsFromReceipt.js.map +1 -1
- package/lib/staking/transactionData.d.ts +2 -1
- package/lib/staking/transactionData.d.ts.map +1 -1
- package/lib/staking/transactionData.js +6 -6
- package/lib/staking/transactionData.js.map +1 -1
- package/lib/staking/unbondings.d.ts +1 -1
- package/lib/staking/unbondings.d.ts.map +1 -1
- package/lib/staking/unbondings.js +2 -2
- package/lib/staking/unbondings.js.map +1 -1
- package/lib/staking/validators/index.d.ts +14 -14
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +39 -38
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +5 -5
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +31 -33
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +1 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js +4 -4
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/sei.js +2 -2
- package/lib/staking/validators/sei.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts +4 -4
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js +22 -22
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/types.d.ts +1 -1
- package/lib/staking/validators/types.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts +1 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js +7 -7
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/staking.d.ts +5 -6
- package/lib/types/staking.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.d.ts +2 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +16 -2
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts +2 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +4 -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 +1 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +95 -0
- package/lib-es/chains.d.ts.map +1 -0
- package/lib-es/chains.js +96 -0
- package/lib-es/chains.js.map +1 -0
- package/lib-es/config.d.ts +4 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -0
- package/lib-es/config.js.map +1 -1
- package/lib-es/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/common.d.ts +1 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +11 -11
- 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 +3 -3
- 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 +7 -7
- 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 +9 -9
- 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 +39 -22
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.js +2 -2
- 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/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +10 -10
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js +8 -8
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- 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 +3 -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 +9 -9
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +14 -13
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +2 -3
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +6 -8
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +5 -5
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +2 -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/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +14 -12
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/index.d.ts +1 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +7 -7
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts +3 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +32 -22
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +67 -39
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +18 -16
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
- package/lib-es/network/node/withNodeSources.js +15 -15
- package/lib-es/network/node/withNodeSources.js.map +1 -1
- package/lib-es/staking/abis.d.ts +3 -2
- package/lib-es/staking/abis.d.ts.map +1 -1
- package/lib-es/staking/abis.js +10 -9
- package/lib-es/staking/abis.js.map +1 -1
- package/lib-es/staking/contracts.d.ts +3 -2
- package/lib-es/staking/contracts.d.ts.map +1 -1
- package/lib-es/staking/contracts.js +11 -10
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/detectOperationType.d.ts +2 -1
- package/lib-es/staking/detectOperationType.d.ts.map +1 -1
- package/lib-es/staking/detectOperationType.js +7 -7
- package/lib-es/staking/detectOperationType.js.map +1 -1
- package/lib-es/staking/encoder.d.ts +2 -1
- package/lib-es/staking/encoder.d.ts.map +1 -1
- package/lib-es/staking/encoder.js +8 -8
- package/lib-es/staking/encoder.js.map +1 -1
- package/lib-es/staking/fetchers.d.ts +2 -1
- package/lib-es/staking/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +27 -27
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/logic.d.ts +6 -6
- package/lib-es/staking/logic.d.ts.map +1 -1
- package/lib-es/staking/logic.js +14 -13
- package/lib-es/staking/logic.js.map +1 -1
- package/lib-es/staking/operations/index.d.ts +2 -1
- package/lib-es/staking/operations/index.d.ts.map +1 -1
- package/lib-es/staking/operations/index.js +30 -28
- package/lib-es/staking/operations/index.js.map +1 -1
- package/lib-es/staking/prepareIntents.d.ts +1 -1
- package/lib-es/staking/prepareIntents.d.ts.map +1 -1
- package/lib-es/staking/prepareIntents.js +11 -10
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/redelegations.d.ts +4 -4
- package/lib-es/staking/redelegations.d.ts.map +1 -1
- package/lib-es/staking/redelegations.js +18 -20
- package/lib-es/staking/redelegations.js.map +1 -1
- package/lib-es/staking/rewards.d.ts +1 -1
- package/lib-es/staking/rewards.d.ts.map +1 -1
- package/lib-es/staking/rewards.js +2 -2
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.js +2 -2
- package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
- package/lib-es/staking/transactionData.d.ts +2 -1
- package/lib-es/staking/transactionData.d.ts.map +1 -1
- package/lib-es/staking/transactionData.js +6 -6
- package/lib-es/staking/transactionData.js.map +1 -1
- package/lib-es/staking/unbondings.d.ts +1 -1
- package/lib-es/staking/unbondings.d.ts.map +1 -1
- package/lib-es/staking/unbondings.js +2 -2
- package/lib-es/staking/unbondings.js.map +1 -1
- package/lib-es/staking/validators/index.d.ts +14 -14
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +39 -38
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +5 -5
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +31 -33
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +4 -4
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/sei.js +2 -2
- package/lib-es/staking/validators/sei.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts +4 -4
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js +22 -22
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/types.d.ts +1 -1
- package/lib-es/staking/validators/types.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js +7 -7
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/staking.d.ts +5 -6
- package/lib-es/types/staking.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/etherscan.test.ts +91 -43
- package/src/adapters/etherscan.ts +18 -2
- package/src/adapters/ledger.test.ts +106 -31
- package/src/adapters/ledger.ts +5 -2
- package/src/api/index.ts +1 -2
- package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +5 -4
- package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +3 -3
- package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +3 -3
- package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +3 -3
- package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +3 -3
- package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +3 -3
- package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +3 -3
- package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +3 -3
- package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +6 -6
- package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +3 -3
- package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +3 -3
- package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +3 -3
- package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +3 -3
- package/src/api/{index.test.ts → tests/index.test.ts} +4 -4
- package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +2 -2
- package/src/chains.test.ts +12 -0
- package/src/chains.ts +98 -0
- package/src/config.ts +5 -1
- package/src/fixtures/staking.fixtures.ts +13 -0
- package/src/logic/broadcast.ts +2 -2
- package/src/logic/common.ts +10 -11
- package/src/logic/craftTransaction.ts +2 -3
- package/src/logic/estimateFees.ts +6 -23
- package/src/logic/getBalance.ts +7 -13
- package/src/logic/getBlock.ts +59 -23
- package/src/logic/getBlockInfo.ts +2 -2
- package/src/logic/getNextSequence.ts +1 -4
- package/src/logic/getStakes.ts +11 -12
- package/src/logic/internalTransactionsFetcher.ts +6 -8
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +2 -1
- package/src/logic/tests/broadcast.test.ts +5 -5
- package/src/logic/tests/broadcastSource.test.ts +1 -4
- package/src/logic/tests/common.test.ts +18 -34
- package/src/logic/tests/craftTransaction.test.ts +14 -7
- package/src/logic/tests/estimateFees.test.ts +17 -8
- package/src/logic/tests/getBalance.test.ts +18 -34
- package/src/logic/tests/getBlock.test.ts +195 -80
- package/src/logic/tests/getBlockInfo.test.ts +2 -2
- package/src/logic/tests/getNextSequence.test.ts +2 -2
- package/src/logic/tests/getStakes.test.ts +28 -16
- package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -6
- package/src/logic/tests/lastBlock.test.ts +4 -7
- package/src/logic/tests/listOperations.test.ts +8 -7
- package/src/logic/tests/validateIntent.test.ts +49 -3
- package/src/logic/validateIntent.ts +8 -10
- package/src/logic.test.ts +13 -5
- package/src/logic.ts +13 -13
- package/src/network/explorer/etherscan.ts +8 -24
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +0 -2
- package/src/network/node/explorerProxy.ts +14 -12
- package/src/network/node/index.ts +11 -8
- package/src/network/node/ledger.ts +32 -34
- package/src/network/node/rpc.common.ts +79 -86
- package/src/network/node/types.ts +16 -31
- package/src/network/node/withNodeSources.ts +23 -26
- package/src/network/{explorer → tests/explorer}/etherscan.test.ts +16 -65
- package/src/network/{explorer → tests/explorer}/index.test.ts +8 -8
- package/src/network/{explorer → tests/explorer}/ledger.test.ts +34 -142
- package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
- package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
- package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
- package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/explorerProxy.test.ts +22 -24
- package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
- package/src/network/tests/node/index.memoization.test.ts +70 -0
- package/src/network/{node → tests/node}/index.test.ts +4 -6
- package/src/network/{node → tests/node}/ledger.test.ts +69 -74
- package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
- package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
- package/src/network/{node → tests/node}/rpc.test.ts +100 -119
- package/src/network/{node → tests/node}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/withNodeSources.test.ts +10 -12
- package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
- package/src/staking/abis.test.ts +24 -28
- package/src/staking/abis.ts +12 -10
- package/src/staking/contracts.test.ts +20 -8
- package/src/staking/contracts.ts +12 -11
- package/src/staking/detectOperationType.test.ts +16 -13
- package/src/staking/detectOperationType.ts +9 -8
- package/src/staking/encoder.test.ts +38 -27
- package/src/staking/encoder.ts +9 -8
- package/src/staking/fetchers.ts +28 -39
- package/src/staking/logic.test.ts +34 -32
- package/src/staking/logic.ts +14 -14
- package/src/staking/operations/index.test.ts +48 -39
- package/src/staking/operations/index.ts +31 -28
- package/src/staking/prepareIntents.test.ts +14 -34
- package/src/staking/prepareIntents.ts +10 -13
- package/src/staking/redelegations.test.ts +73 -131
- package/src/staking/redelegations.ts +12 -26
- package/src/staking/rewards.test.ts +19 -21
- package/src/staking/rewards.ts +1 -2
- package/src/staking/rewardsFromReceipt.test.ts +9 -8
- package/src/staking/rewardsFromReceipt.ts +3 -2
- package/src/staking/transactionData.test.ts +35 -25
- package/src/staking/transactionData.ts +7 -6
- package/src/staking/unbondings.test.ts +26 -20
- package/src/staking/unbondings.ts +1 -2
- package/src/staking/validators/index.ts +45 -51
- package/src/staking/validators/monad.test.ts +52 -54
- package/src/staking/validators/monad.ts +31 -37
- package/src/staking/validators/monadResolver.ts +2 -4
- package/src/staking/validators/sei.ts +2 -2
- package/src/staking/validators/somnia.test.ts +22 -19
- package/src/staking/validators/somnia.ts +20 -27
- package/src/staking/validators/types.ts +0 -1
- package/src/staking/validators/zero_gravity.test.ts +34 -49
- package/src/staking/validators/zero_gravity.ts +5 -11
- package/src/staking/validators.integ.test.ts +3 -5
- package/src/staking/validators.test.ts +56 -53
- package/src/types/staking.ts +3 -6
- package/src/network/node/index.memoization.test.ts +0 -63
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
createMockEvmConfigInfo,
|
|
8
8
|
mkExternalNode,
|
|
9
9
|
testLogger,
|
|
10
|
-
} from '
|
|
10
|
+
} from '../../../fixtures/context.fixtures'
|
|
11
11
|
import {
|
|
12
12
|
createExplorerProxyNodeApi,
|
|
13
13
|
getBlockFromExplorerProxy,
|
|
14
14
|
getTransactionFromExplorerProxy,
|
|
15
|
-
} from '
|
|
15
|
+
} from '../../node/explorerProxy'
|
|
16
16
|
|
|
17
17
|
jest.mock('axios')
|
|
18
18
|
const mockAxiosGet = jest.mocked(axios.get)
|
|
@@ -29,27 +29,22 @@ describe('createExplorerProxyNodeApi', () => {
|
|
|
29
29
|
|
|
30
30
|
describe('unsupported methods', () => {
|
|
31
31
|
it.each([
|
|
32
|
-
['call', () => api.call(
|
|
33
|
-
['getCoinBalance', () => api.getCoinBalance('
|
|
34
|
-
['getTokenBalance', () => api.getTokenBalance('
|
|
35
|
-
['getTokenAllowance', () => api.getTokenAllowance('
|
|
36
|
-
['getTransactionCount', () => api.getTransactionCount('
|
|
32
|
+
['call', () => api.call({ to: '0x', data: '0x' })],
|
|
33
|
+
['getCoinBalance', () => api.getCoinBalance('0x')],
|
|
34
|
+
['getTokenBalance', () => api.getTokenBalance('0x', '0x')],
|
|
35
|
+
['getTokenAllowance', () => api.getTokenAllowance('0x', '0x', '0x')],
|
|
36
|
+
['getTransactionCount', () => api.getTransactionCount('0x')],
|
|
37
37
|
[
|
|
38
38
|
'getGasEstimation',
|
|
39
|
-
() => api.getGasEstimation('
|
|
39
|
+
() => api.getGasEstimation('0x', { amount: new BigNumber(0), recipient: '0x' }),
|
|
40
40
|
],
|
|
41
41
|
[
|
|
42
42
|
'getFeeData',
|
|
43
|
-
() =>
|
|
44
|
-
api.getFeeData(
|
|
45
|
-
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() }),
|
|
46
|
-
'eth',
|
|
47
|
-
{}
|
|
48
|
-
),
|
|
43
|
+
() => api.getFeeData(createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() }), {}),
|
|
49
44
|
],
|
|
50
|
-
['broadcastTransaction', () => api.broadcastTransaction('
|
|
51
|
-
['getOptimismAdditionalFees', () => api.getOptimismAdditionalFees('
|
|
52
|
-
['getScrollAdditionalFees', () => api.getScrollAdditionalFees('
|
|
45
|
+
['broadcastTransaction', () => api.broadcastTransaction('0x')],
|
|
46
|
+
['getOptimismAdditionalFees', () => api.getOptimismAdditionalFees('0x')],
|
|
47
|
+
['getScrollAdditionalFees', () => api.getScrollAdditionalFees('0x')],
|
|
53
48
|
] as const)(
|
|
54
49
|
'%s rejects immediately with "not supported by explorer proxy"',
|
|
55
50
|
async (_name, invoke) => {
|
|
@@ -61,7 +56,7 @@ describe('createExplorerProxyNodeApi', () => {
|
|
|
61
56
|
|
|
62
57
|
describe('getBlockByHeight', () => {
|
|
63
58
|
it('throws before hitting the network when height is a BlockFinalizationTag', async () => {
|
|
64
|
-
await expect(api.getBlockByHeight('
|
|
59
|
+
await expect(api.getBlockByHeight('latest')).rejects.toThrow(
|
|
65
60
|
'explorer proxy only supports numeric heights'
|
|
66
61
|
)
|
|
67
62
|
expect(mockAxiosGet).not.toHaveBeenCalled()
|
|
@@ -69,7 +64,7 @@ describe('createExplorerProxyNodeApi', () => {
|
|
|
69
64
|
|
|
70
65
|
it('throws when the proxy returns null (block not found or malformed)', async () => {
|
|
71
66
|
mockAxiosGet.mockResolvedValueOnce({ data: { result: null } })
|
|
72
|
-
await expect(api.getBlockByHeight(
|
|
67
|
+
await expect(api.getBlockByHeight(1)).rejects.toThrow(
|
|
73
68
|
'explorer proxy returned no result for block 1'
|
|
74
69
|
)
|
|
75
70
|
})
|
|
@@ -86,7 +81,7 @@ describe('createExplorerProxyNodeApi', () => {
|
|
|
86
81
|
},
|
|
87
82
|
},
|
|
88
83
|
})
|
|
89
|
-
const result = await api.getBlockByHeight(
|
|
84
|
+
const result = await api.getBlockByHeight(1)
|
|
90
85
|
expect(result.hash).toBe('0xdeadbeef')
|
|
91
86
|
expect(result.height).toBe(1)
|
|
92
87
|
expect(result.transactionHashes).toEqual(['0xhash1'])
|
|
@@ -94,7 +89,7 @@ describe('createExplorerProxyNodeApi', () => {
|
|
|
94
89
|
|
|
95
90
|
it('propagates network errors as a throw (via the null path)', async () => {
|
|
96
91
|
mockAxiosGet.mockRejectedValueOnce(new Error('ECONNREFUSED'))
|
|
97
|
-
await expect(api.getBlockByHeight(
|
|
92
|
+
await expect(api.getBlockByHeight(1)).rejects.toThrow(
|
|
98
93
|
'explorer proxy returned no result for block 1'
|
|
99
94
|
)
|
|
100
95
|
})
|
|
@@ -105,7 +100,7 @@ describe('createExplorerProxyNodeApi', () => {
|
|
|
105
100
|
mockAxiosGet
|
|
106
101
|
.mockResolvedValueOnce({ data: { result: null } })
|
|
107
102
|
.mockResolvedValueOnce({ data: { result: null } })
|
|
108
|
-
await expect(api.getTransaction(
|
|
103
|
+
await expect(api.getTransaction(TX_HASH)).rejects.toThrow(
|
|
109
104
|
`explorer proxy returned no result for tx ${TX_HASH}`
|
|
110
105
|
)
|
|
111
106
|
})
|
|
@@ -120,6 +115,7 @@ describe('createExplorerProxyNodeApi', () => {
|
|
|
120
115
|
blockHash: '0xblockhash',
|
|
121
116
|
nonce: '0x1',
|
|
122
117
|
gasPrice: '0x3b9aca00',
|
|
118
|
+
gas: '0x11e72',
|
|
123
119
|
value: '0x0',
|
|
124
120
|
from: '0xaabbcc0000000000000000000000000000000001',
|
|
125
121
|
to: '0xaabbcc0000000000000000000000000000000002',
|
|
@@ -140,15 +136,17 @@ describe('createExplorerProxyNodeApi', () => {
|
|
|
140
136
|
},
|
|
141
137
|
},
|
|
142
138
|
})
|
|
143
|
-
const result = await api.getTransaction(
|
|
139
|
+
const result = await api.getTransaction(TX_HASH)
|
|
144
140
|
expect(result.hash).toBe(TX_HASH)
|
|
145
141
|
expect(result.status).toBe(1)
|
|
146
142
|
expect(result.erc20Transfers).toEqual([])
|
|
143
|
+
expect(result.gasLimit).toBe('73330')
|
|
144
|
+
expect(result.nonce).toBe(1)
|
|
147
145
|
})
|
|
148
146
|
|
|
149
147
|
it('propagates network errors as a throw (via the null path)', async () => {
|
|
150
148
|
mockAxiosGet.mockRejectedValue(new Error('ECONNREFUSED'))
|
|
151
|
-
await expect(api.getTransaction(
|
|
149
|
+
await expect(api.getTransaction(TX_HASH)).rejects.toThrow(
|
|
152
150
|
`explorer proxy returned no result for tx ${TX_HASH}`
|
|
153
151
|
)
|
|
154
152
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { TraceBlockItem } from '
|
|
5
|
-
import { isTraceBlockItem } from '
|
|
6
|
-
import { gethCallTracerToTraceBlockItems } from '
|
|
7
|
-
import flareBlock0x36ffc39CallTracerTrace from '
|
|
4
|
+
import type { TraceBlockItem } from '../../node/types'
|
|
5
|
+
import { isTraceBlockItem } from '../../../logic/predicates'
|
|
6
|
+
import { gethCallTracerToTraceBlockItems } from '../../node/gethCallTracerToTraceBlockItems'
|
|
7
|
+
import flareBlock0x36ffc39CallTracerTrace from '../../node/resources/flare-0x36ffc39-debug-trace-block-call-tracer.json'
|
|
8
8
|
|
|
9
9
|
describe('gethCallTracerToTraceBlockItems', () => {
|
|
10
10
|
const blockNumber = 12345
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { CHAIN_ID } from '../../../config'
|
|
5
|
+
import {
|
|
6
|
+
createMockEvmConfigInfo,
|
|
7
|
+
mkExternalNode,
|
|
8
|
+
testLogger,
|
|
9
|
+
} from '../../../fixtures/context.fixtures'
|
|
10
|
+
import { getNodeApi } from '../../node/index'
|
|
11
|
+
|
|
12
|
+
describe('getNodeApi memoization', () => {
|
|
13
|
+
it('should return the same NodeApi instance for same chain and retries (memoization)', () => {
|
|
14
|
+
const config = createMockEvmConfigInfo({
|
|
15
|
+
chainId: CHAIN_ID.ETHEREUM,
|
|
16
|
+
node: mkExternalNode(),
|
|
17
|
+
})
|
|
18
|
+
expect(getNodeApi(config, testLogger)).toBe(getNodeApi(config, testLogger))
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should return cached NodeApi on subsequent calls (createNodeApi called once)', () => {
|
|
22
|
+
const config = createMockEvmConfigInfo({
|
|
23
|
+
chainId: CHAIN_ID.ETHEREUM,
|
|
24
|
+
node: mkExternalNode(),
|
|
25
|
+
})
|
|
26
|
+
const cachedInstance = getNodeApi(config, testLogger)
|
|
27
|
+
|
|
28
|
+
expect(getNodeApi(config, testLogger)).toBe(cachedInstance)
|
|
29
|
+
expect(getNodeApi(config, testLogger)).toBe(cachedInstance)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should return different NodeApi instances for different retries', () => {
|
|
33
|
+
const node1 = getNodeApi(
|
|
34
|
+
createMockEvmConfigInfo({
|
|
35
|
+
chainId: CHAIN_ID.ETHEREUM,
|
|
36
|
+
node: mkExternalNode({ uri: 'u', retries: 2 }),
|
|
37
|
+
}),
|
|
38
|
+
testLogger
|
|
39
|
+
)
|
|
40
|
+
const node2 = getNodeApi(
|
|
41
|
+
createMockEvmConfigInfo({
|
|
42
|
+
chainId: CHAIN_ID.ETHEREUM,
|
|
43
|
+
node: mkExternalNode({ uri: 'u', retries: 5 }),
|
|
44
|
+
}),
|
|
45
|
+
testLogger
|
|
46
|
+
)
|
|
47
|
+
expect(node1).not.toBe(node2)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('should return different NodeApi instances for different uris', () => {
|
|
51
|
+
const node1 = getNodeApi(
|
|
52
|
+
createMockEvmConfigInfo({ chainId: CHAIN_ID.ETHEREUM, node: mkExternalNode({ uri: 'u1' }) }),
|
|
53
|
+
testLogger
|
|
54
|
+
)
|
|
55
|
+
const node2 = getNodeApi(
|
|
56
|
+
createMockEvmConfigInfo({ chainId: CHAIN_ID.ETHEREUM, node: mkExternalNode({ uri: 'u2' }) }),
|
|
57
|
+
testLogger
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
expect(node1).not.toBe(node2)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('should return different NodeApi instances for different chains sharing a node', () => {
|
|
64
|
+
const node = mkExternalNode({ uri: 'u1' })
|
|
65
|
+
const ethereum = createMockEvmConfigInfo({ chainId: CHAIN_ID.ETHEREUM, node })
|
|
66
|
+
const bsc = createMockEvmConfigInfo({ chainId: CHAIN_ID.BSC, node })
|
|
67
|
+
|
|
68
|
+
expect(getNodeApi(ethereum, testLogger)).not.toBe(getNodeApi(bsc, testLogger))
|
|
69
|
+
})
|
|
70
|
+
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { UnknownNode } from '
|
|
4
|
+
import { UnknownNode } from '../../../errors'
|
|
5
5
|
import {
|
|
6
6
|
createMockEvmConfigInfo,
|
|
7
7
|
mkExternalNode,
|
|
8
8
|
mkLedgerNode,
|
|
9
9
|
testLogger,
|
|
10
|
-
} from '
|
|
11
|
-
import { getNodeApi } from '
|
|
10
|
+
} from '../../../fixtures/context.fixtures'
|
|
11
|
+
import { getNodeApi } from '../../node/index'
|
|
12
12
|
|
|
13
13
|
describe('EVM Family', () => {
|
|
14
14
|
describe('network/node/index.ts', () => {
|
|
@@ -16,13 +16,12 @@ describe('EVM Family', () => {
|
|
|
16
16
|
it('should throw when requesting a non existing node type', () => {
|
|
17
17
|
const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
18
18
|
Object.assign(config, { node: { type: 'anything', uri: 'notworking' } })
|
|
19
|
-
expect(() => getNodeApi(config,
|
|
19
|
+
expect(() => getNodeApi(config, testLogger)).toThrow(UnknownNode)
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
it('should return the rpc api', () => {
|
|
23
23
|
const node = getNodeApi(
|
|
24
24
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'working' }) }),
|
|
25
|
-
'external',
|
|
26
25
|
testLogger
|
|
27
26
|
)
|
|
28
27
|
|
|
@@ -44,7 +43,6 @@ describe('EVM Family', () => {
|
|
|
44
43
|
it('should return the ledger api', () => {
|
|
45
44
|
const node = getNodeApi(
|
|
46
45
|
createMockEvmConfigInfo({ chainId: 1, node: mkLedgerNode({ explorerId: 'eth' }) }),
|
|
47
|
-
'ledger-supported',
|
|
48
46
|
testLogger
|
|
49
47
|
)
|
|
50
48
|
|
|
@@ -5,17 +5,17 @@ import { delay } from '@ledgerhq/coin-module-framework/promises'
|
|
|
5
5
|
import axios from 'axios'
|
|
6
6
|
import BigNumber from 'bignumber.js'
|
|
7
7
|
import { Transaction } from 'ethers'
|
|
8
|
-
import { DEFAULT_LEDGER_EXPLORER_URI } from '
|
|
9
|
-
import { GasEstimationError } from '
|
|
10
|
-
import { createMockEvmConfigInfo, testLogger } from '
|
|
11
|
-
import { getGasOptions } from '
|
|
12
|
-
import { createLedgerNodeApi } from '
|
|
8
|
+
import { CHAIN_ID, DEFAULT_LEDGER_EXPLORER_URI } from '../../../config'
|
|
9
|
+
import { GasEstimationError } from '../../../errors'
|
|
10
|
+
import { createMockEvmConfigInfo, testLogger } from '../../../fixtures/context.fixtures'
|
|
11
|
+
import { getGasOptions } from '../../gasTracker/ledger'
|
|
12
|
+
import { createLedgerNodeApi } from '../../node/ledger'
|
|
13
13
|
|
|
14
14
|
jest.useFakeTimers({ doNotFake: ['setTimeout'] })
|
|
15
15
|
|
|
16
16
|
jest.mock('axios')
|
|
17
17
|
jest.mock('@ledgerhq/coin-module-framework/promises')
|
|
18
|
-
jest.mock('
|
|
18
|
+
jest.mock('../../gasTracker/ledger', () => ({
|
|
19
19
|
getGasOptions: jest.fn(),
|
|
20
20
|
}))
|
|
21
21
|
|
|
@@ -25,10 +25,10 @@ jest.mocked(delay).mockImplementation(
|
|
|
25
25
|
() => new Promise((resolve) => setTimeout(resolve, 1)) // mocking the delay supposed to happen after each try
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
const currencyId = 'ethereum'
|
|
29
28
|
const address = '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d'
|
|
30
29
|
|
|
31
30
|
const ledgerConfig = {
|
|
31
|
+
chainId: CHAIN_ID.ETHEREUM,
|
|
32
32
|
type: 'ledger' as const,
|
|
33
33
|
explorerId: 'eth' as const,
|
|
34
34
|
retries: 2,
|
|
@@ -60,7 +60,7 @@ describe('EVM Family', () => {
|
|
|
60
60
|
],
|
|
61
61
|
}))
|
|
62
62
|
|
|
63
|
-
const result = await api.call(
|
|
63
|
+
const result = await api.call({ to: USDC, data: DECIMALS_SELECTOR })
|
|
64
64
|
|
|
65
65
|
expect(result).toEqual(DECIMALS_RESPONSE)
|
|
66
66
|
expect(spy).toHaveBeenCalledWith(
|
|
@@ -83,7 +83,7 @@ describe('EVM Family', () => {
|
|
|
83
83
|
],
|
|
84
84
|
}))
|
|
85
85
|
|
|
86
|
-
await api.call(
|
|
86
|
+
await api.call({ to: USDC, data: DECIMALS_SELECTOR, block: 123 })
|
|
87
87
|
|
|
88
88
|
expect(spy).toHaveBeenCalledWith(
|
|
89
89
|
expect.objectContaining({
|
|
@@ -103,7 +103,7 @@ describe('EVM Family', () => {
|
|
|
103
103
|
],
|
|
104
104
|
}))
|
|
105
105
|
|
|
106
|
-
await expect(api.call(
|
|
106
|
+
await expect(api.call({ to: USDC, data: DECIMALS_SELECTOR })).rejects.toThrow(
|
|
107
107
|
'EVM call failed'
|
|
108
108
|
)
|
|
109
109
|
})
|
|
@@ -133,7 +133,7 @@ describe('EVM Family', () => {
|
|
|
133
133
|
},
|
|
134
134
|
}
|
|
135
135
|
})
|
|
136
|
-
const response = await api.getTransaction(
|
|
136
|
+
const response = await api.getTransaction('0xHash')
|
|
137
137
|
expect(response.hash).toEqual('0xabc')
|
|
138
138
|
expect(spy).toHaveBeenCalledTimes(3)
|
|
139
139
|
})
|
|
@@ -149,7 +149,7 @@ describe('EVM Family', () => {
|
|
|
149
149
|
}
|
|
150
150
|
return { data: {} }
|
|
151
151
|
})
|
|
152
|
-
await expect(api.getTransaction(
|
|
152
|
+
await expect(api.getTransaction('0xHash')).rejects.toBeInstanceOf(SpyError)
|
|
153
153
|
})
|
|
154
154
|
})
|
|
155
155
|
|
|
@@ -201,9 +201,10 @@ describe('EVM Family', () => {
|
|
|
201
201
|
},
|
|
202
202
|
}))
|
|
203
203
|
|
|
204
|
-
const response = await api.getTransaction(
|
|
204
|
+
const response = await api.getTransaction('0xHash')
|
|
205
205
|
expect(response).toEqual({
|
|
206
206
|
gasPrice: '83953611012',
|
|
207
|
+
gasLimit: '32000',
|
|
207
208
|
gasUsed: '21000',
|
|
208
209
|
value: '70494048649554430',
|
|
209
210
|
hash: '0x8d5ef4d7673fbfa6a4755cdfdb913742c47c7fdac2d214046387bbcbf10957c9',
|
|
@@ -244,7 +245,7 @@ describe('EVM Family', () => {
|
|
|
244
245
|
data: { balance: '6969' },
|
|
245
246
|
}))
|
|
246
247
|
|
|
247
|
-
expect(await api.getCoinBalance(
|
|
248
|
+
expect(await api.getCoinBalance('0xkvn')).toEqual(new BigNumber('6969'))
|
|
248
249
|
})
|
|
249
250
|
})
|
|
250
251
|
|
|
@@ -258,9 +259,7 @@ describe('EVM Family', () => {
|
|
|
258
259
|
],
|
|
259
260
|
}))
|
|
260
261
|
|
|
261
|
-
expect(await api.getTokenBalance(
|
|
262
|
-
new BigNumber('6969')
|
|
263
|
-
)
|
|
262
|
+
expect(await api.getTokenBalance('0xusdc', '0xkvn')).toEqual(new BigNumber('6969'))
|
|
264
263
|
})
|
|
265
264
|
})
|
|
266
265
|
|
|
@@ -271,7 +270,7 @@ describe('EVM Family', () => {
|
|
|
271
270
|
data: { address: '0xkvn', nonce: 123 },
|
|
272
271
|
}))
|
|
273
272
|
|
|
274
|
-
expect(await api.getTransactionCount(
|
|
273
|
+
expect(await api.getTransactionCount('0xkvn')).toEqual(123)
|
|
275
274
|
})
|
|
276
275
|
})
|
|
277
276
|
|
|
@@ -283,7 +282,7 @@ describe('EVM Family', () => {
|
|
|
283
282
|
})
|
|
284
283
|
|
|
285
284
|
await expect(
|
|
286
|
-
api.getGasEstimation(
|
|
285
|
+
api.getGasEstimation(address, { amount: new BigNumber(0), recipient: '0x0' })
|
|
287
286
|
).rejects.toBeInstanceOf(GasEstimationError)
|
|
288
287
|
})
|
|
289
288
|
|
|
@@ -294,7 +293,7 @@ describe('EVM Family', () => {
|
|
|
294
293
|
.mockImplementation(() => Promise.reject({ code: 'ECONNABORTED' }))
|
|
295
294
|
|
|
296
295
|
await expect(
|
|
297
|
-
api.getGasEstimation(
|
|
296
|
+
api.getGasEstimation(address, { amount: new BigNumber(0), recipient: '0x0' })
|
|
298
297
|
).rejects.toBeInstanceOf(GasEstimationError)
|
|
299
298
|
})
|
|
300
299
|
|
|
@@ -321,10 +320,8 @@ describe('EVM Family', () => {
|
|
|
321
320
|
data: Buffer.from('ffff', 'hex'),
|
|
322
321
|
}
|
|
323
322
|
|
|
324
|
-
expect(await api.getGasEstimation(
|
|
325
|
-
|
|
326
|
-
)
|
|
327
|
-
expect(await api.getGasEstimation(currencyId, address, transactionWithData)).toEqual(
|
|
323
|
+
expect(await api.getGasEstimation(address, transaction)).toEqual(new BigNumber(789))
|
|
324
|
+
expect(await api.getGasEstimation(address, transactionWithData)).toEqual(
|
|
328
325
|
new BigNumber(1_000_000)
|
|
329
326
|
)
|
|
330
327
|
})
|
|
@@ -356,7 +353,6 @@ describe('EVM Family', () => {
|
|
|
356
353
|
|
|
357
354
|
const slowFeeData = await api.getFeeData(
|
|
358
355
|
createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
|
|
359
|
-
currencyId,
|
|
360
356
|
{
|
|
361
357
|
type: 2,
|
|
362
358
|
feesStrategy: 'slow',
|
|
@@ -364,7 +360,6 @@ describe('EVM Family', () => {
|
|
|
364
360
|
)
|
|
365
361
|
const mediumFeeData = await api.getFeeData(
|
|
366
362
|
createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
|
|
367
|
-
currencyId,
|
|
368
363
|
{
|
|
369
364
|
type: 2,
|
|
370
365
|
feesStrategy: 'medium',
|
|
@@ -372,7 +367,6 @@ describe('EVM Family', () => {
|
|
|
372
367
|
)
|
|
373
368
|
const fastFeeData = await api.getFeeData(
|
|
374
369
|
createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
|
|
375
|
-
currencyId,
|
|
376
370
|
{
|
|
377
371
|
type: 2,
|
|
378
372
|
feesStrategy: 'fast',
|
|
@@ -424,7 +418,6 @@ describe('EVM Family', () => {
|
|
|
424
418
|
|
|
425
419
|
const feeData = await api.getFeeData(
|
|
426
420
|
createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
|
|
427
|
-
currencyId,
|
|
428
421
|
{ type: 2 }
|
|
429
422
|
)
|
|
430
423
|
|
|
@@ -446,7 +439,7 @@ describe('EVM Family', () => {
|
|
|
446
439
|
},
|
|
447
440
|
}))
|
|
448
441
|
|
|
449
|
-
expect(await api.broadcastTransaction(
|
|
442
|
+
expect(await api.broadcastTransaction('0xSigneTx')).toEqual('0xHash')
|
|
450
443
|
})
|
|
451
444
|
|
|
452
445
|
it('should include mevProtected=true in the request parameters when specified', async () => {
|
|
@@ -457,7 +450,7 @@ describe('EVM Family', () => {
|
|
|
457
450
|
},
|
|
458
451
|
}))
|
|
459
452
|
|
|
460
|
-
await api.broadcastTransaction(
|
|
453
|
+
await api.broadcastTransaction('0xSignedTx', { mevProtected: true })
|
|
461
454
|
|
|
462
455
|
expect(mockRequest).toHaveBeenCalledWith(
|
|
463
456
|
expect.objectContaining({
|
|
@@ -478,7 +471,7 @@ describe('EVM Family', () => {
|
|
|
478
471
|
},
|
|
479
472
|
}))
|
|
480
473
|
|
|
481
|
-
await api.broadcastTransaction(
|
|
474
|
+
await api.broadcastTransaction('0xSignedTx', {
|
|
482
475
|
mevProtected: false,
|
|
483
476
|
source: { type: 'live-app', name: 'test-manifest-id' },
|
|
484
477
|
})
|
|
@@ -503,7 +496,7 @@ describe('EVM Family', () => {
|
|
|
503
496
|
},
|
|
504
497
|
}))
|
|
505
498
|
|
|
506
|
-
await api.broadcastTransaction(
|
|
499
|
+
await api.broadcastTransaction('0xSignedTx', { mevProtected: false })
|
|
507
500
|
|
|
508
501
|
// ledgerConfig sets no clientVersion, so `{}` proves no source header was added.
|
|
509
502
|
expect(mockRequest).toHaveBeenCalledWith(
|
|
@@ -544,14 +537,14 @@ describe('EVM Family', () => {
|
|
|
544
537
|
}
|
|
545
538
|
})
|
|
546
539
|
|
|
547
|
-
expect(await api.getBlockByHeight(
|
|
540
|
+
expect(await api.getBlockByHeight(12)).toEqual({
|
|
548
541
|
hash: '0xhash',
|
|
549
542
|
height: 123,
|
|
550
543
|
timestamp: Date.now(),
|
|
551
544
|
parentHash: '0xparentHash',
|
|
552
545
|
transactionHashes: ['0xTx1', '0xTx2'],
|
|
553
546
|
})
|
|
554
|
-
expect(await api.getBlockByHeight(
|
|
547
|
+
expect(await api.getBlockByHeight('latest')).toEqual({
|
|
555
548
|
hash: '0xhashLatest',
|
|
556
549
|
height: 456,
|
|
557
550
|
timestamp: Date.now(),
|
|
@@ -564,11 +557,11 @@ describe('EVM Family', () => {
|
|
|
564
557
|
describe('getOptimismAdditionalFees', () => {
|
|
565
558
|
it('should return 0 for an incompatible currency', async () => {
|
|
566
559
|
const api = createLedgerNodeApi(ledgerConfig, testLogger)
|
|
567
|
-
expect(await api.getOptimismAdditionalFees(
|
|
560
|
+
expect(await api.getOptimismAdditionalFees('')).toEqual(new BigNumber(0))
|
|
568
561
|
})
|
|
569
562
|
|
|
570
563
|
it('should return the expected payload', async () => {
|
|
571
|
-
const api = createLedgerNodeApi(ledgerConfig, testLogger)
|
|
564
|
+
const api = createLedgerNodeApi({ ...ledgerConfig, chainId: CHAIN_ID.OPTIMISM }, testLogger)
|
|
572
565
|
jest.spyOn(axios, 'request').mockImplementationOnce(async () => ({
|
|
573
566
|
data: [
|
|
574
567
|
{
|
|
@@ -597,58 +590,60 @@ describe('EVM Family', () => {
|
|
|
597
590
|
},
|
|
598
591
|
})
|
|
599
592
|
|
|
600
|
-
expect(await api.getOptimismAdditionalFees(
|
|
593
|
+
expect(await api.getOptimismAdditionalFees(transaction.serialized)).toEqual(
|
|
601
594
|
new BigNumber('100000000')
|
|
602
595
|
)
|
|
603
596
|
})
|
|
604
597
|
|
|
605
|
-
it.each([
|
|
606
|
-
'
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
598
|
+
it.each([
|
|
599
|
+
['blast', CHAIN_ID.BLAST],
|
|
600
|
+
['blast_sepolia', CHAIN_ID.BLAST_SEPOLIA],
|
|
601
|
+
['base', CHAIN_ID.BASE],
|
|
602
|
+
['base_sepolia', CHAIN_ID.BASE_SEPOLIA],
|
|
603
|
+
])('should query the OP-stack gas oracle for %s (not return 0)', async (_name, chainId) => {
|
|
604
|
+
const api = createLedgerNodeApi({ ...ledgerConfig, chainId }, testLogger)
|
|
605
|
+
jest.spyOn(axios, 'request').mockImplementationOnce(async () => ({
|
|
606
|
+
data: [
|
|
607
|
+
{
|
|
608
|
+
info: {
|
|
609
|
+
contract: '0x420000000000000000000000000000000000000F',
|
|
610
|
+
data: '0xSerializedTransaction',
|
|
611
|
+
blockNumber: 123,
|
|
618
612
|
},
|
|
619
|
-
|
|
620
|
-
}))
|
|
621
|
-
|
|
622
|
-
const transaction = Transaction.from({
|
|
623
|
-
to: '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d',
|
|
624
|
-
value: 1n,
|
|
625
|
-
gasLimit: 2n,
|
|
626
|
-
chainId: 1,
|
|
627
|
-
nonce: 0,
|
|
628
|
-
gasPrice: 3n,
|
|
629
|
-
type: 0,
|
|
630
|
-
signature: {
|
|
631
|
-
r: '0xffffffffffffffffffffffffffffffffffffffff',
|
|
632
|
-
s: '0xffffffffffffffffffffffffffffffffffffffff',
|
|
633
|
-
v: 27,
|
|
613
|
+
response: '100000000',
|
|
634
614
|
},
|
|
635
|
-
|
|
615
|
+
],
|
|
616
|
+
}))
|
|
636
617
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
618
|
+
const transaction = Transaction.from({
|
|
619
|
+
to: '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d',
|
|
620
|
+
value: 1n,
|
|
621
|
+
gasLimit: 2n,
|
|
622
|
+
chainId: 1,
|
|
623
|
+
nonce: 0,
|
|
624
|
+
gasPrice: 3n,
|
|
625
|
+
type: 0,
|
|
626
|
+
signature: {
|
|
627
|
+
r: '0xffffffffffffffffffffffffffffffffffffffff',
|
|
628
|
+
s: '0xffffffffffffffffffffffffffffffffffffffff',
|
|
629
|
+
v: 27,
|
|
630
|
+
},
|
|
631
|
+
})
|
|
632
|
+
|
|
633
|
+
expect(await api.getOptimismAdditionalFees(transaction.serialized)).toEqual(
|
|
634
|
+
new BigNumber('100000000')
|
|
635
|
+
)
|
|
636
|
+
})
|
|
642
637
|
})
|
|
643
638
|
|
|
644
639
|
describe('getScrollAdditionalFees', () => {
|
|
645
640
|
it('should return 0 for an incompatible currency', async () => {
|
|
646
641
|
const api = createLedgerNodeApi(ledgerConfig, testLogger)
|
|
647
|
-
expect(await api.getScrollAdditionalFees(
|
|
642
|
+
expect(await api.getScrollAdditionalFees('')).toEqual(new BigNumber(0))
|
|
648
643
|
})
|
|
649
644
|
|
|
650
645
|
it('should return the expected payload', async () => {
|
|
651
|
-
const api = createLedgerNodeApi(ledgerConfig, testLogger)
|
|
646
|
+
const api = createLedgerNodeApi({ ...ledgerConfig, chainId: CHAIN_ID.SCROLL }, testLogger)
|
|
652
647
|
jest.spyOn(axios, 'request').mockImplementationOnce(async () => ({
|
|
653
648
|
data: [
|
|
654
649
|
{
|
|
@@ -677,7 +672,7 @@ describe('EVM Family', () => {
|
|
|
677
672
|
},
|
|
678
673
|
})
|
|
679
674
|
|
|
680
|
-
expect(await api.getScrollAdditionalFees(
|
|
675
|
+
expect(await api.getScrollAdditionalFees(transaction.serialized)).toEqual(
|
|
681
676
|
new BigNumber('100000000')
|
|
682
677
|
)
|
|
683
678
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { NodeApi } from '
|
|
4
|
+
import type { NodeApi } from '../../node/types'
|
|
5
5
|
|
|
6
6
|
export function mockNodeApi(overrides: Partial<jest.Mocked<NodeApi>> = {}): jest.Mocked<NodeApi> {
|
|
7
7
|
return {
|