@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 { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
|
|
5
5
|
import { ethers } from 'ethers'
|
|
6
|
+
import { CHAIN_ID } from '../config'
|
|
6
7
|
import { createMockEvmConfigInfo, mkExternalNode, testLogger } from '../fixtures/context.fixtures'
|
|
7
8
|
import { fetchRewards } from './rewards'
|
|
8
9
|
import { USEI_TO_EVM_SCALE } from './utils'
|
|
@@ -28,7 +29,7 @@ const EVM_ADDRESS = '0x1234567890abcdef1234567890abcdef12345678'
|
|
|
28
29
|
const COSMOS_ADDRESS = 'sei1defaultcosmosaddressfortest'
|
|
29
30
|
|
|
30
31
|
const mockNode = mkExternalNode({ uri: 'https://sei-evm.coin.ledger.com' })
|
|
31
|
-
const mockConfig = createMockEvmConfigInfo({ chainId:
|
|
32
|
+
const mockConfig = createMockEvmConfigInfo({ chainId: CHAIN_ID.SEI_EVM, node: mockNode })
|
|
32
33
|
|
|
33
34
|
type RewardCoin = { denom: string; amount: string }
|
|
34
35
|
const restResponse = (rewards: Array<{ validator_address: string; reward: RewardCoin[] }>) => ({
|
|
@@ -51,30 +52,32 @@ describe('fetchRewards', () => {
|
|
|
51
52
|
})
|
|
52
53
|
|
|
53
54
|
it.each([
|
|
54
|
-
{ case: '
|
|
55
|
+
{ case: 'chain without staking', chainId: CHAIN_ID.ETHEREUM, setup: () => undefined },
|
|
55
56
|
{
|
|
56
57
|
case: 'chain has no rewardsStrategy (e.g. Celo)',
|
|
57
|
-
|
|
58
|
+
chainId: CHAIN_ID.CELO,
|
|
58
59
|
setup: () => undefined,
|
|
59
60
|
},
|
|
60
61
|
{
|
|
61
62
|
case: 'REST call fails',
|
|
62
|
-
|
|
63
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
63
64
|
setup: () => mockNetwork.mockRejectedValue(new Error('network error')),
|
|
64
65
|
},
|
|
65
66
|
{
|
|
66
67
|
case: 'API response has no rewards array',
|
|
67
|
-
|
|
68
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
68
69
|
setup: () => mockNetwork.mockResolvedValue({ data: {} }),
|
|
69
70
|
},
|
|
70
71
|
{
|
|
71
72
|
case: 'address precompile call fails',
|
|
72
|
-
|
|
73
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
73
74
|
setup: () => mockGetSeiAddr.mockRejectedValueOnce(new Error('not associated')),
|
|
74
75
|
},
|
|
75
|
-
])('returns an empty map when $case', async ({
|
|
76
|
+
])('returns an empty map when $case', async ({ chainId, setup }) => {
|
|
76
77
|
setup()
|
|
77
|
-
expect(await fetchRewards(mockConfig,
|
|
78
|
+
expect(await fetchRewards({ ...mockConfig, chainId }, EVM_ADDRESS, testLogger)).toEqual(
|
|
79
|
+
new Map()
|
|
80
|
+
)
|
|
78
81
|
})
|
|
79
82
|
|
|
80
83
|
it('resolves the EVM address to its canonical Cosmos bech32 via the precompile', async () => {
|
|
@@ -82,12 +85,7 @@ describe('fetchRewards', () => {
|
|
|
82
85
|
mockGetSeiAddr.mockResolvedValueOnce(canonicalCosmosAddress)
|
|
83
86
|
mockNetwork.mockResolvedValueOnce(restResponse([]))
|
|
84
87
|
|
|
85
|
-
await fetchRewards(
|
|
86
|
-
mockConfig,
|
|
87
|
-
'sei_evm',
|
|
88
|
-
'0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3',
|
|
89
|
-
testLogger
|
|
90
|
-
)
|
|
88
|
+
await fetchRewards(mockConfig, '0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3', testLogger)
|
|
91
89
|
|
|
92
90
|
expect(mockNetwork.mock.calls[0][0]).toMatchObject({
|
|
93
91
|
url: expect.stringContaining(canonicalCosmosAddress),
|
|
@@ -105,7 +103,7 @@ describe('fetchRewards', () => {
|
|
|
105
103
|
])
|
|
106
104
|
)
|
|
107
105
|
|
|
108
|
-
const result = await fetchRewards(mockConfig,
|
|
106
|
+
const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
|
|
109
107
|
|
|
110
108
|
expect(result.size).toBe(1)
|
|
111
109
|
expect(result.get('seivaloper1one')).toBe(569n * USEI_TO_EVM_SCALE)
|
|
@@ -124,7 +122,7 @@ describe('fetchRewards', () => {
|
|
|
124
122
|
])
|
|
125
123
|
)
|
|
126
124
|
|
|
127
|
-
const result = await fetchRewards(mockConfig,
|
|
125
|
+
const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
|
|
128
126
|
|
|
129
127
|
expect(result.get('seivaloper1one')).toBe(123n * USEI_TO_EVM_SCALE)
|
|
130
128
|
})
|
|
@@ -142,7 +140,7 @@ describe('fetchRewards', () => {
|
|
|
142
140
|
])
|
|
143
141
|
)
|
|
144
142
|
|
|
145
|
-
const result = await fetchRewards(mockConfig,
|
|
143
|
+
const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
|
|
146
144
|
|
|
147
145
|
expect(result.get('seivaloper1one')).toBe(500n * USEI_TO_EVM_SCALE)
|
|
148
146
|
})
|
|
@@ -158,7 +156,7 @@ describe('fetchRewards', () => {
|
|
|
158
156
|
])
|
|
159
157
|
)
|
|
160
158
|
|
|
161
|
-
const result = await fetchRewards(mockConfig,
|
|
159
|
+
const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
|
|
162
160
|
|
|
163
161
|
expect(result.has('seivaloper1dust')).toBe(false)
|
|
164
162
|
expect(result.get('seivaloper1real')).toBe(42n * USEI_TO_EVM_SCALE)
|
|
@@ -173,7 +171,7 @@ describe('fetchRewards', () => {
|
|
|
173
171
|
])
|
|
174
172
|
)
|
|
175
173
|
|
|
176
|
-
const result = await fetchRewards(mockConfig,
|
|
174
|
+
const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
|
|
177
175
|
|
|
178
176
|
expect(result.size).toBe(3)
|
|
179
177
|
expect(result.get('seivaloper1a')).toBe(10n * USEI_TO_EVM_SCALE)
|
|
@@ -191,7 +189,7 @@ describe('fetchRewards', () => {
|
|
|
191
189
|
])
|
|
192
190
|
)
|
|
193
191
|
|
|
194
|
-
const result = await fetchRewards(mockConfig,
|
|
192
|
+
const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
|
|
195
193
|
|
|
196
194
|
expect(result.has('seivaloper1bad')).toBe(false)
|
|
197
195
|
})
|
|
@@ -209,7 +207,7 @@ describe('fetchRewards', () => {
|
|
|
209
207
|
])
|
|
210
208
|
)
|
|
211
209
|
|
|
212
|
-
const result = await fetchRewards(mockConfig,
|
|
210
|
+
const result = await fetchRewards(mockConfig, EVM_ADDRESS, testLogger)
|
|
213
211
|
|
|
214
212
|
expect(result.get('seivaloper1mixed')).toBe(100n * USEI_TO_EVM_SCALE)
|
|
215
213
|
})
|
package/src/staking/rewards.ts
CHANGED
|
@@ -59,12 +59,11 @@ async function fetchCosmosRestRewards(
|
|
|
59
59
|
// back to zero without blocking the staking sync.
|
|
60
60
|
export async function fetchRewards(
|
|
61
61
|
evmConfig: EvmConfigInfo,
|
|
62
|
-
currencyId: string,
|
|
63
62
|
evmAddress: string,
|
|
64
63
|
logger: Logger
|
|
65
64
|
): Promise<Map<string, bigint>> {
|
|
66
65
|
try {
|
|
67
|
-
const config = STAKING_CONTRACTS[
|
|
66
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
68
67
|
const strategy = config?.rewardsStrategy
|
|
69
68
|
if (!strategy || strategy.type === 'none') return new Map()
|
|
70
69
|
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import type { LogWithAddress } from '../network/node/types'
|
|
5
5
|
import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
|
+
import { CHAIN_ID } from '../config'
|
|
6
7
|
import { testLogger } from '../fixtures/context.fixtures'
|
|
7
|
-
import {
|
|
8
|
+
import { requireStakingContract } from '../fixtures/staking.fixtures'
|
|
8
9
|
import { enrichRewardOperationsValue, sumRewardFromReceiptLogs } from './rewardsFromReceipt'
|
|
9
10
|
|
|
10
|
-
const MONAD_DECODER =
|
|
11
|
-
const SEI_DECODER =
|
|
11
|
+
const MONAD_DECODER = requireStakingContract(CHAIN_ID.MONAD).rewardsEventDecoder!
|
|
12
|
+
const SEI_DECODER = requireStakingContract(CHAIN_ID.SEI_EVM).rewardsEventDecoder!
|
|
12
13
|
|
|
13
14
|
const MONAD_STAKING = '0x0000000000000000000000000000000000001000'
|
|
14
15
|
const SEI_DISTRIBUTION = '0x0000000000000000000000000000000000001007'
|
|
@@ -108,17 +109,17 @@ describe('enrichRewardOperationsValue', () => {
|
|
|
108
109
|
.fn()
|
|
109
110
|
.mockResolvedValue({ logs: [monadClaimRewardsLog(MONAD_DELEGATOR_TOPIC, '030405ea888e')] })
|
|
110
111
|
|
|
111
|
-
await enrichRewardOperationsValue(
|
|
112
|
+
await enrichRewardOperationsValue(CHAIN_ID.MONAD, [op], getReceipt, testLogger)
|
|
112
113
|
|
|
113
114
|
expect(getReceipt).toHaveBeenCalledWith('0xabc')
|
|
114
115
|
expect(op.value).toStrictEqual(3315814008974n)
|
|
115
116
|
})
|
|
116
117
|
|
|
117
|
-
it('is a no-op for a
|
|
118
|
+
it('is a no-op for a chain without a rewardsEventDecoder', async () => {
|
|
118
119
|
const op = rewardOp('0xabc', MONAD_DELEGATOR)
|
|
119
120
|
const getReceipt = jest.fn()
|
|
120
121
|
|
|
121
|
-
await enrichRewardOperationsValue(
|
|
122
|
+
await enrichRewardOperationsValue(CHAIN_ID.ETHEREUM, [op], getReceipt, testLogger)
|
|
122
123
|
|
|
123
124
|
expect(getReceipt).not.toHaveBeenCalled()
|
|
124
125
|
expect(op.value).toStrictEqual(0n)
|
|
@@ -135,7 +136,7 @@ describe('enrichRewardOperationsValue', () => {
|
|
|
135
136
|
}
|
|
136
137
|
const getReceipt = jest.fn().mockResolvedValue(null)
|
|
137
138
|
|
|
138
|
-
await enrichRewardOperationsValue(
|
|
139
|
+
await enrichRewardOperationsValue(CHAIN_ID.MONAD, [out, nonZero], getReceipt, testLogger)
|
|
139
140
|
|
|
140
141
|
expect(getReceipt).not.toHaveBeenCalled()
|
|
141
142
|
})
|
|
@@ -144,7 +145,7 @@ describe('enrichRewardOperationsValue', () => {
|
|
|
144
145
|
const op = rewardOp('0xabc', MONAD_DELEGATOR)
|
|
145
146
|
const getReceipt = jest.fn().mockRejectedValue(new Error('rpc down'))
|
|
146
147
|
|
|
147
|
-
await enrichRewardOperationsValue(
|
|
148
|
+
await enrichRewardOperationsValue(CHAIN_ID.MONAD, [op], getReceipt, testLogger)
|
|
148
149
|
|
|
149
150
|
expect(op.value).toStrictEqual(0n)
|
|
150
151
|
})
|
|
@@ -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 { LogWithAddress } from '../network/node/types'
|
|
5
6
|
import type { RewardsEventDecoder } from '../types/staking'
|
|
6
7
|
import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
@@ -72,12 +73,12 @@ export function sumRewardFromReceiptLogs(
|
|
|
72
73
|
* untouched (amount falls back to 0) rather than blocking sync.
|
|
73
74
|
*/
|
|
74
75
|
export async function enrichRewardOperationsValue(
|
|
75
|
-
|
|
76
|
+
chainId: ChainId,
|
|
76
77
|
operations: Array<Operation<MemoNotSupported>>,
|
|
77
78
|
getReceipt: ReceiptFetcher,
|
|
78
79
|
logger: Logger
|
|
79
80
|
): Promise<void> {
|
|
80
|
-
const decoder = STAKING_CONTRACTS[
|
|
81
|
+
const decoder = STAKING_CONTRACTS[chainId]?.rewardsEventDecoder
|
|
81
82
|
if (!decoder) {
|
|
82
83
|
return
|
|
83
84
|
}
|
|
@@ -1,14 +1,24 @@
|
|
|
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 { MemoNotSupported } from '@ledgerhq/coin-module-framework/api/index'
|
|
5
6
|
import type { BufferTxData } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
7
|
import { createStakingTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
|
|
7
8
|
import { ethers } from 'ethers'
|
|
9
|
+
import { CHAIN_ID } from '../config'
|
|
10
|
+
import { createMockEvmConfigInfo, mkExternalNode } from '../fixtures/context.fixtures'
|
|
11
|
+
import { requireStakingContract } from '../fixtures/staking.fixtures'
|
|
8
12
|
import { getStakingABI } from './abis'
|
|
9
|
-
import { STAKING_CONTRACTS } from './contracts'
|
|
10
13
|
import { buildStakingTransactionParams } from './transactionData'
|
|
11
14
|
|
|
15
|
+
const mkConfig = (chainId: ChainId, name: string) =>
|
|
16
|
+
createMockEvmConfigInfo({ chainId, name, node: mkExternalNode() })
|
|
17
|
+
|
|
18
|
+
const monadConfig = mkConfig(CHAIN_ID.MONAD, 'monad')
|
|
19
|
+
const seiConfig = mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm')
|
|
20
|
+
const zeroGravityConfig = mkConfig(CHAIN_ID.ZERO_GRAVITY, 'zero_gravity')
|
|
21
|
+
|
|
12
22
|
const delegateIntent = (fields: Record<string, unknown>) =>
|
|
13
23
|
Object.assign(
|
|
14
24
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
@@ -30,9 +40,9 @@ describe('buildStakingTransactionParams', () => {
|
|
|
30
40
|
valAddress: '0xDisplayAddressIgnoredByEncoder',
|
|
31
41
|
})
|
|
32
42
|
|
|
33
|
-
const { to, data, value } = buildStakingTransactionParams(
|
|
43
|
+
const { to, data, value } = buildStakingTransactionParams(monadConfig, intent)
|
|
34
44
|
|
|
35
|
-
const iface = new ethers.Interface(getStakingABI(
|
|
45
|
+
const iface = new ethers.Interface(getStakingABI(CHAIN_ID.MONAD) ?? [])
|
|
36
46
|
expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('delegate', [42n]))
|
|
37
47
|
expect(to).toEqual('0x0000000000000000000000000000000000001000')
|
|
38
48
|
expect(value).toEqual(1000000000000000000n)
|
|
@@ -46,9 +56,9 @@ describe('buildStakingTransactionParams', () => {
|
|
|
46
56
|
valAddress: '0xDisplayAddressIgnoredByEncoder',
|
|
47
57
|
})
|
|
48
58
|
|
|
49
|
-
const { to, data, value } = buildStakingTransactionParams(
|
|
59
|
+
const { to, data, value } = buildStakingTransactionParams(monadConfig, intent)
|
|
50
60
|
|
|
51
|
-
const iface = new ethers.Interface(getStakingABI(
|
|
61
|
+
const iface = new ethers.Interface(getStakingABI(CHAIN_ID.MONAD) ?? [])
|
|
52
62
|
expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('compound', [42n]))
|
|
53
63
|
expect(to).toEqual('0x0000000000000000000000000000000000001000')
|
|
54
64
|
expect(value).toEqual(0n)
|
|
@@ -56,7 +66,7 @@ describe('buildStakingTransactionParams', () => {
|
|
|
56
66
|
|
|
57
67
|
it('throws when a Monad delegate intent has no valId', () => {
|
|
58
68
|
expect(() => {
|
|
59
|
-
buildStakingTransactionParams(
|
|
69
|
+
buildStakingTransactionParams(monadConfig, delegateIntent({}))
|
|
60
70
|
}).toThrow('monad staking requires valId')
|
|
61
71
|
})
|
|
62
72
|
|
|
@@ -68,9 +78,9 @@ describe('buildStakingTransactionParams', () => {
|
|
|
68
78
|
valAddress: '0xDisplayAddressIgnoredByEncoder',
|
|
69
79
|
})
|
|
70
80
|
|
|
71
|
-
const { to, data, value } = buildStakingTransactionParams(
|
|
81
|
+
const { to, data, value } = buildStakingTransactionParams(monadConfig, intent)
|
|
72
82
|
|
|
73
|
-
const iface = new ethers.Interface(getStakingABI(
|
|
83
|
+
const iface = new ethers.Interface(getStakingABI(CHAIN_ID.MONAD) ?? [])
|
|
74
84
|
expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('withdraw', [42n, 7n]))
|
|
75
85
|
expect(to).toEqual('0x0000000000000000000000000000000000001000')
|
|
76
86
|
expect(value).toEqual(0n)
|
|
@@ -78,7 +88,7 @@ describe('buildStakingTransactionParams', () => {
|
|
|
78
88
|
|
|
79
89
|
it('throws when a Monad withdraw intent has no withdrawId', () => {
|
|
80
90
|
expect(() => {
|
|
81
|
-
buildStakingTransactionParams(
|
|
91
|
+
buildStakingTransactionParams(monadConfig, delegateIntent({ mode: 'withdraw', valId: '42' }))
|
|
82
92
|
}).toThrow('monad withdraw requires withdrawId')
|
|
83
93
|
})
|
|
84
94
|
|
|
@@ -86,9 +96,9 @@ describe('buildStakingTransactionParams', () => {
|
|
|
86
96
|
const valAddress = 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn'
|
|
87
97
|
const intent = delegateIntent({ valAddress })
|
|
88
98
|
|
|
89
|
-
const { to, data, value } = buildStakingTransactionParams(
|
|
99
|
+
const { to, data, value } = buildStakingTransactionParams(seiConfig, intent)
|
|
90
100
|
|
|
91
|
-
const iface = new ethers.Interface(getStakingABI(
|
|
101
|
+
const iface = new ethers.Interface(getStakingABI(CHAIN_ID.SEI_EVM) ?? [])
|
|
92
102
|
expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('delegate', [valAddress]))
|
|
93
103
|
expect(to).toEqual('0x0000000000000000000000000000000000001005')
|
|
94
104
|
expect(value).toEqual(1000000000000000000n)
|
|
@@ -98,18 +108,18 @@ describe('buildStakingTransactionParams', () => {
|
|
|
98
108
|
const valAddress = 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn'
|
|
99
109
|
const intent = delegateIntent({ mode: 'claimReward', valAddress })
|
|
100
110
|
|
|
101
|
-
const { to } = buildStakingTransactionParams(
|
|
111
|
+
const { to } = buildStakingTransactionParams(seiConfig, intent)
|
|
102
112
|
|
|
103
113
|
expect(to).toEqual('0x0000000000000000000000000000000000001007')
|
|
104
114
|
})
|
|
105
115
|
|
|
106
116
|
it.each([
|
|
107
|
-
['sei_evm', { valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn' }],
|
|
108
|
-
['monad', { valId: '42', valAddress: '0xDisplayAddressIgnoredByEncoder' }],
|
|
109
|
-
])("ignores txValue for '%s'", (
|
|
117
|
+
['sei_evm', seiConfig, { valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn' }],
|
|
118
|
+
['monad', monadConfig, { valId: '42', valAddress: '0xDisplayAddressIgnoredByEncoder' }],
|
|
119
|
+
])("ignores txValue for '%s'", (_name, evmConfig, fields) => {
|
|
110
120
|
const intent = delegateIntent({ ...fields, txValue: 999n })
|
|
111
121
|
|
|
112
|
-
const { value } = buildStakingTransactionParams(
|
|
122
|
+
const { value } = buildStakingTransactionParams(evmConfig, intent)
|
|
113
123
|
|
|
114
124
|
expect(value).toEqual(1000000000000000000n)
|
|
115
125
|
})
|
|
@@ -122,9 +132,9 @@ describe('0G / zero_gravity delegate', () => {
|
|
|
122
132
|
sender: '0x0000000000000000000000000000000000000002',
|
|
123
133
|
})
|
|
124
134
|
|
|
125
|
-
const { to, data, value } = buildStakingTransactionParams(
|
|
135
|
+
const { to, data, value } = buildStakingTransactionParams(zeroGravityConfig, intent)
|
|
126
136
|
|
|
127
|
-
const iface = new ethers.Interface(getStakingABI(
|
|
137
|
+
const iface = new ethers.Interface(getStakingABI(CHAIN_ID.ZERO_GRAVITY) ?? [])
|
|
128
138
|
expect('0x' + data.toString('hex')).toEqual(
|
|
129
139
|
iface.encodeFunctionData('delegate', ['0x0000000000000000000000000000000000000002'])
|
|
130
140
|
)
|
|
@@ -134,14 +144,14 @@ describe('0G / zero_gravity delegate', () => {
|
|
|
134
144
|
|
|
135
145
|
it('throws when valAddress is missing', () => {
|
|
136
146
|
expect(() => {
|
|
137
|
-
buildStakingTransactionParams(
|
|
147
|
+
buildStakingTransactionParams(zeroGravityConfig, delegateIntent({ valAddress: '' }))
|
|
138
148
|
}).toThrow('0G staking requires a validator address')
|
|
139
149
|
})
|
|
140
150
|
|
|
141
151
|
it('throws when delegator is missing', () => {
|
|
142
152
|
expect(() => {
|
|
143
153
|
buildStakingTransactionParams(
|
|
144
|
-
|
|
154
|
+
zeroGravityConfig,
|
|
145
155
|
delegateIntent({ valAddress: '0x0000000000000000000000000000000000000001', sender: '' })
|
|
146
156
|
)
|
|
147
157
|
}).toThrow('zero_gravity staking requires delegator')
|
|
@@ -162,9 +172,9 @@ describe('0G / zero_gravity undelegate', () => {
|
|
|
162
172
|
txValue: 50_000_000_000n,
|
|
163
173
|
})
|
|
164
174
|
|
|
165
|
-
const { to, data, value } = buildStakingTransactionParams(
|
|
175
|
+
const { to, data, value } = buildStakingTransactionParams(zeroGravityConfig, intent)
|
|
166
176
|
|
|
167
|
-
const iface = new ethers.Interface(getStakingABI(
|
|
177
|
+
const iface = new ethers.Interface(getStakingABI(CHAIN_ID.ZERO_GRAVITY) ?? [])
|
|
168
178
|
expect('0x' + data.toString('hex')).toEqual(
|
|
169
179
|
iface.encodeFunctionData('undelegate', [DELEGATOR, 1_500_000_000n])
|
|
170
180
|
)
|
|
@@ -175,7 +185,7 @@ describe('0G / zero_gravity undelegate', () => {
|
|
|
175
185
|
it('throws when shares is missing', () => {
|
|
176
186
|
expect(() => {
|
|
177
187
|
buildStakingTransactionParams(
|
|
178
|
-
|
|
188
|
+
zeroGravityConfig,
|
|
179
189
|
delegateIntent({ mode: 'undelegate', valAddress: VAL })
|
|
180
190
|
)
|
|
181
191
|
}).toThrow('zero_gravity undelegate requires shares')
|
|
@@ -183,7 +193,7 @@ describe('0G / zero_gravity undelegate', () => {
|
|
|
183
193
|
})
|
|
184
194
|
|
|
185
195
|
describe('0G / zero_gravity contractAddress resolver', () => {
|
|
186
|
-
const config =
|
|
196
|
+
const config = requireStakingContract(CHAIN_ID.ZERO_GRAVITY)
|
|
187
197
|
|
|
188
198
|
it('returns valAddress when provided', () => {
|
|
189
199
|
expect(config.contractAddress({ mode: 'delegate', valAddress: '0xValidatorAddr' })).toEqual(
|
|
@@ -203,7 +213,7 @@ describe('0G / zero_gravity contractAddress resolver', () => {
|
|
|
203
213
|
})
|
|
204
214
|
|
|
205
215
|
describe('0G / zero_gravity value resolver', () => {
|
|
206
|
-
const config =
|
|
216
|
+
const config = requireStakingContract(CHAIN_ID.ZERO_GRAVITY)
|
|
207
217
|
|
|
208
218
|
it.each([
|
|
209
219
|
[{ mode: 'delegate', amount: 1000n }, 1000n],
|
|
@@ -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 { TransactionIntent, MemoNotSupported } from '@ledgerhq/coin-module-framework/api/index'
|
|
5
6
|
import { isStakingIntent } from '../logic-public'
|
|
6
7
|
import { isPayable } from './abis'
|
|
@@ -13,7 +14,7 @@ import { buildTransactionParams } from './operations'
|
|
|
13
14
|
* Builds transaction parameters for staking transactions
|
|
14
15
|
*/
|
|
15
16
|
export function buildStakingTransactionParams(
|
|
16
|
-
|
|
17
|
+
evmConfig: EvmConfigInfo,
|
|
17
18
|
intent: TransactionIntent<MemoNotSupported>
|
|
18
19
|
): {
|
|
19
20
|
to: string
|
|
@@ -27,16 +28,16 @@ export function buildStakingTransactionParams(
|
|
|
27
28
|
const { amount, sender, mode, valAddress, valId, dstValAddress, withdrawId, txValue, shares } =
|
|
28
29
|
intent
|
|
29
30
|
|
|
30
|
-
const config = STAKING_CONTRACTS[
|
|
31
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
31
32
|
if (!config) {
|
|
32
|
-
throw new Error(`Unsupported staking currency: ${
|
|
33
|
+
throw new Error(`Unsupported staking currency: ${evmConfig.name}`)
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
if (!mode || !isStakingOperation(mode)) {
|
|
36
37
|
throw new Error(`Invalid staking operation: ${mode}`)
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
const stakingParams = buildTransactionParams(
|
|
40
|
+
const stakingParams = buildTransactionParams(evmConfig, mode, {
|
|
40
41
|
valAddress,
|
|
41
42
|
valId,
|
|
42
43
|
amount,
|
|
@@ -49,7 +50,7 @@ export function buildStakingTransactionParams(
|
|
|
49
50
|
const to = config.contractAddress({ mode, valAddress })
|
|
50
51
|
const data = Buffer.from(
|
|
51
52
|
encodeStakingData({
|
|
52
|
-
|
|
53
|
+
evmConfig,
|
|
53
54
|
operation: mode,
|
|
54
55
|
config,
|
|
55
56
|
params: stakingParams,
|
|
@@ -62,7 +63,7 @@ export function buildStakingTransactionParams(
|
|
|
62
63
|
throw new Error(`No function mapping found for the operation: ${mode}`)
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
const value = isPayable(
|
|
66
|
+
const value = isPayable(evmConfig.chainId, functionName)
|
|
66
67
|
? config.value({ mode, amount, ...(typeof txValue === 'bigint' ? { txValue } : {}) })
|
|
67
68
|
: 0n
|
|
68
69
|
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
5
|
import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
|
|
6
6
|
import { ethers } from 'ethers'
|
|
7
|
+
import { CHAIN_ID } from '../config'
|
|
7
8
|
import { testLogger } from '../fixtures/context.fixtures'
|
|
8
|
-
import {
|
|
9
|
+
import { requireStakingContract } from '../fixtures/staking.fixtures'
|
|
9
10
|
import { fetchUnbondings } from './unbondings'
|
|
10
11
|
import { USEI_TO_EVM_SCALE } from './utils'
|
|
11
12
|
|
|
@@ -29,14 +30,13 @@ const mockIsExternalNodeConfig = jest.mocked(require('../network/node/types').is
|
|
|
29
30
|
const mockNode: EvmConfigInfo['node'] = { type: 'external', uri: 'https://sei-evm.coin.ledger.com' }
|
|
30
31
|
const mockConfig: EvmConfigInfo = {
|
|
31
32
|
status: { type: 'active' },
|
|
32
|
-
chainId:
|
|
33
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
33
34
|
name: 'Sei',
|
|
34
35
|
unit: { name: 'sei', code: 'SEI', magnitude: 18 },
|
|
35
36
|
node: mockNode,
|
|
36
37
|
explorer: { type: 'none' },
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
const SEI_CURRENCY = 'sei_evm'
|
|
40
40
|
const EVM_ADDRESS = '0x1111111111111111111111111111111111111111'
|
|
41
41
|
const VALIDATOR = 'seivaloper1qe8uuf5x69c526h4nzxwv4ltftr73v7qnkypla'
|
|
42
42
|
const OTHER_VALIDATOR = 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn'
|
|
@@ -79,38 +79,44 @@ describe('staking/unbondings', () => {
|
|
|
79
79
|
mockIsExternalNodeConfig.mockImplementation((node: unknown) => node === mockNode)
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
-
it('should return [] for
|
|
83
|
-
expect(
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
it('should return [] for a chain without staking', async () => {
|
|
83
|
+
expect(
|
|
84
|
+
await fetchUnbondings(
|
|
85
|
+
{ ...mockConfig, chainId: CHAIN_ID.ETHEREUM },
|
|
86
|
+
EVM_ADDRESS,
|
|
87
|
+
testLogger
|
|
88
|
+
)
|
|
89
|
+
).toEqual([])
|
|
86
90
|
expect(mockNetwork).not.toHaveBeenCalled()
|
|
87
91
|
})
|
|
88
92
|
|
|
89
|
-
it('should return [] for a
|
|
90
|
-
expect(
|
|
93
|
+
it('should return [] for a chain without an unbonding strategy', async () => {
|
|
94
|
+
expect(
|
|
95
|
+
await fetchUnbondings({ ...mockConfig, chainId: CHAIN_ID.CELO }, EVM_ADDRESS, testLogger)
|
|
96
|
+
).toEqual([])
|
|
91
97
|
expect(mockNetwork).not.toHaveBeenCalled()
|
|
92
98
|
})
|
|
93
99
|
|
|
94
100
|
it('should return [] when the address is not associated on-chain yet', async () => {
|
|
95
101
|
mockGetSeiAddr.mockResolvedValue(null)
|
|
96
|
-
expect(await fetchUnbondings(mockConfig,
|
|
102
|
+
expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
|
|
97
103
|
expect(mockNetwork).not.toHaveBeenCalled()
|
|
98
104
|
})
|
|
99
105
|
|
|
100
106
|
it('should return [] when the REST call fails', async () => {
|
|
101
107
|
mockNetwork.mockRejectedValue(new Error('network error'))
|
|
102
|
-
expect(await fetchUnbondings(mockConfig,
|
|
108
|
+
expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
|
|
103
109
|
})
|
|
104
110
|
|
|
105
111
|
it('should return [] when the response has no unbonding_responses array', async () => {
|
|
106
112
|
mockNetwork.mockResolvedValue({ data: {} })
|
|
107
|
-
expect(await fetchUnbondings(mockConfig,
|
|
113
|
+
expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
|
|
108
114
|
})
|
|
109
115
|
|
|
110
116
|
it('should query the delegator endpoint with the resolved Cosmos address', async () => {
|
|
111
117
|
mockNetwork.mockResolvedValue({ data: { unbonding_responses: [] } })
|
|
112
118
|
|
|
113
|
-
await fetchUnbondings(mockConfig,
|
|
119
|
+
await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
114
120
|
|
|
115
121
|
expect(mockNetwork).toHaveBeenCalledWith({
|
|
116
122
|
url: 'https://rest.sei-apis.com/cosmos/staking/v1beta1/delegators/sei1defaultcosmosaddressfortest/unbonding_delegations',
|
|
@@ -130,7 +136,7 @@ describe('staking/unbondings', () => {
|
|
|
130
136
|
},
|
|
131
137
|
})
|
|
132
138
|
|
|
133
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
139
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
134
140
|
|
|
135
141
|
expect(stakes).toHaveLength(1)
|
|
136
142
|
expect(stakes[0]).toMatchObject({
|
|
@@ -153,7 +159,7 @@ describe('staking/unbondings', () => {
|
|
|
153
159
|
},
|
|
154
160
|
})
|
|
155
161
|
|
|
156
|
-
const [stake] = await fetchUnbondings(mockConfig,
|
|
162
|
+
const [stake] = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
157
163
|
|
|
158
164
|
// Sei credits the funds back automatically: no withdraw transaction exists.
|
|
159
165
|
expect(stake.actions).toEqual([])
|
|
@@ -172,7 +178,7 @@ describe('staking/unbondings', () => {
|
|
|
172
178
|
},
|
|
173
179
|
})
|
|
174
180
|
|
|
175
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
181
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
176
182
|
|
|
177
183
|
expect(stakes).toHaveLength(2)
|
|
178
184
|
expect(new Set(stakes.map((s) => s.uid)).size).toBe(2)
|
|
@@ -194,7 +200,7 @@ describe('staking/unbondings', () => {
|
|
|
194
200
|
},
|
|
195
201
|
})
|
|
196
202
|
|
|
197
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
203
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
198
204
|
|
|
199
205
|
expect(stakes.map((s) => s.delegate)).toEqual([VALIDATOR, OTHER_VALIDATOR])
|
|
200
206
|
})
|
|
@@ -211,7 +217,7 @@ describe('staking/unbondings', () => {
|
|
|
211
217
|
},
|
|
212
218
|
})
|
|
213
219
|
|
|
214
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
220
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
215
221
|
|
|
216
222
|
expect(stakes).toHaveLength(1)
|
|
217
223
|
expect(stakes[0].amount).toBe(2000000n * USEI_TO_EVM_SCALE)
|
|
@@ -231,7 +237,7 @@ describe('staking/unbondings', () => {
|
|
|
231
237
|
},
|
|
232
238
|
})
|
|
233
239
|
|
|
234
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
240
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
235
241
|
|
|
236
242
|
expect(stakes).toHaveLength(1)
|
|
237
243
|
expect(stakes[0].amount).toBe(3000000n * USEI_TO_EVM_SCALE)
|
|
@@ -240,7 +246,7 @@ describe('staking/unbondings', () => {
|
|
|
240
246
|
|
|
241
247
|
describe('sei_evm unbonding strategy config', () => {
|
|
242
248
|
it('should be configured to read the Cosmos unbonding_delegations endpoint', () => {
|
|
243
|
-
expect(
|
|
249
|
+
expect(requireStakingContract(CHAIN_ID.SEI_EVM).unbondingStrategy).toEqual({
|
|
244
250
|
type: 'cosmos-rest',
|
|
245
251
|
endpoint: '/cosmos/staking/v1beta1/delegators/{address}/unbonding_delegations',
|
|
246
252
|
})
|
|
@@ -120,11 +120,10 @@ async function fetchCosmosRestUnbondings(
|
|
|
120
120
|
*/
|
|
121
121
|
export async function fetchUnbondings(
|
|
122
122
|
evmConfig: EvmConfigInfo,
|
|
123
|
-
currencyId: string,
|
|
124
123
|
evmAddress: string,
|
|
125
124
|
logger: Logger
|
|
126
125
|
): Promise<Stake[]> {
|
|
127
|
-
const config = STAKING_CONTRACTS[
|
|
126
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
128
127
|
const strategy = config?.unbondingStrategy
|
|
129
128
|
if (!config || !strategy || strategy.type === 'none') return []
|
|
130
129
|
|