@ledgerhq/coin-evm 10.1.0 → 15.2.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 +58 -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 +16 -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 +4 -2
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -2
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +95 -0
- package/lib/chains.d.ts.map +1 -0
- package/lib/chains.js +99 -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 +38 -21
- 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 +3 -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.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +14 -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 +32 -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 +67 -39
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +18 -16
- 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 +16 -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 +4 -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 +1 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +95 -0
- package/lib-es/chains.d.ts.map +1 -0
- package/lib-es/chains.js +96 -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 +39 -22
- 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 +3 -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.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +14 -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 +32 -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 +67 -39
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +18 -16
- 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 +2 -2
- package/src/adapters/etherscan.test.ts +91 -43
- package/src/adapters/etherscan.ts +18 -2
- package/src/adapters/ledger.test.ts +106 -31
- package/src/adapters/ledger.ts +5 -2
- package/src/api/index.ts +1 -2
- package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +5 -4
- package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +3 -3
- package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +3 -3
- package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +3 -3
- package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +3 -3
- package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +3 -3
- package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +3 -3
- package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +3 -3
- package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +6 -6
- package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +3 -3
- package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +3 -3
- package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +3 -3
- package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +3 -3
- package/src/api/{index.test.ts → tests/index.test.ts} +4 -4
- package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +2 -2
- package/src/chains.test.ts +12 -0
- package/src/chains.ts +98 -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 +59 -23
- 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 +2 -1
- package/src/logic/tests/broadcast.test.ts +5 -5
- package/src/logic/tests/broadcastSource.test.ts +1 -4
- package/src/logic/tests/common.test.ts +18 -34
- package/src/logic/tests/craftTransaction.test.ts +14 -7
- package/src/logic/tests/estimateFees.test.ts +17 -8
- package/src/logic/tests/getBalance.test.ts +18 -34
- package/src/logic/tests/getBlock.test.ts +195 -80
- package/src/logic/tests/getBlockInfo.test.ts +2 -2
- package/src/logic/tests/getNextSequence.test.ts +2 -2
- package/src/logic/tests/getStakes.test.ts +28 -16
- package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -6
- package/src/logic/tests/lastBlock.test.ts +4 -7
- package/src/logic/tests/listOperations.test.ts +8 -7
- package/src/logic/tests/validateIntent.test.ts +49 -3
- package/src/logic/validateIntent.ts +8 -10
- package/src/logic.test.ts +13 -5
- package/src/logic.ts +13 -13
- package/src/network/explorer/etherscan.ts +8 -24
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +0 -2
- package/src/network/node/explorerProxy.ts +14 -12
- package/src/network/node/index.ts +11 -8
- package/src/network/node/ledger.ts +32 -34
- package/src/network/node/rpc.common.ts +79 -86
- package/src/network/node/types.ts +16 -31
- package/src/network/node/withNodeSources.ts +23 -26
- package/src/network/{explorer → tests/explorer}/etherscan.test.ts +16 -65
- package/src/network/{explorer → tests/explorer}/index.test.ts +8 -8
- package/src/network/{explorer → tests/explorer}/ledger.test.ts +34 -142
- package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
- package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
- package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
- package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/explorerProxy.test.ts +22 -24
- package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
- package/src/network/tests/node/index.memoization.test.ts +70 -0
- package/src/network/{node → tests/node}/index.test.ts +4 -6
- package/src/network/{node → tests/node}/ledger.test.ts +69 -74
- package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
- package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
- package/src/network/{node → tests/node}/rpc.test.ts +100 -119
- package/src/network/{node → tests/node}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/withNodeSources.test.ts +10 -12
- package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
- 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
- package/src/network/node/index.memoization.test.ts +0 -63
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '../config'
|
|
4
|
+
import type { ChainId, EvmConfigInfo } from '../config'
|
|
5
5
|
import type {
|
|
6
6
|
BufferTxData,
|
|
7
7
|
MemoNotSupported,
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
11
11
|
import { ethers } from 'ethers'
|
|
12
12
|
import { toInterfaceAbi } from '../abis'
|
|
13
|
+
import { CHAIN_ID } from '../config'
|
|
13
14
|
import { isStakingIntent } from '../logic-public'
|
|
14
15
|
import { withApi } from '../network/node/rpc.common'
|
|
15
16
|
import { isExternalNodeConfig } from '../network/node/types'
|
|
@@ -41,12 +42,11 @@ function isWithdrawalFeeInGweiResult(value: unknown): value is WithdrawalFeeInGw
|
|
|
41
42
|
*/
|
|
42
43
|
type IntentPreparer = (
|
|
43
44
|
config: EvmConfigInfo,
|
|
44
|
-
currencyId: string,
|
|
45
45
|
intent: StakingIntent,
|
|
46
46
|
logger: Logger
|
|
47
47
|
) => Promise<StakingIntent>
|
|
48
48
|
|
|
49
|
-
const prepareMonadIntent: IntentPreparer = async (config,
|
|
49
|
+
const prepareMonadIntent: IntentPreparer = async (config, intent, logger) => {
|
|
50
50
|
if (!isStakingIntent(intent)) return intent
|
|
51
51
|
if (intent.mode !== 'undelegate' || intent.withdrawId !== undefined || !intent.valId) {
|
|
52
52
|
return intent
|
|
@@ -54,7 +54,6 @@ const prepareMonadIntent: IntentPreparer = async (config, _currencyId, intent, l
|
|
|
54
54
|
|
|
55
55
|
const withdrawId = await findFirstFreeWithdrawId(
|
|
56
56
|
config,
|
|
57
|
-
'monad',
|
|
58
57
|
BigInt(intent.valId),
|
|
59
58
|
intent.sender,
|
|
60
59
|
logger
|
|
@@ -72,14 +71,14 @@ const prepareMonadIntent: IntentPreparer = async (config, _currencyId, intent, l
|
|
|
72
71
|
return enriched
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
const prepareZeroGravityIntent: IntentPreparer = async (config,
|
|
74
|
+
const prepareZeroGravityIntent: IntentPreparer = async (config, intent) => {
|
|
76
75
|
if (!isStakingIntent(intent)) return intent
|
|
77
76
|
if (intent.mode !== 'undelegate' || intent.shares !== undefined || !intent.valAddress) {
|
|
78
77
|
return intent
|
|
79
78
|
}
|
|
80
79
|
if (!intent.useAllAmount && intent.amount <= 0n) return intent
|
|
81
80
|
|
|
82
|
-
const abi = getStakingABI(
|
|
81
|
+
const abi = getStakingABI(config.chainId)
|
|
83
82
|
if (!abi) return intent
|
|
84
83
|
|
|
85
84
|
const node = config.node
|
|
@@ -91,7 +90,6 @@ const prepareZeroGravityIntent: IntentPreparer = async (config, currencyId, inte
|
|
|
91
90
|
|
|
92
91
|
const { shares, txValue } = await withApi(
|
|
93
92
|
config,
|
|
94
|
-
currencyId,
|
|
95
93
|
async (provider) => {
|
|
96
94
|
const rawDelegation = await provider.call({
|
|
97
95
|
to: valAddress,
|
|
@@ -144,9 +142,9 @@ const prepareZeroGravityIntent: IntentPreparer = async (config, currencyId, inte
|
|
|
144
142
|
return enriched
|
|
145
143
|
}
|
|
146
144
|
|
|
147
|
-
const STAKING_INTENT_PREPARERS: Record<
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
const STAKING_INTENT_PREPARERS: Partial<Record<ChainId, IntentPreparer>> = {
|
|
146
|
+
[CHAIN_ID.MONAD]: prepareMonadIntent,
|
|
147
|
+
[CHAIN_ID.ZERO_GRAVITY]: prepareZeroGravityIntent,
|
|
150
148
|
}
|
|
151
149
|
|
|
152
150
|
/**
|
|
@@ -156,10 +154,9 @@ const STAKING_INTENT_PREPARERS: Record<string, IntentPreparer> = {
|
|
|
156
154
|
*/
|
|
157
155
|
export const prepareStakingIntent = async (
|
|
158
156
|
config: EvmConfigInfo,
|
|
159
|
-
currencyId: string,
|
|
160
157
|
intent: StakingIntent,
|
|
161
158
|
logger: Logger
|
|
162
159
|
): Promise<StakingIntent> => {
|
|
163
|
-
const prepare = STAKING_INTENT_PREPARERS[
|
|
164
|
-
return prepare ? prepare(config,
|
|
160
|
+
const prepare = STAKING_INTENT_PREPARERS[config.chainId]
|
|
161
|
+
return prepare ? prepare(config, intent, logger) : intent
|
|
165
162
|
}
|
|
@@ -6,9 +6,10 @@ import type { OperationLike } from './redelegations'
|
|
|
6
6
|
import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
|
|
7
7
|
import { BigNumber } from 'bignumber.js'
|
|
8
8
|
import { ethers } from 'ethers'
|
|
9
|
+
import { CHAIN_ID } from '../config'
|
|
9
10
|
import { testLogger } from '../fixtures/context.fixtures'
|
|
11
|
+
import { requireStakingContract } from '../fixtures/staking.fixtures'
|
|
10
12
|
import { getStakingABI } from './abis'
|
|
11
|
-
import { STAKING_CONTRACTS } from './contracts'
|
|
12
13
|
import {
|
|
13
14
|
fetchRedelegations,
|
|
14
15
|
resolveRedelegationValidators,
|
|
@@ -39,27 +40,29 @@ const mockIsExternalNodeConfig = jest.mocked(require('../network/node/types').is
|
|
|
39
40
|
const mockNode: EvmConfigInfo['node'] = { type: 'external', uri: 'https://sei-evm.coin.ledger.com' }
|
|
40
41
|
const mockConfig: EvmConfigInfo = {
|
|
41
42
|
status: { type: 'active' },
|
|
42
|
-
chainId:
|
|
43
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
43
44
|
name: 'Test EVM',
|
|
44
45
|
unit: { name: 'test', code: 'TEST', magnitude: 18 },
|
|
45
46
|
node: mockNode,
|
|
46
47
|
explorer: { type: 'none' },
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
const
|
|
49
|
+
const ethereumConfig: EvmConfigInfo = { ...mockConfig, chainId: CHAIN_ID.ETHEREUM }
|
|
50
|
+
const celoConfig: EvmConfigInfo = { ...mockConfig, chainId: CHAIN_ID.CELO }
|
|
51
|
+
const monadConfig: EvmConfigInfo = { ...mockConfig, chainId: CHAIN_ID.MONAD }
|
|
52
|
+
const zeroGravityConfig: EvmConfigInfo = { ...mockConfig, chainId: CHAIN_ID.ZERO_GRAVITY }
|
|
50
53
|
|
|
51
54
|
function encodeDelegateCalldata(validatorAddress: string): string {
|
|
52
|
-
const abi = getStakingABI(
|
|
55
|
+
const abi = getStakingABI(CHAIN_ID.SEI_EVM)!
|
|
53
56
|
return new ethers.Interface(abi).encodeFunctionData('delegate', [validatorAddress])
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
function encodeUndelegateCalldata(validatorAddress: string, amountUsei: bigint): string {
|
|
57
|
-
const abi = getStakingABI(
|
|
60
|
+
const abi = getStakingABI(CHAIN_ID.SEI_EVM)!
|
|
58
61
|
return new ethers.Interface(abi).encodeFunctionData('undelegate', [validatorAddress, amountUsei])
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
function encodeRedelegateCalldata(src: string, dst: string, amountUsei: bigint): string {
|
|
62
|
-
const abi = getStakingABI(
|
|
65
|
+
const abi = getStakingABI(CHAIN_ID.SEI_EVM)!
|
|
63
66
|
return new ethers.Interface(abi).encodeFunctionData('redelegate', [src, dst, amountUsei])
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -93,12 +96,12 @@ describe('redelegations', () => {
|
|
|
93
96
|
mockIsExternalNodeConfig.mockImplementation((node: unknown) => node === mockNode)
|
|
94
97
|
})
|
|
95
98
|
|
|
96
|
-
it('should return [] for
|
|
97
|
-
expect(await fetchRedelegations(
|
|
99
|
+
it('should return [] for a chain without staking', async () => {
|
|
100
|
+
expect(await fetchRedelegations(ethereumConfig, '0xabc', testLogger)).toEqual([])
|
|
98
101
|
})
|
|
99
102
|
|
|
100
103
|
it("should return [] when the strategy type is 'none'", async () => {
|
|
101
|
-
expect(await fetchRedelegations(
|
|
104
|
+
expect(await fetchRedelegations(celoConfig, '0xabc', testLogger)).toEqual([])
|
|
102
105
|
})
|
|
103
106
|
|
|
104
107
|
it('should return [] when the network call fails', async () => {
|
|
@@ -106,7 +109,6 @@ describe('redelegations', () => {
|
|
|
106
109
|
expect(
|
|
107
110
|
await fetchRedelegations(
|
|
108
111
|
mockConfig,
|
|
109
|
-
'sei_evm',
|
|
110
112
|
'0x1234567890abcdef1234567890abcdef12345678',
|
|
111
113
|
testLogger
|
|
112
114
|
)
|
|
@@ -118,7 +120,6 @@ describe('redelegations', () => {
|
|
|
118
120
|
expect(
|
|
119
121
|
await fetchRedelegations(
|
|
120
122
|
mockConfig,
|
|
121
|
-
'sei_evm',
|
|
122
123
|
'0x1234567890abcdef1234567890abcdef12345678',
|
|
123
124
|
testLogger
|
|
124
125
|
)
|
|
@@ -151,7 +152,6 @@ describe('redelegations', () => {
|
|
|
151
152
|
expect(
|
|
152
153
|
await fetchRedelegations(
|
|
153
154
|
mockConfig,
|
|
154
|
-
'sei_evm',
|
|
155
155
|
'0x1234567890abcdef1234567890abcdef12345678',
|
|
156
156
|
testLogger
|
|
157
157
|
)
|
|
@@ -183,7 +183,6 @@ describe('redelegations', () => {
|
|
|
183
183
|
|
|
184
184
|
const result = await fetchRedelegations(
|
|
185
185
|
mockConfig,
|
|
186
|
-
'sei_evm',
|
|
187
186
|
'0x1234567890abcdef1234567890abcdef12345678',
|
|
188
187
|
testLogger
|
|
189
188
|
)
|
|
@@ -206,7 +205,7 @@ describe('redelegations', () => {
|
|
|
206
205
|
mockGetSeiAddr.mockResolvedValueOnce(canonicalCosmosAddress)
|
|
207
206
|
mockNetwork.mockResolvedValueOnce({ data: { redelegation_responses: [] } })
|
|
208
207
|
|
|
209
|
-
await fetchRedelegations(mockConfig,
|
|
208
|
+
await fetchRedelegations(mockConfig, evmAddress, testLogger)
|
|
210
209
|
|
|
211
210
|
expect(mockNetwork).toHaveBeenCalledTimes(1)
|
|
212
211
|
expect(mockNetwork).toHaveBeenCalledWith(
|
|
@@ -224,7 +223,6 @@ describe('redelegations', () => {
|
|
|
224
223
|
expect(
|
|
225
224
|
await fetchRedelegations(
|
|
226
225
|
mockConfig,
|
|
227
|
-
'sei_evm',
|
|
228
226
|
'0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3',
|
|
229
227
|
testLogger
|
|
230
228
|
)
|
|
@@ -245,7 +243,7 @@ describe('redelegations', () => {
|
|
|
245
243
|
const calldata = encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI)
|
|
246
244
|
const op = makeOperation({ type: 'REDELEGATE', extra: { contractPayload: calldata } })
|
|
247
245
|
|
|
248
|
-
const result = await resolveRedelegationValidators(mockConfig,
|
|
246
|
+
const result = await resolveRedelegationValidators(mockConfig, op, testLogger)
|
|
249
247
|
|
|
250
248
|
expect(result).toMatchObject({
|
|
251
249
|
srcValidatorAddress: SRC,
|
|
@@ -257,14 +255,12 @@ describe('redelegations', () => {
|
|
|
257
255
|
it('should fall back to RPC when contractPayload is absent', async () => {
|
|
258
256
|
const calldata = encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI)
|
|
259
257
|
mockIsExternalNodeConfig.mockReturnValue(true)
|
|
260
|
-
mockWithApi.mockImplementation(
|
|
261
|
-
(
|
|
262
|
-
fn({ getTransaction: async () => ({ data: calldata }) })
|
|
258
|
+
mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
|
|
259
|
+
fn({ getTransaction: async () => ({ data: calldata }) })
|
|
263
260
|
)
|
|
264
261
|
|
|
265
262
|
const result = await resolveRedelegationValidators(
|
|
266
263
|
mockConfig,
|
|
267
|
-
SEI_CURRENCY,
|
|
268
264
|
makeOperation({ type: 'REDELEGATE', extra: {} }),
|
|
269
265
|
testLogger
|
|
270
266
|
)
|
|
@@ -281,7 +277,6 @@ describe('redelegations', () => {
|
|
|
281
277
|
|
|
282
278
|
const result = await resolveRedelegationValidators(
|
|
283
279
|
mockConfig,
|
|
284
|
-
SEI_CURRENCY,
|
|
285
280
|
makeOperation({ type: 'REDELEGATE', extra: {} }),
|
|
286
281
|
testLogger
|
|
287
282
|
)
|
|
@@ -293,16 +288,12 @@ describe('redelegations', () => {
|
|
|
293
288
|
type: 'REDELEGATE',
|
|
294
289
|
extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
|
|
295
290
|
})
|
|
296
|
-
expect(
|
|
297
|
-
await resolveRedelegationValidators(mockConfig, 'unsupported', op, testLogger)
|
|
298
|
-
).toBeNull()
|
|
291
|
+
expect(await resolveRedelegationValidators(ethereumConfig, op, testLogger)).toBeNull()
|
|
299
292
|
})
|
|
300
293
|
|
|
301
294
|
it('should return null for malformed calldata', async () => {
|
|
302
295
|
const op = makeOperation({ type: 'REDELEGATE', extra: { contractPayload: '0xdeadbeef' } })
|
|
303
|
-
expect(
|
|
304
|
-
await resolveRedelegationValidators(mockConfig, SEI_CURRENCY, op, testLogger)
|
|
305
|
-
).toBeNull()
|
|
296
|
+
expect(await resolveRedelegationValidators(mockConfig, op, testLogger)).toBeNull()
|
|
306
297
|
})
|
|
307
298
|
})
|
|
308
299
|
|
|
@@ -318,48 +309,39 @@ describe('redelegations', () => {
|
|
|
318
309
|
type: 'DELEGATE',
|
|
319
310
|
extra: { contractPayload: encodeDelegateCalldata(VALIDATOR) },
|
|
320
311
|
})
|
|
321
|
-
expect(
|
|
322
|
-
await resolveStakingValidator(mockConfig, 'unsupported', op, 'delegate', testLogger)
|
|
323
|
-
).toBeNull()
|
|
312
|
+
expect(await resolveStakingValidator(ethereumConfig, op, 'delegate', testLogger)).toBeNull()
|
|
324
313
|
})
|
|
325
314
|
|
|
326
315
|
describe('delegate (Monad, id-keyed validatorId)', () => {
|
|
327
316
|
it('resolves the validator address from the uint64 validatorId via getValidator', async () => {
|
|
328
|
-
const monadIface = new ethers.Interface(getStakingABI(
|
|
317
|
+
const monadIface = new ethers.Interface(getStakingABI(CHAIN_ID.MONAD)!)
|
|
329
318
|
const op = makeOperation({
|
|
330
319
|
type: 'DELEGATE',
|
|
331
320
|
extra: { contractPayload: monadIface.encodeFunctionData('delegate', [110n]) },
|
|
332
321
|
})
|
|
333
322
|
|
|
334
323
|
mockIsExternalNodeConfig.mockReturnValue(true)
|
|
335
|
-
mockWithApi.mockImplementation(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
})
|
|
324
|
+
mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
|
|
325
|
+
fn({
|
|
326
|
+
call: async () =>
|
|
327
|
+
monadIface.encodeFunctionResult('getValidator', [
|
|
328
|
+
'0x0000000000000000000000000000000000000000',
|
|
329
|
+
0n,
|
|
330
|
+
0n,
|
|
331
|
+
0n,
|
|
332
|
+
0n,
|
|
333
|
+
0n,
|
|
334
|
+
0n,
|
|
335
|
+
0n,
|
|
336
|
+
0n,
|
|
337
|
+
0n,
|
|
338
|
+
'0x036e44a092493800e427b2b08d3427d804348b1368ecd0a6af6510ae40ce507187',
|
|
339
|
+
'0x',
|
|
340
|
+
]),
|
|
341
|
+
})
|
|
354
342
|
)
|
|
355
343
|
|
|
356
|
-
const result = await resolveStakingValidator(
|
|
357
|
-
mockConfig,
|
|
358
|
-
'monad',
|
|
359
|
-
op,
|
|
360
|
-
'delegate',
|
|
361
|
-
testLogger
|
|
362
|
-
)
|
|
344
|
+
const result = await resolveStakingValidator(monadConfig, op, 'delegate', testLogger)
|
|
363
345
|
|
|
364
346
|
expect(result).toMatchObject({
|
|
365
347
|
validatorAddress: ethers.computeAddress(
|
|
@@ -376,18 +358,12 @@ describe('redelegations', () => {
|
|
|
376
358
|
recipients: ['0x2222222222222222222222222222222222222222'],
|
|
377
359
|
extra: {
|
|
378
360
|
contractPayload: new ethers.Interface(
|
|
379
|
-
getStakingABI(
|
|
361
|
+
getStakingABI(CHAIN_ID.ZERO_GRAVITY)!
|
|
380
362
|
).encodeFunctionData('delegate', ['0x1111111111111111111111111111111111111111']),
|
|
381
363
|
},
|
|
382
364
|
})
|
|
383
365
|
|
|
384
|
-
const result = await resolveStakingValidator(
|
|
385
|
-
mockConfig,
|
|
386
|
-
'zero_gravity',
|
|
387
|
-
op,
|
|
388
|
-
'delegate',
|
|
389
|
-
testLogger
|
|
390
|
-
)
|
|
366
|
+
const result = await resolveStakingValidator(zeroGravityConfig, op, 'delegate', testLogger)
|
|
391
367
|
|
|
392
368
|
expect(result).toMatchObject({
|
|
393
369
|
validatorAddress: '0x2222222222222222222222222222222222222222',
|
|
@@ -397,7 +373,7 @@ describe('redelegations', () => {
|
|
|
397
373
|
|
|
398
374
|
describe('undelegate (0G, convertToTokens)', () => {
|
|
399
375
|
it('calls convertToTokens on the validator contract to resolve the display amount', async () => {
|
|
400
|
-
const zgIface = new ethers.Interface(getStakingABI(
|
|
376
|
+
const zgIface = new ethers.Interface(getStakingABI(CHAIN_ID.ZERO_GRAVITY)!)
|
|
401
377
|
const convertIface = new ethers.Interface([
|
|
402
378
|
'function convertToTokens(uint256 shares) view returns (uint256)',
|
|
403
379
|
])
|
|
@@ -415,28 +391,21 @@ describe('redelegations', () => {
|
|
|
415
391
|
const zgNode: EvmConfigInfo['node'] = { type: 'external', uri: 'https://0g.rpc' }
|
|
416
392
|
const zgConfig: EvmConfigInfo = {
|
|
417
393
|
status: { type: 'active' },
|
|
418
|
-
chainId:
|
|
394
|
+
chainId: CHAIN_ID.ZERO_GRAVITY,
|
|
419
395
|
name: 'Test EVM',
|
|
420
396
|
unit: { name: 'test', code: 'TEST', magnitude: 18 },
|
|
421
397
|
node: zgNode,
|
|
422
398
|
explorer: { type: 'none' },
|
|
423
399
|
}
|
|
424
400
|
mockIsExternalNodeConfig.mockImplementation((node: unknown) => node === zgNode)
|
|
425
|
-
mockWithApi.mockImplementation(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
})
|
|
401
|
+
mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
|
|
402
|
+
fn({
|
|
403
|
+
call: async () =>
|
|
404
|
+
convertIface.encodeFunctionResult('convertToTokens', [13_000_000_000_000_000n]),
|
|
405
|
+
})
|
|
431
406
|
)
|
|
432
407
|
|
|
433
|
-
const result = await resolveStakingValidator(
|
|
434
|
-
zgConfig,
|
|
435
|
-
'zero_gravity',
|
|
436
|
-
op,
|
|
437
|
-
'undelegate',
|
|
438
|
-
testLogger
|
|
439
|
-
)
|
|
408
|
+
const result = await resolveStakingValidator(zgConfig, op, 'undelegate', testLogger)
|
|
440
409
|
|
|
441
410
|
expect(result).toEqual({
|
|
442
411
|
validatorAddress: '0x3333333333333333333333333333333333333333',
|
|
@@ -452,27 +421,19 @@ describe('redelegations', () => {
|
|
|
452
421
|
extra: { contractPayload: encodeDelegateCalldata(VALIDATOR) },
|
|
453
422
|
})
|
|
454
423
|
|
|
455
|
-
const result = await resolveStakingValidator(
|
|
456
|
-
mockConfig,
|
|
457
|
-
SEI_CURRENCY,
|
|
458
|
-
op,
|
|
459
|
-
'delegate',
|
|
460
|
-
testLogger
|
|
461
|
-
)
|
|
424
|
+
const result = await resolveStakingValidator(mockConfig, op, 'delegate', testLogger)
|
|
462
425
|
|
|
463
426
|
expect(result).toMatchObject({ validatorAddress: VALIDATOR })
|
|
464
427
|
})
|
|
465
428
|
|
|
466
429
|
it('should fall back to RPC when contractPayload is absent', async () => {
|
|
467
430
|
mockIsExternalNodeConfig.mockReturnValue(true)
|
|
468
|
-
mockWithApi.mockImplementation(
|
|
469
|
-
(
|
|
470
|
-
fn({ getTransaction: async () => ({ data: encodeDelegateCalldata(VALIDATOR) }) })
|
|
431
|
+
mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
|
|
432
|
+
fn({ getTransaction: async () => ({ data: encodeDelegateCalldata(VALIDATOR) }) })
|
|
471
433
|
)
|
|
472
434
|
|
|
473
435
|
const result = await resolveStakingValidator(
|
|
474
436
|
mockConfig,
|
|
475
|
-
SEI_CURRENCY,
|
|
476
437
|
makeOperation({ type: 'DELEGATE', extra: {} }),
|
|
477
438
|
'delegate',
|
|
478
439
|
testLogger
|
|
@@ -487,7 +448,6 @@ describe('redelegations', () => {
|
|
|
487
448
|
expect(
|
|
488
449
|
await resolveStakingValidator(
|
|
489
450
|
mockConfig,
|
|
490
|
-
SEI_CURRENCY,
|
|
491
451
|
makeOperation({ type: 'DELEGATE', extra: {} }),
|
|
492
452
|
'delegate',
|
|
493
453
|
testLogger
|
|
@@ -503,13 +463,7 @@ describe('redelegations', () => {
|
|
|
503
463
|
extra: { contractPayload: encodeUndelegateCalldata(VALIDATOR, AMOUNT_USEI) },
|
|
504
464
|
})
|
|
505
465
|
|
|
506
|
-
const result = await resolveStakingValidator(
|
|
507
|
-
mockConfig,
|
|
508
|
-
SEI_CURRENCY,
|
|
509
|
-
op,
|
|
510
|
-
'undelegate',
|
|
511
|
-
testLogger
|
|
512
|
-
)
|
|
466
|
+
const result = await resolveStakingValidator(mockConfig, op, 'undelegate', testLogger)
|
|
513
467
|
|
|
514
468
|
expect(result).toMatchObject({ validatorAddress: VALIDATOR })
|
|
515
469
|
expect(result!.amount?.isEqualTo(EXPECTED_WEI.toString())).toBe(true)
|
|
@@ -517,18 +471,16 @@ describe('redelegations', () => {
|
|
|
517
471
|
|
|
518
472
|
it('should fall back to RPC when contractPayload is absent', async () => {
|
|
519
473
|
mockIsExternalNodeConfig.mockReturnValue(true)
|
|
520
|
-
mockWithApi.mockImplementation(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
})
|
|
474
|
+
mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
|
|
475
|
+
fn({
|
|
476
|
+
getTransaction: async () => ({
|
|
477
|
+
data: encodeUndelegateCalldata(VALIDATOR, AMOUNT_USEI),
|
|
478
|
+
}),
|
|
479
|
+
})
|
|
527
480
|
)
|
|
528
481
|
|
|
529
482
|
const result = await resolveStakingValidator(
|
|
530
483
|
mockConfig,
|
|
531
|
-
SEI_CURRENCY,
|
|
532
484
|
makeOperation({ type: 'UNDELEGATE', extra: {} }),
|
|
533
485
|
'undelegate',
|
|
534
486
|
testLogger
|
|
@@ -542,9 +494,7 @@ describe('redelegations', () => {
|
|
|
542
494
|
type: 'UNDELEGATE',
|
|
543
495
|
extra: { contractPayload: '0xdeadbeef' },
|
|
544
496
|
})
|
|
545
|
-
expect(
|
|
546
|
-
await resolveStakingValidator(mockConfig, SEI_CURRENCY, op, 'undelegate', testLogger)
|
|
547
|
-
).toBeNull()
|
|
497
|
+
expect(await resolveStakingValidator(mockConfig, op, 'undelegate', testLogger)).toBeNull()
|
|
548
498
|
})
|
|
549
499
|
})
|
|
550
500
|
})
|
|
@@ -554,19 +504,19 @@ describe('redelegations', () => {
|
|
|
554
504
|
const DST = 'seivaloper1dst000000000000000000000000000000000'
|
|
555
505
|
const AMOUNT_USEI = 1_000_000n
|
|
556
506
|
const EXPECTED_WEI = AMOUNT_USEI * USEI_TO_EVM_SCALE
|
|
557
|
-
const unbondingMs =
|
|
507
|
+
const unbondingMs =
|
|
508
|
+
requireStakingContract(CHAIN_ID.SEI_EVM).unbondingPeriodDays! * 24 * 60 * 60 * 1000
|
|
558
509
|
|
|
559
510
|
beforeEach(() => jest.clearAllMocks())
|
|
560
511
|
|
|
561
512
|
it('should return [] for an unsupported currencyId', async () => {
|
|
562
|
-
expect(await buildRedelegationsFromOps(
|
|
513
|
+
expect(await buildRedelegationsFromOps(ethereumConfig, [], testLogger)).toEqual([])
|
|
563
514
|
})
|
|
564
515
|
|
|
565
516
|
it('should ignore non-REDELEGATE operations', async () => {
|
|
566
517
|
expect(
|
|
567
518
|
await buildRedelegationsFromOps(
|
|
568
519
|
mockConfig,
|
|
569
|
-
SEI_CURRENCY,
|
|
570
520
|
[makeOperation({ type: 'DELEGATE' })],
|
|
571
521
|
testLogger
|
|
572
522
|
)
|
|
@@ -580,9 +530,7 @@ describe('redelegations', () => {
|
|
|
580
530
|
extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
|
|
581
531
|
date: new Date(),
|
|
582
532
|
})
|
|
583
|
-
expect(await buildRedelegationsFromOps(mockConfig,
|
|
584
|
-
[]
|
|
585
|
-
)
|
|
533
|
+
expect(await buildRedelegationsFromOps(mockConfig, [op], testLogger)).toEqual([])
|
|
586
534
|
})
|
|
587
535
|
|
|
588
536
|
it('should ignore operations whose unbonding period has already elapsed', async () => {
|
|
@@ -591,9 +539,7 @@ describe('redelegations', () => {
|
|
|
591
539
|
extra: { contractPayload: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) },
|
|
592
540
|
date: new Date(Date.now() - unbondingMs - 1000),
|
|
593
541
|
})
|
|
594
|
-
expect(await buildRedelegationsFromOps(mockConfig,
|
|
595
|
-
[]
|
|
596
|
-
)
|
|
542
|
+
expect(await buildRedelegationsFromOps(mockConfig, [op], testLogger)).toEqual([])
|
|
597
543
|
})
|
|
598
544
|
|
|
599
545
|
it('should build a redelegation from a recent REDELEGATE op with cached calldata', async () => {
|
|
@@ -603,7 +549,7 @@ describe('redelegations', () => {
|
|
|
603
549
|
date: new Date(),
|
|
604
550
|
})
|
|
605
551
|
|
|
606
|
-
const result = await buildRedelegationsFromOps(mockConfig,
|
|
552
|
+
const result = await buildRedelegationsFromOps(mockConfig, [op], testLogger)
|
|
607
553
|
|
|
608
554
|
expect(result).toHaveLength(1)
|
|
609
555
|
expect(result[0]).toMatchObject({
|
|
@@ -617,16 +563,14 @@ describe('redelegations', () => {
|
|
|
617
563
|
|
|
618
564
|
it('should fetch calldata from RPC when contractPayload is absent', async () => {
|
|
619
565
|
mockIsExternalNodeConfig.mockReturnValue(true)
|
|
620
|
-
mockWithApi.mockImplementation(
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
})
|
|
566
|
+
mockWithApi.mockImplementation((_config: unknown, fn: (p: unknown) => unknown) =>
|
|
567
|
+
fn({
|
|
568
|
+
getTransaction: async () => ({ data: encodeRedelegateCalldata(SRC, DST, AMOUNT_USEI) }),
|
|
569
|
+
})
|
|
625
570
|
)
|
|
626
571
|
|
|
627
572
|
const result = await buildRedelegationsFromOps(
|
|
628
573
|
mockConfig,
|
|
629
|
-
SEI_CURRENCY,
|
|
630
574
|
[makeOperation({ type: 'REDELEGATE', extra: {}, date: new Date() })],
|
|
631
575
|
testLogger
|
|
632
576
|
)
|
|
@@ -641,9 +585,7 @@ describe('redelegations', () => {
|
|
|
641
585
|
extra: { contractPayload: '0xdeadbeef' },
|
|
642
586
|
date: new Date(),
|
|
643
587
|
})
|
|
644
|
-
expect(await buildRedelegationsFromOps(mockConfig,
|
|
645
|
-
[]
|
|
646
|
-
)
|
|
588
|
+
expect(await buildRedelegationsFromOps(mockConfig, [op], testLogger)).toEqual([])
|
|
647
589
|
})
|
|
648
590
|
|
|
649
591
|
it('should process multiple operations correctly', async () => {
|
|
@@ -660,7 +602,7 @@ describe('redelegations', () => {
|
|
|
660
602
|
}),
|
|
661
603
|
]
|
|
662
604
|
|
|
663
|
-
const result = await buildRedelegationsFromOps(mockConfig,
|
|
605
|
+
const result = await buildRedelegationsFromOps(mockConfig, ops, testLogger)
|
|
664
606
|
expect(result).toHaveLength(2)
|
|
665
607
|
expect(result[0].validatorSrcAddress).toBe(SRC)
|
|
666
608
|
expect(result[1].validatorSrcAddress).toBe(DST)
|