@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
package/src/chains.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The EVM networks coin-evm supports, valued by their EIP-155 chain id.
|
|
6
|
+
*/
|
|
7
|
+
export const CHAIN_ID = {
|
|
8
|
+
ETHEREUM: 1,
|
|
9
|
+
EXPANSE: 2,
|
|
10
|
+
UBIQ: 8,
|
|
11
|
+
OPTIMISM: 10,
|
|
12
|
+
FLARE: 14,
|
|
13
|
+
SONGBIRD: 19,
|
|
14
|
+
CRONOS: 25,
|
|
15
|
+
RSK: 30,
|
|
16
|
+
TELOS_EVM: 40,
|
|
17
|
+
LUKSO: 42,
|
|
18
|
+
BSC: 56,
|
|
19
|
+
SYSCOIN: 57,
|
|
20
|
+
GOCHAIN: 60,
|
|
21
|
+
ETHEREUM_CLASSIC: 61,
|
|
22
|
+
ELLAISM: 64,
|
|
23
|
+
MIX: 76,
|
|
24
|
+
TOMO: 88,
|
|
25
|
+
POA: 99,
|
|
26
|
+
VELAS_EVM: 106,
|
|
27
|
+
THUNDERCORE: 108,
|
|
28
|
+
UNICHAIN: 130,
|
|
29
|
+
POLYGON: 137,
|
|
30
|
+
MONAD: 143,
|
|
31
|
+
SONIC: 146,
|
|
32
|
+
BITTORRENT: 199,
|
|
33
|
+
DEXON: 237,
|
|
34
|
+
ENERGY_WEB: 246,
|
|
35
|
+
FANTOM: 250,
|
|
36
|
+
HPB: 269,
|
|
37
|
+
BOBA: 288,
|
|
38
|
+
ZKSYNC_SEPOLIA: 300,
|
|
39
|
+
ZKSYNC: 324,
|
|
40
|
+
SHAPE: 360,
|
|
41
|
+
ASTAR: 592,
|
|
42
|
+
CALLISTO: 820,
|
|
43
|
+
WANCHAIN: 888,
|
|
44
|
+
HYPEREVM: 999,
|
|
45
|
+
KLAYTN_BAOBAB: 1001,
|
|
46
|
+
METIS: 1088,
|
|
47
|
+
POLYGON_ZK_EVM: 1101,
|
|
48
|
+
CORE: 1116,
|
|
49
|
+
MOONBEAM: 1284,
|
|
50
|
+
MOONRIVER: 1285,
|
|
51
|
+
UNICHAIN_SEPOLIA: 1301,
|
|
52
|
+
SEI_EVM: 1329,
|
|
53
|
+
POLYGON_ZK_EVM_TESTNET: 1442,
|
|
54
|
+
STORY: 1514,
|
|
55
|
+
ATHEIOS: 1620,
|
|
56
|
+
ETHERGEM: 1987,
|
|
57
|
+
REOSC: 2894,
|
|
58
|
+
ROBINHOOD: 4663,
|
|
59
|
+
MANTLE: 5000,
|
|
60
|
+
MANTLE_SEPOLIA: 5003,
|
|
61
|
+
SOMNIA: 5031,
|
|
62
|
+
ARC: 5042,
|
|
63
|
+
KLAYTN: 8217,
|
|
64
|
+
BASE: 8453,
|
|
65
|
+
MONAD_TESTNET: 10143,
|
|
66
|
+
ZERO_GRAVITY: 16661,
|
|
67
|
+
ETHERSOCIAL: 31102,
|
|
68
|
+
ADI: 36900,
|
|
69
|
+
ARBITRUM: 42161,
|
|
70
|
+
CELO: 42220,
|
|
71
|
+
ETHERLINK: 42793,
|
|
72
|
+
AVALANCHE_C_CHAIN_FUJI: 43113,
|
|
73
|
+
AVALANCHE_C_CHAIN: 43114,
|
|
74
|
+
ROBINHOOD_TESTNET: 46630,
|
|
75
|
+
SONIC_BLAZE: 57054,
|
|
76
|
+
LINEA_SEPOLIA: 59141,
|
|
77
|
+
LINEA: 59144,
|
|
78
|
+
POLYGON_AMOY: 80002,
|
|
79
|
+
BERACHAIN: 80094,
|
|
80
|
+
BLAST: 81457,
|
|
81
|
+
BASE_SEPOLIA: 84532,
|
|
82
|
+
AKROMA: 200625,
|
|
83
|
+
BITLAYER: 200901,
|
|
84
|
+
ARBITRUM_SEPOLIA: 421614,
|
|
85
|
+
SCROLL: 534352,
|
|
86
|
+
ETHEREUM_HOODI: 560048,
|
|
87
|
+
ETHER1: 1313114,
|
|
88
|
+
ARC_TESTNET: 5042002,
|
|
89
|
+
MUSICOIN: 7762959,
|
|
90
|
+
ETHEREUM_SEPOLIA: 11155111,
|
|
91
|
+
OPTIMISM_SEPOLIA: 11155420,
|
|
92
|
+
BLAST_SEPOLIA: 168587773,
|
|
93
|
+
NEON_EVM: 245022934,
|
|
94
|
+
PIRL: 3125659152,
|
|
95
|
+
} as const
|
|
96
|
+
|
|
97
|
+
export type ChainId = (typeof CHAIN_ID)[keyof typeof CHAIN_ID]
|
package/src/config.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { ChainId } from './chains'
|
|
4
5
|
import type { InternalTxSourceList } from './internalTxSources'
|
|
5
6
|
import type { NodeSourceList } from './nodeSources'
|
|
6
7
|
import type { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
|
|
7
8
|
|
|
9
|
+
export { CHAIN_ID } from './chains'
|
|
10
|
+
export type { ChainId } from './chains'
|
|
11
|
+
|
|
8
12
|
export type { InternalTxSource, InternalTxSourceList, NonEmptySource } from './internalTxSources'
|
|
9
13
|
export {
|
|
10
14
|
DEFAULT_INTERNAL_TX_SOURCES,
|
|
@@ -27,7 +31,7 @@ export const DEFAULT_LEDGER_EXPLORER_URI = 'https://explorers.api.live.ledger.co
|
|
|
27
31
|
export const DEFAULT_EIP1559_BASE_FEE_MULTIPLIER = 1.6
|
|
28
32
|
|
|
29
33
|
export type EvmConfig = {
|
|
30
|
-
chainId:
|
|
34
|
+
chainId: ChainId
|
|
31
35
|
node:
|
|
32
36
|
| {
|
|
33
37
|
type: 'external'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { ChainId } from '../config'
|
|
5
|
+
import type { StakingContractConfig } from '../types/staking'
|
|
6
|
+
import { STAKING_CONTRACTS } from '../staking/contracts'
|
|
7
|
+
|
|
8
|
+
/** The staking contract config of a chain that is expected to have one (registries are partial). */
|
|
9
|
+
export const requireStakingContract = (chainId: ChainId): StakingContractConfig => {
|
|
10
|
+
const config = STAKING_CONTRACTS[chainId]
|
|
11
|
+
if (!config) throw new Error(`No staking contract config for chain ${chainId}`)
|
|
12
|
+
return config
|
|
13
|
+
}
|
package/src/internalTxSources.ts
CHANGED
|
@@ -31,7 +31,8 @@ export function internalTxSourcesFromList(sources: readonly string[]): InternalT
|
|
|
31
31
|
throw new Error('internalTxSources: at least one source is required')
|
|
32
32
|
}
|
|
33
33
|
const seen = new Set<string>()
|
|
34
|
-
|
|
34
|
+
const validated: InternalTxSource[] = []
|
|
35
|
+
for (const [index, source] of sources.entries()) {
|
|
35
36
|
if (!isInternalTxSource(source)) {
|
|
36
37
|
throw new Error(`internalTxSources: invalid source "${source}"`)
|
|
37
38
|
}
|
|
@@ -42,8 +43,24 @@ export function internalTxSourcesFromList(sources: readonly string[]): InternalT
|
|
|
42
43
|
if (seen.has(source)) throw new Error(`internalTxSources: duplicate source "${source}"`)
|
|
43
44
|
seen.add(source)
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
validated.push(source)
|
|
47
|
+
}
|
|
48
|
+
const frozen = Object.freeze(validated)
|
|
49
|
+
if (isInternalTxSourceList(frozen)) return frozen
|
|
50
|
+
throw new Error('internalTxSources: invalid list')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isInternalTxSourceList(
|
|
54
|
+
sources: readonly InternalTxSource[]
|
|
55
|
+
): sources is InternalTxSourceList {
|
|
56
|
+
if (sources.length === 0) return false
|
|
57
|
+
const seen = new Set<string>()
|
|
58
|
+
for (const [index, source] of sources.entries()) {
|
|
59
|
+
if (source === 'empty') return index === sources.length - 1
|
|
60
|
+
if (seen.has(source)) return false
|
|
61
|
+
seen.add(source)
|
|
62
|
+
}
|
|
63
|
+
return true
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
export const DEFAULT_INTERNAL_TX_SOURCES = internalTxSourcesFromList([
|
package/src/logic/broadcast.ts
CHANGED
|
@@ -17,8 +17,8 @@ export async function broadcast(
|
|
|
17
17
|
}
|
|
18
18
|
): Promise<string> {
|
|
19
19
|
const config = await context.config(currencyId)
|
|
20
|
-
const nodeApi = getNodeApi(config,
|
|
21
|
-
return await nodeApi.broadcastTransaction(
|
|
20
|
+
const nodeApi = getNodeApi(config, context.logger)
|
|
21
|
+
return await nodeApi.broadcastTransaction(signature, broadcastConfig)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export default broadcast
|
package/src/logic/common.ts
CHANGED
|
@@ -21,9 +21,10 @@ import { getNodeApi } from '../network/node'
|
|
|
21
21
|
import { buildStakingTransactionParams, prepareStakingIntent, STAKING_CONTRACTS } from '../staking'
|
|
22
22
|
import { isNative, TransactionTypes } from '../types'
|
|
23
23
|
import { getErc20Data } from './getErc20Data'
|
|
24
|
+
import { isRecord } from './predicates'
|
|
24
25
|
|
|
25
26
|
export function isApiGasOptions(options: unknown): options is ApiGasOptions {
|
|
26
|
-
if (!options
|
|
27
|
+
if (!isRecord(options)) return false
|
|
27
28
|
|
|
28
29
|
return (
|
|
29
30
|
'slow' in options &&
|
|
@@ -36,7 +37,7 @@ export function isApiGasOptions(options: unknown): options is ApiGasOptions {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export function isApiFeeData(fees: unknown): fees is ApiFeeData {
|
|
39
|
-
if (!fees
|
|
40
|
+
if (!isRecord(fees)) return false
|
|
40
41
|
|
|
41
42
|
const isBigIntOrNull = (value: unknown): boolean => value === null || typeof value === 'bigint'
|
|
42
43
|
|
|
@@ -101,6 +102,15 @@ export function getCallData(intent: TransactionIntent<MemoNotSupported, BufferTx
|
|
|
101
102
|
: getErc20Data(intent.recipient, intent.amount)
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
function transactionRecipient(
|
|
106
|
+
asset: TransactionIntent<MemoNotSupported, BufferTxData>['asset'],
|
|
107
|
+
recipient: string
|
|
108
|
+
): string {
|
|
109
|
+
if (isNative(asset)) return recipient
|
|
110
|
+
if (typeof asset.assetReference === 'string') return asset.assetReference
|
|
111
|
+
throw new Error('token asset is missing assetReference')
|
|
112
|
+
}
|
|
113
|
+
|
|
104
114
|
function buildSendTxParams(intent: TransactionIntent<MemoNotSupported, BufferTxData>): {
|
|
105
115
|
to: string
|
|
106
116
|
data: Buffer
|
|
@@ -108,14 +118,14 @@ function buildSendTxParams(intent: TransactionIntent<MemoNotSupported, BufferTxD
|
|
|
108
118
|
} {
|
|
109
119
|
const { amount, asset, recipient } = intent
|
|
110
120
|
return {
|
|
111
|
-
to:
|
|
121
|
+
to: transactionRecipient(asset, recipient),
|
|
112
122
|
data: getCallData(intent),
|
|
113
123
|
value: isNative(asset) ? amount : 0n,
|
|
114
124
|
}
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
async function estimateGas(
|
|
118
|
-
|
|
128
|
+
config: EvmConfigInfo,
|
|
119
129
|
node: ReturnType<typeof getNodeApi>,
|
|
120
130
|
sender: string,
|
|
121
131
|
params: { to: string; data: Buffer; value: bigint },
|
|
@@ -126,7 +136,7 @@ async function estimateGas(
|
|
|
126
136
|
// trying to send more token asset than available.
|
|
127
137
|
// Fallback to an estimation of 0 to not break the UI.
|
|
128
138
|
return node
|
|
129
|
-
.getGasEstimation(
|
|
139
|
+
.getGasEstimation(sender, {
|
|
130
140
|
amount: BigNumber(params.value.toString()),
|
|
131
141
|
recipient: params.to,
|
|
132
142
|
data: params.data,
|
|
@@ -135,15 +145,15 @@ async function estimateGas(
|
|
|
135
145
|
if (!isStakingTransactionIntent(transactionIntent)) return new BigNumber(0)
|
|
136
146
|
// Retry staking gas estimation with the chain min calldata unit (LIVE-32750).
|
|
137
147
|
// Rebuild calldata + value to keep `msg.value` consistent with calldata-encoded amounts (e.g. Somnia).
|
|
138
|
-
const minUnit = STAKING_CONTRACTS[
|
|
148
|
+
const minUnit = STAKING_CONTRACTS[config.chainId]?.calldataAmountScale ?? 1n
|
|
139
149
|
// Reuse the already-prepared staking intent (enrichment done above) and only
|
|
140
150
|
// override the amount, so we don't repeat the async on-chain lookups.
|
|
141
|
-
const retry = buildStakingTransactionParams(
|
|
151
|
+
const retry = buildStakingTransactionParams(config, {
|
|
142
152
|
...(preparedStakingIntent ?? transactionIntent),
|
|
143
153
|
amount: minUnit,
|
|
144
154
|
})
|
|
145
155
|
return node
|
|
146
|
-
.getGasEstimation(
|
|
156
|
+
.getGasEstimation(sender, {
|
|
147
157
|
amount: new BigNumber(retry.value.toString()),
|
|
148
158
|
recipient: retry.to,
|
|
149
159
|
data: retry.data,
|
|
@@ -154,27 +164,26 @@ async function estimateGas(
|
|
|
154
164
|
|
|
155
165
|
export async function prepareUnsignedTxParams(
|
|
156
166
|
config: EvmConfigInfo,
|
|
157
|
-
currencyId: string,
|
|
158
167
|
transactionIntent: TransactionIntent<MemoNotSupported, BufferTxData>,
|
|
159
168
|
logger: Logger,
|
|
160
169
|
customFeesParameters?: FeeEstimation['parameters']
|
|
161
170
|
): Promise<TransactionLikeWithPreparedParams> {
|
|
162
171
|
const { sender, type } = transactionIntent
|
|
163
172
|
const transactionType = getTransactionType(type)
|
|
164
|
-
const node = getNodeApi(config,
|
|
173
|
+
const node = getNodeApi(config, logger)
|
|
165
174
|
const isSend = isSendTransactionIntent(transactionIntent)
|
|
166
175
|
|
|
167
176
|
// Prepare staking intents once (can require async on-chain lookups). See: LIVE-32750
|
|
168
177
|
const preparedStakingIntent = isSend
|
|
169
178
|
? undefined
|
|
170
|
-
: await prepareStakingIntent(config,
|
|
179
|
+
: await prepareStakingIntent(config, transactionIntent, logger)
|
|
171
180
|
|
|
172
181
|
const { to, data, value } = isSend
|
|
173
182
|
? buildSendTxParams(transactionIntent)
|
|
174
|
-
: buildStakingTransactionParams(
|
|
183
|
+
: buildStakingTransactionParams(config, preparedStakingIntent ?? transactionIntent)
|
|
175
184
|
|
|
176
185
|
const stakingGasMultiplier = isStakingTransactionIntent(transactionIntent)
|
|
177
|
-
? (STAKING_CONTRACTS[
|
|
186
|
+
? (STAKING_CONTRACTS[config.chainId]?.gasMultiplier?.({ mode: transactionIntent.mode }) ??
|
|
178
187
|
new BigNumber(1))
|
|
179
188
|
: new BigNumber(1)
|
|
180
189
|
|
|
@@ -188,7 +197,7 @@ export async function prepareUnsignedTxParams(
|
|
|
188
197
|
? BigNumber(customGasLimit.toString())
|
|
189
198
|
: (
|
|
190
199
|
await estimateGas(
|
|
191
|
-
|
|
200
|
+
config,
|
|
192
201
|
node,
|
|
193
202
|
sender,
|
|
194
203
|
{ to, data, value },
|
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
BufferTxData,
|
|
7
7
|
CraftedTransaction,
|
|
8
8
|
FeeEstimation,
|
|
9
|
-
FeesStrategy,
|
|
10
9
|
MemoNotSupported,
|
|
11
10
|
TransactionIntent,
|
|
12
11
|
} from '@ledgerhq/coin-module-framework/api/types'
|
|
@@ -17,6 +16,7 @@ import { getNodeApi } from '../network/node'
|
|
|
17
16
|
import { TransactionTypes } from '../types'
|
|
18
17
|
import { prepareUnsignedTxParams } from './common'
|
|
19
18
|
import { getNextSequence } from './getNextSequence'
|
|
19
|
+
import { isFeesStrategy } from './predicates'
|
|
20
20
|
|
|
21
21
|
export async function craftTransaction(
|
|
22
22
|
context: EvmContext,
|
|
@@ -32,7 +32,6 @@ export async function craftTransaction(
|
|
|
32
32
|
const config = await context.config(currencyId)
|
|
33
33
|
const { type, to, data, value, gasLimit } = await prepareUnsignedTxParams(
|
|
34
34
|
config,
|
|
35
|
-
currencyId,
|
|
36
35
|
transactionIntent,
|
|
37
36
|
context.logger,
|
|
38
37
|
customFees?.parameters
|
|
@@ -80,10 +79,12 @@ export async function craftTransaction(
|
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
if (!hasFeeData) {
|
|
83
|
-
const node = getNodeApi(config,
|
|
84
|
-
const feeData = await node.getFeeData(config,
|
|
82
|
+
const node = getNodeApi(config, context.logger)
|
|
83
|
+
const feeData = await node.getFeeData(config, {
|
|
85
84
|
type,
|
|
86
|
-
feesStrategy: customFees?.parameters?.feesStrategy
|
|
85
|
+
feesStrategy: isFeesStrategy(customFees?.parameters?.feesStrategy)
|
|
86
|
+
? customFees.parameters.feesStrategy
|
|
87
|
+
: undefined,
|
|
87
88
|
})
|
|
88
89
|
|
|
89
90
|
if (type === TransactionTypes.legacy && feeData.gasPrice) {
|
|
@@ -7,7 +7,6 @@ import type { ApiFeeData, ApiGasOptions, FeeData, GasOptions } from '../types'
|
|
|
7
7
|
import type {
|
|
8
8
|
BufferTxData,
|
|
9
9
|
FeeEstimation,
|
|
10
|
-
FeesStrategy,
|
|
11
10
|
MemoNotSupported,
|
|
12
11
|
TransactionIntent,
|
|
13
12
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
@@ -23,12 +22,12 @@ import { STAKING_CONTRACTS } from '../staking'
|
|
|
23
22
|
import { TransactionTypes } from '../types'
|
|
24
23
|
import { getTransactionType, prepareUnsignedTxParams } from './common'
|
|
25
24
|
import { getNextSequence } from './getNextSequence'
|
|
25
|
+
import { isFeesStrategy } from './predicates'
|
|
26
26
|
|
|
27
27
|
const SEND_MAX_L1_FEE_BUFFER = new BigNumber(2)
|
|
28
28
|
|
|
29
29
|
async function computeAdditionalFees(
|
|
30
30
|
config: EvmConfigInfo,
|
|
31
|
-
currencyId: string,
|
|
32
31
|
unsignedTransaction: TransactionLike,
|
|
33
32
|
logger: Logger
|
|
34
33
|
): Promise<BigNumber | undefined> {
|
|
@@ -43,12 +42,7 @@ async function computeAdditionalFees(
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
try {
|
|
46
|
-
return await getAdditionalLayer2Fees(
|
|
47
|
-
config,
|
|
48
|
-
currencyId,
|
|
49
|
-
Transaction.from(transaction).serialized,
|
|
50
|
-
logger
|
|
51
|
-
)
|
|
45
|
+
return await getAdditionalLayer2Fees(config, Transaction.from(transaction).serialized, logger)
|
|
52
46
|
} catch {
|
|
53
47
|
return new BigNumber(0)
|
|
54
48
|
}
|
|
@@ -159,7 +153,9 @@ export async function estimateFees(
|
|
|
159
153
|
finalFeeData: FeeData
|
|
160
154
|
finalGasOptions?: GasOptions
|
|
161
155
|
}> => {
|
|
162
|
-
const feesStrategy = customFeesParameters?.feesStrategy
|
|
156
|
+
const feesStrategy = isFeesStrategy(customFeesParameters?.feesStrategy)
|
|
157
|
+
? customFeesParameters.feesStrategy
|
|
158
|
+
: undefined
|
|
163
159
|
|
|
164
160
|
if (feesStrategy === 'custom') {
|
|
165
161
|
return { finalFeeData: extractFeeData(customFeesParameters) }
|
|
@@ -181,8 +177,8 @@ export async function estimateFees(
|
|
|
181
177
|
return { finalFeeData: remoteGasOptions[feesStrategy], finalGasOptions: remoteGasOptions }
|
|
182
178
|
}
|
|
183
179
|
|
|
184
|
-
const node = getNodeApi(config,
|
|
185
|
-
const feeData = await node.getFeeData(config,
|
|
180
|
+
const node = getNodeApi(config, context.logger)
|
|
181
|
+
const feeData = await node.getFeeData(config, {
|
|
186
182
|
type: txType,
|
|
187
183
|
feesStrategy,
|
|
188
184
|
})
|
|
@@ -194,13 +190,7 @@ export async function estimateFees(
|
|
|
194
190
|
// all independent network calls and sequencing them triples the latency.
|
|
195
191
|
const [{ to, data, value, gasLimit }, nonce, { finalFeeData, finalGasOptions }] =
|
|
196
192
|
await Promise.all([
|
|
197
|
-
prepareUnsignedTxParams(
|
|
198
|
-
config,
|
|
199
|
-
currencyId,
|
|
200
|
-
transactionIntent,
|
|
201
|
-
context.logger,
|
|
202
|
-
customFeesParameters
|
|
203
|
-
),
|
|
193
|
+
prepareUnsignedTxParams(config, transactionIntent, context.logger, customFeesParameters),
|
|
204
194
|
noncePromise,
|
|
205
195
|
feeDataPromise,
|
|
206
196
|
])
|
|
@@ -238,19 +228,14 @@ export async function estimateFees(
|
|
|
238
228
|
value,
|
|
239
229
|
chainId,
|
|
240
230
|
}
|
|
241
|
-
const rawAdditionalFees = await computeAdditionalFees(
|
|
242
|
-
config,
|
|
243
|
-
currencyId,
|
|
244
|
-
unsignedTransaction,
|
|
245
|
-
context.logger
|
|
246
|
-
)
|
|
231
|
+
const rawAdditionalFees = await computeAdditionalFees(config, unsignedTransaction, context.logger)
|
|
247
232
|
const additionalFees =
|
|
248
233
|
transactionIntent.useAllAmount && rawAdditionalFees
|
|
249
234
|
? rawAdditionalFees.multipliedBy(SEND_MAX_L1_FEE_BUFFER).integerValue(BigNumber.ROUND_CEIL)
|
|
250
235
|
: rawAdditionalFees
|
|
251
236
|
|
|
252
237
|
// delegate send-max: expose reserve/scale so the bridge can compute the amount (it has the balance)
|
|
253
|
-
const stakingConfig = STAKING_CONTRACTS[
|
|
238
|
+
const stakingConfig = STAKING_CONTRACTS[config.chainId]
|
|
254
239
|
const delegateMaxParams =
|
|
255
240
|
transactionIntent.useAllAmount &&
|
|
256
241
|
isStakingIntent(transactionIntent) &&
|
package/src/logic/getBalance.ts
CHANGED
|
@@ -27,24 +27,20 @@ export async function getBalance(
|
|
|
27
27
|
options?: BalanceOptions
|
|
28
28
|
): Promise<Balance[]> {
|
|
29
29
|
const config = await context.config(currencyId)
|
|
30
|
-
const nodeApi = getNodeApi(config,
|
|
30
|
+
const nodeApi = getNodeApi(config, context.logger)
|
|
31
31
|
const explorerApi = getExplorerApi(config)
|
|
32
32
|
|
|
33
33
|
const [nativeBalance, tokensBalances] = await Promise.all([
|
|
34
|
-
getNativeBalance(
|
|
34
|
+
getNativeBalance(address, nodeApi),
|
|
35
35
|
getTokenBalances(context, currencyId, address, nodeApi, explorerApi, config, options),
|
|
36
36
|
])
|
|
37
37
|
|
|
38
38
|
return [nativeBalance].concat(tokensBalances)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
async function getNativeBalance(
|
|
42
|
-
currencyId: string,
|
|
43
|
-
address: string,
|
|
44
|
-
nodeApi: NodeApi
|
|
45
|
-
): Promise<Balance> {
|
|
41
|
+
async function getNativeBalance(address: string, nodeApi: NodeApi): Promise<Balance> {
|
|
46
42
|
// Get native balance for the first element array
|
|
47
|
-
const nativeBalance = await nodeApi.getCoinBalance(
|
|
43
|
+
const nativeBalance = await nodeApi.getCoinBalance(address)
|
|
48
44
|
|
|
49
45
|
return {
|
|
50
46
|
asset: { type: 'native' },
|
|
@@ -73,7 +69,7 @@ async function getTokenBalances(
|
|
|
73
69
|
// list into `{ value: 0n }` for every already-known sub-account, which would silently display
|
|
74
70
|
// a held token's balance as zero — so the explorer's own error is left to propagate, never
|
|
75
71
|
// swallowed into an empty result.
|
|
76
|
-
const extractKnownValIds = STAKING_CONFIG[
|
|
72
|
+
const extractKnownValIds = STAKING_CONFIG[config.chainId]?.extractKnownValIds
|
|
77
73
|
|
|
78
74
|
let discoveredAssets: AssetInfo[]
|
|
79
75
|
let knownValidatorIds: string[] | undefined
|
|
@@ -82,7 +78,6 @@ async function getTokenBalances(
|
|
|
82
78
|
const ops = await explorerApi.getOperations(
|
|
83
79
|
config,
|
|
84
80
|
context.logger,
|
|
85
|
-
currencyId,
|
|
86
81
|
address,
|
|
87
82
|
0,
|
|
88
83
|
undefined,
|
|
@@ -90,7 +85,7 @@ async function getTokenBalances(
|
|
|
90
85
|
undefined,
|
|
91
86
|
undefined
|
|
92
87
|
)
|
|
93
|
-
knownValidatorIds = extractKnownValIds(
|
|
88
|
+
knownValidatorIds = extractKnownValIds(config.chainId, ops.lastCoinOperations, context.logger)
|
|
94
89
|
|
|
95
90
|
discoveredAssets = []
|
|
96
91
|
for (const operation of ops.lastTokenOperations) {
|
|
@@ -106,7 +101,6 @@ async function getTokenBalances(
|
|
|
106
101
|
discoveredAssets = await explorerApi.discoverTokenAssets(
|
|
107
102
|
config,
|
|
108
103
|
context.logger,
|
|
109
|
-
currencyId,
|
|
110
104
|
address,
|
|
111
105
|
scanMinHeight
|
|
112
106
|
)
|
|
@@ -163,7 +157,7 @@ async function getTokenBalances(
|
|
|
163
157
|
chunk.map(async (contract) => {
|
|
164
158
|
const asset = assets.get(contract)
|
|
165
159
|
if (asset === undefined) throw new Error(`No asset defined for contract ${contract}`)
|
|
166
|
-
const balance = await nodeApi.getTokenBalance(
|
|
160
|
+
const balance = await nodeApi.getTokenBalance(address, contract)
|
|
167
161
|
return { asset, value: BigInt(balance.toFixed(0)) }
|
|
168
162
|
})
|
|
169
163
|
)
|
package/src/logic/getBlock.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmContext } from '../config'
|
|
4
|
+
import type { ChainId, EvmContext } from '../config'
|
|
5
5
|
import type { BlockReceiptInfo, PrefetchedBlockTransaction } from '../network/node/types'
|
|
6
6
|
import type { InternalTxsByHash } from './internalTransactionsFetcher'
|
|
7
7
|
import type {
|
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
15
15
|
import { promiseAllBatched } from '@ledgerhq/coin-module-framework/promises'
|
|
16
16
|
import { rpcTransactionToBlockOperations } from '../adapters/blockOperations'
|
|
17
|
-
import { DEFAULT_INTERNAL_TX_SOURCES } from '../config'
|
|
17
|
+
import { CHAIN_ID, DEFAULT_INTERNAL_TX_SOURCES } from '../config'
|
|
18
18
|
import { UnsupportedRpcMethodError } from '../errors'
|
|
19
19
|
import { buildSmartContractDetails, safeEncodeEIP55 } from '../logic-public'
|
|
20
20
|
import { getNodeApi } from '../network/node'
|
|
@@ -35,17 +35,16 @@ export async function getBlock(
|
|
|
35
35
|
// per `getBlockInternalTxsSources`) in parallel with the receipts, and merge them into the
|
|
36
36
|
// block transactions
|
|
37
37
|
const config = await context.config(currencyId)
|
|
38
|
-
const nodeApi = getNodeApi(config,
|
|
38
|
+
const nodeApi = getNodeApi(config, context.logger)
|
|
39
39
|
const internalTxSources = config.getBlockInternalTxsSources ?? DEFAULT_INTERNAL_TX_SOURCES
|
|
40
40
|
const fetchInternalTxs = createInternalTransactionsFetcher(
|
|
41
41
|
config,
|
|
42
42
|
nodeApi,
|
|
43
|
-
currencyId,
|
|
44
43
|
internalTxSources,
|
|
45
44
|
context.logger
|
|
46
45
|
)
|
|
47
46
|
|
|
48
|
-
const result = await nodeApi.getBlockByHeight(
|
|
47
|
+
const result = await nodeApi.getBlockByHeight(height, true)
|
|
49
48
|
|
|
50
49
|
const info: BlockInfo = {
|
|
51
50
|
height: result.height,
|
|
@@ -68,7 +67,8 @@ export async function getBlock(
|
|
|
68
67
|
// source that is one metered `txlistinternal` call per empty block.
|
|
69
68
|
const [transactions, internalTxs] = await Promise.all([
|
|
70
69
|
getTransactionsFromNode(
|
|
71
|
-
|
|
70
|
+
config.chainId,
|
|
71
|
+
config.name,
|
|
72
72
|
transactionHashes,
|
|
73
73
|
nodeApi,
|
|
74
74
|
result.height,
|
|
@@ -125,7 +125,8 @@ function mergeInternalTransactions(
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
async function getTransactionsFromNode(
|
|
128
|
-
|
|
128
|
+
chainId: ChainId,
|
|
129
|
+
chainName: string,
|
|
129
130
|
transactionHashes: string[],
|
|
130
131
|
nodeApi: ReturnType<typeof getNodeApi>,
|
|
131
132
|
blockHeight: number,
|
|
@@ -135,7 +136,8 @@ async function getTransactionsFromNode(
|
|
|
135
136
|
if (transactionHashes.length === 0) return []
|
|
136
137
|
|
|
137
138
|
const bulkTransactions = await getTransactionsFromPrefetchedData(
|
|
138
|
-
|
|
139
|
+
chainId,
|
|
140
|
+
chainName,
|
|
139
141
|
blockHeight,
|
|
140
142
|
prefetchedTransactions,
|
|
141
143
|
nodeApi,
|
|
@@ -154,14 +156,15 @@ async function getTransactionsFromNode(
|
|
|
154
156
|
const transactionResults = await promiseAllBatched(
|
|
155
157
|
MAX_CONCURRENCY,
|
|
156
158
|
transactionHashes,
|
|
157
|
-
(txHash: string) => getTransactionFromHash(
|
|
159
|
+
(txHash: string) => getTransactionFromHash(chainId, txHash, nodeApi, logger)
|
|
158
160
|
)
|
|
159
161
|
|
|
160
162
|
return transactionResults.filter((tx): tx is BlockTransaction => tx !== null)
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
async function getTransactionsFromPrefetchedData(
|
|
164
|
-
|
|
166
|
+
chainId: ChainId,
|
|
167
|
+
chainName: string,
|
|
165
168
|
blockHeight: number,
|
|
166
169
|
prefetchedTransactions: PrefetchedBlockTransaction[] | undefined,
|
|
167
170
|
nodeApi: ReturnType<typeof getNodeApi>,
|
|
@@ -171,7 +174,7 @@ async function getTransactionsFromPrefetchedData(
|
|
|
171
174
|
return null
|
|
172
175
|
|
|
173
176
|
try {
|
|
174
|
-
const receipts = await nodeApi.getBlockReceipts(
|
|
177
|
+
const receipts = await nodeApi.getBlockReceipts(blockHeight)
|
|
175
178
|
const receiptsByHash = new Map(receipts.map((receipt) => [receipt.hash, receipt]))
|
|
176
179
|
|
|
177
180
|
const transactions: BlockTransaction[] = []
|
|
@@ -182,7 +185,7 @@ async function getTransactionsFromPrefetchedData(
|
|
|
182
185
|
transactions.push({
|
|
183
186
|
...blockTx,
|
|
184
187
|
operations: applyChainSpecificCorrections(
|
|
185
|
-
|
|
188
|
+
chainId,
|
|
186
189
|
blockTx.operations,
|
|
187
190
|
receipt.type,
|
|
188
191
|
logger
|
|
@@ -196,7 +199,7 @@ async function getTransactionsFromPrefetchedData(
|
|
|
196
199
|
throw error
|
|
197
200
|
|
|
198
201
|
logger('warn', 'EVM getBlock fallback: eth_getBlockReceipts unsupported', {
|
|
199
|
-
|
|
202
|
+
currency: chainName,
|
|
200
203
|
blockHeight,
|
|
201
204
|
error: error.rawError,
|
|
202
205
|
})
|
|
@@ -239,19 +242,19 @@ function prefetchedTransactionToBlockTransaction(
|
|
|
239
242
|
}
|
|
240
243
|
|
|
241
244
|
async function getTransactionFromHash(
|
|
242
|
-
|
|
245
|
+
chainId: ChainId,
|
|
243
246
|
txHash: string,
|
|
244
247
|
nodeApi: ReturnType<typeof getNodeApi>,
|
|
245
248
|
logger: Logger
|
|
246
249
|
): Promise<BlockTransaction | null> {
|
|
247
|
-
const txInfo = await nodeApi.getTransaction(
|
|
250
|
+
const txInfo = await nodeApi.getTransaction(txHash)
|
|
248
251
|
|
|
249
252
|
const failed = txInfo.status === 0
|
|
250
253
|
const fees =
|
|
251
254
|
BigInt(txInfo.gasUsed) * BigInt(txInfo.gasPrice) + (txInfo.l1Fee ? BigInt(txInfo.l1Fee) : 0n)
|
|
252
255
|
|
|
253
256
|
const rawOperations = rpcTransactionToBlockOperations(txInfo, logger)
|
|
254
|
-
const operations = applyChainSpecificCorrections(
|
|
257
|
+
const operations = applyChainSpecificCorrections(chainId, rawOperations, txInfo.type, logger)
|
|
255
258
|
|
|
256
259
|
const details = buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress)
|
|
257
260
|
|
|
@@ -266,13 +269,13 @@ async function getTransactionFromHash(
|
|
|
266
269
|
}
|
|
267
270
|
|
|
268
271
|
function applyChainSpecificCorrections(
|
|
269
|
-
|
|
272
|
+
chainId: ChainId,
|
|
270
273
|
operations: BlockOperation[],
|
|
271
274
|
receiptType: number | undefined,
|
|
272
275
|
logger: Logger
|
|
273
276
|
): BlockOperation[] {
|
|
274
|
-
switch (
|
|
275
|
-
case
|
|
277
|
+
switch (chainId) {
|
|
278
|
+
case CHAIN_ID.ZKSYNC:
|
|
276
279
|
return rewriteZkSyncL1ToL2DepositOps(operations, receiptType, logger)
|
|
277
280
|
default:
|
|
278
281
|
return operations
|
|
@@ -11,8 +11,8 @@ export async function getBlockInfo(
|
|
|
11
11
|
height: number
|
|
12
12
|
): Promise<BlockInfo> {
|
|
13
13
|
const config = await context.config(currencyId)
|
|
14
|
-
const api = getNodeApi(config,
|
|
15
|
-
const result = await api.getBlockByHeight(
|
|
14
|
+
const api = getNodeApi(config, context.logger)
|
|
15
|
+
const result = await api.getBlockByHeight(height)
|
|
16
16
|
|
|
17
17
|
const blockInfo: BlockInfo = {
|
|
18
18
|
height: result.height,
|
|
@@ -10,9 +10,6 @@ export async function getNextSequence(
|
|
|
10
10
|
address: string
|
|
11
11
|
): Promise<bigint> {
|
|
12
12
|
const config = await context.config(currencyId)
|
|
13
|
-
const txCount = await getNodeApi(config,
|
|
14
|
-
currencyId,
|
|
15
|
-
address
|
|
16
|
-
)
|
|
13
|
+
const txCount = await getNodeApi(config, context.logger).getTransactionCount(address)
|
|
17
14
|
return typeof txCount === 'number' ? BigInt(txCount) : txCount
|
|
18
15
|
}
|