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