@ledgerhq/coin-evm 10.1.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/CHANGELOG.md +42 -0
- package/docs/getBlock-internal-txs-schema.md +2 -2
- package/docs/network/node/index.md +1 -1
- package/lib/adapters/etherscan.d.ts +2 -1
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +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.js +1 -1
- 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/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/common.d.ts +1 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +11 -11
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +3 -3
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +7 -7
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +9 -9
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +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 +8 -8
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +1 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +9 -9
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +14 -13
- package/lib/logic.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +2 -3
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +6 -8
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +5 -5
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/types.d.ts +2 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/node/explorerProxy.js +12 -12
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/index.d.ts +1 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +7 -7
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.d.ts +3 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +31 -22
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +50 -39
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +15 -15
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/network/node/withNodeSources.d.ts.map +1 -1
- package/lib/network/node/withNodeSources.js +15 -15
- package/lib/network/node/withNodeSources.js.map +1 -1
- package/lib/staking/abis.d.ts +3 -2
- package/lib/staking/abis.d.ts.map +1 -1
- package/lib/staking/abis.js +10 -9
- package/lib/staking/abis.js.map +1 -1
- package/lib/staking/contracts.d.ts +3 -2
- package/lib/staking/contracts.d.ts.map +1 -1
- package/lib/staking/contracts.js +11 -10
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/detectOperationType.d.ts +2 -1
- package/lib/staking/detectOperationType.d.ts.map +1 -1
- package/lib/staking/detectOperationType.js +7 -7
- package/lib/staking/detectOperationType.js.map +1 -1
- package/lib/staking/encoder.d.ts +2 -1
- package/lib/staking/encoder.d.ts.map +1 -1
- package/lib/staking/encoder.js +8 -8
- package/lib/staking/encoder.js.map +1 -1
- package/lib/staking/fetchers.d.ts +2 -1
- package/lib/staking/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +27 -27
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/logic.d.ts +6 -6
- package/lib/staking/logic.d.ts.map +1 -1
- package/lib/staking/logic.js +14 -13
- package/lib/staking/logic.js.map +1 -1
- package/lib/staking/operations/index.d.ts +2 -1
- package/lib/staking/operations/index.d.ts.map +1 -1
- package/lib/staking/operations/index.js +30 -28
- package/lib/staking/operations/index.js.map +1 -1
- package/lib/staking/prepareIntents.d.ts +1 -1
- package/lib/staking/prepareIntents.d.ts.map +1 -1
- package/lib/staking/prepareIntents.js +11 -10
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/redelegations.d.ts +4 -4
- package/lib/staking/redelegations.d.ts.map +1 -1
- package/lib/staking/redelegations.js +18 -20
- package/lib/staking/redelegations.js.map +1 -1
- package/lib/staking/rewards.d.ts +1 -1
- package/lib/staking/rewards.d.ts.map +1 -1
- package/lib/staking/rewards.js +2 -2
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib/staking/rewardsFromReceipt.js +2 -2
- package/lib/staking/rewardsFromReceipt.js.map +1 -1
- package/lib/staking/transactionData.d.ts +2 -1
- package/lib/staking/transactionData.d.ts.map +1 -1
- package/lib/staking/transactionData.js +6 -6
- package/lib/staking/transactionData.js.map +1 -1
- package/lib/staking/unbondings.d.ts +1 -1
- package/lib/staking/unbondings.d.ts.map +1 -1
- package/lib/staking/unbondings.js +2 -2
- package/lib/staking/unbondings.js.map +1 -1
- package/lib/staking/validators/index.d.ts +14 -14
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +39 -38
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +5 -5
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +31 -33
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +1 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js +4 -4
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/sei.js +2 -2
- package/lib/staking/validators/sei.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts +4 -4
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js +22 -22
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/types.d.ts +1 -1
- package/lib/staking/validators/types.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts +1 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js +7 -7
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/staking.d.ts +5 -6
- package/lib/types/staking.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.d.ts +2 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +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.js +1 -1
- 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/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/common.d.ts +1 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +11 -11
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +3 -3
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +7 -7
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +9 -9
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +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 +8 -8
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +1 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +9 -9
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +14 -13
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +2 -3
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +6 -8
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +5 -5
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +2 -2
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/node/explorerProxy.js +12 -12
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/index.d.ts +1 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +7 -7
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts +3 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +31 -22
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +50 -39
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +15 -15
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
- package/lib-es/network/node/withNodeSources.js +15 -15
- package/lib-es/network/node/withNodeSources.js.map +1 -1
- package/lib-es/staking/abis.d.ts +3 -2
- package/lib-es/staking/abis.d.ts.map +1 -1
- package/lib-es/staking/abis.js +10 -9
- package/lib-es/staking/abis.js.map +1 -1
- package/lib-es/staking/contracts.d.ts +3 -2
- package/lib-es/staking/contracts.d.ts.map +1 -1
- package/lib-es/staking/contracts.js +11 -10
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/detectOperationType.d.ts +2 -1
- package/lib-es/staking/detectOperationType.d.ts.map +1 -1
- package/lib-es/staking/detectOperationType.js +7 -7
- package/lib-es/staking/detectOperationType.js.map +1 -1
- package/lib-es/staking/encoder.d.ts +2 -1
- package/lib-es/staking/encoder.d.ts.map +1 -1
- package/lib-es/staking/encoder.js +8 -8
- package/lib-es/staking/encoder.js.map +1 -1
- package/lib-es/staking/fetchers.d.ts +2 -1
- package/lib-es/staking/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +27 -27
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/logic.d.ts +6 -6
- package/lib-es/staking/logic.d.ts.map +1 -1
- package/lib-es/staking/logic.js +14 -13
- package/lib-es/staking/logic.js.map +1 -1
- package/lib-es/staking/operations/index.d.ts +2 -1
- package/lib-es/staking/operations/index.d.ts.map +1 -1
- package/lib-es/staking/operations/index.js +30 -28
- package/lib-es/staking/operations/index.js.map +1 -1
- package/lib-es/staking/prepareIntents.d.ts +1 -1
- package/lib-es/staking/prepareIntents.d.ts.map +1 -1
- package/lib-es/staking/prepareIntents.js +11 -10
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/redelegations.d.ts +4 -4
- package/lib-es/staking/redelegations.d.ts.map +1 -1
- package/lib-es/staking/redelegations.js +18 -20
- package/lib-es/staking/redelegations.js.map +1 -1
- package/lib-es/staking/rewards.d.ts +1 -1
- package/lib-es/staking/rewards.d.ts.map +1 -1
- package/lib-es/staking/rewards.js +2 -2
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.js +2 -2
- package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
- package/lib-es/staking/transactionData.d.ts +2 -1
- package/lib-es/staking/transactionData.d.ts.map +1 -1
- package/lib-es/staking/transactionData.js +6 -6
- package/lib-es/staking/transactionData.js.map +1 -1
- package/lib-es/staking/unbondings.d.ts +1 -1
- package/lib-es/staking/unbondings.d.ts.map +1 -1
- package/lib-es/staking/unbondings.js +2 -2
- package/lib-es/staking/unbondings.js.map +1 -1
- package/lib-es/staking/validators/index.d.ts +14 -14
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +39 -38
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +5 -5
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +31 -33
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +4 -4
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/sei.js +2 -2
- package/lib-es/staking/validators/sei.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts +4 -4
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js +22 -22
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/types.d.ts +1 -1
- package/lib-es/staking/validators/types.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js +7 -7
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/staking.d.ts +5 -6
- package/lib-es/types/staking.d.ts.map +1 -1
- package/package.json +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 +1 -1
- 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/logic/broadcast.ts +2 -2
- package/src/logic/common.ts +10 -11
- package/src/logic/craftTransaction.ts +2 -3
- package/src/logic/estimateFees.ts +6 -23
- package/src/logic/getBalance.ts +7 -13
- package/src/logic/getBlock.ts +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 +6 -8
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +0 -1
- 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 +12 -2
- 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 +23 -131
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +0 -2
- package/src/network/node/explorerProxy.test.ts +17 -22
- package/src/network/node/explorerProxy.ts +12 -12
- 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 +31 -34
- package/src/network/node/rpc.common.ts +58 -86
- package/src/network/node/rpc.test.ts +86 -114
- package/src/network/node/types.ts +11 -29
- package/src/network/node/withNodeSources.test.ts +7 -9
- package/src/network/node/withNodeSources.ts +23 -26
- package/src/staking/abis.test.ts +24 -28
- package/src/staking/abis.ts +12 -10
- package/src/staking/contracts.test.ts +20 -8
- package/src/staking/contracts.ts +12 -11
- package/src/staking/detectOperationType.test.ts +16 -13
- package/src/staking/detectOperationType.ts +9 -8
- package/src/staking/encoder.test.ts +38 -27
- package/src/staking/encoder.ts +9 -8
- package/src/staking/fetchers.ts +28 -39
- package/src/staking/logic.test.ts +34 -32
- package/src/staking/logic.ts +14 -14
- package/src/staking/operations/index.test.ts +48 -39
- package/src/staking/operations/index.ts +31 -28
- package/src/staking/prepareIntents.test.ts +14 -34
- package/src/staking/prepareIntents.ts +10 -13
- package/src/staking/redelegations.test.ts +73 -131
- package/src/staking/redelegations.ts +12 -26
- package/src/staking/rewards.test.ts +19 -21
- package/src/staking/rewards.ts +1 -2
- package/src/staking/rewardsFromReceipt.test.ts +9 -8
- package/src/staking/rewardsFromReceipt.ts +3 -2
- package/src/staking/transactionData.test.ts +35 -25
- package/src/staking/transactionData.ts +7 -6
- package/src/staking/unbondings.test.ts +26 -20
- package/src/staking/unbondings.ts +1 -2
- package/src/staking/validators/index.ts +45 -51
- package/src/staking/validators/monad.test.ts +52 -54
- package/src/staking/validators/monad.ts +31 -37
- package/src/staking/validators/monadResolver.ts +2 -4
- package/src/staking/validators/sei.ts +2 -2
- package/src/staking/validators/somnia.test.ts +22 -19
- package/src/staking/validators/somnia.ts +20 -27
- package/src/staking/validators/types.ts +0 -1
- package/src/staking/validators/zero_gravity.test.ts +34 -49
- package/src/staking/validators/zero_gravity.ts +5 -11
- package/src/staking/validators.integ.test.ts +3 -5
- package/src/staking/validators.test.ts +56 -53
- package/src/types/staking.ts +3 -6
|
@@ -168,11 +168,10 @@ async function fetchCosmosRestRedelegations(
|
|
|
168
168
|
*/
|
|
169
169
|
export async function fetchRedelegations(
|
|
170
170
|
evmConfig: EvmConfigInfo,
|
|
171
|
-
currencyId: string,
|
|
172
171
|
evmAddress: string,
|
|
173
172
|
logger: Logger
|
|
174
173
|
): Promise<EvmRedelegation[]> {
|
|
175
|
-
const config = STAKING_CONTRACTS[
|
|
174
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
176
175
|
const strategy = config?.redelegationStrategy
|
|
177
176
|
if (!strategy || strategy.type === 'none') return []
|
|
178
177
|
|
|
@@ -205,7 +204,6 @@ export async function fetchRedelegations(
|
|
|
205
204
|
*/
|
|
206
205
|
async function fetchTxDataFromRpc(
|
|
207
206
|
config: EvmConfigInfo,
|
|
208
|
-
currencyId: string,
|
|
209
207
|
txHash: string,
|
|
210
208
|
logger: Logger
|
|
211
209
|
): Promise<string | undefined> {
|
|
@@ -214,7 +212,6 @@ async function fetchTxDataFromRpc(
|
|
|
214
212
|
if (!isExternalNodeConfig(node)) return undefined
|
|
215
213
|
const data = await withApi(
|
|
216
214
|
config,
|
|
217
|
-
currencyId,
|
|
218
215
|
async (api) => {
|
|
219
216
|
const tx = await api.getTransaction(txHash)
|
|
220
217
|
return tx?.data ?? null
|
|
@@ -224,7 +221,7 @@ async function fetchTxDataFromRpc(
|
|
|
224
221
|
return data && data !== '0x' ? data : undefined
|
|
225
222
|
} catch (e) {
|
|
226
223
|
logger('coin-evm/staking', 'fetchTxDataFromRpc: getTransaction failed', {
|
|
227
|
-
|
|
224
|
+
currency: config.name,
|
|
228
225
|
txHash,
|
|
229
226
|
error: e instanceof Error ? e.message : String(e),
|
|
230
227
|
})
|
|
@@ -243,7 +240,6 @@ async function fetchTxDataFromRpc(
|
|
|
243
240
|
*/
|
|
244
241
|
export async function resolveRedelegationValidators(
|
|
245
242
|
evmConfig: EvmConfigInfo,
|
|
246
|
-
currencyId: string,
|
|
247
243
|
operation: OperationLike,
|
|
248
244
|
logger: Logger
|
|
249
245
|
): Promise<{
|
|
@@ -256,13 +252,13 @@ export async function resolveRedelegationValidators(
|
|
|
256
252
|
const payload =
|
|
257
253
|
typeof cached === 'string'
|
|
258
254
|
? cached
|
|
259
|
-
: await fetchTxDataFromRpc(evmConfig,
|
|
255
|
+
: await fetchTxDataFromRpc(evmConfig, operation.hash, logger)
|
|
260
256
|
|
|
261
257
|
if (!payload) return null
|
|
262
258
|
|
|
263
|
-
const config = STAKING_CONTRACTS[
|
|
259
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
264
260
|
const functionName = config?.functions.redelegate
|
|
265
|
-
const abi = getStakingABI(
|
|
261
|
+
const abi = getStakingABI(evmConfig.chainId)
|
|
266
262
|
if (!abi || !functionName) return null
|
|
267
263
|
try {
|
|
268
264
|
const iface = new ethers.Interface(abi)
|
|
@@ -295,7 +291,6 @@ export async function resolveRedelegationValidators(
|
|
|
295
291
|
*/
|
|
296
292
|
export async function resolveStakingValidator(
|
|
297
293
|
evmConfig: EvmConfigInfo,
|
|
298
|
-
currencyId: string,
|
|
299
294
|
operation: OperationLike,
|
|
300
295
|
operationType: 'delegate' | 'undelegate' | 'withdraw',
|
|
301
296
|
logger: Logger
|
|
@@ -305,13 +300,13 @@ export async function resolveStakingValidator(
|
|
|
305
300
|
const payload =
|
|
306
301
|
typeof cached === 'string'
|
|
307
302
|
? cached
|
|
308
|
-
: await fetchTxDataFromRpc(evmConfig,
|
|
303
|
+
: await fetchTxDataFromRpc(evmConfig, operation.hash, logger)
|
|
309
304
|
|
|
310
305
|
if (!payload) return null
|
|
311
306
|
|
|
312
|
-
const config = STAKING_CONTRACTS[
|
|
307
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
313
308
|
const functionName = config?.functions[operationType]
|
|
314
|
-
const abi = getStakingABI(
|
|
309
|
+
const abi = getStakingABI(evmConfig.chainId)
|
|
315
310
|
if (!abi || !functionName) return null
|
|
316
311
|
try {
|
|
317
312
|
const iface = new ethers.Interface(abi)
|
|
@@ -326,13 +321,7 @@ export async function resolveStakingValidator(
|
|
|
326
321
|
if (!validatorAddress) return null
|
|
327
322
|
|
|
328
323
|
const contractAddress = operation.recipients[0] ?? validatorAddress
|
|
329
|
-
const amount = await config.resolveOperationAmount(
|
|
330
|
-
evmConfig,
|
|
331
|
-
d,
|
|
332
|
-
operationType,
|
|
333
|
-
currencyId,
|
|
334
|
-
contractAddress
|
|
335
|
-
)
|
|
324
|
+
const amount = await config.resolveOperationAmount(evmConfig, d, operationType, contractAddress)
|
|
336
325
|
return { validatorAddress, amount }
|
|
337
326
|
} catch {
|
|
338
327
|
return null
|
|
@@ -341,14 +330,13 @@ export async function resolveStakingValidator(
|
|
|
341
330
|
|
|
342
331
|
export async function buildRedelegationsFromOps(
|
|
343
332
|
evmConfig: EvmConfigInfo,
|
|
344
|
-
currencyId: string,
|
|
345
333
|
operations: OperationLike[],
|
|
346
334
|
logger: Logger
|
|
347
335
|
): Promise<EvmRedelegation[]> {
|
|
348
|
-
const config = STAKING_CONTRACTS[
|
|
336
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
349
337
|
if (!config?.functions.redelegate) return []
|
|
350
338
|
|
|
351
|
-
const abi = getStakingABI(
|
|
339
|
+
const abi = getStakingABI(evmConfig.chainId)
|
|
352
340
|
if (!abi) return []
|
|
353
341
|
|
|
354
342
|
const functionName = config.functions.redelegate
|
|
@@ -369,9 +357,7 @@ export async function buildRedelegationsFromOps(
|
|
|
369
357
|
const extra = isRecord(op.extra) ? op.extra : undefined
|
|
370
358
|
const cached = extra?.contractPayload
|
|
371
359
|
const payload =
|
|
372
|
-
typeof cached === 'string'
|
|
373
|
-
? cached
|
|
374
|
-
: await fetchTxDataFromRpc(evmConfig, currencyId, op.hash, logger)
|
|
360
|
+
typeof cached === 'string' ? cached : await fetchTxDataFromRpc(evmConfig, op.hash, logger)
|
|
375
361
|
if (!payload) return null
|
|
376
362
|
try {
|
|
377
363
|
const d = iface.decodeFunctionData(functionName, payload)
|
|
@@ -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
|
|