@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
|
@@ -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,
|
|
@@ -26,13 +26,10 @@ import {
|
|
|
26
26
|
import { safeEncodeEIP55 } from '../../logic-public'
|
|
27
27
|
import { getInternalTransactionsByBlock } from '../../network/explorer/etherscan'
|
|
28
28
|
import { getNodeApi } from '../../network/node'
|
|
29
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
29
|
+
import { mockNodeApi } from '../../network/tests/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({
|
|
@@ -404,10 +401,131 @@ describe('getBlock', () => {
|
|
|
404
401
|
|
|
405
402
|
const result = await getBlock(context, '', 12345)
|
|
406
403
|
|
|
407
|
-
expect(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
404
|
+
expect(result.transactions[0].details).not.toHaveProperty('contractInteraction')
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
it('adds the receipt gas price, the gas limit and the nonce to prefetched tx details', async () => {
|
|
408
|
+
const context = createMockEvmContext(
|
|
409
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
mockGetBlockNodeApi(
|
|
413
|
+
mockNodeApi({
|
|
414
|
+
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
415
|
+
makeNodeBlock({
|
|
416
|
+
transactions: [
|
|
417
|
+
makeNodeBlockTx({
|
|
418
|
+
hash: '0xtx1',
|
|
419
|
+
gasPrice: '30000000000', // maxFeePerGas fallback of a type-2 tx: must NOT win
|
|
420
|
+
gasLimit: '73330',
|
|
421
|
+
nonce: 42,
|
|
422
|
+
}),
|
|
423
|
+
],
|
|
424
|
+
})
|
|
425
|
+
),
|
|
426
|
+
getBlockReceipts: jest
|
|
427
|
+
.fn()
|
|
428
|
+
.mockResolvedValueOnce([makeNodeBlockReceipt({ hash: '0xtx1', gasPrice: '1000000000' })]),
|
|
429
|
+
getTransaction: jest.fn(),
|
|
430
|
+
})
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
const result = await getBlock(context, '', 12345)
|
|
434
|
+
|
|
435
|
+
expect(result.transactions[0].details).toEqual({
|
|
436
|
+
gasPrice: '1000000000',
|
|
437
|
+
gasLimit: '73330',
|
|
438
|
+
sequence: 42,
|
|
439
|
+
})
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
it('adds the gas price, the gas limit and the nonce to contract details', async () => {
|
|
443
|
+
const context = createMockEvmContext(
|
|
444
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
mockGetBlockNodeApi(
|
|
448
|
+
mockNodeApi({
|
|
449
|
+
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
450
|
+
makeNodeBlock({
|
|
451
|
+
transactions: [
|
|
452
|
+
makeNodeBlockTx({ hash: '0xtx1', input: '0xdeadbeef', gasLimit: '73330', nonce: 0 }),
|
|
453
|
+
],
|
|
454
|
+
})
|
|
455
|
+
),
|
|
456
|
+
getBlockReceipts: jest
|
|
457
|
+
.fn()
|
|
458
|
+
.mockResolvedValueOnce([makeNodeBlockReceipt({ hash: '0xtx1', gasPrice: '1000000000' })]),
|
|
459
|
+
getTransaction: jest.fn(),
|
|
460
|
+
})
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
const result = await getBlock(context, '', 12345)
|
|
464
|
+
|
|
465
|
+
expect(result.transactions[0].details).toEqual({
|
|
466
|
+
gasPrice: '1000000000',
|
|
467
|
+
gasLimit: '73330',
|
|
468
|
+
sequence: 0,
|
|
469
|
+
contractInteraction: 'SmartContractInteraction',
|
|
470
|
+
contractAddress: safeEncodeEIP55(address2, testLogger),
|
|
471
|
+
contractPayload: '0xdeadbeef',
|
|
472
|
+
})
|
|
473
|
+
})
|
|
474
|
+
|
|
475
|
+
it('omits the gas limit and the nonce when the prefetched tx does not report them', async () => {
|
|
476
|
+
const context = createMockEvmContext(
|
|
477
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
mockGetBlockNodeApi(
|
|
481
|
+
mockNodeApi({
|
|
482
|
+
getBlockByHeight: jest
|
|
483
|
+
.fn()
|
|
484
|
+
.mockResolvedValueOnce(makeNodeBlock({ transactions: [makeNodeBlockTx()] })),
|
|
485
|
+
getBlockReceipts: jest.fn().mockResolvedValueOnce([makeNodeBlockReceipt()]),
|
|
486
|
+
getTransaction: jest.fn(),
|
|
487
|
+
})
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
const result = await getBlock(context, '', 12345)
|
|
491
|
+
|
|
492
|
+
expect(result.transactions[0].details).toEqual({ gasPrice: '20000000000' })
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
it('adds the gas price, the gas limit and the nonce when falling back to getTransaction', async () => {
|
|
496
|
+
const context = createMockEvmContext(
|
|
497
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
mockGetBlockNodeApi(
|
|
501
|
+
mockNodeApi({
|
|
502
|
+
getBlockByHeight: jest
|
|
503
|
+
.fn()
|
|
504
|
+
.mockResolvedValueOnce(makeNodeBlock({ transactions: [makeNodeBlockTx()] })),
|
|
505
|
+
getBlockReceipts: jest.fn().mockRejectedValueOnce(
|
|
506
|
+
new UnsupportedRpcMethodError(
|
|
507
|
+
'eth_getBlockReceipts is not supported by this RPC provider',
|
|
508
|
+
{
|
|
509
|
+
method: 'eth_getBlockReceipts',
|
|
510
|
+
rawError: { code: -32601 },
|
|
511
|
+
}
|
|
512
|
+
)
|
|
513
|
+
),
|
|
514
|
+
getTransaction: jest
|
|
515
|
+
.fn()
|
|
516
|
+
.mockResolvedValueOnce(
|
|
517
|
+
makeNodeTxInfo({ gasPrice: '1000000000', gasLimit: '21000', nonce: 7 })
|
|
518
|
+
),
|
|
519
|
+
})
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
const result = await getBlock(context, '', 12345)
|
|
523
|
+
|
|
524
|
+
expect(result.transactions[0].details).toEqual({
|
|
525
|
+
gasPrice: '1000000000',
|
|
526
|
+
gasLimit: '21000',
|
|
527
|
+
sequence: 7,
|
|
528
|
+
})
|
|
411
529
|
})
|
|
412
530
|
|
|
413
531
|
it('adds contract details when falling back to getTransaction with non-trivial input', async () => {
|
|
@@ -416,7 +534,7 @@ describe('getBlock', () => {
|
|
|
416
534
|
)
|
|
417
535
|
|
|
418
536
|
const calldata = '0xdeadbeef'
|
|
419
|
-
|
|
537
|
+
|
|
420
538
|
const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
|
|
421
539
|
makeNodeBlock({
|
|
422
540
|
transactions: [makeNodeBlockTx({ hash: '0xtx1' })],
|
|
@@ -437,7 +555,7 @@ describe('getBlock', () => {
|
|
|
437
555
|
})
|
|
438
556
|
)
|
|
439
557
|
|
|
440
|
-
|
|
558
|
+
mockGetBlockNodeApi(
|
|
441
559
|
mockNodeApi({
|
|
442
560
|
getBlockByHeight: mockGetBlockByHeight,
|
|
443
561
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -462,7 +580,6 @@ describe('getBlock', () => {
|
|
|
462
580
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
463
581
|
)
|
|
464
582
|
|
|
465
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
466
583
|
const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
|
|
467
584
|
makeNodeBlock({
|
|
468
585
|
hash: '0xabc123',
|
|
@@ -479,7 +596,7 @@ describe('getBlock', () => {
|
|
|
479
596
|
.fn()
|
|
480
597
|
.mockResolvedValueOnce(makeNodeTxInfo({ hash: '0xtx1', value: '1000' }))
|
|
481
598
|
|
|
482
|
-
|
|
599
|
+
mockGetBlockNodeApi(
|
|
483
600
|
mockNodeApi({
|
|
484
601
|
getBlockByHeight: mockGetBlockByHeight,
|
|
485
602
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -499,8 +616,8 @@ describe('getBlock', () => {
|
|
|
499
616
|
}),
|
|
500
617
|
]),
|
|
501
618
|
})
|
|
502
|
-
expect(mockGetBlockReceipts).toHaveBeenCalledWith(
|
|
503
|
-
expect(mockGetTransaction).toHaveBeenCalledWith(
|
|
619
|
+
expect(mockGetBlockReceipts).toHaveBeenCalledWith(12345)
|
|
620
|
+
expect(mockGetTransaction).toHaveBeenCalledWith('0xtx1')
|
|
504
621
|
})
|
|
505
622
|
|
|
506
623
|
it('falls back to per-transaction calls when prefetchTxs is not supported', async () => {
|
|
@@ -508,14 +625,13 @@ describe('getBlock', () => {
|
|
|
508
625
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
509
626
|
)
|
|
510
627
|
|
|
511
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
512
628
|
const mockGetBlockByHeight = jest
|
|
513
629
|
.fn()
|
|
514
630
|
.mockResolvedValueOnce(makeNodeBlock({ hash: '0xabc123', transactionHashes: ['0xtx1'] }))
|
|
515
631
|
const mockGetBlockReceipts = jest.fn()
|
|
516
632
|
const mockGetTransaction = jest.fn().mockResolvedValueOnce(makeNodeTxInfo({ hash: '0xtx1' }))
|
|
517
633
|
|
|
518
|
-
|
|
634
|
+
mockGetBlockNodeApi(
|
|
519
635
|
mockNodeApi({
|
|
520
636
|
getBlockByHeight: mockGetBlockByHeight,
|
|
521
637
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -535,9 +651,9 @@ describe('getBlock', () => {
|
|
|
535
651
|
}),
|
|
536
652
|
]),
|
|
537
653
|
})
|
|
538
|
-
expect(mockGetBlockByHeight).toHaveBeenCalledWith(
|
|
654
|
+
expect(mockGetBlockByHeight).toHaveBeenCalledWith(12345, true)
|
|
539
655
|
expect(mockGetBlockReceipts).not.toHaveBeenCalled()
|
|
540
|
-
expect(mockGetTransaction).toHaveBeenCalledWith(
|
|
656
|
+
expect(mockGetTransaction).toHaveBeenCalledWith('0xtx1')
|
|
541
657
|
})
|
|
542
658
|
|
|
543
659
|
it('does not fallback when getBlockReceipts fails for another reason', async () => {
|
|
@@ -545,7 +661,6 @@ describe('getBlock', () => {
|
|
|
545
661
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
546
662
|
)
|
|
547
663
|
|
|
548
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
549
664
|
const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
|
|
550
665
|
makeNodeBlock({
|
|
551
666
|
height: 12345,
|
|
@@ -556,7 +671,7 @@ describe('getBlock', () => {
|
|
|
556
671
|
const mockGetBlockReceipts = jest.fn().mockRejectedValueOnce(serverError)
|
|
557
672
|
const mockGetTransaction = jest.fn()
|
|
558
673
|
|
|
559
|
-
|
|
674
|
+
mockGetBlockNodeApi(
|
|
560
675
|
mockNodeApi({
|
|
561
676
|
getBlockByHeight: mockGetBlockByHeight,
|
|
562
677
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -599,7 +714,6 @@ describe('getBlock', () => {
|
|
|
599
714
|
})
|
|
600
715
|
)
|
|
601
716
|
|
|
602
|
-
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
603
717
|
const mockGetBlockByHeight = jest.fn().mockResolvedValueOnce(
|
|
604
718
|
makeNodeBlock({
|
|
605
719
|
transactions: [makeNodeBlockTx({ hash: '0xtx1', value: '0' })],
|
|
@@ -609,7 +723,7 @@ describe('getBlock', () => {
|
|
|
609
723
|
.fn()
|
|
610
724
|
.mockResolvedValue([makeNodeBlockReceipt({ hash: '0xtx1', erc20Transfers: [] })])
|
|
611
725
|
|
|
612
|
-
|
|
726
|
+
mockGetBlockNodeApi(
|
|
613
727
|
mockNodeApi({
|
|
614
728
|
getBlockByHeight: mockGetBlockByHeight,
|
|
615
729
|
getBlockReceipts: mockGetBlockReceipts,
|
|
@@ -674,8 +788,8 @@ describe('getBlock', () => {
|
|
|
674
788
|
)
|
|
675
789
|
|
|
676
790
|
const amount = 200000000000000000n
|
|
677
|
-
|
|
678
|
-
|
|
791
|
+
|
|
792
|
+
mockGetBlockNodeApi(
|
|
679
793
|
mockNodeApi({
|
|
680
794
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
681
795
|
makeNodeBlock({
|
|
@@ -725,8 +839,8 @@ describe('getBlock', () => {
|
|
|
725
839
|
const coinAmount = 200000000000000000n
|
|
726
840
|
const nestedAmount = 200000000000000000n
|
|
727
841
|
const nestedRecipient = '0x330E16622F947CBBfA15aB2fdf83014EAa27eCd1'
|
|
728
|
-
|
|
729
|
-
|
|
842
|
+
|
|
843
|
+
mockGetBlockNodeApi(
|
|
730
844
|
mockNodeApi({
|
|
731
845
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
732
846
|
makeNodeBlock({
|
|
@@ -793,8 +907,8 @@ describe('getBlock', () => {
|
|
|
793
907
|
action: makeNodeTraceAction({ from: address1, to: address2, value: amount.toString() }),
|
|
794
908
|
}),
|
|
795
909
|
])
|
|
796
|
-
|
|
797
|
-
|
|
910
|
+
|
|
911
|
+
mockGetBlockNodeApi(
|
|
798
912
|
mockNodeApi({
|
|
799
913
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
800
914
|
makeNodeBlock({
|
|
@@ -813,7 +927,7 @@ describe('getBlock', () => {
|
|
|
813
927
|
const result = await getBlock(context, '', 12345)
|
|
814
928
|
|
|
815
929
|
expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
|
|
816
|
-
expect(mockTraceBlock).toHaveBeenCalledWith(
|
|
930
|
+
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
817
931
|
|
|
818
932
|
const encodedFrom = safeEncodeEIP55(address1, testLogger)
|
|
819
933
|
const encodedTo = safeEncodeEIP55(address2, testLogger)
|
|
@@ -855,8 +969,8 @@ describe('getBlock', () => {
|
|
|
855
969
|
}
|
|
856
970
|
)
|
|
857
971
|
const mockTraceBlock = jest.fn().mockRejectedValue(error)
|
|
858
|
-
|
|
859
|
-
|
|
972
|
+
|
|
973
|
+
mockGetBlockNodeApi(
|
|
860
974
|
mockNodeApi({
|
|
861
975
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
862
976
|
makeNodeBlock({
|
|
@@ -874,7 +988,7 @@ describe('getBlock', () => {
|
|
|
874
988
|
await expect(getBlock(context, '', 12345)).rejects.toThrow(error)
|
|
875
989
|
|
|
876
990
|
expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
|
|
877
|
-
expect(mockTraceBlock).toHaveBeenCalledWith(
|
|
991
|
+
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
878
992
|
})
|
|
879
993
|
|
|
880
994
|
it('when explorer.getInternalTransactionsByBlock fails and node trace methods are undefined, returns block with no internal transactions', async () => {
|
|
@@ -886,8 +1000,7 @@ describe('getBlock', () => {
|
|
|
886
1000
|
})
|
|
887
1001
|
)
|
|
888
1002
|
|
|
889
|
-
|
|
890
|
-
mockGetNodeApi.mockReturnValue(
|
|
1003
|
+
mockGetBlockNodeApi(
|
|
891
1004
|
mockNodeApi({
|
|
892
1005
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
893
1006
|
makeNodeBlock({
|
|
@@ -934,8 +1047,8 @@ describe('getBlock', () => {
|
|
|
934
1047
|
})
|
|
935
1048
|
|
|
936
1049
|
const mockTraceBlock = jest.fn().mockResolvedValue([traceBlockItem])
|
|
937
|
-
|
|
938
|
-
|
|
1050
|
+
|
|
1051
|
+
mockGetBlockNodeApi(
|
|
939
1052
|
mockNodeApi({
|
|
940
1053
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
941
1054
|
makeNodeBlock({
|
|
@@ -955,7 +1068,7 @@ describe('getBlock', () => {
|
|
|
955
1068
|
|
|
956
1069
|
const result = await getBlock(context, '', 12345)
|
|
957
1070
|
|
|
958
|
-
expect(mockTraceBlock).toHaveBeenCalledWith(
|
|
1071
|
+
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
959
1072
|
const encodedFrom = safeEncodeEIP55(address1, testLogger)
|
|
960
1073
|
const encodedTo = safeEncodeEIP55(address2, testLogger)
|
|
961
1074
|
expect(result).toMatchObject({
|
|
@@ -1004,8 +1117,8 @@ describe('getBlock', () => {
|
|
|
1004
1117
|
}
|
|
1005
1118
|
)
|
|
1006
1119
|
const mockTraceBlock = jest.fn().mockRejectedValue(error)
|
|
1007
|
-
|
|
1008
|
-
|
|
1120
|
+
|
|
1121
|
+
mockGetBlockNodeApi(
|
|
1009
1122
|
mockNodeApi({
|
|
1010
1123
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
1011
1124
|
makeNodeBlock({
|
|
@@ -1026,7 +1139,7 @@ describe('getBlock', () => {
|
|
|
1026
1139
|
await expect(getBlock(context, '', 12345)).rejects.toThrow(error)
|
|
1027
1140
|
|
|
1028
1141
|
expect(mockGetInternalTransactionsByBlock).toHaveBeenCalledWith(expect.anything(), 12345)
|
|
1029
|
-
expect(mockTraceBlock).toHaveBeenCalledWith(
|
|
1142
|
+
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
1030
1143
|
})
|
|
1031
1144
|
|
|
1032
1145
|
it('with default source list, propagates trace errors when explorer and both trace methods fail at runtime', async () => {
|
|
@@ -1048,8 +1161,8 @@ describe('getBlock', () => {
|
|
|
1048
1161
|
)
|
|
1049
1162
|
const mockTraceBlockErigon = jest.fn().mockRejectedValue(erigonError)
|
|
1050
1163
|
const mockTraceBlockGeth = jest.fn().mockRejectedValue(gethError)
|
|
1051
|
-
|
|
1052
|
-
|
|
1164
|
+
|
|
1165
|
+
mockGetBlockNodeApi(
|
|
1053
1166
|
mockNodeApi({
|
|
1054
1167
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
1055
1168
|
makeNodeBlock({
|
|
@@ -1071,8 +1184,8 @@ describe('getBlock', () => {
|
|
|
1071
1184
|
await expect(getBlock(context, '', 12345)).rejects.toMatchObject({
|
|
1072
1185
|
errors: [erigonError, gethError],
|
|
1073
1186
|
})
|
|
1074
|
-
expect(mockTraceBlockErigon).toHaveBeenCalledWith(
|
|
1075
|
-
expect(mockTraceBlockGeth).toHaveBeenCalledWith(
|
|
1187
|
+
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
1188
|
+
expect(mockTraceBlockGeth).toHaveBeenCalledWith(12345)
|
|
1076
1189
|
})
|
|
1077
1190
|
|
|
1078
1191
|
it('with default source list, falls back from traceBlockErigon to traceBlockGeth when explorer fails', async () => {
|
|
@@ -1091,8 +1204,8 @@ describe('getBlock', () => {
|
|
|
1091
1204
|
action: makeNodeTraceAction({ from: address1, to: address2, value: amount.toString() }),
|
|
1092
1205
|
}),
|
|
1093
1206
|
])
|
|
1094
|
-
|
|
1095
|
-
|
|
1207
|
+
|
|
1208
|
+
mockGetBlockNodeApi(
|
|
1096
1209
|
mockNodeApi({
|
|
1097
1210
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
1098
1211
|
makeNodeBlock({
|
|
@@ -1112,8 +1225,8 @@ describe('getBlock', () => {
|
|
|
1112
1225
|
|
|
1113
1226
|
const result = await getBlock(context, '', 12345)
|
|
1114
1227
|
|
|
1115
|
-
expect(mockTraceBlockErigon).toHaveBeenCalledWith(
|
|
1116
|
-
expect(mockTraceBlockGeth).toHaveBeenCalledWith(
|
|
1228
|
+
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
1229
|
+
expect(mockTraceBlockGeth).toHaveBeenCalledWith(12345)
|
|
1117
1230
|
const encodedFrom = safeEncodeEIP55(address1, testLogger)
|
|
1118
1231
|
const encodedTo = safeEncodeEIP55(address2, testLogger)
|
|
1119
1232
|
expect(result.transactions[0].operations).toEqual(
|
|
@@ -1150,8 +1263,8 @@ describe('getBlock', () => {
|
|
|
1150
1263
|
{ method: 'trace_block', rawError: { code: -32601 } }
|
|
1151
1264
|
)
|
|
1152
1265
|
const mockTraceBlockErigon = jest.fn().mockRejectedValue(erigonError)
|
|
1153
|
-
|
|
1154
|
-
|
|
1266
|
+
|
|
1267
|
+
mockGetBlockNodeApi(
|
|
1155
1268
|
mockNodeApi({
|
|
1156
1269
|
getBlockByHeight: jest.fn().mockResolvedValue(
|
|
1157
1270
|
makeNodeBlock({
|
|
@@ -1170,7 +1283,7 @@ describe('getBlock', () => {
|
|
|
1170
1283
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
1171
1284
|
|
|
1172
1285
|
await expect(getBlock(context, '', 12345)).rejects.toThrow(erigonError)
|
|
1173
|
-
expect(mockTraceBlockErigon).toHaveBeenCalledWith(
|
|
1286
|
+
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
1174
1287
|
})
|
|
1175
1288
|
|
|
1176
1289
|
it('uses prefetched tx gasPrice as fallback when Cronos receipt omits effectiveGasPrice and gasPrice', async () => {
|
|
@@ -1179,8 +1292,8 @@ describe('getBlock', () => {
|
|
|
1179
1292
|
)
|
|
1180
1293
|
const gasUsed = 21000n
|
|
1181
1294
|
const txGasPrice = '568125000000'
|
|
1182
|
-
|
|
1183
|
-
|
|
1295
|
+
|
|
1296
|
+
mockGetBlockNodeApi(
|
|
1184
1297
|
mockNodeApi({
|
|
1185
1298
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
1186
1299
|
makeNodeBlock({
|
|
@@ -1209,8 +1322,8 @@ describe('getBlock', () => {
|
|
|
1209
1322
|
const gasUsed = 21000n
|
|
1210
1323
|
const receiptEffectiveGasPrice = '1000000000' // 1 Gwei — resolved from effectiveGasPrice by getBlockReceipts
|
|
1211
1324
|
const txGasPrice = '568125000000' // higher value in the prefetched tx — must NOT win
|
|
1212
|
-
|
|
1213
|
-
|
|
1325
|
+
|
|
1326
|
+
mockGetBlockNodeApi(
|
|
1214
1327
|
mockNodeApi({
|
|
1215
1328
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
1216
1329
|
makeNodeBlock({
|
|
@@ -1239,8 +1352,8 @@ describe('getBlock', () => {
|
|
|
1239
1352
|
const gasUsed = 21000n
|
|
1240
1353
|
const gasPrice = '1000000000'
|
|
1241
1354
|
const l1Fee = '95394812830580'
|
|
1242
|
-
|
|
1243
|
-
|
|
1355
|
+
|
|
1356
|
+
mockGetBlockNodeApi(
|
|
1244
1357
|
mockNodeApi({
|
|
1245
1358
|
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
1246
1359
|
makeNodeBlock({
|
|
@@ -1270,8 +1383,8 @@ describe('getBlock', () => {
|
|
|
1270
1383
|
const gasUsed = '21000'
|
|
1271
1384
|
const gasPrice = '1000000000'
|
|
1272
1385
|
const l1Fee = '95394812830580'
|
|
1273
|
-
|
|
1274
|
-
|
|
1386
|
+
|
|
1387
|
+
mockGetBlockNodeApi(
|
|
1275
1388
|
mockNodeApi({
|
|
1276
1389
|
getBlockByHeight: jest
|
|
1277
1390
|
.fn()
|
|
@@ -1293,13 +1406,14 @@ describe('getBlock', () => {
|
|
|
1293
1406
|
|
|
1294
1407
|
function buildZksyncMocks(
|
|
1295
1408
|
txOverrides: Partial<PrefetchedBlockTransaction>,
|
|
1296
|
-
receiptOverrides: Partial<BlockReceiptInfo
|
|
1409
|
+
receiptOverrides: Partial<BlockReceiptInfo>,
|
|
1410
|
+
chainId: ChainId = CHAIN_ID.ZKSYNC
|
|
1297
1411
|
): EvmContext {
|
|
1298
1412
|
const context = createMockEvmContext(
|
|
1299
|
-
createMockEvmConfigInfo({ chainId
|
|
1413
|
+
createMockEvmConfigInfo({ chainId, node: mkExternalNode() })
|
|
1300
1414
|
)
|
|
1301
|
-
|
|
1302
|
-
|
|
1415
|
+
|
|
1416
|
+
mockGetBlockNodeApi(
|
|
1303
1417
|
mockNodeApi({
|
|
1304
1418
|
getBlockByHeight: jest
|
|
1305
1419
|
.fn()
|
|
@@ -1561,7 +1675,7 @@ describe('getBlock', () => {
|
|
|
1561
1675
|
])
|
|
1562
1676
|
})
|
|
1563
1677
|
|
|
1564
|
-
it('does not apply zkSync corrections to other
|
|
1678
|
+
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
1679
|
const context = buildZksyncMocks(
|
|
1566
1680
|
{ from: USER, to: USER, value: '270000000000000000' },
|
|
1567
1681
|
{
|
|
@@ -1574,9 +1688,10 @@ describe('getBlock', () => {
|
|
|
1574
1688
|
value: '270000000000000000',
|
|
1575
1689
|
},
|
|
1576
1690
|
],
|
|
1577
|
-
}
|
|
1691
|
+
},
|
|
1692
|
+
CHAIN_ID.ETHEREUM
|
|
1578
1693
|
)
|
|
1579
|
-
const result = await getBlock(context, '
|
|
1694
|
+
const result = await getBlock(context, 'zksync', 12345)
|
|
1580
1695
|
expect(result.transactions[0].operations).toEqual([
|
|
1581
1696
|
{
|
|
1582
1697
|
type: 'transfer',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
5
|
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
6
6
|
import { getNodeApi } from '../../network/node'
|
|
7
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
7
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
8
8
|
import { getBlockInfo } from '../getBlockInfo'
|
|
9
9
|
|
|
10
10
|
jest.mock('../../network/node', () => ({
|
|
@@ -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
|
})
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
5
|
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
6
6
|
import { getNodeApi } from '../../network/node'
|
|
7
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
7
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
8
8
|
import { getNextSequence } from '../getNextSequence'
|
|
9
9
|
|
|
10
10
|
jest.mock('../../network/node', () => ({
|
|
@@ -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
|
})
|