@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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { Stake } from '@ledgerhq/coin-module-framework/api/types'
|
|
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 { createMockEvmConfigInfo, mkExternalNode } from '../fixtures/context.fixtures'
|
|
8
9
|
import {
|
|
9
10
|
canCompound,
|
|
@@ -29,7 +30,8 @@ jest.mock('../network/node/types')
|
|
|
29
30
|
const mockIsExternalNodeConfig = jest.mocked(require('../network/node/types').isExternalNodeConfig)
|
|
30
31
|
|
|
31
32
|
const mockNode = mkExternalNode({ uri: 'https://sei-evm.coin.ledger.com' })
|
|
32
|
-
const mockConfig = createMockEvmConfigInfo({ chainId:
|
|
33
|
+
const mockConfig = createMockEvmConfigInfo({ chainId: CHAIN_ID.ETHEREUM, node: mockNode })
|
|
34
|
+
const seiConfig = createMockEvmConfigInfo({ chainId: CHAIN_ID.SEI_EVM, node: mockNode })
|
|
33
35
|
|
|
34
36
|
function makeStake(delegate: string, overrides: Partial<Stake> = {}): Stake {
|
|
35
37
|
return {
|
|
@@ -49,20 +51,22 @@ describe('evm staking logic', () => {
|
|
|
49
51
|
const FUTURE = new Date(Date.now() + 86_400_000)
|
|
50
52
|
|
|
51
53
|
it('returns false for a chain without a redelegate precompile function (celo)', () => {
|
|
52
|
-
expect(canRedelegate(makeStake('0xvalidator'), [],
|
|
54
|
+
expect(canRedelegate(makeStake('0xvalidator'), [], CHAIN_ID.CELO)).toBe(false)
|
|
53
55
|
})
|
|
54
56
|
|
|
55
|
-
it('returns false for
|
|
56
|
-
expect(canRedelegate(makeStake('0xvalidator'), [],
|
|
57
|
+
it('returns false for a chain without staking', () => {
|
|
58
|
+
expect(canRedelegate(makeStake('0xvalidator'), [], CHAIN_ID.ETHEREUM)).toBe(false)
|
|
57
59
|
})
|
|
58
60
|
|
|
59
61
|
it('returns true for sei_evm when no active redelegations exist', () => {
|
|
60
|
-
expect(canRedelegate(makeStake('0xvalidator'), [],
|
|
62
|
+
expect(canRedelegate(makeStake('0xvalidator'), [], CHAIN_ID.SEI_EVM)).toBe(true)
|
|
61
63
|
})
|
|
62
64
|
|
|
63
65
|
it('returns false when the delegation is the destination of an active redelegation (cooldown)', () => {
|
|
64
66
|
const activeRedelegations = [{ validatorDstAddress: '0xvalidator', completionDate: FUTURE }]
|
|
65
|
-
expect(canRedelegate(makeStake('0xvalidator'), activeRedelegations,
|
|
67
|
+
expect(canRedelegate(makeStake('0xvalidator'), activeRedelegations, CHAIN_ID.SEI_EVM)).toBe(
|
|
68
|
+
false
|
|
69
|
+
)
|
|
66
70
|
})
|
|
67
71
|
|
|
68
72
|
it('returns false when the maxRedelegations cap is reached', () => {
|
|
@@ -70,36 +74,42 @@ describe('evm staking logic', () => {
|
|
|
70
74
|
validatorDstAddress: `0xdst${i}`,
|
|
71
75
|
completionDate: FUTURE,
|
|
72
76
|
}))
|
|
73
|
-
expect(canRedelegate(makeStake('0xother'), activeRedelegations,
|
|
77
|
+
expect(canRedelegate(makeStake('0xother'), activeRedelegations, CHAIN_ID.SEI_EVM)).toBe(false)
|
|
74
78
|
})
|
|
75
79
|
})
|
|
76
80
|
|
|
77
81
|
describe('canCompound', () => {
|
|
78
82
|
it('returns false for a chain without a compound precompile function (sei_evm)', () => {
|
|
79
|
-
expect(
|
|
83
|
+
expect(
|
|
84
|
+
canCompound(makeStake('0xvalidator', { amountRewarded: 100n }), CHAIN_ID.SEI_EVM)
|
|
85
|
+
).toBe(false)
|
|
80
86
|
})
|
|
81
87
|
|
|
82
88
|
it('returns false for monad when there are no pending rewards', () => {
|
|
83
|
-
expect(canCompound(makeStake('0xvalidator'),
|
|
89
|
+
expect(canCompound(makeStake('0xvalidator'), CHAIN_ID.MONAD)).toBe(false)
|
|
84
90
|
})
|
|
85
91
|
|
|
86
92
|
it('returns true for monad when there are pending rewards', () => {
|
|
87
|
-
expect(canCompound(makeStake('0xvalidator', { amountRewarded: 100n }),
|
|
93
|
+
expect(canCompound(makeStake('0xvalidator', { amountRewarded: 100n }), CHAIN_ID.MONAD)).toBe(
|
|
94
|
+
true
|
|
95
|
+
)
|
|
88
96
|
})
|
|
89
97
|
})
|
|
90
98
|
|
|
91
99
|
describe('canUndelegate', () => {
|
|
92
100
|
it('returns true for an active stake', () => {
|
|
93
|
-
expect(canUndelegate(makeStake('0xvalidator'),
|
|
101
|
+
expect(canUndelegate(makeStake('0xvalidator'), CHAIN_ID.MONAD)).toBe(true)
|
|
94
102
|
})
|
|
95
103
|
|
|
96
104
|
it('returns false for an activating stake', () => {
|
|
97
|
-
expect(canUndelegate(makeStake('0xvalidator', { state: 'activating' }),
|
|
105
|
+
expect(canUndelegate(makeStake('0xvalidator', { state: 'activating' }), CHAIN_ID.MONAD)).toBe(
|
|
106
|
+
false
|
|
107
|
+
)
|
|
98
108
|
})
|
|
99
109
|
|
|
100
110
|
it('returns false for 0G when shares is zero', () => {
|
|
101
111
|
expect(
|
|
102
|
-
canUndelegate(makeStake('0xvalidator', { details: { shares: 0n } }),
|
|
112
|
+
canUndelegate(makeStake('0xvalidator', { details: { shares: 0n } }), CHAIN_ID.ZERO_GRAVITY)
|
|
103
113
|
).toBe(false)
|
|
104
114
|
})
|
|
105
115
|
|
|
@@ -107,7 +117,7 @@ describe('evm staking logic', () => {
|
|
|
107
117
|
expect(
|
|
108
118
|
canUndelegate(
|
|
109
119
|
makeStake('0xvalidator', { details: { shares: 999_999_999n } }),
|
|
110
|
-
|
|
120
|
+
CHAIN_ID.ZERO_GRAVITY
|
|
111
121
|
)
|
|
112
122
|
).toBe(false)
|
|
113
123
|
})
|
|
@@ -116,13 +126,13 @@ describe('evm staking logic', () => {
|
|
|
116
126
|
expect(
|
|
117
127
|
canUndelegate(
|
|
118
128
|
makeStake('0xvalidator', { details: { shares: 1_000_000_000n } }),
|
|
119
|
-
|
|
129
|
+
CHAIN_ID.ZERO_GRAVITY
|
|
120
130
|
)
|
|
121
131
|
).toBe(true)
|
|
122
132
|
})
|
|
123
133
|
|
|
124
134
|
it('returns true for 0G when shares is undefined (legacy pre-sync account)', () => {
|
|
125
|
-
expect(canUndelegate(makeStake('0xvalidator'),
|
|
135
|
+
expect(canUndelegate(makeStake('0xvalidator'), CHAIN_ID.ZERO_GRAVITY)).toBe(true)
|
|
126
136
|
})
|
|
127
137
|
})
|
|
128
138
|
|
|
@@ -157,31 +167,25 @@ describe('evm staking logic', () => {
|
|
|
157
167
|
})
|
|
158
168
|
|
|
159
169
|
it('returns false for a non-sei_evm currency without querying the chain', async () => {
|
|
160
|
-
await expect(isSeiAccountUnassociated(mockConfig,
|
|
161
|
-
false
|
|
162
|
-
)
|
|
170
|
+
await expect(isSeiAccountUnassociated(mockConfig, SEI_ADDRESS)).resolves.toBe(false)
|
|
163
171
|
expect(mockGetSeiAddr).not.toHaveBeenCalled()
|
|
164
172
|
})
|
|
165
173
|
|
|
166
174
|
it('returns false when the currency has no external RPC node configured', async () => {
|
|
167
175
|
mockIsExternalNodeConfig.mockReturnValue(false)
|
|
168
|
-
await expect(isSeiAccountUnassociated(
|
|
169
|
-
false
|
|
170
|
-
)
|
|
176
|
+
await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(false)
|
|
171
177
|
expect(mockGetSeiAddr).not.toHaveBeenCalled()
|
|
172
178
|
})
|
|
173
179
|
|
|
174
180
|
it('returns true for sei_evm when the precompile resolves an empty string (unassociated)', async () => {
|
|
175
181
|
mockGetSeiAddr.mockResolvedValue('')
|
|
176
|
-
await expect(isSeiAccountUnassociated(
|
|
182
|
+
await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(true)
|
|
177
183
|
expect(mockGetSeiAddr).toHaveBeenCalledWith(SEI_ADDRESS)
|
|
178
184
|
})
|
|
179
185
|
|
|
180
186
|
it('returns false for sei_evm when the precompile resolves a linked Cosmos address', async () => {
|
|
181
187
|
mockGetSeiAddr.mockResolvedValue('sei1associatedcosmosaddress')
|
|
182
|
-
await expect(isSeiAccountUnassociated(
|
|
183
|
-
false
|
|
184
|
-
)
|
|
188
|
+
await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(false)
|
|
185
189
|
})
|
|
186
190
|
|
|
187
191
|
it('returns true when the precompile reverts (unassociated address)', async () => {
|
|
@@ -192,23 +196,21 @@ describe('evm staking logic', () => {
|
|
|
192
196
|
revert: null,
|
|
193
197
|
})
|
|
194
198
|
mockGetSeiAddr.mockRejectedValue(revert)
|
|
195
|
-
await expect(isSeiAccountUnassociated(
|
|
199
|
+
await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(true)
|
|
196
200
|
})
|
|
197
201
|
|
|
198
202
|
it('returns true when the precompile call fails for any other reason', async () => {
|
|
199
203
|
mockGetSeiAddr.mockRejectedValue(new Error('network error'))
|
|
200
|
-
await expect(isSeiAccountUnassociated(
|
|
204
|
+
await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(true)
|
|
201
205
|
})
|
|
202
206
|
|
|
203
207
|
it('returns true when the precompile returns an unexpected non-string result', async () => {
|
|
204
208
|
mockGetSeiAddr.mockResolvedValue(undefined)
|
|
205
|
-
await expect(isSeiAccountUnassociated(
|
|
209
|
+
await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(true)
|
|
206
210
|
})
|
|
207
211
|
|
|
208
212
|
it('returns false when the config carries no external RPC node', async () => {
|
|
209
|
-
await expect(isSeiAccountUnassociated(
|
|
210
|
-
false
|
|
211
|
-
)
|
|
213
|
+
await expect(isSeiAccountUnassociated(seiConfig, SEI_ADDRESS)).resolves.toBe(false)
|
|
212
214
|
})
|
|
213
215
|
})
|
|
214
216
|
})
|
package/src/staking/logic.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '../config'
|
|
4
|
+
import type { ChainId, EvmConfigInfo } from '../config'
|
|
5
5
|
import type { Stake } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
6
|
import { ethers } from 'ethers'
|
|
7
|
+
import { CHAIN_ID } from '../config'
|
|
7
8
|
import { isExternalNodeConfig } from '../network/node/types'
|
|
8
9
|
import { getStakingABI } from './abis'
|
|
9
10
|
import { STAKING_CONTRACTS } from './contracts'
|
|
@@ -11,10 +12,10 @@ import { getCosmosAddr } from './redelegations'
|
|
|
11
12
|
|
|
12
13
|
type RedelegationLike = { validatorDstAddress: string; completionDate: Date }
|
|
13
14
|
|
|
14
|
-
export function canUndelegate(stake: Stake,
|
|
15
|
+
export function canUndelegate(stake: Stake, chainId: ChainId): boolean {
|
|
15
16
|
// An activating stake is not yet in the active set, so it cannot be undelegated.
|
|
16
17
|
if (stake.state === 'activating') return false
|
|
17
|
-
const chainCanUndelegate = STAKING_CONTRACTS[
|
|
18
|
+
const chainCanUndelegate = STAKING_CONTRACTS[chainId]?.canUndelegate
|
|
18
19
|
if (chainCanUndelegate) return chainCanUndelegate(stake)
|
|
19
20
|
return true
|
|
20
21
|
}
|
|
@@ -38,13 +39,13 @@ export function canDelegate(spendableBalance: bigint): boolean {
|
|
|
38
39
|
export function canRedelegate(
|
|
39
40
|
stake: Stake,
|
|
40
41
|
activeRedelegations: RedelegationLike[],
|
|
41
|
-
|
|
42
|
+
chainId: ChainId
|
|
42
43
|
): boolean {
|
|
43
44
|
// The chain must expose a redelegate precompile function; without it the
|
|
44
45
|
// transaction will always fail, so the UI action should be hidden entirely.
|
|
45
|
-
if (!STAKING_CONTRACTS[
|
|
46
|
+
if (!STAKING_CONTRACTS[chainId]?.functions.redelegate) return false
|
|
46
47
|
|
|
47
|
-
const maxRedelegations = STAKING_CONTRACTS[
|
|
48
|
+
const maxRedelegations = STAKING_CONTRACTS[chainId]?.maxRedelegations
|
|
48
49
|
if (maxRedelegations !== undefined && activeRedelegations.length >= maxRedelegations) return false
|
|
49
50
|
|
|
50
51
|
// Cannot redelegate FROM a validator that currently holds an active incoming
|
|
@@ -53,10 +54,10 @@ export function canRedelegate(
|
|
|
53
54
|
return !activeRedelegations.some((rd) => rd.validatorDstAddress === stake.delegate)
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
export function canCompound(stake: Stake,
|
|
57
|
+
export function canCompound(stake: Stake, chainId: ChainId): boolean {
|
|
57
58
|
// The chain must expose a compound precompile function; without it the
|
|
58
59
|
// transaction will always fail, so the UI option should be hidden entirely.
|
|
59
|
-
if (!STAKING_CONTRACTS[
|
|
60
|
+
if (!STAKING_CONTRACTS[chainId]?.functions.compoundReward) return false
|
|
60
61
|
|
|
61
62
|
// Compounding restakes accrued rewards, so it only makes sense when there is
|
|
62
63
|
// something to restake.
|
|
@@ -84,12 +85,11 @@ export function parseAmountStringToNumber(amountString: string, unitCode: string
|
|
|
84
85
|
*/
|
|
85
86
|
export async function isSeiAccountUnassociated(
|
|
86
87
|
config: EvmConfigInfo,
|
|
87
|
-
currencyId: string,
|
|
88
88
|
freshAddress: string
|
|
89
89
|
): Promise<boolean> {
|
|
90
|
-
if (
|
|
90
|
+
if (config.chainId !== CHAIN_ID.SEI_EVM) return false
|
|
91
91
|
|
|
92
|
-
const precompile = STAKING_CONTRACTS[
|
|
92
|
+
const precompile = STAKING_CONTRACTS[config.chainId]?.apiConfig?.precompileAddress
|
|
93
93
|
if (!precompile) return false
|
|
94
94
|
|
|
95
95
|
// Resolve the RPC endpoint. A missing/non-external config means we cannot
|
|
@@ -116,12 +116,12 @@ export async function isSeiAccountUnassociated(
|
|
|
116
116
|
* absent or malformed so callers can fall back gracefully.
|
|
117
117
|
*/
|
|
118
118
|
export function decodeRedelegatePayload(
|
|
119
|
-
|
|
119
|
+
chainId: ChainId,
|
|
120
120
|
contractPayload: string
|
|
121
121
|
): { srcValidatorAddress: string; dstValidatorAddress: string } | null {
|
|
122
|
-
const config = STAKING_CONTRACTS[
|
|
122
|
+
const config = STAKING_CONTRACTS[chainId]
|
|
123
123
|
const functionName = config?.functions.redelegate
|
|
124
|
-
const abi = getStakingABI(
|
|
124
|
+
const abi = getStakingABI(chainId)
|
|
125
125
|
if (!abi || !functionName) return null
|
|
126
126
|
try {
|
|
127
127
|
const iface = new ethers.Interface(abi)
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { ChainId } from '../../config'
|
|
4
5
|
import type { StakingOperation } from '../../types/staking'
|
|
6
|
+
import { CHAIN_ID } from '../../config'
|
|
7
|
+
import { createMockEvmConfigInfo, mkExternalNode } from '../../fixtures/context.fixtures'
|
|
5
8
|
import { buildTransactionParams } from '.'
|
|
6
9
|
|
|
10
|
+
const mkConfig = (chainId: ChainId, name: string) =>
|
|
11
|
+
createMockEvmConfigInfo({ chainId, name, node: mkExternalNode() })
|
|
12
|
+
|
|
7
13
|
describe('buildTransactionParams', () => {
|
|
8
14
|
const validatorAddress = 'seivaloper1abc123'
|
|
9
15
|
// 1 SEI expressed in the EVM-native unit (18 decimals). The precompile
|
|
@@ -15,10 +21,10 @@ describe('buildTransactionParams', () => {
|
|
|
15
21
|
const delegatorAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
|
|
16
22
|
|
|
17
23
|
describe('SEI Network', () => {
|
|
18
|
-
const
|
|
24
|
+
const evmConfig = mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm')
|
|
19
25
|
|
|
20
26
|
it('should build params for delegate operation', () => {
|
|
21
|
-
const params = buildTransactionParams(
|
|
27
|
+
const params = buildTransactionParams(evmConfig, 'delegate', {
|
|
22
28
|
valAddress: validatorAddress,
|
|
23
29
|
amount,
|
|
24
30
|
})
|
|
@@ -27,7 +33,7 @@ describe('buildTransactionParams', () => {
|
|
|
27
33
|
})
|
|
28
34
|
|
|
29
35
|
it('should build params for undelegate operation (amount converted from 18-dec EVM to 6-dec usei)', () => {
|
|
30
|
-
const params = buildTransactionParams(
|
|
36
|
+
const params = buildTransactionParams(evmConfig, 'undelegate', {
|
|
31
37
|
valAddress: validatorAddress,
|
|
32
38
|
amount,
|
|
33
39
|
})
|
|
@@ -36,7 +42,7 @@ describe('buildTransactionParams', () => {
|
|
|
36
42
|
})
|
|
37
43
|
|
|
38
44
|
it('should build params for redelegate operation (amount converted from 18-dec EVM to 6-dec usei)', () => {
|
|
39
|
-
const params = buildTransactionParams(
|
|
45
|
+
const params = buildTransactionParams(evmConfig, 'redelegate', {
|
|
40
46
|
valAddress: validatorAddress,
|
|
41
47
|
amount,
|
|
42
48
|
dstValAddress: dstValidatorAddress,
|
|
@@ -47,7 +53,7 @@ describe('buildTransactionParams', () => {
|
|
|
47
53
|
|
|
48
54
|
it('should truncate sub-usei precision on undelegate (precompile has 6-decimal precision)', () => {
|
|
49
55
|
// 1.234567891 SEI -> truncated to 1.234567 uSEI (9th and later decimals dropped)
|
|
50
|
-
const params = buildTransactionParams(
|
|
56
|
+
const params = buildTransactionParams(evmConfig, 'undelegate', {
|
|
51
57
|
valAddress: validatorAddress,
|
|
52
58
|
amount: 1234567891000000000n,
|
|
53
59
|
})
|
|
@@ -57,7 +63,7 @@ describe('buildTransactionParams', () => {
|
|
|
57
63
|
|
|
58
64
|
it('should throw error for redelegate without dstValAddress', () => {
|
|
59
65
|
expect(() => {
|
|
60
|
-
buildTransactionParams(
|
|
66
|
+
buildTransactionParams(evmConfig, 'redelegate', {
|
|
61
67
|
valAddress: validatorAddress,
|
|
62
68
|
amount,
|
|
63
69
|
})
|
|
@@ -65,7 +71,7 @@ describe('buildTransactionParams', () => {
|
|
|
65
71
|
})
|
|
66
72
|
|
|
67
73
|
it('should build params for getStakedBalance operation', () => {
|
|
68
|
-
const params = buildTransactionParams(
|
|
74
|
+
const params = buildTransactionParams(evmConfig, 'getStakedBalance', {
|
|
69
75
|
valAddress: validatorAddress,
|
|
70
76
|
amount,
|
|
71
77
|
dstValAddress: validatorAddress,
|
|
@@ -77,7 +83,7 @@ describe('buildTransactionParams', () => {
|
|
|
77
83
|
|
|
78
84
|
it('should throw error for getStakedBalance without required params', () => {
|
|
79
85
|
expect(() => {
|
|
80
|
-
buildTransactionParams(
|
|
86
|
+
buildTransactionParams(evmConfig, 'getStakedBalance', {
|
|
81
87
|
valAddress: validatorAddress,
|
|
82
88
|
amount,
|
|
83
89
|
})
|
|
@@ -86,7 +92,7 @@ describe('buildTransactionParams', () => {
|
|
|
86
92
|
|
|
87
93
|
it('should return the correct params for a claim rewards', () => {
|
|
88
94
|
const transactionType: StakingOperation = 'claimReward'
|
|
89
|
-
const params = buildTransactionParams(
|
|
95
|
+
const params = buildTransactionParams(evmConfig, transactionType, {
|
|
90
96
|
valAddress: validatorAddress,
|
|
91
97
|
amount,
|
|
92
98
|
})
|
|
@@ -96,8 +102,10 @@ describe('buildTransactionParams', () => {
|
|
|
96
102
|
})
|
|
97
103
|
|
|
98
104
|
describe('Monad', () => {
|
|
105
|
+
const evmConfig = mkConfig(CHAIN_ID.MONAD, 'monad')
|
|
106
|
+
|
|
99
107
|
it('builds params for delegate operation (valId as bigint, amount carried by msg.value)', () => {
|
|
100
|
-
const params = buildTransactionParams(
|
|
108
|
+
const params = buildTransactionParams(evmConfig, 'delegate', {
|
|
101
109
|
valId: '42',
|
|
102
110
|
amount: 1000000000000000000n,
|
|
103
111
|
})
|
|
@@ -106,7 +114,7 @@ describe('buildTransactionParams', () => {
|
|
|
106
114
|
})
|
|
107
115
|
|
|
108
116
|
it('builds params for claimReward operation (valId as bigint)', () => {
|
|
109
|
-
const params = buildTransactionParams(
|
|
117
|
+
const params = buildTransactionParams(evmConfig, 'claimReward', {
|
|
110
118
|
valId: '42',
|
|
111
119
|
amount: 0n,
|
|
112
120
|
})
|
|
@@ -115,7 +123,7 @@ describe('buildTransactionParams', () => {
|
|
|
115
123
|
})
|
|
116
124
|
|
|
117
125
|
it('builds params for compoundReward operation (valId as bigint)', () => {
|
|
118
|
-
const params = buildTransactionParams(
|
|
126
|
+
const params = buildTransactionParams(evmConfig, 'compoundReward', {
|
|
119
127
|
valId: '42',
|
|
120
128
|
amount: 0n,
|
|
121
129
|
})
|
|
@@ -125,14 +133,14 @@ describe('buildTransactionParams', () => {
|
|
|
125
133
|
|
|
126
134
|
it('throws when monad staking is missing valId', () => {
|
|
127
135
|
expect(() => {
|
|
128
|
-
buildTransactionParams(
|
|
136
|
+
buildTransactionParams(evmConfig, 'delegate', {
|
|
129
137
|
amount: 1000000000000000000n,
|
|
130
138
|
})
|
|
131
139
|
}).toThrow('monad staking requires valId')
|
|
132
140
|
})
|
|
133
141
|
|
|
134
142
|
it('builds params for undelegate operation (valId, amount, withdrawId as bigints)', () => {
|
|
135
|
-
const params = buildTransactionParams(
|
|
143
|
+
const params = buildTransactionParams(evmConfig, 'undelegate', {
|
|
136
144
|
valId: '42',
|
|
137
145
|
amount: 1000000000000000000n,
|
|
138
146
|
withdrawId: '7',
|
|
@@ -143,7 +151,7 @@ describe('buildTransactionParams', () => {
|
|
|
143
151
|
|
|
144
152
|
it('throws when monad undelegate is missing withdrawId', () => {
|
|
145
153
|
expect(() => {
|
|
146
|
-
buildTransactionParams(
|
|
154
|
+
buildTransactionParams(evmConfig, 'undelegate', {
|
|
147
155
|
valId: '42',
|
|
148
156
|
amount: 1000000000000000000n,
|
|
149
157
|
})
|
|
@@ -151,7 +159,7 @@ describe('buildTransactionParams', () => {
|
|
|
151
159
|
})
|
|
152
160
|
|
|
153
161
|
it('builds params for withdraw operation (valId, withdrawId as bigints)', () => {
|
|
154
|
-
const params = buildTransactionParams(
|
|
162
|
+
const params = buildTransactionParams(evmConfig, 'withdraw', {
|
|
155
163
|
valId: '42',
|
|
156
164
|
amount: 0n,
|
|
157
165
|
withdrawId: '7',
|
|
@@ -162,7 +170,7 @@ describe('buildTransactionParams', () => {
|
|
|
162
170
|
|
|
163
171
|
it('throws when monad withdraw is missing withdrawId', () => {
|
|
164
172
|
expect(() => {
|
|
165
|
-
buildTransactionParams(
|
|
173
|
+
buildTransactionParams(evmConfig, 'withdraw', {
|
|
166
174
|
valId: '42',
|
|
167
175
|
amount: 0n,
|
|
168
176
|
})
|
|
@@ -171,11 +179,11 @@ describe('buildTransactionParams', () => {
|
|
|
171
179
|
})
|
|
172
180
|
|
|
173
181
|
describe('CELO', () => {
|
|
174
|
-
const
|
|
182
|
+
const evmConfig = mkConfig(CHAIN_ID.CELO, 'celo')
|
|
175
183
|
const celoValidatorAddress = '0x123456789abcdef'
|
|
176
184
|
|
|
177
185
|
it('should build params for delegate operation', () => {
|
|
178
|
-
const params = buildTransactionParams(
|
|
186
|
+
const params = buildTransactionParams(evmConfig, 'delegate', {
|
|
179
187
|
valAddress: celoValidatorAddress,
|
|
180
188
|
amount,
|
|
181
189
|
})
|
|
@@ -184,7 +192,7 @@ describe('buildTransactionParams', () => {
|
|
|
184
192
|
})
|
|
185
193
|
|
|
186
194
|
it('should build params for undelegate operation', () => {
|
|
187
|
-
const params = buildTransactionParams(
|
|
195
|
+
const params = buildTransactionParams(evmConfig, 'undelegate', {
|
|
188
196
|
valAddress: celoValidatorAddress,
|
|
189
197
|
amount,
|
|
190
198
|
})
|
|
@@ -194,7 +202,7 @@ describe('buildTransactionParams', () => {
|
|
|
194
202
|
|
|
195
203
|
it('should throw error for redelegate operation (not supported)', () => {
|
|
196
204
|
expect(() => {
|
|
197
|
-
buildTransactionParams(
|
|
205
|
+
buildTransactionParams(evmConfig, 'redelegate', {
|
|
198
206
|
valAddress: celoValidatorAddress,
|
|
199
207
|
amount,
|
|
200
208
|
})
|
|
@@ -202,7 +210,7 @@ describe('buildTransactionParams', () => {
|
|
|
202
210
|
})
|
|
203
211
|
|
|
204
212
|
it('should build params for getStakedBalance operation', () => {
|
|
205
|
-
const params = buildTransactionParams(
|
|
213
|
+
const params = buildTransactionParams(evmConfig, 'getStakedBalance', {
|
|
206
214
|
valAddress: celoValidatorAddress,
|
|
207
215
|
amount,
|
|
208
216
|
})
|
|
@@ -211,7 +219,7 @@ describe('buildTransactionParams', () => {
|
|
|
211
219
|
})
|
|
212
220
|
|
|
213
221
|
it('should build params for getUnstakedBalance operation', () => {
|
|
214
|
-
const params = buildTransactionParams(
|
|
222
|
+
const params = buildTransactionParams(evmConfig, 'getUnstakedBalance', {
|
|
215
223
|
valAddress: celoValidatorAddress,
|
|
216
224
|
amount,
|
|
217
225
|
})
|
|
@@ -221,11 +229,11 @@ describe('buildTransactionParams', () => {
|
|
|
221
229
|
})
|
|
222
230
|
|
|
223
231
|
describe('Somnia', () => {
|
|
224
|
-
const
|
|
232
|
+
const evmConfig = mkConfig(CHAIN_ID.SOMNIA, 'somnia')
|
|
225
233
|
const somniaValidatorAddress = '0x1234567890abcdef1234567890abcdef12345678'
|
|
226
234
|
|
|
227
235
|
it('builds params for delegate operation', () => {
|
|
228
|
-
const params = buildTransactionParams(
|
|
236
|
+
const params = buildTransactionParams(evmConfig, 'delegate', {
|
|
229
237
|
valAddress: somniaValidatorAddress,
|
|
230
238
|
amount,
|
|
231
239
|
})
|
|
@@ -234,7 +242,7 @@ describe('buildTransactionParams', () => {
|
|
|
234
242
|
})
|
|
235
243
|
|
|
236
244
|
it('builds params for undelegate operation', () => {
|
|
237
|
-
const params = buildTransactionParams(
|
|
245
|
+
const params = buildTransactionParams(evmConfig, 'undelegate', {
|
|
238
246
|
valAddress: somniaValidatorAddress,
|
|
239
247
|
amount,
|
|
240
248
|
})
|
|
@@ -243,7 +251,7 @@ describe('buildTransactionParams', () => {
|
|
|
243
251
|
})
|
|
244
252
|
|
|
245
253
|
it('builds params for claimReward operation', () => {
|
|
246
|
-
const params = buildTransactionParams(
|
|
254
|
+
const params = buildTransactionParams(evmConfig, 'claimReward', {
|
|
247
255
|
valAddress: somniaValidatorAddress,
|
|
248
256
|
amount: 0n,
|
|
249
257
|
})
|
|
@@ -252,7 +260,7 @@ describe('buildTransactionParams', () => {
|
|
|
252
260
|
})
|
|
253
261
|
|
|
254
262
|
it('builds params for getStakedBalance operation', () => {
|
|
255
|
-
const params = buildTransactionParams(
|
|
263
|
+
const params = buildTransactionParams(evmConfig, 'getStakedBalance', {
|
|
256
264
|
valAddress: somniaValidatorAddress,
|
|
257
265
|
amount: 0n,
|
|
258
266
|
delegator: delegatorAddress,
|
|
@@ -263,7 +271,7 @@ describe('buildTransactionParams', () => {
|
|
|
263
271
|
|
|
264
272
|
it('throws when getStakedBalance is missing delegator', () => {
|
|
265
273
|
expect(() => {
|
|
266
|
-
buildTransactionParams(
|
|
274
|
+
buildTransactionParams(evmConfig, 'getStakedBalance', {
|
|
267
275
|
valAddress: somniaValidatorAddress,
|
|
268
276
|
amount: 0n,
|
|
269
277
|
})
|
|
@@ -274,7 +282,7 @@ describe('buildTransactionParams', () => {
|
|
|
274
282
|
describe('Error handling', () => {
|
|
275
283
|
it('should throw error for unsupported currency', () => {
|
|
276
284
|
expect(() => {
|
|
277
|
-
buildTransactionParams('unsupported_currency', 'delegate', {
|
|
285
|
+
buildTransactionParams(mkConfig(CHAIN_ID.ETHEREUM, 'unsupported_currency'), 'delegate', {
|
|
278
286
|
valAddress: validatorAddress,
|
|
279
287
|
amount,
|
|
280
288
|
})
|
|
@@ -284,20 +292,21 @@ describe('buildTransactionParams', () => {
|
|
|
284
292
|
it('should throw error for unsupported operation type', () => {
|
|
285
293
|
expect(() => {
|
|
286
294
|
// @ts-expect-error invalid operation
|
|
287
|
-
buildTransactionParams('sei_evm', 'invalidOperation', {
|
|
295
|
+
buildTransactionParams(mkConfig(CHAIN_ID.SEI_EVM, 'sei_evm'), 'invalidOperation', {
|
|
288
296
|
valAddress: validatorAddress,
|
|
289
297
|
amount,
|
|
290
298
|
})
|
|
291
299
|
}).toThrow('Unsupported transaction type for sei_evm: invalidOperation')
|
|
292
300
|
})
|
|
293
301
|
|
|
294
|
-
it.each([
|
|
295
|
-
'
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
+
it.each([
|
|
303
|
+
['sei_evm', CHAIN_ID.SEI_EVM],
|
|
304
|
+
['celo', CHAIN_ID.CELO],
|
|
305
|
+
['somnia', CHAIN_ID.SOMNIA],
|
|
306
|
+
])('throws when %s staking is missing valAddress', (name, chainId) => {
|
|
307
|
+
expect(() => {
|
|
308
|
+
buildTransactionParams(mkConfig(chainId, name), 'delegate', { amount })
|
|
309
|
+
}).toThrow(`${name} staking requires valAddress`)
|
|
310
|
+
})
|
|
302
311
|
})
|
|
303
312
|
})
|