@ledgerhq/coin-evm 10.1.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/CHANGELOG.md +42 -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 +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.js +1 -1
- 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/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 +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 +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 +1 -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.js +12 -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 +31 -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 +50 -39
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +15 -15
- 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 +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.js +1 -1
- 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/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 +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 +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 +1 -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.js +12 -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 +31 -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 +50 -39
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +15 -15
- 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 +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 +1 -1
- 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/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 +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 +6 -8
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +0 -1
- 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 +12 -2
- 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 +23 -131
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +0 -2
- package/src/network/node/explorerProxy.test.ts +17 -22
- package/src/network/node/explorerProxy.ts +12 -12
- 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 +31 -34
- package/src/network/node/rpc.common.ts +58 -86
- package/src/network/node/rpc.test.ts +86 -114
- package/src/network/node/types.ts +11 -29
- package/src/network/node/withNodeSources.test.ts +7 -9
- package/src/network/node/withNodeSources.ts +23 -26
- 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
|
@@ -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, LedgerNodeConfig } from '../../config'
|
|
4
|
+
import type { BlockFinalizationTag, ChainId, LedgerNodeConfig } from '../../config'
|
|
5
5
|
import type { LedgerExplorerOperation } from '../../types'
|
|
6
6
|
import type { BlockByHeightResult, EvmCallParams, NodeApi, TransactionInfo } from './types'
|
|
7
7
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
@@ -14,6 +14,7 @@ import { ethers } from 'ethers'
|
|
|
14
14
|
import { toInterfaceAbi } from '../../abis'
|
|
15
15
|
import ERC20Abi from '../../abis/erc20.abi.json'
|
|
16
16
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
17
|
+
import { CHAIN_ID } from '../../config'
|
|
17
18
|
import { GasEstimationError } from '../../errors'
|
|
18
19
|
import { normalizeAddress, padHexString, safeEncodeEIP55 } from '../../logic-public'
|
|
19
20
|
import { getGasOptions } from '../gasTracker/ledger'
|
|
@@ -25,6 +26,8 @@ const DEFAULT_RETRIES_API = 2
|
|
|
25
26
|
|
|
26
27
|
/** The node config, narrowed and defaulted, as the request builders need it. */
|
|
27
28
|
export type LedgerNodeApiConfig = LedgerNodeConfig & {
|
|
29
|
+
/** The chain this node API serves, to key its per-chain caches. */
|
|
30
|
+
chainId: ChainId
|
|
28
31
|
explorerUri: string
|
|
29
32
|
clientVersion?: string
|
|
30
33
|
}
|
|
@@ -52,17 +55,16 @@ function makeFetchWithRetries(config: LedgerNodeApiConfig): LedgerFetch {
|
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
function make<Args extends readonly unknown[], R>(
|
|
55
|
-
f: (fetch: LedgerFetch, config: LedgerNodeApiConfig,
|
|
58
|
+
f: (fetch: LedgerFetch, config: LedgerNodeApiConfig, ...args: Args) => R,
|
|
56
59
|
config: LedgerNodeApiConfig,
|
|
57
60
|
fetch: LedgerFetch
|
|
58
|
-
): (
|
|
59
|
-
return (
|
|
61
|
+
): (...args: Args) => R {
|
|
62
|
+
return (...args) => f(fetch, config, ...args)
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
async function getTransaction(
|
|
63
66
|
fetch: LedgerFetch,
|
|
64
67
|
config: LedgerNodeApiConfig,
|
|
65
|
-
_currencyId: string,
|
|
66
68
|
hash: string,
|
|
67
69
|
logger: Logger
|
|
68
70
|
): Promise<TransactionInfo> {
|
|
@@ -98,7 +100,7 @@ function makeGetTokenBalance(
|
|
|
98
100
|
config: LedgerNodeApiConfig,
|
|
99
101
|
fetch: LedgerFetch,
|
|
100
102
|
tokenBalancesBatchersMap: Map<
|
|
101
|
-
|
|
103
|
+
ChainId,
|
|
102
104
|
Batcher<
|
|
103
105
|
{
|
|
104
106
|
address: string
|
|
@@ -108,12 +110,12 @@ function makeGetTokenBalance(
|
|
|
108
110
|
>
|
|
109
111
|
>
|
|
110
112
|
): NodeApi['getTokenBalance'] {
|
|
111
|
-
return async (
|
|
112
|
-
if (!tokenBalancesBatchersMap.has(
|
|
113
|
+
return async (address, contractAddress) => {
|
|
114
|
+
if (!tokenBalancesBatchersMap.has(config.chainId)) {
|
|
113
115
|
const batcher = makeBatcher(makeGetBatchTokenBalances(config, fetch), {})
|
|
114
|
-
tokenBalancesBatchersMap.set(
|
|
116
|
+
tokenBalancesBatchersMap.set(config.chainId, batcher)
|
|
115
117
|
}
|
|
116
|
-
const requestBatcher = tokenBalancesBatchersMap.get(
|
|
118
|
+
const requestBatcher = tokenBalancesBatchersMap.get(config.chainId)!
|
|
117
119
|
return requestBatcher({ address, contract: contractAddress })
|
|
118
120
|
}
|
|
119
121
|
}
|
|
@@ -121,7 +123,6 @@ function makeGetTokenBalance(
|
|
|
121
123
|
async function getCoinBalance(
|
|
122
124
|
fetch: LedgerFetch,
|
|
123
125
|
config: LedgerNodeApiConfig,
|
|
124
|
-
_currencyId: string,
|
|
125
126
|
address: string
|
|
126
127
|
): Promise<BigNumber> {
|
|
127
128
|
const { balance } = await fetch<{ address: string; balance: string }>({
|
|
@@ -157,7 +158,6 @@ function makeGetBatchTokenBalances(
|
|
|
157
158
|
async function getTransactionCount(
|
|
158
159
|
fetch: LedgerFetch,
|
|
159
160
|
config: LedgerNodeApiConfig,
|
|
160
|
-
_currencyId: string,
|
|
161
161
|
address: string
|
|
162
162
|
): Promise<number> {
|
|
163
163
|
const { nonce } = await fetch<{ address: string; nonce: number }>({
|
|
@@ -172,7 +172,7 @@ function makeGetGasEstimation(
|
|
|
172
172
|
fetch: LedgerFetch,
|
|
173
173
|
logger: Logger
|
|
174
174
|
): NodeApi['getGasEstimation'] {
|
|
175
|
-
return async (
|
|
175
|
+
return async (address, transaction) => {
|
|
176
176
|
const { recipient: to, amount: value, data } = transaction
|
|
177
177
|
try {
|
|
178
178
|
const { estimated_gas_limit: gasEstimation } = await fetch<{
|
|
@@ -201,8 +201,7 @@ async function getFeeData(
|
|
|
201
201
|
_fetch: LedgerFetch,
|
|
202
202
|
config: LedgerNodeApiConfig,
|
|
203
203
|
evmConfig: Parameters<NodeApi['getFeeData']>[0],
|
|
204
|
-
|
|
205
|
-
transaction: Parameters<NodeApi['getFeeData']>[2]
|
|
204
|
+
transaction: Parameters<NodeApi['getFeeData']>[1]
|
|
206
205
|
): Promise<Awaited<ReturnType<NodeApi['getFeeData']>>> {
|
|
207
206
|
const options = await getGasOptions({
|
|
208
207
|
config: evmConfig,
|
|
@@ -221,9 +220,8 @@ async function getFeeData(
|
|
|
221
220
|
async function broadcastTransaction(
|
|
222
221
|
fetch: LedgerFetch,
|
|
223
222
|
config: LedgerNodeApiConfig,
|
|
224
|
-
_currencyId: string,
|
|
225
223
|
signedTxHex: string,
|
|
226
|
-
broadcastConfig?: Parameters<NodeApi['broadcastTransaction']>[
|
|
224
|
+
broadcastConfig?: Parameters<NodeApi['broadcastTransaction']>[1]
|
|
227
225
|
): Promise<string> {
|
|
228
226
|
const params: Record<string, boolean> = {
|
|
229
227
|
mevProtected: Boolean(broadcastConfig?.mevProtected),
|
|
@@ -247,7 +245,6 @@ async function broadcastTransaction(
|
|
|
247
245
|
async function getBlockByHeight(
|
|
248
246
|
fetch: LedgerFetch,
|
|
249
247
|
config: LedgerNodeApiConfig,
|
|
250
|
-
_currencyId: string,
|
|
251
248
|
blockHeight: number | BlockFinalizationTag = 'latest',
|
|
252
249
|
_prefetchTxs = false
|
|
253
250
|
): Promise<BlockByHeightResult> {
|
|
@@ -288,14 +285,17 @@ async function getBlockByHeight(
|
|
|
288
285
|
async function getOptimismAdditionalFees(
|
|
289
286
|
fetch: LedgerFetch,
|
|
290
287
|
config: LedgerNodeApiConfig,
|
|
291
|
-
currencyId: string,
|
|
292
288
|
transaction: string
|
|
293
289
|
): Promise<BigNumber> {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
290
|
+
const optimismFeeChainIds: readonly ChainId[] = [
|
|
291
|
+
CHAIN_ID.OPTIMISM,
|
|
292
|
+
CHAIN_ID.OPTIMISM_SEPOLIA,
|
|
293
|
+
CHAIN_ID.BLAST,
|
|
294
|
+
CHAIN_ID.BLAST_SEPOLIA,
|
|
295
|
+
CHAIN_ID.BASE,
|
|
296
|
+
CHAIN_ID.BASE_SEPOLIA,
|
|
297
|
+
]
|
|
298
|
+
if (!optimismFeeChainIds.includes(config.chainId)) {
|
|
299
299
|
return new BigNumber(0)
|
|
300
300
|
}
|
|
301
301
|
if (!transaction) {
|
|
@@ -338,7 +338,6 @@ type ContractReadResult = {
|
|
|
338
338
|
async function call(
|
|
339
339
|
fetch: LedgerFetch,
|
|
340
340
|
config: LedgerNodeApiConfig,
|
|
341
|
-
_currencyId: string,
|
|
342
341
|
params: EvmCallParams
|
|
343
342
|
): Promise<string> {
|
|
344
343
|
// `contract/read` accepts a decimal block height or a tag ("latest"/"earliest"/"pending"); it
|
|
@@ -374,7 +373,7 @@ function makeGetTokenAllowance(
|
|
|
374
373
|
fetch: LedgerFetch
|
|
375
374
|
): NodeApi['getTokenAllowance'] {
|
|
376
375
|
const iface = new ethers.Interface(toInterfaceAbi(ERC20Abi))
|
|
377
|
-
return async (
|
|
376
|
+
return async (ownerAddress, contractAddress, spenderAddress) => {
|
|
378
377
|
const data = iface.encodeFunctionData('allowance', [
|
|
379
378
|
ethers.getAddress(ownerAddress),
|
|
380
379
|
ethers.getAddress(spenderAddress),
|
|
@@ -396,10 +395,9 @@ function makeGetTokenAllowance(
|
|
|
396
395
|
async function getScrollAdditionalFees(
|
|
397
396
|
fetch: LedgerFetch,
|
|
398
397
|
config: LedgerNodeApiConfig,
|
|
399
|
-
currencyId: string,
|
|
400
398
|
transaction: string
|
|
401
399
|
): Promise<BigNumber> {
|
|
402
|
-
if (
|
|
400
|
+
if (config.chainId !== CHAIN_ID.SCROLL) {
|
|
403
401
|
return new BigNumber(0)
|
|
404
402
|
}
|
|
405
403
|
if (!transaction) {
|
|
@@ -428,7 +426,7 @@ async function getScrollAdditionalFees(
|
|
|
428
426
|
export function createLedgerNodeApi(config: LedgerNodeApiConfig, logger: Logger): NodeApi {
|
|
429
427
|
const fetch = makeFetchWithRetries(config)
|
|
430
428
|
const tokenBalancesBatchersMap = new Map<
|
|
431
|
-
|
|
429
|
+
ChainId,
|
|
432
430
|
Batcher<{ address: string; contract: string }, BigNumber>
|
|
433
431
|
>()
|
|
434
432
|
return {
|
|
@@ -438,12 +436,11 @@ export function createLedgerNodeApi(config: LedgerNodeApiConfig, logger: Logger)
|
|
|
438
436
|
getTokenBalance: makeGetTokenBalance(config, fetch, tokenBalancesBatchersMap),
|
|
439
437
|
getTokenAllowance: makeGetTokenAllowance(config, fetch),
|
|
440
438
|
getTransactionCount: make(getTransactionCount, config, fetch),
|
|
441
|
-
getTransaction: (
|
|
439
|
+
getTransaction: (hash) => getTransaction(fetch, config, hash, logger),
|
|
442
440
|
getGasEstimation: makeGetGasEstimation(config, fetch, logger),
|
|
443
|
-
// getFeeData takes `config` (EvmConfigInfo) first,
|
|
444
|
-
//
|
|
445
|
-
getFeeData: (evmConfig,
|
|
446
|
-
getFeeData(fetch, config, evmConfig, currencyId, transaction),
|
|
441
|
+
// getFeeData takes `config` (EvmConfigInfo) first, so it doesn't fit the `make` wrapper;
|
|
442
|
+
// bind it directly (same fetch/config passthrough as `make`).
|
|
443
|
+
getFeeData: (evmConfig, transaction) => getFeeData(fetch, config, evmConfig, transaction),
|
|
447
444
|
broadcastTransaction: make(broadcastTransaction, config, fetch),
|
|
448
445
|
getOptimismAdditionalFees: make(getOptimismAdditionalFees, config, fetch),
|
|
449
446
|
getScrollAdditionalFees: make(getScrollAdditionalFees, config, fetch),
|
|
@@ -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> {
|
|
@@ -316,20 +315,12 @@ async function getTransaction(
|
|
|
316
315
|
}
|
|
317
316
|
}
|
|
318
317
|
|
|
319
|
-
async function getCoinBalance(
|
|
320
|
-
api: JsonRpcProvider,
|
|
321
|
-
_currencyId: string,
|
|
322
|
-
address: string
|
|
323
|
-
): Promise<BigNumber> {
|
|
318
|
+
async function getCoinBalance(api: JsonRpcProvider, address: string): Promise<BigNumber> {
|
|
324
319
|
const balance = await api.getBalance(normalizeAddress(address))
|
|
325
320
|
return new BigNumber(balance.toString())
|
|
326
321
|
}
|
|
327
322
|
|
|
328
|
-
async function call(
|
|
329
|
-
api: JsonRpcProvider,
|
|
330
|
-
_currencyId: string,
|
|
331
|
-
params: EvmCallParams
|
|
332
|
-
): Promise<string> {
|
|
323
|
+
async function call(api: JsonRpcProvider, params: EvmCallParams): Promise<string> {
|
|
333
324
|
const block = typeof params.block === 'number' ? ethers.toQuantity(params.block) : params.block
|
|
334
325
|
return api.send('eth_call', [
|
|
335
326
|
{
|
|
@@ -342,7 +333,6 @@ async function call(
|
|
|
342
333
|
|
|
343
334
|
async function getTokenBalance(
|
|
344
335
|
api: JsonRpcProvider,
|
|
345
|
-
_currencyId: string,
|
|
346
336
|
address: string,
|
|
347
337
|
contractAddress: string
|
|
348
338
|
): Promise<BigNumber> {
|
|
@@ -353,7 +343,6 @@ async function getTokenBalance(
|
|
|
353
343
|
|
|
354
344
|
async function getTokenAllowance(
|
|
355
345
|
api: JsonRpcProvider,
|
|
356
|
-
_currencyId: string,
|
|
357
346
|
ownerAddress: string,
|
|
358
347
|
contractAddress: string,
|
|
359
348
|
spenderAddress: string
|
|
@@ -366,11 +355,7 @@ async function getTokenAllowance(
|
|
|
366
355
|
return new BigNumber(allowance.toString())
|
|
367
356
|
}
|
|
368
357
|
|
|
369
|
-
async function getTransactionCount(
|
|
370
|
-
api: JsonRpcProvider,
|
|
371
|
-
_currencyId: string,
|
|
372
|
-
address: string
|
|
373
|
-
): Promise<number> {
|
|
358
|
+
async function getTransactionCount(api: JsonRpcProvider, address: string): Promise<number> {
|
|
374
359
|
return api.getTransactionCount(normalizeAddress(address), 'pending')
|
|
375
360
|
}
|
|
376
361
|
|
|
@@ -403,8 +388,8 @@ function makeGetGasEstimation(
|
|
|
403
388
|
nodeConfig: ExternalNodeConfig,
|
|
404
389
|
logger: Logger
|
|
405
390
|
): NodeApi['getGasEstimation'] {
|
|
406
|
-
return (
|
|
407
|
-
withApi(evmConfig,
|
|
391
|
+
return (address, transaction) =>
|
|
392
|
+
withApi(evmConfig, (api) => getGasEstimation(api, address, transaction, logger), {
|
|
408
393
|
...nodeConfig,
|
|
409
394
|
retries: 0,
|
|
410
395
|
})
|
|
@@ -413,7 +398,6 @@ function makeGetGasEstimation(
|
|
|
413
398
|
async function getFeeData(
|
|
414
399
|
api: JsonRpcProvider,
|
|
415
400
|
config: EvmConfigInfo,
|
|
416
|
-
currencyId: string,
|
|
417
401
|
transaction: { type?: number | undefined; feesStrategy?: string | null | undefined }
|
|
418
402
|
): Promise<FeeData> {
|
|
419
403
|
const block = await api.getBlock('latest')
|
|
@@ -486,7 +470,7 @@ async function getFeeData(
|
|
|
486
470
|
// As a safety measure, if maxPriorityFeePerGas is zero
|
|
487
471
|
// we enforce a 1 Gwei value
|
|
488
472
|
let maxPriorityFeePerGas = maxPriorityFeeAverage.isZero()
|
|
489
|
-
? getMaxPriorityFeePerGas(
|
|
473
|
+
? getMaxPriorityFeePerGas(config.chainId)
|
|
490
474
|
: maxPriorityFeeAverage
|
|
491
475
|
|
|
492
476
|
// Apply the per-chain config floor on top, for networks (typically sparse testnets)
|
|
@@ -525,7 +509,6 @@ async function getFeeData(
|
|
|
525
509
|
|
|
526
510
|
async function broadcastTransaction(
|
|
527
511
|
api: JsonRpcProvider,
|
|
528
|
-
_currencyId: string,
|
|
529
512
|
signedTxHex: string,
|
|
530
513
|
logger: Logger
|
|
531
514
|
): Promise<string> {
|
|
@@ -557,7 +540,6 @@ function assertNotStubBlock(
|
|
|
557
540
|
|
|
558
541
|
async function getBlockByHeight(
|
|
559
542
|
api: JsonRpcProvider,
|
|
560
|
-
_currencyId: string,
|
|
561
543
|
blockHeight: number | BlockFinalizationTag,
|
|
562
544
|
logger: Logger,
|
|
563
545
|
prefetchTxs?: boolean
|
|
@@ -744,7 +726,6 @@ async function getBlockByHeightFromRawRpc(
|
|
|
744
726
|
|
|
745
727
|
async function getBlockReceipts(
|
|
746
728
|
api: JsonRpcProvider,
|
|
747
|
-
_currencyId: string,
|
|
748
729
|
blockHeight: number | 'latest',
|
|
749
730
|
logger: Logger
|
|
750
731
|
): Promise<BlockReceiptInfo[]> {
|
|
@@ -796,7 +777,6 @@ async function getBlockReceipts(
|
|
|
796
777
|
|
|
797
778
|
async function traceBlockGeth(
|
|
798
779
|
api: JsonRpcProvider,
|
|
799
|
-
_currencyId: string,
|
|
800
780
|
blockHeight: number
|
|
801
781
|
): Promise<TraceBlockItem[]> {
|
|
802
782
|
const rpcBlockTag = ethers.toQuantity(blockHeight) // convert to hex string
|
|
@@ -824,7 +804,6 @@ async function traceBlockGeth(
|
|
|
824
804
|
|
|
825
805
|
async function traceBlockErigon(
|
|
826
806
|
api: JsonRpcProvider,
|
|
827
|
-
_currencyId: string,
|
|
828
807
|
blockHeight: number | 'latest'
|
|
829
808
|
): Promise<TraceBlockItem[]> {
|
|
830
809
|
const blockTag = blockHeight === 'latest' ? 'latest' : ethers.toQuantity(blockHeight)
|
|
@@ -911,14 +890,18 @@ function receiptEnvelopeType(type: TransactionReceipt['type']): number | undefin
|
|
|
911
890
|
|
|
912
891
|
async function getOptimismAdditionalFees(
|
|
913
892
|
api: JsonRpcProvider,
|
|
914
|
-
|
|
893
|
+
chainId: ChainId,
|
|
915
894
|
transaction: string
|
|
916
895
|
): Promise<BigNumber> {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
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)) {
|
|
922
905
|
return new BigNumber(0)
|
|
923
906
|
}
|
|
924
907
|
|
|
@@ -939,10 +922,10 @@ async function getOptimismAdditionalFees(
|
|
|
939
922
|
|
|
940
923
|
async function getScrollAdditionalFees(
|
|
941
924
|
api: JsonRpcProvider,
|
|
942
|
-
|
|
925
|
+
chainId: ChainId,
|
|
943
926
|
transaction: string
|
|
944
927
|
): Promise<BigNumber> {
|
|
945
|
-
if (
|
|
928
|
+
if (chainId !== CHAIN_ID.SCROLL) {
|
|
946
929
|
return new BigNumber(0)
|
|
947
930
|
}
|
|
948
931
|
|
|
@@ -962,9 +945,9 @@ async function getScrollAdditionalFees(
|
|
|
962
945
|
}
|
|
963
946
|
|
|
964
947
|
/* Get default maxPriorityFeePerGas by chain */
|
|
965
|
-
const getMaxPriorityFeePerGas = (
|
|
966
|
-
switch (
|
|
967
|
-
case
|
|
948
|
+
const getMaxPriorityFeePerGas = (chainId: ChainId): BigNumber => {
|
|
949
|
+
switch (chainId) {
|
|
950
|
+
case CHAIN_ID.ZERO_GRAVITY:
|
|
968
951
|
return new BigNumber(2e9) // 2 Gwei
|
|
969
952
|
default:
|
|
970
953
|
return new BigNumber(1e9) // 1 Gwei
|
|
@@ -972,21 +955,20 @@ const getMaxPriorityFeePerGas = (currencyId: string): BigNumber => {
|
|
|
972
955
|
}
|
|
973
956
|
|
|
974
957
|
function cacheKeyOptimismL1Fees(
|
|
975
|
-
|
|
976
|
-
transaction: Parameters<NodeApi['getOptimismAdditionalFees']>[
|
|
958
|
+
chainId: ChainId,
|
|
959
|
+
transaction: Parameters<NodeApi['getOptimismAdditionalFees']>[0]
|
|
977
960
|
): string {
|
|
978
|
-
return 'getOptimismL1BaseFee_' +
|
|
961
|
+
return 'getOptimismL1BaseFee_' + chainId + '_' + transaction
|
|
979
962
|
}
|
|
980
963
|
|
|
981
964
|
function make<Args extends readonly unknown[], R>(
|
|
982
|
-
f: (api: JsonRpcProvider,
|
|
965
|
+
f: (api: JsonRpcProvider, ...args: Args) => Promise<R>,
|
|
983
966
|
evmConfig: EvmConfigInfo,
|
|
984
967
|
nodeConfig: ExternalNodeConfig,
|
|
985
968
|
configOverride: Partial<ExternalNodeConfig> = {}
|
|
986
|
-
): (
|
|
969
|
+
): (...args: Args) => Promise<R> {
|
|
987
970
|
const mergedConfig = { ...nodeConfig, ...configOverride }
|
|
988
|
-
return (
|
|
989
|
-
withApi(evmConfig, currencyId, (api) => f(api, currencyId, ...args), mergedConfig)
|
|
971
|
+
return (...args) => withApi(evmConfig, (api) => f(api, ...args), mergedConfig)
|
|
990
972
|
}
|
|
991
973
|
|
|
992
974
|
export function createNodeApi(
|
|
@@ -996,55 +978,45 @@ export function createNodeApi(
|
|
|
996
978
|
): NodeApi {
|
|
997
979
|
return {
|
|
998
980
|
call: make(call, evmConfig, nodeConfig),
|
|
999
|
-
getBlockByHeight: (
|
|
981
|
+
getBlockByHeight: (blockHeight, prefetchTxs) =>
|
|
1000
982
|
withApi(
|
|
1001
983
|
evmConfig,
|
|
1002
|
-
|
|
1003
|
-
(api) => getBlockByHeight(api, currencyId, blockHeight, logger, prefetchTxs),
|
|
984
|
+
(api) => getBlockByHeight(api, blockHeight, logger, prefetchTxs),
|
|
1004
985
|
nodeConfig
|
|
1005
986
|
),
|
|
1006
987
|
getCoinBalance: make(getCoinBalance, evmConfig, nodeConfig),
|
|
1007
988
|
getTokenBalance: make(getTokenBalance, evmConfig, nodeConfig),
|
|
1008
989
|
getTokenAllowance: make(getTokenAllowance, evmConfig, nodeConfig),
|
|
1009
990
|
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
|
-
),
|
|
991
|
+
getTransaction: (txHash) =>
|
|
992
|
+
withApi(evmConfig, (api) => getTransaction(api, txHash, logger), nodeConfig),
|
|
993
|
+
getBlockReceipts: (blockHeight) =>
|
|
994
|
+
withApi(evmConfig, (api) => getBlockReceipts(api, blockHeight, logger), nodeConfig),
|
|
1024
995
|
traceBlockErigon: make(traceBlockErigon, evmConfig, nodeConfig),
|
|
1025
996
|
traceBlockGeth: make(traceBlockGeth, evmConfig, nodeConfig),
|
|
1026
997
|
getGasEstimation: makeGetGasEstimation(evmConfig, nodeConfig, logger),
|
|
1027
|
-
// getFeeData takes `config` first
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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
|
+
}),
|
|
1006
|
+
getOptimismAdditionalFees: makeLRUCache(
|
|
1007
|
+
make(
|
|
1008
|
+
(api, transaction: string) =>
|
|
1009
|
+
getOptimismAdditionalFees(api, evmConfig.chainId, transaction),
|
|
1031
1010
|
evmConfig,
|
|
1032
|
-
currencyId,
|
|
1033
|
-
(api) => getFeeData(api, config, currencyId, transaction),
|
|
1034
1011
|
nodeConfig
|
|
1035
1012
|
),
|
|
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,
|
|
1013
|
+
(transaction) => cacheKeyOptimismL1Fees(evmConfig.chainId, transaction),
|
|
1046
1014
|
{ ttl: 15 * 1000 } // prevent rate limit by caching for at least 15s
|
|
1047
1015
|
),
|
|
1048
|
-
getScrollAdditionalFees: make(
|
|
1016
|
+
getScrollAdditionalFees: make(
|
|
1017
|
+
(api, transaction: string) => getScrollAdditionalFees(api, evmConfig.chainId, transaction),
|
|
1018
|
+
evmConfig,
|
|
1019
|
+
nodeConfig
|
|
1020
|
+
),
|
|
1049
1021
|
}
|
|
1050
1022
|
}
|