@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
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
5
|
import type { DeepPartialCtor } from '@ledgerhq/coin-module-framework/test/utils'
|
|
6
6
|
import { ethers } from 'ethers'
|
|
7
|
+
import { CHAIN_ID } from '../config'
|
|
7
8
|
import { testLogger } from '../fixtures/context.fixtures'
|
|
8
|
-
import {
|
|
9
|
+
import { requireStakingContract } from '../fixtures/staking.fixtures'
|
|
9
10
|
import { fetchUnbondings } from './unbondings'
|
|
10
11
|
import { USEI_TO_EVM_SCALE } from './utils'
|
|
11
12
|
|
|
@@ -29,14 +30,13 @@ const mockIsExternalNodeConfig = jest.mocked(require('../network/node/types').is
|
|
|
29
30
|
const mockNode: EvmConfigInfo['node'] = { type: 'external', uri: 'https://sei-evm.coin.ledger.com' }
|
|
30
31
|
const mockConfig: EvmConfigInfo = {
|
|
31
32
|
status: { type: 'active' },
|
|
32
|
-
chainId:
|
|
33
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
33
34
|
name: 'Sei',
|
|
34
35
|
unit: { name: 'sei', code: 'SEI', magnitude: 18 },
|
|
35
36
|
node: mockNode,
|
|
36
37
|
explorer: { type: 'none' },
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
const SEI_CURRENCY = 'sei_evm'
|
|
40
40
|
const EVM_ADDRESS = '0x1111111111111111111111111111111111111111'
|
|
41
41
|
const VALIDATOR = 'seivaloper1qe8uuf5x69c526h4nzxwv4ltftr73v7qnkypla'
|
|
42
42
|
const OTHER_VALIDATOR = 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn'
|
|
@@ -79,38 +79,44 @@ describe('staking/unbondings', () => {
|
|
|
79
79
|
mockIsExternalNodeConfig.mockImplementation((node: unknown) => node === mockNode)
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
-
it('should return [] for
|
|
83
|
-
expect(
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
it('should return [] for a chain without staking', async () => {
|
|
83
|
+
expect(
|
|
84
|
+
await fetchUnbondings(
|
|
85
|
+
{ ...mockConfig, chainId: CHAIN_ID.ETHEREUM },
|
|
86
|
+
EVM_ADDRESS,
|
|
87
|
+
testLogger
|
|
88
|
+
)
|
|
89
|
+
).toEqual([])
|
|
86
90
|
expect(mockNetwork).not.toHaveBeenCalled()
|
|
87
91
|
})
|
|
88
92
|
|
|
89
|
-
it('should return [] for a
|
|
90
|
-
expect(
|
|
93
|
+
it('should return [] for a chain without an unbonding strategy', async () => {
|
|
94
|
+
expect(
|
|
95
|
+
await fetchUnbondings({ ...mockConfig, chainId: CHAIN_ID.CELO }, EVM_ADDRESS, testLogger)
|
|
96
|
+
).toEqual([])
|
|
91
97
|
expect(mockNetwork).not.toHaveBeenCalled()
|
|
92
98
|
})
|
|
93
99
|
|
|
94
100
|
it('should return [] when the address is not associated on-chain yet', async () => {
|
|
95
101
|
mockGetSeiAddr.mockResolvedValue(null)
|
|
96
|
-
expect(await fetchUnbondings(mockConfig,
|
|
102
|
+
expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
|
|
97
103
|
expect(mockNetwork).not.toHaveBeenCalled()
|
|
98
104
|
})
|
|
99
105
|
|
|
100
106
|
it('should return [] when the REST call fails', async () => {
|
|
101
107
|
mockNetwork.mockRejectedValue(new Error('network error'))
|
|
102
|
-
expect(await fetchUnbondings(mockConfig,
|
|
108
|
+
expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
|
|
103
109
|
})
|
|
104
110
|
|
|
105
111
|
it('should return [] when the response has no unbonding_responses array', async () => {
|
|
106
112
|
mockNetwork.mockResolvedValue({ data: {} })
|
|
107
|
-
expect(await fetchUnbondings(mockConfig,
|
|
113
|
+
expect(await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)).toEqual([])
|
|
108
114
|
})
|
|
109
115
|
|
|
110
116
|
it('should query the delegator endpoint with the resolved Cosmos address', async () => {
|
|
111
117
|
mockNetwork.mockResolvedValue({ data: { unbonding_responses: [] } })
|
|
112
118
|
|
|
113
|
-
await fetchUnbondings(mockConfig,
|
|
119
|
+
await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
114
120
|
|
|
115
121
|
expect(mockNetwork).toHaveBeenCalledWith({
|
|
116
122
|
url: 'https://rest.sei-apis.com/cosmos/staking/v1beta1/delegators/sei1defaultcosmosaddressfortest/unbonding_delegations',
|
|
@@ -130,7 +136,7 @@ describe('staking/unbondings', () => {
|
|
|
130
136
|
},
|
|
131
137
|
})
|
|
132
138
|
|
|
133
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
139
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
134
140
|
|
|
135
141
|
expect(stakes).toHaveLength(1)
|
|
136
142
|
expect(stakes[0]).toMatchObject({
|
|
@@ -153,7 +159,7 @@ describe('staking/unbondings', () => {
|
|
|
153
159
|
},
|
|
154
160
|
})
|
|
155
161
|
|
|
156
|
-
const [stake] = await fetchUnbondings(mockConfig,
|
|
162
|
+
const [stake] = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
157
163
|
|
|
158
164
|
// Sei credits the funds back automatically: no withdraw transaction exists.
|
|
159
165
|
expect(stake.actions).toEqual([])
|
|
@@ -172,7 +178,7 @@ describe('staking/unbondings', () => {
|
|
|
172
178
|
},
|
|
173
179
|
})
|
|
174
180
|
|
|
175
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
181
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
176
182
|
|
|
177
183
|
expect(stakes).toHaveLength(2)
|
|
178
184
|
expect(new Set(stakes.map((s) => s.uid)).size).toBe(2)
|
|
@@ -194,7 +200,7 @@ describe('staking/unbondings', () => {
|
|
|
194
200
|
},
|
|
195
201
|
})
|
|
196
202
|
|
|
197
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
203
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
198
204
|
|
|
199
205
|
expect(stakes.map((s) => s.delegate)).toEqual([VALIDATOR, OTHER_VALIDATOR])
|
|
200
206
|
})
|
|
@@ -211,7 +217,7 @@ describe('staking/unbondings', () => {
|
|
|
211
217
|
},
|
|
212
218
|
})
|
|
213
219
|
|
|
214
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
220
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
215
221
|
|
|
216
222
|
expect(stakes).toHaveLength(1)
|
|
217
223
|
expect(stakes[0].amount).toBe(2000000n * USEI_TO_EVM_SCALE)
|
|
@@ -231,7 +237,7 @@ describe('staking/unbondings', () => {
|
|
|
231
237
|
},
|
|
232
238
|
})
|
|
233
239
|
|
|
234
|
-
const stakes = await fetchUnbondings(mockConfig,
|
|
240
|
+
const stakes = await fetchUnbondings(mockConfig, EVM_ADDRESS, testLogger)
|
|
235
241
|
|
|
236
242
|
expect(stakes).toHaveLength(1)
|
|
237
243
|
expect(stakes[0].amount).toBe(3000000n * USEI_TO_EVM_SCALE)
|
|
@@ -240,7 +246,7 @@ describe('staking/unbondings', () => {
|
|
|
240
246
|
|
|
241
247
|
describe('sei_evm unbonding strategy config', () => {
|
|
242
248
|
it('should be configured to read the Cosmos unbonding_delegations endpoint', () => {
|
|
243
|
-
expect(
|
|
249
|
+
expect(requireStakingContract(CHAIN_ID.SEI_EVM).unbondingStrategy).toEqual({
|
|
244
250
|
type: 'cosmos-rest',
|
|
245
251
|
endpoint: '/cosmos/staking/v1beta1/delegators/{address}/unbonding_delegations',
|
|
246
252
|
})
|
|
@@ -120,11 +120,10 @@ async function fetchCosmosRestUnbondings(
|
|
|
120
120
|
*/
|
|
121
121
|
export async function fetchUnbondings(
|
|
122
122
|
evmConfig: EvmConfigInfo,
|
|
123
|
-
currencyId: string,
|
|
124
123
|
evmAddress: string,
|
|
125
124
|
logger: Logger
|
|
126
125
|
): Promise<Stake[]> {
|
|
127
|
-
const config = STAKING_CONTRACTS[
|
|
126
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
128
127
|
const strategy = config?.unbondingStrategy
|
|
129
128
|
if (!config || !strategy || strategy.type === 'none') return []
|
|
130
129
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo, EvmContext } from '../../config'
|
|
4
|
+
import type { ChainId, EvmConfigInfo, EvmContext } from '../../config'
|
|
5
5
|
import type { ValidatorApi } from './types'
|
|
6
6
|
import type { Cursor, Page, Validator } from '@ledgerhq/coin-module-framework/api/index'
|
|
7
7
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
8
8
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
9
|
+
import { CHAIN_ID } from '../../config'
|
|
9
10
|
import { STAKING_CONTRACTS } from '../contracts'
|
|
10
11
|
import monadValidatorApi from './monad'
|
|
11
12
|
import seiValidatorApi from './sei'
|
|
@@ -18,15 +19,15 @@ import zeroGravityValidatorApi from './zero_gravity'
|
|
|
18
19
|
*/
|
|
19
20
|
const CACHE_MAX_AGE_MS = 30 * 1000
|
|
20
21
|
|
|
21
|
-
export const getValidatorApi = (
|
|
22
|
-
switch (
|
|
23
|
-
case
|
|
22
|
+
export const getValidatorApi = (chainId: ChainId): ValidatorApi | undefined => {
|
|
23
|
+
switch (chainId) {
|
|
24
|
+
case CHAIN_ID.SEI_EVM:
|
|
24
25
|
return seiValidatorApi
|
|
25
|
-
case
|
|
26
|
+
case CHAIN_ID.MONAD:
|
|
26
27
|
return monadValidatorApi
|
|
27
|
-
case
|
|
28
|
+
case CHAIN_ID.ZERO_GRAVITY:
|
|
28
29
|
return zeroGravityValidatorApi
|
|
29
|
-
case
|
|
30
|
+
case CHAIN_ID.SOMNIA:
|
|
30
31
|
return somniaValidatorApi
|
|
31
32
|
default:
|
|
32
33
|
return undefined
|
|
@@ -35,46 +36,44 @@ export const getValidatorApi = (currencyId: string): ValidatorApi | undefined =>
|
|
|
35
36
|
|
|
36
37
|
const resolveValidators = async (
|
|
37
38
|
config: EvmConfigInfo,
|
|
38
|
-
currencyId: string,
|
|
39
39
|
logger: Logger,
|
|
40
40
|
cursor?: Cursor
|
|
41
41
|
): Promise<Page<Validator>> => {
|
|
42
|
-
const api = getValidatorApi(
|
|
42
|
+
const api = getValidatorApi(config.chainId)
|
|
43
43
|
if (!api) return { items: [], next: undefined }
|
|
44
|
-
return api.fetchValidators(config,
|
|
44
|
+
return api.fetchValidators(config, logger, cursor)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// One cache key per page, so each page of a paginated chain (e.g. Monad) is
|
|
48
48
|
// cached and deduplicated independently. Because makeLRUCache stores the pending
|
|
49
49
|
// promise, concurrent callers (e.g. Info modal + Delegate modal opening in quick
|
|
50
50
|
// succession) share one in-flight fetch — no separate request-deduplication map needed.
|
|
51
|
-
const pageKey = (
|
|
51
|
+
const pageKey = (chainId: ChainId, cursor?: Cursor): string => `${chainId}-${cursor ?? ''}`
|
|
52
52
|
|
|
53
53
|
const validatorsCache = makeLRUCache(
|
|
54
|
-
(config: EvmConfigInfo,
|
|
55
|
-
resolveValidators(config,
|
|
56
|
-
// config
|
|
57
|
-
//
|
|
58
|
-
(
|
|
59
|
-
pageKey(currencyId, cursor),
|
|
54
|
+
(config: EvmConfigInfo, logger: Logger, cursor?: Cursor) =>
|
|
55
|
+
resolveValidators(config, logger, cursor),
|
|
56
|
+
// Only the chain id of config is part of the key: config and logger are otherwise
|
|
57
|
+
// deterministic/side-channel per chain, so they are intentionally excluded.
|
|
58
|
+
(config: EvmConfigInfo, _logger: Logger, cursor?: Cursor) => pageKey(config.chainId, cursor),
|
|
60
59
|
{ max: 50, ttl: CACHE_MAX_AGE_MS }
|
|
61
60
|
)
|
|
62
61
|
|
|
63
62
|
// makeLRUCache exposes no key enumeration, so we track the page keys we've issued
|
|
64
|
-
// to support clearing every page of a single
|
|
63
|
+
// to support clearing every page of a single chain (keys are `chainId-cursor`).
|
|
65
64
|
const issuedKeys = new Set<string>()
|
|
66
65
|
|
|
67
|
-
export const clearValidatorsCache = (
|
|
68
|
-
if (
|
|
66
|
+
export const clearValidatorsCache = (chainId?: ChainId): void => {
|
|
67
|
+
if (chainId === undefined) {
|
|
69
68
|
validatorsCache.reset()
|
|
70
69
|
issuedKeys.clear()
|
|
71
70
|
return
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
// Evict every cached page of this
|
|
75
|
-
//
|
|
73
|
+
// Evict every cached page of this chain (the `-` delimiter keeps e.g.
|
|
74
|
+
// chain 1 from matching chain 10).
|
|
76
75
|
for (const key of issuedKeys) {
|
|
77
|
-
if (key.startsWith(`${
|
|
76
|
+
if (key.startsWith(`${chainId}-`)) {
|
|
78
77
|
validatorsCache.clear(key)
|
|
79
78
|
issuedKeys.delete(key)
|
|
80
79
|
}
|
|
@@ -83,15 +82,14 @@ export const clearValidatorsCache = (currencyId?: string): void => {
|
|
|
83
82
|
|
|
84
83
|
export const getValidators = async (
|
|
85
84
|
config: EvmConfigInfo,
|
|
86
|
-
currencyId: string,
|
|
87
85
|
logger: Logger,
|
|
88
86
|
cursor?: Cursor
|
|
89
87
|
): Promise<Page<Validator>> => {
|
|
90
|
-
const key = pageKey(
|
|
88
|
+
const key = pageKey(config.chainId, cursor)
|
|
91
89
|
issuedKeys.add(key)
|
|
92
90
|
|
|
93
91
|
try {
|
|
94
|
-
const page = await validatorsCache(config,
|
|
92
|
+
const page = await validatorsCache(config, logger, cursor)
|
|
95
93
|
// Never keep an empty page cached, so a transient empty response is retried next time.
|
|
96
94
|
if (page.items.length === 0) {
|
|
97
95
|
validatorsCache.clear(key)
|
|
@@ -111,49 +109,45 @@ export const getValidators = async (
|
|
|
111
109
|
* cache entry already returns without a network call, so repeated calls are cheap.
|
|
112
110
|
* Only the first page is warmed; subsequent pages are fetched lazily by the hook.
|
|
113
111
|
*/
|
|
114
|
-
export const prefetchValidators = (
|
|
115
|
-
config
|
|
116
|
-
currencyId: string,
|
|
117
|
-
logger: Logger
|
|
118
|
-
): void => {
|
|
119
|
-
void getValidators(config, currencyId, logger).catch(() => {
|
|
112
|
+
export const prefetchValidators = (config: EvmConfigInfo, logger: Logger): void => {
|
|
113
|
+
void getValidators(config, logger).catch(() => {
|
|
120
114
|
/* swallow: the hook surfaces errors via its own flow */
|
|
121
115
|
})
|
|
122
116
|
}
|
|
123
117
|
|
|
124
|
-
export const getValidatorExplorerUrl = (
|
|
125
|
-
STAKING_CONTRACTS[
|
|
118
|
+
export const getValidatorExplorerUrl = (chainId: ChainId, address: string): string | undefined =>
|
|
119
|
+
STAKING_CONTRACTS[chainId]?.explorerConfig?.validatorUrl?.replace(
|
|
126
120
|
'$address',
|
|
127
121
|
address.toLowerCase()
|
|
128
122
|
)
|
|
129
123
|
|
|
130
|
-
export const getUnbondingPeriodDays = (
|
|
131
|
-
STAKING_CONTRACTS[
|
|
124
|
+
export const getUnbondingPeriodDays = (chainId: ChainId): number | undefined =>
|
|
125
|
+
STAKING_CONTRACTS[chainId]?.unbondingPeriodDays
|
|
132
126
|
|
|
133
|
-
export const getMaxRedelegations = (
|
|
134
|
-
STAKING_CONTRACTS[
|
|
127
|
+
export const getMaxRedelegations = (chainId: ChainId): number | undefined =>
|
|
128
|
+
STAKING_CONTRACTS[chainId]?.maxRedelegations
|
|
135
129
|
|
|
136
|
-
export const getDelegationVisibilityDelayMinutes = (
|
|
137
|
-
STAKING_CONTRACTS[
|
|
130
|
+
export const getDelegationVisibilityDelayMinutes = (chainId: ChainId): number | undefined =>
|
|
131
|
+
STAKING_CONTRACTS[chainId]?.delegationVisibilityDelayMinutes
|
|
138
132
|
|
|
139
|
-
export const hasDelegationVisibilityDelay = (
|
|
140
|
-
const minutes = getDelegationVisibilityDelayMinutes(
|
|
133
|
+
export const hasDelegationVisibilityDelay = (chainId: ChainId): boolean => {
|
|
134
|
+
const minutes = getDelegationVisibilityDelayMinutes(chainId)
|
|
141
135
|
return typeof minutes === 'number' && minutes > 0
|
|
142
136
|
}
|
|
143
137
|
|
|
144
|
-
export const hasUnbondingPeriod = (
|
|
145
|
-
const days = getUnbondingPeriodDays(
|
|
138
|
+
export const hasUnbondingPeriod = (chainId: ChainId): boolean => {
|
|
139
|
+
const days = getUnbondingPeriodDays(chainId)
|
|
146
140
|
return typeof days === 'number' && days > 0
|
|
147
141
|
}
|
|
148
142
|
|
|
149
|
-
export const hasRedelegation = (
|
|
150
|
-
typeof STAKING_CONTRACTS[
|
|
143
|
+
export const hasRedelegation = (chainId: ChainId): boolean =>
|
|
144
|
+
typeof STAKING_CONTRACTS[chainId]?.functions.redelegate === 'string'
|
|
151
145
|
|
|
152
|
-
export const hasCompound = (
|
|
153
|
-
typeof STAKING_CONTRACTS[
|
|
146
|
+
export const hasCompound = (chainId: ChainId): boolean =>
|
|
147
|
+
typeof STAKING_CONTRACTS[chainId]?.functions.compoundReward === 'string'
|
|
154
148
|
|
|
155
|
-
export const hasChainRewards = (
|
|
156
|
-
const config = STAKING_CONTRACTS[
|
|
149
|
+
export const hasChainRewards = (chainId: ChainId): boolean => {
|
|
150
|
+
const config = STAKING_CONTRACTS[chainId]
|
|
157
151
|
return typeof config?.functions.claimReward === 'string'
|
|
158
152
|
}
|
|
159
153
|
|
|
@@ -167,5 +161,5 @@ export const getValidatorsPage = async (
|
|
|
167
161
|
cursor?: Cursor
|
|
168
162
|
): Promise<Page<Validator>> => {
|
|
169
163
|
const config = await context.config(currencyId)
|
|
170
|
-
return getValidators(config,
|
|
164
|
+
return getValidators(config, context.logger, cursor)
|
|
171
165
|
}
|
|
@@ -7,6 +7,7 @@ import type { AddressLike } from 'ethers'
|
|
|
7
7
|
import network from '@ledgerhq/live-network'
|
|
8
8
|
import { ethers } from 'ethers'
|
|
9
9
|
import monadAbi from '../../abis/monad.abi.json'
|
|
10
|
+
import { CHAIN_ID } from '../../config'
|
|
10
11
|
import {
|
|
11
12
|
createMockEvmConfigInfo,
|
|
12
13
|
mkExternalNode,
|
|
@@ -32,12 +33,15 @@ const mockedWithApi = jest.mocked(withApi)
|
|
|
32
33
|
const mockedNetwork = jest.mocked(network)
|
|
33
34
|
|
|
34
35
|
const mockConfig = createMockEvmConfigInfo({
|
|
35
|
-
chainId:
|
|
36
|
+
chainId: CHAIN_ID.MONAD,
|
|
36
37
|
name: 'Monad',
|
|
37
38
|
unit: { name: 'MON', code: 'MON', magnitude: 18 },
|
|
38
39
|
node: mkExternalNode({ uri: 'https://monad.rpc/' }),
|
|
39
40
|
})
|
|
40
|
-
const ledgerConfig = createMockEvmConfigInfo({
|
|
41
|
+
const ledgerConfig = createMockEvmConfigInfo({
|
|
42
|
+
chainId: CHAIN_ID.MONAD,
|
|
43
|
+
node: mkLedgerNode(),
|
|
44
|
+
})
|
|
41
45
|
|
|
42
46
|
const monadIface = new ethers.Interface(monadAbi)
|
|
43
47
|
const PRECOMPILE = '0x0000000000000000000000000000000000001000'
|
|
@@ -75,7 +79,7 @@ const parseCalldata = (data: string | Uint8Array) =>
|
|
|
75
79
|
|
|
76
80
|
const setupRpc = (handler: CallHandler) => {
|
|
77
81
|
const callMock = jest.fn(handler)
|
|
78
|
-
mockedWithApi.mockImplementation(async (_config,
|
|
82
|
+
mockedWithApi.mockImplementation(async (_config, fn) => {
|
|
79
83
|
const api = mkJsonRpcProvider()
|
|
80
84
|
jest.spyOn(api, 'call').mockImplementation(callMock)
|
|
81
85
|
return fn(api)
|
|
@@ -175,7 +179,7 @@ describe('staking/validators/monad', () => {
|
|
|
175
179
|
})
|
|
176
180
|
)
|
|
177
181
|
|
|
178
|
-
expect(await getValidators(mockConfig,
|
|
182
|
+
expect(await getValidators(mockConfig, testLogger)).toStrictEqual({
|
|
179
183
|
items: [
|
|
180
184
|
{
|
|
181
185
|
id: '1',
|
|
@@ -204,7 +208,7 @@ describe('staking/validators/monad', () => {
|
|
|
204
208
|
|
|
205
209
|
// a non-empty page is cached: the second read makes no further RPC calls
|
|
206
210
|
const callsAfterFirst = callMock.mock.calls.length
|
|
207
|
-
await getValidators(mockConfig,
|
|
211
|
+
await getValidators(mockConfig, testLogger)
|
|
208
212
|
expect(callMock.mock.calls.length).toBe(callsAfterFirst)
|
|
209
213
|
})
|
|
210
214
|
|
|
@@ -226,7 +230,7 @@ describe('staking/validators/monad', () => {
|
|
|
226
230
|
status: 200,
|
|
227
231
|
})
|
|
228
232
|
|
|
229
|
-
const page = await getValidators(mockConfig,
|
|
233
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
230
234
|
|
|
231
235
|
expect(page.items[0]).toMatchObject({
|
|
232
236
|
address: ethers.computeAddress(
|
|
@@ -258,7 +262,7 @@ describe('staking/validators/monad', () => {
|
|
|
258
262
|
})
|
|
259
263
|
)
|
|
260
264
|
|
|
261
|
-
const page = await getValidators(mockConfig,
|
|
265
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
262
266
|
|
|
263
267
|
expect(page.items).toHaveLength(1)
|
|
264
268
|
expect(page.items[0]).toMatchObject({
|
|
@@ -277,19 +281,19 @@ describe('staking/validators/monad', () => {
|
|
|
277
281
|
})
|
|
278
282
|
)
|
|
279
283
|
|
|
280
|
-
const page = await getValidators(mockConfig,
|
|
284
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
281
285
|
|
|
282
286
|
expect(page.items).toStrictEqual([])
|
|
283
287
|
expect(page.next).toBeUndefined()
|
|
284
288
|
|
|
285
289
|
// empty results are not cached, so the next read hits the precompile again
|
|
286
290
|
const callsAfterFirst = callMock.mock.calls.length
|
|
287
|
-
await getValidators(mockConfig,
|
|
291
|
+
await getValidators(mockConfig, testLogger)
|
|
288
292
|
expect(callMock.mock.calls.length).toBeGreaterThan(callsAfterFirst)
|
|
289
293
|
})
|
|
290
294
|
|
|
291
295
|
it('returns an empty page when the node config is not external', async () => {
|
|
292
|
-
const page = await getValidators(ledgerConfig,
|
|
296
|
+
const page = await getValidators(ledgerConfig, testLogger)
|
|
293
297
|
|
|
294
298
|
expect(page.items).toStrictEqual([])
|
|
295
299
|
expect(page.next).toBeUndefined()
|
|
@@ -305,7 +309,7 @@ describe('staking/validators/monad', () => {
|
|
|
305
309
|
})
|
|
306
310
|
)
|
|
307
311
|
|
|
308
|
-
const page = await getValidators(mockConfig,
|
|
312
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
309
313
|
|
|
310
314
|
expect(page.items).toHaveLength(2)
|
|
311
315
|
expect(page.next).toBe('100')
|
|
@@ -322,10 +326,10 @@ describe('staking/validators/monad', () => {
|
|
|
322
326
|
})
|
|
323
327
|
)
|
|
324
328
|
|
|
325
|
-
const first = await getValidators(mockConfig,
|
|
329
|
+
const first = await getValidators(mockConfig, testLogger)
|
|
326
330
|
expect(first.next).toBe('100')
|
|
327
331
|
|
|
328
|
-
const second = await getValidators(mockConfig,
|
|
332
|
+
const second = await getValidators(mockConfig, testLogger, first.next)
|
|
329
333
|
expect(second.items).toHaveLength(1)
|
|
330
334
|
expect(second.next).toBeUndefined()
|
|
331
335
|
})
|
|
@@ -342,7 +346,7 @@ describe('staking/validators/monad', () => {
|
|
|
342
346
|
})
|
|
343
347
|
)
|
|
344
348
|
|
|
345
|
-
const page = await getValidators(mockConfig,
|
|
349
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
346
350
|
|
|
347
351
|
expect(page.next).toBeUndefined()
|
|
348
352
|
})
|
|
@@ -357,10 +361,10 @@ describe('staking/validators/monad', () => {
|
|
|
357
361
|
})
|
|
358
362
|
)
|
|
359
363
|
|
|
360
|
-
await getValidators(mockConfig,
|
|
364
|
+
await getValidators(mockConfig, testLogger)
|
|
361
365
|
const callCountAfterFirst = callMock.mock.calls.length
|
|
362
366
|
|
|
363
|
-
const second = await getValidators(mockConfig,
|
|
367
|
+
const second = await getValidators(mockConfig, testLogger)
|
|
364
368
|
expect(second.items).toHaveLength(1)
|
|
365
369
|
expect(callMock.mock.calls.length).toBe(callCountAfterFirst)
|
|
366
370
|
})
|
|
@@ -376,8 +380,8 @@ describe('staking/validators/monad', () => {
|
|
|
376
380
|
})
|
|
377
381
|
)
|
|
378
382
|
|
|
379
|
-
const firstPage = await getValidators(mockConfig,
|
|
380
|
-
const secondPage = await getValidators(mockConfig,
|
|
383
|
+
const firstPage = await getValidators(mockConfig, testLogger)
|
|
384
|
+
const secondPage = await getValidators(mockConfig, testLogger, '100')
|
|
381
385
|
const callsAfterBoth = callMock.mock.calls.length
|
|
382
386
|
|
|
383
387
|
expect(firstPage).toStrictEqual({
|
|
@@ -398,12 +402,12 @@ describe('staking/validators/monad', () => {
|
|
|
398
402
|
expect(secondPage.next).toBeUndefined()
|
|
399
403
|
|
|
400
404
|
// both cursors are now cached independently — no further RPC calls
|
|
401
|
-
expect(await getValidators(mockConfig,
|
|
402
|
-
expect(await getValidators(mockConfig,
|
|
405
|
+
expect(await getValidators(mockConfig, testLogger)).toStrictEqual(firstPage)
|
|
406
|
+
expect(await getValidators(mockConfig, testLogger, '100')).toStrictEqual(secondPage)
|
|
403
407
|
expect(callMock.mock.calls.length).toBe(callsAfterBoth)
|
|
404
408
|
})
|
|
405
409
|
|
|
406
|
-
it('clearValidatorsCache(
|
|
410
|
+
it('clearValidatorsCache(chainId) drops every cached cursor for that chain', async () => {
|
|
407
411
|
const callMock = setupRpc(
|
|
408
412
|
routeByName({
|
|
409
413
|
getExecutionValidatorSet: (startIndex) =>
|
|
@@ -414,15 +418,15 @@ describe('staking/validators/monad', () => {
|
|
|
414
418
|
})
|
|
415
419
|
)
|
|
416
420
|
|
|
417
|
-
await getValidators(mockConfig,
|
|
418
|
-
await getValidators(mockConfig,
|
|
421
|
+
await getValidators(mockConfig, testLogger)
|
|
422
|
+
await getValidators(mockConfig, testLogger, '100')
|
|
419
423
|
const callsBeforeClear = callMock.mock.calls.length
|
|
420
424
|
|
|
421
|
-
clearValidatorsCache(
|
|
425
|
+
clearValidatorsCache(CHAIN_ID.MONAD)
|
|
422
426
|
|
|
423
427
|
// every cursor was evicted, so both reads hit the precompile again
|
|
424
|
-
await getValidators(mockConfig,
|
|
425
|
-
await getValidators(mockConfig,
|
|
428
|
+
await getValidators(mockConfig, testLogger)
|
|
429
|
+
await getValidators(mockConfig, testLogger, '100')
|
|
426
430
|
expect(callMock.mock.calls.length).toBeGreaterThan(callsBeforeClear)
|
|
427
431
|
})
|
|
428
432
|
})
|
|
@@ -440,7 +444,7 @@ describe('staking/validators/monad', () => {
|
|
|
440
444
|
})
|
|
441
445
|
)
|
|
442
446
|
|
|
443
|
-
expect(await getValidatorAddressById(mockConfig,
|
|
447
|
+
expect(await getValidatorAddressById(mockConfig, 7n, testLogger)).toEqual(
|
|
444
448
|
ethers.computeAddress(
|
|
445
449
|
'0x036e44a092493800e427b2b08d3427d804348b1368ecd0a6af6510ae40ce507187'
|
|
446
450
|
)
|
|
@@ -448,13 +452,13 @@ describe('staking/validators/monad', () => {
|
|
|
448
452
|
})
|
|
449
453
|
|
|
450
454
|
it('returns null when the node config is not external', async () => {
|
|
451
|
-
expect(await getValidatorAddressById(ledgerConfig,
|
|
455
|
+
expect(await getValidatorAddressById(ledgerConfig, 7n, testLogger)).toBeNull()
|
|
452
456
|
})
|
|
453
457
|
|
|
454
458
|
it('returns null when the getValidator call fails', async () => {
|
|
455
459
|
setupRpc(routeByName({ getValidator: () => new Error('boom') }))
|
|
456
460
|
|
|
457
|
-
expect(await getValidatorAddressById(mockConfig,
|
|
461
|
+
expect(await getValidatorAddressById(mockConfig, 7n, testLogger)).toBeNull()
|
|
458
462
|
})
|
|
459
463
|
})
|
|
460
464
|
|
|
@@ -470,7 +474,7 @@ describe('staking/validators/monad', () => {
|
|
|
470
474
|
}
|
|
471
475
|
|
|
472
476
|
const fetchStakes = (config: EvmConfigInfo = mockConfig) =>
|
|
473
|
-
fetchMonadStakes(config, DELEGATOR, dummyStakingConfig,
|
|
477
|
+
fetchMonadStakes(config, DELEGATOR, dummyStakingConfig, testLogger)
|
|
474
478
|
|
|
475
479
|
const encodeDelegator = (
|
|
476
480
|
stake: bigint,
|
|
@@ -858,14 +862,9 @@ describe('staking/validators/monad', () => {
|
|
|
858
862
|
})
|
|
859
863
|
)
|
|
860
864
|
|
|
861
|
-
const stakes = await fetchMonadStakes(
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
dummyStakingConfig,
|
|
865
|
-
'monad',
|
|
866
|
-
testLogger,
|
|
867
|
-
['92']
|
|
868
|
-
)
|
|
865
|
+
const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, dummyStakingConfig, testLogger, [
|
|
866
|
+
'92',
|
|
867
|
+
])
|
|
869
868
|
|
|
870
869
|
const withdrawal = stakes.find((s) => s.details?.validatorId === '92')
|
|
871
870
|
expect(withdrawal).toMatchObject({
|
|
@@ -888,14 +887,9 @@ describe('staking/validators/monad', () => {
|
|
|
888
887
|
})
|
|
889
888
|
)
|
|
890
889
|
|
|
891
|
-
const stakes = await fetchMonadStakes(
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
dummyStakingConfig,
|
|
895
|
-
'monad',
|
|
896
|
-
testLogger,
|
|
897
|
-
['7']
|
|
898
|
-
)
|
|
890
|
+
const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, dummyStakingConfig, testLogger, [
|
|
891
|
+
'7',
|
|
892
|
+
])
|
|
899
893
|
|
|
900
894
|
expect(stakes).toHaveLength(1)
|
|
901
895
|
expect(delegatorCallCount).toBe(1)
|
|
@@ -926,21 +920,21 @@ describe('staking/validators/monad', () => {
|
|
|
926
920
|
it('extracts a validator id from a DELEGATE op', () => {
|
|
927
921
|
const payload = monadIface.encodeFunctionData('delegate', [42n])
|
|
928
922
|
expect(
|
|
929
|
-
extractMonadKnownValIds(
|
|
923
|
+
extractMonadKnownValIds(CHAIN_ID.MONAD, [makeOp('DELEGATE', payload)], testLogger)
|
|
930
924
|
).toStrictEqual(['42'])
|
|
931
925
|
})
|
|
932
926
|
|
|
933
927
|
it('extracts a validator id from an UNDELEGATE op', () => {
|
|
934
928
|
const payload = monadIface.encodeFunctionData('undelegate', [92n, 10_000_000_000n, 0n])
|
|
935
929
|
expect(
|
|
936
|
-
extractMonadKnownValIds(
|
|
930
|
+
extractMonadKnownValIds(CHAIN_ID.MONAD, [makeOp('UNDELEGATE', payload)], testLogger)
|
|
937
931
|
).toStrictEqual(['92'])
|
|
938
932
|
})
|
|
939
933
|
|
|
940
934
|
it('extracts a validator id from a WITHDRAW_UNBONDED op', () => {
|
|
941
935
|
const payload = monadIface.encodeFunctionData('withdraw', [7n, 3n])
|
|
942
936
|
expect(
|
|
943
|
-
extractMonadKnownValIds(
|
|
937
|
+
extractMonadKnownValIds(CHAIN_ID.MONAD, [makeOp('WITHDRAW_UNBONDED', payload)], testLogger)
|
|
944
938
|
).toStrictEqual(['7'])
|
|
945
939
|
})
|
|
946
940
|
|
|
@@ -948,7 +942,7 @@ describe('staking/validators/monad', () => {
|
|
|
948
942
|
const p1 = monadIface.encodeFunctionData('undelegate', [92n, 5_000_000_000n, 0n])
|
|
949
943
|
const p2 = monadIface.encodeFunctionData('undelegate', [92n, 5_000_000_000n, 1n])
|
|
950
944
|
const result = extractMonadKnownValIds(
|
|
951
|
-
|
|
945
|
+
CHAIN_ID.MONAD,
|
|
952
946
|
[makeOp('UNDELEGATE', p1), makeOp('UNDELEGATE', p2)],
|
|
953
947
|
testLogger
|
|
954
948
|
)
|
|
@@ -956,19 +950,23 @@ describe('staking/validators/monad', () => {
|
|
|
956
950
|
})
|
|
957
951
|
|
|
958
952
|
it('ignores ops whose type is not a staking function', () => {
|
|
959
|
-
const result = extractMonadKnownValIds(
|
|
953
|
+
const result = extractMonadKnownValIds(
|
|
954
|
+
CHAIN_ID.MONAD,
|
|
955
|
+
[makeOp('OUT'), makeOp('IN')],
|
|
956
|
+
testLogger
|
|
957
|
+
)
|
|
960
958
|
expect(result).toStrictEqual([])
|
|
961
959
|
})
|
|
962
960
|
|
|
963
961
|
it('skips ops with no contractPayload without throwing', () => {
|
|
964
|
-
const result = extractMonadKnownValIds(
|
|
962
|
+
const result = extractMonadKnownValIds(CHAIN_ID.MONAD, [makeOp('UNDELEGATE')], testLogger)
|
|
965
963
|
expect(result).toStrictEqual([])
|
|
966
964
|
})
|
|
967
965
|
|
|
968
|
-
it('returns an empty array for an unknown
|
|
966
|
+
it('returns an empty array for an unknown chainId (no ABI available)', () => {
|
|
969
967
|
const payload = monadIface.encodeFunctionData('undelegate', [7n, 1n, 0n])
|
|
970
968
|
expect(
|
|
971
|
-
extractMonadKnownValIds(
|
|
969
|
+
extractMonadKnownValIds(CHAIN_ID.ETHEREUM, [makeOp('UNDELEGATE', payload)], testLogger)
|
|
972
970
|
).toStrictEqual([])
|
|
973
971
|
})
|
|
974
972
|
})
|