@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
|
@@ -46,17 +46,6 @@ export type TraceBlockCallAction = {
|
|
|
46
46
|
value: string
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function isTraceBlockCallAction(
|
|
50
|
-
action: Record<string, unknown>
|
|
51
|
-
): action is TraceBlockCallAction {
|
|
52
|
-
return (
|
|
53
|
-
typeof action.from === 'string' &&
|
|
54
|
-
typeof action.to === 'string' &&
|
|
55
|
-
typeof action.callType === 'string' &&
|
|
56
|
-
typeof action.value === 'string'
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
49
|
/**
|
|
61
50
|
* Other action types (e.g. reward, or other trace_block action shapes).
|
|
62
51
|
* No specific fields are prescribed.
|
|
@@ -92,36 +81,18 @@ export type TraceBlockItem = {
|
|
|
92
81
|
type: string
|
|
93
82
|
}
|
|
94
83
|
|
|
95
|
-
/** Type guard for {@link TraceBlockItem} (Erigon `trace_block` and Geth adapter output). */
|
|
96
|
-
export function isTraceBlockItem(value: unknown): value is TraceBlockItem {
|
|
97
|
-
if (typeof value !== 'object' || value === null) return false
|
|
98
|
-
const o = value as Record<string, unknown>
|
|
99
|
-
if (!o.action || typeof o.action !== 'object' || o.action === null) return false
|
|
100
|
-
const action = o.action as Record<string, unknown>
|
|
101
|
-
if (o.error !== undefined && typeof o.error !== 'string') return false
|
|
102
|
-
|
|
103
|
-
const result = o.result
|
|
104
|
-
const resultOk =
|
|
105
|
-
result === undefined ||
|
|
106
|
-
result === null ||
|
|
107
|
-
(typeof result === 'object' &&
|
|
108
|
-
((result as Record<string, unknown>).error === undefined ||
|
|
109
|
-
typeof (result as Record<string, unknown>).error === 'string'))
|
|
110
|
-
const validCall = typeof o.transactionHash === 'string' && resultOk
|
|
111
|
-
|
|
112
|
-
return !isTraceBlockCallAction(action) || validCall
|
|
113
|
-
}
|
|
114
|
-
|
|
115
84
|
/** A transaction receipt as returned by a RPC node. */
|
|
116
85
|
export type TransactionReceipt = {
|
|
117
86
|
transactionHash: string
|
|
118
87
|
gasUsed: string
|
|
119
|
-
|
|
120
|
-
|
|
88
|
+
/** Absent, or JSON `null`, when the node does not report this field. */
|
|
89
|
+
effectiveGasPrice?: string | null
|
|
90
|
+
/** Absent, or JSON `null`, when the node does not report this field. */
|
|
91
|
+
gasPrice?: string | null
|
|
121
92
|
status: string | number | null
|
|
122
93
|
logs: LogWithAddress[]
|
|
123
|
-
/** Tx envelope type per EIP-2718, hex-prefixed (e.g. "0x2" EIP-1559). */
|
|
124
|
-
type?: string
|
|
94
|
+
/** Tx envelope type per EIP-2718, hex-prefixed (e.g. "0x2" EIP-1559). `null` when the node omits it. */
|
|
95
|
+
type?: string | null
|
|
125
96
|
}
|
|
126
97
|
|
|
127
98
|
/**
|
|
@@ -183,53 +154,35 @@ export type EvmCallParams = {
|
|
|
183
154
|
}
|
|
184
155
|
|
|
185
156
|
export type NodeApi = {
|
|
186
|
-
call: (
|
|
187
|
-
getTransaction: (
|
|
188
|
-
getCoinBalance: (
|
|
189
|
-
getTokenBalance: (
|
|
190
|
-
currencyId: string,
|
|
191
|
-
address: string,
|
|
192
|
-
contractAddress: string
|
|
193
|
-
) => Promise<BigNumber>
|
|
157
|
+
call: (params: EvmCallParams) => Promise<string>
|
|
158
|
+
getTransaction: (hash: string) => Promise<TransactionInfo>
|
|
159
|
+
getCoinBalance: (address: string) => Promise<BigNumber>
|
|
160
|
+
getTokenBalance: (address: string, contractAddress: string) => Promise<BigNumber>
|
|
194
161
|
getTokenAllowance: (
|
|
195
|
-
currencyId: string,
|
|
196
162
|
ownerAddress: string,
|
|
197
163
|
contractAddress: string,
|
|
198
164
|
spenderAddress: string
|
|
199
165
|
) => Promise<BigNumber>
|
|
200
|
-
getTransactionCount: (
|
|
166
|
+
getTransactionCount: (address: string) => Promise<number>
|
|
201
167
|
getGasEstimation: (
|
|
202
|
-
currencyId: string,
|
|
203
168
|
address: string,
|
|
204
169
|
transaction: { amount: BigNumber; data?: Buffer | null | undefined; recipient: string }
|
|
205
170
|
) => Promise<BigNumber>
|
|
206
171
|
getFeeData: (
|
|
207
172
|
config: EvmConfigInfo,
|
|
208
|
-
currencyId: string,
|
|
209
173
|
transaction: { type?: number | undefined; feesStrategy?: string | null | undefined }
|
|
210
174
|
) => Promise<FeeData>
|
|
211
|
-
broadcastTransaction: (
|
|
212
|
-
currencyId: string,
|
|
213
|
-
signedTxHex: string,
|
|
214
|
-
broadcastConfig?: BroadcastConfig
|
|
215
|
-
) => Promise<string>
|
|
175
|
+
broadcastTransaction: (signedTxHex: string, broadcastConfig?: BroadcastConfig) => Promise<string>
|
|
216
176
|
getBlockByHeight: (
|
|
217
|
-
currencyId: string,
|
|
218
177
|
blockHeight: number | BlockFinalizationTag,
|
|
219
178
|
prefetchTxs?: boolean
|
|
220
179
|
// timestamp is in milliseconds
|
|
221
180
|
) => Promise<BlockByHeightResult>
|
|
222
|
-
getBlockReceipts?: (
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
) => Promise<
|
|
226
|
-
|
|
227
|
-
currencyId: string,
|
|
228
|
-
blockHeight: number | 'latest'
|
|
229
|
-
) => Promise<TraceBlockItem[]>
|
|
230
|
-
traceBlockGeth?: (currencyId: string, blockHeight: number) => Promise<TraceBlockItem[]>
|
|
231
|
-
getOptimismAdditionalFees: (currencyId: string, transaction: string) => Promise<BigNumber>
|
|
232
|
-
getScrollAdditionalFees: (currencyId: string, transaction: string) => Promise<BigNumber>
|
|
181
|
+
getBlockReceipts?: (blockHeight: number | 'latest') => Promise<BlockReceiptInfo[]>
|
|
182
|
+
traceBlockErigon?: (blockHeight: number | 'latest') => Promise<TraceBlockItem[]>
|
|
183
|
+
traceBlockGeth?: (blockHeight: number) => Promise<TraceBlockItem[]>
|
|
184
|
+
getOptimismAdditionalFees: (transaction: string) => Promise<BigNumber>
|
|
185
|
+
getScrollAdditionalFees: (transaction: string) => Promise<BigNumber>
|
|
233
186
|
}
|
|
234
187
|
|
|
235
188
|
type NodeConfig = EvmConfigInfo['node']
|
|
@@ -65,7 +65,7 @@ describe('withNodeSources', () => {
|
|
|
65
65
|
api.getBlockByHeight.mockResolvedValueOnce(block)
|
|
66
66
|
|
|
67
67
|
const wrapped = withNodeSources(api, config, testLogger)
|
|
68
|
-
await expect(wrapped.getBlockByHeight(
|
|
68
|
+
await expect(wrapped.getBlockByHeight(100)).resolves.toEqual(block)
|
|
69
69
|
expect(mockAxiosGet).not.toHaveBeenCalled()
|
|
70
70
|
})
|
|
71
71
|
|
|
@@ -90,7 +90,7 @@ describe('withNodeSources', () => {
|
|
|
90
90
|
})
|
|
91
91
|
|
|
92
92
|
const wrapped = withNodeSources(api, config, testLogger)
|
|
93
|
-
const result = await wrapped.getBlockByHeight(
|
|
93
|
+
const result = await wrapped.getBlockByHeight(PRUNED_HEIGHT)
|
|
94
94
|
|
|
95
95
|
expect(result.hash).toBe('0xdeadbeef')
|
|
96
96
|
// Always populates transactionHashes (never transactions) so callers go through
|
|
@@ -122,7 +122,7 @@ describe('withNodeSources', () => {
|
|
|
122
122
|
mockAxiosGet.mockRejectedValueOnce(new Error('Explorer unreachable'))
|
|
123
123
|
|
|
124
124
|
const wrapped = withNodeSources(api, config, testLogger)
|
|
125
|
-
await expect(wrapped.getBlockByHeight(
|
|
125
|
+
await expect(wrapped.getBlockByHeight(PRUNED_HEIGHT)).rejects.toThrow(
|
|
126
126
|
`Block ${PRUNED_HEIGHT} not found`
|
|
127
127
|
)
|
|
128
128
|
})
|
|
@@ -138,7 +138,7 @@ describe('withNodeSources', () => {
|
|
|
138
138
|
mockAxiosGet.mockRejectedValueOnce(new Error('Explorer unreachable'))
|
|
139
139
|
|
|
140
140
|
const wrapped = withNodeSources(api, config, testLogger)
|
|
141
|
-
await expect(wrapped.getBlockByHeight(
|
|
141
|
+
await expect(wrapped.getBlockByHeight(PRUNED_HEIGHT)).rejects.toThrow(
|
|
142
142
|
'RPC connection timeout'
|
|
143
143
|
)
|
|
144
144
|
expect(mockAxiosGet).toHaveBeenCalled()
|
|
@@ -198,7 +198,7 @@ describe('withNodeSources', () => {
|
|
|
198
198
|
api.getTransaction.mockResolvedValueOnce(txInfo)
|
|
199
199
|
|
|
200
200
|
const wrapped = withNodeSources(api, config, testLogger)
|
|
201
|
-
await expect(wrapped.getTransaction(
|
|
201
|
+
await expect(wrapped.getTransaction(TX_HASH)).resolves.toEqual(txInfo)
|
|
202
202
|
expect(mockAxiosGet).not.toHaveBeenCalled()
|
|
203
203
|
})
|
|
204
204
|
|
|
@@ -213,7 +213,7 @@ describe('withNodeSources', () => {
|
|
|
213
213
|
mockAxiosGet.mockResolvedValueOnce(txResponse).mockResolvedValueOnce(receiptResponse)
|
|
214
214
|
|
|
215
215
|
const wrapped = withNodeSources(api, config, testLogger)
|
|
216
|
-
const result = await wrapped.getTransaction(
|
|
216
|
+
const result = await wrapped.getTransaction(TX_HASH)
|
|
217
217
|
|
|
218
218
|
expect(result.hash).toBe(TX_HASH)
|
|
219
219
|
expect(result.status).toBe(1)
|
|
@@ -232,9 +232,7 @@ describe('withNodeSources', () => {
|
|
|
232
232
|
mockAxiosGet.mockRejectedValue(new Error('Explorer unreachable'))
|
|
233
233
|
|
|
234
234
|
const wrapped = withNodeSources(api, config, testLogger)
|
|
235
|
-
await expect(wrapped.getTransaction(
|
|
236
|
-
'Transaction not found'
|
|
237
|
-
)
|
|
235
|
+
await expect(wrapped.getTransaction(TX_HASH)).rejects.toThrow('Transaction not found')
|
|
238
236
|
})
|
|
239
237
|
})
|
|
240
238
|
})
|
|
@@ -34,37 +34,34 @@ export function createFailoverNodeApi(sources: NodeApi[], logger: Logger): NodeA
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const base: NodeApi = {
|
|
37
|
-
call: (
|
|
38
|
-
getCoinBalance: (
|
|
39
|
-
getTokenBalance: (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
tryInOrder('
|
|
50
|
-
|
|
51
|
-
tryInOrder('
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
getBlockByHeight: (c, h, p) =>
|
|
55
|
-
tryInOrder('getBlockByHeight', (api) => api.getBlockByHeight(c, h, p)),
|
|
56
|
-
getTransaction: (c, h) => tryInOrder('getTransaction', (api) => api.getTransaction(c, h)),
|
|
37
|
+
call: (p) => tryInOrder('call', (api) => api.call(p)),
|
|
38
|
+
getCoinBalance: (a) => tryInOrder('getCoinBalance', (api) => api.getCoinBalance(a)),
|
|
39
|
+
getTokenBalance: (a, ca) => tryInOrder('getTokenBalance', (api) => api.getTokenBalance(a, ca)),
|
|
40
|
+
getTokenAllowance: (o, ca, s) =>
|
|
41
|
+
tryInOrder('getTokenAllowance', (api) => api.getTokenAllowance(o, ca, s)),
|
|
42
|
+
getTransactionCount: (a) =>
|
|
43
|
+
tryInOrder('getTransactionCount', (api) => api.getTransactionCount(a)),
|
|
44
|
+
getGasEstimation: (a, t) => tryInOrder('getGasEstimation', (api) => api.getGasEstimation(a, t)),
|
|
45
|
+
getFeeData: (cfg, t) => tryInOrder('getFeeData', (api) => api.getFeeData(cfg, t)),
|
|
46
|
+
broadcastTransaction: (tx, bc) =>
|
|
47
|
+
tryInOrder('broadcastTransaction', (api) => api.broadcastTransaction(tx, bc)),
|
|
48
|
+
getOptimismAdditionalFees: (t) =>
|
|
49
|
+
tryInOrder('getOptimismAdditionalFees', (api) => api.getOptimismAdditionalFees(t)),
|
|
50
|
+
getScrollAdditionalFees: (t) =>
|
|
51
|
+
tryInOrder('getScrollAdditionalFees', (api) => api.getScrollAdditionalFees(t)),
|
|
52
|
+
getBlockByHeight: (h, p) => tryInOrder('getBlockByHeight', (api) => api.getBlockByHeight(h, p)),
|
|
53
|
+
getTransaction: (h) => tryInOrder('getTransaction', (api) => api.getTransaction(h)),
|
|
57
54
|
}
|
|
58
55
|
// Optional methods: wired when at least one source implements them; undefined sources skipped
|
|
59
56
|
if (sources.some((api) => api.getBlockReceipts))
|
|
60
|
-
base.getBlockReceipts = (
|
|
61
|
-
tryInOrder('getBlockReceipts', (api) => api.getBlockReceipts?.(
|
|
57
|
+
base.getBlockReceipts = (h): Promise<BlockReceiptInfo[]> =>
|
|
58
|
+
tryInOrder('getBlockReceipts', (api) => api.getBlockReceipts?.(h))
|
|
62
59
|
if (sources.some((api) => api.traceBlockErigon))
|
|
63
|
-
base.traceBlockErigon = (
|
|
64
|
-
tryInOrder('traceBlockErigon', (api) => api.traceBlockErigon?.(
|
|
60
|
+
base.traceBlockErigon = (h): Promise<TraceBlockItem[]> =>
|
|
61
|
+
tryInOrder('traceBlockErigon', (api) => api.traceBlockErigon?.(h))
|
|
65
62
|
if (sources.some((api) => api.traceBlockGeth))
|
|
66
|
-
base.traceBlockGeth = (
|
|
67
|
-
tryInOrder('traceBlockGeth', (api) => api.traceBlockGeth?.(
|
|
63
|
+
base.traceBlockGeth = (h): Promise<TraceBlockItem[]> =>
|
|
64
|
+
tryInOrder('traceBlockGeth', (api) => api.traceBlockGeth?.(h))
|
|
68
65
|
return base
|
|
69
66
|
}
|
|
70
67
|
|
package/src/nodeSources.ts
CHANGED
|
@@ -24,14 +24,22 @@ export function nodeSourcesFromList(sources: readonly string[]): NodeSourceList
|
|
|
24
24
|
throw new Error('nodeSources: at least one source is required')
|
|
25
25
|
}
|
|
26
26
|
const seen = new Set<string>()
|
|
27
|
-
|
|
27
|
+
const validated: NodeSource[] = []
|
|
28
|
+
for (const source of sources) {
|
|
28
29
|
if (!isNodeSource(source)) {
|
|
29
30
|
throw new Error(`nodeSources: invalid source "${source}"`)
|
|
30
31
|
}
|
|
31
32
|
if (seen.has(source)) throw new Error(`nodeSources: duplicate source "${source}"`)
|
|
32
33
|
seen.add(source)
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
validated.push(source)
|
|
35
|
+
}
|
|
36
|
+
const frozen = Object.freeze(validated)
|
|
37
|
+
if (isNodeSourceList(frozen)) return frozen
|
|
38
|
+
throw new Error('nodeSources: invalid list')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isNodeSourceList(sources: readonly NodeSource[]): sources is NodeSourceList {
|
|
42
|
+
return sources.length > 0 && new Set(sources).size === sources.length
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
/** Default: direct RPC node only. */
|
package/src/staking/abis.test.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
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 { getStakingABI, isPayable } from './abis'
|
|
5
6
|
|
|
6
7
|
describe('getStakingABI', () => {
|
|
7
8
|
it('should return SEI ABI for sei_evm', () => {
|
|
8
|
-
const abi = getStakingABI(
|
|
9
|
+
const abi = getStakingABI(CHAIN_ID.SEI_EVM)
|
|
9
10
|
expect(abi).toBeInstanceOf(Array)
|
|
10
11
|
expect(abi?.length).toBeGreaterThan(0)
|
|
11
12
|
})
|
|
12
13
|
|
|
13
14
|
it('should return CELO ABI for celo', () => {
|
|
14
|
-
const abi = getStakingABI(
|
|
15
|
+
const abi = getStakingABI(CHAIN_ID.CELO)
|
|
15
16
|
expect(abi).toBeInstanceOf(Array)
|
|
16
17
|
expect(abi?.length).toBeGreaterThan(0)
|
|
17
18
|
})
|
|
18
19
|
|
|
19
20
|
it('should return Monad ABI for monad', () => {
|
|
20
|
-
const abi = getStakingABI(
|
|
21
|
+
const abi = getStakingABI(CHAIN_ID.MONAD)
|
|
21
22
|
expect(abi).toBeInstanceOf(Array)
|
|
22
23
|
expect(abi?.length).toBeGreaterThan(0)
|
|
23
24
|
})
|
|
24
25
|
|
|
25
26
|
it('should return undefined for unsupported currency', () => {
|
|
26
|
-
const abi = getStakingABI(
|
|
27
|
+
const abi = getStakingABI(CHAIN_ID.ETHEREUM)
|
|
27
28
|
expect(abi).toBeUndefined()
|
|
28
29
|
})
|
|
29
30
|
})
|
|
@@ -31,83 +32,83 @@ describe('getStakingABI', () => {
|
|
|
31
32
|
describe('isPayable', () => {
|
|
32
33
|
describe('SEI Network', () => {
|
|
33
34
|
it('should return true for delegate function (payable)', () => {
|
|
34
|
-
const result = isPayable(
|
|
35
|
+
const result = isPayable(CHAIN_ID.SEI_EVM, 'delegate')
|
|
35
36
|
expect(result).toBe(true)
|
|
36
37
|
})
|
|
37
38
|
|
|
38
39
|
it('should return false for undelegate function (nonpayable)', () => {
|
|
39
|
-
const result = isPayable(
|
|
40
|
+
const result = isPayable(CHAIN_ID.SEI_EVM, 'undelegate')
|
|
40
41
|
expect(result).toBe(false)
|
|
41
42
|
})
|
|
42
43
|
|
|
43
44
|
it('should return false for redelegate function (nonpayable)', () => {
|
|
44
|
-
const result = isPayable(
|
|
45
|
+
const result = isPayable(CHAIN_ID.SEI_EVM, 'redelegate')
|
|
45
46
|
expect(result).toBe(false)
|
|
46
47
|
})
|
|
47
48
|
|
|
48
49
|
it('should return false for delegation function (view)', () => {
|
|
49
|
-
const result = isPayable(
|
|
50
|
+
const result = isPayable(CHAIN_ID.SEI_EVM, 'delegation')
|
|
50
51
|
expect(result).toBe(false)
|
|
51
52
|
})
|
|
52
53
|
|
|
53
54
|
it('should return false for withdrawDelegationRewards function (nonpayable)', () => {
|
|
54
|
-
const result = isPayable(
|
|
55
|
+
const result = isPayable(CHAIN_ID.SEI_EVM, 'withdrawDelegationRewards')
|
|
55
56
|
expect(result).toBe(false)
|
|
56
57
|
})
|
|
57
58
|
|
|
58
59
|
it('should return false for non-existent function', () => {
|
|
59
|
-
const result = isPayable(
|
|
60
|
+
const result = isPayable(CHAIN_ID.SEI_EVM, 'nonExistentFunction')
|
|
60
61
|
expect(result).toBe(false)
|
|
61
62
|
})
|
|
62
63
|
})
|
|
63
64
|
|
|
64
65
|
describe('Monad', () => {
|
|
65
66
|
it('should return true for delegate function (payable)', () => {
|
|
66
|
-
expect(isPayable(
|
|
67
|
+
expect(isPayable(CHAIN_ID.MONAD, 'delegate')).toBe(true)
|
|
67
68
|
})
|
|
68
69
|
|
|
69
70
|
it('should return false for undelegate function (nonpayable)', () => {
|
|
70
|
-
expect(isPayable(
|
|
71
|
+
expect(isPayable(CHAIN_ID.MONAD, 'undelegate')).toBe(false)
|
|
71
72
|
})
|
|
72
73
|
|
|
73
74
|
it('should return false for claimRewards function (nonpayable)', () => {
|
|
74
|
-
expect(isPayable(
|
|
75
|
+
expect(isPayable(CHAIN_ID.MONAD, 'claimRewards')).toBe(false)
|
|
75
76
|
})
|
|
76
77
|
|
|
77
78
|
it('should return false for getDelegator function (nonpayable — precompile getter)', () => {
|
|
78
|
-
expect(isPayable(
|
|
79
|
+
expect(isPayable(CHAIN_ID.MONAD, 'getDelegator')).toBe(false)
|
|
79
80
|
})
|
|
80
81
|
|
|
81
82
|
it('should return false for non-existent function', () => {
|
|
82
|
-
expect(isPayable(
|
|
83
|
+
expect(isPayable(CHAIN_ID.MONAD, 'nonExistentFunction')).toBe(false)
|
|
83
84
|
})
|
|
84
85
|
})
|
|
85
86
|
|
|
86
87
|
describe('CELO', () => {
|
|
87
88
|
it('should return false for delegateGovernanceVotes function (nonpayable)', () => {
|
|
88
|
-
const result = isPayable(
|
|
89
|
+
const result = isPayable(CHAIN_ID.CELO, 'delegateGovernanceVotes')
|
|
89
90
|
expect(result).toBe(false)
|
|
90
91
|
})
|
|
91
92
|
|
|
92
93
|
it('should return false for revokeDelegatedGovernanceVotes function (nonpayable)', () => {
|
|
93
|
-
const result = isPayable(
|
|
94
|
+
const result = isPayable(CHAIN_ID.CELO, 'revokeDelegatedGovernanceVotes')
|
|
94
95
|
expect(result).toBe(false)
|
|
95
96
|
})
|
|
96
97
|
|
|
97
98
|
it('should return false for getAccountTotalLockedGold function (view)', () => {
|
|
98
|
-
const result = isPayable(
|
|
99
|
+
const result = isPayable(CHAIN_ID.CELO, 'getAccountTotalLockedGold')
|
|
99
100
|
expect(result).toBe(false)
|
|
100
101
|
})
|
|
101
102
|
|
|
102
103
|
it('should return false for getTotalPendingWithdrawals function (view)', () => {
|
|
103
|
-
const result = isPayable(
|
|
104
|
+
const result = isPayable(CHAIN_ID.CELO, 'getTotalPendingWithdrawals')
|
|
104
105
|
expect(result).toBe(false)
|
|
105
106
|
})
|
|
106
107
|
})
|
|
107
108
|
|
|
108
109
|
describe('0G / zero_gravity', () => {
|
|
109
110
|
it('returns the zero_gravity ABI', () => {
|
|
110
|
-
const abi = getStakingABI(
|
|
111
|
+
const abi = getStakingABI(CHAIN_ID.ZERO_GRAVITY)
|
|
111
112
|
expect(abi).toBeInstanceOf(Array)
|
|
112
113
|
expect(abi?.length).toBeGreaterThan(0)
|
|
113
114
|
})
|
|
@@ -118,23 +119,18 @@ describe('isPayable', () => {
|
|
|
118
119
|
['getDelegation', false],
|
|
119
120
|
['convertToTokens', false],
|
|
120
121
|
])('isPayable(%s) returns %s', (fn, expected) => {
|
|
121
|
-
expect(isPayable(
|
|
122
|
+
expect(isPayable(CHAIN_ID.ZERO_GRAVITY, fn)).toBe(expected)
|
|
122
123
|
})
|
|
123
124
|
})
|
|
124
125
|
|
|
125
126
|
describe('Edge cases', () => {
|
|
126
127
|
it('should return false for unsupported currency', () => {
|
|
127
|
-
const result = isPayable(
|
|
128
|
+
const result = isPayable(CHAIN_ID.ETHEREUM, 'delegate')
|
|
128
129
|
expect(result).toBe(false)
|
|
129
130
|
})
|
|
130
131
|
|
|
131
132
|
it('should return false for empty function name', () => {
|
|
132
|
-
const result = isPayable(
|
|
133
|
-
expect(result).toBe(false)
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
it('should return false for empty currency ID', () => {
|
|
137
|
-
const result = isPayable('', 'delegate')
|
|
133
|
+
const result = isPayable(CHAIN_ID.SEI_EVM, '')
|
|
138
134
|
expect(result).toBe(false)
|
|
139
135
|
})
|
|
140
136
|
})
|
package/src/staking/abis.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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 celoAbi from '../abis/celo.abi.json'
|
|
5
6
|
import monadAbi from '../abis/monad.abi.json'
|
|
6
7
|
import seiDistributionAbi from '../abis/sei-distribution.abi.json'
|
|
7
8
|
import seiAbi from '../abis/sei.abi.json'
|
|
8
9
|
import somniaAbi from '../abis/somnia.abi.json'
|
|
9
10
|
import zeroGravityValidatorAbi from '../abis/zero_gravity-validator.abi.json'
|
|
11
|
+
import { CHAIN_ID } from '../config'
|
|
10
12
|
|
|
11
13
|
type StakingABI =
|
|
12
14
|
| typeof seiDistributionAbi
|
|
@@ -23,12 +25,12 @@ interface ABIFunction {
|
|
|
23
25
|
anonymous?: boolean
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
const STAKING_ABIS: Record<
|
|
28
|
+
const STAKING_ABIS: Partial<Record<ChainId, StakingABI>> = {
|
|
27
29
|
// Sei EVM staking contract
|
|
28
|
-
|
|
30
|
+
[CHAIN_ID.SEI_EVM]: [...seiAbi, ...seiDistributionAbi],
|
|
29
31
|
|
|
30
32
|
// Celo staking contract
|
|
31
|
-
|
|
33
|
+
[CHAIN_ID.CELO]: celoAbi,
|
|
32
34
|
|
|
33
35
|
// Monad staking precompile.
|
|
34
36
|
// Note: all getter functions (getDelegator, getValidator, etc.) are marked
|
|
@@ -36,24 +38,24 @@ const STAKING_ABIS: Record<string, StakingABI> = {
|
|
|
36
38
|
// not a regular Solidity contract. The precompile can consume all gas on
|
|
37
39
|
// invalid arguments, so "view" semantics do not apply.
|
|
38
40
|
// Source: https://docs.monad.xyz/reference/staking/api (Staking ABI JSON)
|
|
39
|
-
|
|
41
|
+
[CHAIN_ID.MONAD]: monadAbi,
|
|
40
42
|
|
|
41
43
|
// 0G validator contract (per-validator dynamic address - factory-per-validator model).
|
|
42
44
|
// Source: https://docs.0g.ai/developer-hub/building-on-0g/contracts-on-0g/validator-contract-functions
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
[CHAIN_ID.ZERO_GRAVITY]: zeroGravityValidatorAbi,
|
|
46
|
+
[CHAIN_ID.SOMNIA]: somniaAbi,
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
export const getStakingABI = (
|
|
48
|
-
return STAKING_ABIS[
|
|
49
|
+
export const getStakingABI = (chainId: ChainId): StakingABI | undefined => {
|
|
50
|
+
return STAKING_ABIS[chainId]
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
54
|
* Checks if state mutability of a function in the ABI is payable
|
|
53
55
|
* (useful for staking operations)
|
|
54
56
|
*/
|
|
55
|
-
export const isPayable = (
|
|
56
|
-
const abi = getStakingABI(
|
|
57
|
+
export const isPayable = (chainId: ChainId, functionName: string): boolean => {
|
|
58
|
+
const abi = getStakingABI(chainId)
|
|
57
59
|
if (!abi) {
|
|
58
60
|
return false
|
|
59
61
|
}
|
|
@@ -1,22 +1,34 @@
|
|
|
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 { getStakingContractAddress } from './contracts'
|
|
5
6
|
|
|
6
7
|
describe('getStakingContractAddress', () => {
|
|
7
8
|
it.each([
|
|
8
|
-
['0x55E1A0C8f376964bd339167476063bFED7f213d5', 'celo', undefined],
|
|
9
|
-
['0x0000000000000000000000000000000000001000', 'monad', undefined],
|
|
10
|
-
[
|
|
11
|
-
|
|
9
|
+
['0x55E1A0C8f376964bd339167476063bFED7f213d5', 'celo', CHAIN_ID.CELO, undefined],
|
|
10
|
+
['0x0000000000000000000000000000000000001000', 'monad', CHAIN_ID.MONAD, undefined],
|
|
11
|
+
[
|
|
12
|
+
'0x0000000000000000000000000000000000001005',
|
|
13
|
+
'sei_evm',
|
|
14
|
+
CHAIN_ID.SEI_EVM,
|
|
15
|
+
{ mode: 'delegate' },
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
'0x0000000000000000000000000000000000001007',
|
|
19
|
+
'sei_evm',
|
|
20
|
+
CHAIN_ID.SEI_EVM,
|
|
21
|
+
{ mode: 'claimReward' },
|
|
22
|
+
],
|
|
12
23
|
[
|
|
13
24
|
'0x1111111111111111111111111111111111111111',
|
|
14
25
|
'zero_gravity',
|
|
26
|
+
CHAIN_ID.ZERO_GRAVITY,
|
|
15
27
|
{ mode: 'delegate', valAddress: '0x1111111111111111111111111111111111111111' },
|
|
16
28
|
],
|
|
17
|
-
[undefined, 'zero_gravity', { mode: 'delegate' }],
|
|
18
|
-
[undefined, 'unknown_chain', undefined],
|
|
19
|
-
] as const)('returns %s for %s', (expected,
|
|
20
|
-
expect(getStakingContractAddress(
|
|
29
|
+
[undefined, 'zero_gravity', CHAIN_ID.ZERO_GRAVITY, { mode: 'delegate' }],
|
|
30
|
+
[undefined, 'unknown_chain', CHAIN_ID.ETHEREUM, undefined],
|
|
31
|
+
] as const)('returns %s for %s', (expected, _name, chainId, ctx) => {
|
|
32
|
+
expect(getStakingContractAddress(chainId, ctx)).toEqual(expected)
|
|
21
33
|
})
|
|
22
34
|
})
|
package/src/staking/contracts.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
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 { StakingContractConfig, StakingOperation } from '../types/staking'
|
|
5
6
|
import { BigNumber } from 'bignumber.js'
|
|
6
7
|
import { ethers } from 'ethers'
|
|
8
|
+
import { CHAIN_ID } from '../config'
|
|
7
9
|
import { withApi } from '../network/node/rpc.common'
|
|
8
10
|
import { isExternalNodeConfig } from '../network/node/types'
|
|
9
11
|
import { USEI_TO_EVM_SCALE } from './utils'
|
|
10
12
|
import { getValidatorAddressById } from './validators/monadResolver'
|
|
11
13
|
|
|
12
14
|
export function getStakingContractAddress(
|
|
13
|
-
|
|
15
|
+
chainId: ChainId,
|
|
14
16
|
ctx?: { mode: StakingOperation; valAddress?: string }
|
|
15
17
|
): string | undefined {
|
|
16
|
-
const config = STAKING_CONTRACTS[
|
|
18
|
+
const config = STAKING_CONTRACTS[chainId]
|
|
17
19
|
if (!config) return undefined
|
|
18
20
|
try {
|
|
19
21
|
return config.contractAddress(ctx)
|
|
@@ -22,11 +24,11 @@ export function getStakingContractAddress(
|
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
export const STAKING_CONTRACTS: Record<
|
|
27
|
+
export const STAKING_CONTRACTS: Partial<Record<ChainId, StakingContractConfig>> = {
|
|
26
28
|
// Sei EVM staking
|
|
27
29
|
// Source: https://docs.sei.io/evm/precompiles/staking
|
|
28
30
|
// claimReward routes to the distribution precompile: https://docs.sei.io/evm/precompiles/distribution
|
|
29
|
-
|
|
31
|
+
[CHAIN_ID.SEI_EVM]: {
|
|
30
32
|
contractAddress: (ctx) => {
|
|
31
33
|
switch (ctx?.mode) {
|
|
32
34
|
case 'claimReward':
|
|
@@ -113,7 +115,7 @@ export const STAKING_CONTRACTS: Record<string, StakingContractConfig> = {
|
|
|
113
115
|
|
|
114
116
|
// Celo staking
|
|
115
117
|
// Source: https://celo.blockscout.com/address/0x55E1A0C8f376964bd339167476063bFED7f213d5?tab=contract_source_code
|
|
116
|
-
|
|
118
|
+
[CHAIN_ID.CELO]: {
|
|
117
119
|
contractAddress: () => '0x55E1A0C8f376964bd339167476063bFED7f213d5',
|
|
118
120
|
value: ({ amount }) => amount,
|
|
119
121
|
functions: {
|
|
@@ -140,7 +142,7 @@ export const STAKING_CONTRACTS: Record<string, StakingContractConfig> = {
|
|
|
140
142
|
// Monad staking
|
|
141
143
|
// Source: https://docs.monad.xyz/reference/staking/api
|
|
142
144
|
// Source: https://docs.monad.xyz/monad-arch/consensus/staking
|
|
143
|
-
|
|
145
|
+
[CHAIN_ID.MONAD]: {
|
|
144
146
|
// Native staking precompile — address 0x1000
|
|
145
147
|
// There is no bytecode at this address; it is a precompile, not a smart contract.
|
|
146
148
|
contractAddress: () => '0x0000000000000000000000000000000000001000',
|
|
@@ -191,7 +193,7 @@ export const STAKING_CONTRACTS: Record<string, StakingContractConfig> = {
|
|
|
191
193
|
unbondingPeriodDays: 0.75,
|
|
192
194
|
resolveValidatorAddress: (config, d, _contractAddress, logger) => {
|
|
193
195
|
return typeof d[0] === 'bigint'
|
|
194
|
-
? getValidatorAddressById(config,
|
|
196
|
+
? getValidatorAddressById(config, d[0], logger)
|
|
195
197
|
: Promise.resolve(null)
|
|
196
198
|
},
|
|
197
199
|
resolveOperationAmount: async (_config, decoded, operationType) => {
|
|
@@ -208,7 +210,7 @@ export const STAKING_CONTRACTS: Record<string, StakingContractConfig> = {
|
|
|
208
210
|
|
|
209
211
|
// 0G staking - factory-per-validator model.
|
|
210
212
|
// Source: https://docs.0g.ai/developer-hub/building-on-0g/contracts-on-0g/validator-contract-functions
|
|
211
|
-
|
|
213
|
+
[CHAIN_ID.ZERO_GRAVITY]: {
|
|
212
214
|
contractAddress: (ctx) => {
|
|
213
215
|
const addr = ctx?.valAddress
|
|
214
216
|
if (!addr) throw new Error('0G staking requires a validator address')
|
|
@@ -238,7 +240,7 @@ export const STAKING_CONTRACTS: Record<string, StakingContractConfig> = {
|
|
|
238
240
|
resolveValidatorAddress: async (_config, _, contractAddress) => {
|
|
239
241
|
return contractAddress ? ethers.getAddress(contractAddress) : null
|
|
240
242
|
},
|
|
241
|
-
resolveOperationAmount: async (config, decoded, operationType,
|
|
243
|
+
resolveOperationAmount: async (config, decoded, operationType, contractAddress) => {
|
|
242
244
|
switch (operationType) {
|
|
243
245
|
case 'undelegate': {
|
|
244
246
|
const shares = decoded[1]
|
|
@@ -248,7 +250,6 @@ export const STAKING_CONTRACTS: Record<string, StakingContractConfig> = {
|
|
|
248
250
|
try {
|
|
249
251
|
return await withApi(
|
|
250
252
|
config,
|
|
251
|
-
currencyId,
|
|
252
253
|
async (provider) => {
|
|
253
254
|
const iface = new ethers.Interface([
|
|
254
255
|
'function convertToTokens(uint256 shares) view returns (uint256)',
|
|
@@ -274,12 +275,10 @@ export const STAKING_CONTRACTS: Record<string, StakingContractConfig> = {
|
|
|
274
275
|
return typeof shares !== 'bigint' || shares >= 10n ** 9n
|
|
275
276
|
},
|
|
276
277
|
gasMultiplier: ({ mode }) => {
|
|
277
|
-
return
|
|
278
|
-
? new BigNumber(1.2)
|
|
279
|
-
: new BigNumber(1)
|
|
278
|
+
return mode === 'delegate' || mode === 'undelegate' ? new BigNumber(1.2) : new BigNumber(1)
|
|
280
279
|
},
|
|
281
280
|
},
|
|
282
|
-
|
|
281
|
+
[CHAIN_ID.SOMNIA]: {
|
|
283
282
|
contractAddress: () => '0xBe367d410D96E1cAeF68C0632251072CDf1b8250',
|
|
284
283
|
functions: {
|
|
285
284
|
delegate: 'delegateStake',
|