@ledgerhq/coin-evm 10.0.0 → 15.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/.oxlintrc.json +2 -6
- package/CHANGELOG.md +54 -0
- package/docs/getBlock-internal-txs-schema.md +2 -2
- package/docs/network/node/index.md +1 -1
- package/lib/abis/index.d.ts +8 -0
- package/lib/abis/index.d.ts.map +1 -1
- package/lib/abis/index.js +30 -0
- package/lib/abis/index.js.map +1 -1
- package/lib/adapters/blockOperations.js +2 -2
- package/lib/adapters/blockOperations.js.map +1 -1
- package/lib/adapters/etherscan.d.ts +2 -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 +2 -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 +3 -2
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +94 -0
- package/lib/chains.d.ts.map +1 -0
- package/lib/chains.js +98 -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/internalTxSources.d.ts.map +1 -1
- package/lib/internalTxSources.js +21 -3
- package/lib/internalTxSources.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 +22 -14
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +7 -4
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +11 -8
- 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 +17 -17
- 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 +9 -9
- 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 +1 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/predicates.d.ts +17 -0
- package/lib/logic/predicates.d.ts.map +1 -0
- package/lib/logic/predicates.js +126 -0
- package/lib/logic/predicates.js.map +1 -0
- 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 +11 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib/network/gasTracker/ledger.js +1 -3
- package/lib/network/gasTracker/ledger.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +22 -17
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/gethCallTracerToTraceBlockItems.d.ts.map +1 -1
- package/lib/network/node/gethCallTracerToTraceBlockItems.js +10 -12
- package/lib/network/node/gethCallTracerToTraceBlockItems.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 +38 -24
- 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 +104 -103
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +21 -22
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js +0 -27
- 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/nodeSources.d.ts.map +1 -1
- package/lib/nodeSources.js +11 -3
- package/lib/nodeSources.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 +12 -13
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/detectOperationType.d.ts +2 -4
- package/lib/staking/detectOperationType.d.ts.map +1 -1
- package/lib/staking/detectOperationType.js +22 -21
- 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 +39 -20
- 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 +14 -12
- 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 +22 -27
- 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/utils.d.ts.map +1 -1
- package/lib/staking/utils.js +22 -27
- package/lib/staking/utils.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 +44 -37
- 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 +7 -6
- 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 +25 -24
- 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 +10 -9
- 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/abis/index.d.ts +8 -0
- package/lib-es/abis/index.d.ts.map +1 -1
- package/lib-es/abis/index.js +29 -0
- package/lib-es/abis/index.js.map +1 -1
- package/lib-es/adapters/blockOperations.js +1 -1
- package/lib-es/adapters/blockOperations.js.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 +2 -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 +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 +3 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +94 -0
- package/lib-es/chains.d.ts.map +1 -0
- package/lib-es/chains.js +95 -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/internalTxSources.d.ts.map +1 -1
- package/lib-es/internalTxSources.js +21 -3
- package/lib-es/internalTxSources.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 +22 -14
- 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 +7 -4
- 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 +11 -8
- 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 +18 -18
- 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 +9 -9
- 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 +1 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/predicates.d.ts +17 -0
- package/lib-es/logic/predicates.d.ts.map +1 -0
- package/lib-es/logic/predicates.js +114 -0
- package/lib-es/logic/predicates.js.map +1 -0
- 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 +11 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib-es/network/gasTracker/ledger.js +1 -3
- package/lib-es/network/gasTracker/ledger.js.map +1 -1
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +22 -17
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.d.ts.map +1 -1
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.js +4 -6
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.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 +38 -24
- 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 +102 -101
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +21 -22
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js +0 -25
- 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/nodeSources.d.ts.map +1 -1
- package/lib-es/nodeSources.js +11 -3
- package/lib-es/nodeSources.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 +12 -13
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/detectOperationType.d.ts +2 -4
- package/lib-es/staking/detectOperationType.d.ts.map +1 -1
- package/lib-es/staking/detectOperationType.js +22 -21
- 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 +39 -20
- 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 +13 -11
- 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 +19 -24
- 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/utils.d.ts.map +1 -1
- package/lib-es/staking/utils.js +20 -25
- package/lib-es/staking/utils.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 +43 -36
- 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 +6 -5
- 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 +24 -23
- 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 +9 -8
- 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/abis/index.test.ts +36 -0
- package/src/abis/index.ts +30 -0
- package/src/adapters/blockOperations.ts +1 -1
- package/src/adapters/etherscan.test.ts +34 -38
- package/src/adapters/etherscan.ts +3 -2
- package/src/adapters/ledger.test.ts +49 -22
- package/src/adapters/ledger.ts +3 -2
- package/src/api/getBlock.integ.test.ts +2 -1
- package/src/api/index.monad_testnet.integ.test.ts +2 -2
- package/src/api/index.ts +4 -3
- package/src/chains.test.ts +12 -0
- package/src/chains.ts +97 -0
- package/src/config.ts +5 -1
- package/src/fixtures/staking.fixtures.ts +13 -0
- package/src/internalTxSources.ts +20 -3
- package/src/logic/broadcast.ts +2 -2
- package/src/logic/common.ts +23 -14
- package/src/logic/craftTransaction.ts +6 -5
- package/src/logic/estimateFees.ts +10 -25
- package/src/logic/getBalance.ts +7 -13
- package/src/logic/getBlock.ts +22 -19
- 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 +7 -9
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +0 -1
- package/src/logic/predicates.ts +124 -0
- package/src/logic/tests/broadcast.test.ts +4 -4
- package/src/logic/tests/broadcastSource.test.ts +0 -3
- package/src/logic/tests/common.test.ts +17 -33
- package/src/logic/tests/craftTransaction.test.ts +13 -6
- package/src/logic/tests/estimateFees.test.ts +16 -7
- package/src/logic/tests/getBalance.test.ts +17 -33
- package/src/logic/tests/getBlock.test.ts +69 -75
- package/src/logic/tests/getBlockInfo.test.ts +1 -1
- package/src/logic/tests/getNextSequence.test.ts +1 -1
- package/src/logic/tests/getStakes.test.ts +28 -16
- package/src/logic/tests/internalTransactionsFetcher.test.ts +5 -5
- package/src/logic/tests/lastBlock.test.ts +3 -6
- package/src/logic/tests/listOperations.test.ts +3 -4
- package/src/logic/tests/validateIntent.test.ts +16 -3
- package/src/logic/validateIntent.ts +8 -10
- package/src/logic.test.ts +12 -4
- package/src/logic.ts +13 -13
- package/src/network/explorer/etherscan.test.ts +9 -58
- package/src/network/explorer/etherscan.ts +8 -24
- package/src/network/explorer/index.test.ts +1 -1
- package/src/network/explorer/ledger.test.ts +44 -146
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +12 -5
- package/src/network/gasTracker/ledger.ts +1 -4
- package/src/network/node/explorerProxy.test.ts +17 -22
- package/src/network/node/explorerProxy.ts +23 -20
- package/src/network/node/gethCallTracerToTraceBlockItems.test.ts +1 -1
- package/src/network/node/gethCallTracerToTraceBlockItems.ts +6 -9
- package/src/network/node/index.memoization.test.ts +29 -22
- package/src/network/node/index.test.ts +1 -3
- package/src/network/node/index.ts +11 -8
- package/src/network/node/ledger.test.ts +63 -69
- package/src/network/node/ledger.ts +39 -38
- package/src/network/node/rpc.common.ts +134 -158
- package/src/network/node/rpc.test.ts +201 -110
- package/src/network/node/types.ts +17 -64
- package/src/network/node/withNodeSources.test.ts +7 -9
- package/src/network/node/withNodeSources.ts +23 -26
- package/src/nodeSources.ts +11 -3
- 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 +13 -14
- package/src/staking/detectOperationType.test.ts +16 -13
- package/src/staking/detectOperationType.ts +24 -22
- 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 +43 -21
- package/src/staking/prepareIntents.test.ts +14 -34
- package/src/staking/prepareIntents.ts +12 -14
- package/src/staking/redelegations.test.ts +73 -131
- package/src/staking/redelegations.ts +13 -31
- 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/utils.ts +19 -26
- package/src/staking/validators/index.ts +45 -51
- package/src/staking/validators/monad.test.ts +52 -54
- package/src/staking/validators/monad.ts +42 -40
- package/src/staking/validators/monadResolver.ts +4 -5
- package/src/staking/validators/sei.ts +2 -2
- package/src/staking/validators/somnia.test.ts +22 -19
- package/src/staking/validators/somnia.ts +23 -29
- 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 +7 -12
- package/src/staking/validators.integ.test.ts +3 -5
- package/src/staking/validators.test.ts +56 -53
- package/src/types/staking.ts +3 -6
|
@@ -5,6 +5,7 @@ import type { EvmContext } from '../../config'
|
|
|
5
5
|
import type { ExplorerApi } from '../../network/explorer/types'
|
|
6
6
|
import type { AssetInfo } from '@ledgerhq/coin-module-framework/api/types'
|
|
7
7
|
import BigNumber from 'bignumber.js'
|
|
8
|
+
import { CHAIN_ID } from '../../config'
|
|
8
9
|
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
9
10
|
import { getExplorerApi } from '../../network/explorer'
|
|
10
11
|
import { getNodeApi } from '../../network/node'
|
|
@@ -115,9 +116,8 @@ describe('getBalance', () => {
|
|
|
115
116
|
'returns %s',
|
|
116
117
|
async (_, discoveredAssets: AssetInfo[], tokenBalances: Record<string, string>, expected) => {
|
|
117
118
|
nodeApiMock.getCoinBalance.mockResolvedValue(new BigNumber('10000000000000000000000'))
|
|
118
|
-
nodeApiMock.getTokenBalance.mockImplementation(
|
|
119
|
-
(
|
|
120
|
-
Promise.resolve(new BigNumber(tokenBalances[contractAddress] || '0'))
|
|
119
|
+
nodeApiMock.getTokenBalance.mockImplementation((_address: string, contractAddress: string) =>
|
|
120
|
+
Promise.resolve(new BigNumber(tokenBalances[contractAddress] || '0'))
|
|
121
121
|
)
|
|
122
122
|
|
|
123
123
|
mockGetExplorerApi.mockReturnValue(explorerWithDiscovery(discoveredAssets))
|
|
@@ -198,7 +198,6 @@ describe('getBalance', () => {
|
|
|
198
198
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(expected.length)
|
|
199
199
|
for (const balance of expected) {
|
|
200
200
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith(
|
|
201
|
-
currency,
|
|
202
201
|
userAddress,
|
|
203
202
|
balance.asset.assetReference
|
|
204
203
|
)
|
|
@@ -213,7 +212,6 @@ describe('getBalance', () => {
|
|
|
213
212
|
expect(notSupportedTokens).not.toHaveLength(0)
|
|
214
213
|
for (const asset of notSupportedTokens) {
|
|
215
214
|
expect(nodeApiMock.getTokenBalance).not.toHaveBeenCalledWith(
|
|
216
|
-
currency,
|
|
217
215
|
userAddress,
|
|
218
216
|
'assetReference' in asset ? asset.assetReference : undefined
|
|
219
217
|
)
|
|
@@ -223,14 +221,12 @@ describe('getBalance', () => {
|
|
|
223
221
|
|
|
224
222
|
it('is resilient when failing to fetch token balances', async () => {
|
|
225
223
|
nodeApiMock.getCoinBalance.mockResolvedValue(new BigNumber(10))
|
|
226
|
-
nodeApiMock.getTokenBalance.mockImplementation(
|
|
227
|
-
(
|
|
228
|
-
|
|
229
|
-
return Promise.reject(new Error('Scam token'))
|
|
230
|
-
}
|
|
231
|
-
return Promise.resolve(new BigNumber(2))
|
|
224
|
+
nodeApiMock.getTokenBalance.mockImplementation((_address: string, contract: string) => {
|
|
225
|
+
if (contract === 'contract2') {
|
|
226
|
+
return Promise.reject(new Error('Scam token'))
|
|
232
227
|
}
|
|
233
|
-
|
|
228
|
+
return Promise.resolve(new BigNumber(2))
|
|
229
|
+
})
|
|
234
230
|
mockGetExplorerApi.mockReturnValue(
|
|
235
231
|
explorerWithDiscovery([
|
|
236
232
|
{ type: 'erc20', assetReference: 'contract1' },
|
|
@@ -275,13 +271,8 @@ describe('getBalance', () => {
|
|
|
275
271
|
const result = await getBalance(context, '', 'address')
|
|
276
272
|
|
|
277
273
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(1)
|
|
278
|
-
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith(
|
|
279
|
-
expect.anything(),
|
|
280
|
-
'address',
|
|
281
|
-
REGULAR_CONTRACT
|
|
282
|
-
)
|
|
274
|
+
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith('address', REGULAR_CONTRACT)
|
|
283
275
|
expect(nodeApiMock.getTokenBalance).not.toHaveBeenCalledWith(
|
|
284
|
-
expect.anything(),
|
|
285
276
|
expect.anything(),
|
|
286
277
|
NATIVE_CONTRACT
|
|
287
278
|
)
|
|
@@ -376,11 +367,7 @@ describe('getBalance', () => {
|
|
|
376
367
|
|
|
377
368
|
const result = await getBalance(context, '', 'address', { knownAssets })
|
|
378
369
|
|
|
379
|
-
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith(
|
|
380
|
-
expect.anything(),
|
|
381
|
-
'address',
|
|
382
|
-
'0xknown'
|
|
383
|
-
)
|
|
370
|
+
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith('address', '0xknown')
|
|
384
371
|
expect(result).toEqual([
|
|
385
372
|
{ asset: { type: 'native' }, value: 0n },
|
|
386
373
|
{ asset: { type: 'erc20', assetReference: '0xknown', assetOwner: 'address' }, value: 7n },
|
|
@@ -429,7 +416,6 @@ describe('getBalance', () => {
|
|
|
429
416
|
expect(discoverTokenAssets).toHaveBeenCalledWith(
|
|
430
417
|
expect.anything(),
|
|
431
418
|
expect.anything(),
|
|
432
|
-
'currency',
|
|
433
419
|
'address',
|
|
434
420
|
12345
|
|
435
421
|
)
|
|
@@ -448,7 +434,6 @@ describe('getBalance', () => {
|
|
|
448
434
|
expect(discoverTokenAssets).toHaveBeenCalledWith(
|
|
449
435
|
expect.anything(),
|
|
450
436
|
expect.anything(),
|
|
451
|
-
'currency',
|
|
452
437
|
'address',
|
|
453
438
|
undefined
|
|
454
439
|
)
|
|
@@ -472,11 +457,7 @@ describe('getBalance', () => {
|
|
|
472
457
|
})
|
|
473
458
|
|
|
474
459
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(1)
|
|
475
|
-
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith(
|
|
476
|
-
expect.anything(),
|
|
477
|
-
'address',
|
|
478
|
-
'0xkept'
|
|
479
|
-
)
|
|
460
|
+
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith('address', '0xkept')
|
|
480
461
|
expect(result).toEqual([
|
|
481
462
|
{ asset: { type: 'native' }, value: 0n },
|
|
482
463
|
{ asset: { type: 'erc20', assetReference: '0xkept', assetOwner: 'address' }, value: 1n },
|
|
@@ -531,6 +512,8 @@ describe('getBalance', () => {
|
|
|
531
512
|
// source — the account's history is walked once, not twice, and `discoverTokenAssets` is
|
|
532
513
|
// never called.
|
|
533
514
|
describe('known-validator wiring (monad)', () => {
|
|
515
|
+
const monadContext = createMockEvmContext({ chainId: CHAIN_ID.MONAD })
|
|
516
|
+
|
|
534
517
|
it('derives token balances from getOperations and never calls discoverTokenAssets', async () => {
|
|
535
518
|
nodeApiMock.getCoinBalance.mockResolvedValue(new BigNumber('0'))
|
|
536
519
|
nodeApiMock.getTokenBalance.mockResolvedValue(new BigNumber('4'))
|
|
@@ -550,14 +533,13 @@ describe('getBalance', () => {
|
|
|
550
533
|
const discoverTokenAssets = jest.fn()
|
|
551
534
|
mockGetExplorerApi.mockReturnValue({ getOperations, discoverTokenAssets })
|
|
552
535
|
|
|
553
|
-
const result = await getBalance(
|
|
536
|
+
const result = await getBalance(monadContext, 'monad', 'address')
|
|
554
537
|
|
|
555
538
|
// The explorer's `getOperations` takes the logger as its second argument; the walk this
|
|
556
539
|
// branch reuses passes it like every other caller.
|
|
557
540
|
expect(getOperations).toHaveBeenCalledWith(
|
|
558
541
|
expect.anything(),
|
|
559
542
|
expect.anything(),
|
|
560
|
-
'monad',
|
|
561
543
|
'address',
|
|
562
544
|
0,
|
|
563
545
|
undefined,
|
|
@@ -598,7 +580,9 @@ describe('getBalance', () => {
|
|
|
598
580
|
discoverTokenAssets: jest.fn(),
|
|
599
581
|
})
|
|
600
582
|
|
|
601
|
-
await expect(getBalance(
|
|
583
|
+
await expect(getBalance(monadContext, 'monad', 'address')).rejects.toThrow(
|
|
584
|
+
'explorer unavailable'
|
|
585
|
+
)
|
|
602
586
|
})
|
|
603
587
|
})
|
|
604
588
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmContext } from '../../config'
|
|
4
|
+
import type { ChainId, EvmContext } from '../../config'
|
|
5
5
|
import type {
|
|
6
6
|
BlockByHeightResult,
|
|
7
7
|
BlockReceiptInfo,
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
} from '../../network/node/types'
|
|
14
14
|
import type { EtherscanInternalTransaction } from '../../types'
|
|
15
15
|
import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
|
|
16
|
-
import { internalTxSourcesFromList } from '../../config'
|
|
16
|
+
import { CHAIN_ID, internalTxSourcesFromList } from '../../config'
|
|
17
17
|
import { UnsupportedRpcMethodError } from '../../errors'
|
|
18
18
|
import {
|
|
19
19
|
createMockEvmConfigInfo,
|
|
@@ -30,9 +30,6 @@ import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
|
30
30
|
import { getBlock } from '../getBlock'
|
|
31
31
|
import { dropRootTraceDuplicates } from '../rootTraceDedup'
|
|
32
32
|
|
|
33
|
-
// fixme refactor this test
|
|
34
|
-
// use builder function to build the mocked return values
|
|
35
|
-
|
|
36
33
|
jest.mock('../../network/node')
|
|
37
34
|
jest.mock('../../network/explorer/etherscan', () => ({
|
|
38
35
|
getInternalTransactionsByBlock: jest.fn().mockResolvedValue([]),
|
|
@@ -43,6 +40,10 @@ describe('getBlock', () => {
|
|
|
43
40
|
jest.clearAllMocks()
|
|
44
41
|
})
|
|
45
42
|
|
|
43
|
+
function mockGetBlockNodeApi(nodeApi: ReturnType<typeof mockNodeApi>): void {
|
|
44
|
+
jest.mocked(getNodeApi).mockReturnValue(nodeApi)
|
|
45
|
+
}
|
|
46
|
+
|
|
46
47
|
const address1 = '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d'
|
|
47
48
|
const address2 = '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619'
|
|
48
49
|
const erc20Address = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
|
|
@@ -148,13 +149,12 @@ describe('getBlock', () => {
|
|
|
148
149
|
})
|
|
149
150
|
)
|
|
150
151
|
|
|
151
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
152
152
|
const mockGetBlockByHeight = jest
|
|
153
153
|
.fn()
|
|
154
154
|
.mockResolvedValueOnce(makeNodeBlock({ transactions: [] }))
|
|
155
155
|
const mockTraceBlockErigon = jest.fn()
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
mockGetBlockNodeApi(
|
|
158
158
|
mockNodeApi({
|
|
159
159
|
getBlockByHeight: mockGetBlockByHeight,
|
|
160
160
|
getBlockReceipts: jest.fn(),
|
|
@@ -179,12 +179,11 @@ describe('getBlock', () => {
|
|
|
179
179
|
})
|
|
180
180
|
)
|
|
181
181
|
|
|
182
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
183
182
|
const mockGetBlockByHeight = jest
|
|
184
183
|
.fn()
|
|
185
184
|
.mockResolvedValueOnce(makeNodeBlock({ transactions: [makeNodeBlockTx({ hash: '0xtx1' })] }))
|
|
186
185
|
|
|
187
|
-
|
|
186
|
+
mockGetBlockNodeApi(
|
|
188
187
|
mockNodeApi({
|
|
189
188
|
getBlockByHeight: mockGetBlockByHeight,
|
|
190
189
|
getBlockReceipts: jest.fn().mockResolvedValue([makeNodeBlockReceipt({ hash: '0xtx1' })]),
|
|
@@ -205,7 +204,6 @@ describe('getBlock', () => {
|
|
|
205
204
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
206
205
|
)
|
|
207
206
|
|
|
208
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
209
207
|
const mockGetBlockByHeight = jest.fn()
|
|
210
208
|
mockGetBlockByHeight.mockResolvedValueOnce(
|
|
211
209
|
makeNodeBlock({
|
|
@@ -226,7 +224,7 @@ describe('getBlock', () => {
|
|
|
226
224
|
}),
|
|
227
225
|
])
|
|
228
226
|
|
|
229
|
-
|
|
227
|
+
mockGetBlockNodeApi(
|
|
230
228
|
mockNodeApi({
|
|
231
229
|
getBlockByHeight: mockGetBlockByHeight,
|
|
232
230
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -297,8 +295,8 @@ describe('getBlock', () => {
|
|
|
297
295
|
)
|
|
298
296
|
|
|
299
297
|
const calldata = '0xa9059cbb00000000'
|
|
300
|
-
|
|
301
|
-
|
|
298
|
+
|
|
299
|
+
mockGetBlockNodeApi(
|
|
302
300
|
mockNodeApi({
|
|
303
301
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
304
302
|
makeNodeBlock({
|
|
@@ -338,8 +336,8 @@ describe('getBlock', () => {
|
|
|
338
336
|
)
|
|
339
337
|
|
|
340
338
|
const initCode = '0x6001600055'
|
|
341
|
-
|
|
342
|
-
|
|
339
|
+
|
|
340
|
+
mockGetBlockNodeApi(
|
|
343
341
|
mockNodeApi({
|
|
344
342
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
345
343
|
makeNodeBlock({
|
|
@@ -382,8 +380,7 @@ describe('getBlock', () => {
|
|
|
382
380
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
383
381
|
)
|
|
384
382
|
|
|
385
|
-
|
|
386
|
-
mockGetNodeApi.mockReturnValue(
|
|
383
|
+
mockGetBlockNodeApi(
|
|
387
384
|
mockNodeApi({
|
|
388
385
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
389
386
|
makeNodeBlock({
|
|
@@ -416,7 +413,7 @@ describe('getBlock', () => {
|
|
|
416
413
|
)
|
|
417
414
|
|
|
418
415
|
const calldata = '0xdeadbeef'
|
|
419
|
-
|
|
416
|
+
|
|
420
417
|
const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
|
|
421
418
|
makeNodeBlock({
|
|
422
419
|
transactions: [makeNodeBlockTx({ hash: '0xtx1' })],
|
|
@@ -437,7 +434,7 @@ describe('getBlock', () => {
|
|
|
437
434
|
})
|
|
438
435
|
)
|
|
439
436
|
|
|
440
|
-
|
|
437
|
+
mockGetBlockNodeApi(
|
|
441
438
|
mockNodeApi({
|
|
442
439
|
getBlockByHeight: mockGetBlockByHeight,
|
|
443
440
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -462,7 +459,6 @@ describe('getBlock', () => {
|
|
|
462
459
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
463
460
|
)
|
|
464
461
|
|
|
465
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
466
462
|
const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
|
|
467
463
|
makeNodeBlock({
|
|
468
464
|
hash: '0xabc123',
|
|
@@ -479,7 +475,7 @@ describe('getBlock', () => {
|
|
|
479
475
|
.fn()
|
|
480
476
|
.mockResolvedValueOnce(makeNodeTxInfo({ hash: '0xtx1', value: '1000' }))
|
|
481
477
|
|
|
482
|
-
|
|
478
|
+
mockGetBlockNodeApi(
|
|
483
479
|
mockNodeApi({
|
|
484
480
|
getBlockByHeight: mockGetBlockByHeight,
|
|
485
481
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -499,8 +495,8 @@ describe('getBlock', () => {
|
|
|
499
495
|
}),
|
|
500
496
|
]),
|
|
501
497
|
})
|
|
502
|
-
expect(mockGetBlockReceipts).toHaveBeenCalledWith(
|
|
503
|
-
expect(mockGetTransaction).toHaveBeenCalledWith(
|
|
498
|
+
expect(mockGetBlockReceipts).toHaveBeenCalledWith(12345)
|
|
499
|
+
expect(mockGetTransaction).toHaveBeenCalledWith('0xtx1')
|
|
504
500
|
})
|
|
505
501
|
|
|
506
502
|
it('falls back to per-transaction calls when prefetchTxs is not supported', async () => {
|
|
@@ -508,14 +504,13 @@ describe('getBlock', () => {
|
|
|
508
504
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
509
505
|
)
|
|
510
506
|
|
|
511
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
512
507
|
const mockGetBlockByHeight = jest
|
|
513
508
|
.fn()
|
|
514
509
|
.mockResolvedValueOnce(makeNodeBlock({ hash: '0xabc123', transactionHashes: ['0xtx1'] }))
|
|
515
510
|
const mockGetBlockReceipts = jest.fn()
|
|
516
511
|
const mockGetTransaction = jest.fn().mockResolvedValueOnce(makeNodeTxInfo({ hash: '0xtx1' }))
|
|
517
512
|
|
|
518
|
-
|
|
513
|
+
mockGetBlockNodeApi(
|
|
519
514
|
mockNodeApi({
|
|
520
515
|
getBlockByHeight: mockGetBlockByHeight,
|
|
521
516
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -535,9 +530,9 @@ describe('getBlock', () => {
|
|
|
535
530
|
}),
|
|
536
531
|
]),
|
|
537
532
|
})
|
|
538
|
-
expect(mockGetBlockByHeight).toHaveBeenCalledWith(
|
|
533
|
+
expect(mockGetBlockByHeight).toHaveBeenCalledWith(12345, true)
|
|
539
534
|
expect(mockGetBlockReceipts).not.toHaveBeenCalled()
|
|
540
|
-
expect(mockGetTransaction).toHaveBeenCalledWith(
|
|
535
|
+
expect(mockGetTransaction).toHaveBeenCalledWith('0xtx1')
|
|
541
536
|
})
|
|
542
537
|
|
|
543
538
|
it('does not fallback when getBlockReceipts fails for another reason', async () => {
|
|
@@ -545,7 +540,6 @@ describe('getBlock', () => {
|
|
|
545
540
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
546
541
|
)
|
|
547
542
|
|
|
548
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
549
543
|
const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
|
|
550
544
|
makeNodeBlock({
|
|
551
545
|
height: 12345,
|
|
@@ -556,7 +550,7 @@ describe('getBlock', () => {
|
|
|
556
550
|
const mockGetBlockReceipts = jest.fn().mockRejectedValueOnce(serverError)
|
|
557
551
|
const mockGetTransaction = jest.fn()
|
|
558
552
|
|
|
559
|
-
|
|
553
|
+
mockGetBlockNodeApi(
|
|
560
554
|
mockNodeApi({
|
|
561
555
|
getBlockByHeight: mockGetBlockByHeight,
|
|
562
556
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -599,7 +593,6 @@ describe('getBlock', () => {
|
|
|
599
593
|
})
|
|
600
594
|
)
|
|
601
595
|
|
|
602
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
603
596
|
const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
|
|
604
597
|
makeNodeBlock({
|
|
605
598
|
transactions: [makeNodeBlockTx({ hash: '0xtx1', value: '0' })],
|
|
@@ -609,7 +602,7 @@ describe('getBlock', () => {
|
|
|
609
602
|
.fn()
|
|
610
603
|
.mockResolvedValue([makeNodeBlockReceipt({ hash: '0xtx1', erc20Transfers: [] })])
|
|
611
604
|
|
|
612
|
-
|
|
605
|
+
mockGetBlockNodeApi(
|
|
613
606
|
mockNodeApi({
|
|
614
607
|
getBlockByHeight: mockGetBlockByHeight,
|
|
615
608
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -674,8 +667,8 @@ describe('getBlock', () => {
|
|
|
674
667
|
)
|
|
675
668
|
|
|
676
669
|
const amount = 200000000000000000n
|
|
677
|
-
|
|
678
|
-
|
|
670
|
+
|
|
671
|
+
mockGetBlockNodeApi(
|
|
679
672
|
mockNodeApi({
|
|
680
673
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
681
674
|
makeNodeBlock({
|
|
@@ -725,8 +718,8 @@ describe('getBlock', () => {
|
|
|
725
718
|
const coinAmount = 200000000000000000n
|
|
726
719
|
const nestedAmount = 200000000000000000n
|
|
727
720
|
const nestedRecipient = '0x330E16622F947CBBfA15aB2fdf83014EAa27eCd1'
|
|
728
|
-
|
|
729
|
-
|
|
721
|
+
|
|
722
|
+
mockGetBlockNodeApi(
|
|
730
723
|
mockNodeApi({
|
|
731
724
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
732
725
|
makeNodeBlock({
|
|
@@ -793,8 +786,8 @@ describe('getBlock', () => {
|
|
|
793
786
|
action: makeNodeTraceAction({ from: address1, to: address2, value: amount.toString() }),
|
|
794
787
|
}),
|
|
795
788
|
])
|
|
796
|
-
|
|
797
|
-
|
|
789
|
+
|
|
790
|
+
mockGetBlockNodeApi(
|
|
798
791
|
mockNodeApi({
|
|
799
792
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
800
793
|
makeNodeBlock({
|
|
@@ -813,7 +806,7 @@ describe('getBlock', () => {
|
|
|
813
806
|
const result = await getBlock(context, '', 12345)
|
|
814
807
|
|
|
815
808
|
expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
|
|
816
|
-
expect(mockTraceBlock).toHaveBeenCalledWith(
|
|
809
|
+
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
817
810
|
|
|
818
811
|
const encodedFrom = safeEncodeEIP55(address1, testLogger)
|
|
819
812
|
const encodedTo = safeEncodeEIP55(address2, testLogger)
|
|
@@ -855,8 +848,8 @@ describe('getBlock', () => {
|
|
|
855
848
|
}
|
|
856
849
|
)
|
|
857
850
|
const mockTraceBlock = jest.fn().mockRejectedValue(error)
|
|
858
|
-
|
|
859
|
-
|
|
851
|
+
|
|
852
|
+
mockGetBlockNodeApi(
|
|
860
853
|
mockNodeApi({
|
|
861
854
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
862
855
|
makeNodeBlock({
|
|
@@ -874,7 +867,7 @@ describe('getBlock', () => {
|
|
|
874
867
|
await expect(getBlock(context, '', 12345)).rejects.toThrow(error)
|
|
875
868
|
|
|
876
869
|
expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
|
|
877
|
-
expect(mockTraceBlock).toHaveBeenCalledWith(
|
|
870
|
+
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
878
871
|
})
|
|
879
872
|
|
|
880
873
|
it('when explorer.getInternalTransactionsByBlock fails and node trace methods are undefined, returns block with no internal transactions', async () => {
|
|
@@ -886,8 +879,7 @@ describe('getBlock', () => {
|
|
|
886
879
|
})
|
|
887
880
|
)
|
|
888
881
|
|
|
889
|
-
|
|
890
|
-
mockGetNodeApi.mockReturnValue(
|
|
882
|
+
mockGetBlockNodeApi(
|
|
891
883
|
mockNodeApi({
|
|
892
884
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
893
885
|
makeNodeBlock({
|
|
@@ -934,8 +926,8 @@ describe('getBlock', () => {
|
|
|
934
926
|
})
|
|
935
927
|
|
|
936
928
|
const mockTraceBlock = jest.fn().mockResolvedValue([traceBlockItem])
|
|
937
|
-
|
|
938
|
-
|
|
929
|
+
|
|
930
|
+
mockGetBlockNodeApi(
|
|
939
931
|
mockNodeApi({
|
|
940
932
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
941
933
|
makeNodeBlock({
|
|
@@ -955,7 +947,7 @@ describe('getBlock', () => {
|
|
|
955
947
|
|
|
956
948
|
const result = await getBlock(context, '', 12345)
|
|
957
949
|
|
|
958
|
-
expect(mockTraceBlock).toHaveBeenCalledWith(
|
|
950
|
+
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
959
951
|
const encodedFrom = safeEncodeEIP55(address1, testLogger)
|
|
960
952
|
const encodedTo = safeEncodeEIP55(address2, testLogger)
|
|
961
953
|
expect(result).toMatchObject({
|
|
@@ -1004,8 +996,8 @@ describe('getBlock', () => {
|
|
|
1004
996
|
}
|
|
1005
997
|
)
|
|
1006
998
|
const mockTraceBlock = jest.fn().mockRejectedValue(error)
|
|
1007
|
-
|
|
1008
|
-
|
|
999
|
+
|
|
1000
|
+
mockGetBlockNodeApi(
|
|
1009
1001
|
mockNodeApi({
|
|
1010
1002
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
1011
1003
|
makeNodeBlock({
|
|
@@ -1026,7 +1018,7 @@ describe('getBlock', () => {
|
|
|
1026
1018
|
await expect(getBlock(context, '', 12345)).rejects.toThrow(error)
|
|
1027
1019
|
|
|
1028
1020
|
expect(mockGetInternalTransactionsByBlock).toHaveBeenCalledWith(expect.anything(), 12345)
|
|
1029
|
-
expect(mockTraceBlock).toHaveBeenCalledWith(
|
|
1021
|
+
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
1030
1022
|
})
|
|
1031
1023
|
|
|
1032
1024
|
it('with default source list, propagates trace errors when explorer and both trace methods fail at runtime', async () => {
|
|
@@ -1048,8 +1040,8 @@ describe('getBlock', () => {
|
|
|
1048
1040
|
)
|
|
1049
1041
|
const mockTraceBlockErigon = jest.fn().mockRejectedValue(erigonError)
|
|
1050
1042
|
const mockTraceBlockGeth = jest.fn().mockRejectedValue(gethError)
|
|
1051
|
-
|
|
1052
|
-
|
|
1043
|
+
|
|
1044
|
+
mockGetBlockNodeApi(
|
|
1053
1045
|
mockNodeApi({
|
|
1054
1046
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
1055
1047
|
makeNodeBlock({
|
|
@@ -1071,8 +1063,8 @@ describe('getBlock', () => {
|
|
|
1071
1063
|
await expect(getBlock(context, '', 12345)).rejects.toMatchObject({
|
|
1072
1064
|
errors: [erigonError, gethError],
|
|
1073
1065
|
})
|
|
1074
|
-
expect(mockTraceBlockErigon).toHaveBeenCalledWith(
|
|
1075
|
-
expect(mockTraceBlockGeth).toHaveBeenCalledWith(
|
|
1066
|
+
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
1067
|
+
expect(mockTraceBlockGeth).toHaveBeenCalledWith(12345)
|
|
1076
1068
|
})
|
|
1077
1069
|
|
|
1078
1070
|
it('with default source list, falls back from traceBlockErigon to traceBlockGeth when explorer fails', async () => {
|
|
@@ -1091,8 +1083,8 @@ describe('getBlock', () => {
|
|
|
1091
1083
|
action: makeNodeTraceAction({ from: address1, to: address2, value: amount.toString() }),
|
|
1092
1084
|
}),
|
|
1093
1085
|
])
|
|
1094
|
-
|
|
1095
|
-
|
|
1086
|
+
|
|
1087
|
+
mockGetBlockNodeApi(
|
|
1096
1088
|
mockNodeApi({
|
|
1097
1089
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
1098
1090
|
makeNodeBlock({
|
|
@@ -1112,8 +1104,8 @@ describe('getBlock', () => {
|
|
|
1112
1104
|
|
|
1113
1105
|
const result = await getBlock(context, '', 12345)
|
|
1114
1106
|
|
|
1115
|
-
expect(mockTraceBlockErigon).toHaveBeenCalledWith(
|
|
1116
|
-
expect(mockTraceBlockGeth).toHaveBeenCalledWith(
|
|
1107
|
+
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
1108
|
+
expect(mockTraceBlockGeth).toHaveBeenCalledWith(12345)
|
|
1117
1109
|
const encodedFrom = safeEncodeEIP55(address1, testLogger)
|
|
1118
1110
|
const encodedTo = safeEncodeEIP55(address2, testLogger)
|
|
1119
1111
|
expect(result.transactions[0].operations).toEqual(
|
|
@@ -1150,8 +1142,8 @@ describe('getBlock', () => {
|
|
|
1150
1142
|
{ method: 'trace_block', rawError: { code: -32601 } }
|
|
1151
1143
|
)
|
|
1152
1144
|
const mockTraceBlockErigon = jest.fn().mockRejectedValue(erigonError)
|
|
1153
|
-
|
|
1154
|
-
|
|
1145
|
+
|
|
1146
|
+
mockGetBlockNodeApi(
|
|
1155
1147
|
mockNodeApi({
|
|
1156
1148
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
1157
1149
|
makeNodeBlock({
|
|
@@ -1170,7 +1162,7 @@ describe('getBlock', () => {
|
|
|
1170
1162
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
1171
1163
|
|
|
1172
1164
|
await expect(getBlock(context, '', 12345)).rejects.toThrow(erigonError)
|
|
1173
|
-
expect(mockTraceBlockErigon).toHaveBeenCalledWith(
|
|
1165
|
+
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
1174
1166
|
})
|
|
1175
1167
|
|
|
1176
1168
|
it('uses prefetched tx gasPrice as fallback when Cronos receipt omits effectiveGasPrice and gasPrice', async () => {
|
|
@@ -1179,8 +1171,8 @@ describe('getBlock', () => {
|
|
|
1179
1171
|
)
|
|
1180
1172
|
const gasUsed = 21000n
|
|
1181
1173
|
const txGasPrice = '568125000000'
|
|
1182
|
-
|
|
1183
|
-
|
|
1174
|
+
|
|
1175
|
+
mockGetBlockNodeApi(
|
|
1184
1176
|
mockNodeApi({
|
|
1185
1177
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
1186
1178
|
makeNodeBlock({
|
|
@@ -1209,8 +1201,8 @@ describe('getBlock', () => {
|
|
|
1209
1201
|
const gasUsed = 21000n
|
|
1210
1202
|
const receiptEffectiveGasPrice = '1000000000' // 1 Gwei — resolved from effectiveGasPrice by getBlockReceipts
|
|
1211
1203
|
const txGasPrice = '568125000000' // higher value in the prefetched tx — must NOT win
|
|
1212
|
-
|
|
1213
|
-
|
|
1204
|
+
|
|
1205
|
+
mockGetBlockNodeApi(
|
|
1214
1206
|
mockNodeApi({
|
|
1215
1207
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
1216
1208
|
makeNodeBlock({
|
|
@@ -1239,8 +1231,8 @@ describe('getBlock', () => {
|
|
|
1239
1231
|
const gasUsed = 21000n
|
|
1240
1232
|
const gasPrice = '1000000000'
|
|
1241
1233
|
const l1Fee = '95394812830580'
|
|
1242
|
-
|
|
1243
|
-
|
|
1234
|
+
|
|
1235
|
+
mockGetBlockNodeApi(
|
|
1244
1236
|
mockNodeApi({
|
|
1245
1237
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
1246
1238
|
makeNodeBlock({
|
|
@@ -1270,8 +1262,8 @@ describe('getBlock', () => {
|
|
|
1270
1262
|
const gasUsed = '21000'
|
|
1271
1263
|
const gasPrice = '1000000000'
|
|
1272
1264
|
const l1Fee = '95394812830580'
|
|
1273
|
-
|
|
1274
|
-
|
|
1265
|
+
|
|
1266
|
+
mockGetBlockNodeApi(
|
|
1275
1267
|
mockNodeApi({
|
|
1276
1268
|
getBlockByHeight: jest
|
|
1277
1269
|
.fn()
|
|
@@ -1293,13 +1285,14 @@ describe('getBlock', () => {
|
|
|
1293
1285
|
|
|
1294
1286
|
function buildZksyncMocks(
|
|
1295
1287
|
txOverrides: Partial<PrefetchedBlockTransaction>,
|
|
1296
|
-
receiptOverrides: Partial<BlockReceiptInfo
|
|
1288
|
+
receiptOverrides: Partial<BlockReceiptInfo>,
|
|
1289
|
+
chainId: ChainId = CHAIN_ID.ZKSYNC
|
|
1297
1290
|
): EvmContext {
|
|
1298
1291
|
const context = createMockEvmContext(
|
|
1299
|
-
createMockEvmConfigInfo({ chainId
|
|
1292
|
+
createMockEvmConfigInfo({ chainId, node: mkExternalNode() })
|
|
1300
1293
|
)
|
|
1301
|
-
|
|
1302
|
-
|
|
1294
|
+
|
|
1295
|
+
mockGetBlockNodeApi(
|
|
1303
1296
|
mockNodeApi({
|
|
1304
1297
|
getBlockByHeight: jest
|
|
1305
1298
|
.fn()
|
|
@@ -1561,7 +1554,7 @@ describe('getBlock', () => {
|
|
|
1561
1554
|
])
|
|
1562
1555
|
})
|
|
1563
1556
|
|
|
1564
|
-
it('does not apply zkSync corrections to other
|
|
1557
|
+
it('does not apply zkSync corrections to other chains (e.g. ethereum) even when the currency id is zksync and receipt type is 0xff', async () => {
|
|
1565
1558
|
const context = buildZksyncMocks(
|
|
1566
1559
|
{ from: USER, to: USER, value: '270000000000000000' },
|
|
1567
1560
|
{
|
|
@@ -1574,9 +1567,10 @@ describe('getBlock', () => {
|
|
|
1574
1567
|
value: '270000000000000000',
|
|
1575
1568
|
},
|
|
1576
1569
|
],
|
|
1577
|
-
}
|
|
1570
|
+
},
|
|
1571
|
+
CHAIN_ID.ETHEREUM
|
|
1578
1572
|
)
|
|
1579
|
-
const result = await getBlock(context, '
|
|
1573
|
+
const result = await getBlock(context, 'zksync', 12345)
|
|
1580
1574
|
expect(result.transactions[0].operations).toEqual([
|
|
1581
1575
|
{
|
|
1582
1576
|
type: 'transfer',
|
|
@@ -20,7 +20,7 @@ describe('getBlockInfo', () => {
|
|
|
20
20
|
|
|
21
21
|
beforeEach(() => {
|
|
22
22
|
jest.clearAllMocks()
|
|
23
|
-
mockGetNodeApi.mockImplementation((config: EvmConfigInfo
|
|
23
|
+
mockGetNodeApi.mockImplementation((config: EvmConfigInfo) => {
|
|
24
24
|
return config?.node?.type === 'ledger' ? ledgerMocks : externalMocks
|
|
25
25
|
})
|
|
26
26
|
})
|
|
@@ -20,7 +20,7 @@ describe('getNextSequence', () => {
|
|
|
20
20
|
|
|
21
21
|
beforeEach(() => {
|
|
22
22
|
jest.clearAllMocks()
|
|
23
|
-
mockGetNodeApi.mockImplementation((config: EvmConfigInfo
|
|
23
|
+
mockGetNodeApi.mockImplementation((config: EvmConfigInfo) => {
|
|
24
24
|
return config?.node?.type === 'ledger' ? ledgerMocks : externalMocks
|
|
25
25
|
})
|
|
26
26
|
})
|