@ledgerhq/coin-evm 10.1.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/CHANGELOG.md +42 -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 +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.js +1 -1
- 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/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 +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 +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 +1 -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.js +12 -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 +31 -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 +50 -39
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +15 -15
- 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 +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.js +1 -1
- 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/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 +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 +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 +1 -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.js +12 -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 +31 -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 +50 -39
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +15 -15
- 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 +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 +1 -1
- 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/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 +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 +6 -8
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +0 -1
- 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 +12 -2
- 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 +23 -131
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +0 -2
- package/src/network/node/explorerProxy.test.ts +17 -22
- package/src/network/node/explorerProxy.ts +12 -12
- 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 +31 -34
- package/src/network/node/rpc.common.ts +58 -86
- package/src/network/node/rpc.test.ts +86 -114
- package/src/network/node/types.ts +11 -29
- package/src/network/node/withNodeSources.test.ts +7 -9
- package/src/network/node/withNodeSources.ts +23 -26
- 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
|
@@ -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
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { CHAIN_ID } from '../../config'
|
|
4
5
|
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
5
6
|
import { mkJsonRpcProvider, mkResult } from '../../fixtures/ethers.fixtures'
|
|
6
7
|
import { withApi } from '../../network/node/rpc.common'
|
|
@@ -35,10 +36,21 @@ const mockFetchUnbondings = jest.mocked(fetchUnbondings)
|
|
|
35
36
|
|
|
36
37
|
const externalNodeConfig = { type: 'external' as const, uri: 'https://test' }
|
|
37
38
|
const context = createMockEvmContext({
|
|
39
|
+
chainId: CHAIN_ID.CELO,
|
|
38
40
|
node: externalNodeConfig,
|
|
39
41
|
name: 'Celo',
|
|
40
42
|
unit: { name: 'CELO', code: 'CELO', magnitude: 18 },
|
|
41
43
|
})
|
|
44
|
+
const seiContext = createMockEvmContext({
|
|
45
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
46
|
+
node: externalNodeConfig,
|
|
47
|
+
name: 'Sei',
|
|
48
|
+
unit: { name: 'SEI', code: 'SEI', magnitude: 18 },
|
|
49
|
+
})
|
|
50
|
+
const ethereumContext = createMockEvmContext({
|
|
51
|
+
chainId: CHAIN_ID.ETHEREUM,
|
|
52
|
+
node: externalNodeConfig,
|
|
53
|
+
})
|
|
42
54
|
const makeValidator = (validatorAddress: string) => ({
|
|
43
55
|
id: validatorAddress,
|
|
44
56
|
address: validatorAddress,
|
|
@@ -55,7 +67,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
55
67
|
})
|
|
56
68
|
|
|
57
69
|
it('should return stake objects with positive amounts for supported currencies', async () => {
|
|
58
|
-
mockWithApi.mockImplementation(async (_cur,
|
|
70
|
+
mockWithApi.mockImplementation(async (_cur, fn) => {
|
|
59
71
|
const api = mkJsonRpcProvider()
|
|
60
72
|
jest.spyOn(api, 'call').mockResolvedValue('0x')
|
|
61
73
|
return fn(api)
|
|
@@ -88,7 +100,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
88
100
|
})
|
|
89
101
|
|
|
90
102
|
it('should filter out stakes with zero amounts', async () => {
|
|
91
|
-
mockWithApi.mockImplementation(async (_cur,
|
|
103
|
+
mockWithApi.mockImplementation(async (_cur, fn) => {
|
|
92
104
|
const api = mkJsonRpcProvider()
|
|
93
105
|
jest.spyOn(api, 'call').mockResolvedValue('0x')
|
|
94
106
|
return fn(api)
|
|
@@ -109,7 +121,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
109
121
|
next: undefined,
|
|
110
122
|
})
|
|
111
123
|
|
|
112
|
-
mockWithApi.mockImplementation(async (_cur,
|
|
124
|
+
mockWithApi.mockImplementation(async (_cur, fn) => {
|
|
113
125
|
const api = mkJsonRpcProvider()
|
|
114
126
|
jest.spyOn(api, 'call').mockResolvedValue('0x')
|
|
115
127
|
return fn(api)
|
|
@@ -130,7 +142,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
130
142
|
})
|
|
131
143
|
)
|
|
132
144
|
|
|
133
|
-
const result = await getStakes(
|
|
145
|
+
const result = await getStakes(seiContext, 'sei_evm', address)
|
|
134
146
|
|
|
135
147
|
expect(result).toEqual({
|
|
136
148
|
items: [
|
|
@@ -149,7 +161,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
149
161
|
})
|
|
150
162
|
|
|
151
163
|
it('should return empty list for currencies not configured for staking', async () => {
|
|
152
|
-
const result = await getStakes(
|
|
164
|
+
const result = await getStakes(ethereumContext, 'ethereum', address)
|
|
153
165
|
|
|
154
166
|
expect(result).toEqual({
|
|
155
167
|
items: [],
|
|
@@ -157,7 +169,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
157
169
|
})
|
|
158
170
|
|
|
159
171
|
it('should handle RPC call failures gracefully without crashing', async () => {
|
|
160
|
-
mockWithApi.mockImplementation(async (_cur,
|
|
172
|
+
mockWithApi.mockImplementation(async (_cur, fn) => {
|
|
161
173
|
const api = mkJsonRpcProvider()
|
|
162
174
|
jest.spyOn(api, 'call').mockRejectedValue(new Error('rpc error'))
|
|
163
175
|
return fn(api)
|
|
@@ -176,7 +188,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
176
188
|
items: [makeValidator('seivaloper1abc')],
|
|
177
189
|
next: undefined,
|
|
178
190
|
})
|
|
179
|
-
mockWithApi.mockImplementation(async (_cur,
|
|
191
|
+
mockWithApi.mockImplementation(async (_cur, fn) => {
|
|
180
192
|
const api = mkJsonRpcProvider()
|
|
181
193
|
jest.spyOn(api, 'call').mockRejectedValue(
|
|
182
194
|
Object.assign(new Error('missing revert data'), {
|
|
@@ -191,7 +203,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
191
203
|
})
|
|
192
204
|
mockEncodeStakingData.mockReturnValue('0xdeadbeef')
|
|
193
205
|
|
|
194
|
-
const result = await getStakes(
|
|
206
|
+
const result = await getStakes(seiContext, 'sei_evm', address)
|
|
195
207
|
|
|
196
208
|
expect(result).toEqual({
|
|
197
209
|
items: [],
|
|
@@ -202,7 +214,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
202
214
|
it('should handle SEI when no validators are available', async () => {
|
|
203
215
|
mockGetValidators.mockResolvedValue({ items: [], next: undefined })
|
|
204
216
|
|
|
205
|
-
const result = await getStakes(
|
|
217
|
+
const result = await getStakes(seiContext, 'sei_evm', address)
|
|
206
218
|
|
|
207
219
|
expect(result).toEqual({
|
|
208
220
|
items: [],
|
|
@@ -212,7 +224,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
212
224
|
it('should survive network failures during validator fetching', async () => {
|
|
213
225
|
mockGetValidators.mockRejectedValue(new Error('Network unreachable'))
|
|
214
226
|
|
|
215
|
-
const result = await getStakes(
|
|
227
|
+
const result = await getStakes(seiContext, 'sei_evm', address)
|
|
216
228
|
|
|
217
229
|
expect(result).toEqual({
|
|
218
230
|
items: [],
|
|
@@ -220,7 +232,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
220
232
|
})
|
|
221
233
|
|
|
222
234
|
it('should handle completely unsupported currencies', async () => {
|
|
223
|
-
const result = await getStakes(
|
|
235
|
+
const result = await getStakes(ethereumContext, 'unsupported_currency', address)
|
|
224
236
|
|
|
225
237
|
expect(result).toEqual({
|
|
226
238
|
items: [],
|
|
@@ -260,7 +272,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
260
272
|
items: [makeValidator('seivaloper1abc')],
|
|
261
273
|
next: undefined,
|
|
262
274
|
})
|
|
263
|
-
mockWithApi.mockImplementation(async (_cur,
|
|
275
|
+
mockWithApi.mockImplementation(async (_cur, fn) => {
|
|
264
276
|
const api = mkJsonRpcProvider()
|
|
265
277
|
jest.spyOn(api, 'call').mockResolvedValue('0x')
|
|
266
278
|
return fn(api)
|
|
@@ -278,7 +290,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
278
290
|
mockOneDelegation()
|
|
279
291
|
mockFetchUnbondings.mockResolvedValue([unbondingStake])
|
|
280
292
|
|
|
281
|
-
const result = await getStakes(
|
|
293
|
+
const result = await getStakes(seiContext, 'sei_evm', address)
|
|
282
294
|
|
|
283
295
|
expect(result.items.map((i) => i.state)).toEqual(['active', 'deactivating'])
|
|
284
296
|
})
|
|
@@ -287,7 +299,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
287
299
|
mockGetValidators.mockResolvedValue({ items: [], next: undefined })
|
|
288
300
|
mockFetchUnbondings.mockResolvedValue([unbondingStake])
|
|
289
301
|
|
|
290
|
-
const result = await getStakes(
|
|
302
|
+
const result = await getStakes(seiContext, 'sei_evm', address)
|
|
291
303
|
|
|
292
304
|
expect(result.items).toEqual([unbondingStake])
|
|
293
305
|
})
|
|
@@ -296,13 +308,13 @@ describe('EVM Staking - getStakes', () => {
|
|
|
296
308
|
mockOneDelegation()
|
|
297
309
|
mockFetchUnbondings.mockRejectedValue(new Error('REST down'))
|
|
298
310
|
|
|
299
|
-
const result = await getStakes(
|
|
311
|
+
const result = await getStakes(seiContext, 'sei_evm', address)
|
|
300
312
|
|
|
301
313
|
expect(result.items.map((i) => i.state)).toEqual(['active'])
|
|
302
314
|
})
|
|
303
315
|
|
|
304
316
|
it('should not be attempted for a chain without an unbonding strategy', async () => {
|
|
305
|
-
mockWithApi.mockImplementation(async (_cur,
|
|
317
|
+
mockWithApi.mockImplementation(async (_cur, fn) => {
|
|
306
318
|
const api = mkJsonRpcProvider()
|
|
307
319
|
jest.spyOn(api, 'call').mockResolvedValue('0x')
|
|
308
320
|
return fn(api)
|