@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,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)
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
testLogger,
|
|
14
14
|
} from '../../fixtures/context.fixtures'
|
|
15
15
|
import { getInternalTransactionsByBlock } from '../../network/explorer/etherscan'
|
|
16
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
16
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
17
17
|
import { composeInternalTxsFetcher, makeSourceFetchers } from '../internalTransactionsFetcher'
|
|
18
18
|
|
|
19
19
|
jest.mock('../../network/explorer/etherscan', () => ({
|
|
@@ -176,7 +176,7 @@ describe('makeSourceFetchers', () => {
|
|
|
176
176
|
explorer: mkLedgerExplorer(),
|
|
177
177
|
})
|
|
178
178
|
|
|
179
|
-
const fetchers = makeSourceFetchers(config, mockNodeApi(),
|
|
179
|
+
const fetchers = makeSourceFetchers(config, mockNodeApi(), testLogger)
|
|
180
180
|
await expect(fetchers.explorer(1)).rejects.toBeInstanceOf(SourceUnavailableError)
|
|
181
181
|
})
|
|
182
182
|
|
|
@@ -184,7 +184,7 @@ describe('makeSourceFetchers', () => {
|
|
|
184
184
|
const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
185
185
|
|
|
186
186
|
const { traceBlockErigon: _traceBlockErigon, ...nodeApiWithoutErigon } = mockNodeApi()
|
|
187
|
-
const fetchers = makeSourceFetchers(config, nodeApiWithoutErigon,
|
|
187
|
+
const fetchers = makeSourceFetchers(config, nodeApiWithoutErigon, testLogger)
|
|
188
188
|
await expect(fetchers.trace_block(1)).rejects.toBeInstanceOf(SourceUnavailableError)
|
|
189
189
|
})
|
|
190
190
|
|
|
@@ -198,7 +198,7 @@ describe('makeSourceFetchers', () => {
|
|
|
198
198
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
199
199
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
200
200
|
|
|
201
|
-
const fetchers = makeSourceFetchers(config, mockNodeApi(),
|
|
201
|
+
const fetchers = makeSourceFetchers(config, mockNodeApi(), testLogger)
|
|
202
202
|
await expect(fetchers.explorer(99)).rejects.toBeInstanceOf(SourceUnavailableError)
|
|
203
203
|
})
|
|
204
204
|
|
|
@@ -212,7 +212,7 @@ describe('makeSourceFetchers', () => {
|
|
|
212
212
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
213
213
|
mockGetInternalTransactionsByBlock.mockResolvedValueOnce([])
|
|
214
214
|
|
|
215
|
-
const fetchers = makeSourceFetchers(config, mockNodeApi(),
|
|
215
|
+
const fetchers = makeSourceFetchers(config, mockNodeApi(), testLogger)
|
|
216
216
|
await fetchers.explorer(99)
|
|
217
217
|
|
|
218
218
|
expect(mockGetInternalTransactionsByBlock).toHaveBeenCalledWith(config, 99)
|
|
@@ -221,7 +221,7 @@ describe('makeSourceFetchers', () => {
|
|
|
221
221
|
it('empty always resolves to an empty map', async () => {
|
|
222
222
|
const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
223
223
|
|
|
224
|
-
const fetchers = makeSourceFetchers(config, mockNodeApi(),
|
|
224
|
+
const fetchers = makeSourceFetchers(config, mockNodeApi(), testLogger)
|
|
225
225
|
await expect(fetchers.empty(1)).resolves.toEqual(new Map<string, BlockOperation[]>())
|
|
226
226
|
})
|
|
227
227
|
})
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
} from '../../config'
|
|
10
10
|
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
11
11
|
import { getNodeApi } from '../../network/node'
|
|
12
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
12
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
13
13
|
import { lastBlock } from '../lastBlock'
|
|
14
14
|
|
|
15
15
|
jest.mock('../../network/node', () => ({
|
|
@@ -25,7 +25,7 @@ describe('lastBlock', () => {
|
|
|
25
25
|
|
|
26
26
|
beforeEach(() => {
|
|
27
27
|
jest.clearAllMocks()
|
|
28
|
-
mockGetNodeApi.mockImplementation((config: EvmConfigInfo
|
|
28
|
+
mockGetNodeApi.mockImplementation((config: EvmConfigInfo) => {
|
|
29
29
|
return config?.node?.type === 'ledger' ? ledgerMocks : externalMocks
|
|
30
30
|
})
|
|
31
31
|
})
|
|
@@ -64,7 +64,7 @@ describe('lastBlock', () => {
|
|
|
64
64
|
|
|
65
65
|
await lastBlock(context, '')
|
|
66
66
|
|
|
67
|
-
expect(nodeApiMock.getBlockByHeight).toHaveBeenCalledWith(
|
|
67
|
+
expect(nodeApiMock.getBlockByHeight).toHaveBeenCalledWith('latest')
|
|
68
68
|
})
|
|
69
69
|
|
|
70
70
|
it.each<
|
|
@@ -94,10 +94,7 @@ describe('lastBlock', () => {
|
|
|
94
94
|
nodeApiMock.getBlockByHeight.mockResolvedValue(blockResult)
|
|
95
95
|
|
|
96
96
|
expect(await lastBlock(context, '')).toEqual(expectedInfo)
|
|
97
|
-
expect(nodeApiMock.getBlockByHeight).toHaveBeenCalledWith(
|
|
98
|
-
expect.anything(),
|
|
99
|
-
finalizationLevel
|
|
100
|
-
)
|
|
97
|
+
expect(nodeApiMock.getBlockByHeight).toHaveBeenCalledWith(finalizationLevel)
|
|
101
98
|
}
|
|
102
99
|
)
|
|
103
100
|
})
|
|
@@ -568,7 +568,6 @@ describe('listOperations', () => {
|
|
|
568
568
|
[
|
|
569
569
|
expect.anything(),
|
|
570
570
|
testContext.logger,
|
|
571
|
-
currency,
|
|
572
571
|
address,
|
|
573
572
|
minHeight,
|
|
574
573
|
undefinedToBlock,
|
|
@@ -999,8 +998,8 @@ describe('listOperations', () => {
|
|
|
999
998
|
expect(tokenOp?.tx.block.hash).toBe(parentBlockHash)
|
|
1000
999
|
})
|
|
1001
1000
|
|
|
1002
|
-
it('inherits the parent nonce on token ops, whose fees-only native op is dropped', async () => {
|
|
1003
|
-
// LIVE-35844: the Ledger explorer only reports the nonce on the native op
|
|
1001
|
+
it('inherits the parent nonce and gas on token ops, whose fees-only native op is dropped', async () => {
|
|
1002
|
+
// LIVE-35844: the Ledger explorer only reports the nonce and gas on the native op
|
|
1004
1003
|
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1005
1004
|
|
|
1006
1005
|
const address = '0xb69b37a4fb4a18b3258f974ff6e9f529ad2647b1'
|
|
@@ -1018,7 +1017,7 @@ describe('listOperations', () => {
|
|
|
1018
1017
|
value: 0n,
|
|
1019
1018
|
asset: { type: 'native' as const },
|
|
1020
1019
|
tx: { ...tx, feesPayer: address },
|
|
1021
|
-
details: { sequence: 316 },
|
|
1020
|
+
details: { sequence: 316, gasPrice: '570000000', gasLimit: '73330' },
|
|
1022
1021
|
},
|
|
1023
1022
|
],
|
|
1024
1023
|
lastTokenOperations: [
|
|
@@ -1049,6 +1048,8 @@ describe('listOperations', () => {
|
|
|
1049
1048
|
|
|
1050
1049
|
// a cancel is a self transfer of 0, so the explorer reports both sides
|
|
1051
1050
|
expect(items.map((op) => op.details?.sequence)).toEqual([316, 316])
|
|
1051
|
+
expect(items.map((op) => op.details?.gasPrice)).toEqual(['570000000', '570000000'])
|
|
1052
|
+
expect(items.map((op) => op.details?.gasLimit)).toEqual(['73330', '73330'])
|
|
1052
1053
|
})
|
|
1053
1054
|
|
|
1054
1055
|
it('should emit both native and token operations when tx has native value > 0 and token transfers', async () => {
|
|
@@ -1208,9 +1209,9 @@ describe('listOperations', () => {
|
|
|
1208
1209
|
expect(result.length).toBeGreaterThan(1)
|
|
1209
1210
|
|
|
1210
1211
|
// check how the explorer is called
|
|
1211
|
-
const actualExplorerLimit = getOperationsSpy.mock.calls[0][
|
|
1212
|
+
const actualExplorerLimit = getOperationsSpy.mock.calls[0][6]
|
|
1212
1213
|
expect(actualExplorerLimit).toBe(limit)
|
|
1213
|
-
const actualExplorerOrder = getOperationsSpy.mock.calls[0][
|
|
1214
|
+
const actualExplorerOrder = getOperationsSpy.mock.calls[0][7]
|
|
1214
1215
|
expect(actualExplorerOrder).toBe(expectedExplorerOrder)
|
|
1215
1216
|
|
|
1216
1217
|
// check the result order
|
|
@@ -1562,7 +1563,7 @@ describe('listOperations', () => {
|
|
|
1562
1563
|
}
|
|
1563
1564
|
return jest
|
|
1564
1565
|
.spyOn(ledgerExplorer, 'getOperations')
|
|
1565
|
-
.mockImplementation(async (_config, _logger,
|
|
1566
|
+
.mockImplementation(async (_config, _logger, queriedAddress) => {
|
|
1566
1567
|
const coinOps: Array<Operation<MemoNotSupported>> = (
|
|
1567
1568
|
response.lastCoinOperations ?? []
|
|
1568
1569
|
).map((op, i) => ({
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from '@ledgerhq/coin-module-framework/errors'
|
|
18
18
|
import { createStakingTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
|
|
19
19
|
import BigNumber from 'bignumber.js'
|
|
20
|
+
import { CHAIN_ID } from '../../config'
|
|
20
21
|
import {
|
|
21
22
|
ClaimRewardsFeesWarning,
|
|
22
23
|
ETHAddressNonEIP,
|
|
@@ -41,7 +42,7 @@ import {
|
|
|
41
42
|
import ledgerExplorer from '../../network/explorer/ledger'
|
|
42
43
|
import ledgerGasTracker from '../../network/gasTracker/ledger'
|
|
43
44
|
import { getNodeApi } from '../../network/node'
|
|
44
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
45
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
45
46
|
import * as computeGasLimitModule from '../computeGasLimit'
|
|
46
47
|
import { validateIntent } from '../validateIntent'
|
|
47
48
|
|
|
@@ -747,6 +748,15 @@ describe('validateIntent', () => {
|
|
|
747
748
|
|
|
748
749
|
describe('useAllAmount on delegate', () => {
|
|
749
750
|
// sei_evm has delegationMaxAmountReserve = 10n**17n and calldataAmountScale = 10n**12n.
|
|
751
|
+
const seiContext = createMockEvmContext(
|
|
752
|
+
createMockEvmConfigInfo({
|
|
753
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
754
|
+
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
755
|
+
name: 'Sei',
|
|
756
|
+
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
757
|
+
gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
|
|
758
|
+
})
|
|
759
|
+
)
|
|
750
760
|
|
|
751
761
|
it('uses totalFees as the effective reserve when no reserve is configured for the chain', async () => {
|
|
752
762
|
// Unknown chain → configuredReserve = 0n, effectiveReserve = max(0n, totalFees) = totalFees.
|
|
@@ -778,7 +788,7 @@ describe('validateIntent', () => {
|
|
|
778
788
|
const balance = 10n ** 18n
|
|
779
789
|
const fees = 2n * 10n ** 17n // > configuredReserve
|
|
780
790
|
const res = await validateIntent(
|
|
781
|
-
|
|
791
|
+
seiContext,
|
|
782
792
|
'sei_evm',
|
|
783
793
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
784
794
|
type: 'staking-legacy',
|
|
@@ -806,7 +816,7 @@ describe('validateIntent', () => {
|
|
|
806
816
|
const balance = 10n ** 18n
|
|
807
817
|
const fees = 10n ** 14n // < configuredReserve
|
|
808
818
|
const res = await validateIntent(
|
|
809
|
-
|
|
819
|
+
seiContext,
|
|
810
820
|
'sei_evm',
|
|
811
821
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
812
822
|
type: 'staking-legacy',
|
|
@@ -1040,6 +1050,42 @@ describe('validateIntent', () => {
|
|
|
1040
1050
|
)
|
|
1041
1051
|
})
|
|
1042
1052
|
|
|
1053
|
+
it('renders the native unit and network name in NotEnoughGas for Alpen', async () => {
|
|
1054
|
+
const alpenContext = createMockEvmContext(
|
|
1055
|
+
createMockEvmConfigInfo({
|
|
1056
|
+
chainId: CHAIN_ID.ALPEN_TESTNET,
|
|
1057
|
+
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
1058
|
+
name: 'Alpen Testnet',
|
|
1059
|
+
unit: { name: 'BTC', code: 'BTC', magnitude: 18 },
|
|
1060
|
+
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
1061
|
+
gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
|
|
1062
|
+
})
|
|
1063
|
+
)
|
|
1064
|
+
|
|
1065
|
+
const res = await validateIntent(
|
|
1066
|
+
alpenContext,
|
|
1067
|
+
'alpen_testnet',
|
|
1068
|
+
createIntent({ recipient: 'recipient-address' }),
|
|
1069
|
+
[{ value: 10n, asset: { type: 'native' } }],
|
|
1070
|
+
{
|
|
1071
|
+
value: 11n,
|
|
1072
|
+
parameters: {
|
|
1073
|
+
gasLimit: 11n,
|
|
1074
|
+
gasPrice: 1n,
|
|
1075
|
+
maxFeePerGas: 1n,
|
|
1076
|
+
maxPriorityFeePerGas: 1n,
|
|
1077
|
+
},
|
|
1078
|
+
}
|
|
1079
|
+
)
|
|
1080
|
+
|
|
1081
|
+
expect(res.errors.gasPrice).toBeInstanceOf(NotEnoughGas)
|
|
1082
|
+
expect(res.errors.gasPrice).toMatchObject({
|
|
1083
|
+
ticker: 'BTC',
|
|
1084
|
+
cryptoName: 'Alpen Testnet',
|
|
1085
|
+
fees: expect.stringMatching(/\S/),
|
|
1086
|
+
})
|
|
1087
|
+
})
|
|
1088
|
+
|
|
1043
1089
|
it('includes additionalFees (L2 L1-data fee) when deciding NotEnoughGas', async () => {
|
|
1044
1090
|
// gas fee alone fits in the available balance, but the additionalFees
|
|
1045
1091
|
// (e.g. L1 data fee on L2s) push the total above the native balance.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '../config'
|
|
4
|
+
import type { ChainId, EvmConfigInfo } from '../config'
|
|
5
5
|
import type { EvmContext } from '../config'
|
|
6
6
|
import type { StakingOperation } from '../types'
|
|
7
7
|
import type {
|
|
@@ -122,7 +122,6 @@ function validateFeeRatio(
|
|
|
122
122
|
*/
|
|
123
123
|
async function validateNewAccountRecipient(
|
|
124
124
|
config: EvmConfigInfo,
|
|
125
|
-
currencyId: string,
|
|
126
125
|
intent: TransactionIntent<MemoNotSupported, BufferTxData>,
|
|
127
126
|
amount: bigint,
|
|
128
127
|
logger: Logger
|
|
@@ -136,10 +135,10 @@ async function validateNewAccountRecipient(
|
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
try {
|
|
139
|
-
const nodeApi = getNodeApi(config,
|
|
138
|
+
const nodeApi = getNodeApi(config, logger)
|
|
140
139
|
const [balance, nonce] = await Promise.all([
|
|
141
|
-
nodeApi.getCoinBalance(
|
|
142
|
-
nodeApi.getTransactionCount(
|
|
140
|
+
nodeApi.getCoinBalance(intent.recipient),
|
|
141
|
+
nodeApi.getTransactionCount(intent.recipient),
|
|
143
142
|
])
|
|
144
143
|
|
|
145
144
|
if (balance.isZero() && nonce === 0) {
|
|
@@ -389,7 +388,7 @@ function validateStaking(
|
|
|
389
388
|
}
|
|
390
389
|
|
|
391
390
|
function computeAmount(
|
|
392
|
-
|
|
391
|
+
chainId: ChainId,
|
|
393
392
|
intent: TransactionIntent,
|
|
394
393
|
estimatedFees: FeeEstimation,
|
|
395
394
|
balance: Balance
|
|
@@ -408,14 +407,14 @@ function computeAmount(
|
|
|
408
407
|
// - chains with a large per-chain reserve keep their existing behaviour,
|
|
409
408
|
// - unconfigured chains (reserve = 0n) fall back to the current fees,
|
|
410
409
|
// - high-fee selections never produce an amount the account cannot afford.
|
|
411
|
-
const configuredReserve = STAKING_CONTRACTS[
|
|
410
|
+
const configuredReserve = STAKING_CONTRACTS[chainId]?.delegationMaxAmountReserve ?? 0n
|
|
412
411
|
const effectiveReserve = configuredReserve > totalFees ? configuredReserve : totalFees
|
|
413
412
|
const rawAmount = available > effectiveReserve ? available - effectiveReserve : 0n
|
|
414
413
|
// Floor-round to the nearest minimum calldata unit for this chain's staking precompile.
|
|
415
414
|
// Chains like SEI require msg.value to be a whole multiple of their unit scale
|
|
416
415
|
// (e.g. 10^12 wei = 1 usei), otherwise the precompile reverts.
|
|
417
416
|
// For chains without a scale (calldataAmountScale = 1n), this is a no-op.
|
|
418
|
-
const scale = STAKING_CONTRACTS[
|
|
417
|
+
const scale = STAKING_CONTRACTS[chainId]?.calldataAmountScale ?? 1n
|
|
419
418
|
return (rawAmount / scale) * scale
|
|
420
419
|
}
|
|
421
420
|
const additionalFees =
|
|
@@ -466,7 +465,7 @@ export async function validateIntent(
|
|
|
466
465
|
? { ...customFees, value: refreshEstimationValue(intent, customFees.parameters) }
|
|
467
466
|
: await estimateFees(context, currencyId, intent)
|
|
468
467
|
const balance = findBalance(intent.asset, balances)
|
|
469
|
-
const amount = computeAmount(
|
|
468
|
+
const amount = computeAmount(config.chainId, intent, estimatedFees, balance)
|
|
470
469
|
const additionalFees =
|
|
471
470
|
typeof estimatedFees.parameters?.additionalFees === 'bigint'
|
|
472
471
|
? estimatedFees.parameters.additionalFees
|
|
@@ -505,7 +504,6 @@ export async function validateIntent(
|
|
|
505
504
|
)
|
|
506
505
|
const { errors: newAccountErr, warnings: newAccountWarn } = await validateNewAccountRecipient(
|
|
507
506
|
config,
|
|
508
|
-
currencyId,
|
|
509
507
|
intent,
|
|
510
508
|
amount,
|
|
511
509
|
context.logger
|
package/src/logic.test.ts
CHANGED
|
@@ -8,11 +8,12 @@ jest.mock('./network/node/index', () => ({
|
|
|
8
8
|
),
|
|
9
9
|
}))
|
|
10
10
|
|
|
11
|
+
import { CHAIN_ID } from './config'
|
|
11
12
|
import { createMockEvmConfigInfo, mkExternalNode, testLogger } from './fixtures/context.fixtures'
|
|
12
13
|
import { getAdditionalLayer2Fees } from './logic'
|
|
13
14
|
import { padHexString, safeEncodeEIP55 } from './logic-public'
|
|
14
15
|
import { getNodeApi } from './network/node/index'
|
|
15
|
-
import { mockNodeApi } from './network/node/node.fixtures'
|
|
16
|
+
import { mockNodeApi } from './network/tests/node/node.fixtures'
|
|
16
17
|
|
|
17
18
|
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
18
19
|
const nodeApiMock = mockNodeApi()
|
|
@@ -30,16 +31,23 @@ describe('EVM Family', () => {
|
|
|
30
31
|
})
|
|
31
32
|
|
|
32
33
|
it('should try to get additionalFees for a valid layer 2', async () => {
|
|
33
|
-
const
|
|
34
|
-
|
|
34
|
+
const optimismCfg = createMockEvmConfigInfo({
|
|
35
|
+
chainId: CHAIN_ID.OPTIMISM,
|
|
36
|
+
node: mkExternalNode(),
|
|
37
|
+
})
|
|
38
|
+
await getAdditionalLayer2Fees(optimismCfg, '', testLogger)
|
|
35
39
|
expect(mockGetOptimismAdditionalFees).toHaveBeenCalled()
|
|
36
|
-
|
|
40
|
+
const scrollCfg = createMockEvmConfigInfo({
|
|
41
|
+
chainId: CHAIN_ID.SCROLL,
|
|
42
|
+
node: mkExternalNode(),
|
|
43
|
+
})
|
|
44
|
+
await getAdditionalLayer2Fees(scrollCfg, '', testLogger)
|
|
37
45
|
expect(mockGetScrollAdditionalFees).toHaveBeenCalled()
|
|
38
46
|
})
|
|
39
47
|
|
|
40
48
|
it('should not try to get additionalFees for an invalid layer 2', async () => {
|
|
41
49
|
const cfg = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
42
|
-
await getAdditionalLayer2Fees(cfg, '
|
|
50
|
+
await getAdditionalLayer2Fees(cfg, '', testLogger)
|
|
43
51
|
expect(mockGetOptimismAdditionalFees).not.toHaveBeenCalled()
|
|
44
52
|
expect(mockGetScrollAdditionalFees).not.toHaveBeenCalled()
|
|
45
53
|
})
|
package/src/logic.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from './config'
|
|
5
5
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
6
6
|
import type BigNumber from 'bignumber.js'
|
|
7
|
+
import { CHAIN_ID } from './config'
|
|
7
8
|
import { getNodeApi } from './network/node/index'
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -12,24 +13,23 @@ import { getNodeApi } from './network/node/index'
|
|
|
12
13
|
*/
|
|
13
14
|
export const getAdditionalLayer2Fees = async (
|
|
14
15
|
config: EvmConfigInfo,
|
|
15
|
-
currencyId: string,
|
|
16
16
|
transaction: string,
|
|
17
17
|
logger: Logger
|
|
18
18
|
): Promise<BigNumber | undefined> => {
|
|
19
|
-
switch (
|
|
20
|
-
case
|
|
21
|
-
case
|
|
22
|
-
case
|
|
23
|
-
case
|
|
24
|
-
case
|
|
25
|
-
case
|
|
26
|
-
const nodeApi = getNodeApi(config,
|
|
27
|
-
const additionalFees = await nodeApi.getOptimismAdditionalFees(
|
|
19
|
+
switch (config.chainId) {
|
|
20
|
+
case CHAIN_ID.OPTIMISM:
|
|
21
|
+
case CHAIN_ID.OPTIMISM_SEPOLIA:
|
|
22
|
+
case CHAIN_ID.BLAST:
|
|
23
|
+
case CHAIN_ID.BLAST_SEPOLIA:
|
|
24
|
+
case CHAIN_ID.BASE:
|
|
25
|
+
case CHAIN_ID.BASE_SEPOLIA: {
|
|
26
|
+
const nodeApi = getNodeApi(config, logger)
|
|
27
|
+
const additionalFees = await nodeApi.getOptimismAdditionalFees(transaction)
|
|
28
28
|
return additionalFees
|
|
29
29
|
}
|
|
30
|
-
case
|
|
31
|
-
const nodeApi = getNodeApi(config,
|
|
32
|
-
const additionalFees = await nodeApi.getScrollAdditionalFees(
|
|
30
|
+
case CHAIN_ID.SCROLL: {
|
|
31
|
+
const nodeApi = getNodeApi(config, logger)
|
|
32
|
+
const additionalFees = await nodeApi.getScrollAdditionalFees(transaction)
|
|
33
33
|
return additionalFees
|
|
34
34
|
}
|
|
35
35
|
default:
|
|
@@ -71,7 +71,6 @@ function getMaxBoundaryExhaustionPages(config: EvmConfigInfo): number {
|
|
|
71
71
|
* Common parameters for fetching operations from an endpoint
|
|
72
72
|
*/
|
|
73
73
|
export type FetchOperationsParams = {
|
|
74
|
-
currencyId: string
|
|
75
74
|
config: EvmConfigInfo
|
|
76
75
|
// Instance-scoped logger threaded from the caller's context (set by `getOperations`).
|
|
77
76
|
logger: Logger
|
|
@@ -308,7 +307,7 @@ export const getCoinOperations = async (params: FetchOperationsParams): Promise<
|
|
|
308
307
|
const ops = Array.isArray(raw) ? raw : []
|
|
309
308
|
|
|
310
309
|
const operations = ops.flatMap((tx) =>
|
|
311
|
-
etherscanOperationToOperations(params.address, params.
|
|
310
|
+
etherscanOperationToOperations(params.address, params.config.chainId, tx, params.logger)
|
|
312
311
|
)
|
|
313
312
|
|
|
314
313
|
// Recover REWARD op amounts (claim/compound) from receipt logs — these txs send 0 native
|
|
@@ -321,10 +320,9 @@ export const getCoinOperations = async (params: FetchOperationsParams): Promise<
|
|
|
321
320
|
try {
|
|
322
321
|
await withApi(
|
|
323
322
|
params.config,
|
|
324
|
-
params.currencyId,
|
|
325
323
|
(api) =>
|
|
326
324
|
enrichRewardOperationsValue(
|
|
327
|
-
params.
|
|
325
|
+
params.config.chainId,
|
|
328
326
|
operations,
|
|
329
327
|
(hash) => api.getTransactionReceipt(hash),
|
|
330
328
|
params.logger
|
|
@@ -783,7 +781,6 @@ export const getOperations = makeLRUCache<
|
|
|
783
781
|
[
|
|
784
782
|
config: EvmConfigInfo,
|
|
785
783
|
logger: Logger,
|
|
786
|
-
currencyId: string,
|
|
787
784
|
address: string,
|
|
788
785
|
fromBlock: number,
|
|
789
786
|
toBlock: number | undefined,
|
|
@@ -799,17 +796,7 @@ export const getOperations = makeLRUCache<
|
|
|
799
796
|
nextPagingToken: string
|
|
800
797
|
}
|
|
801
798
|
>(
|
|
802
|
-
async (
|
|
803
|
-
config,
|
|
804
|
-
logger,
|
|
805
|
-
currencyId,
|
|
806
|
-
address,
|
|
807
|
-
fromBlock,
|
|
808
|
-
toBlock,
|
|
809
|
-
pagingToken,
|
|
810
|
-
limit,
|
|
811
|
-
order = 'desc'
|
|
812
|
-
) => {
|
|
799
|
+
async (config, logger, address, fromBlock, toBlock, pagingToken, limit, order = 'desc') => {
|
|
813
800
|
try {
|
|
814
801
|
const configuredMaxLimit = getConfiguredMaxLimit(config)
|
|
815
802
|
const effectiveLimit =
|
|
@@ -823,7 +810,6 @@ export const getOperations = makeLRUCache<
|
|
|
823
810
|
const cmp = createBlockComparator(order)
|
|
824
811
|
|
|
825
812
|
const baseParams: FetchOperationsParams = {
|
|
826
|
-
currencyId,
|
|
827
813
|
config,
|
|
828
814
|
address,
|
|
829
815
|
fromBlock,
|
|
@@ -967,8 +953,8 @@ export const getOperations = makeLRUCache<
|
|
|
967
953
|
)
|
|
968
954
|
}
|
|
969
955
|
},
|
|
970
|
-
(
|
|
971
|
-
`${
|
|
956
|
+
(config, _logger, address, fromBlock, toBlock, pagingToken, limit, order) =>
|
|
957
|
+
`${config.chainId}:${address}:${fromBlock}:${toBlock ?? ''}:${pagingToken ?? ''}:${limit ?? ''}:${order ?? 'desc'}`,
|
|
972
958
|
{ ttl: ETHERSCAN_TIMEOUT }
|
|
973
959
|
)
|
|
974
960
|
|
|
@@ -983,12 +969,11 @@ export const getOperations = makeLRUCache<
|
|
|
983
969
|
* and NFT endpoints, which this arm never needed to discover tokens.
|
|
984
970
|
*/
|
|
985
971
|
export const discoverTokenAssets = makeLRUCache<
|
|
986
|
-
[config: EvmConfigInfo, logger: Logger,
|
|
972
|
+
[config: EvmConfigInfo, logger: Logger, address: string, fromBlock?: number],
|
|
987
973
|
AssetInfo[]
|
|
988
974
|
>(
|
|
989
|
-
async (config, logger,
|
|
975
|
+
async (config, logger, address, fromBlock = 0) => {
|
|
990
976
|
const { operations } = await getTokenOperations({
|
|
991
|
-
currencyId,
|
|
992
977
|
config,
|
|
993
978
|
address,
|
|
994
979
|
fromBlock,
|
|
@@ -1004,8 +989,7 @@ export const discoverTokenAssets = makeLRUCache<
|
|
|
1004
989
|
|
|
1005
990
|
return Array.from(assets.values())
|
|
1006
991
|
},
|
|
1007
|
-
(
|
|
1008
|
-
`${currencyId}:${address}:${fromBlock ?? 0}`,
|
|
992
|
+
(config, _logger, address, fromBlock) => `${config.chainId}:${address}:${fromBlock ?? 0}`,
|
|
1009
993
|
{ ttl: ETHERSCAN_TIMEOUT }
|
|
1010
994
|
)
|
|
1011
995
|
|