@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
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { decodeAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
2
|
-
import { AccountShapeInfo } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
3
|
-
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
4
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
5
|
-
import { AssertionError, fail } from "assert";
|
|
6
1
|
import BigNumber from "bignumber.js";
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import * as
|
|
12
|
-
import
|
|
13
|
-
|
|
2
|
+
import { AssertionError, fail } from "assert";
|
|
3
|
+
import { decodeAccountId } from "@ledgerhq/coin-framework/account/accountId";
|
|
4
|
+
import { AccountShapeInfo } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
5
|
+
import { makeTokenAccount } from "../fixtures/common.fixtures";
|
|
6
|
+
import * as etherscanAPI from "../../api/explorer/etherscan";
|
|
7
|
+
import * as synchronization from "../../synchronization";
|
|
8
|
+
import * as rpcAPI from "../../api/rpc/rpc.common";
|
|
9
|
+
import { getEnv } from "../../../../env";
|
|
10
|
+
import * as logic from "../../logic";
|
|
11
|
+
import {
|
|
12
|
+
account,
|
|
13
|
+
coinOperations,
|
|
14
|
+
currency,
|
|
15
|
+
erc1155Operations,
|
|
16
|
+
erc721Operations,
|
|
17
|
+
nfts,
|
|
18
|
+
pendingOperation,
|
|
19
|
+
tokenAccount,
|
|
20
|
+
tokenCurrencies,
|
|
21
|
+
tokenOperations,
|
|
22
|
+
} from "../fixtures/synchronization.fixtures";
|
|
23
|
+
|
|
24
|
+
jest.mock("../../api/rpc/rpc.common");
|
|
14
25
|
jest.useFakeTimers().setSystemTime(new Date("2014-04-21"));
|
|
15
26
|
|
|
16
|
-
const currency: CryptoCurrency = {
|
|
17
|
-
...getCryptoCurrencyById("ethereum"),
|
|
18
|
-
ethereumLikeInfo: {
|
|
19
|
-
chainId: 1,
|
|
20
|
-
rpc: "https://my-rpc.com",
|
|
21
|
-
explorer: {
|
|
22
|
-
uri: "https://api.com",
|
|
23
|
-
type: "etherscan",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
27
|
const getAccountShapeParameters: AccountShapeInfo = {
|
|
28
28
|
address: "0xkvn",
|
|
29
29
|
currency,
|
|
@@ -31,80 +31,6 @@ const getAccountShapeParameters: AccountShapeInfo = {
|
|
|
31
31
|
derivationPath: "44'/60'/0'/0/0",
|
|
32
32
|
index: 0,
|
|
33
33
|
};
|
|
34
|
-
const tokenCurrency1 = getTokenById("ethereum/erc20/usd__coin");
|
|
35
|
-
const tokenCurrency2 = getTokenById("ethereum/erc20/usd_tether__erc20_");
|
|
36
|
-
const tokenAccount = makeTokenAccount("0xkvn", tokenCurrency1);
|
|
37
|
-
const account = {
|
|
38
|
-
...makeAccount("0xkvn", currency, [tokenAccount]),
|
|
39
|
-
syncHash: logic.getSyncHash(currency),
|
|
40
|
-
};
|
|
41
|
-
const coinOperation1 = makeOperation({
|
|
42
|
-
hash: "0xH4sH",
|
|
43
|
-
accountId: "js:2:ethereum:0xkvn:",
|
|
44
|
-
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
45
|
-
senders: ["0xd48f2332Eeed88243Cb6b1D0d65a10368A5370f0"], // johnnyhallyday.eth
|
|
46
|
-
transactionSequenceNumber: 1,
|
|
47
|
-
date: new Date(),
|
|
48
|
-
blockHeight: 1,
|
|
49
|
-
});
|
|
50
|
-
const coinOperation2 = makeOperation({
|
|
51
|
-
hash: "0xOtherHash",
|
|
52
|
-
accountId: "js:2:ethereum:0xkvn:",
|
|
53
|
-
transactionSequenceNumber: 2,
|
|
54
|
-
date: new Date(Date.now() + 1),
|
|
55
|
-
blockHeight: 100,
|
|
56
|
-
});
|
|
57
|
-
const coinOperation3 = makeOperation({
|
|
58
|
-
hash: "0xYeTAnOtherHash",
|
|
59
|
-
accountId: "js:2:ethereum:0xkvn:",
|
|
60
|
-
transactionSequenceNumber: 5,
|
|
61
|
-
date: new Date(Date.now() + 2),
|
|
62
|
-
blockHeight: 1000,
|
|
63
|
-
});
|
|
64
|
-
const tokenOperation1 = makeOperation({
|
|
65
|
-
hash: "0xH4sHT0k3n",
|
|
66
|
-
accountId: "js:2:ethereum:0xkvn:+ethereum%2Ferc20%2Fusd__coin",
|
|
67
|
-
blockHash: "0x95dc138a02c1b0e3fd49305f785e8e27e88a885004af13a9b4c62ad94eed07dd",
|
|
68
|
-
recipients: ["0xB0B"],
|
|
69
|
-
senders: ["0x9b744C0451D73C0958d8aA566dAd33022E4Ee797"], // sbf.eth
|
|
70
|
-
contract: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
71
|
-
value: new BigNumber(152021496),
|
|
72
|
-
fee: new BigNumber(1935663357068271),
|
|
73
|
-
type: "OUT",
|
|
74
|
-
date: new Date(),
|
|
75
|
-
blockHeight: 10,
|
|
76
|
-
});
|
|
77
|
-
const tokenOperation2 = makeOperation({
|
|
78
|
-
hash: "0xTokenHashAga1n",
|
|
79
|
-
accountId: "js:2:ethereum:0xkvn:+ethereum%2Ferc20%2Fusd__coin",
|
|
80
|
-
contract: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
81
|
-
date: new Date(Date.now() + 1),
|
|
82
|
-
blockHeight: 1000,
|
|
83
|
-
});
|
|
84
|
-
const tokenOperation3 = makeOperation({
|
|
85
|
-
hash: "0xTokenHashAga1n",
|
|
86
|
-
accountId: "js:2:ethereum:0xkvn:+ethereum%2Ferc20%2Fusd__coin",
|
|
87
|
-
contract: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
88
|
-
date: new Date(Date.now() + 2),
|
|
89
|
-
blockHeight: 10000,
|
|
90
|
-
});
|
|
91
|
-
const tokenOperation4 = makeOperation({
|
|
92
|
-
hash: "0xTokenHashOtherToken",
|
|
93
|
-
accountId: "js:2:ethereum:0xkvn:+ethereum%2Ferc20%2Fusd_tether__erc20_",
|
|
94
|
-
contract: "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
|
95
|
-
date: new Date(Date.now() + 3),
|
|
96
|
-
blockHeight: 11000,
|
|
97
|
-
});
|
|
98
|
-
const ignoredTokenOperation = makeOperation({
|
|
99
|
-
hash: "0xigN0r3Me",
|
|
100
|
-
accountId: "js:2:ethereum:0xkvn:+ethereum%2Ferc20%2Fusd_tether__erc20_",
|
|
101
|
-
contract: "0xUnknownContract",
|
|
102
|
-
date: new Date(Date.now() + 4),
|
|
103
|
-
blockHeight: 12000,
|
|
104
|
-
});
|
|
105
|
-
const pendingOperation = makeOperation({
|
|
106
|
-
hash: "123",
|
|
107
|
-
});
|
|
108
34
|
|
|
109
35
|
describe("EVM Family", () => {
|
|
110
36
|
describe("synchronization.ts", () => {
|
|
@@ -113,7 +39,7 @@ describe("EVM Family", () => {
|
|
|
113
39
|
// Mocking getAccount to prevent network calls
|
|
114
40
|
jest.spyOn(rpcAPI, "getBalanceAndBlock").mockImplementation(() =>
|
|
115
41
|
Promise.resolve({
|
|
116
|
-
blockHeight:
|
|
42
|
+
blockHeight: 6969,
|
|
117
43
|
balance: new BigNumber(100),
|
|
118
44
|
}),
|
|
119
45
|
);
|
|
@@ -180,18 +106,20 @@ describe("EVM Family", () => {
|
|
|
180
106
|
|
|
181
107
|
describe("With no transactions fetched", () => {
|
|
182
108
|
beforeAll(() => {
|
|
183
|
-
jest
|
|
184
|
-
.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
109
|
+
jest.spyOn(etherscanAPI, "getLastOperations").mockImplementation(() =>
|
|
110
|
+
Promise.resolve({
|
|
111
|
+
lastCoinOperations: [],
|
|
112
|
+
lastTokenOperations: [],
|
|
113
|
+
lastNftOperations: [],
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
jest.spyOn(etherscanAPI?.default, "getLastOperations").mockImplementation(() =>
|
|
117
|
+
Promise.resolve({
|
|
118
|
+
lastCoinOperations: [],
|
|
119
|
+
lastTokenOperations: [],
|
|
120
|
+
lastNftOperations: [],
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
195
123
|
});
|
|
196
124
|
|
|
197
125
|
afterAll(() => {
|
|
@@ -233,25 +161,25 @@ describe("EVM Family", () => {
|
|
|
233
161
|
getAccountShapeParameters,
|
|
234
162
|
{} as any,
|
|
235
163
|
);
|
|
236
|
-
expect(account.blockHeight).toBe(
|
|
164
|
+
expect(account.blockHeight).toBe(6969);
|
|
237
165
|
});
|
|
238
166
|
|
|
239
167
|
it("should keep the operations from a sync to another", async () => {
|
|
240
|
-
const operations = [
|
|
241
|
-
const
|
|
168
|
+
const operations = [coinOperations[0]];
|
|
169
|
+
const tokenOps = [tokenOperations[0]];
|
|
242
170
|
const accountWithSubAccount = await synchronization.getAccountShape(
|
|
243
171
|
{
|
|
244
172
|
...getAccountShapeParameters,
|
|
245
173
|
initialAccount: {
|
|
246
174
|
...account,
|
|
247
175
|
operations,
|
|
248
|
-
subAccounts: [{ ...tokenAccount, operations:
|
|
176
|
+
subAccounts: [{ ...tokenAccount, operations: tokenOps }],
|
|
249
177
|
},
|
|
250
178
|
},
|
|
251
179
|
{} as any,
|
|
252
180
|
);
|
|
253
181
|
expect(accountWithSubAccount.operations).toBe(operations);
|
|
254
|
-
expect(accountWithSubAccount?.subAccounts?.[0].operations).toBe(
|
|
182
|
+
expect(accountWithSubAccount?.subAccounts?.[0].operations).toBe(tokenOps);
|
|
255
183
|
});
|
|
256
184
|
|
|
257
185
|
it("should do a full sync when syncHash changes", async () => {
|
|
@@ -262,51 +190,41 @@ describe("EVM Family", () => {
|
|
|
262
190
|
...getAccountShapeParameters,
|
|
263
191
|
initialAccount: {
|
|
264
192
|
...account,
|
|
265
|
-
operations: [
|
|
266
|
-
subAccounts: [{ ...tokenAccount, operations: [
|
|
193
|
+
operations: [coinOperations[0]],
|
|
194
|
+
subAccounts: [{ ...tokenAccount, operations: [tokenOperations[0]] }],
|
|
267
195
|
},
|
|
268
196
|
},
|
|
269
197
|
{} as any,
|
|
270
198
|
);
|
|
271
199
|
|
|
272
|
-
expect(etherscanAPI?.default.
|
|
273
|
-
getAccountShapeParameters.currency,
|
|
274
|
-
getAccountShapeParameters.address,
|
|
275
|
-
account.id,
|
|
276
|
-
0,
|
|
277
|
-
);
|
|
278
|
-
expect(etherscanAPI?.default.getLastTokenOperations).toHaveBeenCalledWith(
|
|
200
|
+
expect(etherscanAPI?.default.getLastOperations).toHaveBeenCalledWith(
|
|
279
201
|
getAccountShapeParameters.currency,
|
|
280
202
|
getAccountShapeParameters.address,
|
|
281
203
|
account.id,
|
|
282
204
|
0,
|
|
205
|
+
6969,
|
|
283
206
|
);
|
|
284
207
|
});
|
|
285
208
|
|
|
286
|
-
it("should do
|
|
209
|
+
it("should do an incremental sync when syncHash is identical", async () => {
|
|
287
210
|
await synchronization.getAccountShape(
|
|
288
211
|
{
|
|
289
212
|
...getAccountShapeParameters,
|
|
290
213
|
initialAccount: {
|
|
291
214
|
...account,
|
|
292
|
-
operations: [
|
|
293
|
-
subAccounts: [{ ...tokenAccount, operations: [
|
|
215
|
+
operations: [coinOperations[2]],
|
|
216
|
+
subAccounts: [{ ...tokenAccount, operations: [tokenOperations[0]] }],
|
|
294
217
|
},
|
|
295
218
|
},
|
|
296
219
|
{} as any,
|
|
297
220
|
);
|
|
298
221
|
|
|
299
|
-
expect(etherscanAPI?.default.
|
|
300
|
-
getAccountShapeParameters.currency,
|
|
301
|
-
getAccountShapeParameters.address,
|
|
302
|
-
account.id,
|
|
303
|
-
coinOperation1.blockHeight,
|
|
304
|
-
);
|
|
305
|
-
expect(etherscanAPI?.default.getLastTokenOperations).toHaveBeenCalledWith(
|
|
222
|
+
expect(etherscanAPI?.default.getLastOperations).toHaveBeenCalledWith(
|
|
306
223
|
getAccountShapeParameters.currency,
|
|
307
224
|
getAccountShapeParameters.address,
|
|
308
225
|
account.id,
|
|
309
|
-
|
|
226
|
+
coinOperations[2].blockHeight! - synchronization.SAFE_REORG_THRESHOLD,
|
|
227
|
+
6969,
|
|
310
228
|
);
|
|
311
229
|
});
|
|
312
230
|
});
|
|
@@ -314,24 +232,30 @@ describe("EVM Family", () => {
|
|
|
314
232
|
describe("With transactions fetched", () => {
|
|
315
233
|
beforeAll(() => {
|
|
316
234
|
jest
|
|
317
|
-
.spyOn(etherscanAPI
|
|
318
|
-
.mockImplementation(() =>
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
},
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
235
|
+
.spyOn(etherscanAPI, "getLastCoinOperations")
|
|
236
|
+
.mockImplementation(() =>
|
|
237
|
+
Promise.resolve([{ ...coinOperations[0] }, { ...coinOperations[1] }]),
|
|
238
|
+
);
|
|
239
|
+
jest
|
|
240
|
+
.spyOn(etherscanAPI, "getLastTokenOperations")
|
|
241
|
+
.mockImplementation(() =>
|
|
242
|
+
Promise.resolve([{ ...tokenOperations[0] }, { ...tokenOperations[1] }]),
|
|
243
|
+
);
|
|
244
|
+
jest
|
|
245
|
+
.spyOn(etherscanAPI, "getLastNftOperations")
|
|
246
|
+
.mockImplementation(() =>
|
|
247
|
+
Promise.resolve([
|
|
248
|
+
{ ...erc721Operations[0] },
|
|
249
|
+
{ ...erc721Operations[1] },
|
|
250
|
+
{ ...erc721Operations[2] },
|
|
251
|
+
{ ...erc1155Operations[0] },
|
|
252
|
+
{ ...erc1155Operations[1] },
|
|
253
|
+
]),
|
|
254
|
+
);
|
|
331
255
|
jest
|
|
332
256
|
.spyOn(rpcAPI, "getTokenBalance")
|
|
333
257
|
.mockImplementation(async (a, b, contractAddress) => {
|
|
334
|
-
if (contractAddress ===
|
|
258
|
+
if (contractAddress === tokenCurrencies[0].contractAddress) {
|
|
335
259
|
return new BigNumber(10000);
|
|
336
260
|
}
|
|
337
261
|
throw new Error("Shouldn't be trying to fetch this token balance");
|
|
@@ -350,18 +274,65 @@ describe("EVM Family", () => {
|
|
|
350
274
|
},
|
|
351
275
|
{} as any,
|
|
352
276
|
);
|
|
353
|
-
|
|
277
|
+
|
|
278
|
+
expect(accountShape.operations).toEqual([
|
|
279
|
+
{
|
|
280
|
+
...coinOperations[1],
|
|
281
|
+
nftOperations: [erc721Operations[1], erc721Operations[2], erc1155Operations[1]],
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
...tokenOperations[1],
|
|
285
|
+
id: `js:2:ethereum:0xkvn:-${tokenOperations[1].hash}-NONE`,
|
|
286
|
+
type: "NONE",
|
|
287
|
+
value: new BigNumber(0),
|
|
288
|
+
fee: new BigNumber(0),
|
|
289
|
+
senders: [],
|
|
290
|
+
recipients: [],
|
|
291
|
+
subOperations: [tokenOperations[1]],
|
|
292
|
+
accountId: "",
|
|
293
|
+
contract: undefined,
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
...coinOperations[0],
|
|
297
|
+
subOperations: [tokenOperations[0]],
|
|
298
|
+
nftOperations: [erc721Operations[0], erc1155Operations[0]],
|
|
299
|
+
},
|
|
300
|
+
]);
|
|
301
|
+
|
|
354
302
|
expect(accountShape?.subAccounts?.[0]?.operations).toEqual([
|
|
355
|
-
|
|
356
|
-
|
|
303
|
+
tokenOperations[1],
|
|
304
|
+
tokenOperations[0],
|
|
357
305
|
]);
|
|
358
306
|
});
|
|
359
307
|
|
|
308
|
+
it("should add aggregated NFTs to the account", async () => {
|
|
309
|
+
const accountShape = await synchronization.getAccountShape(
|
|
310
|
+
{
|
|
311
|
+
...getAccountShapeParameters,
|
|
312
|
+
initialAccount: account,
|
|
313
|
+
},
|
|
314
|
+
{} as any,
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
expect(accountShape.nfts).toEqual([nfts[0], nfts[1]]);
|
|
318
|
+
});
|
|
319
|
+
|
|
360
320
|
it("should return a partial account based on blockHeight", async () => {
|
|
361
|
-
jest
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
321
|
+
jest.spyOn(etherscanAPI?.default, "getLastOperations").mockImplementation(async () => ({
|
|
322
|
+
lastTokenOperations: [],
|
|
323
|
+
lastNftOperations: [],
|
|
324
|
+
lastCoinOperations: [coinOperations[2]],
|
|
325
|
+
}));
|
|
326
|
+
const operations = [
|
|
327
|
+
{
|
|
328
|
+
...coinOperations[1],
|
|
329
|
+
nftOperations: [erc721Operations[1], erc721Operations[2], erc1155Operations[1]],
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
...coinOperations[0],
|
|
333
|
+
nftOperations: [erc721Operations[0], erc1155Operations[0]],
|
|
334
|
+
},
|
|
335
|
+
];
|
|
365
336
|
const accountShape = await synchronization.getAccountShape(
|
|
366
337
|
{
|
|
367
338
|
...getAccountShapeParameters,
|
|
@@ -379,18 +350,11 @@ describe("EVM Family", () => {
|
|
|
379
350
|
syncHash: expect.stringMatching(/^0x[A-Fa-f0-9]{64}$/), // matching a sha256 hex
|
|
380
351
|
balance: new BigNumber(100),
|
|
381
352
|
spendableBalance: new BigNumber(100),
|
|
382
|
-
|
|
383
|
-
|
|
353
|
+
nfts: [nfts[0], nfts[1]],
|
|
354
|
+
blockHeight: 6969,
|
|
355
|
+
operations: [coinOperations[2], ...operations],
|
|
384
356
|
operationsCount: 3,
|
|
385
|
-
subAccounts:
|
|
386
|
-
{
|
|
387
|
-
...tokenAccount,
|
|
388
|
-
balance: new BigNumber(10000),
|
|
389
|
-
spendableBalance: new BigNumber(10000),
|
|
390
|
-
operations: [tokenOperation2, tokenOperation1],
|
|
391
|
-
operationsCount: 2,
|
|
392
|
-
},
|
|
393
|
-
],
|
|
357
|
+
subAccounts: account.subAccounts,
|
|
394
358
|
lastSyncDate: new Date("2014-04-21"),
|
|
395
359
|
});
|
|
396
360
|
});
|
|
@@ -398,22 +362,17 @@ describe("EVM Family", () => {
|
|
|
398
362
|
|
|
399
363
|
describe("With pending operations", () => {
|
|
400
364
|
beforeAll(() => {
|
|
401
|
-
jest
|
|
402
|
-
.
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
.spyOn(etherscanAPI, "getLastTokenOperations")
|
|
409
|
-
.mockImplementation(() => Promise.resolve([]));
|
|
410
|
-
jest
|
|
411
|
-
.spyOn(etherscanAPI?.default, "getLastTokenOperations")
|
|
412
|
-
.mockImplementation(() => Promise.resolve([]));
|
|
365
|
+
jest.spyOn(etherscanAPI?.default, "getLastOperations").mockImplementation(() =>
|
|
366
|
+
Promise.resolve({
|
|
367
|
+
lastCoinOperations: [],
|
|
368
|
+
lastTokenOperations: [],
|
|
369
|
+
lastNftOperations: [],
|
|
370
|
+
}),
|
|
371
|
+
);
|
|
413
372
|
jest
|
|
414
373
|
.spyOn(synchronization, "getOperationStatus")
|
|
415
374
|
.mockImplementation((currency, op) =>
|
|
416
|
-
Promise.resolve(op.hash ===
|
|
375
|
+
Promise.resolve(op.hash === coinOperations[0].hash ? coinOperations[0] : null),
|
|
417
376
|
);
|
|
418
377
|
});
|
|
419
378
|
|
|
@@ -429,9 +388,9 @@ describe("EVM Family", () => {
|
|
|
429
388
|
...account,
|
|
430
389
|
// 2 operations to confirm here, they're differenciated by id
|
|
431
390
|
pendingOperations: [
|
|
432
|
-
|
|
391
|
+
coinOperations[0],
|
|
433
392
|
{
|
|
434
|
-
...
|
|
393
|
+
...coinOperations[0],
|
|
435
394
|
hash: "0xN0tH4sH",
|
|
436
395
|
id: "js:2:ethereum:0xkvn:-0xN0tH4sH-OUT",
|
|
437
396
|
},
|
|
@@ -441,7 +400,7 @@ describe("EVM Family", () => {
|
|
|
441
400
|
{} as any,
|
|
442
401
|
);
|
|
443
402
|
|
|
444
|
-
expect(accountShape.operations).toEqual([
|
|
403
|
+
expect(accountShape.operations).toEqual([coinOperations[0]]);
|
|
445
404
|
});
|
|
446
405
|
});
|
|
447
406
|
});
|
|
@@ -464,38 +423,29 @@ describe("EVM Family", () => {
|
|
|
464
423
|
});
|
|
465
424
|
|
|
466
425
|
it("should return the right subAccounts", async () => {
|
|
467
|
-
jest.spyOn(etherscanAPI?.default, "getLastTokenOperations").mockImplementation(async () => [
|
|
468
|
-
{ tokenCurrency: tokenCurrency1, operation: tokenOperation1 },
|
|
469
|
-
{ tokenCurrency: tokenCurrency1, operation: tokenOperation2 },
|
|
470
|
-
{ tokenCurrency: tokenCurrency2, operation: tokenOperation4 },
|
|
471
|
-
{
|
|
472
|
-
tokenCurrency: undefined as any,
|
|
473
|
-
operation: ignoredTokenOperation,
|
|
474
|
-
},
|
|
475
|
-
]);
|
|
476
|
-
|
|
477
426
|
const tokenAccounts = await synchronization.getSubAccounts(
|
|
478
427
|
{
|
|
479
428
|
...getAccountShapeParameters,
|
|
480
429
|
initialAccount: account,
|
|
481
430
|
},
|
|
482
431
|
account.id,
|
|
432
|
+
[tokenOperations[0], tokenOperations[1], tokenOperations[3]],
|
|
483
433
|
);
|
|
484
434
|
|
|
485
435
|
const expectedUsdcAccount = {
|
|
486
436
|
...tokenAccount,
|
|
487
437
|
balance: new BigNumber(1),
|
|
488
438
|
spendableBalance: new BigNumber(1),
|
|
489
|
-
operations: [
|
|
439
|
+
operations: [tokenOperations[0], tokenOperations[1]],
|
|
490
440
|
operationsCount: 2,
|
|
491
441
|
starred: undefined,
|
|
492
442
|
swapHistory: [],
|
|
493
443
|
};
|
|
494
444
|
const expectedUsdtAccount = {
|
|
495
|
-
...makeTokenAccount(account.freshAddress,
|
|
445
|
+
...makeTokenAccount(account.freshAddress, tokenCurrencies[1]),
|
|
496
446
|
balance: new BigNumber(2),
|
|
497
447
|
spendableBalance: new BigNumber(2),
|
|
498
|
-
operations: [
|
|
448
|
+
operations: [tokenOperations[3]],
|
|
499
449
|
operationsCount: 1,
|
|
500
450
|
starred: undefined,
|
|
501
451
|
swapHistory: [],
|
|
@@ -503,80 +453,6 @@ describe("EVM Family", () => {
|
|
|
503
453
|
|
|
504
454
|
expect(tokenAccounts).toEqual([expectedUsdcAccount, expectedUsdtAccount]);
|
|
505
455
|
});
|
|
506
|
-
|
|
507
|
-
it("should return a partial sub account based on blockHeight", async () => {
|
|
508
|
-
jest
|
|
509
|
-
.spyOn(etherscanAPI?.default, "getLastTokenOperations")
|
|
510
|
-
.mockImplementation(async () => [
|
|
511
|
-
{ tokenCurrency: tokenCurrency1, operation: tokenOperation3 },
|
|
512
|
-
]);
|
|
513
|
-
|
|
514
|
-
const incompleteUsdcAccount = {
|
|
515
|
-
...tokenAccount,
|
|
516
|
-
balance: new BigNumber(0),
|
|
517
|
-
spendableBalance: new BigNumber(0),
|
|
518
|
-
operations: [tokenOperation1, tokenOperation2],
|
|
519
|
-
operationsCount: 1,
|
|
520
|
-
};
|
|
521
|
-
const accountWithIncompleteSubAccount = {
|
|
522
|
-
...account,
|
|
523
|
-
subAccounts: [incompleteUsdcAccount],
|
|
524
|
-
};
|
|
525
|
-
|
|
526
|
-
const tokenAccounts = await synchronization.getSubAccounts(
|
|
527
|
-
{
|
|
528
|
-
...getAccountShapeParameters,
|
|
529
|
-
initialAccount: accountWithIncompleteSubAccount,
|
|
530
|
-
},
|
|
531
|
-
account.id,
|
|
532
|
-
);
|
|
533
|
-
|
|
534
|
-
const expectedUsdcAccount = {
|
|
535
|
-
...incompleteUsdcAccount,
|
|
536
|
-
balance: new BigNumber(1),
|
|
537
|
-
spendableBalance: new BigNumber(1),
|
|
538
|
-
operations: [tokenOperation3],
|
|
539
|
-
operationsCount: 1,
|
|
540
|
-
starred: undefined,
|
|
541
|
-
swapHistory: [],
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
expect(tokenAccounts).toEqual([expectedUsdcAccount]);
|
|
545
|
-
// (currency, address, accountId, fromBlock)
|
|
546
|
-
expect(etherscanAPI.default.getLastTokenOperations).toBeCalledWith(
|
|
547
|
-
currency,
|
|
548
|
-
account.freshAddress,
|
|
549
|
-
account.id,
|
|
550
|
-
tokenOperation2.blockHeight,
|
|
551
|
-
);
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
it("should throw for currency with unsupported explorer", async () => {
|
|
555
|
-
try {
|
|
556
|
-
await synchronization.getSubAccounts(
|
|
557
|
-
{
|
|
558
|
-
...getAccountShapeParameters,
|
|
559
|
-
currency: {
|
|
560
|
-
...currency,
|
|
561
|
-
ethereumLikeInfo: {
|
|
562
|
-
chainId: 1,
|
|
563
|
-
explorer: {
|
|
564
|
-
uri: "http://nope.com",
|
|
565
|
-
type: "unsupported" as any,
|
|
566
|
-
},
|
|
567
|
-
},
|
|
568
|
-
},
|
|
569
|
-
},
|
|
570
|
-
account.id,
|
|
571
|
-
);
|
|
572
|
-
fail("Promise should have been rejected");
|
|
573
|
-
} catch (e: any) {
|
|
574
|
-
if (e instanceof AssertionError) {
|
|
575
|
-
throw e;
|
|
576
|
-
}
|
|
577
|
-
expect(e.message).toMatch("No explorer found for currency");
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
456
|
});
|
|
581
457
|
|
|
582
458
|
describe("getSubAccountShape", () => {
|
|
@@ -600,15 +476,15 @@ describe("EVM Family", () => {
|
|
|
600
476
|
const subAccount = await synchronization.getSubAccountShape(
|
|
601
477
|
currency,
|
|
602
478
|
account.id,
|
|
603
|
-
|
|
604
|
-
[
|
|
479
|
+
tokenCurrencies[0],
|
|
480
|
+
[tokenOperations[0], tokenOperations[1], tokenOperations[2]],
|
|
605
481
|
);
|
|
606
482
|
|
|
607
483
|
expect(subAccount).toEqual({
|
|
608
484
|
...tokenAccount,
|
|
609
485
|
balance: new BigNumber(1),
|
|
610
486
|
spendableBalance: new BigNumber(1),
|
|
611
|
-
operations: [
|
|
487
|
+
operations: [tokenOperations[0], tokenOperations[1], tokenOperations[2]],
|
|
612
488
|
operationsCount: 3,
|
|
613
489
|
starred: undefined,
|
|
614
490
|
swapHistory: [],
|
|
@@ -622,7 +498,11 @@ describe("EVM Family", () => {
|
|
|
622
498
|
throw new Error();
|
|
623
499
|
});
|
|
624
500
|
|
|
625
|
-
|
|
501
|
+
const operationStatus = await synchronization.getOperationStatus(
|
|
502
|
+
currency,
|
|
503
|
+
coinOperations[0],
|
|
504
|
+
);
|
|
505
|
+
expect(operationStatus).toBe(null);
|
|
626
506
|
});
|
|
627
507
|
|
|
628
508
|
it("should return null if retrieved transaction has no blockHeight", async () => {
|
|
@@ -635,7 +515,11 @@ describe("EVM Family", () => {
|
|
|
635
515
|
} as any),
|
|
636
516
|
);
|
|
637
517
|
|
|
638
|
-
|
|
518
|
+
const operationStatus = await synchronization.getOperationStatus(
|
|
519
|
+
currency,
|
|
520
|
+
coinOperations[0],
|
|
521
|
+
);
|
|
522
|
+
expect(operationStatus).toBe(null);
|
|
639
523
|
});
|
|
640
524
|
|
|
641
525
|
it("should return the retrieved operation with network properties", async () => {
|
|
@@ -649,12 +533,31 @@ describe("EVM Family", () => {
|
|
|
649
533
|
} as any),
|
|
650
534
|
);
|
|
651
535
|
|
|
652
|
-
|
|
653
|
-
...coinOperation1,
|
|
536
|
+
const expectedAddition = {
|
|
654
537
|
blockHash: "hash",
|
|
655
538
|
blockHeight: 10,
|
|
656
539
|
date: new Date(),
|
|
657
540
|
transactionSequenceNumber: 123,
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
const operationStatus = await synchronization.getOperationStatus(currency, {
|
|
544
|
+
...coinOperations[0],
|
|
545
|
+
subOperations: [tokenOperations[0]],
|
|
546
|
+
nftOperations: [erc721Operations[0], erc1155Operations[0]],
|
|
547
|
+
});
|
|
548
|
+
expect(operationStatus).toEqual({
|
|
549
|
+
...coinOperations[0],
|
|
550
|
+
...expectedAddition,
|
|
551
|
+
subOperations: [
|
|
552
|
+
{
|
|
553
|
+
...tokenOperations[0],
|
|
554
|
+
...expectedAddition,
|
|
555
|
+
},
|
|
556
|
+
],
|
|
557
|
+
nftOperations: [
|
|
558
|
+
{ ...erc721Operations[0], ...expectedAddition },
|
|
559
|
+
{ ...erc1155Operations[0], ...expectedAddition },
|
|
560
|
+
],
|
|
658
561
|
});
|
|
659
562
|
});
|
|
660
563
|
|
|
@@ -671,12 +574,31 @@ describe("EVM Family", () => {
|
|
|
671
574
|
.spyOn(rpcAPI, "getBlock")
|
|
672
575
|
.mockImplementationOnce(async () => ({ timestamp: Date.now() / 1000 } as any));
|
|
673
576
|
|
|
674
|
-
|
|
675
|
-
...coinOperation1,
|
|
577
|
+
const expectedAddition = {
|
|
676
578
|
blockHash: "hash",
|
|
677
579
|
blockHeight: 10,
|
|
678
580
|
date: new Date(),
|
|
679
581
|
transactionSequenceNumber: 123,
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
const operationStatus = await synchronization.getOperationStatus(currency, {
|
|
585
|
+
...coinOperations[0],
|
|
586
|
+
subOperations: [tokenOperations[0]],
|
|
587
|
+
nftOperations: [erc721Operations[0], erc1155Operations[0]],
|
|
588
|
+
});
|
|
589
|
+
expect(operationStatus).toEqual({
|
|
590
|
+
...coinOperations[0],
|
|
591
|
+
...expectedAddition,
|
|
592
|
+
subOperations: [
|
|
593
|
+
{
|
|
594
|
+
...tokenOperations[0],
|
|
595
|
+
...expectedAddition,
|
|
596
|
+
},
|
|
597
|
+
],
|
|
598
|
+
nftOperations: [
|
|
599
|
+
{ ...erc721Operations[0], ...expectedAddition },
|
|
600
|
+
{ ...erc1155Operations[0], ...expectedAddition },
|
|
601
|
+
],
|
|
680
602
|
});
|
|
681
603
|
});
|
|
682
604
|
});
|