@ledgerhq/coin-evm 0.3.0 → 0.4.0-next.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 +31 -0
- package/jest.config.js +4 -0
- package/lib/__tests__/fixtures/common.fixtures.d.ts +9 -0
- package/lib/__tests__/fixtures/common.fixtures.d.ts.map +1 -0
- package/lib/{testUtils.js → __tests__/fixtures/common.fixtures.js} +40 -9
- package/lib/__tests__/fixtures/common.fixtures.js.map +1 -0
- package/lib/__tests__/fixtures/etherscan.fixtures.d.ts +86 -0
- package/lib/__tests__/fixtures/etherscan.fixtures.d.ts.map +1 -0
- package/lib/__tests__/fixtures/etherscan.fixtures.js +267 -0
- package/lib/__tests__/fixtures/etherscan.fixtures.js.map +1 -0
- package/lib/__tests__/fixtures/prepareTransaction.fixtures.d.ts +10 -0
- package/lib/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -0
- package/lib/__tests__/fixtures/prepareTransaction.fixtures.js +69 -0
- package/lib/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -0
- package/lib/__tests__/fixtures/synchronization.fixtures.d.ts +44 -0
- package/lib/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -0
- package/lib/__tests__/fixtures/synchronization.fixtures.js +219 -0
- package/lib/__tests__/fixtures/synchronization.fixtures.js.map +1 -0
- package/lib/__tests__/fixtures/transaction.fixtures.d.ts +47 -0
- package/lib/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -0
- package/lib/__tests__/fixtures/transaction.fixtures.js +182 -0
- package/lib/__tests__/fixtures/transaction.fixtures.js.map +1 -0
- package/lib/__tests__/integration/bridge.integration.test.d.ts +7 -0
- package/lib/__tests__/integration/bridge.integration.test.d.ts.map +1 -0
- package/lib/__tests__/integration/bridge.integration.test.js +74 -0
- package/lib/__tests__/integration/bridge.integration.test.js.map +1 -0
- package/lib/__tests__/unit/adapters.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/adapters.unit.test.js +989 -0
- package/lib/__tests__/unit/adapters.unit.test.js.map +1 -0
- package/lib/__tests__/unit/api/explorer/etherscan.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/api/explorer/etherscan.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js +430 -0
- package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -0
- package/lib/__tests__/unit/api/explorer/index.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/api/explorer/index.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/api/explorer/index.unit.test.js +49 -0
- package/lib/__tests__/unit/api/explorer/index.unit.test.js.map +1 -0
- package/lib/__tests__/unit/api/gasTracker/index.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/api/gasTracker/index.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.js +3 -3
- package/lib/__tests__/unit/api/gasTracker/index.unit.test.js.map +1 -0
- package/lib/__tests__/unit/api/gasTracker/ledger.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.js +2 -2
- package/lib/__tests__/unit/api/gasTracker/ledger.unit.test.js.map +1 -0
- package/lib/__tests__/unit/api/rpc/rpc.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{rpc.unit.test.js → unit/api/rpc/rpc.unit.test.js} +14 -14
- package/lib/__tests__/unit/api/rpc/rpc.unit.test.js.map +1 -0
- package/lib/__tests__/unit/broadcast.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/broadcast.unit.test.js +335 -0
- package/lib/__tests__/unit/broadcast.unit.test.js.map +1 -0
- package/lib/__tests__/unit/buildOptimisticOperation.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{buildOptimisticOperation.unit.test.js → unit/buildOptimisticOperation.unit.test.js} +132 -6
- package/lib/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -0
- package/lib/__tests__/unit/createTransaction.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{createTransaction.unit.test.js → unit/createTransaction.unit.test.js} +5 -5
- package/lib/__tests__/unit/createTransaction.unit.test.js.map +1 -0
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{deviceTransactionConfig.unit.test.js → unit/deviceTransactionConfig.unit.test.js} +123 -6
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -0
- package/lib/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{estimateMaxSpendable.unit.test.js → unit/estimateMaxSpendable.unit.test.js} +6 -6
- package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -0
- package/lib/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{getTransactionStatus.unit.test.js → unit/getTransactionStatus.unit.test.js} +76 -6
- package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -0
- package/lib/__tests__/unit/hw-getAddress.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{hw-getAddress.unit.test.js → unit/hw-getAddress.unit.test.js} +5 -1
- package/lib/__tests__/unit/hw-getAddress.unit.test.js.map +1 -0
- package/lib/__tests__/unit/hw-signMessage.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/hw-signMessage.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/hw-signMessage.unit.test.js +188 -0
- package/lib/__tests__/unit/hw-signMessage.unit.test.js.map +1 -0
- package/lib/__tests__/unit/logic.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{logic.unit.test.js → unit/logic.unit.test.js} +111 -20
- package/lib/__tests__/unit/logic.unit.test.js.map +1 -0
- package/lib/__tests__/unit/nftResolvers.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/nftResolvers.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/nftResolvers.unit.test.js +163 -0
- package/lib/__tests__/unit/nftResolvers.unit.test.js.map +1 -0
- package/lib/__tests__/unit/preload.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{preload.unit.test.js → unit/preload.unit.test.js} +3 -3
- package/lib/__tests__/unit/preload.unit.test.js.map +1 -0
- package/lib/__tests__/unit/prepareTransaction.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/prepareTransaction.unit.test.js +300 -0
- package/lib/__tests__/unit/prepareTransaction.unit.test.js.map +1 -0
- package/lib/__tests__/unit/signOperation.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{signOperation.unit.test.js → unit/signOperation.unit.test.js} +14 -17
- package/lib/__tests__/unit/signOperation.unit.test.js.map +1 -0
- package/lib/__tests__/unit/synchronization.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{synchronization.unit.test.js → unit/synchronization.unit.test.js} +139 -231
- package/lib/__tests__/unit/synchronization.unit.test.js.map +1 -0
- package/lib/__tests__/unit/transaction.unit.test.d.ts.map +1 -0
- package/lib/__tests__/{transaction.unit.test.js → unit/transaction.unit.test.js} +48 -80
- package/lib/__tests__/unit/transaction.unit.test.js.map +1 -0
- package/lib/abis/erc1155.abi.json +314 -0
- package/lib/abis/erc721.abi.json +346 -0
- package/lib/adapters.d.ts +18 -7
- package/lib/adapters.d.ts.map +1 -1
- package/lib/adapters.js +131 -46
- package/lib/adapters.js.map +1 -1
- package/lib/api/explorer/etherscan.d.ts +39 -11
- package/lib/api/explorer/etherscan.d.ts.map +1 -1
- package/lib/api/explorer/etherscan.js +151 -9
- package/lib/api/explorer/etherscan.js.map +1 -1
- package/lib/api/explorer/index.d.ts +7 -16
- package/lib/api/explorer/index.d.ts.map +1 -1
- package/lib/api/explorer/index.js.map +1 -1
- package/lib/api/nft/index.d.ts +24 -0
- package/lib/api/nft/index.d.ts.map +1 -0
- package/lib/api/nft/index.js +54 -0
- package/lib/api/nft/index.js.map +1 -0
- package/lib/api/rpc/index.native.d.ts.map +1 -1
- package/lib/api/rpc/index.native.js +1 -0
- package/lib/api/rpc/index.native.js.map +1 -1
- package/lib/api/rpc/rpc.common.d.ts +2 -2
- package/lib/api/rpc/rpc.common.d.ts.map +1 -1
- package/lib/api/rpc/rpc.common.js +3 -3
- package/lib/api/rpc/rpc.common.js.map +1 -1
- package/lib/bridge/js.d.ts +1 -1
- package/lib/bridge/js.d.ts.map +1 -1
- package/lib/bridge/js.js +10 -10
- package/lib/bridge/js.js.map +1 -1
- package/lib/broadcast.d.ts.map +1 -1
- package/lib/broadcast.js +9 -2
- package/lib/broadcast.js.map +1 -1
- package/lib/buildOptimisticOperation.d.ts +5 -1
- package/lib/buildOptimisticOperation.d.ts.map +1 -1
- package/lib/buildOptimisticOperation.js +46 -4
- package/lib/buildOptimisticOperation.js.map +1 -1
- package/lib/cli-transaction.d.ts.map +1 -1
- package/lib/cli-transaction.js +1 -0
- package/lib/cli-transaction.js.map +1 -1
- package/lib/datasets/ethereum1.d.ts.map +1 -1
- package/lib/datasets/ethereum1.js +3 -2
- package/lib/datasets/ethereum1.js.map +1 -1
- package/lib/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/deviceTransactionConfig.js +50 -0
- package/lib/deviceTransactionConfig.js.map +1 -1
- package/lib/errors.d.ts +9 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +7 -1
- package/lib/errors.js.map +1 -1
- package/lib/getTransactionStatus.d.ts +1 -0
- package/lib/getTransactionStatus.d.ts.map +1 -1
- package/lib/getTransactionStatus.js +25 -3
- package/lib/getTransactionStatus.js.map +1 -1
- package/lib/hw-signMessage.d.ts +15 -0
- package/lib/hw-signMessage.d.ts.map +1 -0
- package/lib/hw-signMessage.js +86 -0
- package/lib/hw-signMessage.js.map +1 -0
- package/lib/logic.d.ts +63 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +98 -2
- package/lib/logic.js.map +1 -1
- package/lib/nftResolvers.d.ts +19 -0
- package/lib/nftResolvers.d.ts.map +1 -0
- package/lib/nftResolvers.js +58 -0
- package/lib/nftResolvers.js.map +1 -0
- package/lib/preload.d.ts.map +1 -1
- package/lib/preload.js +7 -3
- package/lib/preload.js.map +1 -1
- package/lib/prepareTransaction.d.ts +6 -1
- package/lib/prepareTransaction.d.ts.map +1 -1
- package/lib/prepareTransaction.js +69 -18
- package/lib/prepareTransaction.js.map +1 -1
- package/lib/signOperation.d.ts +1 -1
- package/lib/signOperation.d.ts.map +1 -1
- package/lib/signOperation.js +17 -6
- package/lib/signOperation.js.map +1 -1
- package/lib/signer.d.ts +24 -1
- package/lib/signer.d.ts.map +1 -1
- package/lib/specs.d.ts +3 -1
- package/lib/specs.d.ts.map +1 -1
- package/lib/specs.js +3 -3
- package/lib/specs.js.map +1 -1
- package/lib/speculos-deviceActions.d.ts.map +1 -1
- package/lib/speculos-deviceActions.js +2 -1
- package/lib/speculos-deviceActions.js.map +1 -1
- package/lib/synchronization.d.ts +7 -2
- package/lib/synchronization.d.ts.map +1 -1
- package/lib/synchronization.js +45 -45
- package/lib/synchronization.js.map +1 -1
- package/lib/transaction.d.ts +3 -4
- package/lib/transaction.d.ts.map +1 -1
- package/lib/transaction.js +58 -12
- package/lib/transaction.js.map +1 -1
- package/lib/types.d.ts +85 -10
- package/lib/types.d.ts.map +1 -1
- package/lib-es/__tests__/fixtures/common.fixtures.d.ts +9 -0
- package/lib-es/__tests__/fixtures/common.fixtures.d.ts.map +1 -0
- package/lib-es/{testUtils.js → __tests__/fixtures/common.fixtures.js} +36 -8
- package/lib-es/__tests__/fixtures/common.fixtures.js.map +1 -0
- package/lib-es/__tests__/fixtures/etherscan.fixtures.d.ts +86 -0
- package/lib-es/__tests__/fixtures/etherscan.fixtures.d.ts.map +1 -0
- package/lib-es/__tests__/fixtures/etherscan.fixtures.js +264 -0
- package/lib-es/__tests__/fixtures/etherscan.fixtures.js.map +1 -0
- package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.d.ts +10 -0
- package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -0
- package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js +62 -0
- package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -0
- package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts +44 -0
- package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -0
- package/lib-es/__tests__/fixtures/synchronization.fixtures.js +190 -0
- package/lib-es/__tests__/fixtures/synchronization.fixtures.js.map +1 -0
- package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts +47 -0
- package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -0
- package/lib-es/__tests__/fixtures/transaction.fixtures.js +176 -0
- package/lib-es/__tests__/fixtures/transaction.fixtures.js.map +1 -0
- package/lib-es/__tests__/integration/bridge.integration.test.d.ts +7 -0
- package/lib-es/__tests__/integration/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/__tests__/integration/bridge.integration.test.js +71 -0
- package/lib-es/__tests__/integration/bridge.integration.test.js.map +1 -0
- package/lib-es/__tests__/unit/adapters.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/adapters.unit.test.js +984 -0
- package/lib-es/__tests__/unit/adapters.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.d.ts +2 -0
- package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js +402 -0
- package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/api/explorer/index.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/api/explorer/index.unit.test.js +44 -0
- package/lib-es/__tests__/unit/api/explorer/index.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/api/gasTracker/index.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.js +3 -3
- package/lib-es/__tests__/unit/api/gasTracker/index.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/api/gasTracker/ledger.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.js +2 -2
- package/lib-es/__tests__/unit/api/gasTracker/ledger.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/api/rpc/rpc.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{rpc.unit.test.js → unit/api/rpc/rpc.unit.test.js} +13 -13
- package/lib-es/__tests__/unit/api/rpc/rpc.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/broadcast.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/broadcast.unit.test.js +307 -0
- package/lib-es/__tests__/unit/broadcast.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{buildOptimisticOperation.unit.test.js → unit/buildOptimisticOperation.unit.test.js} +130 -4
- package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/createTransaction.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{createTransaction.unit.test.js → unit/createTransaction.unit.test.js} +3 -3
- package/lib-es/__tests__/unit/createTransaction.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{deviceTransactionConfig.unit.test.js → unit/deviceTransactionConfig.unit.test.js} +121 -4
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{estimateMaxSpendable.unit.test.js → unit/estimateMaxSpendable.unit.test.js} +4 -4
- package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{getTransactionStatus.unit.test.js → unit/getTransactionStatus.unit.test.js} +74 -4
- package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/hw-getAddress.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{hw-getAddress.unit.test.js → unit/hw-getAddress.unit.test.js} +5 -1
- package/lib-es/__tests__/unit/hw-getAddress.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/hw-signMessage.unit.test.d.ts +2 -0
- package/lib-es/__tests__/unit/hw-signMessage.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/hw-signMessage.unit.test.js +186 -0
- package/lib-es/__tests__/unit/hw-signMessage.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/logic.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{logic.unit.test.js → unit/logic.unit.test.js} +97 -6
- package/lib-es/__tests__/unit/logic.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/nftResolvers.unit.test.d.ts +2 -0
- package/lib-es/__tests__/unit/nftResolvers.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/nftResolvers.unit.test.js +158 -0
- package/lib-es/__tests__/unit/nftResolvers.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/preload.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{preload.unit.test.js → unit/preload.unit.test.js} +3 -3
- package/lib-es/__tests__/unit/preload.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/prepareTransaction.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{prepareTransaction.unit.test.js → unit/prepareTransaction.unit.test.js} +134 -82
- package/lib-es/__tests__/unit/prepareTransaction.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/signOperation.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{signOperation.unit.test.js → unit/signOperation.unit.test.js} +13 -16
- package/lib-es/__tests__/unit/signOperation.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/synchronization.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{synchronization.unit.test.js → unit/synchronization.unit.test.js} +115 -207
- package/lib-es/__tests__/unit/synchronization.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/transaction.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/{transaction.unit.test.js → unit/transaction.unit.test.js} +40 -72
- package/lib-es/__tests__/unit/transaction.unit.test.js.map +1 -0
- package/lib-es/abis/erc1155.abi.json +314 -0
- package/lib-es/abis/erc721.abi.json +346 -0
- package/lib-es/adapters.d.ts +18 -7
- package/lib-es/adapters.d.ts.map +1 -1
- package/lib-es/adapters.js +127 -44
- package/lib-es/adapters.js.map +1 -1
- package/lib-es/api/explorer/etherscan.d.ts +39 -11
- package/lib-es/api/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/api/explorer/etherscan.js +146 -10
- package/lib-es/api/explorer/etherscan.js.map +1 -1
- package/lib-es/api/explorer/index.d.ts +7 -16
- package/lib-es/api/explorer/index.d.ts.map +1 -1
- package/lib-es/api/explorer/index.js.map +1 -1
- package/lib-es/api/nft/index.d.ts +24 -0
- package/lib-es/api/nft/index.d.ts.map +1 -0
- package/lib-es/api/nft/index.js +46 -0
- package/lib-es/api/nft/index.js.map +1 -0
- package/lib-es/api/rpc/index.native.d.ts.map +1 -1
- package/lib-es/api/rpc/index.native.js +1 -0
- package/lib-es/api/rpc/index.native.js.map +1 -1
- package/lib-es/api/rpc/rpc.common.d.ts +2 -2
- package/lib-es/api/rpc/rpc.common.d.ts.map +1 -1
- package/lib-es/api/rpc/rpc.common.js +3 -3
- package/lib-es/api/rpc/rpc.common.js.map +1 -1
- package/lib-es/bridge/js.d.ts +1 -1
- package/lib-es/bridge/js.d.ts.map +1 -1
- package/lib-es/bridge/js.js +10 -10
- package/lib-es/bridge/js.js.map +1 -1
- package/lib-es/broadcast.d.ts.map +1 -1
- package/lib-es/broadcast.js +9 -2
- package/lib-es/broadcast.js.map +1 -1
- package/lib-es/buildOptimisticOperation.d.ts +5 -1
- package/lib-es/buildOptimisticOperation.d.ts.map +1 -1
- package/lib-es/buildOptimisticOperation.js +45 -4
- package/lib-es/buildOptimisticOperation.js.map +1 -1
- package/lib-es/cli-transaction.d.ts.map +1 -1
- package/lib-es/cli-transaction.js +1 -0
- package/lib-es/cli-transaction.js.map +1 -1
- package/lib-es/datasets/ethereum1.d.ts.map +1 -1
- package/lib-es/datasets/ethereum1.js +3 -2
- package/lib-es/datasets/ethereum1.js.map +1 -1
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/deviceTransactionConfig.js +50 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -1
- package/lib-es/errors.d.ts +9 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +6 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/getTransactionStatus.d.ts +1 -0
- package/lib-es/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/getTransactionStatus.js +23 -2
- package/lib-es/getTransactionStatus.js.map +1 -1
- package/lib-es/hw-signMessage.d.ts +15 -0
- package/lib-es/hw-signMessage.d.ts.map +1 -0
- package/lib-es/hw-signMessage.js +81 -0
- package/lib-es/hw-signMessage.js.map +1 -0
- package/lib-es/logic.d.ts +63 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +95 -1
- package/lib-es/logic.js.map +1 -1
- package/lib-es/nftResolvers.d.ts +19 -0
- package/lib-es/nftResolvers.d.ts.map +1 -0
- package/lib-es/nftResolvers.js +50 -0
- package/lib-es/nftResolvers.js.map +1 -0
- package/lib-es/preload.d.ts.map +1 -1
- package/lib-es/preload.js +7 -3
- package/lib-es/preload.js.map +1 -1
- package/lib-es/prepareTransaction.d.ts +6 -1
- package/lib-es/prepareTransaction.d.ts.map +1 -1
- package/lib-es/prepareTransaction.js +68 -18
- package/lib-es/prepareTransaction.js.map +1 -1
- package/lib-es/signOperation.d.ts +1 -1
- package/lib-es/signOperation.d.ts.map +1 -1
- package/lib-es/signOperation.js +17 -6
- package/lib-es/signOperation.js.map +1 -1
- package/lib-es/signer.d.ts +24 -1
- package/lib-es/signer.d.ts.map +1 -1
- package/lib-es/specs.d.ts +3 -1
- package/lib-es/specs.d.ts.map +1 -1
- package/lib-es/specs.js +3 -3
- package/lib-es/specs.js.map +1 -1
- package/lib-es/speculos-deviceActions.d.ts.map +1 -1
- package/lib-es/speculos-deviceActions.js +2 -1
- package/lib-es/speculos-deviceActions.js.map +1 -1
- package/lib-es/synchronization.d.ts +7 -2
- package/lib-es/synchronization.d.ts.map +1 -1
- package/lib-es/synchronization.js +46 -46
- package/lib-es/synchronization.js.map +1 -1
- package/lib-es/transaction.d.ts +3 -4
- package/lib-es/transaction.d.ts.map +1 -1
- package/lib-es/transaction.js +58 -12
- package/lib-es/transaction.js.map +1 -1
- package/lib-es/types.d.ts +85 -10
- package/lib-es/types.d.ts.map +1 -1
- package/package.json +13 -12
- package/src/{testUtils.ts → __tests__/fixtures/common.fixtures.ts} +78 -11
- package/src/__tests__/fixtures/etherscan.fixtures.ts +266 -0
- package/src/__tests__/fixtures/prepareTransaction.fixtures.ts +86 -0
- package/src/__tests__/fixtures/synchronization.fixtures.ts +229 -0
- package/src/__tests__/fixtures/transaction.fixtures.ts +229 -0
- package/src/__tests__/integration/bridge.integration.test.ts +74 -0
- package/src/__tests__/unit/adapters.unit.test.ts +1076 -0
- package/src/__tests__/unit/api/explorer/etherscan.unit.test.ts +563 -0
- package/src/__tests__/unit/api/explorer/index.unit.test.ts +36 -0
- package/src/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.ts +3 -3
- package/src/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.ts +3 -3
- package/src/__tests__/{rpc.unit.test.ts → unit/api/rpc/rpc.unit.test.ts} +17 -14
- package/src/__tests__/unit/broadcast.unit.test.ts +332 -0
- package/src/__tests__/{buildOptimisticOperation.unit.test.ts → unit/buildOptimisticOperation.unit.test.ts} +144 -5
- package/src/__tests__/{createTransaction.unit.test.ts → unit/createTransaction.unit.test.ts} +4 -4
- package/src/__tests__/{deviceTransactionConfig.unit.test.ts → unit/deviceTransactionConfig.unit.test.ts} +130 -5
- package/src/__tests__/{estimateMaxSpendable.unit.test.ts → unit/estimateMaxSpendable.unit.test.ts} +5 -5
- package/src/__tests__/{getTransactionStatus.unit.test.ts → unit/getTransactionStatus.unit.test.ts} +121 -5
- package/src/__tests__/{hw-getAddress.unit.test.ts → unit/hw-getAddress.unit.test.ts} +6 -2
- package/src/__tests__/unit/hw-signMessage.unit.test.ts +192 -0
- package/src/__tests__/{logic.unit.test.ts → unit/logic.unit.test.ts} +143 -8
- package/src/__tests__/unit/nftResolvers.unit.test.ts +179 -0
- package/src/__tests__/{preload.unit.test.ts → unit/preload.unit.test.ts} +4 -4
- package/src/__tests__/{prepareTransaction.unit.test.ts → unit/prepareTransaction.unit.test.ts} +284 -109
- package/src/__tests__/{signOperation.unit.test.ts → unit/signOperation.unit.test.ts} +18 -20
- package/src/__tests__/{synchronization.unit.test.ts → unit/synchronization.unit.test.ts} +202 -280
- package/src/__tests__/unit/transaction.unit.test.ts +198 -0
- package/src/abis/erc1155.abi.json +314 -0
- package/src/abis/erc20.abi.json +4 -12
- package/src/abis/erc721.abi.json +346 -0
- package/src/adapters.ts +177 -64
- package/src/api/explorer/etherscan.ts +265 -49
- package/src/api/explorer/index.ts +24 -10
- package/src/api/nft/index.ts +49 -0
- package/src/api/rpc/index.native.ts +2 -0
- package/src/api/rpc/rpc.common.ts +3 -3
- package/src/bridge/js.ts +13 -16
- package/src/broadcast.ts +29 -2
- package/src/buildOptimisticOperation.ts +71 -6
- package/src/cli-transaction.ts +2 -0
- package/src/datasets/ethereum1.ts +4 -2
- package/src/deviceTransactionConfig.ts +65 -0
- package/src/errors.ts +8 -0
- package/src/getTransactionStatus.ts +26 -0
- package/src/hw-signMessage.ts +92 -0
- package/src/logic.ts +118 -2
- package/src/nftResolvers.ts +71 -0
- package/src/preload.ts +9 -3
- package/src/prepareTransaction.ts +102 -24
- package/src/signOperation.ts +21 -8
- package/src/signer.ts +44 -1
- package/src/specs.ts +11 -6
- package/src/speculos-deviceActions.ts +3 -1
- package/src/synchronization.ts +73 -59
- package/src/transaction.ts +68 -15
- package/src/types.ts +108 -10
- package/.eslintrc.js +0 -22
- package/lib/__tests__/adapters.unit.test.d.ts.map +0 -1
- package/lib/__tests__/adapters.unit.test.js +0 -455
- package/lib/__tests__/adapters.unit.test.js.map +0 -1
- package/lib/__tests__/broadcast.unit.test.d.ts.map +0 -1
- package/lib/__tests__/broadcast.unit.test.js +0 -181
- package/lib/__tests__/broadcast.unit.test.js.map +0 -1
- package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts.map +0 -1
- package/lib/__tests__/buildOptimisticOperation.unit.test.js.map +0 -1
- package/lib/__tests__/createTransaction.unit.test.d.ts.map +0 -1
- package/lib/__tests__/createTransaction.unit.test.js.map +0 -1
- package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts.map +0 -1
- package/lib/__tests__/deviceTransactionConfig.unit.test.js.map +0 -1
- package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts.map +0 -1
- package/lib/__tests__/estimateMaxSpendable.unit.test.js.map +0 -1
- package/lib/__tests__/gasTracker/index.unit.test.d.ts.map +0 -1
- package/lib/__tests__/gasTracker/index.unit.test.js.map +0 -1
- package/lib/__tests__/gasTracker/ledger.unit.test.d.ts.map +0 -1
- package/lib/__tests__/gasTracker/ledger.unit.test.js.map +0 -1
- package/lib/__tests__/getTransactionStatus.unit.test.d.ts.map +0 -1
- package/lib/__tests__/getTransactionStatus.unit.test.js.map +0 -1
- package/lib/__tests__/hw-getAddress.unit.test.d.ts.map +0 -1
- package/lib/__tests__/hw-getAddress.unit.test.js.map +0 -1
- package/lib/__tests__/logic.unit.test.d.ts.map +0 -1
- package/lib/__tests__/logic.unit.test.js.map +0 -1
- package/lib/__tests__/preload.unit.test.d.ts.map +0 -1
- package/lib/__tests__/preload.unit.test.js.map +0 -1
- package/lib/__tests__/prepareTransaction.unit.test.d.ts.map +0 -1
- package/lib/__tests__/prepareTransaction.unit.test.js +0 -248
- package/lib/__tests__/prepareTransaction.unit.test.js.map +0 -1
- package/lib/__tests__/rpc.unit.test.d.ts.map +0 -1
- package/lib/__tests__/rpc.unit.test.js.map +0 -1
- package/lib/__tests__/signOperation.unit.test.d.ts.map +0 -1
- package/lib/__tests__/signOperation.unit.test.js.map +0 -1
- package/lib/__tests__/synchronization.unit.test.d.ts.map +0 -1
- package/lib/__tests__/synchronization.unit.test.js.map +0 -1
- package/lib/__tests__/transaction.unit.test.d.ts.map +0 -1
- package/lib/__tests__/transaction.unit.test.js.map +0 -1
- package/lib/bridge.integration.test.d.ts +0 -14
- package/lib/bridge.integration.test.d.ts.map +0 -1
- package/lib/bridge.integration.test.js +0 -85
- package/lib/bridge.integration.test.js.map +0 -1
- package/lib/datasets/ethereum.scanAccounts.1.d.ts +0 -7
- package/lib/datasets/ethereum.scanAccounts.1.d.ts.map +0 -1
- package/lib/datasets/ethereum.scanAccounts.1.js +0 -51
- package/lib/datasets/ethereum.scanAccounts.1.js.map +0 -1
- package/lib/datasets/ethereum2.d.ts +0 -3
- package/lib/datasets/ethereum2.d.ts.map +0 -1
- package/lib/datasets/ethereum2.js +0 -22
- package/lib/datasets/ethereum2.js.map +0 -1
- package/lib/datasets/ethereum_classic.d.ts +0 -5
- package/lib/datasets/ethereum_classic.d.ts.map +0 -1
- package/lib/datasets/ethereum_classic.js +0 -69
- package/lib/datasets/ethereum_classic.js.map +0 -1
- package/lib/testUtils.d.ts +0 -6
- package/lib/testUtils.d.ts.map +0 -1
- package/lib/testUtils.js.map +0 -1
- package/lib-es/__tests__/adapters.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/adapters.unit.test.js +0 -450
- package/lib-es/__tests__/adapters.unit.test.js.map +0 -1
- package/lib-es/__tests__/broadcast.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/broadcast.unit.test.js +0 -153
- package/lib-es/__tests__/broadcast.unit.test.js.map +0 -1
- package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/buildOptimisticOperation.unit.test.js.map +0 -1
- package/lib-es/__tests__/createTransaction.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/createTransaction.unit.test.js.map +0 -1
- package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/deviceTransactionConfig.unit.test.js.map +0 -1
- package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/estimateMaxSpendable.unit.test.js.map +0 -1
- package/lib-es/__tests__/gasTracker/index.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/gasTracker/index.unit.test.js.map +0 -1
- package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/gasTracker/ledger.unit.test.js.map +0 -1
- package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/getTransactionStatus.unit.test.js.map +0 -1
- package/lib-es/__tests__/hw-getAddress.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/hw-getAddress.unit.test.js.map +0 -1
- package/lib-es/__tests__/logic.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/logic.unit.test.js.map +0 -1
- package/lib-es/__tests__/preload.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/preload.unit.test.js.map +0 -1
- package/lib-es/__tests__/prepareTransaction.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/prepareTransaction.unit.test.js.map +0 -1
- package/lib-es/__tests__/rpc.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/rpc.unit.test.js.map +0 -1
- package/lib-es/__tests__/signOperation.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/signOperation.unit.test.js.map +0 -1
- package/lib-es/__tests__/synchronization.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/synchronization.unit.test.js.map +0 -1
- package/lib-es/__tests__/transaction.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/transaction.unit.test.js.map +0 -1
- package/lib-es/bridge.integration.test.d.ts +0 -14
- package/lib-es/bridge.integration.test.d.ts.map +0 -1
- package/lib-es/bridge.integration.test.js +0 -79
- package/lib-es/bridge.integration.test.js.map +0 -1
- package/lib-es/datasets/ethereum.scanAccounts.1.d.ts +0 -7
- package/lib-es/datasets/ethereum.scanAccounts.1.d.ts.map +0 -1
- package/lib-es/datasets/ethereum.scanAccounts.1.js +0 -49
- package/lib-es/datasets/ethereum.scanAccounts.1.js.map +0 -1
- package/lib-es/datasets/ethereum2.d.ts +0 -3
- package/lib-es/datasets/ethereum2.d.ts.map +0 -1
- package/lib-es/datasets/ethereum2.js +0 -19
- package/lib-es/datasets/ethereum2.js.map +0 -1
- package/lib-es/datasets/ethereum_classic.d.ts +0 -5
- package/lib-es/datasets/ethereum_classic.d.ts.map +0 -1
- package/lib-es/datasets/ethereum_classic.js +0 -67
- package/lib-es/datasets/ethereum_classic.js.map +0 -1
- package/lib-es/testUtils.d.ts +0 -6
- package/lib-es/testUtils.d.ts.map +0 -1
- package/lib-es/testUtils.js.map +0 -1
- package/src/__tests__/adapters.unit.test.ts +0 -497
- package/src/__tests__/broadcast.unit.test.ts +0 -163
- package/src/__tests__/transaction.unit.test.ts +0 -188
- package/src/bridge.integration.test.ts +0 -86
- package/src/datasets/ethereum.scanAccounts.1.ts +0 -48
- package/src/datasets/ethereum2.ts +0 -20
- package/src/datasets/ethereum_classic.ts +0 -68
- /package/lib/__tests__/{adapters.unit.test.d.ts → unit/adapters.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.d.ts +0 -0
- /package/lib/__tests__/{rpc.unit.test.d.ts → unit/api/rpc/rpc.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{broadcast.unit.test.d.ts → unit/broadcast.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{buildOptimisticOperation.unit.test.d.ts → unit/buildOptimisticOperation.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{createTransaction.unit.test.d.ts → unit/createTransaction.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{deviceTransactionConfig.unit.test.d.ts → unit/deviceTransactionConfig.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{estimateMaxSpendable.unit.test.d.ts → unit/estimateMaxSpendable.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{getTransactionStatus.unit.test.d.ts → unit/getTransactionStatus.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{hw-getAddress.unit.test.d.ts → unit/hw-getAddress.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{logic.unit.test.d.ts → unit/logic.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{preload.unit.test.d.ts → unit/preload.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{prepareTransaction.unit.test.d.ts → unit/prepareTransaction.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{signOperation.unit.test.d.ts → unit/signOperation.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{synchronization.unit.test.d.ts → unit/synchronization.unit.test.d.ts} +0 -0
- /package/lib/__tests__/{transaction.unit.test.d.ts → unit/transaction.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{adapters.unit.test.d.ts → unit/adapters.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{gasTracker → unit/api/explorer}/index.unit.test.d.ts +0 -0
- /package/{lib/__tests__ → lib-es/__tests__/unit/api}/gasTracker/index.unit.test.d.ts +0 -0
- /package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.d.ts +0 -0
- /package/lib-es/__tests__/{rpc.unit.test.d.ts → unit/api/rpc/rpc.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{broadcast.unit.test.d.ts → unit/broadcast.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{buildOptimisticOperation.unit.test.d.ts → unit/buildOptimisticOperation.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{createTransaction.unit.test.d.ts → unit/createTransaction.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{deviceTransactionConfig.unit.test.d.ts → unit/deviceTransactionConfig.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{estimateMaxSpendable.unit.test.d.ts → unit/estimateMaxSpendable.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{getTransactionStatus.unit.test.d.ts → unit/getTransactionStatus.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{hw-getAddress.unit.test.d.ts → unit/hw-getAddress.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{logic.unit.test.d.ts → unit/logic.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{preload.unit.test.d.ts → unit/preload.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{prepareTransaction.unit.test.d.ts → unit/prepareTransaction.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{signOperation.unit.test.d.ts → unit/signOperation.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{synchronization.unit.test.d.ts → unit/synchronization.unit.test.d.ts} +0 -0
- /package/lib-es/__tests__/{transaction.unit.test.d.ts → unit/transaction.unit.test.d.ts} +0 -0
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { AssertionError, fail } from "assert";
|
|
3
|
+
import { delay } from "@ledgerhq/live-promise";
|
|
4
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
5
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
6
|
+
import * as ETHERSCAN_API from "../../../../api/explorer/etherscan";
|
|
7
|
+
import { makeAccount } from "../../../fixtures/common.fixtures";
|
|
8
|
+
import {
|
|
9
|
+
etherscanCoinOperations,
|
|
10
|
+
etherscanERC1155Operations,
|
|
11
|
+
etherscanERC721Operations,
|
|
12
|
+
etherscanTokenOperations,
|
|
13
|
+
} from "../../../fixtures/etherscan.fixtures";
|
|
14
|
+
import {
|
|
15
|
+
etherscanERC1155EventToOperations,
|
|
16
|
+
etherscanERC20EventToOperations,
|
|
17
|
+
etherscanERC721EventToOperations,
|
|
18
|
+
etherscanOperationToOperations,
|
|
19
|
+
} from "../../../../adapters";
|
|
20
|
+
|
|
21
|
+
jest.mock("axios");
|
|
22
|
+
jest.mock("@ledgerhq/live-promise");
|
|
23
|
+
(delay as jest.Mock).mockImplementation(
|
|
24
|
+
() => new Promise(resolve => setTimeout(resolve, 1)), // mocking the delay supposed to happen after each try
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const currency: CryptoCurrency = {
|
|
28
|
+
...getCryptoCurrencyById("ethereum"),
|
|
29
|
+
ethereumLikeInfo: {
|
|
30
|
+
chainId: 1,
|
|
31
|
+
explorer: {
|
|
32
|
+
type: "etherscan",
|
|
33
|
+
uri: "mock",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const account = makeAccount("0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d", currency);
|
|
38
|
+
|
|
39
|
+
describe("EVM Family", () => {
|
|
40
|
+
describe("api/explorer/etherscan.ts", () => {
|
|
41
|
+
afterAll(() => {
|
|
42
|
+
jest.restoreAllMocks();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("fetchWithRetries", () => {
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
jest.clearAllMocks();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should retry on fail", async () => {
|
|
51
|
+
let retries = 2;
|
|
52
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => {
|
|
53
|
+
if (retries) {
|
|
54
|
+
--retries;
|
|
55
|
+
throw new Error();
|
|
56
|
+
}
|
|
57
|
+
return { data: { result: true } };
|
|
58
|
+
});
|
|
59
|
+
const response = await ETHERSCAN_API.fetchWithRetries({}, retries);
|
|
60
|
+
|
|
61
|
+
expect(response).toBe(true);
|
|
62
|
+
// it should fail 2 times and succeed on the next try
|
|
63
|
+
expect(spy).toBeCalledTimes(3);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should throw after too many retries", async () => {
|
|
67
|
+
const SpyError = class SpyError extends Error {};
|
|
68
|
+
|
|
69
|
+
let retries = ETHERSCAN_API.DEFAULT_RETRIES_API + 1;
|
|
70
|
+
jest.spyOn(axios, "request").mockImplementation(async () => {
|
|
71
|
+
if (retries) {
|
|
72
|
+
--retries;
|
|
73
|
+
throw new SpyError();
|
|
74
|
+
}
|
|
75
|
+
return { data: { result: true } };
|
|
76
|
+
});
|
|
77
|
+
try {
|
|
78
|
+
await ETHERSCAN_API.fetchWithRetries({});
|
|
79
|
+
fail("Promise should have been rejected");
|
|
80
|
+
} catch (e) {
|
|
81
|
+
if (e instanceof AssertionError) {
|
|
82
|
+
throw e;
|
|
83
|
+
}
|
|
84
|
+
expect(e).toBeInstanceOf(SpyError);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should also retry if the Etherscan reponse is a 200 w/ a NOTOK message (used for rate limit)", async () => {
|
|
89
|
+
let retries = 2;
|
|
90
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => {
|
|
91
|
+
if (retries) {
|
|
92
|
+
--retries;
|
|
93
|
+
return { data: { message: "NOTOK" } };
|
|
94
|
+
}
|
|
95
|
+
return { data: { result: true } };
|
|
96
|
+
});
|
|
97
|
+
const response = await ETHERSCAN_API.fetchWithRetries({}, retries);
|
|
98
|
+
|
|
99
|
+
expect(response).toBe(true);
|
|
100
|
+
// it should fail 2 times and succeed on the next try
|
|
101
|
+
expect(spy).toBeCalledTimes(3);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe("getLastCoinOperations", () => {
|
|
106
|
+
afterEach(() => {
|
|
107
|
+
jest.clearAllMocks();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("should return an empty array if the currency is misconfigured", async () => {
|
|
111
|
+
jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
112
|
+
data: {
|
|
113
|
+
result: etherscanCoinOperations,
|
|
114
|
+
},
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
const response = await ETHERSCAN_API.getLastCoinOperations(
|
|
118
|
+
{
|
|
119
|
+
...currency,
|
|
120
|
+
ethereumLikeInfo: {
|
|
121
|
+
chainId: 1,
|
|
122
|
+
// no explorer
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
account.freshAddress,
|
|
126
|
+
account.id,
|
|
127
|
+
0,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
expect(response).toEqual([]);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("should return a flat list of coin transactions from block 0", async () => {
|
|
134
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
135
|
+
data: {
|
|
136
|
+
result: etherscanCoinOperations,
|
|
137
|
+
},
|
|
138
|
+
}));
|
|
139
|
+
|
|
140
|
+
const response = await ETHERSCAN_API.getLastCoinOperations(
|
|
141
|
+
currency,
|
|
142
|
+
account.freshAddress,
|
|
143
|
+
account.id,
|
|
144
|
+
0,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
expect(response).toEqual(
|
|
148
|
+
etherscanCoinOperations.map(op => etherscanOperationToOperations(account.id, op)).flat(),
|
|
149
|
+
);
|
|
150
|
+
expect(response.length).toBe(4);
|
|
151
|
+
expect(spy).toBeCalledWith({
|
|
152
|
+
method: "GET",
|
|
153
|
+
url: `mock/api?module=account&action=txlist&address=${account.freshAddress}&tag=latest&page=1&sort=desc`,
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should return a flat list of coin transactions from block 50", async () => {
|
|
158
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
159
|
+
data: {
|
|
160
|
+
result: etherscanCoinOperations,
|
|
161
|
+
},
|
|
162
|
+
}));
|
|
163
|
+
|
|
164
|
+
const response = await ETHERSCAN_API.getLastCoinOperations(
|
|
165
|
+
currency,
|
|
166
|
+
account.freshAddress,
|
|
167
|
+
account.id,
|
|
168
|
+
50,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
expect(response).toEqual(
|
|
172
|
+
etherscanCoinOperations.map(op => etherscanOperationToOperations(account.id, op)).flat(),
|
|
173
|
+
);
|
|
174
|
+
expect(response.length).toBe(4);
|
|
175
|
+
expect(spy).toBeCalledWith({
|
|
176
|
+
method: "GET",
|
|
177
|
+
url: `mock/api?module=account&action=txlist&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50`,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("should return a flat list of coin transactions from block 50 to block 100", async () => {
|
|
182
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
183
|
+
data: {
|
|
184
|
+
result: etherscanCoinOperations,
|
|
185
|
+
},
|
|
186
|
+
}));
|
|
187
|
+
|
|
188
|
+
const response = await ETHERSCAN_API.getLastCoinOperations(
|
|
189
|
+
currency,
|
|
190
|
+
account.freshAddress,
|
|
191
|
+
account.id,
|
|
192
|
+
50,
|
|
193
|
+
100,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
expect(response).toEqual(
|
|
197
|
+
etherscanCoinOperations.map(op => etherscanOperationToOperations(account.id, op)).flat(),
|
|
198
|
+
);
|
|
199
|
+
expect(response.length).toBe(4);
|
|
200
|
+
expect(spy).toBeCalledWith({
|
|
201
|
+
method: "GET",
|
|
202
|
+
url: `mock/api?module=account&action=txlist&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50&endBlock=100`,
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe("getLastTokenOperations", () => {
|
|
208
|
+
afterEach(() => {
|
|
209
|
+
jest.clearAllMocks();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("should return an empty array if the currency is misconfigured", async () => {
|
|
213
|
+
jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
214
|
+
data: {
|
|
215
|
+
result: etherscanTokenOperations,
|
|
216
|
+
},
|
|
217
|
+
}));
|
|
218
|
+
|
|
219
|
+
const response = await ETHERSCAN_API.getLastTokenOperations(
|
|
220
|
+
{
|
|
221
|
+
...currency,
|
|
222
|
+
ethereumLikeInfo: {
|
|
223
|
+
chainId: 1,
|
|
224
|
+
// no explorer
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
account.freshAddress,
|
|
228
|
+
account.id,
|
|
229
|
+
0,
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
expect(response).toEqual([]);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("should return a flat list of token transactions from block 0", async () => {
|
|
236
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
237
|
+
data: {
|
|
238
|
+
result: etherscanTokenOperations,
|
|
239
|
+
},
|
|
240
|
+
}));
|
|
241
|
+
|
|
242
|
+
const response = await ETHERSCAN_API.getLastTokenOperations(
|
|
243
|
+
currency,
|
|
244
|
+
account.freshAddress,
|
|
245
|
+
account.id,
|
|
246
|
+
0,
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
expect(response).toEqual(
|
|
250
|
+
[
|
|
251
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[0], 0),
|
|
252
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[1], 0),
|
|
253
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[2], 1),
|
|
254
|
+
].flat(),
|
|
255
|
+
);
|
|
256
|
+
expect(spy).toBeCalledWith({
|
|
257
|
+
method: "GET",
|
|
258
|
+
url: `mock/api?module=account&action=tokentx&address=${account.freshAddress}&tag=latest&page=1&sort=desc`,
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("should return a flat list of token transactions from block 50", async () => {
|
|
263
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
264
|
+
data: {
|
|
265
|
+
result: etherscanTokenOperations,
|
|
266
|
+
},
|
|
267
|
+
}));
|
|
268
|
+
|
|
269
|
+
const response = await ETHERSCAN_API.getLastTokenOperations(
|
|
270
|
+
currency,
|
|
271
|
+
account.freshAddress,
|
|
272
|
+
account.id,
|
|
273
|
+
50,
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
expect(response).toEqual(
|
|
277
|
+
[
|
|
278
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[0], 0),
|
|
279
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[1], 0),
|
|
280
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[2], 1),
|
|
281
|
+
].flat(),
|
|
282
|
+
);
|
|
283
|
+
expect(spy).toBeCalledWith({
|
|
284
|
+
method: "GET",
|
|
285
|
+
url: `mock/api?module=account&action=tokentx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50`,
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("should return a flat list of token transactions from block 50 to block 100", async () => {
|
|
290
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
291
|
+
data: {
|
|
292
|
+
result: etherscanTokenOperations,
|
|
293
|
+
},
|
|
294
|
+
}));
|
|
295
|
+
|
|
296
|
+
const response = await ETHERSCAN_API.getLastTokenOperations(
|
|
297
|
+
currency,
|
|
298
|
+
account.freshAddress,
|
|
299
|
+
account.id,
|
|
300
|
+
50,
|
|
301
|
+
100,
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
expect(response).toEqual(
|
|
305
|
+
[
|
|
306
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[0], 0),
|
|
307
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[1], 0),
|
|
308
|
+
etherscanERC20EventToOperations(account.id, etherscanTokenOperations[2], 1),
|
|
309
|
+
].flat(),
|
|
310
|
+
);
|
|
311
|
+
expect(spy).toBeCalledWith({
|
|
312
|
+
method: "GET",
|
|
313
|
+
url: `mock/api?module=account&action=tokentx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50&endBlock=100`,
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
describe("getLastERC721Operations", () => {
|
|
319
|
+
afterEach(() => {
|
|
320
|
+
jest.clearAllMocks();
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("should return an empty array if the currency is misconfigured", async () => {
|
|
324
|
+
jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
325
|
+
data: {
|
|
326
|
+
result: etherscanERC721Operations,
|
|
327
|
+
},
|
|
328
|
+
}));
|
|
329
|
+
|
|
330
|
+
const response = await ETHERSCAN_API.getLastERC721Operations(
|
|
331
|
+
{
|
|
332
|
+
...currency,
|
|
333
|
+
ethereumLikeInfo: {
|
|
334
|
+
chainId: 1,
|
|
335
|
+
// no explorer
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
account.freshAddress,
|
|
339
|
+
account.id,
|
|
340
|
+
0,
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
expect(response).toEqual([]);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it("should return a flat list of erc721 transactions from block 0", async () => {
|
|
347
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
348
|
+
data: {
|
|
349
|
+
result: etherscanERC721Operations,
|
|
350
|
+
},
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
const response = await ETHERSCAN_API.getLastERC721Operations(
|
|
354
|
+
currency,
|
|
355
|
+
account.freshAddress,
|
|
356
|
+
account.id,
|
|
357
|
+
0,
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
expect(response).toEqual(
|
|
361
|
+
[
|
|
362
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[0], 0),
|
|
363
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[1], 0),
|
|
364
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[2], 1),
|
|
365
|
+
].flat(),
|
|
366
|
+
);
|
|
367
|
+
expect(spy).toBeCalledWith({
|
|
368
|
+
method: "GET",
|
|
369
|
+
url: `mock/api?module=account&action=tokennfttx&address=${account.freshAddress}&tag=latest&page=1&sort=desc`,
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it("should return a flat list of erc721 transactions from block 50", async () => {
|
|
374
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
375
|
+
data: {
|
|
376
|
+
result: etherscanERC721Operations,
|
|
377
|
+
},
|
|
378
|
+
}));
|
|
379
|
+
|
|
380
|
+
const response = await ETHERSCAN_API.getLastERC721Operations(
|
|
381
|
+
currency,
|
|
382
|
+
account.freshAddress,
|
|
383
|
+
account.id,
|
|
384
|
+
50,
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
expect(response).toEqual(
|
|
388
|
+
[
|
|
389
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[0], 0),
|
|
390
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[1], 0),
|
|
391
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[2], 1),
|
|
392
|
+
].flat(),
|
|
393
|
+
);
|
|
394
|
+
expect(spy).toBeCalledWith({
|
|
395
|
+
method: "GET",
|
|
396
|
+
url: `mock/api?module=account&action=tokennfttx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50`,
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it("should return a flat list of erc721 transactions from block 50 to block 100", async () => {
|
|
401
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
402
|
+
data: {
|
|
403
|
+
result: etherscanERC721Operations,
|
|
404
|
+
},
|
|
405
|
+
}));
|
|
406
|
+
|
|
407
|
+
const response = await ETHERSCAN_API.getLastERC721Operations(
|
|
408
|
+
currency,
|
|
409
|
+
account.freshAddress,
|
|
410
|
+
account.id,
|
|
411
|
+
50,
|
|
412
|
+
100,
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
expect(response).toEqual(
|
|
416
|
+
[
|
|
417
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[0], 0),
|
|
418
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[1], 0),
|
|
419
|
+
etherscanERC721EventToOperations(account.id, etherscanERC721Operations[2], 1),
|
|
420
|
+
].flat(),
|
|
421
|
+
);
|
|
422
|
+
expect(spy).toBeCalledWith({
|
|
423
|
+
method: "GET",
|
|
424
|
+
url: `mock/api?module=account&action=tokennfttx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50&endBlock=100`,
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
describe("getLastERC1155Operations", () => {
|
|
430
|
+
afterEach(() => {
|
|
431
|
+
jest.clearAllMocks();
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it("should return an empty array if the currency is misconfigured", async () => {
|
|
435
|
+
jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
436
|
+
data: {
|
|
437
|
+
result: etherscanERC721Operations,
|
|
438
|
+
},
|
|
439
|
+
}));
|
|
440
|
+
|
|
441
|
+
const response = await ETHERSCAN_API.getLastERC1155Operations(
|
|
442
|
+
{
|
|
443
|
+
...currency,
|
|
444
|
+
ethereumLikeInfo: {
|
|
445
|
+
chainId: 1,
|
|
446
|
+
// no explorer
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
account.freshAddress,
|
|
450
|
+
account.id,
|
|
451
|
+
0,
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
expect(response).toEqual([]);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it("should return a flat list of erc1155 transactions from block 0", async () => {
|
|
458
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
459
|
+
data: {
|
|
460
|
+
result: etherscanERC1155Operations,
|
|
461
|
+
},
|
|
462
|
+
}));
|
|
463
|
+
|
|
464
|
+
const response = await ETHERSCAN_API.getLastERC1155Operations(
|
|
465
|
+
currency,
|
|
466
|
+
account.freshAddress,
|
|
467
|
+
account.id,
|
|
468
|
+
0,
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
expect(response).toEqual(
|
|
472
|
+
[
|
|
473
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[0], 0),
|
|
474
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[1], 0),
|
|
475
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[2], 1),
|
|
476
|
+
].flat(),
|
|
477
|
+
);
|
|
478
|
+
expect(spy).toBeCalledWith({
|
|
479
|
+
method: "GET",
|
|
480
|
+
url: `mock/api?module=account&action=token1155tx&address=${account.freshAddress}&tag=latest&page=1&sort=desc`,
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it("should return a flat list of erc1155 transactions from block 50", async () => {
|
|
485
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
486
|
+
data: {
|
|
487
|
+
result: etherscanERC1155Operations,
|
|
488
|
+
},
|
|
489
|
+
}));
|
|
490
|
+
|
|
491
|
+
const response = await ETHERSCAN_API.getLastERC1155Operations(
|
|
492
|
+
currency,
|
|
493
|
+
account.freshAddress,
|
|
494
|
+
account.id,
|
|
495
|
+
50,
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
expect(response).toEqual(
|
|
499
|
+
[
|
|
500
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[0], 0),
|
|
501
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[1], 0),
|
|
502
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[2], 1),
|
|
503
|
+
].flat(),
|
|
504
|
+
);
|
|
505
|
+
expect(spy).toBeCalledWith({
|
|
506
|
+
method: "GET",
|
|
507
|
+
url: `mock/api?module=account&action=token1155tx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50`,
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("should return a flat list of erc1155 transactions from block 50 to block 100", async () => {
|
|
512
|
+
const spy = jest.spyOn(axios, "request").mockImplementation(async () => ({
|
|
513
|
+
data: {
|
|
514
|
+
result: etherscanERC1155Operations,
|
|
515
|
+
},
|
|
516
|
+
}));
|
|
517
|
+
|
|
518
|
+
const response = await ETHERSCAN_API.getLastERC1155Operations(
|
|
519
|
+
currency,
|
|
520
|
+
account.freshAddress,
|
|
521
|
+
account.id,
|
|
522
|
+
50,
|
|
523
|
+
100,
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
expect(response).toEqual(
|
|
527
|
+
[
|
|
528
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[0], 0),
|
|
529
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[1], 0),
|
|
530
|
+
etherscanERC1155EventToOperations(account.id, etherscanERC1155Operations[2], 1),
|
|
531
|
+
].flat(),
|
|
532
|
+
);
|
|
533
|
+
expect(spy).toBeCalledWith({
|
|
534
|
+
method: "GET",
|
|
535
|
+
url: `mock/api?module=account&action=token1155tx&address=${account.freshAddress}&tag=latest&page=1&sort=desc&startBlock=50&endBlock=100`,
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
describe("getLastNftOperations", () => {
|
|
541
|
+
it("should return a sorted array of nft transactions", async () => {
|
|
542
|
+
jest.spyOn(axios, "request").mockImplementation(async params => ({
|
|
543
|
+
data: {
|
|
544
|
+
result: params.url?.includes("tokennfttx")
|
|
545
|
+
? etherscanERC721Operations
|
|
546
|
+
: etherscanERC1155Operations,
|
|
547
|
+
},
|
|
548
|
+
}));
|
|
549
|
+
|
|
550
|
+
const response = await ETHERSCAN_API.getLastNftOperations(
|
|
551
|
+
currency,
|
|
552
|
+
account.freshAddress,
|
|
553
|
+
account.id,
|
|
554
|
+
0,
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
expect(response).toEqual(
|
|
558
|
+
response.slice().sort((a, b) => b.date.getTime() - a.date.getTime()),
|
|
559
|
+
);
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AssertionError, fail } from "assert";
|
|
2
|
+
import { getExplorerApi } from "../../../../api/explorer";
|
|
3
|
+
import etherscanLikeApi from "../../../../api/explorer/etherscan";
|
|
4
|
+
|
|
5
|
+
describe("EVM Family", () => {
|
|
6
|
+
describe("api/explorer/index.ts", () => {
|
|
7
|
+
describe("getExplorerApi", () => {
|
|
8
|
+
it("should throw when requesting a non existing explorer", async () => {
|
|
9
|
+
try {
|
|
10
|
+
await getExplorerApi({
|
|
11
|
+
id: "not-existing",
|
|
12
|
+
ethereumLikeInfo: { explorer: { type: "anything", uri: "notworking" } },
|
|
13
|
+
} as any);
|
|
14
|
+
fail("Promise should have been rejected");
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (e instanceof AssertionError) {
|
|
17
|
+
throw e;
|
|
18
|
+
}
|
|
19
|
+
expect((e as Error).message).toEqual(`No explorer found for currency "not-existing"`);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should return the etherscan api", async () => {
|
|
24
|
+
const explorerA = await getExplorerApi({
|
|
25
|
+
ethereumLikeInfo: { explorer: { type: "etherscan", uri: "working" } },
|
|
26
|
+
} as any);
|
|
27
|
+
const explorerB = await getExplorerApi({
|
|
28
|
+
ethereumLikeInfo: { explorer: { type: "blockscout", uri: "working" } },
|
|
29
|
+
} as any);
|
|
30
|
+
|
|
31
|
+
expect(explorerA).toBe(etherscanLikeApi);
|
|
32
|
+
expect(explorerB).toBe(etherscanLikeApi);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
|
2
|
-
import { getGasTracker } from "
|
|
3
|
-
import { getGasOptions as ledgerGetGasOptions } from "
|
|
2
|
+
import { getGasTracker } from "../../../../api/gasTracker";
|
|
3
|
+
import { getGasOptions as ledgerGetGasOptions } from "../../../../api/gasTracker/ledger";
|
|
4
4
|
|
|
5
5
|
const fakeCurrency: Partial<CryptoCurrency> = {
|
|
6
6
|
id: "my_new_chain" as CryptoCurrencyId,
|
|
@@ -22,7 +22,7 @@ const fakeCurrencyWithoutGasTracker: Partial<CryptoCurrency> = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
describe("EVM Family", () => {
|
|
25
|
-
describe("gasTracker", () => {
|
|
25
|
+
describe("api/gasTracker/index.ts", () => {
|
|
26
26
|
it("should return null if no gas tracker is found", () => {
|
|
27
27
|
expect(getGasTracker(fakeCurrencyWithoutGasTracker as CryptoCurrency)).toBeNull();
|
|
28
28
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import network from "@ledgerhq/live-network/network";
|
|
2
2
|
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
|
3
3
|
import BigNumber from "bignumber.js";
|
|
4
|
-
import { GasOptions } from "
|
|
4
|
+
import { GasOptions } from "../../../../types";
|
|
5
5
|
import { getEnv, setEnv } from "@ledgerhq/live-env";
|
|
6
|
-
import { getGasOptions } from "
|
|
6
|
+
import { getGasOptions } from "../../../../api/gasTracker/ledger";
|
|
7
7
|
jest.mock("@ledgerhq/live-network/network");
|
|
8
8
|
|
|
9
9
|
const fakeCurrency: Partial<CryptoCurrency> = {
|
|
@@ -19,7 +19,7 @@ const fakeCurrency: Partial<CryptoCurrency> = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
describe("EVM Family", () => {
|
|
22
|
-
describe("gasTracker", () => {
|
|
22
|
+
describe("api/gasTracker/index.ts", () => {
|
|
23
23
|
const originalEIP1559_BASE_FEE_MULTIPLIER: number = getEnv("EIP1559_BASE_FEE_MULTIPLIER");
|
|
24
24
|
|
|
25
25
|
beforeAll(() => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
import { AssertionError, fail } from "assert";
|
|
1
4
|
import { delay } from "@ledgerhq/live-promise";
|
|
2
5
|
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import * as RPC_API from "
|
|
7
|
-
import { GasEstimationError, InsufficientFunds } from "../errors";
|
|
8
|
-
import { makeAccount } from "../testUtils";
|
|
9
|
-
import { Transaction as EvmTransaction, EvmTransactionLegacy } from "../types";
|
|
6
|
+
import { EvmTransactionLegacy, Transaction as EvmTransaction } from "../../../../types";
|
|
7
|
+
import { GasEstimationError, InsufficientFunds } from "../../../../errors";
|
|
8
|
+
import { makeAccount } from "../../../fixtures/common.fixtures";
|
|
9
|
+
import * as RPC_API from "../../../../api/rpc/rpc.common";
|
|
10
10
|
|
|
11
11
|
const fakeCurrency: Partial<CryptoCurrency> = {
|
|
12
12
|
id: "my_new_chain" as CryptoCurrencyId,
|
|
@@ -114,11 +114,14 @@ describe("EVM Family", () => {
|
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
describe("api/rpc.common.ts", () => {
|
|
117
|
+
describe("api/rpc/rpc.common.ts", () => {
|
|
118
118
|
describe("withApi", () => {
|
|
119
119
|
it("should throw if the currency doesn't have an RPC node", async () => {
|
|
120
120
|
try {
|
|
121
|
-
await RPC_API.withApi(
|
|
121
|
+
await RPC_API.withApi(
|
|
122
|
+
fakeCurrencyWithoutRPC as CryptoCurrency,
|
|
123
|
+
(() => Promise.resolve()) as any,
|
|
124
|
+
);
|
|
122
125
|
fail("Promise should have been rejected");
|
|
123
126
|
} catch (e) {
|
|
124
127
|
if (e instanceof AssertionError) {
|
|
@@ -128,8 +131,8 @@ describe("EVM Family", () => {
|
|
|
128
131
|
}
|
|
129
132
|
});
|
|
130
133
|
|
|
131
|
-
it("should retry on fail
|
|
132
|
-
let retries =
|
|
134
|
+
it("should retry on fail", async () => {
|
|
135
|
+
let retries = 2;
|
|
133
136
|
const spy = jest.fn(async () => {
|
|
134
137
|
if (retries) {
|
|
135
138
|
--retries;
|
|
@@ -137,11 +140,11 @@ describe("EVM Family", () => {
|
|
|
137
140
|
}
|
|
138
141
|
return true;
|
|
139
142
|
});
|
|
140
|
-
const response = await RPC_API.withApi(fakeCurrency as CryptoCurrency, spy);
|
|
143
|
+
const response = await RPC_API.withApi(fakeCurrency as CryptoCurrency, spy, retries);
|
|
141
144
|
|
|
142
145
|
expect(response).toBe(true);
|
|
143
|
-
// it should fail
|
|
144
|
-
expect(spy).toBeCalledTimes(
|
|
146
|
+
// it should fail 2 times and succeed on the next try
|
|
147
|
+
expect(spy).toBeCalledTimes(3);
|
|
145
148
|
});
|
|
146
149
|
|
|
147
150
|
it("should throw after too many retries", async () => {
|