@ledgerhq/coin-evm 10.1.0 → 15.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/docs/getBlock-internal-txs-schema.md +2 -2
- package/docs/network/node/index.md +1 -1
- package/lib/adapters/etherscan.d.ts +2 -1
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +16 -2
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts +2 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +4 -2
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -2
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +95 -0
- package/lib/chains.d.ts.map +1 -0
- package/lib/chains.js +99 -0
- package/lib/chains.js.map +1 -0
- package/lib/config.d.ts +4 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -1
- package/lib/config.js.map +1 -1
- package/lib/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/common.d.ts +1 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +11 -11
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +3 -3
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +7 -7
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +9 -9
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +38 -21
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -2
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +1 -1
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +10 -10
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js +8 -8
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +3 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +9 -9
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +14 -13
- package/lib/logic.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +2 -3
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +6 -8
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +5 -5
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/types.d.ts +2 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +14 -12
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/index.d.ts +1 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +7 -7
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.d.ts +3 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +32 -22
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +67 -39
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +18 -16
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/network/node/withNodeSources.d.ts.map +1 -1
- package/lib/network/node/withNodeSources.js +15 -15
- package/lib/network/node/withNodeSources.js.map +1 -1
- package/lib/staking/abis.d.ts +3 -2
- package/lib/staking/abis.d.ts.map +1 -1
- package/lib/staking/abis.js +10 -9
- package/lib/staking/abis.js.map +1 -1
- package/lib/staking/contracts.d.ts +3 -2
- package/lib/staking/contracts.d.ts.map +1 -1
- package/lib/staking/contracts.js +11 -10
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/detectOperationType.d.ts +2 -1
- package/lib/staking/detectOperationType.d.ts.map +1 -1
- package/lib/staking/detectOperationType.js +7 -7
- package/lib/staking/detectOperationType.js.map +1 -1
- package/lib/staking/encoder.d.ts +2 -1
- package/lib/staking/encoder.d.ts.map +1 -1
- package/lib/staking/encoder.js +8 -8
- package/lib/staking/encoder.js.map +1 -1
- package/lib/staking/fetchers.d.ts +2 -1
- package/lib/staking/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +27 -27
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/logic.d.ts +6 -6
- package/lib/staking/logic.d.ts.map +1 -1
- package/lib/staking/logic.js +14 -13
- package/lib/staking/logic.js.map +1 -1
- package/lib/staking/operations/index.d.ts +2 -1
- package/lib/staking/operations/index.d.ts.map +1 -1
- package/lib/staking/operations/index.js +30 -28
- package/lib/staking/operations/index.js.map +1 -1
- package/lib/staking/prepareIntents.d.ts +1 -1
- package/lib/staking/prepareIntents.d.ts.map +1 -1
- package/lib/staking/prepareIntents.js +11 -10
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/redelegations.d.ts +4 -4
- package/lib/staking/redelegations.d.ts.map +1 -1
- package/lib/staking/redelegations.js +18 -20
- package/lib/staking/redelegations.js.map +1 -1
- package/lib/staking/rewards.d.ts +1 -1
- package/lib/staking/rewards.d.ts.map +1 -1
- package/lib/staking/rewards.js +2 -2
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib/staking/rewardsFromReceipt.js +2 -2
- package/lib/staking/rewardsFromReceipt.js.map +1 -1
- package/lib/staking/transactionData.d.ts +2 -1
- package/lib/staking/transactionData.d.ts.map +1 -1
- package/lib/staking/transactionData.js +6 -6
- package/lib/staking/transactionData.js.map +1 -1
- package/lib/staking/unbondings.d.ts +1 -1
- package/lib/staking/unbondings.d.ts.map +1 -1
- package/lib/staking/unbondings.js +2 -2
- package/lib/staking/unbondings.js.map +1 -1
- package/lib/staking/validators/index.d.ts +14 -14
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +39 -38
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +5 -5
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +31 -33
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +1 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js +4 -4
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/sei.js +2 -2
- package/lib/staking/validators/sei.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts +4 -4
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js +22 -22
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/types.d.ts +1 -1
- package/lib/staking/validators/types.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts +1 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js +7 -7
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/staking.d.ts +5 -6
- package/lib/types/staking.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.d.ts +2 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +16 -2
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts +2 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +4 -2
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +1 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +95 -0
- package/lib-es/chains.d.ts.map +1 -0
- package/lib-es/chains.js +96 -0
- package/lib-es/chains.js.map +1 -0
- package/lib-es/config.d.ts +4 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -0
- package/lib-es/config.js.map +1 -1
- package/lib-es/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/common.d.ts +1 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +11 -11
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +3 -3
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +7 -7
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +9 -9
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +39 -22
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.js +2 -2
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +1 -1
- package/lib-es/logic/getNextSequence.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +10 -10
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js +8 -8
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +3 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +9 -9
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +14 -13
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +2 -3
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +6 -8
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +5 -5
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +2 -2
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +14 -12
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/index.d.ts +1 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +7 -7
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts +3 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +32 -22
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +67 -39
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +18 -16
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
- package/lib-es/network/node/withNodeSources.js +15 -15
- package/lib-es/network/node/withNodeSources.js.map +1 -1
- package/lib-es/staking/abis.d.ts +3 -2
- package/lib-es/staking/abis.d.ts.map +1 -1
- package/lib-es/staking/abis.js +10 -9
- package/lib-es/staking/abis.js.map +1 -1
- package/lib-es/staking/contracts.d.ts +3 -2
- package/lib-es/staking/contracts.d.ts.map +1 -1
- package/lib-es/staking/contracts.js +11 -10
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/detectOperationType.d.ts +2 -1
- package/lib-es/staking/detectOperationType.d.ts.map +1 -1
- package/lib-es/staking/detectOperationType.js +7 -7
- package/lib-es/staking/detectOperationType.js.map +1 -1
- package/lib-es/staking/encoder.d.ts +2 -1
- package/lib-es/staking/encoder.d.ts.map +1 -1
- package/lib-es/staking/encoder.js +8 -8
- package/lib-es/staking/encoder.js.map +1 -1
- package/lib-es/staking/fetchers.d.ts +2 -1
- package/lib-es/staking/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +27 -27
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/logic.d.ts +6 -6
- package/lib-es/staking/logic.d.ts.map +1 -1
- package/lib-es/staking/logic.js +14 -13
- package/lib-es/staking/logic.js.map +1 -1
- package/lib-es/staking/operations/index.d.ts +2 -1
- package/lib-es/staking/operations/index.d.ts.map +1 -1
- package/lib-es/staking/operations/index.js +30 -28
- package/lib-es/staking/operations/index.js.map +1 -1
- package/lib-es/staking/prepareIntents.d.ts +1 -1
- package/lib-es/staking/prepareIntents.d.ts.map +1 -1
- package/lib-es/staking/prepareIntents.js +11 -10
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/redelegations.d.ts +4 -4
- package/lib-es/staking/redelegations.d.ts.map +1 -1
- package/lib-es/staking/redelegations.js +18 -20
- package/lib-es/staking/redelegations.js.map +1 -1
- package/lib-es/staking/rewards.d.ts +1 -1
- package/lib-es/staking/rewards.d.ts.map +1 -1
- package/lib-es/staking/rewards.js +2 -2
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.js +2 -2
- package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
- package/lib-es/staking/transactionData.d.ts +2 -1
- package/lib-es/staking/transactionData.d.ts.map +1 -1
- package/lib-es/staking/transactionData.js +6 -6
- package/lib-es/staking/transactionData.js.map +1 -1
- package/lib-es/staking/unbondings.d.ts +1 -1
- package/lib-es/staking/unbondings.d.ts.map +1 -1
- package/lib-es/staking/unbondings.js +2 -2
- package/lib-es/staking/unbondings.js.map +1 -1
- package/lib-es/staking/validators/index.d.ts +14 -14
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +39 -38
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +5 -5
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +31 -33
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +4 -4
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/sei.js +2 -2
- package/lib-es/staking/validators/sei.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts +4 -4
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js +22 -22
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/types.d.ts +1 -1
- package/lib-es/staking/validators/types.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js +7 -7
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/staking.d.ts +5 -6
- package/lib-es/types/staking.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/etherscan.test.ts +91 -43
- package/src/adapters/etherscan.ts +18 -2
- package/src/adapters/ledger.test.ts +106 -31
- package/src/adapters/ledger.ts +5 -2
- package/src/api/index.ts +1 -2
- package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +5 -4
- package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +3 -3
- package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +3 -3
- package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +3 -3
- package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +3 -3
- package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +3 -3
- package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +3 -3
- package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +3 -3
- package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +6 -6
- package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +3 -3
- package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +3 -3
- package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +3 -3
- package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +3 -3
- package/src/api/{index.test.ts → tests/index.test.ts} +4 -4
- package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +2 -2
- package/src/chains.test.ts +12 -0
- package/src/chains.ts +98 -0
- package/src/config.ts +5 -1
- package/src/fixtures/staking.fixtures.ts +13 -0
- package/src/logic/broadcast.ts +2 -2
- package/src/logic/common.ts +10 -11
- package/src/logic/craftTransaction.ts +2 -3
- package/src/logic/estimateFees.ts +6 -23
- package/src/logic/getBalance.ts +7 -13
- package/src/logic/getBlock.ts +59 -23
- package/src/logic/getBlockInfo.ts +2 -2
- package/src/logic/getNextSequence.ts +1 -4
- package/src/logic/getStakes.ts +11 -12
- package/src/logic/internalTransactionsFetcher.ts +6 -8
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +2 -1
- package/src/logic/tests/broadcast.test.ts +5 -5
- package/src/logic/tests/broadcastSource.test.ts +1 -4
- package/src/logic/tests/common.test.ts +18 -34
- package/src/logic/tests/craftTransaction.test.ts +14 -7
- package/src/logic/tests/estimateFees.test.ts +17 -8
- package/src/logic/tests/getBalance.test.ts +18 -34
- package/src/logic/tests/getBlock.test.ts +195 -80
- package/src/logic/tests/getBlockInfo.test.ts +2 -2
- package/src/logic/tests/getNextSequence.test.ts +2 -2
- package/src/logic/tests/getStakes.test.ts +28 -16
- package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -6
- package/src/logic/tests/lastBlock.test.ts +4 -7
- package/src/logic/tests/listOperations.test.ts +8 -7
- package/src/logic/tests/validateIntent.test.ts +49 -3
- package/src/logic/validateIntent.ts +8 -10
- package/src/logic.test.ts +13 -5
- package/src/logic.ts +13 -13
- package/src/network/explorer/etherscan.ts +8 -24
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +0 -2
- package/src/network/node/explorerProxy.ts +14 -12
- package/src/network/node/index.ts +11 -8
- package/src/network/node/ledger.ts +32 -34
- package/src/network/node/rpc.common.ts +79 -86
- package/src/network/node/types.ts +16 -31
- package/src/network/node/withNodeSources.ts +23 -26
- package/src/network/{explorer → tests/explorer}/etherscan.test.ts +16 -65
- package/src/network/{explorer → tests/explorer}/index.test.ts +8 -8
- package/src/network/{explorer → tests/explorer}/ledger.test.ts +34 -142
- package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
- package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
- package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
- package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/explorerProxy.test.ts +22 -24
- package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
- package/src/network/tests/node/index.memoization.test.ts +70 -0
- package/src/network/{node → tests/node}/index.test.ts +4 -6
- package/src/network/{node → tests/node}/ledger.test.ts +69 -74
- package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
- package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
- package/src/network/{node → tests/node}/rpc.test.ts +100 -119
- package/src/network/{node → tests/node}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/withNodeSources.test.ts +10 -12
- package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
- package/src/staking/abis.test.ts +24 -28
- package/src/staking/abis.ts +12 -10
- package/src/staking/contracts.test.ts +20 -8
- package/src/staking/contracts.ts +12 -11
- package/src/staking/detectOperationType.test.ts +16 -13
- package/src/staking/detectOperationType.ts +9 -8
- package/src/staking/encoder.test.ts +38 -27
- package/src/staking/encoder.ts +9 -8
- package/src/staking/fetchers.ts +28 -39
- package/src/staking/logic.test.ts +34 -32
- package/src/staking/logic.ts +14 -14
- package/src/staking/operations/index.test.ts +48 -39
- package/src/staking/operations/index.ts +31 -28
- package/src/staking/prepareIntents.test.ts +14 -34
- package/src/staking/prepareIntents.ts +10 -13
- package/src/staking/redelegations.test.ts +73 -131
- package/src/staking/redelegations.ts +12 -26
- package/src/staking/rewards.test.ts +19 -21
- package/src/staking/rewards.ts +1 -2
- package/src/staking/rewardsFromReceipt.test.ts +9 -8
- package/src/staking/rewardsFromReceipt.ts +3 -2
- package/src/staking/transactionData.test.ts +35 -25
- package/src/staking/transactionData.ts +7 -6
- package/src/staking/unbondings.test.ts +26 -20
- package/src/staking/unbondings.ts +1 -2
- package/src/staking/validators/index.ts +45 -51
- package/src/staking/validators/monad.test.ts +52 -54
- package/src/staking/validators/monad.ts +31 -37
- package/src/staking/validators/monadResolver.ts +2 -4
- package/src/staking/validators/sei.ts +2 -2
- package/src/staking/validators/somnia.test.ts +22 -19
- package/src/staking/validators/somnia.ts +20 -27
- package/src/staking/validators/types.ts +0 -1
- package/src/staking/validators/zero_gravity.test.ts +34 -49
- package/src/staking/validators/zero_gravity.ts +5 -11
- package/src/staking/validators.integ.test.ts +3 -5
- package/src/staking/validators.test.ts +56 -53
- package/src/types/staking.ts +3 -6
- package/src/network/node/index.memoization.test.ts +0 -63
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { 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,
|
|
@@ -22,6 +22,7 @@ import { ethers, FetchRequest, JsonRpcProvider } from 'ethers'
|
|
|
22
22
|
import ERC20Abi from '../../abis/erc20.abi.json'
|
|
23
23
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
24
24
|
import ScrollGasPriceOracleAbi from '../../abis/scrollGasPriceOracle.abi.json'
|
|
25
|
+
import { CHAIN_ID } from '../../config'
|
|
25
26
|
import { GasEstimationError, InsufficientFunds, UnsupportedRpcMethodError } from '../../errors'
|
|
26
27
|
import { isSmartContractInput, safeEncodeEIP55, normalizeAddress } from '../../logic-public'
|
|
27
28
|
import {
|
|
@@ -197,12 +198,12 @@ export const DEFAULT_RETRIES_RPC_METHODS =
|
|
|
197
198
|
* Without this, ethers will create a new provider and use the `eth_chainId` RPC call
|
|
198
199
|
* at instanciation which could result in rate limits being reached
|
|
199
200
|
* on some specific nodes (E.g. the main Optimism RPC)
|
|
200
|
-
* Keyed by
|
|
201
|
+
* Keyed by chain id + RPC URI so the same chain with different uri gets distinct providers.
|
|
201
202
|
*/
|
|
202
203
|
const PROVIDERS_BY_RPC: Record<string, JsonRpcProvider> = {}
|
|
203
204
|
|
|
204
|
-
function providerCacheKey(
|
|
205
|
-
return `${
|
|
205
|
+
function providerCacheKey(chainId: ChainId, uri: string): string {
|
|
206
|
+
return `${chainId}:${uri}`
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
/**
|
|
@@ -230,16 +231,15 @@ export function destroyAllRpcProviders(): void {
|
|
|
230
231
|
*/
|
|
231
232
|
export async function withApi<T>(
|
|
232
233
|
config: EvmConfigInfo,
|
|
233
|
-
currencyId: string,
|
|
234
234
|
execute: (api: JsonRpcProvider) => Promise<T>,
|
|
235
235
|
nodeConfig: ExternalNodeConfig
|
|
236
236
|
): Promise<T> {
|
|
237
237
|
const retries = nodeConfig.retries ?? DEFAULT_RETRIES_RPC_METHODS
|
|
238
238
|
return withRetries(
|
|
239
239
|
async () => {
|
|
240
|
-
const
|
|
240
|
+
const chainId = config.chainId
|
|
241
|
+
const key = providerCacheKey(chainId, nodeConfig.uri)
|
|
241
242
|
if (!PROVIDERS_BY_RPC[key]) {
|
|
242
|
-
const chainId = config.chainId
|
|
243
243
|
const fetchReq = new FetchRequest(nodeConfig.uri)
|
|
244
244
|
// Disable ethers' built-in HTTP-level retries: withRetries handles all retry logic.
|
|
245
245
|
fetchReq.setThrottleParams({ maxAttempts: 1 })
|
|
@@ -268,7 +268,6 @@ function parseReceiptL1Fee(raw: Record<string, unknown>): string | undefined {
|
|
|
268
268
|
|
|
269
269
|
async function getTransaction(
|
|
270
270
|
api: JsonRpcProvider,
|
|
271
|
-
_currencyId: string,
|
|
272
271
|
txHash: string,
|
|
273
272
|
logger: Logger
|
|
274
273
|
): Promise<TransactionInfo> {
|
|
@@ -302,6 +301,7 @@ async function getTransaction(
|
|
|
302
301
|
nonce: tx.nonce,
|
|
303
302
|
gasUsed: quantityToDecimal(receipt.gasUsed),
|
|
304
303
|
gasPrice: receiptGasPrice(receipt),
|
|
304
|
+
gasLimit: tx.gasLimit.toString(),
|
|
305
305
|
status: receiptStatus(receipt.status),
|
|
306
306
|
value: tx.value.toString(),
|
|
307
307
|
from: tx.from,
|
|
@@ -316,20 +316,12 @@ async function getTransaction(
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
async function getCoinBalance(
|
|
320
|
-
api: JsonRpcProvider,
|
|
321
|
-
_currencyId: string,
|
|
322
|
-
address: string
|
|
323
|
-
): Promise<BigNumber> {
|
|
319
|
+
async function getCoinBalance(api: JsonRpcProvider, address: string): Promise<BigNumber> {
|
|
324
320
|
const balance = await api.getBalance(normalizeAddress(address))
|
|
325
321
|
return new BigNumber(balance.toString())
|
|
326
322
|
}
|
|
327
323
|
|
|
328
|
-
async function call(
|
|
329
|
-
api: JsonRpcProvider,
|
|
330
|
-
_currencyId: string,
|
|
331
|
-
params: EvmCallParams
|
|
332
|
-
): Promise<string> {
|
|
324
|
+
async function call(api: JsonRpcProvider, params: EvmCallParams): Promise<string> {
|
|
333
325
|
const block = typeof params.block === 'number' ? ethers.toQuantity(params.block) : params.block
|
|
334
326
|
return api.send('eth_call', [
|
|
335
327
|
{
|
|
@@ -342,7 +334,6 @@ async function call(
|
|
|
342
334
|
|
|
343
335
|
async function getTokenBalance(
|
|
344
336
|
api: JsonRpcProvider,
|
|
345
|
-
_currencyId: string,
|
|
346
337
|
address: string,
|
|
347
338
|
contractAddress: string
|
|
348
339
|
): Promise<BigNumber> {
|
|
@@ -353,7 +344,6 @@ async function getTokenBalance(
|
|
|
353
344
|
|
|
354
345
|
async function getTokenAllowance(
|
|
355
346
|
api: JsonRpcProvider,
|
|
356
|
-
_currencyId: string,
|
|
357
347
|
ownerAddress: string,
|
|
358
348
|
contractAddress: string,
|
|
359
349
|
spenderAddress: string
|
|
@@ -366,11 +356,7 @@ async function getTokenAllowance(
|
|
|
366
356
|
return new BigNumber(allowance.toString())
|
|
367
357
|
}
|
|
368
358
|
|
|
369
|
-
async function getTransactionCount(
|
|
370
|
-
api: JsonRpcProvider,
|
|
371
|
-
_currencyId: string,
|
|
372
|
-
address: string
|
|
373
|
-
): Promise<number> {
|
|
359
|
+
async function getTransactionCount(api: JsonRpcProvider, address: string): Promise<number> {
|
|
374
360
|
return api.getTransactionCount(normalizeAddress(address), 'pending')
|
|
375
361
|
}
|
|
376
362
|
|
|
@@ -403,8 +389,8 @@ function makeGetGasEstimation(
|
|
|
403
389
|
nodeConfig: ExternalNodeConfig,
|
|
404
390
|
logger: Logger
|
|
405
391
|
): NodeApi['getGasEstimation'] {
|
|
406
|
-
return (
|
|
407
|
-
withApi(evmConfig,
|
|
392
|
+
return (address, transaction) =>
|
|
393
|
+
withApi(evmConfig, (api) => getGasEstimation(api, address, transaction, logger), {
|
|
408
394
|
...nodeConfig,
|
|
409
395
|
retries: 0,
|
|
410
396
|
})
|
|
@@ -413,7 +399,6 @@ function makeGetGasEstimation(
|
|
|
413
399
|
async function getFeeData(
|
|
414
400
|
api: JsonRpcProvider,
|
|
415
401
|
config: EvmConfigInfo,
|
|
416
|
-
currencyId: string,
|
|
417
402
|
transaction: { type?: number | undefined; feesStrategy?: string | null | undefined }
|
|
418
403
|
): Promise<FeeData> {
|
|
419
404
|
const block = await api.getBlock('latest')
|
|
@@ -486,7 +471,7 @@ async function getFeeData(
|
|
|
486
471
|
// As a safety measure, if maxPriorityFeePerGas is zero
|
|
487
472
|
// we enforce a 1 Gwei value
|
|
488
473
|
let maxPriorityFeePerGas = maxPriorityFeeAverage.isZero()
|
|
489
|
-
? getMaxPriorityFeePerGas(
|
|
474
|
+
? getMaxPriorityFeePerGas(config.chainId)
|
|
490
475
|
: maxPriorityFeeAverage
|
|
491
476
|
|
|
492
477
|
// Apply the per-chain config floor on top, for networks (typically sparse testnets)
|
|
@@ -525,7 +510,6 @@ async function getFeeData(
|
|
|
525
510
|
|
|
526
511
|
async function broadcastTransaction(
|
|
527
512
|
api: JsonRpcProvider,
|
|
528
|
-
_currencyId: string,
|
|
529
513
|
signedTxHex: string,
|
|
530
514
|
logger: Logger
|
|
531
515
|
): Promise<string> {
|
|
@@ -557,7 +541,6 @@ function assertNotStubBlock(
|
|
|
557
541
|
|
|
558
542
|
async function getBlockByHeight(
|
|
559
543
|
api: JsonRpcProvider,
|
|
560
|
-
_currencyId: string,
|
|
561
544
|
blockHeight: number | BlockFinalizationTag,
|
|
562
545
|
logger: Logger,
|
|
563
546
|
prefetchTxs?: boolean
|
|
@@ -615,6 +598,10 @@ async function getBlockByHeight(
|
|
|
615
598
|
...(typeof data === 'string' && isSmartContractInput(data) ? { input: data } : {}),
|
|
616
599
|
// EIP-1559 transactions have gasPrice: null; fall back to maxFeePerGas then 0
|
|
617
600
|
gasPrice: (tx.gasPrice ?? tx.maxFeePerGas ?? 0n).toString(),
|
|
601
|
+
...(tx.gasLimit !== null && tx.gasLimit !== undefined
|
|
602
|
+
? { gasLimit: BigInt(tx.gasLimit).toString() }
|
|
603
|
+
: {}),
|
|
604
|
+
...(typeof tx.nonce === 'number' ? { nonce: tx.nonce } : {}),
|
|
618
605
|
}
|
|
619
606
|
})
|
|
620
607
|
|
|
@@ -709,6 +696,12 @@ async function getBlockByHeightFromRawRpc(
|
|
|
709
696
|
throw new Error(
|
|
710
697
|
'Malformed prefetched transaction gasPrice in eth_getBlockByNumber response'
|
|
711
698
|
)
|
|
699
|
+
if ('gas' in tx && tx.gas !== undefined && typeof tx.gas !== 'string')
|
|
700
|
+
throw new Error('Malformed prefetched transaction gas in eth_getBlockByNumber response')
|
|
701
|
+
if ('nonce' in tx && tx.nonce !== undefined && typeof tx.nonce !== 'string')
|
|
702
|
+
throw new Error(
|
|
703
|
+
'Malformed prefetched transaction nonce in eth_getBlockByNumber response'
|
|
704
|
+
)
|
|
712
705
|
if (
|
|
713
706
|
'input' in tx &&
|
|
714
707
|
tx.input !== undefined &&
|
|
@@ -728,6 +721,12 @@ async function getBlockByHeightFromRawRpc(
|
|
|
728
721
|
? { input: tx.input }
|
|
729
722
|
: {}),
|
|
730
723
|
gasPrice: BigInt(tx.gasPrice ?? '0x0').toString(),
|
|
724
|
+
...('gas' in tx && typeof tx.gas === 'string'
|
|
725
|
+
? { gasLimit: BigInt(tx.gas).toString() }
|
|
726
|
+
: {}),
|
|
727
|
+
...('nonce' in tx && typeof tx.nonce === 'string'
|
|
728
|
+
? { nonce: Number(BigInt(tx.nonce)) }
|
|
729
|
+
: {}),
|
|
731
730
|
}
|
|
732
731
|
})
|
|
733
732
|
: undefined
|
|
@@ -744,7 +743,6 @@ async function getBlockByHeightFromRawRpc(
|
|
|
744
743
|
|
|
745
744
|
async function getBlockReceipts(
|
|
746
745
|
api: JsonRpcProvider,
|
|
747
|
-
_currencyId: string,
|
|
748
746
|
blockHeight: number | 'latest',
|
|
749
747
|
logger: Logger
|
|
750
748
|
): Promise<BlockReceiptInfo[]> {
|
|
@@ -796,7 +794,6 @@ async function getBlockReceipts(
|
|
|
796
794
|
|
|
797
795
|
async function traceBlockGeth(
|
|
798
796
|
api: JsonRpcProvider,
|
|
799
|
-
_currencyId: string,
|
|
800
797
|
blockHeight: number
|
|
801
798
|
): Promise<TraceBlockItem[]> {
|
|
802
799
|
const rpcBlockTag = ethers.toQuantity(blockHeight) // convert to hex string
|
|
@@ -824,7 +821,6 @@ async function traceBlockGeth(
|
|
|
824
821
|
|
|
825
822
|
async function traceBlockErigon(
|
|
826
823
|
api: JsonRpcProvider,
|
|
827
|
-
_currencyId: string,
|
|
828
824
|
blockHeight: number | 'latest'
|
|
829
825
|
): Promise<TraceBlockItem[]> {
|
|
830
826
|
const blockTag = blockHeight === 'latest' ? 'latest' : ethers.toQuantity(blockHeight)
|
|
@@ -859,6 +855,8 @@ type EthersPrefetchedTransaction = {
|
|
|
859
855
|
data?: string | null
|
|
860
856
|
gasPrice?: bigint | string | null
|
|
861
857
|
maxFeePerGas?: bigint | string | null
|
|
858
|
+
gasLimit?: bigint | string | null
|
|
859
|
+
nonce?: number | null
|
|
862
860
|
}
|
|
863
861
|
|
|
864
862
|
function recordOf(value: object): Record<string, unknown> {
|
|
@@ -875,6 +873,8 @@ function isPrefetchedBlockTransaction(value: unknown): value is EthersPrefetched
|
|
|
875
873
|
isOptionalString(value.to) &&
|
|
876
874
|
isOptionalQuantity(value.gasPrice) &&
|
|
877
875
|
isOptionalQuantity(value.maxFeePerGas) &&
|
|
876
|
+
isOptionalQuantity(value.gasLimit) &&
|
|
877
|
+
(value.nonce === undefined || value.nonce === null || typeof value.nonce === 'number') &&
|
|
878
878
|
isOptionalString(value.data)
|
|
879
879
|
)
|
|
880
880
|
}
|
|
@@ -911,14 +911,18 @@ function receiptEnvelopeType(type: TransactionReceipt['type']): number | undefin
|
|
|
911
911
|
|
|
912
912
|
async function getOptimismAdditionalFees(
|
|
913
913
|
api: JsonRpcProvider,
|
|
914
|
-
|
|
914
|
+
chainId: ChainId,
|
|
915
915
|
transaction: string
|
|
916
916
|
): Promise<BigNumber> {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
917
|
+
const optimismFeeChainIds: readonly ChainId[] = [
|
|
918
|
+
CHAIN_ID.OPTIMISM,
|
|
919
|
+
CHAIN_ID.OPTIMISM_SEPOLIA,
|
|
920
|
+
CHAIN_ID.BASE,
|
|
921
|
+
CHAIN_ID.BASE_SEPOLIA,
|
|
922
|
+
CHAIN_ID.BLAST,
|
|
923
|
+
CHAIN_ID.BLAST_SEPOLIA,
|
|
924
|
+
]
|
|
925
|
+
if (!optimismFeeChainIds.includes(chainId)) {
|
|
922
926
|
return new BigNumber(0)
|
|
923
927
|
}
|
|
924
928
|
|
|
@@ -939,10 +943,10 @@ async function getOptimismAdditionalFees(
|
|
|
939
943
|
|
|
940
944
|
async function getScrollAdditionalFees(
|
|
941
945
|
api: JsonRpcProvider,
|
|
942
|
-
|
|
946
|
+
chainId: ChainId,
|
|
943
947
|
transaction: string
|
|
944
948
|
): Promise<BigNumber> {
|
|
945
|
-
if (
|
|
949
|
+
if (chainId !== CHAIN_ID.SCROLL) {
|
|
946
950
|
return new BigNumber(0)
|
|
947
951
|
}
|
|
948
952
|
|
|
@@ -962,9 +966,9 @@ async function getScrollAdditionalFees(
|
|
|
962
966
|
}
|
|
963
967
|
|
|
964
968
|
/* Get default maxPriorityFeePerGas by chain */
|
|
965
|
-
const getMaxPriorityFeePerGas = (
|
|
966
|
-
switch (
|
|
967
|
-
case
|
|
969
|
+
const getMaxPriorityFeePerGas = (chainId: ChainId): BigNumber => {
|
|
970
|
+
switch (chainId) {
|
|
971
|
+
case CHAIN_ID.ZERO_GRAVITY:
|
|
968
972
|
return new BigNumber(2e9) // 2 Gwei
|
|
969
973
|
default:
|
|
970
974
|
return new BigNumber(1e9) // 1 Gwei
|
|
@@ -972,21 +976,20 @@ const getMaxPriorityFeePerGas = (currencyId: string): BigNumber => {
|
|
|
972
976
|
}
|
|
973
977
|
|
|
974
978
|
function cacheKeyOptimismL1Fees(
|
|
975
|
-
|
|
976
|
-
transaction: Parameters<NodeApi['getOptimismAdditionalFees']>[
|
|
979
|
+
chainId: ChainId,
|
|
980
|
+
transaction: Parameters<NodeApi['getOptimismAdditionalFees']>[0]
|
|
977
981
|
): string {
|
|
978
|
-
return 'getOptimismL1BaseFee_' +
|
|
982
|
+
return 'getOptimismL1BaseFee_' + chainId + '_' + transaction
|
|
979
983
|
}
|
|
980
984
|
|
|
981
985
|
function make<Args extends readonly unknown[], R>(
|
|
982
|
-
f: (api: JsonRpcProvider,
|
|
986
|
+
f: (api: JsonRpcProvider, ...args: Args) => Promise<R>,
|
|
983
987
|
evmConfig: EvmConfigInfo,
|
|
984
988
|
nodeConfig: ExternalNodeConfig,
|
|
985
989
|
configOverride: Partial<ExternalNodeConfig> = {}
|
|
986
|
-
): (
|
|
990
|
+
): (...args: Args) => Promise<R> {
|
|
987
991
|
const mergedConfig = { ...nodeConfig, ...configOverride }
|
|
988
|
-
return (
|
|
989
|
-
withApi(evmConfig, currencyId, (api) => f(api, currencyId, ...args), mergedConfig)
|
|
992
|
+
return (...args) => withApi(evmConfig, (api) => f(api, ...args), mergedConfig)
|
|
990
993
|
}
|
|
991
994
|
|
|
992
995
|
export function createNodeApi(
|
|
@@ -996,55 +999,45 @@ export function createNodeApi(
|
|
|
996
999
|
): NodeApi {
|
|
997
1000
|
return {
|
|
998
1001
|
call: make(call, evmConfig, nodeConfig),
|
|
999
|
-
getBlockByHeight: (
|
|
1002
|
+
getBlockByHeight: (blockHeight, prefetchTxs) =>
|
|
1000
1003
|
withApi(
|
|
1001
1004
|
evmConfig,
|
|
1002
|
-
|
|
1003
|
-
(api) => getBlockByHeight(api, currencyId, blockHeight, logger, prefetchTxs),
|
|
1005
|
+
(api) => getBlockByHeight(api, blockHeight, logger, prefetchTxs),
|
|
1004
1006
|
nodeConfig
|
|
1005
1007
|
),
|
|
1006
1008
|
getCoinBalance: make(getCoinBalance, evmConfig, nodeConfig),
|
|
1007
1009
|
getTokenBalance: make(getTokenBalance, evmConfig, nodeConfig),
|
|
1008
1010
|
getTokenAllowance: make(getTokenAllowance, evmConfig, nodeConfig),
|
|
1009
1011
|
getTransactionCount: make(getTransactionCount, evmConfig, nodeConfig),
|
|
1010
|
-
getTransaction: (
|
|
1011
|
-
withApi(
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
(api) => getTransaction(api, currencyId, txHash, logger),
|
|
1015
|
-
nodeConfig
|
|
1016
|
-
),
|
|
1017
|
-
getBlockReceipts: (currencyId, blockHeight) =>
|
|
1018
|
-
withApi(
|
|
1019
|
-
evmConfig,
|
|
1020
|
-
currencyId,
|
|
1021
|
-
(api) => getBlockReceipts(api, currencyId, blockHeight, logger),
|
|
1022
|
-
nodeConfig
|
|
1023
|
-
),
|
|
1012
|
+
getTransaction: (txHash) =>
|
|
1013
|
+
withApi(evmConfig, (api) => getTransaction(api, txHash, logger), nodeConfig),
|
|
1014
|
+
getBlockReceipts: (blockHeight) =>
|
|
1015
|
+
withApi(evmConfig, (api) => getBlockReceipts(api, blockHeight, logger), nodeConfig),
|
|
1024
1016
|
traceBlockErigon: make(traceBlockErigon, evmConfig, nodeConfig),
|
|
1025
1017
|
traceBlockGeth: make(traceBlockGeth, evmConfig, nodeConfig),
|
|
1026
1018
|
getGasEstimation: makeGetGasEstimation(evmConfig, nodeConfig, logger),
|
|
1027
|
-
// getFeeData takes `config` first
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1019
|
+
// getFeeData takes `config` first, so it can't use the `make` wrapper; bind it explicitly.
|
|
1020
|
+
getFeeData: (config, transaction) =>
|
|
1021
|
+
withApi(evmConfig, (api) => getFeeData(api, config, transaction), nodeConfig),
|
|
1022
|
+
broadcastTransaction: (signedTxHex) =>
|
|
1023
|
+
withApi(evmConfig, (api) => broadcastTransaction(api, signedTxHex, logger), {
|
|
1024
|
+
...nodeConfig,
|
|
1025
|
+
retries: 0,
|
|
1026
|
+
}),
|
|
1027
|
+
getOptimismAdditionalFees: makeLRUCache(
|
|
1028
|
+
make(
|
|
1029
|
+
(api, transaction: string) =>
|
|
1030
|
+
getOptimismAdditionalFees(api, evmConfig.chainId, transaction),
|
|
1031
1031
|
evmConfig,
|
|
1032
|
-
currencyId,
|
|
1033
|
-
(api) => getFeeData(api, config, currencyId, transaction),
|
|
1034
1032
|
nodeConfig
|
|
1035
1033
|
),
|
|
1036
|
-
|
|
1037
|
-
withApi(
|
|
1038
|
-
evmConfig,
|
|
1039
|
-
currencyId,
|
|
1040
|
-
(api) => broadcastTransaction(api, currencyId, signedTxHex, logger),
|
|
1041
|
-
{ ...nodeConfig, retries: 0 }
|
|
1042
|
-
),
|
|
1043
|
-
getOptimismAdditionalFees: makeLRUCache(
|
|
1044
|
-
make(getOptimismAdditionalFees, evmConfig, nodeConfig),
|
|
1045
|
-
cacheKeyOptimismL1Fees,
|
|
1034
|
+
(transaction) => cacheKeyOptimismL1Fees(evmConfig.chainId, transaction),
|
|
1046
1035
|
{ ttl: 15 * 1000 } // prevent rate limit by caching for at least 15s
|
|
1047
1036
|
),
|
|
1048
|
-
getScrollAdditionalFees: make(
|
|
1037
|
+
getScrollAdditionalFees: make(
|
|
1038
|
+
(api, transaction: string) => getScrollAdditionalFees(api, evmConfig.chainId, transaction),
|
|
1039
|
+
evmConfig,
|
|
1040
|
+
nodeConfig
|
|
1041
|
+
),
|
|
1049
1042
|
}
|
|
1050
1043
|
}
|
|
@@ -105,6 +105,8 @@ export type TransactionInfo = {
|
|
|
105
105
|
nonce: number
|
|
106
106
|
gasUsed: string
|
|
107
107
|
gasPrice: string
|
|
108
|
+
/** Gas limit set by the sender (decimal), when the source reports it */
|
|
109
|
+
gasLimit?: string
|
|
108
110
|
value: string | bigint // can be returned as bigint by ethers prefetched txs, or string in raw payloads
|
|
109
111
|
status: number | null
|
|
110
112
|
from: string
|
|
@@ -123,8 +125,9 @@ export type TransactionInfo = {
|
|
|
123
125
|
|
|
124
126
|
export type PrefetchedBlockTransaction = Pick<
|
|
125
127
|
TransactionInfo,
|
|
126
|
-
'hash' | 'value' | 'from' | 'to' | 'input' | 'gasPrice'
|
|
127
|
-
>
|
|
128
|
+
'hash' | 'value' | 'from' | 'to' | 'input' | 'gasPrice' | 'gasLimit'
|
|
129
|
+
> &
|
|
130
|
+
Partial<Pick<TransactionInfo, 'nonce'>>
|
|
128
131
|
|
|
129
132
|
export type BlockReceiptInfo = Pick<
|
|
130
133
|
TransactionInfo,
|
|
@@ -154,53 +157,35 @@ export type EvmCallParams = {
|
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
export type NodeApi = {
|
|
157
|
-
call: (
|
|
158
|
-
getTransaction: (
|
|
159
|
-
getCoinBalance: (
|
|
160
|
-
getTokenBalance: (
|
|
161
|
-
currencyId: string,
|
|
162
|
-
address: string,
|
|
163
|
-
contractAddress: string
|
|
164
|
-
) => Promise<BigNumber>
|
|
160
|
+
call: (params: EvmCallParams) => Promise<string>
|
|
161
|
+
getTransaction: (hash: string) => Promise<TransactionInfo>
|
|
162
|
+
getCoinBalance: (address: string) => Promise<BigNumber>
|
|
163
|
+
getTokenBalance: (address: string, contractAddress: string) => Promise<BigNumber>
|
|
165
164
|
getTokenAllowance: (
|
|
166
|
-
currencyId: string,
|
|
167
165
|
ownerAddress: string,
|
|
168
166
|
contractAddress: string,
|
|
169
167
|
spenderAddress: string
|
|
170
168
|
) => Promise<BigNumber>
|
|
171
|
-
getTransactionCount: (
|
|
169
|
+
getTransactionCount: (address: string) => Promise<number>
|
|
172
170
|
getGasEstimation: (
|
|
173
|
-
currencyId: string,
|
|
174
171
|
address: string,
|
|
175
172
|
transaction: { amount: BigNumber; data?: Buffer | null | undefined; recipient: string }
|
|
176
173
|
) => Promise<BigNumber>
|
|
177
174
|
getFeeData: (
|
|
178
175
|
config: EvmConfigInfo,
|
|
179
|
-
currencyId: string,
|
|
180
176
|
transaction: { type?: number | undefined; feesStrategy?: string | null | undefined }
|
|
181
177
|
) => Promise<FeeData>
|
|
182
|
-
broadcastTransaction: (
|
|
183
|
-
currencyId: string,
|
|
184
|
-
signedTxHex: string,
|
|
185
|
-
broadcastConfig?: BroadcastConfig
|
|
186
|
-
) => Promise<string>
|
|
178
|
+
broadcastTransaction: (signedTxHex: string, broadcastConfig?: BroadcastConfig) => Promise<string>
|
|
187
179
|
getBlockByHeight: (
|
|
188
|
-
currencyId: string,
|
|
189
180
|
blockHeight: number | BlockFinalizationTag,
|
|
190
181
|
prefetchTxs?: boolean
|
|
191
182
|
// timestamp is in milliseconds
|
|
192
183
|
) => Promise<BlockByHeightResult>
|
|
193
|
-
getBlockReceipts?: (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
) => Promise<
|
|
197
|
-
|
|
198
|
-
currencyId: string,
|
|
199
|
-
blockHeight: number | 'latest'
|
|
200
|
-
) => Promise<TraceBlockItem[]>
|
|
201
|
-
traceBlockGeth?: (currencyId: string, blockHeight: number) => Promise<TraceBlockItem[]>
|
|
202
|
-
getOptimismAdditionalFees: (currencyId: string, transaction: string) => Promise<BigNumber>
|
|
203
|
-
getScrollAdditionalFees: (currencyId: string, transaction: string) => Promise<BigNumber>
|
|
184
|
+
getBlockReceipts?: (blockHeight: number | 'latest') => Promise<BlockReceiptInfo[]>
|
|
185
|
+
traceBlockErigon?: (blockHeight: number | 'latest') => Promise<TraceBlockItem[]>
|
|
186
|
+
traceBlockGeth?: (blockHeight: number) => Promise<TraceBlockItem[]>
|
|
187
|
+
getOptimismAdditionalFees: (transaction: string) => Promise<BigNumber>
|
|
188
|
+
getScrollAdditionalFees: (transaction: string) => Promise<BigNumber>
|
|
204
189
|
}
|
|
205
190
|
|
|
206
191
|
type NodeConfig = EvmConfigInfo['node']
|
|
@@ -34,37 +34,34 @@ export function createFailoverNodeApi(sources: NodeApi[], logger: Logger): NodeA
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const base: NodeApi = {
|
|
37
|
-
call: (
|
|
38
|
-
getCoinBalance: (
|
|
39
|
-
getTokenBalance: (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
tryInOrder('
|
|
50
|
-
|
|
51
|
-
tryInOrder('
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
getBlockByHeight: (c, h, p) =>
|
|
55
|
-
tryInOrder('getBlockByHeight', (api) => api.getBlockByHeight(c, h, p)),
|
|
56
|
-
getTransaction: (c, h) => tryInOrder('getTransaction', (api) => api.getTransaction(c, h)),
|
|
37
|
+
call: (p) => tryInOrder('call', (api) => api.call(p)),
|
|
38
|
+
getCoinBalance: (a) => tryInOrder('getCoinBalance', (api) => api.getCoinBalance(a)),
|
|
39
|
+
getTokenBalance: (a, ca) => tryInOrder('getTokenBalance', (api) => api.getTokenBalance(a, ca)),
|
|
40
|
+
getTokenAllowance: (o, ca, s) =>
|
|
41
|
+
tryInOrder('getTokenAllowance', (api) => api.getTokenAllowance(o, ca, s)),
|
|
42
|
+
getTransactionCount: (a) =>
|
|
43
|
+
tryInOrder('getTransactionCount', (api) => api.getTransactionCount(a)),
|
|
44
|
+
getGasEstimation: (a, t) => tryInOrder('getGasEstimation', (api) => api.getGasEstimation(a, t)),
|
|
45
|
+
getFeeData: (cfg, t) => tryInOrder('getFeeData', (api) => api.getFeeData(cfg, t)),
|
|
46
|
+
broadcastTransaction: (tx, bc) =>
|
|
47
|
+
tryInOrder('broadcastTransaction', (api) => api.broadcastTransaction(tx, bc)),
|
|
48
|
+
getOptimismAdditionalFees: (t) =>
|
|
49
|
+
tryInOrder('getOptimismAdditionalFees', (api) => api.getOptimismAdditionalFees(t)),
|
|
50
|
+
getScrollAdditionalFees: (t) =>
|
|
51
|
+
tryInOrder('getScrollAdditionalFees', (api) => api.getScrollAdditionalFees(t)),
|
|
52
|
+
getBlockByHeight: (h, p) => tryInOrder('getBlockByHeight', (api) => api.getBlockByHeight(h, p)),
|
|
53
|
+
getTransaction: (h) => tryInOrder('getTransaction', (api) => api.getTransaction(h)),
|
|
57
54
|
}
|
|
58
55
|
// Optional methods: wired when at least one source implements them; undefined sources skipped
|
|
59
56
|
if (sources.some((api) => api.getBlockReceipts))
|
|
60
|
-
base.getBlockReceipts = (
|
|
61
|
-
tryInOrder('getBlockReceipts', (api) => api.getBlockReceipts?.(
|
|
57
|
+
base.getBlockReceipts = (h): Promise<BlockReceiptInfo[]> =>
|
|
58
|
+
tryInOrder('getBlockReceipts', (api) => api.getBlockReceipts?.(h))
|
|
62
59
|
if (sources.some((api) => api.traceBlockErigon))
|
|
63
|
-
base.traceBlockErigon = (
|
|
64
|
-
tryInOrder('traceBlockErigon', (api) => api.traceBlockErigon?.(
|
|
60
|
+
base.traceBlockErigon = (h): Promise<TraceBlockItem[]> =>
|
|
61
|
+
tryInOrder('traceBlockErigon', (api) => api.traceBlockErigon?.(h))
|
|
65
62
|
if (sources.some((api) => api.traceBlockGeth))
|
|
66
|
-
base.traceBlockGeth = (
|
|
67
|
-
tryInOrder('traceBlockGeth', (api) => api.traceBlockGeth?.(
|
|
63
|
+
base.traceBlockGeth = (h): Promise<TraceBlockItem[]> =>
|
|
64
|
+
tryInOrder('traceBlockGeth', (api) => api.traceBlockGeth?.(h))
|
|
68
65
|
return base
|
|
69
66
|
}
|
|
70
67
|
|