@ledgerhq/coin-evm 10.0.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oxlintrc.json +2 -6
- package/CHANGELOG.md +54 -0
- package/docs/getBlock-internal-txs-schema.md +2 -2
- package/docs/network/node/index.md +1 -1
- package/lib/abis/index.d.ts +8 -0
- package/lib/abis/index.d.ts.map +1 -1
- package/lib/abis/index.js +30 -0
- package/lib/abis/index.js.map +1 -1
- package/lib/adapters/blockOperations.js +2 -2
- package/lib/adapters/blockOperations.js.map +1 -1
- package/lib/adapters/etherscan.d.ts +2 -1
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +2 -2
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts +2 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +2 -2
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +3 -2
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +94 -0
- package/lib/chains.d.ts.map +1 -0
- package/lib/chains.js +98 -0
- package/lib/chains.js.map +1 -0
- package/lib/config.d.ts +4 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -1
- package/lib/config.js.map +1 -1
- package/lib/internalTxSources.d.ts.map +1 -1
- package/lib/internalTxSources.js +21 -3
- package/lib/internalTxSources.js.map +1 -1
- package/lib/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/common.d.ts +1 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +22 -14
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +7 -4
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +11 -8
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +9 -9
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +17 -17
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -2
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +1 -1
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +10 -10
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js +9 -9
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +1 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/predicates.d.ts +17 -0
- package/lib/logic/predicates.d.ts.map +1 -0
- package/lib/logic/predicates.js +126 -0
- package/lib/logic/predicates.js.map +1 -0
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +9 -9
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +14 -13
- package/lib/logic.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +2 -3
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +6 -8
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +5 -5
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/types.d.ts +2 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js +11 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib/network/gasTracker/ledger.js +1 -3
- package/lib/network/gasTracker/ledger.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +22 -17
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/gethCallTracerToTraceBlockItems.d.ts.map +1 -1
- package/lib/network/node/gethCallTracerToTraceBlockItems.js +10 -12
- package/lib/network/node/gethCallTracerToTraceBlockItems.js.map +1 -1
- package/lib/network/node/index.d.ts +1 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +7 -7
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.d.ts +3 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +38 -24
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +104 -103
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +21 -22
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js +0 -27
- package/lib/network/node/types.js.map +1 -1
- package/lib/network/node/withNodeSources.d.ts.map +1 -1
- package/lib/network/node/withNodeSources.js +15 -15
- package/lib/network/node/withNodeSources.js.map +1 -1
- package/lib/nodeSources.d.ts.map +1 -1
- package/lib/nodeSources.js +11 -3
- package/lib/nodeSources.js.map +1 -1
- package/lib/staking/abis.d.ts +3 -2
- package/lib/staking/abis.d.ts.map +1 -1
- package/lib/staking/abis.js +10 -9
- package/lib/staking/abis.js.map +1 -1
- package/lib/staking/contracts.d.ts +3 -2
- package/lib/staking/contracts.d.ts.map +1 -1
- package/lib/staking/contracts.js +12 -13
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/detectOperationType.d.ts +2 -4
- package/lib/staking/detectOperationType.d.ts.map +1 -1
- package/lib/staking/detectOperationType.js +22 -21
- package/lib/staking/detectOperationType.js.map +1 -1
- package/lib/staking/encoder.d.ts +2 -1
- package/lib/staking/encoder.d.ts.map +1 -1
- package/lib/staking/encoder.js +8 -8
- package/lib/staking/encoder.js.map +1 -1
- package/lib/staking/fetchers.d.ts +2 -1
- package/lib/staking/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +27 -27
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/logic.d.ts +6 -6
- package/lib/staking/logic.d.ts.map +1 -1
- package/lib/staking/logic.js +14 -13
- package/lib/staking/logic.js.map +1 -1
- package/lib/staking/operations/index.d.ts +2 -1
- package/lib/staking/operations/index.d.ts.map +1 -1
- package/lib/staking/operations/index.js +39 -20
- package/lib/staking/operations/index.js.map +1 -1
- package/lib/staking/prepareIntents.d.ts +1 -1
- package/lib/staking/prepareIntents.d.ts.map +1 -1
- package/lib/staking/prepareIntents.js +14 -12
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/redelegations.d.ts +4 -4
- package/lib/staking/redelegations.d.ts.map +1 -1
- package/lib/staking/redelegations.js +22 -27
- package/lib/staking/redelegations.js.map +1 -1
- package/lib/staking/rewards.d.ts +1 -1
- package/lib/staking/rewards.d.ts.map +1 -1
- package/lib/staking/rewards.js +2 -2
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib/staking/rewardsFromReceipt.js +2 -2
- package/lib/staking/rewardsFromReceipt.js.map +1 -1
- package/lib/staking/transactionData.d.ts +2 -1
- package/lib/staking/transactionData.d.ts.map +1 -1
- package/lib/staking/transactionData.js +6 -6
- package/lib/staking/transactionData.js.map +1 -1
- package/lib/staking/unbondings.d.ts +1 -1
- package/lib/staking/unbondings.d.ts.map +1 -1
- package/lib/staking/unbondings.js +2 -2
- package/lib/staking/unbondings.js.map +1 -1
- package/lib/staking/utils.d.ts.map +1 -1
- package/lib/staking/utils.js +22 -27
- package/lib/staking/utils.js.map +1 -1
- package/lib/staking/validators/index.d.ts +14 -14
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +39 -38
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +5 -5
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +44 -37
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +1 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js +7 -6
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/sei.js +2 -2
- package/lib/staking/validators/sei.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts +4 -4
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js +25 -24
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/types.d.ts +1 -1
- package/lib/staking/validators/types.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts +1 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js +10 -9
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/staking.d.ts +5 -6
- package/lib/types/staking.d.ts.map +1 -1
- package/lib-es/abis/index.d.ts +8 -0
- package/lib-es/abis/index.d.ts.map +1 -1
- package/lib-es/abis/index.js +29 -0
- package/lib-es/abis/index.js.map +1 -1
- package/lib-es/adapters/blockOperations.js +1 -1
- package/lib-es/adapters/blockOperations.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts +2 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +2 -2
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts +2 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +2 -2
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +3 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +94 -0
- package/lib-es/chains.d.ts.map +1 -0
- package/lib-es/chains.js +95 -0
- package/lib-es/chains.js.map +1 -0
- package/lib-es/config.d.ts +4 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -0
- package/lib-es/config.js.map +1 -1
- package/lib-es/internalTxSources.d.ts.map +1 -1
- package/lib-es/internalTxSources.js +21 -3
- package/lib-es/internalTxSources.js.map +1 -1
- package/lib-es/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/common.d.ts +1 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +22 -14
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +7 -4
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +11 -8
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +9 -9
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +18 -18
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.js +2 -2
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +1 -1
- package/lib-es/logic/getNextSequence.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +10 -10
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js +9 -9
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +1 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/predicates.d.ts +17 -0
- package/lib-es/logic/predicates.d.ts.map +1 -0
- package/lib-es/logic/predicates.js +114 -0
- package/lib-es/logic/predicates.js.map +1 -0
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +9 -9
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +14 -13
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +2 -3
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +6 -8
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +5 -5
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +2 -2
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js +11 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib-es/network/gasTracker/ledger.js +1 -3
- package/lib-es/network/gasTracker/ledger.js.map +1 -1
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +22 -17
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.d.ts.map +1 -1
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.js +4 -6
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.js.map +1 -1
- package/lib-es/network/node/index.d.ts +1 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +7 -7
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts +3 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +38 -24
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +102 -101
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +21 -22
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js +0 -25
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
- package/lib-es/network/node/withNodeSources.js +15 -15
- package/lib-es/network/node/withNodeSources.js.map +1 -1
- package/lib-es/nodeSources.d.ts.map +1 -1
- package/lib-es/nodeSources.js +11 -3
- package/lib-es/nodeSources.js.map +1 -1
- package/lib-es/staking/abis.d.ts +3 -2
- package/lib-es/staking/abis.d.ts.map +1 -1
- package/lib-es/staking/abis.js +10 -9
- package/lib-es/staking/abis.js.map +1 -1
- package/lib-es/staking/contracts.d.ts +3 -2
- package/lib-es/staking/contracts.d.ts.map +1 -1
- package/lib-es/staking/contracts.js +12 -13
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/detectOperationType.d.ts +2 -4
- package/lib-es/staking/detectOperationType.d.ts.map +1 -1
- package/lib-es/staking/detectOperationType.js +22 -21
- package/lib-es/staking/detectOperationType.js.map +1 -1
- package/lib-es/staking/encoder.d.ts +2 -1
- package/lib-es/staking/encoder.d.ts.map +1 -1
- package/lib-es/staking/encoder.js +8 -8
- package/lib-es/staking/encoder.js.map +1 -1
- package/lib-es/staking/fetchers.d.ts +2 -1
- package/lib-es/staking/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +27 -27
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/logic.d.ts +6 -6
- package/lib-es/staking/logic.d.ts.map +1 -1
- package/lib-es/staking/logic.js +14 -13
- package/lib-es/staking/logic.js.map +1 -1
- package/lib-es/staking/operations/index.d.ts +2 -1
- package/lib-es/staking/operations/index.d.ts.map +1 -1
- package/lib-es/staking/operations/index.js +39 -20
- package/lib-es/staking/operations/index.js.map +1 -1
- package/lib-es/staking/prepareIntents.d.ts +1 -1
- package/lib-es/staking/prepareIntents.d.ts.map +1 -1
- package/lib-es/staking/prepareIntents.js +13 -11
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/redelegations.d.ts +4 -4
- package/lib-es/staking/redelegations.d.ts.map +1 -1
- package/lib-es/staking/redelegations.js +19 -24
- package/lib-es/staking/redelegations.js.map +1 -1
- package/lib-es/staking/rewards.d.ts +1 -1
- package/lib-es/staking/rewards.d.ts.map +1 -1
- package/lib-es/staking/rewards.js +2 -2
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.js +2 -2
- package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
- package/lib-es/staking/transactionData.d.ts +2 -1
- package/lib-es/staking/transactionData.d.ts.map +1 -1
- package/lib-es/staking/transactionData.js +6 -6
- package/lib-es/staking/transactionData.js.map +1 -1
- package/lib-es/staking/unbondings.d.ts +1 -1
- package/lib-es/staking/unbondings.d.ts.map +1 -1
- package/lib-es/staking/unbondings.js +2 -2
- package/lib-es/staking/unbondings.js.map +1 -1
- package/lib-es/staking/utils.d.ts.map +1 -1
- package/lib-es/staking/utils.js +20 -25
- package/lib-es/staking/utils.js.map +1 -1
- package/lib-es/staking/validators/index.d.ts +14 -14
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +39 -38
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +5 -5
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +43 -36
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +6 -5
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/sei.js +2 -2
- package/lib-es/staking/validators/sei.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts +4 -4
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js +24 -23
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/types.d.ts +1 -1
- package/lib-es/staking/validators/types.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js +9 -8
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/staking.d.ts +5 -6
- package/lib-es/types/staking.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/abis/index.test.ts +36 -0
- package/src/abis/index.ts +30 -0
- package/src/adapters/blockOperations.ts +1 -1
- package/src/adapters/etherscan.test.ts +34 -38
- package/src/adapters/etherscan.ts +3 -2
- package/src/adapters/ledger.test.ts +49 -22
- package/src/adapters/ledger.ts +3 -2
- package/src/api/getBlock.integ.test.ts +2 -1
- package/src/api/index.monad_testnet.integ.test.ts +2 -2
- package/src/api/index.ts +4 -3
- package/src/chains.test.ts +12 -0
- package/src/chains.ts +97 -0
- package/src/config.ts +5 -1
- package/src/fixtures/staking.fixtures.ts +13 -0
- package/src/internalTxSources.ts +20 -3
- package/src/logic/broadcast.ts +2 -2
- package/src/logic/common.ts +23 -14
- package/src/logic/craftTransaction.ts +6 -5
- package/src/logic/estimateFees.ts +10 -25
- package/src/logic/getBalance.ts +7 -13
- package/src/logic/getBlock.ts +22 -19
- package/src/logic/getBlockInfo.ts +2 -2
- package/src/logic/getNextSequence.ts +1 -4
- package/src/logic/getStakes.ts +11 -12
- package/src/logic/internalTransactionsFetcher.ts +7 -9
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +0 -1
- package/src/logic/predicates.ts +124 -0
- package/src/logic/tests/broadcast.test.ts +4 -4
- package/src/logic/tests/broadcastSource.test.ts +0 -3
- package/src/logic/tests/common.test.ts +17 -33
- package/src/logic/tests/craftTransaction.test.ts +13 -6
- package/src/logic/tests/estimateFees.test.ts +16 -7
- package/src/logic/tests/getBalance.test.ts +17 -33
- package/src/logic/tests/getBlock.test.ts +69 -75
- package/src/logic/tests/getBlockInfo.test.ts +1 -1
- package/src/logic/tests/getNextSequence.test.ts +1 -1
- package/src/logic/tests/getStakes.test.ts +28 -16
- package/src/logic/tests/internalTransactionsFetcher.test.ts +5 -5
- package/src/logic/tests/lastBlock.test.ts +3 -6
- package/src/logic/tests/listOperations.test.ts +3 -4
- package/src/logic/tests/validateIntent.test.ts +16 -3
- package/src/logic/validateIntent.ts +8 -10
- package/src/logic.test.ts +12 -4
- package/src/logic.ts +13 -13
- package/src/network/explorer/etherscan.test.ts +9 -58
- package/src/network/explorer/etherscan.ts +8 -24
- package/src/network/explorer/index.test.ts +1 -1
- package/src/network/explorer/ledger.test.ts +44 -146
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +12 -5
- package/src/network/gasTracker/ledger.ts +1 -4
- package/src/network/node/explorerProxy.test.ts +17 -22
- package/src/network/node/explorerProxy.ts +23 -20
- package/src/network/node/gethCallTracerToTraceBlockItems.test.ts +1 -1
- package/src/network/node/gethCallTracerToTraceBlockItems.ts +6 -9
- package/src/network/node/index.memoization.test.ts +29 -22
- package/src/network/node/index.test.ts +1 -3
- package/src/network/node/index.ts +11 -8
- package/src/network/node/ledger.test.ts +63 -69
- package/src/network/node/ledger.ts +39 -38
- package/src/network/node/rpc.common.ts +134 -158
- package/src/network/node/rpc.test.ts +201 -110
- package/src/network/node/types.ts +17 -64
- package/src/network/node/withNodeSources.test.ts +7 -9
- package/src/network/node/withNodeSources.ts +23 -26
- package/src/nodeSources.ts +11 -3
- package/src/staking/abis.test.ts +24 -28
- package/src/staking/abis.ts +12 -10
- package/src/staking/contracts.test.ts +20 -8
- package/src/staking/contracts.ts +13 -14
- package/src/staking/detectOperationType.test.ts +16 -13
- package/src/staking/detectOperationType.ts +24 -22
- package/src/staking/encoder.test.ts +38 -27
- package/src/staking/encoder.ts +9 -8
- package/src/staking/fetchers.ts +28 -39
- package/src/staking/logic.test.ts +34 -32
- package/src/staking/logic.ts +14 -14
- package/src/staking/operations/index.test.ts +48 -39
- package/src/staking/operations/index.ts +43 -21
- package/src/staking/prepareIntents.test.ts +14 -34
- package/src/staking/prepareIntents.ts +12 -14
- package/src/staking/redelegations.test.ts +73 -131
- package/src/staking/redelegations.ts +13 -31
- package/src/staking/rewards.test.ts +19 -21
- package/src/staking/rewards.ts +1 -2
- package/src/staking/rewardsFromReceipt.test.ts +9 -8
- package/src/staking/rewardsFromReceipt.ts +3 -2
- package/src/staking/transactionData.test.ts +35 -25
- package/src/staking/transactionData.ts +7 -6
- package/src/staking/unbondings.test.ts +26 -20
- package/src/staking/unbondings.ts +1 -2
- package/src/staking/utils.ts +19 -26
- package/src/staking/validators/index.ts +45 -51
- package/src/staking/validators/monad.test.ts +52 -54
- package/src/staking/validators/monad.ts +42 -40
- package/src/staking/validators/monadResolver.ts +4 -5
- package/src/staking/validators/sei.ts +2 -2
- package/src/staking/validators/somnia.test.ts +22 -19
- package/src/staking/validators/somnia.ts +23 -29
- package/src/staking/validators/types.ts +0 -1
- package/src/staking/validators/zero_gravity.test.ts +34 -49
- package/src/staking/validators/zero_gravity.ts +7 -12
- package/src/staking/validators.integ.test.ts +3 -5
- package/src/staking/validators.test.ts +56 -53
- package/src/types/staking.ts +3 -6
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { StakingOperation } from '../types/staking'
|
|
5
5
|
import { ethers } from 'ethers'
|
|
6
|
+
import { CHAIN_ID } from '../config'
|
|
6
7
|
import { detectEvmStakingOperationType, isStakingOperation } from './detectOperationType'
|
|
7
8
|
|
|
8
9
|
describe('isStakingOperation', () => {
|
|
@@ -46,14 +47,14 @@ describe('detectEvmStakingOperationType', () => {
|
|
|
46
47
|
it('should return correct OperationType for delegate', () => {
|
|
47
48
|
const fn = 'delegate(string)'
|
|
48
49
|
const methodId = ethers.id(fn).slice(0, 10).toLowerCase()
|
|
49
|
-
const result = detectEvmStakingOperationType(
|
|
50
|
+
const result = detectEvmStakingOperationType(CHAIN_ID.SEI_EVM, contractAddress, methodId)
|
|
50
51
|
expect(result).toBe('DELEGATE')
|
|
51
52
|
})
|
|
52
53
|
|
|
53
54
|
it('should return correct OperationType for redelegate', () => {
|
|
54
55
|
const fn = 'redelegate(string,string,uint256)'
|
|
55
56
|
const methodId = ethers.id(fn).slice(0, 10).toLowerCase()
|
|
56
|
-
const result = detectEvmStakingOperationType(
|
|
57
|
+
const result = detectEvmStakingOperationType(CHAIN_ID.SEI_EVM, contractAddress, methodId)
|
|
57
58
|
expect(result).toBe('REDELEGATE')
|
|
58
59
|
})
|
|
59
60
|
|
|
@@ -61,7 +62,7 @@ describe('detectEvmStakingOperationType', () => {
|
|
|
61
62
|
const distributionAddress = '0x0000000000000000000000000000000000001007'
|
|
62
63
|
const fn = 'withdrawDelegationRewards(string)'
|
|
63
64
|
const methodId = ethers.id(fn).slice(0, 10).toLowerCase()
|
|
64
|
-
const result = detectEvmStakingOperationType(
|
|
65
|
+
const result = detectEvmStakingOperationType(CHAIN_ID.SEI_EVM, distributionAddress, methodId)
|
|
65
66
|
expect(result).toBe('REWARD')
|
|
66
67
|
})
|
|
67
68
|
|
|
@@ -69,50 +70,52 @@ describe('detectEvmStakingOperationType', () => {
|
|
|
69
70
|
const monadStakingAddress = '0x0000000000000000000000000000000000001000'
|
|
70
71
|
const fn = 'compound(uint64)'
|
|
71
72
|
const methodId = ethers.id(fn).slice(0, 10).toLowerCase()
|
|
72
|
-
const result = detectEvmStakingOperationType(
|
|
73
|
+
const result = detectEvmStakingOperationType(CHAIN_ID.MONAD, monadStakingAddress, methodId)
|
|
73
74
|
expect(result).toBe('REWARD')
|
|
74
75
|
})
|
|
75
76
|
|
|
76
77
|
it('should return undefined for claimReward selector sent to the staking contract', () => {
|
|
77
78
|
const fn = 'withdrawDelegationRewards(string)'
|
|
78
79
|
const methodId = ethers.id(fn).slice(0, 10).toLowerCase()
|
|
79
|
-
const result = detectEvmStakingOperationType(
|
|
80
|
+
const result = detectEvmStakingOperationType(CHAIN_ID.SEI_EVM, contractAddress, methodId)
|
|
80
81
|
expect(result).toBeUndefined()
|
|
81
82
|
})
|
|
82
83
|
|
|
83
84
|
it('should return undefined for invalid methodId', () => {
|
|
84
|
-
const result = detectEvmStakingOperationType(
|
|
85
|
+
const result = detectEvmStakingOperationType(CHAIN_ID.SEI_EVM, contractAddress, '0xdeadbeef')
|
|
85
86
|
expect(result).toBeUndefined()
|
|
86
87
|
})
|
|
87
88
|
|
|
88
89
|
it('should return undefined for mismatched contract address', () => {
|
|
89
90
|
const methodId = '0x9ddb511a' // selector for delegate(address,uint256)
|
|
90
|
-
const result = detectEvmStakingOperationType(
|
|
91
|
+
const result = detectEvmStakingOperationType(CHAIN_ID.SEI_EVM, '0xDifferentAddress', methodId)
|
|
91
92
|
expect(result).toBeUndefined()
|
|
92
93
|
})
|
|
93
94
|
|
|
94
95
|
it('should return undefined if methodId or address is missing', () => {
|
|
95
|
-
expect(detectEvmStakingOperationType(
|
|
96
|
-
expect(detectEvmStakingOperationType(
|
|
96
|
+
expect(detectEvmStakingOperationType(CHAIN_ID.SEI_EVM, null, '0x1234')).toBeUndefined()
|
|
97
|
+
expect(detectEvmStakingOperationType(CHAIN_ID.SEI_EVM, contractAddress, null)).toBeUndefined()
|
|
97
98
|
})
|
|
98
99
|
|
|
99
|
-
it('should return undefined for
|
|
100
|
+
it('should return undefined for a chain without staking', () => {
|
|
100
101
|
const methodId = '0x9ddb511a' // selector for delegate(address,uint256)
|
|
101
|
-
expect(
|
|
102
|
+
expect(
|
|
103
|
+
detectEvmStakingOperationType(CHAIN_ID.ETHEREUM, contractAddress, methodId)
|
|
104
|
+
).toBeUndefined()
|
|
102
105
|
})
|
|
103
106
|
|
|
104
107
|
it('returns DELEGATE for 0G regardless of which validator contract address is the `to`', () => {
|
|
105
108
|
const selector = ethers.id('delegate(address)').slice(0, 10).toLowerCase()
|
|
106
109
|
expect(
|
|
107
110
|
detectEvmStakingOperationType(
|
|
108
|
-
|
|
111
|
+
CHAIN_ID.ZERO_GRAVITY,
|
|
109
112
|
'0x0000000000000000000000000000000000000001',
|
|
110
113
|
selector
|
|
111
114
|
)
|
|
112
115
|
).toBe('DELEGATE')
|
|
113
116
|
expect(
|
|
114
117
|
detectEvmStakingOperationType(
|
|
115
|
-
|
|
118
|
+
CHAIN_ID.ZERO_GRAVITY,
|
|
116
119
|
'0x0000000000000000000000000000000000000002',
|
|
117
120
|
selector
|
|
118
121
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { ChainId } from '../config'
|
|
4
5
|
import type { EvmStakingOperationType } from '../types/staking'
|
|
5
6
|
import type { StakingOperation } from '../types/staking'
|
|
6
7
|
import { ethers } from 'ethers'
|
|
@@ -19,18 +20,19 @@ const OP_MAP: Partial<Record<StakingOperation, EvmStakingOperationType>> = {
|
|
|
19
20
|
/**
|
|
20
21
|
* Checks if a string is a valid staking operation
|
|
21
22
|
*/
|
|
23
|
+
const STAKING_OPERATIONS = new Set<string>([
|
|
24
|
+
'delegate',
|
|
25
|
+
'undelegate',
|
|
26
|
+
'redelegate',
|
|
27
|
+
'withdraw',
|
|
28
|
+
'getStakedBalance',
|
|
29
|
+
'getUnstakedBalance',
|
|
30
|
+
'claimReward',
|
|
31
|
+
'compoundReward',
|
|
32
|
+
])
|
|
33
|
+
|
|
22
34
|
export function isStakingOperation(value: string): value is StakingOperation {
|
|
23
|
-
|
|
24
|
-
'delegate',
|
|
25
|
-
'undelegate',
|
|
26
|
-
'redelegate',
|
|
27
|
-
'withdraw',
|
|
28
|
-
'getStakedBalance',
|
|
29
|
-
'getUnstakedBalance',
|
|
30
|
-
'claimReward',
|
|
31
|
-
'compoundReward',
|
|
32
|
-
]
|
|
33
|
-
return stakingOperations.includes(value as StakingOperation)
|
|
35
|
+
return STAKING_OPERATIONS.has(value)
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
type SelectorEntry = {
|
|
@@ -54,21 +56,21 @@ type SelectorEntry = {
|
|
|
54
56
|
* a matching selector sent to the wrong contract (e.g. SEI claimReward selector hitting the
|
|
55
57
|
* staking precompile instead of the distribution precompile) is not a staking operation.
|
|
56
58
|
*/
|
|
57
|
-
const selectorsCache = new Map<
|
|
58
|
-
const getStakingEntries = (
|
|
59
|
-
const cached = selectorsCache.get(
|
|
59
|
+
const selectorsCache = new Map<ChainId, Map<string, SelectorEntry>>()
|
|
60
|
+
const getStakingEntries = (chainId: ChainId): Map<string, SelectorEntry> | undefined => {
|
|
61
|
+
const cached = selectorsCache.get(chainId)
|
|
60
62
|
if (cached) return cached
|
|
61
63
|
|
|
62
|
-
const config = STAKING_CONTRACTS[
|
|
63
|
-
const abi = getStakingABI(
|
|
64
|
+
const config = STAKING_CONTRACTS[chainId]
|
|
65
|
+
const abi = getStakingABI(chainId)
|
|
64
66
|
if (!config || !abi) return undefined
|
|
65
67
|
|
|
66
68
|
const entries = new Map<string, SelectorEntry>()
|
|
67
|
-
selectorsCache.set(
|
|
69
|
+
selectorsCache.set(chainId, entries)
|
|
68
70
|
|
|
69
71
|
for (const [op, fn] of Object.entries(config.functions)) {
|
|
70
|
-
|
|
71
|
-
const mapped = OP_MAP[
|
|
72
|
+
if (!isStakingOperation(op)) continue
|
|
73
|
+
const mapped = OP_MAP[op]
|
|
72
74
|
if (!mapped || !fn) continue
|
|
73
75
|
|
|
74
76
|
try {
|
|
@@ -80,7 +82,7 @@ const getStakingEntries = (currencyId: string): Map<string, SelectorEntry> | und
|
|
|
80
82
|
const signature = `${fn}(${paramTypes})`
|
|
81
83
|
const selector = ethers.id(signature).slice(0, 10).toLowerCase()
|
|
82
84
|
entries.set(selector, {
|
|
83
|
-
resolveAddress: (to) => config.contractAddress({ mode:
|
|
85
|
+
resolveAddress: (to) => config.contractAddress({ mode: op, valAddress: to }),
|
|
84
86
|
opType: mapped,
|
|
85
87
|
})
|
|
86
88
|
} catch {
|
|
@@ -92,13 +94,13 @@ const getStakingEntries = (currencyId: string): Map<string, SelectorEntry> | und
|
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
export const detectEvmStakingOperationType = (
|
|
95
|
-
|
|
97
|
+
chainId: ChainId,
|
|
96
98
|
to: string | undefined | null,
|
|
97
99
|
methodId: string | undefined | null
|
|
98
100
|
): EvmStakingOperationType | undefined => {
|
|
99
101
|
if (!to || !methodId) return undefined
|
|
100
102
|
|
|
101
|
-
const entries = getStakingEntries(
|
|
103
|
+
const entries = getStakingEntries(chainId)
|
|
102
104
|
if (!entries) return undefined
|
|
103
105
|
|
|
104
106
|
const entry = entries.get(methodId.toLowerCase())
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { ChainId } from '../config'
|
|
4
5
|
import type { StakingOperation } from '../types/staking'
|
|
5
6
|
import { ethers } from 'ethers'
|
|
6
|
-
import {
|
|
7
|
+
import { CHAIN_ID } from '../config'
|
|
8
|
+
import { createMockEvmConfigInfo, mkExternalNode } from '../fixtures/context.fixtures'
|
|
9
|
+
import { requireStakingContract } from '../fixtures/staking.fixtures'
|
|
7
10
|
import { encodeStakingData, decodeStakingResult } from './encoder'
|
|
8
11
|
import { extractSeiDelegation, getSeiDelegationAmount } from './utils'
|
|
9
12
|
|
|
13
|
+
const mkConfig = (chainId: ChainId, name: string) =>
|
|
14
|
+
createMockEvmConfigInfo({ chainId, name, node: mkExternalNode() })
|
|
15
|
+
|
|
10
16
|
describe('encodeStakingData', () => {
|
|
11
17
|
describe('SEI Network', () => {
|
|
12
|
-
const
|
|
13
|
-
const config =
|
|
18
|
+
const evmConfig = mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm')
|
|
19
|
+
const config = requireStakingContract(CHAIN_ID.SEI_EVM)
|
|
14
20
|
|
|
15
21
|
it('should encode delegate operation', () => {
|
|
16
22
|
const validatorAddress = 'seivaloper1abc123'
|
|
17
23
|
const params = [validatorAddress]
|
|
18
24
|
|
|
19
25
|
const encoded = encodeStakingData({
|
|
20
|
-
|
|
26
|
+
evmConfig,
|
|
21
27
|
operation: 'delegate',
|
|
22
28
|
config,
|
|
23
29
|
params,
|
|
@@ -32,7 +38,7 @@ describe('encodeStakingData', () => {
|
|
|
32
38
|
const params = [validatorAddress, amount]
|
|
33
39
|
|
|
34
40
|
const encoded = encodeStakingData({
|
|
35
|
-
|
|
41
|
+
evmConfig,
|
|
36
42
|
operation: 'undelegate',
|
|
37
43
|
config,
|
|
38
44
|
params,
|
|
@@ -48,7 +54,7 @@ describe('encodeStakingData', () => {
|
|
|
48
54
|
const params = [srcAddress, dstAddress, amount]
|
|
49
55
|
|
|
50
56
|
const encoded = encodeStakingData({
|
|
51
|
-
|
|
57
|
+
evmConfig,
|
|
52
58
|
operation: 'redelegate',
|
|
53
59
|
config,
|
|
54
60
|
params,
|
|
@@ -63,7 +69,7 @@ describe('encodeStakingData', () => {
|
|
|
63
69
|
const params = [validatorAddress]
|
|
64
70
|
|
|
65
71
|
const encoded = encodeStakingData({
|
|
66
|
-
|
|
72
|
+
evmConfig,
|
|
67
73
|
operation,
|
|
68
74
|
config,
|
|
69
75
|
params,
|
|
@@ -74,8 +80,8 @@ describe('encodeStakingData', () => {
|
|
|
74
80
|
})
|
|
75
81
|
|
|
76
82
|
describe('CELO', () => {
|
|
77
|
-
const
|
|
78
|
-
const config =
|
|
83
|
+
const evmConfig = mkConfig(CHAIN_ID.CELO, 'celo')
|
|
84
|
+
const config = requireStakingContract(CHAIN_ID.CELO)
|
|
79
85
|
|
|
80
86
|
it('should encode delegate operation', () => {
|
|
81
87
|
const account = '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d'
|
|
@@ -83,7 +89,7 @@ describe('encodeStakingData', () => {
|
|
|
83
89
|
const params = [account, value]
|
|
84
90
|
|
|
85
91
|
const encoded = encodeStakingData({
|
|
86
|
-
|
|
92
|
+
evmConfig,
|
|
87
93
|
operation: 'delegate',
|
|
88
94
|
config,
|
|
89
95
|
params,
|
|
@@ -98,7 +104,7 @@ describe('encodeStakingData', () => {
|
|
|
98
104
|
const params = [account, value]
|
|
99
105
|
|
|
100
106
|
const encoded = encodeStakingData({
|
|
101
|
-
|
|
107
|
+
evmConfig,
|
|
102
108
|
operation: 'undelegate',
|
|
103
109
|
config,
|
|
104
110
|
params,
|
|
@@ -109,12 +115,12 @@ describe('encodeStakingData', () => {
|
|
|
109
115
|
})
|
|
110
116
|
|
|
111
117
|
describe('Error handling', () => {
|
|
112
|
-
const config =
|
|
118
|
+
const config = requireStakingContract(CHAIN_ID.SEI_EVM)
|
|
113
119
|
|
|
114
120
|
it('should throw error for unsupported currency', () => {
|
|
115
121
|
expect(() => {
|
|
116
122
|
encodeStakingData({
|
|
117
|
-
|
|
123
|
+
evmConfig: mkConfig(CHAIN_ID.ETHEREUM, 'unsupported_currency'),
|
|
118
124
|
operation: 'delegate',
|
|
119
125
|
config,
|
|
120
126
|
params: ['validator'],
|
|
@@ -125,7 +131,7 @@ describe('encodeStakingData', () => {
|
|
|
125
131
|
it('should throw error for unsupported operation', () => {
|
|
126
132
|
expect(() => {
|
|
127
133
|
encodeStakingData({
|
|
128
|
-
|
|
134
|
+
evmConfig: mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm'),
|
|
129
135
|
// @ts-ignore — intentionally invalid operation to test error path
|
|
130
136
|
operation: 'invalidOperation',
|
|
131
137
|
config,
|
|
@@ -138,8 +144,8 @@ describe('encodeStakingData', () => {
|
|
|
138
144
|
|
|
139
145
|
describe('decodeStakingResult', () => {
|
|
140
146
|
describe('SEI Network', () => {
|
|
141
|
-
const
|
|
142
|
-
const config =
|
|
147
|
+
const evmConfig = mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm')
|
|
148
|
+
const config = requireStakingContract(CHAIN_ID.SEI_EVM)
|
|
143
149
|
|
|
144
150
|
it('should decode delegation result', () => {
|
|
145
151
|
const mockBalance = {
|
|
@@ -198,7 +204,7 @@ describe('decodeStakingResult', () => {
|
|
|
198
204
|
[mockBalance, mockDelegation],
|
|
199
205
|
])
|
|
200
206
|
|
|
201
|
-
const decoded = decodeStakingResult(
|
|
207
|
+
const decoded = decodeStakingResult(evmConfig, 'getStakedBalance', config, encodedResult)
|
|
202
208
|
|
|
203
209
|
expect(decoded).toBeInstanceOf(Array)
|
|
204
210
|
expect(decoded.length).toBeGreaterThan(0)
|
|
@@ -259,12 +265,7 @@ describe('decodeStakingResult', () => {
|
|
|
259
265
|
],
|
|
260
266
|
])
|
|
261
267
|
|
|
262
|
-
const decoded = decodeStakingResult(
|
|
263
|
-
'sei_evm',
|
|
264
|
-
'getStakedBalance',
|
|
265
|
-
STAKING_CONTRACTS['sei_evm'],
|
|
266
|
-
encodedResult
|
|
267
|
-
)
|
|
268
|
+
const decoded = decodeStakingResult(evmConfig, 'getStakedBalance', config, encodedResult)
|
|
268
269
|
|
|
269
270
|
const delegation = extractSeiDelegation(decoded)
|
|
270
271
|
expect(delegation?.balance.denom).toBe('usei')
|
|
@@ -275,18 +276,28 @@ describe('decodeStakingResult', () => {
|
|
|
275
276
|
})
|
|
276
277
|
|
|
277
278
|
describe('Error handling', () => {
|
|
278
|
-
const config =
|
|
279
|
+
const config = requireStakingContract(CHAIN_ID.SEI_EVM)
|
|
279
280
|
|
|
280
281
|
it('should throw error for unsupported currency', () => {
|
|
281
282
|
expect(() => {
|
|
282
|
-
decodeStakingResult(
|
|
283
|
+
decodeStakingResult(
|
|
284
|
+
mkConfig(CHAIN_ID.ETHEREUM, 'unsupported_currency'),
|
|
285
|
+
'getStakedBalance',
|
|
286
|
+
config,
|
|
287
|
+
'0x'
|
|
288
|
+
)
|
|
283
289
|
}).toThrow('No ABI found for staking currency: unsupported_currency')
|
|
284
290
|
})
|
|
285
291
|
|
|
286
292
|
it('should throw error for unsupported operation', () => {
|
|
287
293
|
expect(() => {
|
|
288
|
-
|
|
289
|
-
|
|
294
|
+
decodeStakingResult(
|
|
295
|
+
mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm'),
|
|
296
|
+
// @ts-ignore: intentionally invalid operation to test error path
|
|
297
|
+
'invalidOperation',
|
|
298
|
+
config,
|
|
299
|
+
'0x'
|
|
300
|
+
)
|
|
290
301
|
}).toThrow("Operation 'invalidOperation' not supported for currency: sei_evm")
|
|
291
302
|
})
|
|
292
303
|
})
|
package/src/staking/encoder.ts
CHANGED
|
@@ -1,6 +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
5
|
import type {
|
|
5
6
|
EncodeStakingDataParams,
|
|
6
7
|
StakingContractConfig,
|
|
@@ -10,16 +11,16 @@ import { ethers } from 'ethers'
|
|
|
10
11
|
import { getStakingABI } from './abis'
|
|
11
12
|
|
|
12
13
|
export const encodeStakingData = (encodeParams: EncodeStakingDataParams): string => {
|
|
13
|
-
const {
|
|
14
|
+
const { evmConfig, operation, config, params } = encodeParams
|
|
14
15
|
|
|
15
|
-
const abi = getStakingABI(
|
|
16
|
+
const abi = getStakingABI(evmConfig.chainId)
|
|
16
17
|
if (!abi) {
|
|
17
|
-
throw new Error(`No ABI found for staking currency: ${
|
|
18
|
+
throw new Error(`No ABI found for staking currency: ${evmConfig.name}`)
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
const functionName = config.functions[operation]
|
|
21
22
|
if (!functionName) {
|
|
22
|
-
throw new Error(`Operation '${operation}' not supported for currency: ${
|
|
23
|
+
throw new Error(`Operation '${operation}' not supported for currency: ${evmConfig.name}`)
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const iface = new ethers.Interface(abi)
|
|
@@ -27,19 +28,19 @@ export const encodeStakingData = (encodeParams: EncodeStakingDataParams): string
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export const decodeStakingResult = (
|
|
30
|
-
|
|
31
|
+
evmConfig: EvmConfigInfo,
|
|
31
32
|
operation: StakingOperation,
|
|
32
33
|
config: StakingContractConfig,
|
|
33
34
|
result: string
|
|
34
35
|
): ethers.Result => {
|
|
35
|
-
const abi = getStakingABI(
|
|
36
|
+
const abi = getStakingABI(evmConfig.chainId)
|
|
36
37
|
if (!abi) {
|
|
37
|
-
throw new Error(`No ABI found for staking currency: ${
|
|
38
|
+
throw new Error(`No ABI found for staking currency: ${evmConfig.name}`)
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
const functionName = config.functions[operation]
|
|
41
42
|
if (!functionName) {
|
|
42
|
-
throw new Error(`Operation '${operation}' not supported for currency: ${
|
|
43
|
+
throw new Error(`Operation '${operation}' not supported for currency: ${evmConfig.name}`)
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
const iface = new ethers.Interface(abi)
|
package/src/staking/fetchers.ts
CHANGED
|
@@ -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 {
|
|
6
6
|
StakeCreate,
|
|
7
7
|
StakingContractConfig,
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import type { Stake, Validator } from '@ledgerhq/coin-module-framework/api/types'
|
|
12
12
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
13
13
|
import { delay } from '@ledgerhq/coin-module-framework/promises'
|
|
14
|
+
import { CHAIN_ID } from '../config'
|
|
14
15
|
import { withApi } from '../network/node/rpc.common'
|
|
15
16
|
import { isExternalNodeConfig } from '../network/node/types'
|
|
16
17
|
import { encodeStakingData, decodeStakingResult } from './encoder'
|
|
@@ -29,7 +30,6 @@ const createStakingFetcher = (
|
|
|
29
30
|
getValidatorsFn: (
|
|
30
31
|
evmConfig: EvmConfigInfo,
|
|
31
32
|
config: StakingContractConfig,
|
|
32
|
-
currencyId: string,
|
|
33
33
|
logger: Logger
|
|
34
34
|
) => Promise<Validator[]>
|
|
35
35
|
) => {
|
|
@@ -37,60 +37,52 @@ const createStakingFetcher = (
|
|
|
37
37
|
evmConfig: EvmConfigInfo,
|
|
38
38
|
address: string,
|
|
39
39
|
config: StakingContractConfig,
|
|
40
|
-
currencyId: string,
|
|
41
40
|
logger: Logger,
|
|
42
41
|
_knownValIds?: string[]
|
|
43
42
|
): Promise<Stake[]> => {
|
|
44
|
-
const validators = await getValidatorsFn(evmConfig, config,
|
|
43
|
+
const validators = await getValidatorsFn(evmConfig, config, logger)
|
|
45
44
|
const validatorAddresses = validators.map((v) => v.address)
|
|
46
|
-
return getStakesForValidators(
|
|
47
|
-
evmConfig,
|
|
48
|
-
address,
|
|
49
|
-
config,
|
|
50
|
-
currencyId,
|
|
51
|
-
validatorAddresses,
|
|
52
|
-
logger
|
|
53
|
-
)
|
|
45
|
+
return getStakesForValidators(evmConfig, address, config, validatorAddresses, logger)
|
|
54
46
|
}
|
|
55
47
|
}
|
|
56
48
|
|
|
57
|
-
export const STAKING_CONFIG: Record<
|
|
58
|
-
|
|
49
|
+
export const STAKING_CONFIG: Partial<Record<ChainId, StakingStrategy>> = {
|
|
50
|
+
[CHAIN_ID.SEI_EVM]: {
|
|
59
51
|
// Sei returns its whole validator set in a single page, so the first page's
|
|
60
52
|
// items are the complete list.
|
|
61
|
-
fetcher: createStakingFetcher(async (evmConfig, _config,
|
|
62
|
-
const { items } = await getValidators(evmConfig,
|
|
53
|
+
fetcher: createStakingFetcher(async (evmConfig, _config, logger) => {
|
|
54
|
+
const { items } = await getValidators(evmConfig, logger)
|
|
63
55
|
return items
|
|
64
56
|
}),
|
|
65
57
|
},
|
|
66
|
-
|
|
58
|
+
[CHAIN_ID.CELO]: {
|
|
67
59
|
fetcher: createStakingFetcher(async (_evmConfig, config) => {
|
|
68
60
|
const address = config.contractAddress()
|
|
69
61
|
return [{ id: address, address, name: '' }]
|
|
70
62
|
}),
|
|
71
63
|
},
|
|
72
|
-
|
|
64
|
+
[CHAIN_ID.MONAD]: {
|
|
73
65
|
fetcher: fetchMonadStakes,
|
|
74
66
|
extractKnownValIds: extractMonadKnownValIds,
|
|
75
67
|
},
|
|
76
|
-
|
|
68
|
+
[CHAIN_ID.ZERO_GRAVITY]: {
|
|
77
69
|
fetcher: fetchZeroGravityStakes,
|
|
78
70
|
},
|
|
79
|
-
|
|
71
|
+
[CHAIN_ID.SOMNIA]: {
|
|
80
72
|
fetcher: fetchSomniaStakes,
|
|
81
73
|
},
|
|
82
74
|
}
|
|
83
75
|
|
|
84
|
-
const AMOUNT_EXTRACTORS: Record<
|
|
85
|
-
|
|
76
|
+
const AMOUNT_EXTRACTORS: Partial<Record<ChainId, StakingExtractor>> = {
|
|
77
|
+
[CHAIN_ID.SEI_EVM]: (decoded: unknown): bigint => {
|
|
86
78
|
const delegation = extractSeiDelegation(decoded)
|
|
87
79
|
return getSeiDelegationAmount(delegation)
|
|
88
80
|
},
|
|
89
|
-
|
|
81
|
+
[CHAIN_ID.CELO]: getCeloAmount,
|
|
90
82
|
}
|
|
91
83
|
|
|
92
|
-
const getAmountFromDecoded = (
|
|
93
|
-
const extractor = AMOUNT_EXTRACTORS[
|
|
84
|
+
const getAmountFromDecoded = (chainId: ChainId, decoded: unknown): bigint => {
|
|
85
|
+
const extractor = AMOUNT_EXTRACTORS[chainId]
|
|
94
86
|
return extractor ? extractor(decoded) : 0n
|
|
95
87
|
}
|
|
96
88
|
|
|
@@ -113,8 +105,8 @@ const isMissingRevertDataCallException = (error: unknown): boolean => {
|
|
|
113
105
|
)
|
|
114
106
|
}
|
|
115
107
|
|
|
116
|
-
const isSeiMissingDelegationError = (
|
|
117
|
-
|
|
108
|
+
const isSeiMissingDelegationError = (chainId: ChainId, error: unknown): boolean =>
|
|
109
|
+
chainId === CHAIN_ID.SEI_EVM && isMissingRevertDataCallException(error)
|
|
118
110
|
|
|
119
111
|
// Short retry delay for staking calls. The staking precompile returns
|
|
120
112
|
// CALL_EXCEPTION with "missing revert data" both for genuine no-delegation AND
|
|
@@ -127,7 +119,7 @@ const createStakeFromContract = async (
|
|
|
127
119
|
evmConfig: EvmConfigInfo,
|
|
128
120
|
stakingContract: StakeCreate
|
|
129
121
|
): Promise<Stake | null> => {
|
|
130
|
-
const { config, address,
|
|
122
|
+
const { config, address, validatorAddress } = stakingContract
|
|
131
123
|
const node = evmConfig.node
|
|
132
124
|
if (!isExternalNodeConfig(node)) {
|
|
133
125
|
throw new Error("Currency doesn't have an RPC node provided")
|
|
@@ -135,17 +127,16 @@ const createStakeFromContract = async (
|
|
|
135
127
|
|
|
136
128
|
return withApi(
|
|
137
129
|
evmConfig,
|
|
138
|
-
currencyId,
|
|
139
130
|
async (rpcProvider) => {
|
|
140
131
|
const executeCall = async (): Promise<Stake | null> => {
|
|
141
|
-
const params = buildTransactionParams(
|
|
132
|
+
const params = buildTransactionParams(evmConfig, 'getStakedBalance', {
|
|
142
133
|
valAddress: address,
|
|
143
134
|
amount: 0n,
|
|
144
135
|
dstValAddress: validatorAddress,
|
|
145
136
|
delegator: address,
|
|
146
137
|
})
|
|
147
138
|
const encodedData = encodeStakingData({
|
|
148
|
-
|
|
139
|
+
evmConfig,
|
|
149
140
|
operation: 'getStakedBalance',
|
|
150
141
|
config,
|
|
151
142
|
params,
|
|
@@ -159,8 +150,8 @@ const createStakeFromContract = async (
|
|
|
159
150
|
to: contractAddress,
|
|
160
151
|
data: encodedData,
|
|
161
152
|
})
|
|
162
|
-
const decoded = decodeStakingResult(
|
|
163
|
-
const amount = getAmountFromDecoded(
|
|
153
|
+
const decoded = decodeStakingResult(evmConfig, 'getStakedBalance', config, result)
|
|
154
|
+
const amount = getAmountFromDecoded(evmConfig.chainId, decoded)
|
|
164
155
|
|
|
165
156
|
if (amount === 0n) {
|
|
166
157
|
return null
|
|
@@ -188,7 +179,7 @@ const createStakeFromContract = async (
|
|
|
188
179
|
try {
|
|
189
180
|
return await executeCall()
|
|
190
181
|
} catch (error) {
|
|
191
|
-
if (isSeiMissingDelegationError(
|
|
182
|
+
if (isSeiMissingDelegationError(evmConfig.chainId, error)) {
|
|
192
183
|
// The SEI staking precompile returns CALL_EXCEPTION with "missing revert
|
|
193
184
|
// data" both when there is genuinely no delegation AND on transient RPC
|
|
194
185
|
// failures. Retry once after a brief delay: a genuine no-delegation
|
|
@@ -198,7 +189,7 @@ const createStakeFromContract = async (
|
|
|
198
189
|
try {
|
|
199
190
|
return await executeCall()
|
|
200
191
|
} catch (retryError) {
|
|
201
|
-
if (isSeiMissingDelegationError(
|
|
192
|
+
if (isSeiMissingDelegationError(evmConfig.chainId, retryError)) {
|
|
202
193
|
return null // Consistent CALL_EXCEPTION — genuinely no delegation
|
|
203
194
|
}
|
|
204
195
|
throw new Error(
|
|
@@ -223,7 +214,6 @@ const getStakesForValidators = async (
|
|
|
223
214
|
evmConfig: EvmConfigInfo,
|
|
224
215
|
address: string,
|
|
225
216
|
config: StakingContractConfig,
|
|
226
|
-
currencyId: string,
|
|
227
217
|
validators: string[],
|
|
228
218
|
logger: Logger
|
|
229
219
|
): Promise<Stake[]> => {
|
|
@@ -235,7 +225,7 @@ const getStakesForValidators = async (
|
|
|
235
225
|
// Fired here so its latency overlaps the precompile batch loop below;
|
|
236
226
|
// awaited at the end. Any failure resolves to an empty map so the staking
|
|
237
227
|
// sync never blocks on the off-chain rewards call.
|
|
238
|
-
const rewardsPromise = fetchRewards(evmConfig,
|
|
228
|
+
const rewardsPromise = fetchRewards(evmConfig, address, logger).catch(
|
|
239
229
|
() => new Map<string, bigint>()
|
|
240
230
|
)
|
|
241
231
|
|
|
@@ -251,12 +241,11 @@ const getStakesForValidators = async (
|
|
|
251
241
|
createStakeFromContract(evmConfig, {
|
|
252
242
|
address,
|
|
253
243
|
config,
|
|
254
|
-
currencyId,
|
|
255
244
|
validatorAddress: validator,
|
|
256
245
|
}).catch((error) => {
|
|
257
246
|
console.error('Failed to fetch stake for validator', {
|
|
258
247
|
validator,
|
|
259
|
-
|
|
248
|
+
currency: evmConfig.name,
|
|
260
249
|
address,
|
|
261
250
|
error: error instanceof Error ? error.message : String(error),
|
|
262
251
|
})
|