@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
|
@@ -6,15 +6,16 @@ import type { TransactionRequest } from 'ethers'
|
|
|
6
6
|
import network from '@ledgerhq/live-network'
|
|
7
7
|
import { ethers } from 'ethers'
|
|
8
8
|
import zeroGravityAbi from '../../abis/zero_gravity-validator.abi.json'
|
|
9
|
+
import { CHAIN_ID } from '../../config'
|
|
9
10
|
import {
|
|
10
11
|
createMockEvmConfigInfo,
|
|
11
12
|
mkExternalNode,
|
|
12
13
|
testLogger,
|
|
13
14
|
} from '../../fixtures/context.fixtures'
|
|
14
15
|
import { mkJsonRpcProvider } from '../../fixtures/ethers.fixtures'
|
|
16
|
+
import { requireStakingContract } from '../../fixtures/staking.fixtures'
|
|
15
17
|
import { withApi } from '../../network/node/rpc.common'
|
|
16
18
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
17
|
-
import { STAKING_CONTRACTS } from '../../staking/contracts'
|
|
18
19
|
import { fetchZeroGravityStakes } from './zero_gravity'
|
|
19
20
|
import { clearValidatorsCache, getValidators } from './index'
|
|
20
21
|
|
|
@@ -33,10 +34,12 @@ const mockedWithApi = jest.mocked(withApi)
|
|
|
33
34
|
const mockedIsExternalNodeConfig = jest.mocked(isExternalNodeConfig)
|
|
34
35
|
|
|
35
36
|
const mockConfig = createMockEvmConfigInfo({
|
|
36
|
-
chainId:
|
|
37
|
+
chainId: CHAIN_ID.ZERO_GRAVITY,
|
|
37
38
|
node: mkExternalNode({ uri: 'https://zero-gravity.coin.ledger.com' }),
|
|
38
39
|
})
|
|
39
40
|
|
|
41
|
+
const zeroGravityContract = requireStakingContract(CHAIN_ID.ZERO_GRAVITY)
|
|
42
|
+
|
|
40
43
|
const makeValidator = (
|
|
41
44
|
overrides: Partial<{
|
|
42
45
|
addr: string
|
|
@@ -55,14 +58,14 @@ const makeValidator = (
|
|
|
55
58
|
describe('staking/validators/zero_gravity', () => {
|
|
56
59
|
beforeEach(() => {
|
|
57
60
|
jest.clearAllMocks()
|
|
58
|
-
clearValidatorsCache(
|
|
61
|
+
clearValidatorsCache(CHAIN_ID.ZERO_GRAVITY)
|
|
59
62
|
})
|
|
60
63
|
|
|
61
64
|
it('maps addr to validatorAddress with 0x prefix', async () => {
|
|
62
65
|
const addr = 'aabbccddee' + '00'.repeat(15)
|
|
63
66
|
mockedNetwork.mockResolvedValueOnce({ data: [makeValidator({ addr })] })
|
|
64
67
|
|
|
65
|
-
const page = await getValidators(mockConfig,
|
|
68
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
66
69
|
|
|
67
70
|
expect(page.items[0].address).toEqual(ethers.getAddress('0x' + addr))
|
|
68
71
|
})
|
|
@@ -72,7 +75,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
72
75
|
data: [makeValidator({ moniker: 'MyNode' })],
|
|
73
76
|
})
|
|
74
77
|
|
|
75
|
-
const page = await getValidators(mockConfig,
|
|
78
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
76
79
|
|
|
77
80
|
expect(page.items[0].name).toEqual('MyNode')
|
|
78
81
|
})
|
|
@@ -83,7 +86,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
83
86
|
data: [makeValidator({ addr, moniker: null })],
|
|
84
87
|
})
|
|
85
88
|
|
|
86
|
-
const page = await getValidators(mockConfig,
|
|
89
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
87
90
|
|
|
88
91
|
expect(page.items[0].name).toEqual(ethers.getAddress('0x' + addr))
|
|
89
92
|
})
|
|
@@ -93,7 +96,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
93
96
|
data: [makeValidator({ commission_pct: '5.00' })],
|
|
94
97
|
})
|
|
95
98
|
|
|
96
|
-
const page = await getValidators(mockConfig,
|
|
99
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
97
100
|
|
|
98
101
|
expect(page.items[0].commissionRate).toEqual('0.05')
|
|
99
102
|
})
|
|
@@ -103,7 +106,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
103
106
|
data: [makeValidator({ voting_power_tokens: '42000000000000000000' })],
|
|
104
107
|
})
|
|
105
108
|
|
|
106
|
-
const page = await getValidators(mockConfig,
|
|
109
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
107
110
|
|
|
108
111
|
expect(page.items[0].balance).toEqual(42000000000000000000n)
|
|
109
112
|
})
|
|
@@ -111,7 +114,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
111
114
|
it('returns empty page on network error', async () => {
|
|
112
115
|
mockedNetwork.mockRejectedValueOnce(new Error('network failure'))
|
|
113
116
|
|
|
114
|
-
const page = await getValidators(mockConfig,
|
|
117
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
115
118
|
|
|
116
119
|
expect(page).toEqual({ items: [], next: undefined })
|
|
117
120
|
})
|
|
@@ -119,7 +122,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
119
122
|
it('always returns next: undefined (single-page API)', async () => {
|
|
120
123
|
mockedNetwork.mockResolvedValueOnce({ data: [makeValidator()] })
|
|
121
124
|
|
|
122
|
-
const page = await getValidators(mockConfig,
|
|
125
|
+
const page = await getValidators(mockConfig, testLogger)
|
|
123
126
|
|
|
124
127
|
expect(page.next).toBeUndefined()
|
|
125
128
|
})
|
|
@@ -128,7 +131,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
128
131
|
const DELEGATOR = '0x' + '11'.repeat(20)
|
|
129
132
|
const VALIDATOR_ADDR = ethers.getAddress('0xaabbccddee' + '00'.repeat(15))
|
|
130
133
|
const zgConfig = createMockEvmConfigInfo({
|
|
131
|
-
chainId:
|
|
134
|
+
chainId: CHAIN_ID.ZERO_GRAVITY,
|
|
132
135
|
name: '0G',
|
|
133
136
|
unit: { name: '0G', code: '0G', magnitude: 18 },
|
|
134
137
|
node: mkExternalNode({ uri: 'https://zero-gravity.coin.ledger.com' }),
|
|
@@ -180,7 +183,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
function setupProvider(callHandler: (_tx: TransactionRequest) => Promise<string>) {
|
|
183
|
-
mockedWithApi.mockImplementation(async (_config,
|
|
186
|
+
mockedWithApi.mockImplementation(async (_config, fn) => {
|
|
184
187
|
const api = mkJsonRpcProvider()
|
|
185
188
|
jest.spyOn(api, 'call').mockImplementation(callHandler)
|
|
186
189
|
jest.spyOn(api, 'getBlockNumber').mockResolvedValue(Number(CURRENT_BLOCK))
|
|
@@ -199,8 +202,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
199
202
|
const stakes = await fetchZeroGravityStakes(
|
|
200
203
|
zgConfig,
|
|
201
204
|
DELEGATOR,
|
|
202
|
-
|
|
203
|
-
'zero_gravity',
|
|
205
|
+
zeroGravityContract,
|
|
204
206
|
testLogger
|
|
205
207
|
)
|
|
206
208
|
|
|
@@ -221,8 +223,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
221
223
|
const stakes = await fetchZeroGravityStakes(
|
|
222
224
|
zgConfig,
|
|
223
225
|
DELEGATOR,
|
|
224
|
-
|
|
225
|
-
'zero_gravity',
|
|
226
|
+
zeroGravityContract,
|
|
226
227
|
testLogger
|
|
227
228
|
)
|
|
228
229
|
|
|
@@ -235,8 +236,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
235
236
|
const stakes = await fetchZeroGravityStakes(
|
|
236
237
|
zgConfig,
|
|
237
238
|
DELEGATOR,
|
|
238
|
-
|
|
239
|
-
'zero_gravity',
|
|
239
|
+
zeroGravityContract,
|
|
240
240
|
testLogger
|
|
241
241
|
)
|
|
242
242
|
|
|
@@ -249,8 +249,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
249
249
|
const stakes = await fetchZeroGravityStakes(
|
|
250
250
|
zgConfig,
|
|
251
251
|
DELEGATOR,
|
|
252
|
-
|
|
253
|
-
'zero_gravity',
|
|
252
|
+
zeroGravityContract,
|
|
254
253
|
testLogger
|
|
255
254
|
)
|
|
256
255
|
|
|
@@ -279,8 +278,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
279
278
|
const stakes = await fetchZeroGravityStakes(
|
|
280
279
|
zgConfig,
|
|
281
280
|
DELEGATOR,
|
|
282
|
-
|
|
283
|
-
'zero_gravity',
|
|
281
|
+
zeroGravityContract,
|
|
284
282
|
testLogger
|
|
285
283
|
)
|
|
286
284
|
|
|
@@ -293,8 +291,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
293
291
|
const stakes = await fetchZeroGravityStakes(
|
|
294
292
|
zgConfig,
|
|
295
293
|
DELEGATOR,
|
|
296
|
-
|
|
297
|
-
'zero_gravity',
|
|
294
|
+
zeroGravityContract,
|
|
298
295
|
testLogger
|
|
299
296
|
)
|
|
300
297
|
|
|
@@ -323,8 +320,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
323
320
|
const stakes = await fetchZeroGravityStakes(
|
|
324
321
|
zgConfig,
|
|
325
322
|
DELEGATOR,
|
|
326
|
-
|
|
327
|
-
'zero_gravity',
|
|
323
|
+
zeroGravityContract,
|
|
328
324
|
testLogger
|
|
329
325
|
)
|
|
330
326
|
|
|
@@ -337,8 +333,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
337
333
|
const stakes = await fetchZeroGravityStakes(
|
|
338
334
|
zgConfig,
|
|
339
335
|
DELEGATOR,
|
|
340
|
-
|
|
341
|
-
'zero_gravity',
|
|
336
|
+
zeroGravityContract,
|
|
342
337
|
testLogger
|
|
343
338
|
)
|
|
344
339
|
|
|
@@ -351,8 +346,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
351
346
|
const stakes = await fetchZeroGravityStakes(
|
|
352
347
|
zgConfig,
|
|
353
348
|
DELEGATOR,
|
|
354
|
-
|
|
355
|
-
'zero_gravity',
|
|
349
|
+
zeroGravityContract,
|
|
356
350
|
testLogger
|
|
357
351
|
)
|
|
358
352
|
|
|
@@ -360,7 +354,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
360
354
|
})
|
|
361
355
|
|
|
362
356
|
it('handles a rejected getDelegation call without throwing', async () => {
|
|
363
|
-
mockedWithApi.mockImplementation(async (_config,
|
|
357
|
+
mockedWithApi.mockImplementation(async (_config, fn) => {
|
|
364
358
|
const api = mkJsonRpcProvider()
|
|
365
359
|
jest.spyOn(api, 'call').mockRejectedValue(new Error('RPC error'))
|
|
366
360
|
return fn(api)
|
|
@@ -369,8 +363,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
369
363
|
const stakes = await fetchZeroGravityStakes(
|
|
370
364
|
zgConfig,
|
|
371
365
|
DELEGATOR,
|
|
372
|
-
|
|
373
|
-
'zero_gravity',
|
|
366
|
+
zeroGravityContract,
|
|
374
367
|
testLogger
|
|
375
368
|
)
|
|
376
369
|
|
|
@@ -391,8 +384,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
391
384
|
const stakes = await fetchZeroGravityStakes(
|
|
392
385
|
zgConfig,
|
|
393
386
|
DELEGATOR,
|
|
394
|
-
|
|
395
|
-
'zero_gravity',
|
|
387
|
+
zeroGravityContract,
|
|
396
388
|
testLogger
|
|
397
389
|
)
|
|
398
390
|
|
|
@@ -405,8 +397,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
405
397
|
const stakes = await fetchZeroGravityStakes(
|
|
406
398
|
zgConfig,
|
|
407
399
|
DELEGATOR,
|
|
408
|
-
|
|
409
|
-
'zero_gravity',
|
|
400
|
+
zeroGravityContract,
|
|
410
401
|
testLogger
|
|
411
402
|
)
|
|
412
403
|
|
|
@@ -435,8 +426,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
435
426
|
const stakes = await fetchZeroGravityStakes(
|
|
436
427
|
zgConfig,
|
|
437
428
|
DELEGATOR,
|
|
438
|
-
|
|
439
|
-
'zero_gravity',
|
|
429
|
+
zeroGravityContract,
|
|
440
430
|
testLogger
|
|
441
431
|
)
|
|
442
432
|
|
|
@@ -462,8 +452,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
462
452
|
const stakes = await fetchZeroGravityStakes(
|
|
463
453
|
zgConfig,
|
|
464
454
|
DELEGATOR,
|
|
465
|
-
|
|
466
|
-
'zero_gravity',
|
|
455
|
+
zeroGravityContract,
|
|
467
456
|
testLogger
|
|
468
457
|
)
|
|
469
458
|
|
|
@@ -476,8 +465,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
476
465
|
const stakes = await fetchZeroGravityStakes(
|
|
477
466
|
zgConfig,
|
|
478
467
|
DELEGATOR,
|
|
479
|
-
|
|
480
|
-
'zero_gravity',
|
|
468
|
+
zeroGravityContract,
|
|
481
469
|
testLogger
|
|
482
470
|
)
|
|
483
471
|
|
|
@@ -490,8 +478,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
490
478
|
const stakes = await fetchZeroGravityStakes(
|
|
491
479
|
zgConfig,
|
|
492
480
|
DELEGATOR,
|
|
493
|
-
|
|
494
|
-
'zero_gravity',
|
|
481
|
+
zeroGravityContract,
|
|
495
482
|
testLogger
|
|
496
483
|
)
|
|
497
484
|
|
|
@@ -505,8 +492,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
505
492
|
const stakes = await fetchZeroGravityStakes(
|
|
506
493
|
zgConfig,
|
|
507
494
|
DELEGATOR,
|
|
508
|
-
|
|
509
|
-
'zero_gravity',
|
|
495
|
+
zeroGravityContract,
|
|
510
496
|
testLogger
|
|
511
497
|
)
|
|
512
498
|
|
|
@@ -560,8 +546,7 @@ describe('staking/validators/zero_gravity', () => {
|
|
|
560
546
|
const stakes = await fetchZeroGravityStakes(
|
|
561
547
|
zgConfig,
|
|
562
548
|
DELEGATOR,
|
|
563
|
-
|
|
564
|
-
'zero_gravity',
|
|
549
|
+
zeroGravityContract,
|
|
565
550
|
testLogger
|
|
566
551
|
)
|
|
567
552
|
|
|
@@ -40,8 +40,8 @@ function isExploreMe0gValidator(value: unknown): value is ExploreMe0gValidator {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const zeroGravityValidatorApi: ValidatorApi = {
|
|
43
|
-
fetchValidators: async (
|
|
44
|
-
const apiConfig = STAKING_CONTRACTS[
|
|
43
|
+
fetchValidators: async (config, logger, _cursor): Promise<Page<Validator>> => {
|
|
44
|
+
const apiConfig = STAKING_CONTRACTS[config.chainId]?.apiConfig
|
|
45
45
|
if (!apiConfig?.baseUrl) return { items: [], next: undefined }
|
|
46
46
|
|
|
47
47
|
const { baseUrl, validatorsEndpoint } = apiConfig
|
|
@@ -214,21 +214,16 @@ export const fetchZeroGravityStakes = async (
|
|
|
214
214
|
evmConfig: EvmConfigInfo,
|
|
215
215
|
address: string,
|
|
216
216
|
_config: StakingContractConfig,
|
|
217
|
-
currencyId: string,
|
|
218
217
|
logger: Logger,
|
|
219
218
|
_knownValIds?: string[]
|
|
220
219
|
): Promise<Stake[]> => {
|
|
221
|
-
const abi = getStakingABI(
|
|
220
|
+
const abi = getStakingABI(evmConfig.chainId)
|
|
222
221
|
if (!abi) return []
|
|
223
222
|
|
|
224
223
|
const node = evmConfig.node
|
|
225
224
|
if (!isExternalNodeConfig(node)) return []
|
|
226
225
|
|
|
227
|
-
const { items: validators } = await zeroGravityValidatorApi.fetchValidators(
|
|
228
|
-
evmConfig,
|
|
229
|
-
currencyId,
|
|
230
|
-
logger
|
|
231
|
-
)
|
|
226
|
+
const { items: validators } = await zeroGravityValidatorApi.fetchValidators(evmConfig, logger)
|
|
232
227
|
if (validators.length === 0) return []
|
|
233
228
|
|
|
234
229
|
const asset: AssetInfo = {
|
|
@@ -240,7 +235,6 @@ export const fetchZeroGravityStakes = async (
|
|
|
240
235
|
try {
|
|
241
236
|
return await withApi(
|
|
242
237
|
evmConfig,
|
|
243
|
-
currencyId,
|
|
244
238
|
async (provider) => {
|
|
245
239
|
const iface = new ethers.Interface(toInterfaceAbi(abi))
|
|
246
240
|
const stakes: Stake[] = []
|
|
@@ -294,7 +288,7 @@ export const fetchZeroGravityStakes = async (
|
|
|
294
288
|
)
|
|
295
289
|
} catch (error) {
|
|
296
290
|
logger('coin-evm/staking', 'fetchZeroGravityStakes: delegations fetch failed', {
|
|
297
|
-
|
|
291
|
+
currency: evmConfig.name,
|
|
298
292
|
error: error instanceof Error ? error.message : String(error),
|
|
299
293
|
})
|
|
300
294
|
return []
|
|
@@ -27,16 +27,14 @@ describe('getValidators', () => {
|
|
|
27
27
|
node: mkExternalNode({ uri: 'https://api.infra.mainnet.somnia.network' }),
|
|
28
28
|
}),
|
|
29
29
|
],
|
|
30
|
-
])("fetches validators on '%s'", async (
|
|
31
|
-
const firstPage = await getValidators(config.info,
|
|
30
|
+
])("fetches validators on '%s'", async (_currencyId, config) => {
|
|
31
|
+
const firstPage = await getValidators(config.info, testLogger)
|
|
32
32
|
expect(firstPage.items.length).toBeGreaterThan(0)
|
|
33
33
|
|
|
34
34
|
const validator = firstPage.items[0]
|
|
35
35
|
expect(validator.address).toMatch(/^0x[0-9a-fA-F]{40}$/)
|
|
36
|
-
//
|
|
37
|
-
// fallback — both are non-empty strings.
|
|
36
|
+
// Validator names are strings, but some networks may return an empty name.
|
|
38
37
|
expect(typeof validator.name).toBe('string')
|
|
39
|
-
expect(validator.name.length).toBeGreaterThan(0)
|
|
40
38
|
expect(validator.balance).toBeGreaterThan(0n)
|
|
41
39
|
expect(parseFloat(validator.commissionRate ?? '0')).toBeGreaterThanOrEqual(0)
|
|
42
40
|
expect(parseFloat(validator.commissionRate ?? '0')).toBeLessThanOrEqual(1)
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
5
|
import network from '@ledgerhq/live-network'
|
|
6
|
+
import { CHAIN_ID } from '../config'
|
|
6
7
|
import { createMockEvmContext, testLogger } from '../fixtures/context.fixtures'
|
|
7
8
|
import {
|
|
8
9
|
clearValidatorsCache,
|
|
@@ -26,7 +27,7 @@ const mockedNetwork = jest.mocked(network)
|
|
|
26
27
|
|
|
27
28
|
const mockConfig: EvmConfigInfo = {
|
|
28
29
|
status: { type: 'active' },
|
|
29
|
-
chainId:
|
|
30
|
+
chainId: CHAIN_ID.SEI_EVM,
|
|
30
31
|
name: 'Test EVM',
|
|
31
32
|
unit: { name: 'test', code: 'TEST', magnitude: 18 },
|
|
32
33
|
node: { type: 'external', uri: 'https://sei-evm.coin.ledger.com' },
|
|
@@ -63,7 +64,7 @@ describe('staking/validators', () => {
|
|
|
63
64
|
it('fetches Sei validators from REST and caches non-empty results', async () => {
|
|
64
65
|
mockedNetwork.mockResolvedValue(cosmosValidatorsPayload)
|
|
65
66
|
|
|
66
|
-
const first = await getValidators(mockConfig,
|
|
67
|
+
const first = await getValidators(mockConfig, testLogger)
|
|
67
68
|
|
|
68
69
|
expect(mockedNetwork).toHaveBeenCalledWith(
|
|
69
70
|
expect.objectContaining({
|
|
@@ -94,41 +95,41 @@ describe('staking/validators', () => {
|
|
|
94
95
|
next: undefined,
|
|
95
96
|
})
|
|
96
97
|
|
|
97
|
-
expect(await getValidators(mockConfig,
|
|
98
|
+
expect(await getValidators(mockConfig, testLogger)).toEqual(first)
|
|
98
99
|
expect(mockedNetwork).toHaveBeenCalledTimes(1)
|
|
99
100
|
})
|
|
100
101
|
|
|
101
102
|
it('caches each cursor page under a separate key', async () => {
|
|
102
103
|
mockedNetwork.mockResolvedValue(cosmosValidatorsPayload)
|
|
103
104
|
|
|
104
|
-
await getValidators(mockConfig,
|
|
105
|
-
await getValidators(mockConfig,
|
|
105
|
+
await getValidators(mockConfig, testLogger)
|
|
106
|
+
await getValidators(mockConfig, testLogger, '5')
|
|
106
107
|
expect(mockedNetwork).toHaveBeenCalledTimes(2)
|
|
107
108
|
|
|
108
|
-
await getValidators(mockConfig,
|
|
109
|
-
await getValidators(mockConfig,
|
|
109
|
+
await getValidators(mockConfig, testLogger)
|
|
110
|
+
await getValidators(mockConfig, testLogger, '5')
|
|
110
111
|
expect(mockedNetwork).toHaveBeenCalledTimes(2)
|
|
111
112
|
})
|
|
112
113
|
|
|
113
|
-
it('clearValidatorsCache(
|
|
114
|
+
it('clearValidatorsCache(chainId) evicts every cached page of that chain', async () => {
|
|
114
115
|
mockedNetwork.mockResolvedValue(cosmosValidatorsPayload)
|
|
115
116
|
|
|
116
|
-
await getValidators(mockConfig,
|
|
117
|
-
await getValidators(mockConfig,
|
|
117
|
+
await getValidators(mockConfig, testLogger)
|
|
118
|
+
await getValidators(mockConfig, testLogger, '5')
|
|
118
119
|
expect(mockedNetwork).toHaveBeenCalledTimes(2)
|
|
119
120
|
|
|
120
|
-
clearValidatorsCache(
|
|
121
|
+
clearValidatorsCache(CHAIN_ID.SEI_EVM)
|
|
121
122
|
|
|
122
|
-
await getValidators(mockConfig,
|
|
123
|
-
await getValidators(mockConfig,
|
|
123
|
+
await getValidators(mockConfig, testLogger)
|
|
124
|
+
await getValidators(mockConfig, testLogger, '5')
|
|
124
125
|
expect(mockedNetwork).toHaveBeenCalledTimes(4)
|
|
125
126
|
})
|
|
126
127
|
|
|
127
128
|
it('returns cached data without a second network call while fresh', async () => {
|
|
128
129
|
mockedNetwork.mockResolvedValue(cosmosValidatorsPayload)
|
|
129
130
|
|
|
130
|
-
await getValidators(mockConfig,
|
|
131
|
-
await getValidators(mockConfig,
|
|
131
|
+
await getValidators(mockConfig, testLogger)
|
|
132
|
+
await getValidators(mockConfig, testLogger)
|
|
132
133
|
|
|
133
134
|
expect(mockedNetwork).toHaveBeenCalledTimes(1)
|
|
134
135
|
})
|
|
@@ -137,8 +138,8 @@ describe('staking/validators', () => {
|
|
|
137
138
|
mockedNetwork.mockResolvedValue(cosmosValidatorsPayload)
|
|
138
139
|
|
|
139
140
|
await Promise.all([
|
|
140
|
-
getValidators(mockConfig,
|
|
141
|
-
getValidators(mockConfig,
|
|
141
|
+
getValidators(mockConfig, testLogger),
|
|
142
|
+
getValidators(mockConfig, testLogger),
|
|
142
143
|
])
|
|
143
144
|
|
|
144
145
|
expect(mockedNetwork).toHaveBeenCalledTimes(1)
|
|
@@ -147,15 +148,17 @@ describe('staking/validators', () => {
|
|
|
147
148
|
it('does not cache an empty validator list', async () => {
|
|
148
149
|
mockedNetwork.mockResolvedValue({ status: 200, data: { validators: [] } })
|
|
149
150
|
|
|
150
|
-
await getValidators(mockConfig,
|
|
151
|
-
await getValidators(mockConfig,
|
|
151
|
+
await getValidators(mockConfig, testLogger)
|
|
152
|
+
await getValidators(mockConfig, testLogger)
|
|
152
153
|
|
|
153
154
|
// empty results are not cached, so each call hits the network again
|
|
154
155
|
expect(mockedNetwork).toHaveBeenCalledTimes(2)
|
|
155
156
|
})
|
|
156
157
|
|
|
157
158
|
it('returns an empty page for currencies without a validator API', async () => {
|
|
158
|
-
expect(
|
|
159
|
+
expect(
|
|
160
|
+
await getValidators({ ...mockConfig, chainId: CHAIN_ID.ETHEREUM }, testLogger)
|
|
161
|
+
).toEqual({
|
|
159
162
|
items: [],
|
|
160
163
|
next: undefined,
|
|
161
164
|
})
|
|
@@ -171,11 +174,11 @@ describe('staking/validators', () => {
|
|
|
171
174
|
mockedNetwork.mockImplementationOnce(() => firstPending)
|
|
172
175
|
mockedNetwork.mockResolvedValue(cosmosValidatorsPayload)
|
|
173
176
|
|
|
174
|
-
const firstCall = getValidators(mockConfig,
|
|
177
|
+
const firstCall = getValidators(mockConfig, testLogger)
|
|
175
178
|
|
|
176
|
-
clearValidatorsCache(
|
|
179
|
+
clearValidatorsCache(CHAIN_ID.SEI_EVM)
|
|
177
180
|
|
|
178
|
-
const second = await getValidators(mockConfig,
|
|
181
|
+
const second = await getValidators(mockConfig, testLogger)
|
|
179
182
|
|
|
180
183
|
expect(second).toEqual({
|
|
181
184
|
items: [
|
|
@@ -214,7 +217,7 @@ describe('staking/validators', () => {
|
|
|
214
217
|
|
|
215
218
|
// non-zero base: lru-cache treats a start time of 0 as "no TTL"
|
|
216
219
|
setNow(1000)
|
|
217
|
-
await getValidators(mockConfig,
|
|
220
|
+
await getValidators(mockConfig, testLogger)
|
|
218
221
|
expect(mockedNetwork).toHaveBeenCalledTimes(1)
|
|
219
222
|
|
|
220
223
|
// lru-cache debounces its clock read for `ttlResolution` (1ms) via a real
|
|
@@ -222,7 +225,7 @@ describe('staking/validators', () => {
|
|
|
222
225
|
await new Promise((resolve) => setTimeout(resolve, 5))
|
|
223
226
|
|
|
224
227
|
setNow(32000) // 31s later, past the 30s TTL
|
|
225
|
-
await getValidators(mockConfig,
|
|
228
|
+
await getValidators(mockConfig, testLogger)
|
|
226
229
|
|
|
227
230
|
expect(mockedNetwork).toHaveBeenCalledTimes(2)
|
|
228
231
|
})
|
|
@@ -232,23 +235,23 @@ describe('staking/validators', () => {
|
|
|
232
235
|
it('warms the cache so a later read hits no network', async () => {
|
|
233
236
|
mockedNetwork.mockResolvedValue(cosmosValidatorsPayload)
|
|
234
237
|
|
|
235
|
-
prefetchValidators(mockConfig,
|
|
238
|
+
prefetchValidators(mockConfig, testLogger)
|
|
236
239
|
await Promise.resolve()
|
|
237
240
|
await Promise.resolve()
|
|
238
241
|
expect(mockedNetwork).toHaveBeenCalledTimes(1)
|
|
239
242
|
|
|
240
243
|
// the warmed entry serves the subsequent read without another network call
|
|
241
|
-
await getValidators(mockConfig,
|
|
244
|
+
await getValidators(mockConfig, testLogger)
|
|
242
245
|
expect(mockedNetwork).toHaveBeenCalledTimes(1)
|
|
243
246
|
})
|
|
244
247
|
|
|
245
248
|
it('is a no-op when cache is already fresh', async () => {
|
|
246
249
|
mockedNetwork.mockResolvedValue(cosmosValidatorsPayload)
|
|
247
250
|
|
|
248
|
-
await getValidators(mockConfig,
|
|
251
|
+
await getValidators(mockConfig, testLogger)
|
|
249
252
|
expect(mockedNetwork).toHaveBeenCalledTimes(1)
|
|
250
253
|
|
|
251
|
-
prefetchValidators(mockConfig,
|
|
254
|
+
prefetchValidators(mockConfig, testLogger)
|
|
252
255
|
await Promise.resolve()
|
|
253
256
|
|
|
254
257
|
expect(mockedNetwork).toHaveBeenCalledTimes(1)
|
|
@@ -257,52 +260,52 @@ describe('staking/validators', () => {
|
|
|
257
260
|
|
|
258
261
|
describe('explorer & unbonding helpers', () => {
|
|
259
262
|
it('getValidatorExplorerUrl substitutes the validator address after turning it to lowercase', () => {
|
|
260
|
-
expect(getValidatorExplorerUrl(
|
|
263
|
+
expect(getValidatorExplorerUrl(CHAIN_ID.SEI_EVM, 'ADDR')).toBe(
|
|
261
264
|
'https://seistream.app/validators/addr'
|
|
262
265
|
)
|
|
263
266
|
})
|
|
264
267
|
|
|
265
268
|
it('getUnbondingPeriodDays returns Sei config', () => {
|
|
266
|
-
expect(getUnbondingPeriodDays(
|
|
269
|
+
expect(getUnbondingPeriodDays(CHAIN_ID.SEI_EVM)).toBe(21)
|
|
267
270
|
})
|
|
268
271
|
|
|
269
|
-
it.each([
|
|
272
|
+
it.each([CHAIN_ID.CELO, CHAIN_ID.ETHEREUM])(
|
|
270
273
|
'getUnbondingPeriodDays returns undefined without config (%s)',
|
|
271
|
-
(
|
|
272
|
-
expect(getUnbondingPeriodDays(
|
|
274
|
+
(chainId) => {
|
|
275
|
+
expect(getUnbondingPeriodDays(chainId)).toBeUndefined()
|
|
273
276
|
}
|
|
274
277
|
)
|
|
275
278
|
|
|
276
279
|
it('hasUnbondingPeriod is true for Sei', () => {
|
|
277
|
-
expect(hasUnbondingPeriod(
|
|
280
|
+
expect(hasUnbondingPeriod(CHAIN_ID.SEI_EVM)).toBe(true)
|
|
278
281
|
})
|
|
279
282
|
|
|
280
|
-
it.each([
|
|
283
|
+
it.each([CHAIN_ID.CELO, CHAIN_ID.ETHEREUM])(
|
|
281
284
|
'hasUnbondingPeriod is false without configured unbonding (%s)',
|
|
282
|
-
(
|
|
283
|
-
expect(hasUnbondingPeriod(
|
|
285
|
+
(chainId) => {
|
|
286
|
+
expect(hasUnbondingPeriod(chainId)).toBe(false)
|
|
284
287
|
}
|
|
285
288
|
)
|
|
286
289
|
|
|
287
290
|
it('getDelegationVisibilityDelayMinutes returns Somnia config', () => {
|
|
288
|
-
expect(getDelegationVisibilityDelayMinutes(
|
|
291
|
+
expect(getDelegationVisibilityDelayMinutes(CHAIN_ID.SOMNIA)).toBe(5)
|
|
289
292
|
})
|
|
290
293
|
|
|
291
|
-
it.each([
|
|
294
|
+
it.each([CHAIN_ID.SEI_EVM, CHAIN_ID.ETHEREUM])(
|
|
292
295
|
'getDelegationVisibilityDelayMinutes returns undefined without config (%s)',
|
|
293
|
-
(
|
|
294
|
-
expect(getDelegationVisibilityDelayMinutes(
|
|
296
|
+
(chainId) => {
|
|
297
|
+
expect(getDelegationVisibilityDelayMinutes(chainId)).toBeUndefined()
|
|
295
298
|
}
|
|
296
299
|
)
|
|
297
300
|
|
|
298
301
|
it('hasDelegationVisibilityDelay is true for Somnia', () => {
|
|
299
|
-
expect(hasDelegationVisibilityDelay(
|
|
302
|
+
expect(hasDelegationVisibilityDelay(CHAIN_ID.SOMNIA)).toBe(true)
|
|
300
303
|
})
|
|
301
304
|
|
|
302
|
-
it.each([
|
|
305
|
+
it.each([CHAIN_ID.SEI_EVM, CHAIN_ID.ETHEREUM])(
|
|
303
306
|
'hasDelegationVisibilityDelay is false without configured delay (%s)',
|
|
304
|
-
(
|
|
305
|
-
expect(hasDelegationVisibilityDelay(
|
|
307
|
+
(chainId) => {
|
|
308
|
+
expect(hasDelegationVisibilityDelay(chainId)).toBe(false)
|
|
306
309
|
}
|
|
307
310
|
)
|
|
308
311
|
})
|
|
@@ -343,13 +346,13 @@ describe('staking/validators', () => {
|
|
|
343
346
|
|
|
344
347
|
describe('hasChainRewards', () => {
|
|
345
348
|
it.each([
|
|
346
|
-
[
|
|
347
|
-
[
|
|
348
|
-
[
|
|
349
|
-
[
|
|
350
|
-
[
|
|
351
|
-
])('%s returns %s', (
|
|
352
|
-
expect(hasChainRewards(
|
|
349
|
+
[CHAIN_ID.SEI_EVM, true],
|
|
350
|
+
[CHAIN_ID.MONAD, true],
|
|
351
|
+
[CHAIN_ID.SOMNIA, true],
|
|
352
|
+
[CHAIN_ID.ZERO_GRAVITY, false],
|
|
353
|
+
[CHAIN_ID.ETHEREUM, false],
|
|
354
|
+
])('%s returns %s', (chainId, expected) => {
|
|
355
|
+
expect(hasChainRewards(chainId)).toEqual(expected)
|
|
353
356
|
})
|
|
354
357
|
})
|
|
355
358
|
})
|