@ledgerhq/coin-evm 10.0.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oxlintrc.json +2 -6
- package/CHANGELOG.md +54 -0
- package/docs/getBlock-internal-txs-schema.md +2 -2
- package/docs/network/node/index.md +1 -1
- package/lib/abis/index.d.ts +8 -0
- package/lib/abis/index.d.ts.map +1 -1
- package/lib/abis/index.js +30 -0
- package/lib/abis/index.js.map +1 -1
- package/lib/adapters/blockOperations.js +2 -2
- package/lib/adapters/blockOperations.js.map +1 -1
- package/lib/adapters/etherscan.d.ts +2 -1
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +2 -2
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts +2 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +2 -2
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +3 -2
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +94 -0
- package/lib/chains.d.ts.map +1 -0
- package/lib/chains.js +98 -0
- package/lib/chains.js.map +1 -0
- package/lib/config.d.ts +4 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -1
- package/lib/config.js.map +1 -1
- package/lib/internalTxSources.d.ts.map +1 -1
- package/lib/internalTxSources.js +21 -3
- package/lib/internalTxSources.js.map +1 -1
- package/lib/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/common.d.ts +1 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +22 -14
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +7 -4
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +11 -8
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +9 -9
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +17 -17
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -2
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +1 -1
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +10 -10
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js +9 -9
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +1 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/predicates.d.ts +17 -0
- package/lib/logic/predicates.d.ts.map +1 -0
- package/lib/logic/predicates.js +126 -0
- package/lib/logic/predicates.js.map +1 -0
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +9 -9
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +14 -13
- package/lib/logic.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +2 -3
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +6 -8
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +5 -5
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/types.d.ts +2 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js +11 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib/network/gasTracker/ledger.js +1 -3
- package/lib/network/gasTracker/ledger.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +22 -17
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/gethCallTracerToTraceBlockItems.d.ts.map +1 -1
- package/lib/network/node/gethCallTracerToTraceBlockItems.js +10 -12
- package/lib/network/node/gethCallTracerToTraceBlockItems.js.map +1 -1
- package/lib/network/node/index.d.ts +1 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +7 -7
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.d.ts +3 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +38 -24
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +104 -103
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +21 -22
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js +0 -27
- package/lib/network/node/types.js.map +1 -1
- package/lib/network/node/withNodeSources.d.ts.map +1 -1
- package/lib/network/node/withNodeSources.js +15 -15
- package/lib/network/node/withNodeSources.js.map +1 -1
- package/lib/nodeSources.d.ts.map +1 -1
- package/lib/nodeSources.js +11 -3
- package/lib/nodeSources.js.map +1 -1
- package/lib/staking/abis.d.ts +3 -2
- package/lib/staking/abis.d.ts.map +1 -1
- package/lib/staking/abis.js +10 -9
- package/lib/staking/abis.js.map +1 -1
- package/lib/staking/contracts.d.ts +3 -2
- package/lib/staking/contracts.d.ts.map +1 -1
- package/lib/staking/contracts.js +12 -13
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/detectOperationType.d.ts +2 -4
- package/lib/staking/detectOperationType.d.ts.map +1 -1
- package/lib/staking/detectOperationType.js +22 -21
- package/lib/staking/detectOperationType.js.map +1 -1
- package/lib/staking/encoder.d.ts +2 -1
- package/lib/staking/encoder.d.ts.map +1 -1
- package/lib/staking/encoder.js +8 -8
- package/lib/staking/encoder.js.map +1 -1
- package/lib/staking/fetchers.d.ts +2 -1
- package/lib/staking/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +27 -27
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/logic.d.ts +6 -6
- package/lib/staking/logic.d.ts.map +1 -1
- package/lib/staking/logic.js +14 -13
- package/lib/staking/logic.js.map +1 -1
- package/lib/staking/operations/index.d.ts +2 -1
- package/lib/staking/operations/index.d.ts.map +1 -1
- package/lib/staking/operations/index.js +39 -20
- package/lib/staking/operations/index.js.map +1 -1
- package/lib/staking/prepareIntents.d.ts +1 -1
- package/lib/staking/prepareIntents.d.ts.map +1 -1
- package/lib/staking/prepareIntents.js +14 -12
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/redelegations.d.ts +4 -4
- package/lib/staking/redelegations.d.ts.map +1 -1
- package/lib/staking/redelegations.js +22 -27
- package/lib/staking/redelegations.js.map +1 -1
- package/lib/staking/rewards.d.ts +1 -1
- package/lib/staking/rewards.d.ts.map +1 -1
- package/lib/staking/rewards.js +2 -2
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib/staking/rewardsFromReceipt.js +2 -2
- package/lib/staking/rewardsFromReceipt.js.map +1 -1
- package/lib/staking/transactionData.d.ts +2 -1
- package/lib/staking/transactionData.d.ts.map +1 -1
- package/lib/staking/transactionData.js +6 -6
- package/lib/staking/transactionData.js.map +1 -1
- package/lib/staking/unbondings.d.ts +1 -1
- package/lib/staking/unbondings.d.ts.map +1 -1
- package/lib/staking/unbondings.js +2 -2
- package/lib/staking/unbondings.js.map +1 -1
- package/lib/staking/utils.d.ts.map +1 -1
- package/lib/staking/utils.js +22 -27
- package/lib/staking/utils.js.map +1 -1
- package/lib/staking/validators/index.d.ts +14 -14
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +39 -38
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +5 -5
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +44 -37
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +1 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js +7 -6
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/sei.js +2 -2
- package/lib/staking/validators/sei.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts +4 -4
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js +25 -24
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/types.d.ts +1 -1
- package/lib/staking/validators/types.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts +1 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js +10 -9
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/staking.d.ts +5 -6
- package/lib/types/staking.d.ts.map +1 -1
- package/lib-es/abis/index.d.ts +8 -0
- package/lib-es/abis/index.d.ts.map +1 -1
- package/lib-es/abis/index.js +29 -0
- package/lib-es/abis/index.js.map +1 -1
- package/lib-es/adapters/blockOperations.js +1 -1
- package/lib-es/adapters/blockOperations.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts +2 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +2 -2
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts +2 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +2 -2
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +3 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +94 -0
- package/lib-es/chains.d.ts.map +1 -0
- package/lib-es/chains.js +95 -0
- package/lib-es/chains.js.map +1 -0
- package/lib-es/config.d.ts +4 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -0
- package/lib-es/config.js.map +1 -1
- package/lib-es/internalTxSources.d.ts.map +1 -1
- package/lib-es/internalTxSources.js +21 -3
- package/lib-es/internalTxSources.js.map +1 -1
- package/lib-es/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/common.d.ts +1 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +22 -14
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +7 -4
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +11 -8
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +9 -9
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +18 -18
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.js +2 -2
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +1 -1
- package/lib-es/logic/getNextSequence.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +10 -10
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js +9 -9
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +1 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/predicates.d.ts +17 -0
- package/lib-es/logic/predicates.d.ts.map +1 -0
- package/lib-es/logic/predicates.js +114 -0
- package/lib-es/logic/predicates.js.map +1 -0
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +9 -9
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +14 -13
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +2 -3
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +6 -8
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +5 -5
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +2 -2
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js +11 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib-es/network/gasTracker/ledger.js +1 -3
- package/lib-es/network/gasTracker/ledger.js.map +1 -1
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +22 -17
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.d.ts.map +1 -1
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.js +4 -6
- package/lib-es/network/node/gethCallTracerToTraceBlockItems.js.map +1 -1
- package/lib-es/network/node/index.d.ts +1 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +7 -7
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts +3 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +38 -24
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +102 -101
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +21 -22
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js +0 -25
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
- package/lib-es/network/node/withNodeSources.js +15 -15
- package/lib-es/network/node/withNodeSources.js.map +1 -1
- package/lib-es/nodeSources.d.ts.map +1 -1
- package/lib-es/nodeSources.js +11 -3
- package/lib-es/nodeSources.js.map +1 -1
- package/lib-es/staking/abis.d.ts +3 -2
- package/lib-es/staking/abis.d.ts.map +1 -1
- package/lib-es/staking/abis.js +10 -9
- package/lib-es/staking/abis.js.map +1 -1
- package/lib-es/staking/contracts.d.ts +3 -2
- package/lib-es/staking/contracts.d.ts.map +1 -1
- package/lib-es/staking/contracts.js +12 -13
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/detectOperationType.d.ts +2 -4
- package/lib-es/staking/detectOperationType.d.ts.map +1 -1
- package/lib-es/staking/detectOperationType.js +22 -21
- package/lib-es/staking/detectOperationType.js.map +1 -1
- package/lib-es/staking/encoder.d.ts +2 -1
- package/lib-es/staking/encoder.d.ts.map +1 -1
- package/lib-es/staking/encoder.js +8 -8
- package/lib-es/staking/encoder.js.map +1 -1
- package/lib-es/staking/fetchers.d.ts +2 -1
- package/lib-es/staking/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +27 -27
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/logic.d.ts +6 -6
- package/lib-es/staking/logic.d.ts.map +1 -1
- package/lib-es/staking/logic.js +14 -13
- package/lib-es/staking/logic.js.map +1 -1
- package/lib-es/staking/operations/index.d.ts +2 -1
- package/lib-es/staking/operations/index.d.ts.map +1 -1
- package/lib-es/staking/operations/index.js +39 -20
- package/lib-es/staking/operations/index.js.map +1 -1
- package/lib-es/staking/prepareIntents.d.ts +1 -1
- package/lib-es/staking/prepareIntents.d.ts.map +1 -1
- package/lib-es/staking/prepareIntents.js +13 -11
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/redelegations.d.ts +4 -4
- package/lib-es/staking/redelegations.d.ts.map +1 -1
- package/lib-es/staking/redelegations.js +19 -24
- package/lib-es/staking/redelegations.js.map +1 -1
- package/lib-es/staking/rewards.d.ts +1 -1
- package/lib-es/staking/rewards.d.ts.map +1 -1
- package/lib-es/staking/rewards.js +2 -2
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.js +2 -2
- package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
- package/lib-es/staking/transactionData.d.ts +2 -1
- package/lib-es/staking/transactionData.d.ts.map +1 -1
- package/lib-es/staking/transactionData.js +6 -6
- package/lib-es/staking/transactionData.js.map +1 -1
- package/lib-es/staking/unbondings.d.ts +1 -1
- package/lib-es/staking/unbondings.d.ts.map +1 -1
- package/lib-es/staking/unbondings.js +2 -2
- package/lib-es/staking/unbondings.js.map +1 -1
- package/lib-es/staking/utils.d.ts.map +1 -1
- package/lib-es/staking/utils.js +20 -25
- package/lib-es/staking/utils.js.map +1 -1
- package/lib-es/staking/validators/index.d.ts +14 -14
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +39 -38
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +5 -5
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +43 -36
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +6 -5
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/sei.js +2 -2
- package/lib-es/staking/validators/sei.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts +4 -4
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js +24 -23
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/types.d.ts +1 -1
- package/lib-es/staking/validators/types.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js +9 -8
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/staking.d.ts +5 -6
- package/lib-es/types/staking.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/abis/index.test.ts +36 -0
- package/src/abis/index.ts +30 -0
- package/src/adapters/blockOperations.ts +1 -1
- package/src/adapters/etherscan.test.ts +34 -38
- package/src/adapters/etherscan.ts +3 -2
- package/src/adapters/ledger.test.ts +49 -22
- package/src/adapters/ledger.ts +3 -2
- package/src/api/getBlock.integ.test.ts +2 -1
- package/src/api/index.monad_testnet.integ.test.ts +2 -2
- package/src/api/index.ts +4 -3
- package/src/chains.test.ts +12 -0
- package/src/chains.ts +97 -0
- package/src/config.ts +5 -1
- package/src/fixtures/staking.fixtures.ts +13 -0
- package/src/internalTxSources.ts +20 -3
- package/src/logic/broadcast.ts +2 -2
- package/src/logic/common.ts +23 -14
- package/src/logic/craftTransaction.ts +6 -5
- package/src/logic/estimateFees.ts +10 -25
- package/src/logic/getBalance.ts +7 -13
- package/src/logic/getBlock.ts +22 -19
- package/src/logic/getBlockInfo.ts +2 -2
- package/src/logic/getNextSequence.ts +1 -4
- package/src/logic/getStakes.ts +11 -12
- package/src/logic/internalTransactionsFetcher.ts +7 -9
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +0 -1
- package/src/logic/predicates.ts +124 -0
- package/src/logic/tests/broadcast.test.ts +4 -4
- package/src/logic/tests/broadcastSource.test.ts +0 -3
- package/src/logic/tests/common.test.ts +17 -33
- package/src/logic/tests/craftTransaction.test.ts +13 -6
- package/src/logic/tests/estimateFees.test.ts +16 -7
- package/src/logic/tests/getBalance.test.ts +17 -33
- package/src/logic/tests/getBlock.test.ts +69 -75
- package/src/logic/tests/getBlockInfo.test.ts +1 -1
- package/src/logic/tests/getNextSequence.test.ts +1 -1
- package/src/logic/tests/getStakes.test.ts +28 -16
- package/src/logic/tests/internalTransactionsFetcher.test.ts +5 -5
- package/src/logic/tests/lastBlock.test.ts +3 -6
- package/src/logic/tests/listOperations.test.ts +3 -4
- package/src/logic/tests/validateIntent.test.ts +16 -3
- package/src/logic/validateIntent.ts +8 -10
- package/src/logic.test.ts +12 -4
- package/src/logic.ts +13 -13
- package/src/network/explorer/etherscan.test.ts +9 -58
- package/src/network/explorer/etherscan.ts +8 -24
- package/src/network/explorer/index.test.ts +1 -1
- package/src/network/explorer/ledger.test.ts +44 -146
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +12 -5
- package/src/network/gasTracker/ledger.ts +1 -4
- package/src/network/node/explorerProxy.test.ts +17 -22
- package/src/network/node/explorerProxy.ts +23 -20
- package/src/network/node/gethCallTracerToTraceBlockItems.test.ts +1 -1
- package/src/network/node/gethCallTracerToTraceBlockItems.ts +6 -9
- package/src/network/node/index.memoization.test.ts +29 -22
- package/src/network/node/index.test.ts +1 -3
- package/src/network/node/index.ts +11 -8
- package/src/network/node/ledger.test.ts +63 -69
- package/src/network/node/ledger.ts +39 -38
- package/src/network/node/rpc.common.ts +134 -158
- package/src/network/node/rpc.test.ts +201 -110
- package/src/network/node/types.ts +17 -64
- package/src/network/node/withNodeSources.test.ts +7 -9
- package/src/network/node/withNodeSources.ts +23 -26
- package/src/nodeSources.ts +11 -3
- package/src/staking/abis.test.ts +24 -28
- package/src/staking/abis.ts +12 -10
- package/src/staking/contracts.test.ts +20 -8
- package/src/staking/contracts.ts +13 -14
- package/src/staking/detectOperationType.test.ts +16 -13
- package/src/staking/detectOperationType.ts +24 -22
- package/src/staking/encoder.test.ts +38 -27
- package/src/staking/encoder.ts +9 -8
- package/src/staking/fetchers.ts +28 -39
- package/src/staking/logic.test.ts +34 -32
- package/src/staking/logic.ts +14 -14
- package/src/staking/operations/index.test.ts +48 -39
- package/src/staking/operations/index.ts +43 -21
- package/src/staking/prepareIntents.test.ts +14 -34
- package/src/staking/prepareIntents.ts +12 -14
- package/src/staking/redelegations.test.ts +73 -131
- package/src/staking/redelegations.ts +13 -31
- package/src/staking/rewards.test.ts +19 -21
- package/src/staking/rewards.ts +1 -2
- package/src/staking/rewardsFromReceipt.test.ts +9 -8
- package/src/staking/rewardsFromReceipt.ts +3 -2
- package/src/staking/transactionData.test.ts +35 -25
- package/src/staking/transactionData.ts +7 -6
- package/src/staking/unbondings.test.ts +26 -20
- package/src/staking/unbondings.ts +1 -2
- package/src/staking/utils.ts +19 -26
- package/src/staking/validators/index.ts +45 -51
- package/src/staking/validators/monad.test.ts +52 -54
- package/src/staking/validators/monad.ts +42 -40
- package/src/staking/validators/monadResolver.ts +4 -5
- package/src/staking/validators/sei.ts +2 -2
- package/src/staking/validators/somnia.test.ts +22 -19
- package/src/staking/validators/somnia.ts +23 -29
- package/src/staking/validators/types.ts +0 -1
- package/src/staking/validators/zero_gravity.test.ts +34 -49
- package/src/staking/validators/zero_gravity.ts +7 -12
- package/src/staking/validators.integ.test.ts +3 -5
- package/src/staking/validators.test.ts +56 -53
- package/src/types/staking.ts +3 -6
|
@@ -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 { StakingContractConfig } from '../../types/staking'
|
|
6
6
|
import type { ValidatorApi } from './types'
|
|
7
7
|
import type { Cursor, Page } from '@ledgerhq/coin-module-framework/api/index'
|
|
@@ -18,6 +18,7 @@ import type { JsonRpcProvider } from 'ethers'
|
|
|
18
18
|
import network from '@ledgerhq/live-network'
|
|
19
19
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
20
20
|
import { ethers } from 'ethers'
|
|
21
|
+
import { toInterfaceAbi } from '../../abis'
|
|
21
22
|
import { withApi } from '../../network/node/rpc.common'
|
|
22
23
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
23
24
|
import { getStakingABI } from '../abis'
|
|
@@ -54,12 +55,19 @@ type ValidatorInfo = { name: string }
|
|
|
54
55
|
* The resolved promise is cached, so a miss is not re-requested; only transient/non-404
|
|
55
56
|
* errors are rethrown so the cache evicts and a later call retries.
|
|
56
57
|
*/
|
|
58
|
+
function responseStatus(error: unknown): number | undefined {
|
|
59
|
+
if (typeof error !== 'object' || error === null || !('response' in error)) return undefined
|
|
60
|
+
const response = error.response
|
|
61
|
+
if (typeof response !== 'object' || response === null || !('status' in response)) return undefined
|
|
62
|
+
return typeof response.status === 'number' ? response.status : undefined
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
const fetchValidatorName = async (
|
|
58
|
-
|
|
66
|
+
chainId: ChainId,
|
|
59
67
|
secp: string,
|
|
60
68
|
logger: Logger
|
|
61
69
|
): Promise<string | null> => {
|
|
62
|
-
const baseUrl = STAKING_CONTRACTS[
|
|
70
|
+
const baseUrl = STAKING_CONTRACTS[chainId]?.validatorNameSource?.baseUrl
|
|
63
71
|
if (!baseUrl) return null
|
|
64
72
|
|
|
65
73
|
try {
|
|
@@ -68,12 +76,12 @@ const fetchValidatorName = async (
|
|
|
68
76
|
typeof res?.data?.name === 'string' && res.data.name.trim().length > 0 ? res.data.name : null
|
|
69
77
|
return name
|
|
70
78
|
} catch (error) {
|
|
71
|
-
const status = (error
|
|
79
|
+
const status = responseStatus(error)
|
|
72
80
|
// A 404 just means this validator hasn't published info — cache the miss.
|
|
73
81
|
if (status === 404) return null
|
|
74
82
|
// Anything else is transient: log and rethrow so the cache doesn't pin a miss.
|
|
75
83
|
logger('coin-evm/staking', 'fetchValidatorName: validator-info lookup failed', {
|
|
76
|
-
|
|
84
|
+
chainId,
|
|
77
85
|
secp,
|
|
78
86
|
error: error instanceof Error ? error.message : String(error),
|
|
79
87
|
})
|
|
@@ -81,11 +89,11 @@ const fetchValidatorName = async (
|
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
// Concurrent calls for the same (
|
|
92
|
+
// Concurrent calls for the same (chainId, secp) share one in-flight request.
|
|
85
93
|
const validatorNameCache = makeLRUCache(
|
|
86
94
|
fetchValidatorName,
|
|
87
95
|
// logger is a side-channel arg, excluded from the cache key.
|
|
88
|
-
(
|
|
96
|
+
(chainId: ChainId, secp: string, _logger: Logger) => `${chainId}-${secp}`,
|
|
89
97
|
{ max: 1000, ttl: NAME_CACHE_MAX_AGE_MS }
|
|
90
98
|
)
|
|
91
99
|
|
|
@@ -129,14 +137,11 @@ type ResolvedContext = {
|
|
|
129
137
|
contractAddress: string
|
|
130
138
|
}
|
|
131
139
|
|
|
132
|
-
const resolveContext = (
|
|
133
|
-
evmConfig
|
|
134
|
-
currencyId: string
|
|
135
|
-
): ResolvedContext | undefined => {
|
|
136
|
-
const config = STAKING_CONTRACTS[currencyId]
|
|
140
|
+
const resolveContext = (evmConfig: EvmConfigInfo): ResolvedContext | undefined => {
|
|
141
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
137
142
|
if (!config) return undefined
|
|
138
143
|
|
|
139
|
-
const abi = getStakingABI(
|
|
144
|
+
const abi = getStakingABI(evmConfig.chainId)
|
|
140
145
|
if (!abi) return undefined
|
|
141
146
|
|
|
142
147
|
const node = evmConfig.node
|
|
@@ -144,7 +149,7 @@ const resolveContext = (
|
|
|
144
149
|
|
|
145
150
|
try {
|
|
146
151
|
return {
|
|
147
|
-
abi: abi
|
|
152
|
+
abi: toInterfaceAbi(abi),
|
|
148
153
|
node,
|
|
149
154
|
contractAddress: config.contractAddress(),
|
|
150
155
|
}
|
|
@@ -154,7 +159,7 @@ const resolveContext = (
|
|
|
154
159
|
}
|
|
155
160
|
|
|
156
161
|
const fetchValidatorDetails = async (
|
|
157
|
-
|
|
162
|
+
chainId: ChainId,
|
|
158
163
|
provider: JsonRpcProvider,
|
|
159
164
|
iface: ethers.Interface,
|
|
160
165
|
contractAddress: string,
|
|
@@ -173,9 +178,7 @@ const fetchValidatorDetails = async (
|
|
|
173
178
|
const [, , stake, , commission, , , , , , secpPubkey] = decoded
|
|
174
179
|
const secp = secpPubkey.toLowerCase().replace(/^0x/, '')
|
|
175
180
|
const name =
|
|
176
|
-
secp.length > 0
|
|
177
|
-
? await validatorNameCache(currencyId, secp, logger).catch(() => null)
|
|
178
|
-
: null
|
|
181
|
+
secp.length > 0 ? await validatorNameCache(chainId, secp, logger).catch(() => null) : null
|
|
179
182
|
|
|
180
183
|
return {
|
|
181
184
|
id: valId.toString(),
|
|
@@ -207,7 +210,7 @@ const fetchValidatorDetails = async (
|
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
const fetchPage = async (
|
|
210
|
-
|
|
213
|
+
chainId: ChainId,
|
|
211
214
|
provider: JsonRpcProvider,
|
|
212
215
|
iface: ethers.Interface,
|
|
213
216
|
contractAddress: string,
|
|
@@ -224,7 +227,7 @@ const fetchPage = async (
|
|
|
224
227
|
const items =
|
|
225
228
|
pageIds.length === 0
|
|
226
229
|
? []
|
|
227
|
-
: await fetchValidatorDetails(
|
|
230
|
+
: await fetchValidatorDetails(chainId, provider, iface, contractAddress, pageIds, logger)
|
|
228
231
|
|
|
229
232
|
const exhausted = isDone || pageIds.length === 0 || nextIndex <= startIndex
|
|
230
233
|
return { items, next: exhausted ? undefined : nextIndex.toString() }
|
|
@@ -232,11 +235,10 @@ const fetchPage = async (
|
|
|
232
235
|
|
|
233
236
|
const fetchValidators = async (
|
|
234
237
|
evmConfig: EvmConfigInfo,
|
|
235
|
-
currencyId: string,
|
|
236
238
|
logger: Logger,
|
|
237
239
|
cursor?: Cursor
|
|
238
240
|
): Promise<Page<Validator>> => {
|
|
239
|
-
const ctx = resolveContext(evmConfig
|
|
241
|
+
const ctx = resolveContext(evmConfig)
|
|
240
242
|
if (!ctx) return { items: [], next: undefined }
|
|
241
243
|
|
|
242
244
|
try {
|
|
@@ -244,17 +246,23 @@ const fetchValidators = async (
|
|
|
244
246
|
|
|
245
247
|
return await withApi(
|
|
246
248
|
evmConfig,
|
|
247
|
-
currencyId,
|
|
248
249
|
async (provider) => {
|
|
249
250
|
const iface = new ethers.Interface(ctx.abi)
|
|
250
|
-
return fetchPage(
|
|
251
|
+
return fetchPage(
|
|
252
|
+
evmConfig.chainId,
|
|
253
|
+
provider,
|
|
254
|
+
iface,
|
|
255
|
+
ctx.contractAddress,
|
|
256
|
+
startIndex,
|
|
257
|
+
logger
|
|
258
|
+
)
|
|
251
259
|
},
|
|
252
260
|
ctx.node
|
|
253
261
|
)
|
|
254
262
|
} catch (error) {
|
|
255
263
|
logger('coin-evm/staking', 'fetchValidators: Monad validators page fetch failed', {
|
|
256
264
|
error: error instanceof Error ? error.message : String(error),
|
|
257
|
-
|
|
265
|
+
currency: evmConfig.name,
|
|
258
266
|
cursor,
|
|
259
267
|
})
|
|
260
268
|
return { items: [], next: undefined }
|
|
@@ -290,7 +298,6 @@ const fetchDelegatedValIds = async (
|
|
|
290
298
|
|
|
291
299
|
const fetchStakeForValId = async (
|
|
292
300
|
evmConfig: EvmConfigInfo,
|
|
293
|
-
currencyId: string,
|
|
294
301
|
provider: JsonRpcProvider,
|
|
295
302
|
iface: ethers.Interface,
|
|
296
303
|
contractAddress: string,
|
|
@@ -335,7 +342,7 @@ const fetchStakeForValId = async (
|
|
|
335
342
|
const secp = secpPubkey.toLowerCase().replace(/^0x/, '')
|
|
336
343
|
if (secp.length > 0) {
|
|
337
344
|
validatorName =
|
|
338
|
-
(await validatorNameCache(
|
|
345
|
+
(await validatorNameCache(evmConfig.chainId, secp, logger).catch(() => null)) ?? undefined
|
|
339
346
|
}
|
|
340
347
|
}
|
|
341
348
|
|
|
@@ -389,7 +396,7 @@ const fetchStakeForValId = async (
|
|
|
389
396
|
}
|
|
390
397
|
|
|
391
398
|
export const extractMonadKnownValIds = (
|
|
392
|
-
|
|
399
|
+
chainId: ChainId,
|
|
393
400
|
ops: Array<Operation<MemoNotSupported>>,
|
|
394
401
|
logger: Logger
|
|
395
402
|
): string[] => {
|
|
@@ -399,10 +406,10 @@ export const extractMonadKnownValIds = (
|
|
|
399
406
|
WITHDRAW_UNBONDED: 'withdraw',
|
|
400
407
|
}
|
|
401
408
|
|
|
402
|
-
const abi = getStakingABI(
|
|
409
|
+
const abi = getStakingABI(chainId)
|
|
403
410
|
if (!abi) return []
|
|
404
411
|
|
|
405
|
-
const iface = new ethers.Interface(abi
|
|
412
|
+
const iface = new ethers.Interface(toInterfaceAbi(abi))
|
|
406
413
|
const valIds = new Set<string>()
|
|
407
414
|
|
|
408
415
|
for (const op of ops) {
|
|
@@ -428,17 +435,15 @@ export const fetchMonadStakes = async (
|
|
|
428
435
|
evmConfig: EvmConfigInfo,
|
|
429
436
|
address: string,
|
|
430
437
|
_config: StakingContractConfig,
|
|
431
|
-
currencyId: string,
|
|
432
438
|
logger: Logger,
|
|
433
439
|
knownValIds?: string[]
|
|
434
440
|
): Promise<Stake[]> => {
|
|
435
|
-
const ctx = resolveContext(evmConfig
|
|
441
|
+
const ctx = resolveContext(evmConfig)
|
|
436
442
|
if (!ctx) return []
|
|
437
443
|
|
|
438
444
|
try {
|
|
439
445
|
return await withApi(
|
|
440
446
|
evmConfig,
|
|
441
|
-
currencyId,
|
|
442
447
|
async (provider) => {
|
|
443
448
|
const iface = new ethers.Interface(ctx.abi)
|
|
444
449
|
const fromDelegations = await fetchDelegatedValIds(
|
|
@@ -463,7 +468,6 @@ export const fetchMonadStakes = async (
|
|
|
463
468
|
chunk.map((valId) =>
|
|
464
469
|
fetchStakeForValId(
|
|
465
470
|
evmConfig,
|
|
466
|
-
currencyId,
|
|
467
471
|
provider,
|
|
468
472
|
iface,
|
|
469
473
|
ctx.contractAddress,
|
|
@@ -493,7 +497,7 @@ export const fetchMonadStakes = async (
|
|
|
493
497
|
)
|
|
494
498
|
} catch (error) {
|
|
495
499
|
logger('coin-evm/staking', 'fetchMonadStakes: delegations fetch failed', {
|
|
496
|
-
|
|
500
|
+
currency: evmConfig.name,
|
|
497
501
|
error: error instanceof Error ? error.message : String(error),
|
|
498
502
|
})
|
|
499
503
|
return []
|
|
@@ -580,18 +584,16 @@ const fetchWithdrawalRequests = async (
|
|
|
580
584
|
|
|
581
585
|
export const findFirstFreeWithdrawId = async (
|
|
582
586
|
evmConfig: EvmConfigInfo,
|
|
583
|
-
currencyId: string,
|
|
584
587
|
valId: bigint,
|
|
585
588
|
delegator: string,
|
|
586
589
|
logger: Logger
|
|
587
590
|
): Promise<number | null> => {
|
|
588
|
-
const ctx = resolveContext(evmConfig
|
|
591
|
+
const ctx = resolveContext(evmConfig)
|
|
589
592
|
if (!ctx) return null
|
|
590
593
|
|
|
591
594
|
try {
|
|
592
595
|
return await withApi(
|
|
593
596
|
evmConfig,
|
|
594
|
-
currencyId,
|
|
595
597
|
async (provider) => {
|
|
596
598
|
const iface = new ethers.Interface(ctx.abi)
|
|
597
599
|
|
|
@@ -619,7 +621,7 @@ export const findFirstFreeWithdrawId = async (
|
|
|
619
621
|
'coin-evm/staking',
|
|
620
622
|
'findFirstFreeWithdrawId: getWithdrawalRequest call failed',
|
|
621
623
|
{
|
|
622
|
-
|
|
624
|
+
currency: evmConfig.name,
|
|
623
625
|
valId: valId.toString(),
|
|
624
626
|
withdrawId: ids[i],
|
|
625
627
|
error: res.reason instanceof Error ? res.reason.message : String(res.reason),
|
|
@@ -637,7 +639,7 @@ export const findFirstFreeWithdrawId = async (
|
|
|
637
639
|
)
|
|
638
640
|
} catch (error) {
|
|
639
641
|
logger('coin-evm/staking', 'findFirstFreeWithdrawId: lookup failed', {
|
|
640
|
-
|
|
642
|
+
currency: evmConfig.name,
|
|
641
643
|
valId: valId.toString(),
|
|
642
644
|
error: error instanceof Error ? error.message : String(error),
|
|
643
645
|
})
|
|
@@ -5,6 +5,7 @@ import type { EvmConfigInfo } from '../../config'
|
|
|
5
5
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
6
6
|
import type { JsonRpcProvider } from 'ethers'
|
|
7
7
|
import { ethers } from 'ethers'
|
|
8
|
+
import { toInterfaceAbi } from '../../abis'
|
|
8
9
|
import { withApi } from '../../network/node/rpc.common'
|
|
9
10
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
10
11
|
import { getStakingABI } from '../abis'
|
|
@@ -53,11 +54,10 @@ export const callGetValidator = async (
|
|
|
53
54
|
|
|
54
55
|
export const getValidatorAddressById = async (
|
|
55
56
|
config: EvmConfigInfo,
|
|
56
|
-
currencyId: string,
|
|
57
57
|
valId: bigint,
|
|
58
58
|
logger: Logger
|
|
59
59
|
): Promise<string | null> => {
|
|
60
|
-
const abi = getStakingABI(
|
|
60
|
+
const abi = getStakingABI(config.chainId)
|
|
61
61
|
if (!abi) return null
|
|
62
62
|
|
|
63
63
|
const node = config.node
|
|
@@ -66,9 +66,8 @@ export const getValidatorAddressById = async (
|
|
|
66
66
|
try {
|
|
67
67
|
return await withApi(
|
|
68
68
|
config,
|
|
69
|
-
currencyId,
|
|
70
69
|
async (provider) => {
|
|
71
|
-
const iface = new ethers.Interface(abi
|
|
70
|
+
const iface = new ethers.Interface(toInterfaceAbi(abi))
|
|
72
71
|
const decoded = await callGetValidator(provider, iface, MONAD_PRECOMPILE, valId)
|
|
73
72
|
if (!decoded) return null
|
|
74
73
|
const [, , , , , , , , , , secpPubkey] = decoded
|
|
@@ -78,7 +77,7 @@ export const getValidatorAddressById = async (
|
|
|
78
77
|
)
|
|
79
78
|
} catch (error) {
|
|
80
79
|
logger('coin-evm/staking', 'getValidatorAddressById: getValidator call failed', {
|
|
81
|
-
|
|
80
|
+
currency: config.name,
|
|
82
81
|
valId: valId.toString(),
|
|
83
82
|
error: error instanceof Error ? error.message : String(error),
|
|
84
83
|
})
|
|
@@ -30,8 +30,8 @@ type CosmosValidatorsResponse = { validators: CosmosValidator[] }
|
|
|
30
30
|
// Sei's REST endpoint returns the whole validator set in one response, so it
|
|
31
31
|
// ignores the cursor and always reports `next: undefined` (single page).
|
|
32
32
|
const seiValidatorApi: ValidatorApi = {
|
|
33
|
-
fetchValidators: async (
|
|
34
|
-
const apiConfig = STAKING_CONTRACTS[
|
|
33
|
+
fetchValidators: async (config): Promise<Page<Validator>> => {
|
|
34
|
+
const apiConfig = STAKING_CONTRACTS[config.chainId]?.apiConfig
|
|
35
35
|
if (!apiConfig?.baseUrl) return { items: [], next: undefined }
|
|
36
36
|
|
|
37
37
|
const { baseUrl, validatorsEndpoint } = apiConfig
|
|
@@ -7,14 +7,15 @@ import type { TransactionRequest } from 'ethers'
|
|
|
7
7
|
import network from '@ledgerhq/live-network'
|
|
8
8
|
import { ethers } from 'ethers'
|
|
9
9
|
import somniaAbi from '../../abis/somnia.abi.json'
|
|
10
|
+
import { CHAIN_ID } from '../../config'
|
|
10
11
|
import {
|
|
11
12
|
createMockEvmConfigInfo,
|
|
12
13
|
mkExternalNode,
|
|
13
14
|
mkLedgerNode,
|
|
14
15
|
testLogger,
|
|
15
16
|
} from '../../fixtures/context.fixtures'
|
|
17
|
+
import { requireStakingContract } from '../../fixtures/staking.fixtures'
|
|
16
18
|
import { withApi } from '../../network/node/rpc.common'
|
|
17
|
-
import { STAKING_CONTRACTS } from '../contracts'
|
|
18
19
|
import { clearValidatorNamesCache, fetchSomniaStakes, fetchValidatorNames } from './somnia'
|
|
19
20
|
import { clearValidatorsCache, getValidators } from './index'
|
|
20
21
|
|
|
@@ -25,12 +26,14 @@ const mockedWithApi = jest.mocked(withApi)
|
|
|
25
26
|
const mockedNetwork = jest.mocked<DeepPartialReturn<typeof network>>(network)
|
|
26
27
|
|
|
27
28
|
const mockConfig = createMockEvmConfigInfo({
|
|
28
|
-
chainId:
|
|
29
|
+
chainId: CHAIN_ID.SOMNIA,
|
|
29
30
|
node: mkExternalNode({ uri: 'https://somnia-rpc.publicnode.com' }),
|
|
30
31
|
name: 'Somnia',
|
|
31
32
|
unit: { name: 'SOMI', code: 'SOMI', magnitude: 18 },
|
|
32
33
|
})
|
|
33
|
-
const ledgerConfig = createMockEvmConfigInfo({ chainId:
|
|
34
|
+
const ledgerConfig = createMockEvmConfigInfo({ chainId: CHAIN_ID.SOMNIA, node: mkLedgerNode() })
|
|
35
|
+
|
|
36
|
+
const somniaContract = requireStakingContract(CHAIN_ID.SOMNIA)
|
|
34
37
|
|
|
35
38
|
const somniaIface = new ethers.Interface(somniaAbi)
|
|
36
39
|
const CONTRACT = '0xBe367d410D96E1cAeF68C0632251072CDf1b8250'
|
|
@@ -42,7 +45,7 @@ type CallHandler = (request: TransactionRequest) => Promise<string>
|
|
|
42
45
|
|
|
43
46
|
const setupRpc = (handler: CallHandler) => {
|
|
44
47
|
const callMock = jest.fn(handler)
|
|
45
|
-
mockedWithApi.mockImplementation(async (_config,
|
|
48
|
+
mockedWithApi.mockImplementation(async (_config, fn) =>
|
|
46
49
|
fn(Object.assign(Object.create(null), { call: callMock }))
|
|
47
50
|
)
|
|
48
51
|
return callMock
|
|
@@ -120,8 +123,8 @@ const routeByName = (responses: {
|
|
|
120
123
|
describe('staking/validators/somnia', () => {
|
|
121
124
|
beforeEach(() => {
|
|
122
125
|
jest.clearAllMocks()
|
|
123
|
-
clearValidatorsCache(
|
|
124
|
-
clearValidatorNamesCache(
|
|
126
|
+
clearValidatorsCache(CHAIN_ID.SOMNIA)
|
|
127
|
+
clearValidatorNamesCache(CHAIN_ID.SOMNIA)
|
|
125
128
|
})
|
|
126
129
|
|
|
127
130
|
describe('fetchValidators', () => {
|
|
@@ -139,7 +142,7 @@ describe('staking/validators/somnia', () => {
|
|
|
139
142
|
})
|
|
140
143
|
)
|
|
141
144
|
|
|
142
|
-
const page = await getValidators(mockConfig,
|
|
145
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
143
146
|
|
|
144
147
|
expect(page.next).toBeUndefined()
|
|
145
148
|
expect(page.items).toHaveLength(2)
|
|
@@ -172,7 +175,7 @@ describe('staking/validators/somnia', () => {
|
|
|
172
175
|
})
|
|
173
176
|
)
|
|
174
177
|
|
|
175
|
-
const page = await getValidators(mockConfig,
|
|
178
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
176
179
|
|
|
177
180
|
expect(page.items).toHaveLength(1)
|
|
178
181
|
expect(page.items[0].address).toBe(VALIDATOR_B)
|
|
@@ -185,14 +188,14 @@ describe('staking/validators/somnia', () => {
|
|
|
185
188
|
})
|
|
186
189
|
)
|
|
187
190
|
|
|
188
|
-
const page = await getValidators(mockConfig,
|
|
191
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
189
192
|
|
|
190
193
|
expect(page.items).toStrictEqual([])
|
|
191
194
|
expect(page.next).toBeUndefined()
|
|
192
195
|
})
|
|
193
196
|
|
|
194
197
|
it('returns empty when the node config is not external', async () => {
|
|
195
|
-
const page = await getValidators(ledgerConfig,
|
|
198
|
+
const page = await getValidators(ledgerConfig, testLogger)
|
|
196
199
|
|
|
197
200
|
expect(page.items).toStrictEqual([])
|
|
198
201
|
expect(mockedWithApi).not.toHaveBeenCalled()
|
|
@@ -201,7 +204,7 @@ describe('staking/validators/somnia', () => {
|
|
|
201
204
|
it('returns empty on getCommitteeValidators failure', async () => {
|
|
202
205
|
setupRpc(routeByName({ getCommitteeValidators: () => new Error('network error') }))
|
|
203
206
|
|
|
204
|
-
const page = await getValidators(mockConfig,
|
|
207
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
205
208
|
|
|
206
209
|
expect(page.items).toStrictEqual([])
|
|
207
210
|
})
|
|
@@ -216,7 +219,7 @@ describe('staking/validators/somnia', () => {
|
|
|
216
219
|
[VALIDATOR_B.toLowerCase()]: 'Kiln',
|
|
217
220
|
})
|
|
218
221
|
|
|
219
|
-
const names = await fetchValidatorNames(
|
|
222
|
+
const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
|
|
220
223
|
|
|
221
224
|
expect(names).toStrictEqual({
|
|
222
225
|
[VALIDATOR_A.toLowerCase()]: 'BitGo',
|
|
@@ -231,7 +234,7 @@ describe('staking/validators/somnia', () => {
|
|
|
231
234
|
'0x1234': 'Too short',
|
|
232
235
|
})
|
|
233
236
|
|
|
234
|
-
const names = await fetchValidatorNames(
|
|
237
|
+
const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
|
|
235
238
|
|
|
236
239
|
expect(names).toStrictEqual({ [VALIDATOR_A.toLowerCase()]: 'Everstake' })
|
|
237
240
|
})
|
|
@@ -245,7 +248,7 @@ describe('staking/validators/somnia', () => {
|
|
|
245
248
|
'0x4444444444444444444444444444444444444444': null,
|
|
246
249
|
})
|
|
247
250
|
|
|
248
|
-
const names = await fetchValidatorNames(
|
|
251
|
+
const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
|
|
249
252
|
|
|
250
253
|
expect(names).toStrictEqual({ [VALIDATOR_A.toLowerCase()]: 'Everstake' })
|
|
251
254
|
})
|
|
@@ -257,7 +260,7 @@ describe('staking/validators/somnia', () => {
|
|
|
257
260
|
error: { code: -32600, message: 'invalid request' },
|
|
258
261
|
})
|
|
259
262
|
|
|
260
|
-
const names = await fetchValidatorNames(
|
|
263
|
+
const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
|
|
261
264
|
|
|
262
265
|
expect(names).toStrictEqual({})
|
|
263
266
|
})
|
|
@@ -265,7 +268,7 @@ describe('staking/validators/somnia', () => {
|
|
|
265
268
|
it('returns {} when the payload is an array', async () => {
|
|
266
269
|
mockNamesResponse([{ addr: VALIDATOR_A, name: 'BitGo' }])
|
|
267
270
|
|
|
268
|
-
const names = await fetchValidatorNames(
|
|
271
|
+
const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
|
|
269
272
|
|
|
270
273
|
expect(names).toStrictEqual({})
|
|
271
274
|
})
|
|
@@ -273,7 +276,7 @@ describe('staking/validators/somnia', () => {
|
|
|
273
276
|
it('returns {} when the payload is null', async () => {
|
|
274
277
|
mockNamesResponse(null)
|
|
275
278
|
|
|
276
|
-
const names = await fetchValidatorNames(
|
|
279
|
+
const names = await fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)
|
|
277
280
|
|
|
278
281
|
expect(names).toStrictEqual({})
|
|
279
282
|
})
|
|
@@ -281,13 +284,13 @@ describe('staking/validators/somnia', () => {
|
|
|
281
284
|
it('rethrows on network error so makeLRUCache evicts (callers stay best-effort)', async () => {
|
|
282
285
|
mockedNetwork.mockRejectedValue(new Error('network down'))
|
|
283
286
|
|
|
284
|
-
await expect(fetchValidatorNames(
|
|
287
|
+
await expect(fetchValidatorNames(CHAIN_ID.SOMNIA, testLogger)).rejects.toThrow('network down')
|
|
285
288
|
})
|
|
286
289
|
})
|
|
287
290
|
|
|
288
291
|
describe('fetchSomniaStakes', () => {
|
|
289
292
|
const fetchStakes = (config: EvmConfigInfo = mockConfig) =>
|
|
290
|
-
fetchSomniaStakes(config, DELEGATOR,
|
|
293
|
+
fetchSomniaStakes(config, DELEGATOR, somniaContract, testLogger)
|
|
291
294
|
|
|
292
295
|
const defaultStakeHandlers = (
|
|
293
296
|
overrides: {
|
|
@@ -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 { StakingContractConfig } from '../../types/staking'
|
|
6
6
|
import type { ValidatorApi } from './types'
|
|
7
7
|
import type { Cursor, Page } from '@ledgerhq/coin-module-framework/api/index'
|
|
@@ -11,6 +11,7 @@ import type { JsonRpcProvider } from 'ethers'
|
|
|
11
11
|
import network from '@ledgerhq/live-network'
|
|
12
12
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
13
13
|
import { ethers } from 'ethers'
|
|
14
|
+
import { toInterfaceAbi } from '../../abis'
|
|
14
15
|
import { withApi } from '../../network/node/rpc.common'
|
|
15
16
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
16
17
|
import { getStakingABI } from '../abis'
|
|
@@ -64,14 +65,11 @@ type ResolvedContext = {
|
|
|
64
65
|
contractAddress: string
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
const resolveContext = (
|
|
68
|
-
evmConfig
|
|
69
|
-
currencyId: string
|
|
70
|
-
): ResolvedContext | undefined => {
|
|
71
|
-
const config = STAKING_CONTRACTS[currencyId]
|
|
68
|
+
const resolveContext = (evmConfig: EvmConfigInfo): ResolvedContext | undefined => {
|
|
69
|
+
const config = STAKING_CONTRACTS[evmConfig.chainId]
|
|
72
70
|
if (!config) return undefined
|
|
73
71
|
|
|
74
|
-
const abi = getStakingABI(
|
|
72
|
+
const abi = getStakingABI(evmConfig.chainId)
|
|
75
73
|
if (!abi) return undefined
|
|
76
74
|
|
|
77
75
|
const node = evmConfig.node
|
|
@@ -79,7 +77,7 @@ const resolveContext = (
|
|
|
79
77
|
|
|
80
78
|
try {
|
|
81
79
|
return {
|
|
82
|
-
abi: abi
|
|
80
|
+
abi: toInterfaceAbi(abi),
|
|
83
81
|
node,
|
|
84
82
|
contractAddress: config.contractAddress(),
|
|
85
83
|
}
|
|
@@ -94,10 +92,10 @@ const resolveContext = (
|
|
|
94
92
|
* Callers should treat it as best-effort and fall back to the on-chain address as the display name.
|
|
95
93
|
*/
|
|
96
94
|
export const fetchValidatorNames = async (
|
|
97
|
-
|
|
95
|
+
chainId: ChainId,
|
|
98
96
|
logger: Logger
|
|
99
97
|
): Promise<ValidatorNamesMap> => {
|
|
100
|
-
const baseUrl = STAKING_CONTRACTS[
|
|
98
|
+
const baseUrl = STAKING_CONTRACTS[chainId]?.validatorNameSource?.baseUrl
|
|
101
99
|
if (!baseUrl) return {}
|
|
102
100
|
|
|
103
101
|
try {
|
|
@@ -115,7 +113,7 @@ export const fetchValidatorNames = async (
|
|
|
115
113
|
return out
|
|
116
114
|
} catch (error) {
|
|
117
115
|
logger('coin-evm/staking', 'fetchValidatorNames: validator-names lookup failed', {
|
|
118
|
-
|
|
116
|
+
chainId,
|
|
119
117
|
error: error instanceof Error ? error.message : String(error),
|
|
120
118
|
})
|
|
121
119
|
throw error
|
|
@@ -125,27 +123,27 @@ export const fetchValidatorNames = async (
|
|
|
125
123
|
const validatorNamesCache = makeLRUCache(
|
|
126
124
|
fetchValidatorNames,
|
|
127
125
|
// logger is a side-channel arg, excluded from the cache key.
|
|
128
|
-
(
|
|
126
|
+
(chainId: ChainId, _logger: Logger) => String(chainId),
|
|
129
127
|
{
|
|
130
128
|
max: 10,
|
|
131
129
|
ttl: NAME_CACHE_MAX_AGE_MS,
|
|
132
130
|
}
|
|
133
131
|
)
|
|
134
132
|
|
|
135
|
-
// Drop the cached validator-names overlay for a
|
|
136
|
-
// since the cache is module-level and keyed only by
|
|
137
|
-
export const clearValidatorNamesCache = (
|
|
138
|
-
validatorNamesCache.clear(
|
|
133
|
+
// Drop the cached validator-names overlay for a chain (primarily to keep tests deterministic,
|
|
134
|
+
// since the cache is module-level and keyed only by chainId).
|
|
135
|
+
export const clearValidatorNamesCache = (chainId: ChainId): void =>
|
|
136
|
+
validatorNamesCache.clear(String(chainId))
|
|
139
137
|
|
|
140
138
|
const fetchValidatorDetails = async (
|
|
141
|
-
|
|
139
|
+
chainId: ChainId,
|
|
142
140
|
provider: JsonRpcProvider,
|
|
143
141
|
iface: ethers.Interface,
|
|
144
142
|
contractAddress: string,
|
|
145
143
|
addresses: string[],
|
|
146
144
|
logger: Logger
|
|
147
145
|
): Promise<Validator[]> => {
|
|
148
|
-
const names = await validatorNamesCache(
|
|
146
|
+
const names = await validatorNamesCache(chainId, logger).catch((): ValidatorNamesMap => ({}))
|
|
149
147
|
|
|
150
148
|
const items: Validator[] = []
|
|
151
149
|
|
|
@@ -194,17 +192,15 @@ const fetchValidatorDetails = async (
|
|
|
194
192
|
|
|
195
193
|
const fetchValidators = async (
|
|
196
194
|
evmConfig: EvmConfigInfo,
|
|
197
|
-
currencyId: string,
|
|
198
195
|
logger: Logger,
|
|
199
196
|
_cursor?: Cursor
|
|
200
197
|
): Promise<Page<Validator>> => {
|
|
201
|
-
const ctx = resolveContext(evmConfig
|
|
198
|
+
const ctx = resolveContext(evmConfig)
|
|
202
199
|
if (!ctx) return { items: [], next: undefined }
|
|
203
200
|
|
|
204
201
|
try {
|
|
205
202
|
return await withApi(
|
|
206
203
|
evmConfig,
|
|
207
|
-
currencyId,
|
|
208
204
|
async (provider) => {
|
|
209
205
|
const iface = new ethers.Interface(ctx.abi)
|
|
210
206
|
const data = iface.encodeFunctionData('getCommitteeValidators', [])
|
|
@@ -217,7 +213,7 @@ const fetchValidators = async (
|
|
|
217
213
|
if (addresses.length === 0) return { items: [], next: undefined }
|
|
218
214
|
|
|
219
215
|
const items = await fetchValidatorDetails(
|
|
220
|
-
|
|
216
|
+
evmConfig.chainId,
|
|
221
217
|
provider,
|
|
222
218
|
iface,
|
|
223
219
|
ctx.contractAddress,
|
|
@@ -230,7 +226,7 @@ const fetchValidators = async (
|
|
|
230
226
|
)
|
|
231
227
|
} catch (error) {
|
|
232
228
|
logger('coin-evm/staking', 'fetchSomniaValidators: fetch failed', {
|
|
233
|
-
|
|
229
|
+
currency: evmConfig.name,
|
|
234
230
|
error: error instanceof Error ? error.message : String(error),
|
|
235
231
|
})
|
|
236
232
|
return { items: [], next: undefined }
|
|
@@ -299,17 +295,15 @@ export const fetchSomniaStakes = async (
|
|
|
299
295
|
evmConfig: EvmConfigInfo,
|
|
300
296
|
address: string,
|
|
301
297
|
_config: StakingContractConfig,
|
|
302
|
-
currencyId: string,
|
|
303
298
|
logger: Logger,
|
|
304
299
|
_knownValIds?: string[]
|
|
305
300
|
): Promise<Stake[]> => {
|
|
306
|
-
const ctx = resolveContext(evmConfig
|
|
301
|
+
const ctx = resolveContext(evmConfig)
|
|
307
302
|
if (!ctx) return []
|
|
308
303
|
|
|
309
304
|
try {
|
|
310
305
|
return await withApi(
|
|
311
306
|
evmConfig,
|
|
312
|
-
currencyId,
|
|
313
307
|
async (provider) => {
|
|
314
308
|
const iface = new ethers.Interface(ctx.abi)
|
|
315
309
|
|
|
@@ -326,8 +320,8 @@ export const fetchSomniaStakes = async (
|
|
|
326
320
|
|
|
327
321
|
// Display-name overlay, keyed by lowercased operator address. Best-effort: on failure
|
|
328
322
|
// the delegation still shows, falling back to the raw address as its name.
|
|
329
|
-
const names = await validatorNamesCache(
|
|
330
|
-
() => ({})
|
|
323
|
+
const names = await validatorNamesCache(evmConfig.chainId, logger).catch(
|
|
324
|
+
(): ValidatorNamesMap => ({})
|
|
331
325
|
)
|
|
332
326
|
|
|
333
327
|
const asset: AssetInfo = {
|
|
@@ -386,7 +380,7 @@ export const fetchSomniaStakes = async (
|
|
|
386
380
|
)
|
|
387
381
|
} catch (error) {
|
|
388
382
|
logger('coin-evm/staking', 'fetchSomniaStakes: delegations fetch failed', {
|
|
389
|
-
|
|
383
|
+
currency: evmConfig.name,
|
|
390
384
|
error: error instanceof Error ? error.message : String(error),
|
|
391
385
|
})
|
|
392
386
|
return []
|