@ledgerhq/coin-evm 10.1.0 → 15.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/docs/getBlock-internal-txs-schema.md +2 -2
- package/docs/network/node/index.md +1 -1
- package/lib/adapters/etherscan.d.ts +2 -1
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +16 -2
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts +2 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +4 -2
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -2
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +95 -0
- package/lib/chains.d.ts.map +1 -0
- package/lib/chains.js +99 -0
- package/lib/chains.js.map +1 -0
- package/lib/config.d.ts +4 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -1
- package/lib/config.js.map +1 -1
- package/lib/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/common.d.ts +1 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +11 -11
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +3 -3
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +7 -7
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +9 -9
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +38 -21
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -2
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +1 -1
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +10 -10
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js +8 -8
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +3 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +9 -9
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +14 -13
- package/lib/logic.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +2 -3
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +6 -8
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +5 -5
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/types.d.ts +2 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +14 -12
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/index.d.ts +1 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +7 -7
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.d.ts +3 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +32 -22
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +67 -39
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +18 -16
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/network/node/withNodeSources.d.ts.map +1 -1
- package/lib/network/node/withNodeSources.js +15 -15
- package/lib/network/node/withNodeSources.js.map +1 -1
- package/lib/staking/abis.d.ts +3 -2
- package/lib/staking/abis.d.ts.map +1 -1
- package/lib/staking/abis.js +10 -9
- package/lib/staking/abis.js.map +1 -1
- package/lib/staking/contracts.d.ts +3 -2
- package/lib/staking/contracts.d.ts.map +1 -1
- package/lib/staking/contracts.js +11 -10
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/detectOperationType.d.ts +2 -1
- package/lib/staking/detectOperationType.d.ts.map +1 -1
- package/lib/staking/detectOperationType.js +7 -7
- package/lib/staking/detectOperationType.js.map +1 -1
- package/lib/staking/encoder.d.ts +2 -1
- package/lib/staking/encoder.d.ts.map +1 -1
- package/lib/staking/encoder.js +8 -8
- package/lib/staking/encoder.js.map +1 -1
- package/lib/staking/fetchers.d.ts +2 -1
- package/lib/staking/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +27 -27
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/logic.d.ts +6 -6
- package/lib/staking/logic.d.ts.map +1 -1
- package/lib/staking/logic.js +14 -13
- package/lib/staking/logic.js.map +1 -1
- package/lib/staking/operations/index.d.ts +2 -1
- package/lib/staking/operations/index.d.ts.map +1 -1
- package/lib/staking/operations/index.js +30 -28
- package/lib/staking/operations/index.js.map +1 -1
- package/lib/staking/prepareIntents.d.ts +1 -1
- package/lib/staking/prepareIntents.d.ts.map +1 -1
- package/lib/staking/prepareIntents.js +11 -10
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/redelegations.d.ts +4 -4
- package/lib/staking/redelegations.d.ts.map +1 -1
- package/lib/staking/redelegations.js +18 -20
- package/lib/staking/redelegations.js.map +1 -1
- package/lib/staking/rewards.d.ts +1 -1
- package/lib/staking/rewards.d.ts.map +1 -1
- package/lib/staking/rewards.js +2 -2
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib/staking/rewardsFromReceipt.js +2 -2
- package/lib/staking/rewardsFromReceipt.js.map +1 -1
- package/lib/staking/transactionData.d.ts +2 -1
- package/lib/staking/transactionData.d.ts.map +1 -1
- package/lib/staking/transactionData.js +6 -6
- package/lib/staking/transactionData.js.map +1 -1
- package/lib/staking/unbondings.d.ts +1 -1
- package/lib/staking/unbondings.d.ts.map +1 -1
- package/lib/staking/unbondings.js +2 -2
- package/lib/staking/unbondings.js.map +1 -1
- package/lib/staking/validators/index.d.ts +14 -14
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +39 -38
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +5 -5
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +31 -33
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +1 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js +4 -4
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/sei.js +2 -2
- package/lib/staking/validators/sei.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts +4 -4
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js +22 -22
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/types.d.ts +1 -1
- package/lib/staking/validators/types.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts +1 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js +7 -7
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/staking.d.ts +5 -6
- package/lib/types/staking.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.d.ts +2 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +16 -2
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts +2 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +4 -2
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +1 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +95 -0
- package/lib-es/chains.d.ts.map +1 -0
- package/lib-es/chains.js +96 -0
- package/lib-es/chains.js.map +1 -0
- package/lib-es/config.d.ts +4 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -0
- package/lib-es/config.js.map +1 -1
- package/lib-es/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/common.d.ts +1 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +11 -11
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +3 -3
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +7 -7
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +9 -9
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +39 -22
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.js +2 -2
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +1 -1
- package/lib-es/logic/getNextSequence.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +10 -10
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts +2 -2
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js +8 -8
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +3 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +9 -9
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +14 -13
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +2 -3
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +6 -8
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +5 -5
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +2 -2
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +14 -12
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/index.d.ts +1 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +7 -7
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts +3 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +32 -22
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +67 -39
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +18 -16
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
- package/lib-es/network/node/withNodeSources.js +15 -15
- package/lib-es/network/node/withNodeSources.js.map +1 -1
- package/lib-es/staking/abis.d.ts +3 -2
- package/lib-es/staking/abis.d.ts.map +1 -1
- package/lib-es/staking/abis.js +10 -9
- package/lib-es/staking/abis.js.map +1 -1
- package/lib-es/staking/contracts.d.ts +3 -2
- package/lib-es/staking/contracts.d.ts.map +1 -1
- package/lib-es/staking/contracts.js +11 -10
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/detectOperationType.d.ts +2 -1
- package/lib-es/staking/detectOperationType.d.ts.map +1 -1
- package/lib-es/staking/detectOperationType.js +7 -7
- package/lib-es/staking/detectOperationType.js.map +1 -1
- package/lib-es/staking/encoder.d.ts +2 -1
- package/lib-es/staking/encoder.d.ts.map +1 -1
- package/lib-es/staking/encoder.js +8 -8
- package/lib-es/staking/encoder.js.map +1 -1
- package/lib-es/staking/fetchers.d.ts +2 -1
- package/lib-es/staking/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +27 -27
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/logic.d.ts +6 -6
- package/lib-es/staking/logic.d.ts.map +1 -1
- package/lib-es/staking/logic.js +14 -13
- package/lib-es/staking/logic.js.map +1 -1
- package/lib-es/staking/operations/index.d.ts +2 -1
- package/lib-es/staking/operations/index.d.ts.map +1 -1
- package/lib-es/staking/operations/index.js +30 -28
- package/lib-es/staking/operations/index.js.map +1 -1
- package/lib-es/staking/prepareIntents.d.ts +1 -1
- package/lib-es/staking/prepareIntents.d.ts.map +1 -1
- package/lib-es/staking/prepareIntents.js +11 -10
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/redelegations.d.ts +4 -4
- package/lib-es/staking/redelegations.d.ts.map +1 -1
- package/lib-es/staking/redelegations.js +18 -20
- package/lib-es/staking/redelegations.js.map +1 -1
- package/lib-es/staking/rewards.d.ts +1 -1
- package/lib-es/staking/rewards.d.ts.map +1 -1
- package/lib-es/staking/rewards.js +2 -2
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.js +2 -2
- package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
- package/lib-es/staking/transactionData.d.ts +2 -1
- package/lib-es/staking/transactionData.d.ts.map +1 -1
- package/lib-es/staking/transactionData.js +6 -6
- package/lib-es/staking/transactionData.js.map +1 -1
- package/lib-es/staking/unbondings.d.ts +1 -1
- package/lib-es/staking/unbondings.d.ts.map +1 -1
- package/lib-es/staking/unbondings.js +2 -2
- package/lib-es/staking/unbondings.js.map +1 -1
- package/lib-es/staking/validators/index.d.ts +14 -14
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +39 -38
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +5 -5
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +31 -33
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +4 -4
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/sei.js +2 -2
- package/lib-es/staking/validators/sei.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts +4 -4
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js +22 -22
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/types.d.ts +1 -1
- package/lib-es/staking/validators/types.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js +7 -7
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/staking.d.ts +5 -6
- package/lib-es/types/staking.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/etherscan.test.ts +91 -43
- package/src/adapters/etherscan.ts +18 -2
- package/src/adapters/ledger.test.ts +106 -31
- package/src/adapters/ledger.ts +5 -2
- package/src/api/index.ts +1 -2
- package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +5 -4
- package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +3 -3
- package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +3 -3
- package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +3 -3
- package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +3 -3
- package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +3 -3
- package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +3 -3
- package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +3 -3
- package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +6 -6
- package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +3 -3
- package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +3 -3
- package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +3 -3
- package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +3 -3
- package/src/api/{index.test.ts → tests/index.test.ts} +4 -4
- package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +2 -2
- package/src/chains.test.ts +12 -0
- package/src/chains.ts +98 -0
- package/src/config.ts +5 -1
- package/src/fixtures/staking.fixtures.ts +13 -0
- package/src/logic/broadcast.ts +2 -2
- package/src/logic/common.ts +10 -11
- package/src/logic/craftTransaction.ts +2 -3
- package/src/logic/estimateFees.ts +6 -23
- package/src/logic/getBalance.ts +7 -13
- package/src/logic/getBlock.ts +59 -23
- package/src/logic/getBlockInfo.ts +2 -2
- package/src/logic/getNextSequence.ts +1 -4
- package/src/logic/getStakes.ts +11 -12
- package/src/logic/internalTransactionsFetcher.ts +6 -8
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +2 -1
- package/src/logic/tests/broadcast.test.ts +5 -5
- package/src/logic/tests/broadcastSource.test.ts +1 -4
- package/src/logic/tests/common.test.ts +18 -34
- package/src/logic/tests/craftTransaction.test.ts +14 -7
- package/src/logic/tests/estimateFees.test.ts +17 -8
- package/src/logic/tests/getBalance.test.ts +18 -34
- package/src/logic/tests/getBlock.test.ts +195 -80
- package/src/logic/tests/getBlockInfo.test.ts +2 -2
- package/src/logic/tests/getNextSequence.test.ts +2 -2
- package/src/logic/tests/getStakes.test.ts +28 -16
- package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -6
- package/src/logic/tests/lastBlock.test.ts +4 -7
- package/src/logic/tests/listOperations.test.ts +8 -7
- package/src/logic/tests/validateIntent.test.ts +49 -3
- package/src/logic/validateIntent.ts +8 -10
- package/src/logic.test.ts +13 -5
- package/src/logic.ts +13 -13
- package/src/network/explorer/etherscan.ts +8 -24
- package/src/network/explorer/ledger.ts +2 -5
- package/src/network/explorer/types.ts +0 -2
- package/src/network/node/explorerProxy.ts +14 -12
- package/src/network/node/index.ts +11 -8
- package/src/network/node/ledger.ts +32 -34
- package/src/network/node/rpc.common.ts +79 -86
- package/src/network/node/types.ts +16 -31
- package/src/network/node/withNodeSources.ts +23 -26
- package/src/network/{explorer → tests/explorer}/etherscan.test.ts +16 -65
- package/src/network/{explorer → tests/explorer}/index.test.ts +8 -8
- package/src/network/{explorer → tests/explorer}/ledger.test.ts +34 -142
- package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
- package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
- package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
- package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/explorerProxy.test.ts +22 -24
- package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
- package/src/network/tests/node/index.memoization.test.ts +70 -0
- package/src/network/{node → tests/node}/index.test.ts +4 -6
- package/src/network/{node → tests/node}/ledger.test.ts +69 -74
- package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
- package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
- package/src/network/{node → tests/node}/rpc.test.ts +100 -119
- package/src/network/{node → tests/node}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/withNodeSources.test.ts +10 -12
- package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
- package/src/staking/abis.test.ts +24 -28
- package/src/staking/abis.ts +12 -10
- package/src/staking/contracts.test.ts +20 -8
- package/src/staking/contracts.ts +12 -11
- package/src/staking/detectOperationType.test.ts +16 -13
- package/src/staking/detectOperationType.ts +9 -8
- package/src/staking/encoder.test.ts +38 -27
- package/src/staking/encoder.ts +9 -8
- package/src/staking/fetchers.ts +28 -39
- package/src/staking/logic.test.ts +34 -32
- package/src/staking/logic.ts +14 -14
- package/src/staking/operations/index.test.ts +48 -39
- package/src/staking/operations/index.ts +31 -28
- package/src/staking/prepareIntents.test.ts +14 -34
- package/src/staking/prepareIntents.ts +10 -13
- package/src/staking/redelegations.test.ts +73 -131
- package/src/staking/redelegations.ts +12 -26
- package/src/staking/rewards.test.ts +19 -21
- package/src/staking/rewards.ts +1 -2
- package/src/staking/rewardsFromReceipt.test.ts +9 -8
- package/src/staking/rewardsFromReceipt.ts +3 -2
- package/src/staking/transactionData.test.ts +35 -25
- package/src/staking/transactionData.ts +7 -6
- package/src/staking/unbondings.test.ts +26 -20
- package/src/staking/unbondings.ts +1 -2
- package/src/staking/validators/index.ts +45 -51
- package/src/staking/validators/monad.test.ts +52 -54
- package/src/staking/validators/monad.ts +31 -37
- package/src/staking/validators/monadResolver.ts +2 -4
- package/src/staking/validators/sei.ts +2 -2
- package/src/staking/validators/somnia.test.ts +22 -19
- package/src/staking/validators/somnia.ts +20 -27
- package/src/staking/validators/types.ts +0 -1
- package/src/staking/validators/zero_gravity.test.ts +34 -49
- package/src/staking/validators/zero_gravity.ts +5 -11
- package/src/staking/validators.integ.test.ts +3 -5
- package/src/staking/validators.test.ts +56 -53
- package/src/types/staking.ts +3 -6
- package/src/network/node/index.memoization.test.ts +0 -63
|
@@ -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,
|
|
@@ -71,7 +71,6 @@ export async function listOperations(
|
|
|
71
71
|
} = await explorerApi.getOperations(
|
|
72
72
|
config,
|
|
73
73
|
context.logger,
|
|
74
|
-
currencyId,
|
|
75
74
|
address,
|
|
76
75
|
options.minHeight,
|
|
77
76
|
undefined,
|
|
@@ -147,6 +146,8 @@ export async function listOperations(
|
|
|
147
146
|
details: {
|
|
148
147
|
...(op.details ?? {}),
|
|
149
148
|
sequence: op.details?.sequence ?? parent.details?.sequence,
|
|
149
|
+
gasPrice: op.details?.gasPrice ?? parent.details?.gasPrice,
|
|
150
|
+
gasLimit: op.details?.gasLimit ?? parent.details?.gasLimit,
|
|
150
151
|
parentSenders: parent.senders,
|
|
151
152
|
parentRecipients: parent.recipients,
|
|
152
153
|
...parentContractDetails,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { mockEvmContext } from '../../fixtures/context.fixtures'
|
|
5
5
|
import { getNodeApi } from '../../network/node/index'
|
|
6
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
6
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
7
7
|
import { broadcast } from '../broadcast'
|
|
8
8
|
|
|
9
9
|
jest.mock('../../network/node/index', () => ({
|
|
@@ -27,8 +27,8 @@ describe('broadcastLogic', () => {
|
|
|
27
27
|
signature: '0xabcdef',
|
|
28
28
|
broadcastConfig: { mevProtected: true },
|
|
29
29
|
})
|
|
30
|
-
expect(mockGetNodeApi).toHaveBeenCalledWith(expect.anything(),
|
|
31
|
-
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('
|
|
30
|
+
expect(mockGetNodeApi).toHaveBeenCalledWith(expect.anything(), expect.any(Function))
|
|
31
|
+
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('0xabcdef', {
|
|
32
32
|
mevProtected: true,
|
|
33
33
|
})
|
|
34
34
|
expect(result).toBe('txid123')
|
|
@@ -50,7 +50,7 @@ describe('broadcastLogic', () => {
|
|
|
50
50
|
signature: '0xabcdef',
|
|
51
51
|
broadcastConfig: undefined,
|
|
52
52
|
})
|
|
53
|
-
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('
|
|
53
|
+
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('0xabcdef', undefined)
|
|
54
54
|
expect(result).toBe('txid456')
|
|
55
55
|
})
|
|
56
56
|
|
|
@@ -60,7 +60,7 @@ describe('broadcastLogic', () => {
|
|
|
60
60
|
signature: '0x123456',
|
|
61
61
|
broadcastConfig: { mevProtected: true },
|
|
62
62
|
})
|
|
63
|
-
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('
|
|
63
|
+
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('0x123456', {
|
|
64
64
|
mevProtected: true,
|
|
65
65
|
})
|
|
66
66
|
expect(result).toBe('txid789')
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { mockEvmContext } from '../../fixtures/context.fixtures'
|
|
5
5
|
import { getNodeApi } from '../../network/node/index'
|
|
6
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
6
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
7
7
|
import { broadcast } from '../broadcast'
|
|
8
8
|
|
|
9
9
|
jest.mock('../../network/node/index', () => ({
|
|
@@ -35,7 +35,6 @@ describe('EVM broadcast with source', () => {
|
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith(
|
|
38
|
-
'ethereum',
|
|
39
38
|
'0xsignature',
|
|
40
39
|
expect.objectContaining({
|
|
41
40
|
mevProtected: true,
|
|
@@ -62,7 +61,6 @@ describe('EVM broadcast with source', () => {
|
|
|
62
61
|
})
|
|
63
62
|
|
|
64
63
|
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith(
|
|
65
|
-
'ethereum',
|
|
66
64
|
'0xsignature',
|
|
67
65
|
expect.objectContaining({
|
|
68
66
|
source: {
|
|
@@ -83,7 +81,6 @@ describe('EVM broadcast with source', () => {
|
|
|
83
81
|
})
|
|
84
82
|
|
|
85
83
|
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith(
|
|
86
|
-
'ethereum',
|
|
87
84
|
'0xsignature',
|
|
88
85
|
expect.objectContaining({
|
|
89
86
|
mevProtected: false,
|
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
createStakingTransactionIntentMockData,
|
|
9
9
|
} from '@ledgerhq/coin-module-framework/test-utils'
|
|
10
10
|
import { BigNumber } from 'bignumber.js'
|
|
11
|
+
import { CHAIN_ID } from '../../config'
|
|
11
12
|
import {
|
|
12
13
|
createMockEvmConfigInfo,
|
|
13
14
|
mkExternalNode,
|
|
14
15
|
testLogger,
|
|
15
16
|
} from '../../fixtures/context.fixtures'
|
|
16
17
|
import { getNodeApi } from '../../network/node'
|
|
17
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
18
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
18
19
|
import { buildStakingTransactionParams } from '../../staking'
|
|
19
20
|
import { USEI_TO_EVM_SCALE } from '../../staking/utils'
|
|
20
21
|
import { getCallData, prepareUnsignedTxParams } from '../common'
|
|
@@ -37,7 +38,7 @@ jest.mock('../../network/node', () => ({
|
|
|
37
38
|
jest.mock('../../staking', () => ({
|
|
38
39
|
...jest.requireActual('../../staking'),
|
|
39
40
|
buildStakingTransactionParams: jest.fn(),
|
|
40
|
-
prepareStakingIntent: jest.fn((_config,
|
|
41
|
+
prepareStakingIntent: jest.fn((_config, intent) => Promise.resolve(intent)),
|
|
41
42
|
}))
|
|
42
43
|
|
|
43
44
|
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
@@ -50,6 +51,9 @@ const testConfig = createMockEvmConfigInfo({
|
|
|
50
51
|
node: mkExternalNode({ uri: 'https://test' }),
|
|
51
52
|
})
|
|
52
53
|
|
|
54
|
+
const seiConfig = { ...testConfig, chainId: CHAIN_ID.SEI_EVM }
|
|
55
|
+
const zeroGravityConfig = { ...testConfig, chainId: CHAIN_ID.ZERO_GRAVITY }
|
|
56
|
+
|
|
53
57
|
describe('common', () => {
|
|
54
58
|
describe('getCallData', () => {
|
|
55
59
|
beforeEach(() => {
|
|
@@ -200,21 +204,20 @@ describe('common', () => {
|
|
|
200
204
|
.mockResolvedValueOnce(new BigNumber(70_000))
|
|
201
205
|
|
|
202
206
|
const result = await prepareUnsignedTxParams(
|
|
203
|
-
|
|
204
|
-
'sei_evm',
|
|
207
|
+
seiConfig,
|
|
205
208
|
makeStakingIntent(spendableBalance),
|
|
206
209
|
testLogger
|
|
207
210
|
)
|
|
208
211
|
|
|
209
212
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
|
|
210
213
|
// First call used the full balance
|
|
211
|
-
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(1, '
|
|
214
|
+
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(1, '0xSender', {
|
|
212
215
|
amount: new BigNumber(spendableBalance.toString()),
|
|
213
216
|
recipient: stakingContractAddress,
|
|
214
217
|
data: stakingData,
|
|
215
218
|
})
|
|
216
219
|
// Retry used the minimum calldata unit for the chain (calldataAmountScale)
|
|
217
|
-
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '
|
|
220
|
+
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '0xSender', {
|
|
218
221
|
amount: new BigNumber(USEI_TO_EVM_SCALE.toString()),
|
|
219
222
|
recipient: stakingContractAddress,
|
|
220
223
|
data: stakingData,
|
|
@@ -234,15 +237,10 @@ describe('common', () => {
|
|
|
234
237
|
.mockRejectedValueOnce(GAS_ESTIMATION_ERROR)
|
|
235
238
|
.mockResolvedValueOnce(new BigNumber(70_000))
|
|
236
239
|
|
|
237
|
-
const result = await prepareUnsignedTxParams(
|
|
238
|
-
testConfig,
|
|
239
|
-
'sei_evm',
|
|
240
|
-
makeStakingIntent(0n),
|
|
241
|
-
testLogger
|
|
242
|
-
)
|
|
240
|
+
const result = await prepareUnsignedTxParams(seiConfig, makeStakingIntent(0n), testLogger)
|
|
243
241
|
|
|
244
242
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
|
|
245
|
-
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '
|
|
243
|
+
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '0xSender', {
|
|
246
244
|
amount: new BigNumber(USEI_TO_EVM_SCALE.toString()),
|
|
247
245
|
recipient: stakingContractAddress,
|
|
248
246
|
data: stakingData,
|
|
@@ -259,12 +257,7 @@ describe('common', () => {
|
|
|
259
257
|
|
|
260
258
|
nodeApiMock.getGasEstimation.mockRejectedValue(GAS_ESTIMATION_ERROR)
|
|
261
259
|
|
|
262
|
-
const result = await prepareUnsignedTxParams(
|
|
263
|
-
testConfig,
|
|
264
|
-
'sei_evm',
|
|
265
|
-
makeStakingIntent(0n),
|
|
266
|
-
testLogger
|
|
267
|
-
)
|
|
260
|
+
const result = await prepareUnsignedTxParams(seiConfig, makeStakingIntent(0n), testLogger)
|
|
268
261
|
|
|
269
262
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
|
|
270
263
|
expect(result.gasLimit).toEqual(new BigNumber(0))
|
|
@@ -289,17 +282,12 @@ describe('common', () => {
|
|
|
289
282
|
.mockRejectedValueOnce(GAS_ESTIMATION_ERROR)
|
|
290
283
|
.mockResolvedValueOnce(new BigNumber(1_412_179))
|
|
291
284
|
|
|
292
|
-
const result = await prepareUnsignedTxParams(
|
|
293
|
-
testConfig,
|
|
294
|
-
'sei_evm',
|
|
295
|
-
makeStakingIntent(0n),
|
|
296
|
-
testLogger
|
|
297
|
-
)
|
|
285
|
+
const result = await prepareUnsignedTxParams(seiConfig, makeStakingIntent(0n), testLogger)
|
|
298
286
|
|
|
299
287
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
|
|
300
288
|
// Retry rebuilds BOTH calldata and value from the min unit (USEI_TO_EVM_SCALE), so the
|
|
301
289
|
// calldata-encoded amount matches msg.value — otherwise the contract would revert.
|
|
302
|
-
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '
|
|
290
|
+
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, '0xSender', {
|
|
303
291
|
amount: new BigNumber(USEI_TO_EVM_SCALE.toString()),
|
|
304
292
|
recipient: stakingContractAddress,
|
|
305
293
|
data: Buffer.from(`delegate:${USEI_TO_EVM_SCALE.toString()}`),
|
|
@@ -318,8 +306,7 @@ describe('common', () => {
|
|
|
318
306
|
nodeApiMock.getGasEstimation.mockResolvedValueOnce(new BigNumber(237_279))
|
|
319
307
|
|
|
320
308
|
const result = await prepareUnsignedTxParams(
|
|
321
|
-
|
|
322
|
-
'zero_gravity',
|
|
309
|
+
zeroGravityConfig,
|
|
323
310
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
324
311
|
type: 'staking-eip1559',
|
|
325
312
|
mode: 'delegate',
|
|
@@ -347,8 +334,7 @@ describe('common', () => {
|
|
|
347
334
|
nodeApiMock.getGasEstimation.mockResolvedValueOnce(new BigNumber(237_279))
|
|
348
335
|
|
|
349
336
|
const result = await prepareUnsignedTxParams(
|
|
350
|
-
|
|
351
|
-
'zero_gravity',
|
|
337
|
+
zeroGravityConfig,
|
|
352
338
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
353
339
|
type: 'staking-eip1559',
|
|
354
340
|
mode: 'undelegate',
|
|
@@ -374,8 +360,7 @@ describe('common', () => {
|
|
|
374
360
|
})
|
|
375
361
|
|
|
376
362
|
const result = await prepareUnsignedTxParams(
|
|
377
|
-
|
|
378
|
-
'zero_gravity',
|
|
363
|
+
zeroGravityConfig,
|
|
379
364
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
380
365
|
type: 'staking-eip1559',
|
|
381
366
|
mode: 'delegate',
|
|
@@ -399,8 +384,7 @@ describe('common', () => {
|
|
|
399
384
|
nodeApiMock.getGasEstimation.mockRejectedValueOnce(GAS_ESTIMATION_ERROR)
|
|
400
385
|
|
|
401
386
|
const result = await prepareUnsignedTxParams(
|
|
402
|
-
|
|
403
|
-
'sei_evm',
|
|
387
|
+
seiConfig,
|
|
404
388
|
createSendTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
405
389
|
type: 'send-legacy',
|
|
406
390
|
amount: 1n,
|
|
@@ -9,9 +9,10 @@ import {
|
|
|
9
9
|
} from '@ledgerhq/coin-module-framework/test-utils'
|
|
10
10
|
import BigNumber from 'bignumber.js'
|
|
11
11
|
import { ethers } from 'ethers'
|
|
12
|
+
import { CHAIN_ID } from '../../config'
|
|
12
13
|
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
13
14
|
import { getNodeApi } from '../../network/node'
|
|
14
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
15
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
15
16
|
import { craftTransaction } from '../craftTransaction'
|
|
16
17
|
|
|
17
18
|
jest.mock('../../network/node', () => ({
|
|
@@ -29,7 +30,7 @@ describe('craftTransaction', () => {
|
|
|
29
30
|
const ledgerMocks = mockNodeApi()
|
|
30
31
|
beforeEach(() => {
|
|
31
32
|
jest.clearAllMocks()
|
|
32
|
-
mockGetNodeApi.mockImplementation((config: EvmConfigInfo
|
|
33
|
+
mockGetNodeApi.mockImplementation((config: EvmConfigInfo) => {
|
|
33
34
|
return config?.node?.type === 'ledger' ? ledgerMocks : externalMocks
|
|
34
35
|
})
|
|
35
36
|
})
|
|
@@ -376,7 +377,10 @@ describe('craftTransaction', () => {
|
|
|
376
377
|
] as const)(
|
|
377
378
|
'crafts a SEI staking delegate transaction using %s',
|
|
378
379
|
async (_, type, mocks) => {
|
|
379
|
-
const context = createMockEvmContext({
|
|
380
|
+
const context = createMockEvmContext({
|
|
381
|
+
node: nodeFor(type),
|
|
382
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
383
|
+
})
|
|
380
384
|
mocks.getTransactionCount.mockResolvedValue(25)
|
|
381
385
|
mocks.getGasEstimation.mockResolvedValue(new BigNumber(45000))
|
|
382
386
|
mocks.getFeeData.mockResolvedValue(feeData)
|
|
@@ -403,7 +407,7 @@ describe('craftTransaction', () => {
|
|
|
403
407
|
nonce: 25,
|
|
404
408
|
gasLimit: 45000n,
|
|
405
409
|
value: 1000000000000000000n,
|
|
406
|
-
chainId:
|
|
410
|
+
chainId: BigInt(CHAIN_ID.SEI_EVM),
|
|
407
411
|
})
|
|
408
412
|
expect(parsedTx.data).toMatch(/^0x[a-fA-F0-9]+$/) // encoded delegate function call
|
|
409
413
|
}
|
|
@@ -415,7 +419,10 @@ describe('craftTransaction', () => {
|
|
|
415
419
|
] as const)(
|
|
416
420
|
'crafts a SEI staking undelegate transaction using %s',
|
|
417
421
|
async (_, type, mocks) => {
|
|
418
|
-
const context = createMockEvmContext({
|
|
422
|
+
const context = createMockEvmContext({
|
|
423
|
+
node: nodeFor(type),
|
|
424
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
425
|
+
})
|
|
419
426
|
mocks.getTransactionCount.mockResolvedValue(26)
|
|
420
427
|
mocks.getGasEstimation.mockResolvedValue(new BigNumber(50000))
|
|
421
428
|
mocks.getFeeData.mockResolvedValue(feeData)
|
|
@@ -442,7 +449,7 @@ describe('craftTransaction', () => {
|
|
|
442
449
|
nonce: 26,
|
|
443
450
|
gasLimit: 50000n,
|
|
444
451
|
value: 0n, // SEI undelegate is nonpayable
|
|
445
|
-
chainId:
|
|
452
|
+
chainId: BigInt(CHAIN_ID.SEI_EVM),
|
|
446
453
|
})
|
|
447
454
|
expect(parsedTx.data).toMatch(/^0x[a-fA-F0-9]+$/) // encoded undelegate function call
|
|
448
455
|
}
|
|
@@ -503,7 +510,7 @@ describe('craftTransaction', () => {
|
|
|
503
510
|
})
|
|
504
511
|
|
|
505
512
|
it('fails to craft staking transaction with unsupported operation', async () => {
|
|
506
|
-
const context = createMockEvmContext({ node: mkExternalNode() })
|
|
513
|
+
const context = createMockEvmContext({ node: mkExternalNode(), chainId: CHAIN_ID.SEI_EVM })
|
|
507
514
|
|
|
508
515
|
await expect(
|
|
509
516
|
craftTransaction(context, 'sei_evm', {
|
|
@@ -10,11 +10,12 @@ import type {
|
|
|
10
10
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
11
11
|
import { createSendTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
|
|
12
12
|
import BigNumber from 'bignumber.js'
|
|
13
|
+
import { CHAIN_ID } from '../../config'
|
|
13
14
|
import { GasEstimationError } from '../../errors'
|
|
14
15
|
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
15
16
|
import { getGasTracker } from '../../network/gasTracker'
|
|
16
17
|
import { getNodeApi } from '../../network/node'
|
|
17
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
18
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
18
19
|
import { estimateFees } from '../estimateFees'
|
|
19
20
|
|
|
20
21
|
jest.mock('../../network/node', () => ({
|
|
@@ -52,6 +53,14 @@ describe('estimateFees', () => {
|
|
|
52
53
|
const context: EvmContext = createMockEvmContext({
|
|
53
54
|
gasTracker: { type: 'ledger', explorerId: 'eth' },
|
|
54
55
|
})
|
|
56
|
+
const optimismContext: EvmContext = createMockEvmContext({
|
|
57
|
+
chainId: CHAIN_ID.OPTIMISM,
|
|
58
|
+
gasTracker: { type: 'ledger', explorerId: 'eth' },
|
|
59
|
+
})
|
|
60
|
+
const seiContext: EvmContext = createMockEvmContext({
|
|
61
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
62
|
+
gasTracker: { type: 'ledger', explorerId: 'eth' },
|
|
63
|
+
})
|
|
55
64
|
|
|
56
65
|
beforeEach(() => {
|
|
57
66
|
jest.clearAllMocks()
|
|
@@ -389,7 +398,7 @@ describe('estimateFees', () => {
|
|
|
389
398
|
mockGetGasTracker.mockReturnValue(null)
|
|
390
399
|
nodeApiMock.getOptimismAdditionalFees.mockResolvedValue(new BigNumber(8000))
|
|
391
400
|
|
|
392
|
-
const result = await estimateFees(
|
|
401
|
+
const result = await estimateFees(optimismContext, 'optimism', {
|
|
393
402
|
intentType: 'transaction',
|
|
394
403
|
type: 'send-legacy',
|
|
395
404
|
amount: BigInt('1000000000000000000'),
|
|
@@ -424,7 +433,7 @@ describe('estimateFees', () => {
|
|
|
424
433
|
mockGetGasTracker.mockReturnValue(null)
|
|
425
434
|
nodeApiMock.getOptimismAdditionalFees.mockResolvedValue(new BigNumber(8000))
|
|
426
435
|
|
|
427
|
-
const result = await estimateFees(
|
|
436
|
+
const result = await estimateFees(optimismContext, 'optimism', {
|
|
428
437
|
intentType: 'transaction',
|
|
429
438
|
type: 'send-legacy',
|
|
430
439
|
amount: BigInt('1000000000000000000'),
|
|
@@ -450,7 +459,7 @@ describe('estimateFees', () => {
|
|
|
450
459
|
mockGetGasTracker.mockReturnValue(null)
|
|
451
460
|
nodeApiMock.getOptimismAdditionalFees.mockResolvedValue(new BigNumber(8000))
|
|
452
461
|
|
|
453
|
-
const result = await estimateFees(
|
|
462
|
+
const result = await estimateFees(optimismContext, 'optimism', {
|
|
454
463
|
intentType: 'transaction',
|
|
455
464
|
type: 'send-legacy',
|
|
456
465
|
amount: BigInt('1000000000000000000'),
|
|
@@ -494,7 +503,7 @@ describe('estimateFees', () => {
|
|
|
494
503
|
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
495
504
|
amount: 1000000n,
|
|
496
505
|
}
|
|
497
|
-
const result = await estimateFees(
|
|
506
|
+
const result = await estimateFees(seiContext, 'sei_evm', tokenIntent)
|
|
498
507
|
expect(result).toEqual({
|
|
499
508
|
value: 420000000000000n,
|
|
500
509
|
parameters: {
|
|
@@ -528,7 +537,7 @@ describe('estimateFees', () => {
|
|
|
528
537
|
amount: 1000000n,
|
|
529
538
|
useAllAmount: true,
|
|
530
539
|
}
|
|
531
|
-
const result = await estimateFees(
|
|
540
|
+
const result = await estimateFees(seiContext, 'sei_evm', delegateMaxIntent)
|
|
532
541
|
expect(result.parameters).toMatchObject({
|
|
533
542
|
reserve: 10n ** 17n, // 0.1 SEI reserve
|
|
534
543
|
amountScale: 10n ** 12n, // usei -> wei scale
|
|
@@ -546,7 +555,7 @@ describe('estimateFees', () => {
|
|
|
546
555
|
amount: 1000000n,
|
|
547
556
|
}
|
|
548
557
|
|
|
549
|
-
const result = await estimateFees(
|
|
558
|
+
const result = await estimateFees(seiContext, 'sei_evm', redelegateNoDst)
|
|
550
559
|
|
|
551
560
|
expect(result).toEqual({ value: 0n })
|
|
552
561
|
expect(mockGetNodeApi).not.toHaveBeenCalled()
|
|
@@ -573,7 +582,7 @@ describe('estimateFees', () => {
|
|
|
573
582
|
dstValAddress: 'selfvaloper1uvdqeduxvtchfphueyxraag9qkf8zfznzxs30y',
|
|
574
583
|
amount: 1000000n,
|
|
575
584
|
}
|
|
576
|
-
const result = await estimateFees(
|
|
585
|
+
const result = await estimateFees(seiContext, 'sei_evm', tokenIntent)
|
|
577
586
|
expect(result).toEqual({
|
|
578
587
|
value: 420000000000000n,
|
|
579
588
|
parameters: {
|
|
@@ -5,10 +5,11 @@ import type { EvmContext } from '../../config'
|
|
|
5
5
|
import type { ExplorerApi } from '../../network/explorer/types'
|
|
6
6
|
import type { AssetInfo } from '@ledgerhq/coin-module-framework/api/types'
|
|
7
7
|
import BigNumber from 'bignumber.js'
|
|
8
|
+
import { CHAIN_ID } from '../../config'
|
|
8
9
|
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
9
10
|
import { getExplorerApi } from '../../network/explorer'
|
|
10
11
|
import { getNodeApi } from '../../network/node'
|
|
11
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
12
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
12
13
|
import { getStakes } from '../getStakes'
|
|
13
14
|
import { getBalance } from '../index'
|
|
14
15
|
|
|
@@ -115,9 +116,8 @@ describe('getBalance', () => {
|
|
|
115
116
|
'returns %s',
|
|
116
117
|
async (_, discoveredAssets: AssetInfo[], tokenBalances: Record<string, string>, expected) => {
|
|
117
118
|
nodeApiMock.getCoinBalance.mockResolvedValue(new BigNumber('10000000000000000000000'))
|
|
118
|
-
nodeApiMock.getTokenBalance.mockImplementation(
|
|
119
|
-
(
|
|
120
|
-
Promise.resolve(new BigNumber(tokenBalances[contractAddress] || '0'))
|
|
119
|
+
nodeApiMock.getTokenBalance.mockImplementation((_address: string, contractAddress: string) =>
|
|
120
|
+
Promise.resolve(new BigNumber(tokenBalances[contractAddress] || '0'))
|
|
121
121
|
)
|
|
122
122
|
|
|
123
123
|
mockGetExplorerApi.mockReturnValue(explorerWithDiscovery(discoveredAssets))
|
|
@@ -198,7 +198,6 @@ describe('getBalance', () => {
|
|
|
198
198
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(expected.length)
|
|
199
199
|
for (const balance of expected) {
|
|
200
200
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith(
|
|
201
|
-
currency,
|
|
202
201
|
userAddress,
|
|
203
202
|
balance.asset.assetReference
|
|
204
203
|
)
|
|
@@ -213,7 +212,6 @@ describe('getBalance', () => {
|
|
|
213
212
|
expect(notSupportedTokens).not.toHaveLength(0)
|
|
214
213
|
for (const asset of notSupportedTokens) {
|
|
215
214
|
expect(nodeApiMock.getTokenBalance).not.toHaveBeenCalledWith(
|
|
216
|
-
currency,
|
|
217
215
|
userAddress,
|
|
218
216
|
'assetReference' in asset ? asset.assetReference : undefined
|
|
219
217
|
)
|
|
@@ -223,14 +221,12 @@ describe('getBalance', () => {
|
|
|
223
221
|
|
|
224
222
|
it('is resilient when failing to fetch token balances', async () => {
|
|
225
223
|
nodeApiMock.getCoinBalance.mockResolvedValue(new BigNumber(10))
|
|
226
|
-
nodeApiMock.getTokenBalance.mockImplementation(
|
|
227
|
-
(
|
|
228
|
-
|
|
229
|
-
return Promise.reject(new Error('Scam token'))
|
|
230
|
-
}
|
|
231
|
-
return Promise.resolve(new BigNumber(2))
|
|
224
|
+
nodeApiMock.getTokenBalance.mockImplementation((_address: string, contract: string) => {
|
|
225
|
+
if (contract === 'contract2') {
|
|
226
|
+
return Promise.reject(new Error('Scam token'))
|
|
232
227
|
}
|
|
233
|
-
|
|
228
|
+
return Promise.resolve(new BigNumber(2))
|
|
229
|
+
})
|
|
234
230
|
mockGetExplorerApi.mockReturnValue(
|
|
235
231
|
explorerWithDiscovery([
|
|
236
232
|
{ type: 'erc20', assetReference: 'contract1' },
|
|
@@ -275,13 +271,8 @@ describe('getBalance', () => {
|
|
|
275
271
|
const result = await getBalance(context, '', 'address')
|
|
276
272
|
|
|
277
273
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(1)
|
|
278
|
-
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith(
|
|
279
|
-
expect.anything(),
|
|
280
|
-
'address',
|
|
281
|
-
REGULAR_CONTRACT
|
|
282
|
-
)
|
|
274
|
+
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith('address', REGULAR_CONTRACT)
|
|
283
275
|
expect(nodeApiMock.getTokenBalance).not.toHaveBeenCalledWith(
|
|
284
|
-
expect.anything(),
|
|
285
276
|
expect.anything(),
|
|
286
277
|
NATIVE_CONTRACT
|
|
287
278
|
)
|
|
@@ -376,11 +367,7 @@ describe('getBalance', () => {
|
|
|
376
367
|
|
|
377
368
|
const result = await getBalance(context, '', 'address', { knownAssets })
|
|
378
369
|
|
|
379
|
-
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith(
|
|
380
|
-
expect.anything(),
|
|
381
|
-
'address',
|
|
382
|
-
'0xknown'
|
|
383
|
-
)
|
|
370
|
+
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith('address', '0xknown')
|
|
384
371
|
expect(result).toEqual([
|
|
385
372
|
{ asset: { type: 'native' }, value: 0n },
|
|
386
373
|
{ asset: { type: 'erc20', assetReference: '0xknown', assetOwner: 'address' }, value: 7n },
|
|
@@ -429,7 +416,6 @@ describe('getBalance', () => {
|
|
|
429
416
|
expect(discoverTokenAssets).toHaveBeenCalledWith(
|
|
430
417
|
expect.anything(),
|
|
431
418
|
expect.anything(),
|
|
432
|
-
'currency',
|
|
433
419
|
'address',
|
|
434
420
|
12345
|
|
435
421
|
)
|
|
@@ -448,7 +434,6 @@ describe('getBalance', () => {
|
|
|
448
434
|
expect(discoverTokenAssets).toHaveBeenCalledWith(
|
|
449
435
|
expect.anything(),
|
|
450
436
|
expect.anything(),
|
|
451
|
-
'currency',
|
|
452
437
|
'address',
|
|
453
438
|
undefined
|
|
454
439
|
)
|
|
@@ -472,11 +457,7 @@ describe('getBalance', () => {
|
|
|
472
457
|
})
|
|
473
458
|
|
|
474
459
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(1)
|
|
475
|
-
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith(
|
|
476
|
-
expect.anything(),
|
|
477
|
-
'address',
|
|
478
|
-
'0xkept'
|
|
479
|
-
)
|
|
460
|
+
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith('address', '0xkept')
|
|
480
461
|
expect(result).toEqual([
|
|
481
462
|
{ asset: { type: 'native' }, value: 0n },
|
|
482
463
|
{ asset: { type: 'erc20', assetReference: '0xkept', assetOwner: 'address' }, value: 1n },
|
|
@@ -531,6 +512,8 @@ describe('getBalance', () => {
|
|
|
531
512
|
// source — the account's history is walked once, not twice, and `discoverTokenAssets` is
|
|
532
513
|
// never called.
|
|
533
514
|
describe('known-validator wiring (monad)', () => {
|
|
515
|
+
const monadContext = createMockEvmContext({ chainId: CHAIN_ID.MONAD })
|
|
516
|
+
|
|
534
517
|
it('derives token balances from getOperations and never calls discoverTokenAssets', async () => {
|
|
535
518
|
nodeApiMock.getCoinBalance.mockResolvedValue(new BigNumber('0'))
|
|
536
519
|
nodeApiMock.getTokenBalance.mockResolvedValue(new BigNumber('4'))
|
|
@@ -550,14 +533,13 @@ describe('getBalance', () => {
|
|
|
550
533
|
const discoverTokenAssets = jest.fn()
|
|
551
534
|
mockGetExplorerApi.mockReturnValue({ getOperations, discoverTokenAssets })
|
|
552
535
|
|
|
553
|
-
const result = await getBalance(
|
|
536
|
+
const result = await getBalance(monadContext, 'monad', 'address')
|
|
554
537
|
|
|
555
538
|
// The explorer's `getOperations` takes the logger as its second argument; the walk this
|
|
556
539
|
// branch reuses passes it like every other caller.
|
|
557
540
|
expect(getOperations).toHaveBeenCalledWith(
|
|
558
541
|
expect.anything(),
|
|
559
542
|
expect.anything(),
|
|
560
|
-
'monad',
|
|
561
543
|
'address',
|
|
562
544
|
0,
|
|
563
545
|
undefined,
|
|
@@ -598,7 +580,9 @@ describe('getBalance', () => {
|
|
|
598
580
|
discoverTokenAssets: jest.fn(),
|
|
599
581
|
})
|
|
600
582
|
|
|
601
|
-
await expect(getBalance(
|
|
583
|
+
await expect(getBalance(monadContext, 'monad', 'address')).rejects.toThrow(
|
|
584
|
+
'explorer unavailable'
|
|
585
|
+
)
|
|
602
586
|
})
|
|
603
587
|
})
|
|
604
588
|
})
|