@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,12 +1,11 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { BlockFinalizationTag, EvmConfigInfo, ExternalNodeConfig } from '../../config'
|
|
4
|
+
import type { BlockFinalizationTag, ChainId, EvmConfigInfo, ExternalNodeConfig } from '../../config'
|
|
5
5
|
import type { FeeHistory, FeeData } from '../../types'
|
|
6
6
|
import type {
|
|
7
7
|
NodeApi,
|
|
8
8
|
ERC20Transfer,
|
|
9
|
-
PrefetchedBlockTransaction,
|
|
10
9
|
LogWithAddress,
|
|
11
10
|
TransactionReceipt,
|
|
12
11
|
TraceBlockItem,
|
|
@@ -23,8 +22,18 @@ import { ethers, FetchRequest, JsonRpcProvider } from 'ethers'
|
|
|
23
22
|
import ERC20Abi from '../../abis/erc20.abi.json'
|
|
24
23
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
25
24
|
import ScrollGasPriceOracleAbi from '../../abis/scrollGasPriceOracle.abi.json'
|
|
25
|
+
import { CHAIN_ID } from '../../config'
|
|
26
26
|
import { GasEstimationError, InsufficientFunds, UnsupportedRpcMethodError } from '../../errors'
|
|
27
27
|
import { isSmartContractInput, safeEncodeEIP55, normalizeAddress } from '../../logic-public'
|
|
28
|
+
import {
|
|
29
|
+
isOptionalQuantity,
|
|
30
|
+
isOptionalString,
|
|
31
|
+
isQuantity,
|
|
32
|
+
isRecord,
|
|
33
|
+
isString,
|
|
34
|
+
isTraceBlockItem,
|
|
35
|
+
isTransactionReceipt,
|
|
36
|
+
} from '../../logic/predicates'
|
|
28
37
|
import { withRetries } from '../withRetries'
|
|
29
38
|
import { gethCallTracerToTraceBlockItems } from './gethCallTracerToTraceBlockItems'
|
|
30
39
|
import {
|
|
@@ -34,7 +43,6 @@ import {
|
|
|
34
43
|
isUnsupportedRpcMethodErrorMsg,
|
|
35
44
|
isUnsupportedRpcMethodError,
|
|
36
45
|
} from './rpc.errors'
|
|
37
|
-
import { isTraceBlockItem } from './types'
|
|
38
46
|
|
|
39
47
|
/**
|
|
40
48
|
* ERC20 Transfer event topic: keccak256("Transfer(address,address,uint256)")
|
|
@@ -190,12 +198,12 @@ export const DEFAULT_RETRIES_RPC_METHODS =
|
|
|
190
198
|
* Without this, ethers will create a new provider and use the `eth_chainId` RPC call
|
|
191
199
|
* at instanciation which could result in rate limits being reached
|
|
192
200
|
* on some specific nodes (E.g. the main Optimism RPC)
|
|
193
|
-
* Keyed by
|
|
201
|
+
* Keyed by chain id + RPC URI so the same chain with different uri gets distinct providers.
|
|
194
202
|
*/
|
|
195
203
|
const PROVIDERS_BY_RPC: Record<string, JsonRpcProvider> = {}
|
|
196
204
|
|
|
197
|
-
function providerCacheKey(
|
|
198
|
-
return `${
|
|
205
|
+
function providerCacheKey(chainId: ChainId, uri: string): string {
|
|
206
|
+
return `${chainId}:${uri}`
|
|
199
207
|
}
|
|
200
208
|
|
|
201
209
|
/**
|
|
@@ -223,16 +231,15 @@ export function destroyAllRpcProviders(): void {
|
|
|
223
231
|
*/
|
|
224
232
|
export async function withApi<T>(
|
|
225
233
|
config: EvmConfigInfo,
|
|
226
|
-
currencyId: string,
|
|
227
234
|
execute: (api: JsonRpcProvider) => Promise<T>,
|
|
228
235
|
nodeConfig: ExternalNodeConfig
|
|
229
236
|
): Promise<T> {
|
|
230
237
|
const retries = nodeConfig.retries ?? DEFAULT_RETRIES_RPC_METHODS
|
|
231
238
|
return withRetries(
|
|
232
239
|
async () => {
|
|
233
|
-
const
|
|
240
|
+
const chainId = config.chainId
|
|
241
|
+
const key = providerCacheKey(chainId, nodeConfig.uri)
|
|
234
242
|
if (!PROVIDERS_BY_RPC[key]) {
|
|
235
|
-
const chainId = config.chainId
|
|
236
243
|
const fetchReq = new FetchRequest(nodeConfig.uri)
|
|
237
244
|
// Disable ethers' built-in HTTP-level retries: withRetries handles all retry logic.
|
|
238
245
|
fetchReq.setThrottleParams({ maxAttempts: 1 })
|
|
@@ -261,23 +268,23 @@ function parseReceiptL1Fee(raw: Record<string, unknown>): string | undefined {
|
|
|
261
268
|
|
|
262
269
|
async function getTransaction(
|
|
263
270
|
api: JsonRpcProvider,
|
|
264
|
-
_currencyId: string,
|
|
265
271
|
txHash: string,
|
|
266
272
|
logger: Logger
|
|
267
273
|
): Promise<TransactionInfo> {
|
|
268
274
|
// Note: raw RPC call is used to get transaction receipt, as ethers method drops extra fields. We need optimism's
|
|
269
275
|
// extra fields that contain L1 fees.
|
|
270
276
|
// A pull request for ethers is open to avoid this: https://github.com/ethers-io/ethers.js/pull/5189
|
|
271
|
-
const [tx,
|
|
277
|
+
const [tx, rawReceipt] = await Promise.all([
|
|
272
278
|
api.getTransaction(txHash),
|
|
273
|
-
api.send('eth_getTransactionReceipt', [txHash])
|
|
279
|
+
api.send('eth_getTransactionReceipt', [txHash]),
|
|
274
280
|
])
|
|
275
281
|
|
|
276
|
-
if (!tx || !
|
|
282
|
+
if (!tx || !isTransactionReceipt(rawReceipt)) {
|
|
277
283
|
throw new Error('Transaction or receipt not found')
|
|
278
284
|
}
|
|
279
285
|
|
|
280
|
-
const
|
|
286
|
+
const receipt = rawReceipt
|
|
287
|
+
const raw = recordOf(receipt)
|
|
281
288
|
const contractAddressRaw = raw.contractAddress
|
|
282
289
|
const contractAddress =
|
|
283
290
|
typeof contractAddressRaw === 'string' && contractAddressRaw.startsWith('0x')
|
|
@@ -285,19 +292,20 @@ async function getTransaction(
|
|
|
285
292
|
: undefined
|
|
286
293
|
|
|
287
294
|
const l1Fee = parseReceiptL1Fee(raw)
|
|
295
|
+
const envelopeType = receiptEnvelopeType(receipt.type)
|
|
288
296
|
|
|
289
297
|
return {
|
|
290
298
|
hash: tx.hash,
|
|
291
299
|
blockHeight: tx.blockNumber ?? undefined,
|
|
292
300
|
blockHash: tx.blockHash ?? undefined,
|
|
293
301
|
nonce: tx.nonce,
|
|
294
|
-
gasUsed:
|
|
295
|
-
gasPrice:
|
|
296
|
-
status:
|
|
302
|
+
gasUsed: quantityToDecimal(receipt.gasUsed),
|
|
303
|
+
gasPrice: receiptGasPrice(receipt),
|
|
304
|
+
status: receiptStatus(receipt.status),
|
|
297
305
|
value: tx.value.toString(),
|
|
298
306
|
from: tx.from,
|
|
299
307
|
to: tx.to ?? undefined,
|
|
300
|
-
type:
|
|
308
|
+
type: envelopeType !== undefined ? envelopeType : (tx.type ?? undefined),
|
|
301
309
|
...(tx.data !== null && tx.data !== undefined && isSmartContractInput(tx.data)
|
|
302
310
|
? { input: tx.data }
|
|
303
311
|
: {}),
|
|
@@ -307,20 +315,12 @@ async function getTransaction(
|
|
|
307
315
|
}
|
|
308
316
|
}
|
|
309
317
|
|
|
310
|
-
async function getCoinBalance(
|
|
311
|
-
api: JsonRpcProvider,
|
|
312
|
-
_currencyId: string,
|
|
313
|
-
address: string
|
|
314
|
-
): Promise<BigNumber> {
|
|
318
|
+
async function getCoinBalance(api: JsonRpcProvider, address: string): Promise<BigNumber> {
|
|
315
319
|
const balance = await api.getBalance(normalizeAddress(address))
|
|
316
320
|
return new BigNumber(balance.toString())
|
|
317
321
|
}
|
|
318
322
|
|
|
319
|
-
async function call(
|
|
320
|
-
api: JsonRpcProvider,
|
|
321
|
-
_currencyId: string,
|
|
322
|
-
params: EvmCallParams
|
|
323
|
-
): Promise<string> {
|
|
323
|
+
async function call(api: JsonRpcProvider, params: EvmCallParams): Promise<string> {
|
|
324
324
|
const block = typeof params.block === 'number' ? ethers.toQuantity(params.block) : params.block
|
|
325
325
|
return api.send('eth_call', [
|
|
326
326
|
{
|
|
@@ -333,7 +333,6 @@ async function call(
|
|
|
333
333
|
|
|
334
334
|
async function getTokenBalance(
|
|
335
335
|
api: JsonRpcProvider,
|
|
336
|
-
_currencyId: string,
|
|
337
336
|
address: string,
|
|
338
337
|
contractAddress: string
|
|
339
338
|
): Promise<BigNumber> {
|
|
@@ -344,7 +343,6 @@ async function getTokenBalance(
|
|
|
344
343
|
|
|
345
344
|
async function getTokenAllowance(
|
|
346
345
|
api: JsonRpcProvider,
|
|
347
|
-
_currencyId: string,
|
|
348
346
|
ownerAddress: string,
|
|
349
347
|
contractAddress: string,
|
|
350
348
|
spenderAddress: string
|
|
@@ -357,11 +355,7 @@ async function getTokenAllowance(
|
|
|
357
355
|
return new BigNumber(allowance.toString())
|
|
358
356
|
}
|
|
359
357
|
|
|
360
|
-
async function getTransactionCount(
|
|
361
|
-
api: JsonRpcProvider,
|
|
362
|
-
_currencyId: string,
|
|
363
|
-
address: string
|
|
364
|
-
): Promise<number> {
|
|
358
|
+
async function getTransactionCount(api: JsonRpcProvider, address: string): Promise<number> {
|
|
365
359
|
return api.getTransactionCount(normalizeAddress(address), 'pending')
|
|
366
360
|
}
|
|
367
361
|
|
|
@@ -394,8 +388,8 @@ function makeGetGasEstimation(
|
|
|
394
388
|
nodeConfig: ExternalNodeConfig,
|
|
395
389
|
logger: Logger
|
|
396
390
|
): NodeApi['getGasEstimation'] {
|
|
397
|
-
return (
|
|
398
|
-
withApi(evmConfig,
|
|
391
|
+
return (address, transaction) =>
|
|
392
|
+
withApi(evmConfig, (api) => getGasEstimation(api, address, transaction, logger), {
|
|
399
393
|
...nodeConfig,
|
|
400
394
|
retries: 0,
|
|
401
395
|
})
|
|
@@ -404,7 +398,6 @@ function makeGetGasEstimation(
|
|
|
404
398
|
async function getFeeData(
|
|
405
399
|
api: JsonRpcProvider,
|
|
406
400
|
config: EvmConfigInfo,
|
|
407
|
-
currencyId: string,
|
|
408
401
|
transaction: { type?: number | undefined; feesStrategy?: string | null | undefined }
|
|
409
402
|
): Promise<FeeData> {
|
|
410
403
|
const block = await api.getBlock('latest')
|
|
@@ -477,7 +470,7 @@ async function getFeeData(
|
|
|
477
470
|
// As a safety measure, if maxPriorityFeePerGas is zero
|
|
478
471
|
// we enforce a 1 Gwei value
|
|
479
472
|
let maxPriorityFeePerGas = maxPriorityFeeAverage.isZero()
|
|
480
|
-
? getMaxPriorityFeePerGas(
|
|
473
|
+
? getMaxPriorityFeePerGas(config.chainId)
|
|
481
474
|
: maxPriorityFeeAverage
|
|
482
475
|
|
|
483
476
|
// Apply the per-chain config floor on top, for networks (typically sparse testnets)
|
|
@@ -516,7 +509,6 @@ async function getFeeData(
|
|
|
516
509
|
|
|
517
510
|
async function broadcastTransaction(
|
|
518
511
|
api: JsonRpcProvider,
|
|
519
|
-
_currencyId: string,
|
|
520
512
|
signedTxHex: string,
|
|
521
513
|
logger: Logger
|
|
522
514
|
): Promise<string> {
|
|
@@ -548,7 +540,6 @@ function assertNotStubBlock(
|
|
|
548
540
|
|
|
549
541
|
async function getBlockByHeight(
|
|
550
542
|
api: JsonRpcProvider,
|
|
551
|
-
_currencyId: string,
|
|
552
543
|
blockHeight: number | BlockFinalizationTag,
|
|
553
544
|
logger: Logger,
|
|
554
545
|
prefetchTxs?: boolean
|
|
@@ -597,23 +588,15 @@ async function getBlockByHeight(
|
|
|
597
588
|
`Block ${blockHeight} contains malformed prefetched transaction at index ${index}`
|
|
598
589
|
)
|
|
599
590
|
|
|
600
|
-
|
|
601
|
-
const rawTx = tx as unknown as {
|
|
602
|
-
data?: string
|
|
603
|
-
// ethers v6: gasPrice is null for EIP-1559 (type-2) transactions
|
|
604
|
-
gasPrice?: bigint | null
|
|
605
|
-
maxFeePerGas?: bigint | null
|
|
606
|
-
}
|
|
591
|
+
const data = tx.data
|
|
607
592
|
return {
|
|
608
593
|
hash: tx.hash,
|
|
609
594
|
value: tx.value.toString(),
|
|
610
595
|
from: tx.from,
|
|
611
596
|
to: tx.to ?? undefined,
|
|
612
|
-
...(
|
|
613
|
-
? { input: rawTx.data }
|
|
614
|
-
: {}),
|
|
597
|
+
...(typeof data === 'string' && isSmartContractInput(data) ? { input: data } : {}),
|
|
615
598
|
// EIP-1559 transactions have gasPrice: null; fall back to maxFeePerGas then 0
|
|
616
|
-
gasPrice: (
|
|
599
|
+
gasPrice: (tx.gasPrice ?? tx.maxFeePerGas ?? 0n).toString(),
|
|
617
600
|
}
|
|
618
601
|
})
|
|
619
602
|
|
|
@@ -631,11 +614,8 @@ async function getBlockByHeight(
|
|
|
631
614
|
/** Specific error thrown by ethers when handling zksync blocks with missing signature fields in prefetched transactions */
|
|
632
615
|
function isSignatureError(error: unknown): boolean {
|
|
633
616
|
if (!hasErrorCode(error, 'INVALID_ARGUMENT')) return false
|
|
634
|
-
if (
|
|
635
|
-
|
|
636
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
637
|
-
const ethersError = error as { argument?: unknown }
|
|
638
|
-
return ethersError.argument === 'signature'
|
|
617
|
+
if (!isRecord(error)) return false
|
|
618
|
+
return error.argument === 'signature'
|
|
639
619
|
}
|
|
640
620
|
|
|
641
621
|
/**
|
|
@@ -662,10 +642,9 @@ async function getBlockByHeightFromRawRpc(
|
|
|
662
642
|
): Promise<BlockByHeightResult> {
|
|
663
643
|
const blockTag = typeof blockHeight === 'number' ? ethers.toQuantity(blockHeight) : blockHeight
|
|
664
644
|
const rawBlock = await api.send('eth_getBlockByNumber', [blockTag, prefetchTxs])
|
|
665
|
-
if (
|
|
666
|
-
throw new Error('Invalid eth_getBlockByNumber response')
|
|
645
|
+
if (!isRecord(rawBlock)) throw new Error('Invalid eth_getBlockByNumber response')
|
|
667
646
|
|
|
668
|
-
const block = rawBlock
|
|
647
|
+
const block = rawBlock
|
|
669
648
|
if (typeof block.hash !== 'string')
|
|
670
649
|
throw new Error('Malformed block hash in eth_getBlockByNumber')
|
|
671
650
|
if (typeof block.parentHash !== 'string')
|
|
@@ -747,7 +726,6 @@ async function getBlockByHeightFromRawRpc(
|
|
|
747
726
|
|
|
748
727
|
async function getBlockReceipts(
|
|
749
728
|
api: JsonRpcProvider,
|
|
750
|
-
_currencyId: string,
|
|
751
729
|
blockHeight: number | 'latest',
|
|
752
730
|
logger: Logger
|
|
753
731
|
): Promise<BlockReceiptInfo[]> {
|
|
@@ -774,7 +752,7 @@ async function getBlockReceipts(
|
|
|
774
752
|
if (!isTransactionReceipt(receipt))
|
|
775
753
|
throw new Error(`Malformed eth_getBlockReceipts response at index ${index}`)
|
|
776
754
|
|
|
777
|
-
const raw = receipt
|
|
755
|
+
const raw = recordOf(receipt)
|
|
778
756
|
const contractAddressRaw = raw.contractAddress
|
|
779
757
|
const contractAddress =
|
|
780
758
|
typeof contractAddressRaw === 'string' && contractAddressRaw.startsWith('0x')
|
|
@@ -782,15 +760,16 @@ async function getBlockReceipts(
|
|
|
782
760
|
: undefined
|
|
783
761
|
|
|
784
762
|
const l1Fee = parseReceiptL1Fee(raw)
|
|
763
|
+
const envelopeType = receiptEnvelopeType(receipt.type)
|
|
785
764
|
|
|
786
765
|
return {
|
|
787
766
|
hash: receipt.transactionHash,
|
|
788
|
-
gasUsed:
|
|
789
|
-
gasPrice:
|
|
790
|
-
status:
|
|
767
|
+
gasUsed: quantityToDecimal(receipt.gasUsed),
|
|
768
|
+
gasPrice: receiptGasPrice(receipt),
|
|
769
|
+
status: receiptStatus(receipt.status),
|
|
791
770
|
erc20Transfers: parseERC20TransfersFromLogs(receipt.logs, logger),
|
|
792
771
|
...(contractAddress ? { contractAddress } : {}),
|
|
793
|
-
...(
|
|
772
|
+
...(envelopeType !== undefined ? { type: envelopeType } : {}),
|
|
794
773
|
...(l1Fee !== undefined ? { l1Fee } : {}),
|
|
795
774
|
}
|
|
796
775
|
})
|
|
@@ -798,7 +777,6 @@ async function getBlockReceipts(
|
|
|
798
777
|
|
|
799
778
|
async function traceBlockGeth(
|
|
800
779
|
api: JsonRpcProvider,
|
|
801
|
-
_currencyId: string,
|
|
802
780
|
blockHeight: number
|
|
803
781
|
): Promise<TraceBlockItem[]> {
|
|
804
782
|
const rpcBlockTag = ethers.toQuantity(blockHeight) // convert to hex string
|
|
@@ -826,7 +804,6 @@ async function traceBlockGeth(
|
|
|
826
804
|
|
|
827
805
|
async function traceBlockErigon(
|
|
828
806
|
api: JsonRpcProvider,
|
|
829
|
-
_currencyId: string,
|
|
830
807
|
blockHeight: number | 'latest'
|
|
831
808
|
): Promise<TraceBlockItem[]> {
|
|
832
809
|
const blockTag = blockHeight === 'latest' ? 'latest' : ethers.toQuantity(blockHeight)
|
|
@@ -853,30 +830,31 @@ function normalizeTraceBlockItems(traces: TraceBlockItem[]): TraceBlockItem[] {
|
|
|
853
830
|
})
|
|
854
831
|
}
|
|
855
832
|
|
|
856
|
-
|
|
833
|
+
type EthersPrefetchedTransaction = {
|
|
834
|
+
hash: string
|
|
835
|
+
value: string | bigint
|
|
836
|
+
from: string
|
|
837
|
+
to?: string | null
|
|
838
|
+
data?: string | null
|
|
839
|
+
gasPrice?: bigint | string | null
|
|
840
|
+
maxFeePerGas?: bigint | string | null
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
function recordOf(value: object): Record<string, unknown> {
|
|
844
|
+
if (isRecord(value)) return value
|
|
845
|
+
throw new Error('expected object')
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function isPrefetchedBlockTransaction(value: unknown): value is EthersPrefetchedTransaction {
|
|
849
|
+
if (!isRecord(value)) return false
|
|
850
|
+
if (!isString(value.hash) || !isString(value.from) || !isQuantity(value.value)) return false
|
|
851
|
+
// gasPrice is intentionally not required: EIP-1559 (type-2) transactions have gasPrice: null
|
|
852
|
+
// in ethers v6, and the mapping falls back to maxFeePerGas ?? 0n
|
|
857
853
|
return (
|
|
858
|
-
|
|
859
|
-
value
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
'from' in value &&
|
|
863
|
-
// gasPrice is intentionally not required: EIP-1559 (type-2) transactions have gasPrice: null
|
|
864
|
-
// in ethers v6, and the mapping falls back to maxFeePerGas ?? 0n
|
|
865
|
-
('gasPrice' in value
|
|
866
|
-
? value.gasPrice === null ||
|
|
867
|
-
typeof value.gasPrice === 'bigint' ||
|
|
868
|
-
typeof value.gasPrice === 'string'
|
|
869
|
-
: true) &&
|
|
870
|
-
('to' in value
|
|
871
|
-
? typeof value.to === 'string' || value.to === null || value.to === undefined
|
|
872
|
-
: true) &&
|
|
873
|
-
typeof value.hash === 'string' &&
|
|
874
|
-
(typeof value.value === 'string' || typeof value.value === 'bigint') &&
|
|
875
|
-
typeof value.from === 'string' &&
|
|
876
|
-
(!('data' in value) ||
|
|
877
|
-
value.data === undefined ||
|
|
878
|
-
value.data === null ||
|
|
879
|
-
typeof value.data === 'string')
|
|
854
|
+
isOptionalString(value.to) &&
|
|
855
|
+
isOptionalQuantity(value.gasPrice) &&
|
|
856
|
+
isOptionalQuantity(value.maxFeePerGas) &&
|
|
857
|
+
isOptionalString(value.data)
|
|
880
858
|
)
|
|
881
859
|
}
|
|
882
860
|
|
|
@@ -892,30 +870,38 @@ function getPrefetchedBlockTransactions(block: ethers.Block): unknown[] | undefi
|
|
|
892
870
|
}
|
|
893
871
|
}
|
|
894
872
|
|
|
895
|
-
function
|
|
896
|
-
return (
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
873
|
+
function quantityToDecimal(value: string): string {
|
|
874
|
+
return BigInt(value).toString()
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
function receiptGasPrice(receipt: TransactionReceipt): string {
|
|
878
|
+
return quantityToDecimal(receipt.effectiveGasPrice ?? receipt.gasPrice ?? '0x0')
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function receiptStatus(status: TransactionReceipt['status']): number | null {
|
|
882
|
+
if (status === null) return null
|
|
883
|
+
return Number(status)
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
function receiptEnvelopeType(type: TransactionReceipt['type']): number | undefined {
|
|
887
|
+
if (type === null || type === undefined) return undefined
|
|
888
|
+
return Number(type)
|
|
907
889
|
}
|
|
908
890
|
|
|
909
891
|
async function getOptimismAdditionalFees(
|
|
910
892
|
api: JsonRpcProvider,
|
|
911
|
-
|
|
893
|
+
chainId: ChainId,
|
|
912
894
|
transaction: string
|
|
913
895
|
): Promise<BigNumber> {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
896
|
+
const optimismFeeChainIds: readonly ChainId[] = [
|
|
897
|
+
CHAIN_ID.OPTIMISM,
|
|
898
|
+
CHAIN_ID.OPTIMISM_SEPOLIA,
|
|
899
|
+
CHAIN_ID.BASE,
|
|
900
|
+
CHAIN_ID.BASE_SEPOLIA,
|
|
901
|
+
CHAIN_ID.BLAST,
|
|
902
|
+
CHAIN_ID.BLAST_SEPOLIA,
|
|
903
|
+
]
|
|
904
|
+
if (!optimismFeeChainIds.includes(chainId)) {
|
|
919
905
|
return new BigNumber(0)
|
|
920
906
|
}
|
|
921
907
|
|
|
@@ -936,10 +922,10 @@ async function getOptimismAdditionalFees(
|
|
|
936
922
|
|
|
937
923
|
async function getScrollAdditionalFees(
|
|
938
924
|
api: JsonRpcProvider,
|
|
939
|
-
|
|
925
|
+
chainId: ChainId,
|
|
940
926
|
transaction: string
|
|
941
927
|
): Promise<BigNumber> {
|
|
942
|
-
if (
|
|
928
|
+
if (chainId !== CHAIN_ID.SCROLL) {
|
|
943
929
|
return new BigNumber(0)
|
|
944
930
|
}
|
|
945
931
|
|
|
@@ -959,9 +945,9 @@ async function getScrollAdditionalFees(
|
|
|
959
945
|
}
|
|
960
946
|
|
|
961
947
|
/* Get default maxPriorityFeePerGas by chain */
|
|
962
|
-
const getMaxPriorityFeePerGas = (
|
|
963
|
-
switch (
|
|
964
|
-
case
|
|
948
|
+
const getMaxPriorityFeePerGas = (chainId: ChainId): BigNumber => {
|
|
949
|
+
switch (chainId) {
|
|
950
|
+
case CHAIN_ID.ZERO_GRAVITY:
|
|
965
951
|
return new BigNumber(2e9) // 2 Gwei
|
|
966
952
|
default:
|
|
967
953
|
return new BigNumber(1e9) // 1 Gwei
|
|
@@ -969,23 +955,20 @@ const getMaxPriorityFeePerGas = (currencyId: string): BigNumber => {
|
|
|
969
955
|
}
|
|
970
956
|
|
|
971
957
|
function cacheKeyOptimismL1Fees(
|
|
972
|
-
|
|
973
|
-
transaction: Parameters<NodeApi['getOptimismAdditionalFees']>[
|
|
958
|
+
chainId: ChainId,
|
|
959
|
+
transaction: Parameters<NodeApi['getOptimismAdditionalFees']>[0]
|
|
974
960
|
): string {
|
|
975
|
-
return 'getOptimismL1BaseFee_' +
|
|
961
|
+
return 'getOptimismL1BaseFee_' + chainId + '_' + transaction
|
|
976
962
|
}
|
|
977
963
|
|
|
978
|
-
function make<
|
|
979
|
-
f: (api: JsonRpcProvider, ...args:
|
|
964
|
+
function make<Args extends readonly unknown[], R>(
|
|
965
|
+
f: (api: JsonRpcProvider, ...args: Args) => Promise<R>,
|
|
980
966
|
evmConfig: EvmConfigInfo,
|
|
981
967
|
nodeConfig: ExternalNodeConfig,
|
|
982
968
|
configOverride: Partial<ExternalNodeConfig> = {}
|
|
983
|
-
):
|
|
969
|
+
): (...args: Args) => Promise<R> {
|
|
984
970
|
const mergedConfig = { ...nodeConfig, ...configOverride }
|
|
985
|
-
return (
|
|
986
|
-
const [currencyId] = args
|
|
987
|
-
return withApi(evmConfig, currencyId, (api) => f(api, ...args), mergedConfig)
|
|
988
|
-
}) as F
|
|
971
|
+
return (...args) => withApi(evmConfig, (api) => f(api, ...args), mergedConfig)
|
|
989
972
|
}
|
|
990
973
|
|
|
991
974
|
export function createNodeApi(
|
|
@@ -995,52 +978,45 @@ export function createNodeApi(
|
|
|
995
978
|
): NodeApi {
|
|
996
979
|
return {
|
|
997
980
|
call: make(call, evmConfig, nodeConfig),
|
|
998
|
-
getBlockByHeight: (
|
|
981
|
+
getBlockByHeight: (blockHeight, prefetchTxs) =>
|
|
999
982
|
withApi(
|
|
1000
983
|
evmConfig,
|
|
1001
|
-
|
|
1002
|
-
(api) => getBlockByHeight(api, currencyId, blockHeight, logger, prefetchTxs),
|
|
984
|
+
(api) => getBlockByHeight(api, blockHeight, logger, prefetchTxs),
|
|
1003
985
|
nodeConfig
|
|
1004
|
-
)
|
|
986
|
+
),
|
|
1005
987
|
getCoinBalance: make(getCoinBalance, evmConfig, nodeConfig),
|
|
1006
988
|
getTokenBalance: make(getTokenBalance, evmConfig, nodeConfig),
|
|
1007
989
|
getTokenAllowance: make(getTokenAllowance, evmConfig, nodeConfig),
|
|
1008
990
|
getTransactionCount: make(getTransactionCount, evmConfig, nodeConfig),
|
|
1009
|
-
getTransaction: (
|
|
1010
|
-
withApi(
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
(api) => getTransaction(api, currencyId, txHash, logger),
|
|
1014
|
-
nodeConfig
|
|
1015
|
-
)) as NodeApi['getTransaction'],
|
|
1016
|
-
getBlockReceipts: ((currencyId, blockHeight) =>
|
|
1017
|
-
withApi(
|
|
1018
|
-
evmConfig,
|
|
1019
|
-
currencyId,
|
|
1020
|
-
(api) => getBlockReceipts(api, currencyId, blockHeight, logger),
|
|
1021
|
-
nodeConfig
|
|
1022
|
-
)) as NonNullable<NodeApi['getBlockReceipts']>,
|
|
991
|
+
getTransaction: (txHash) =>
|
|
992
|
+
withApi(evmConfig, (api) => getTransaction(api, txHash, logger), nodeConfig),
|
|
993
|
+
getBlockReceipts: (blockHeight) =>
|
|
994
|
+
withApi(evmConfig, (api) => getBlockReceipts(api, blockHeight, logger), nodeConfig),
|
|
1023
995
|
traceBlockErigon: make(traceBlockErigon, evmConfig, nodeConfig),
|
|
1024
996
|
traceBlockGeth: make(traceBlockGeth, evmConfig, nodeConfig),
|
|
1025
997
|
getGasEstimation: makeGetGasEstimation(evmConfig, nodeConfig, logger),
|
|
1026
|
-
// getFeeData takes `config` first
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
evmConfig,
|
|
1035
|
-
currencyId,
|
|
1036
|
-
(api) => broadcastTransaction(api, currencyId, signedTxHex, logger),
|
|
1037
|
-
{ ...nodeConfig, retries: 0 }
|
|
1038
|
-
)) as NodeApi['broadcastTransaction'],
|
|
998
|
+
// getFeeData takes `config` first, so it can't use the `make` wrapper; bind it explicitly.
|
|
999
|
+
getFeeData: (config, transaction) =>
|
|
1000
|
+
withApi(evmConfig, (api) => getFeeData(api, config, transaction), nodeConfig),
|
|
1001
|
+
broadcastTransaction: (signedTxHex) =>
|
|
1002
|
+
withApi(evmConfig, (api) => broadcastTransaction(api, signedTxHex, logger), {
|
|
1003
|
+
...nodeConfig,
|
|
1004
|
+
retries: 0,
|
|
1005
|
+
}),
|
|
1039
1006
|
getOptimismAdditionalFees: makeLRUCache(
|
|
1040
|
-
make(
|
|
1041
|
-
|
|
1007
|
+
make(
|
|
1008
|
+
(api, transaction: string) =>
|
|
1009
|
+
getOptimismAdditionalFees(api, evmConfig.chainId, transaction),
|
|
1010
|
+
evmConfig,
|
|
1011
|
+
nodeConfig
|
|
1012
|
+
),
|
|
1013
|
+
(transaction) => cacheKeyOptimismL1Fees(evmConfig.chainId, transaction),
|
|
1042
1014
|
{ ttl: 15 * 1000 } // prevent rate limit by caching for at least 15s
|
|
1043
1015
|
),
|
|
1044
|
-
getScrollAdditionalFees: make(
|
|
1016
|
+
getScrollAdditionalFees: make(
|
|
1017
|
+
(api, transaction: string) => getScrollAdditionalFees(api, evmConfig.chainId, transaction),
|
|
1018
|
+
evmConfig,
|
|
1019
|
+
nodeConfig
|
|
1020
|
+
),
|
|
1045
1021
|
}
|
|
1046
1022
|
}
|