@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,984 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
import { encodeAccountId, encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
4
|
+
import { findTokenById } from "@ledgerhq/cryptoassets";
|
|
5
|
+
import { etherscanERC1155EventToOperations, etherscanERC20EventToOperations, etherscanERC721EventToOperations, etherscanOperationToOperations, transactionToEthersTransaction, } from "../../adapters";
|
|
6
|
+
const testData = Buffer.from("testBufferString").toString("hex");
|
|
7
|
+
const eip1559Tx = {
|
|
8
|
+
amount: new BigNumber(100),
|
|
9
|
+
useAllAmount: false,
|
|
10
|
+
subAccountId: "id",
|
|
11
|
+
recipient: "0xkvn",
|
|
12
|
+
feesStrategy: "custom",
|
|
13
|
+
family: "evm",
|
|
14
|
+
mode: "send",
|
|
15
|
+
nonce: 0,
|
|
16
|
+
gasLimit: new BigNumber(21000),
|
|
17
|
+
chainId: 1,
|
|
18
|
+
data: Buffer.from(testData, "hex"),
|
|
19
|
+
maxFeePerGas: new BigNumber(10000),
|
|
20
|
+
maxPriorityFeePerGas: new BigNumber(10000),
|
|
21
|
+
type: 2,
|
|
22
|
+
};
|
|
23
|
+
const legacyTx = {
|
|
24
|
+
amount: new BigNumber(100),
|
|
25
|
+
useAllAmount: false,
|
|
26
|
+
subAccountId: "id",
|
|
27
|
+
recipient: "0xkvn",
|
|
28
|
+
feesStrategy: "custom",
|
|
29
|
+
family: "evm",
|
|
30
|
+
mode: "send",
|
|
31
|
+
nonce: 0,
|
|
32
|
+
gasLimit: new BigNumber(21000),
|
|
33
|
+
chainId: 1,
|
|
34
|
+
data: Buffer.from(testData, "hex"),
|
|
35
|
+
gasPrice: new BigNumber(10000),
|
|
36
|
+
type: 0,
|
|
37
|
+
};
|
|
38
|
+
describe("EVM Family", () => {
|
|
39
|
+
describe("adapters.ts", () => {
|
|
40
|
+
describe("transactionToEthersTransaction", () => {
|
|
41
|
+
it("should build convert an EIP1559 ledger live transaction to an ethers transaction", () => {
|
|
42
|
+
const ethers1559Tx = {
|
|
43
|
+
to: "0xkvn",
|
|
44
|
+
nonce: 0,
|
|
45
|
+
gasLimit: ethers.BigNumber.from(21000),
|
|
46
|
+
data: "0x" + testData,
|
|
47
|
+
value: ethers.BigNumber.from(100),
|
|
48
|
+
chainId: 1,
|
|
49
|
+
type: 2,
|
|
50
|
+
maxFeePerGas: ethers.BigNumber.from(10000),
|
|
51
|
+
maxPriorityFeePerGas: ethers.BigNumber.from(10000),
|
|
52
|
+
};
|
|
53
|
+
expect(transactionToEthersTransaction(eip1559Tx)).toEqual(ethers1559Tx);
|
|
54
|
+
});
|
|
55
|
+
it("should build convert an legacy ledger live transaction to an ethers transaction", () => {
|
|
56
|
+
const legacyEthersTx = {
|
|
57
|
+
to: "0xkvn",
|
|
58
|
+
nonce: 0,
|
|
59
|
+
gasLimit: ethers.BigNumber.from(21000),
|
|
60
|
+
data: "0x" + testData,
|
|
61
|
+
value: ethers.BigNumber.from(100),
|
|
62
|
+
chainId: 1,
|
|
63
|
+
type: 0,
|
|
64
|
+
gasPrice: ethers.BigNumber.from(10000),
|
|
65
|
+
};
|
|
66
|
+
expect(transactionToEthersTransaction(legacyTx)).toEqual(legacyEthersTx);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe("etherscanOperationToOperations", () => {
|
|
70
|
+
it("should convert an etherscan-like smart contract operation (from their API) to a Ledger Live Operation", () => {
|
|
71
|
+
const etherscanOp = {
|
|
72
|
+
blockNumber: "14923692",
|
|
73
|
+
timeStamp: "1654646570",
|
|
74
|
+
hash: "0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338",
|
|
75
|
+
nonce: "7",
|
|
76
|
+
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
77
|
+
transactionIndex: "27",
|
|
78
|
+
from: "0x9aa99c23f67c81701c772b106b4f83f6e858dd2e",
|
|
79
|
+
to: "0xc5102fe9359fd9a28f877a67e36b0f050d81a3cc",
|
|
80
|
+
value: "0",
|
|
81
|
+
gas: "6000000",
|
|
82
|
+
gasPrice: "125521409858",
|
|
83
|
+
isError: "0",
|
|
84
|
+
txreceipt_status: "1",
|
|
85
|
+
input: "0xa9059cbb000000000000000000000000313143c4088a47c469d06fe3fa5fd4196be6a4d600000000000000000000000000000000000000000003b8e97d229a2d54800000",
|
|
86
|
+
contractAddress: "",
|
|
87
|
+
cumulativeGasUsed: "1977481",
|
|
88
|
+
gasUsed: "57168",
|
|
89
|
+
confirmations: "122471",
|
|
90
|
+
methodId: "0xa9059cbb",
|
|
91
|
+
functionName: "transfer(address _to, uint256 _value)",
|
|
92
|
+
};
|
|
93
|
+
const accountId = encodeAccountId({
|
|
94
|
+
type: "js",
|
|
95
|
+
version: "2",
|
|
96
|
+
currencyId: "ethereum",
|
|
97
|
+
xpubOrAddress: "0x9aa99c23f67c81701c772b106b4f83f6e858dd2e",
|
|
98
|
+
derivationMode: "",
|
|
99
|
+
});
|
|
100
|
+
const expectedOperation = {
|
|
101
|
+
id: "js:2:ethereum:0x9aa99c23f67c81701c772b106b4f83f6e858dd2e:-0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338-FEES",
|
|
102
|
+
hash: "0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338",
|
|
103
|
+
accountId,
|
|
104
|
+
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
105
|
+
blockHeight: 14923692,
|
|
106
|
+
recipients: ["0xc5102fE9359FD9a28f877a67E36B0F050d81a3CC"],
|
|
107
|
+
senders: ["0x9AA99C23F67c81701C772B106b4F83f6e858dd2E"],
|
|
108
|
+
value: new BigNumber("7175807958762144"),
|
|
109
|
+
fee: new BigNumber("7175807958762144"),
|
|
110
|
+
date: new Date("2022-06-08T00:02:50.000Z"),
|
|
111
|
+
transactionSequenceNumber: 7,
|
|
112
|
+
hasFailed: false,
|
|
113
|
+
nftOperations: [],
|
|
114
|
+
subOperations: [],
|
|
115
|
+
type: "FEES",
|
|
116
|
+
extra: {},
|
|
117
|
+
};
|
|
118
|
+
expect(etherscanOperationToOperations(accountId, etherscanOp)).toEqual([expectedOperation]);
|
|
119
|
+
});
|
|
120
|
+
it("should convert an etherscan-like coin out operation (from their API) to a Ledger Live Operation", () => {
|
|
121
|
+
const etherscanOp = {
|
|
122
|
+
blockNumber: "13807766",
|
|
123
|
+
timeStamp: "1639544926",
|
|
124
|
+
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
125
|
+
nonce: "11898499",
|
|
126
|
+
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
127
|
+
transactionIndex: "394",
|
|
128
|
+
from: "0x829bd824b016326a401d083b33d092293333a830",
|
|
129
|
+
to: "0x26e3fd2dec89bf645ba7b41c4ddfad8454ee6245",
|
|
130
|
+
value: "143141441418750645",
|
|
131
|
+
gas: "210000",
|
|
132
|
+
gasPrice: "68363841693",
|
|
133
|
+
isError: "0",
|
|
134
|
+
txreceipt_status: "1",
|
|
135
|
+
input: "0x",
|
|
136
|
+
contractAddress: "",
|
|
137
|
+
cumulativeGasUsed: "14788393",
|
|
138
|
+
gasUsed: "21000",
|
|
139
|
+
confirmations: "2582470",
|
|
140
|
+
methodId: "0x",
|
|
141
|
+
functionName: "",
|
|
142
|
+
};
|
|
143
|
+
const accountId = encodeAccountId({
|
|
144
|
+
type: "js",
|
|
145
|
+
version: "2",
|
|
146
|
+
currencyId: "ethereum",
|
|
147
|
+
xpubOrAddress: "0x829BD824B016326A401d083B33D092293333A830",
|
|
148
|
+
derivationMode: "",
|
|
149
|
+
});
|
|
150
|
+
const expectedOperation = {
|
|
151
|
+
id: "js:2:ethereum:0x829BD824B016326A401d083B33D092293333A830:-0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944-OUT",
|
|
152
|
+
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
153
|
+
accountId,
|
|
154
|
+
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
155
|
+
blockHeight: 13807766,
|
|
156
|
+
recipients: ["0x26E3fd2dEc89bF645BA7b41c4DdFad8454Ee6245"],
|
|
157
|
+
senders: ["0x829BD824B016326A401d083B33D092293333A830"],
|
|
158
|
+
value: new BigNumber("143141441418750645").plus("1435640675553000"),
|
|
159
|
+
fee: new BigNumber("1435640675553000"),
|
|
160
|
+
date: new Date("2021-12-15T05:08:46.000Z"),
|
|
161
|
+
transactionSequenceNumber: 11898499,
|
|
162
|
+
hasFailed: false,
|
|
163
|
+
nftOperations: [],
|
|
164
|
+
subOperations: [],
|
|
165
|
+
type: "OUT",
|
|
166
|
+
extra: {},
|
|
167
|
+
};
|
|
168
|
+
expect(etherscanOperationToOperations(accountId, etherscanOp)).toEqual([expectedOperation]);
|
|
169
|
+
});
|
|
170
|
+
it("should convert an etherscan-like coin in operation (from their API) to a Ledger Live Operation", () => {
|
|
171
|
+
const etherscanOp = {
|
|
172
|
+
blockNumber: "13807766",
|
|
173
|
+
timeStamp: "1639544926",
|
|
174
|
+
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
175
|
+
nonce: "11898499",
|
|
176
|
+
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
177
|
+
transactionIndex: "394",
|
|
178
|
+
from: "0x26e3fd2dec89bf645ba7b41c4ddfad8454ee6245",
|
|
179
|
+
to: "0x829bd824b016326a401d083b33d092293333a830",
|
|
180
|
+
value: "143141441418750645",
|
|
181
|
+
gas: "210000",
|
|
182
|
+
gasPrice: "68363841693",
|
|
183
|
+
isError: "0",
|
|
184
|
+
txreceipt_status: "1",
|
|
185
|
+
input: "0x",
|
|
186
|
+
contractAddress: "",
|
|
187
|
+
cumulativeGasUsed: "14788393",
|
|
188
|
+
gasUsed: "21000",
|
|
189
|
+
confirmations: "2582470",
|
|
190
|
+
methodId: "0x",
|
|
191
|
+
functionName: "",
|
|
192
|
+
};
|
|
193
|
+
const accountId = encodeAccountId({
|
|
194
|
+
type: "js",
|
|
195
|
+
version: "2",
|
|
196
|
+
currencyId: "ethereum",
|
|
197
|
+
xpubOrAddress: "0x829BD824B016326A401d083B33D092293333A830",
|
|
198
|
+
derivationMode: "",
|
|
199
|
+
});
|
|
200
|
+
const expectedOperation = {
|
|
201
|
+
id: "js:2:ethereum:0x829BD824B016326A401d083B33D092293333A830:-0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944-IN",
|
|
202
|
+
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
203
|
+
accountId,
|
|
204
|
+
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
205
|
+
blockHeight: 13807766,
|
|
206
|
+
recipients: ["0x829BD824B016326A401d083B33D092293333A830"],
|
|
207
|
+
senders: ["0x26E3fd2dEc89bF645BA7b41c4DdFad8454Ee6245"],
|
|
208
|
+
value: new BigNumber("143141441418750645"),
|
|
209
|
+
fee: new BigNumber("1435640675553000"),
|
|
210
|
+
date: new Date("2021-12-15T05:08:46.000Z"),
|
|
211
|
+
transactionSequenceNumber: 11898499,
|
|
212
|
+
hasFailed: false,
|
|
213
|
+
nftOperations: [],
|
|
214
|
+
subOperations: [],
|
|
215
|
+
type: "IN",
|
|
216
|
+
extra: {},
|
|
217
|
+
};
|
|
218
|
+
expect(etherscanOperationToOperations(accountId, etherscanOp)).toEqual([expectedOperation]);
|
|
219
|
+
});
|
|
220
|
+
it("should convert an etherscan-like coin none operation (from their API) to a Ledger Live Operation", () => {
|
|
221
|
+
const etherscanOp = {
|
|
222
|
+
blockNumber: "13807766",
|
|
223
|
+
timeStamp: "1639544926",
|
|
224
|
+
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
225
|
+
nonce: "11898499",
|
|
226
|
+
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
227
|
+
transactionIndex: "394",
|
|
228
|
+
from: "0x6bfd74c0996f269bcece59191eff667b3dfd73b9",
|
|
229
|
+
to: "0x02a357476a300c89ce27d7d4c7e57bbd2dd3f006",
|
|
230
|
+
value: "143141441418750645",
|
|
231
|
+
gas: "210000",
|
|
232
|
+
gasPrice: "68363841693",
|
|
233
|
+
isError: "0",
|
|
234
|
+
txreceipt_status: "1",
|
|
235
|
+
input: "0x",
|
|
236
|
+
contractAddress: "",
|
|
237
|
+
cumulativeGasUsed: "14788393",
|
|
238
|
+
gasUsed: "21000",
|
|
239
|
+
confirmations: "2582470",
|
|
240
|
+
methodId: "0x",
|
|
241
|
+
functionName: "",
|
|
242
|
+
};
|
|
243
|
+
const accountId = encodeAccountId({
|
|
244
|
+
type: "js",
|
|
245
|
+
version: "2",
|
|
246
|
+
currencyId: "ethereum",
|
|
247
|
+
xpubOrAddress: "0x829BD824B016326A401d083B33D092293333A830",
|
|
248
|
+
derivationMode: "",
|
|
249
|
+
});
|
|
250
|
+
const expectedOperation = {
|
|
251
|
+
id: "js:2:ethereum:0x829BD824B016326A401d083B33D092293333A830:-0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944-NONE",
|
|
252
|
+
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
253
|
+
accountId,
|
|
254
|
+
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
255
|
+
blockHeight: 13807766,
|
|
256
|
+
recipients: ["0x02a357476A300c89Ce27D7D4C7E57Bbd2DD3f006"],
|
|
257
|
+
senders: ["0x6bfD74C0996F269Bcece59191EFf667b3dFD73b9"],
|
|
258
|
+
value: new BigNumber("143141441418750645"),
|
|
259
|
+
fee: new BigNumber("1435640675553000"),
|
|
260
|
+
date: new Date("2021-12-15T05:08:46.000Z"),
|
|
261
|
+
transactionSequenceNumber: 11898499,
|
|
262
|
+
hasFailed: false,
|
|
263
|
+
nftOperations: [],
|
|
264
|
+
subOperations: [],
|
|
265
|
+
type: "NONE",
|
|
266
|
+
extra: {},
|
|
267
|
+
};
|
|
268
|
+
expect(etherscanOperationToOperations(accountId, etherscanOp)).toEqual([expectedOperation]);
|
|
269
|
+
});
|
|
270
|
+
it("should convert an etherscan-like self send coin operation (from their API) to 2 Ledger Live Operations", () => {
|
|
271
|
+
const etherscanOp = {
|
|
272
|
+
blockNumber: "14923692",
|
|
273
|
+
timeStamp: "1654646570",
|
|
274
|
+
hash: "0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338",
|
|
275
|
+
nonce: "7",
|
|
276
|
+
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
277
|
+
transactionIndex: "27",
|
|
278
|
+
from: "0x9aa99c23f67c81701c772b106b4f83f6e858dd2e",
|
|
279
|
+
to: "0x9aa99c23f67c81701c772b106b4f83f6e858dd2e",
|
|
280
|
+
value: "1000",
|
|
281
|
+
gas: "21000",
|
|
282
|
+
gasPrice: "125521409858",
|
|
283
|
+
isError: "0",
|
|
284
|
+
txreceipt_status: "1",
|
|
285
|
+
input: "",
|
|
286
|
+
contractAddress: "",
|
|
287
|
+
cumulativeGasUsed: "1977481",
|
|
288
|
+
gasUsed: "57168",
|
|
289
|
+
confirmations: "122471",
|
|
290
|
+
methodId: "0x",
|
|
291
|
+
functionName: "",
|
|
292
|
+
};
|
|
293
|
+
const accountId = encodeAccountId({
|
|
294
|
+
type: "js",
|
|
295
|
+
version: "2",
|
|
296
|
+
currencyId: "ethereum",
|
|
297
|
+
xpubOrAddress: "0x9aa99c23f67c81701c772b106b4f83f6e858dd2e",
|
|
298
|
+
derivationMode: "",
|
|
299
|
+
});
|
|
300
|
+
const expectedOperations = [
|
|
301
|
+
{
|
|
302
|
+
id: "js:2:ethereum:0x9aa99c23f67c81701c772b106b4f83f6e858dd2e:-0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338-IN",
|
|
303
|
+
hash: "0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338",
|
|
304
|
+
accountId,
|
|
305
|
+
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
306
|
+
blockHeight: 14923692,
|
|
307
|
+
recipients: ["0x9AA99C23F67c81701C772B106b4F83f6e858dd2E"],
|
|
308
|
+
senders: ["0x9AA99C23F67c81701C772B106b4F83f6e858dd2E"],
|
|
309
|
+
value: new BigNumber("1000"),
|
|
310
|
+
fee: new BigNumber("7175807958762144"),
|
|
311
|
+
date: new Date("2022-06-08T00:02:50.000Z"),
|
|
312
|
+
transactionSequenceNumber: 7,
|
|
313
|
+
hasFailed: false,
|
|
314
|
+
nftOperations: [],
|
|
315
|
+
subOperations: [],
|
|
316
|
+
type: "IN",
|
|
317
|
+
extra: {},
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
id: "js:2:ethereum:0x9aa99c23f67c81701c772b106b4f83f6e858dd2e:-0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338-OUT",
|
|
321
|
+
hash: "0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338",
|
|
322
|
+
accountId,
|
|
323
|
+
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
324
|
+
blockHeight: 14923692,
|
|
325
|
+
recipients: ["0x9AA99C23F67c81701C772B106b4F83f6e858dd2E"],
|
|
326
|
+
senders: ["0x9AA99C23F67c81701C772B106b4F83f6e858dd2E"],
|
|
327
|
+
value: new BigNumber("7175807958763144"),
|
|
328
|
+
fee: new BigNumber("7175807958762144"),
|
|
329
|
+
date: new Date("2022-06-08T00:02:50.000Z"),
|
|
330
|
+
transactionSequenceNumber: 7,
|
|
331
|
+
hasFailed: false,
|
|
332
|
+
nftOperations: [],
|
|
333
|
+
subOperations: [],
|
|
334
|
+
type: "OUT",
|
|
335
|
+
extra: {},
|
|
336
|
+
},
|
|
337
|
+
];
|
|
338
|
+
expect(etherscanOperationToOperations(accountId, etherscanOp)).toEqual(expectedOperations);
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
describe("etherscanERC20EventToOperations", () => {
|
|
342
|
+
it("should return an empty array for an unknown token", () => {
|
|
343
|
+
const etherscanOp = {
|
|
344
|
+
blockNumber: "16240731",
|
|
345
|
+
timeStamp: "1671717983",
|
|
346
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
347
|
+
nonce: "53",
|
|
348
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
349
|
+
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
350
|
+
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb41",
|
|
351
|
+
to: "0xc2907efcce4011c491bbeda8a0fa63ba7aab596c",
|
|
352
|
+
value: "2000000",
|
|
353
|
+
tokenName: "USD Coin",
|
|
354
|
+
tokenSymbol: "USDC",
|
|
355
|
+
tokenDecimal: "6",
|
|
356
|
+
transactionIndex: "65",
|
|
357
|
+
gas: "79381",
|
|
358
|
+
gasPrice: "24314367325",
|
|
359
|
+
gasUsed: "65613",
|
|
360
|
+
cumulativeGasUsed: "4557746",
|
|
361
|
+
input: "deprecated",
|
|
362
|
+
confirmations: "150032",
|
|
363
|
+
};
|
|
364
|
+
const accountId = encodeAccountId({
|
|
365
|
+
type: "js",
|
|
366
|
+
version: "2",
|
|
367
|
+
currencyId: "ethereum",
|
|
368
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
369
|
+
derivationMode: "",
|
|
370
|
+
});
|
|
371
|
+
expect(etherscanERC20EventToOperations(accountId, etherscanOp)).toEqual([]);
|
|
372
|
+
});
|
|
373
|
+
it("should convert an etherscan-like usdc out event (from their API) to a Ledger Live Operation", () => {
|
|
374
|
+
const etherscanOp = {
|
|
375
|
+
blockNumber: "16240731",
|
|
376
|
+
timeStamp: "1671717983",
|
|
377
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
378
|
+
nonce: "53",
|
|
379
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
380
|
+
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
381
|
+
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
382
|
+
to: "0xc2907efcce4011c491bbeda8a0fa63ba7aab596c",
|
|
383
|
+
value: "2000000",
|
|
384
|
+
tokenName: "USD Coin",
|
|
385
|
+
tokenSymbol: "USDC",
|
|
386
|
+
tokenDecimal: "6",
|
|
387
|
+
transactionIndex: "65",
|
|
388
|
+
gas: "79381",
|
|
389
|
+
gasPrice: "24314367325",
|
|
390
|
+
gasUsed: "65613",
|
|
391
|
+
cumulativeGasUsed: "4557746",
|
|
392
|
+
input: "deprecated",
|
|
393
|
+
confirmations: "150032",
|
|
394
|
+
};
|
|
395
|
+
const accountId = encodeAccountId({
|
|
396
|
+
type: "js",
|
|
397
|
+
version: "2",
|
|
398
|
+
currencyId: "ethereum",
|
|
399
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
400
|
+
derivationMode: "",
|
|
401
|
+
});
|
|
402
|
+
const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
|
|
403
|
+
const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency);
|
|
404
|
+
const expectedOperation = {
|
|
405
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0",
|
|
406
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
407
|
+
accountId: tokenAccountId,
|
|
408
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
409
|
+
blockHeight: 16240731,
|
|
410
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
411
|
+
recipients: ["0xC2907EFccE4011C491BbedA8A0fA63BA7aab596C"],
|
|
412
|
+
value: new BigNumber("2000000"),
|
|
413
|
+
fee: new BigNumber("1595338583295225"),
|
|
414
|
+
contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
415
|
+
date: new Date("2022-12-22T14:06:23.000Z"),
|
|
416
|
+
transactionSequenceNumber: 53,
|
|
417
|
+
type: "OUT",
|
|
418
|
+
extra: {},
|
|
419
|
+
};
|
|
420
|
+
expect(etherscanERC20EventToOperations(accountId, etherscanOp)).toEqual([
|
|
421
|
+
expectedOperation,
|
|
422
|
+
]);
|
|
423
|
+
});
|
|
424
|
+
it("should convert an etherscan-like usdc in event (from their API) to a Ledger Live Operation", () => {
|
|
425
|
+
const etherscanOp = {
|
|
426
|
+
blockNumber: "16240731",
|
|
427
|
+
timeStamp: "1671717983",
|
|
428
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
429
|
+
nonce: "53",
|
|
430
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
431
|
+
from: "0xc2907efcce4011c491bbeda8a0fa63ba7aab596c",
|
|
432
|
+
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
433
|
+
to: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
434
|
+
value: "2000000",
|
|
435
|
+
tokenName: "USD Coin",
|
|
436
|
+
tokenSymbol: "USDC",
|
|
437
|
+
tokenDecimal: "6",
|
|
438
|
+
transactionIndex: "65",
|
|
439
|
+
gas: "79381",
|
|
440
|
+
gasPrice: "24314367325",
|
|
441
|
+
gasUsed: "65613",
|
|
442
|
+
cumulativeGasUsed: "4557746",
|
|
443
|
+
input: "deprecated",
|
|
444
|
+
confirmations: "150032",
|
|
445
|
+
};
|
|
446
|
+
const accountId = encodeAccountId({
|
|
447
|
+
type: "js",
|
|
448
|
+
version: "2",
|
|
449
|
+
currencyId: "ethereum",
|
|
450
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
451
|
+
derivationMode: "",
|
|
452
|
+
});
|
|
453
|
+
const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
|
|
454
|
+
const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency);
|
|
455
|
+
const expectedOperation = {
|
|
456
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0",
|
|
457
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
458
|
+
accountId: tokenAccountId,
|
|
459
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
460
|
+
blockHeight: 16240731,
|
|
461
|
+
senders: ["0xC2907EFccE4011C491BbedA8A0fA63BA7aab596C"],
|
|
462
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
463
|
+
value: new BigNumber("2000000"),
|
|
464
|
+
fee: new BigNumber("1595338583295225"),
|
|
465
|
+
contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
466
|
+
date: new Date("2022-12-22T14:06:23.000Z"),
|
|
467
|
+
transactionSequenceNumber: 53,
|
|
468
|
+
type: "IN",
|
|
469
|
+
extra: {},
|
|
470
|
+
};
|
|
471
|
+
expect(etherscanERC20EventToOperations(accountId, etherscanOp)).toEqual([
|
|
472
|
+
expectedOperation,
|
|
473
|
+
]);
|
|
474
|
+
});
|
|
475
|
+
it("should ignore an etherscan-like usdc none event (from their API) and return empty array", () => {
|
|
476
|
+
const etherscanOp = {
|
|
477
|
+
blockNumber: "16240731",
|
|
478
|
+
timeStamp: "1671717983",
|
|
479
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
480
|
+
nonce: "53",
|
|
481
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
482
|
+
from: "0x6bfd74c0996f269bcece59191eff667b3dfd73b9",
|
|
483
|
+
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
484
|
+
to: "0x02a357476a300c89ce27d7d4c7e57bbd2dd3f006",
|
|
485
|
+
value: "2000000",
|
|
486
|
+
tokenName: "USD Coin",
|
|
487
|
+
tokenSymbol: "USDC",
|
|
488
|
+
tokenDecimal: "6",
|
|
489
|
+
transactionIndex: "65",
|
|
490
|
+
gas: "79381",
|
|
491
|
+
gasPrice: "24314367325",
|
|
492
|
+
gasUsed: "65613",
|
|
493
|
+
cumulativeGasUsed: "4557746",
|
|
494
|
+
input: "deprecated",
|
|
495
|
+
confirmations: "150032",
|
|
496
|
+
};
|
|
497
|
+
const accountId = encodeAccountId({
|
|
498
|
+
type: "js",
|
|
499
|
+
version: "2",
|
|
500
|
+
currencyId: "ethereum",
|
|
501
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
502
|
+
derivationMode: "",
|
|
503
|
+
});
|
|
504
|
+
expect(etherscanERC20EventToOperations(accountId, etherscanOp)).toEqual([]);
|
|
505
|
+
});
|
|
506
|
+
it("should convert an etherscan-like self usdc event (from their API) into 2 Ledger Live Operations", () => {
|
|
507
|
+
const etherscanOp = {
|
|
508
|
+
blockNumber: "16240731",
|
|
509
|
+
timeStamp: "1671717983",
|
|
510
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
511
|
+
nonce: "53",
|
|
512
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
513
|
+
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
514
|
+
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
515
|
+
to: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
516
|
+
value: "2000000",
|
|
517
|
+
tokenName: "USD Coin",
|
|
518
|
+
tokenSymbol: "USDC",
|
|
519
|
+
tokenDecimal: "6",
|
|
520
|
+
transactionIndex: "65",
|
|
521
|
+
gas: "79381",
|
|
522
|
+
gasPrice: "24314367325",
|
|
523
|
+
gasUsed: "65613",
|
|
524
|
+
cumulativeGasUsed: "4557746",
|
|
525
|
+
input: "deprecated",
|
|
526
|
+
confirmations: "150032",
|
|
527
|
+
};
|
|
528
|
+
const accountId = encodeAccountId({
|
|
529
|
+
type: "js",
|
|
530
|
+
version: "2",
|
|
531
|
+
currencyId: "ethereum",
|
|
532
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
533
|
+
derivationMode: "",
|
|
534
|
+
});
|
|
535
|
+
const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
|
|
536
|
+
const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency);
|
|
537
|
+
const expectedOperations = [
|
|
538
|
+
{
|
|
539
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN-i0",
|
|
540
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
541
|
+
accountId: tokenAccountId,
|
|
542
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
543
|
+
blockHeight: 16240731,
|
|
544
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
545
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
546
|
+
value: new BigNumber("2000000"),
|
|
547
|
+
fee: new BigNumber("1595338583295225"),
|
|
548
|
+
contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
549
|
+
date: new Date("2022-12-22T14:06:23.000Z"),
|
|
550
|
+
transactionSequenceNumber: 53,
|
|
551
|
+
type: "IN",
|
|
552
|
+
extra: {},
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT-i0",
|
|
556
|
+
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
557
|
+
accountId: tokenAccountId,
|
|
558
|
+
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
559
|
+
blockHeight: 16240731,
|
|
560
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
561
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
562
|
+
value: new BigNumber("2000000"),
|
|
563
|
+
fee: new BigNumber("1595338583295225"),
|
|
564
|
+
contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
565
|
+
date: new Date("2022-12-22T14:06:23.000Z"),
|
|
566
|
+
transactionSequenceNumber: 53,
|
|
567
|
+
type: "OUT",
|
|
568
|
+
extra: {},
|
|
569
|
+
},
|
|
570
|
+
];
|
|
571
|
+
expect(etherscanERC20EventToOperations(accountId, etherscanOp)).toEqual(expectedOperations);
|
|
572
|
+
});
|
|
573
|
+
});
|
|
574
|
+
describe("etherscanER721EventToOperation", () => {
|
|
575
|
+
it("should convert an etherscan-like erc721 nft out event (from their API) to a Ledger Live Operation", () => {
|
|
576
|
+
const etherscanOp = {
|
|
577
|
+
blockNumber: "4708120",
|
|
578
|
+
timeStamp: "1512907118",
|
|
579
|
+
hash: "0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66",
|
|
580
|
+
nonce: "0",
|
|
581
|
+
blockHash: "0x4be19c278bfaead5cb0bc9476fa632e2447f6e6259e0303af210302d22779a24",
|
|
582
|
+
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
583
|
+
contractAddress: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
|
|
584
|
+
to: "0x6975be450864c02b4613023c2152ee0743572325",
|
|
585
|
+
tokenID: "202106",
|
|
586
|
+
tokenName: "CryptoKitties",
|
|
587
|
+
tokenSymbol: "CK",
|
|
588
|
+
tokenDecimal: "0",
|
|
589
|
+
transactionIndex: "81",
|
|
590
|
+
gas: "158820",
|
|
591
|
+
gasPrice: "40000000000",
|
|
592
|
+
gasUsed: "60508",
|
|
593
|
+
cumulativeGasUsed: "4880352",
|
|
594
|
+
input: "deprecated",
|
|
595
|
+
confirmations: "7990490",
|
|
596
|
+
};
|
|
597
|
+
const accountId = encodeAccountId({
|
|
598
|
+
type: "js",
|
|
599
|
+
version: "2",
|
|
600
|
+
currencyId: "ethereum",
|
|
601
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
602
|
+
derivationMode: "",
|
|
603
|
+
});
|
|
604
|
+
const expectedOperation = {
|
|
605
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+0x06012c8cf97BEaD5deAe237070F9587f8E7A266d+202106+ethereum-0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66-NFT_OUT-i0",
|
|
606
|
+
hash: "0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66",
|
|
607
|
+
accountId,
|
|
608
|
+
blockHash: "0x4be19c278bfaead5cb0bc9476fa632e2447f6e6259e0303af210302d22779a24",
|
|
609
|
+
blockHeight: 4708120,
|
|
610
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
611
|
+
recipients: ["0x6975BE450864c02B4613023C2152EE0743572325"],
|
|
612
|
+
value: new BigNumber("1"),
|
|
613
|
+
fee: new BigNumber("2420320000000000"),
|
|
614
|
+
contract: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d",
|
|
615
|
+
tokenId: "202106",
|
|
616
|
+
standard: "ERC721",
|
|
617
|
+
date: new Date("2017-12-10T11:58:38.000Z"),
|
|
618
|
+
transactionSequenceNumber: 0,
|
|
619
|
+
type: "NFT_OUT",
|
|
620
|
+
extra: {},
|
|
621
|
+
};
|
|
622
|
+
expect(etherscanERC721EventToOperations(accountId, etherscanOp)).toEqual([
|
|
623
|
+
expectedOperation,
|
|
624
|
+
]);
|
|
625
|
+
});
|
|
626
|
+
it("should convert an etherscan-like erc721 nft in event (from their API) to a Ledger Live Operation", () => {
|
|
627
|
+
const etherscanOp = {
|
|
628
|
+
blockNumber: "4708120",
|
|
629
|
+
timeStamp: "1512907118",
|
|
630
|
+
hash: "0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66",
|
|
631
|
+
nonce: "0",
|
|
632
|
+
blockHash: "0x4be19c278bfaead5cb0bc9476fa632e2447f6e6259e0303af210302d22779a24",
|
|
633
|
+
from: "0x6975be450864c02b4613023c2152ee0743572325",
|
|
634
|
+
contractAddress: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
|
|
635
|
+
to: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
636
|
+
tokenID: "202106",
|
|
637
|
+
tokenName: "CryptoKitties",
|
|
638
|
+
tokenSymbol: "CK",
|
|
639
|
+
tokenDecimal: "0",
|
|
640
|
+
transactionIndex: "81",
|
|
641
|
+
gas: "158820",
|
|
642
|
+
gasPrice: "40000000000",
|
|
643
|
+
gasUsed: "60508",
|
|
644
|
+
cumulativeGasUsed: "4880352",
|
|
645
|
+
input: "deprecated",
|
|
646
|
+
confirmations: "7990490",
|
|
647
|
+
};
|
|
648
|
+
const accountId = encodeAccountId({
|
|
649
|
+
type: "js",
|
|
650
|
+
version: "2",
|
|
651
|
+
currencyId: "ethereum",
|
|
652
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
653
|
+
derivationMode: "",
|
|
654
|
+
});
|
|
655
|
+
const expectedOperation = {
|
|
656
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+0x06012c8cf97BEaD5deAe237070F9587f8E7A266d+202106+ethereum-0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66-NFT_IN-i0",
|
|
657
|
+
hash: "0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66",
|
|
658
|
+
accountId,
|
|
659
|
+
blockHash: "0x4be19c278bfaead5cb0bc9476fa632e2447f6e6259e0303af210302d22779a24",
|
|
660
|
+
blockHeight: 4708120,
|
|
661
|
+
senders: ["0x6975BE450864c02B4613023C2152EE0743572325"],
|
|
662
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
663
|
+
value: new BigNumber("1"),
|
|
664
|
+
fee: new BigNumber("2420320000000000"),
|
|
665
|
+
contract: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d",
|
|
666
|
+
tokenId: "202106",
|
|
667
|
+
standard: "ERC721",
|
|
668
|
+
date: new Date("2017-12-10T11:58:38.000Z"),
|
|
669
|
+
transactionSequenceNumber: 0,
|
|
670
|
+
type: "NFT_IN",
|
|
671
|
+
extra: {},
|
|
672
|
+
};
|
|
673
|
+
expect(etherscanERC721EventToOperations(accountId, etherscanOp)).toEqual([
|
|
674
|
+
expectedOperation,
|
|
675
|
+
]);
|
|
676
|
+
});
|
|
677
|
+
it("should ignore an etherscan-like erc721 nft none event (from their API) and return empty array", () => {
|
|
678
|
+
const etherscanOp = {
|
|
679
|
+
blockNumber: "4708120",
|
|
680
|
+
timeStamp: "1512907118",
|
|
681
|
+
hash: "0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66",
|
|
682
|
+
nonce: "0",
|
|
683
|
+
blockHash: "0x4be19c278bfaead5cb0bc9476fa632e2447f6e6259e0303af210302d22779a24",
|
|
684
|
+
from: "0x6975be450864c02b4613023c2152ee0743572325",
|
|
685
|
+
contractAddress: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
|
|
686
|
+
to: "0x0000000000000000000000000000000000000000",
|
|
687
|
+
tokenID: "202106",
|
|
688
|
+
tokenName: "CryptoKitties",
|
|
689
|
+
tokenSymbol: "CK",
|
|
690
|
+
tokenDecimal: "0",
|
|
691
|
+
transactionIndex: "81",
|
|
692
|
+
gas: "158820",
|
|
693
|
+
gasPrice: "40000000000",
|
|
694
|
+
gasUsed: "60508",
|
|
695
|
+
cumulativeGasUsed: "4880352",
|
|
696
|
+
input: "deprecated",
|
|
697
|
+
confirmations: "7990490",
|
|
698
|
+
};
|
|
699
|
+
const accountId = encodeAccountId({
|
|
700
|
+
type: "js",
|
|
701
|
+
version: "2",
|
|
702
|
+
currencyId: "ethereum",
|
|
703
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
704
|
+
derivationMode: "",
|
|
705
|
+
});
|
|
706
|
+
expect(etherscanERC721EventToOperations(accountId, etherscanOp)).toEqual([]);
|
|
707
|
+
});
|
|
708
|
+
it("should convert an etherscan-like erc721 nft event (from their API) into 2 Ledger Live Operations", () => {
|
|
709
|
+
const etherscanOp = {
|
|
710
|
+
blockNumber: "4708120",
|
|
711
|
+
timeStamp: "1512907118",
|
|
712
|
+
hash: "0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66",
|
|
713
|
+
nonce: "0",
|
|
714
|
+
blockHash: "0x4be19c278bfaead5cb0bc9476fa632e2447f6e6259e0303af210302d22779a24",
|
|
715
|
+
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
716
|
+
contractAddress: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
|
|
717
|
+
to: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
718
|
+
tokenID: "202106",
|
|
719
|
+
tokenName: "CryptoKitties",
|
|
720
|
+
tokenSymbol: "CK",
|
|
721
|
+
tokenDecimal: "0",
|
|
722
|
+
transactionIndex: "81",
|
|
723
|
+
gas: "158820",
|
|
724
|
+
gasPrice: "40000000000",
|
|
725
|
+
gasUsed: "60508",
|
|
726
|
+
cumulativeGasUsed: "4880352",
|
|
727
|
+
input: "deprecated",
|
|
728
|
+
confirmations: "7990490",
|
|
729
|
+
};
|
|
730
|
+
const accountId = encodeAccountId({
|
|
731
|
+
type: "js",
|
|
732
|
+
version: "2",
|
|
733
|
+
currencyId: "ethereum",
|
|
734
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
735
|
+
derivationMode: "",
|
|
736
|
+
});
|
|
737
|
+
const expectedOperations = [
|
|
738
|
+
{
|
|
739
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+0x06012c8cf97BEaD5deAe237070F9587f8E7A266d+202106+ethereum-0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66-NFT_IN-i0",
|
|
740
|
+
hash: "0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66",
|
|
741
|
+
accountId,
|
|
742
|
+
blockHash: "0x4be19c278bfaead5cb0bc9476fa632e2447f6e6259e0303af210302d22779a24",
|
|
743
|
+
blockHeight: 4708120,
|
|
744
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
745
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
746
|
+
value: new BigNumber("1"),
|
|
747
|
+
fee: new BigNumber("2420320000000000"),
|
|
748
|
+
contract: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d",
|
|
749
|
+
tokenId: "202106",
|
|
750
|
+
standard: "ERC721",
|
|
751
|
+
date: new Date("2017-12-10T11:58:38.000Z"),
|
|
752
|
+
transactionSequenceNumber: 0,
|
|
753
|
+
type: "NFT_IN",
|
|
754
|
+
extra: {},
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+0x06012c8cf97BEaD5deAe237070F9587f8E7A266d+202106+ethereum-0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66-NFT_OUT-i0",
|
|
758
|
+
hash: "0x031e6968a8de362e4328d60dcc7f72f0d6fc84284c452f63176632177146de66",
|
|
759
|
+
accountId,
|
|
760
|
+
blockHash: "0x4be19c278bfaead5cb0bc9476fa632e2447f6e6259e0303af210302d22779a24",
|
|
761
|
+
blockHeight: 4708120,
|
|
762
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
763
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
764
|
+
value: new BigNumber("1"),
|
|
765
|
+
fee: new BigNumber("2420320000000000"),
|
|
766
|
+
contract: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d",
|
|
767
|
+
tokenId: "202106",
|
|
768
|
+
standard: "ERC721",
|
|
769
|
+
date: new Date("2017-12-10T11:58:38.000Z"),
|
|
770
|
+
transactionSequenceNumber: 0,
|
|
771
|
+
type: "NFT_OUT",
|
|
772
|
+
extra: {},
|
|
773
|
+
},
|
|
774
|
+
];
|
|
775
|
+
expect(etherscanERC721EventToOperations(accountId, etherscanOp)).toEqual(expectedOperations);
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
describe("etherscanERC1155EventToOperations", () => {
|
|
779
|
+
it("should convert a etherscan-like erc1155 nft out event (from their API) to a Ledger Live Operation", () => {
|
|
780
|
+
const etherscanOp = {
|
|
781
|
+
blockNumber: "13472395",
|
|
782
|
+
timeStamp: "1634973285",
|
|
783
|
+
hash: "0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d",
|
|
784
|
+
nonce: "41",
|
|
785
|
+
blockHash: "0xa5da536dfbe8125eb146114e2ee0d0bdef2b20483aacbf30fed6b60f092059e6",
|
|
786
|
+
transactionIndex: "100",
|
|
787
|
+
gas: "140000",
|
|
788
|
+
gasPrice: "52898577246",
|
|
789
|
+
gasUsed: "105030",
|
|
790
|
+
cumulativeGasUsed: "11739203",
|
|
791
|
+
input: "deprecated",
|
|
792
|
+
contractAddress: "0x76be3b62873462d2142405439777e971754e8e77",
|
|
793
|
+
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
794
|
+
to: "0x83f564d180b58ad9a02a449105568189ee7de8cb",
|
|
795
|
+
tokenID: "10371",
|
|
796
|
+
tokenValue: "1",
|
|
797
|
+
tokenName: "parallel",
|
|
798
|
+
tokenSymbol: "LL",
|
|
799
|
+
confirmations: "1447769",
|
|
800
|
+
};
|
|
801
|
+
const accountId = encodeAccountId({
|
|
802
|
+
type: "js",
|
|
803
|
+
version: "2",
|
|
804
|
+
currencyId: "ethereum",
|
|
805
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
806
|
+
derivationMode: "",
|
|
807
|
+
});
|
|
808
|
+
const expectedOperation = {
|
|
809
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+0x76BE3b62873462d2142405439777e971754E8E77+10371+ethereum-0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d-NFT_OUT-i0_0",
|
|
810
|
+
hash: "0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d",
|
|
811
|
+
accountId,
|
|
812
|
+
blockHash: "0xa5da536dfbe8125eb146114e2ee0d0bdef2b20483aacbf30fed6b60f092059e6",
|
|
813
|
+
blockHeight: 13472395,
|
|
814
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
815
|
+
recipients: ["0x83f564d180B58Ad9A02A449105568189eE7DE8CB"],
|
|
816
|
+
value: new BigNumber("1"),
|
|
817
|
+
fee: new BigNumber("5555937568147380"),
|
|
818
|
+
contract: "0x76BE3b62873462d2142405439777e971754E8E77",
|
|
819
|
+
tokenId: "10371",
|
|
820
|
+
standard: "ERC1155",
|
|
821
|
+
date: new Date("2021-10-23T07:14:45.000Z"),
|
|
822
|
+
transactionSequenceNumber: 41,
|
|
823
|
+
type: "NFT_OUT",
|
|
824
|
+
extra: {},
|
|
825
|
+
};
|
|
826
|
+
expect(etherscanERC1155EventToOperations(accountId, etherscanOp)).toEqual([
|
|
827
|
+
expectedOperation,
|
|
828
|
+
]);
|
|
829
|
+
});
|
|
830
|
+
it("should convert a etherscan-like erc1155 nft in event (from their API) to a Ledger Live Operation", () => {
|
|
831
|
+
const etherscanOp = {
|
|
832
|
+
blockNumber: "13472395",
|
|
833
|
+
timeStamp: "1634973285",
|
|
834
|
+
hash: "0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d",
|
|
835
|
+
nonce: "41",
|
|
836
|
+
blockHash: "0xa5da536dfbe8125eb146114e2ee0d0bdef2b20483aacbf30fed6b60f092059e6",
|
|
837
|
+
transactionIndex: "100",
|
|
838
|
+
gas: "140000",
|
|
839
|
+
gasPrice: "52898577246",
|
|
840
|
+
gasUsed: "105030",
|
|
841
|
+
cumulativeGasUsed: "11739203",
|
|
842
|
+
input: "deprecated",
|
|
843
|
+
contractAddress: "0x76be3b62873462d2142405439777e971754e8e77",
|
|
844
|
+
from: "0x83f564d180b58ad9a02a449105568189ee7de8cb",
|
|
845
|
+
to: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
846
|
+
tokenID: "10371",
|
|
847
|
+
tokenValue: "1",
|
|
848
|
+
tokenName: "parallel",
|
|
849
|
+
tokenSymbol: "LL",
|
|
850
|
+
confirmations: "1447769",
|
|
851
|
+
};
|
|
852
|
+
const accountId = encodeAccountId({
|
|
853
|
+
type: "js",
|
|
854
|
+
version: "2",
|
|
855
|
+
currencyId: "ethereum",
|
|
856
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
857
|
+
derivationMode: "",
|
|
858
|
+
});
|
|
859
|
+
const expectedOperation = {
|
|
860
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+0x76BE3b62873462d2142405439777e971754E8E77+10371+ethereum-0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d-NFT_IN-i0_0",
|
|
861
|
+
hash: "0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d",
|
|
862
|
+
accountId,
|
|
863
|
+
blockHash: "0xa5da536dfbe8125eb146114e2ee0d0bdef2b20483aacbf30fed6b60f092059e6",
|
|
864
|
+
blockHeight: 13472395,
|
|
865
|
+
senders: ["0x83f564d180B58Ad9A02A449105568189eE7DE8CB"],
|
|
866
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
867
|
+
value: new BigNumber("1"),
|
|
868
|
+
fee: new BigNumber("5555937568147380"),
|
|
869
|
+
contract: "0x76BE3b62873462d2142405439777e971754E8E77",
|
|
870
|
+
tokenId: "10371",
|
|
871
|
+
standard: "ERC1155",
|
|
872
|
+
date: new Date("2021-10-23T07:14:45.000Z"),
|
|
873
|
+
transactionSequenceNumber: 41,
|
|
874
|
+
type: "NFT_IN",
|
|
875
|
+
extra: {},
|
|
876
|
+
};
|
|
877
|
+
expect(etherscanERC1155EventToOperations(accountId, etherscanOp)).toEqual([
|
|
878
|
+
expectedOperation,
|
|
879
|
+
]);
|
|
880
|
+
});
|
|
881
|
+
it("should ignore a etherscan-like erc1155 nft none event (from their API) and return empty array", () => {
|
|
882
|
+
const etherscanOp = {
|
|
883
|
+
blockNumber: "13472395",
|
|
884
|
+
timeStamp: "1634973285",
|
|
885
|
+
hash: "0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d",
|
|
886
|
+
nonce: "41",
|
|
887
|
+
blockHash: "0xa5da536dfbe8125eb146114e2ee0d0bdef2b20483aacbf30fed6b60f092059e6",
|
|
888
|
+
transactionIndex: "100",
|
|
889
|
+
gas: "140000",
|
|
890
|
+
gasPrice: "52898577246",
|
|
891
|
+
gasUsed: "105030",
|
|
892
|
+
cumulativeGasUsed: "11739203",
|
|
893
|
+
input: "deprecated",
|
|
894
|
+
contractAddress: "0x76be3b62873462d2142405439777e971754e8e77",
|
|
895
|
+
from: "0x83f564d180b58ad9a02a449105568189ee7de8cb",
|
|
896
|
+
to: "0x0000000000000000000000000000000000000000",
|
|
897
|
+
tokenID: "10371",
|
|
898
|
+
tokenValue: "1",
|
|
899
|
+
tokenName: "parallel",
|
|
900
|
+
tokenSymbol: "LL",
|
|
901
|
+
confirmations: "1447769",
|
|
902
|
+
};
|
|
903
|
+
const accountId = encodeAccountId({
|
|
904
|
+
type: "js",
|
|
905
|
+
version: "2",
|
|
906
|
+
currencyId: "ethereum",
|
|
907
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
908
|
+
derivationMode: "",
|
|
909
|
+
});
|
|
910
|
+
expect(etherscanERC1155EventToOperations(accountId, etherscanOp)).toEqual([]);
|
|
911
|
+
});
|
|
912
|
+
it("should convert an etherscan-like erc1155 nft event (from their API) into 2 Ledger Live Operations", () => {
|
|
913
|
+
const etherscanOp = {
|
|
914
|
+
blockNumber: "13472395",
|
|
915
|
+
timeStamp: "1634973285",
|
|
916
|
+
hash: "0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d",
|
|
917
|
+
nonce: "41",
|
|
918
|
+
blockHash: "0xa5da536dfbe8125eb146114e2ee0d0bdef2b20483aacbf30fed6b60f092059e6",
|
|
919
|
+
transactionIndex: "100",
|
|
920
|
+
gas: "140000",
|
|
921
|
+
gasPrice: "52898577246",
|
|
922
|
+
gasUsed: "105030",
|
|
923
|
+
cumulativeGasUsed: "11739203",
|
|
924
|
+
input: "deprecated",
|
|
925
|
+
contractAddress: "0x76be3b62873462d2142405439777e971754e8e77",
|
|
926
|
+
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
927
|
+
to: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
928
|
+
tokenID: "10371",
|
|
929
|
+
tokenValue: "1",
|
|
930
|
+
tokenName: "parallel",
|
|
931
|
+
tokenSymbol: "LL",
|
|
932
|
+
confirmations: "1447769",
|
|
933
|
+
};
|
|
934
|
+
const accountId = encodeAccountId({
|
|
935
|
+
type: "js",
|
|
936
|
+
version: "2",
|
|
937
|
+
currencyId: "ethereum",
|
|
938
|
+
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
939
|
+
derivationMode: "",
|
|
940
|
+
});
|
|
941
|
+
const expectedOperations = [
|
|
942
|
+
{
|
|
943
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+0x76BE3b62873462d2142405439777e971754E8E77+10371+ethereum-0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d-NFT_IN-i0_0",
|
|
944
|
+
hash: "0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d",
|
|
945
|
+
accountId,
|
|
946
|
+
blockHash: "0xa5da536dfbe8125eb146114e2ee0d0bdef2b20483aacbf30fed6b60f092059e6",
|
|
947
|
+
blockHeight: 13472395,
|
|
948
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
949
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
950
|
+
value: new BigNumber("1"),
|
|
951
|
+
fee: new BigNumber("5555937568147380"),
|
|
952
|
+
contract: "0x76BE3b62873462d2142405439777e971754E8E77",
|
|
953
|
+
tokenId: "10371",
|
|
954
|
+
standard: "ERC1155",
|
|
955
|
+
date: new Date("2021-10-23T07:14:45.000Z"),
|
|
956
|
+
transactionSequenceNumber: 41,
|
|
957
|
+
type: "NFT_IN",
|
|
958
|
+
extra: {},
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+0x76BE3b62873462d2142405439777e971754E8E77+10371+ethereum-0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d-NFT_OUT-i0_0",
|
|
962
|
+
hash: "0x643b15f3ffaad5d38e33e5872b4ebaa7a643eda8b50ffd5331f682934ee65d4d",
|
|
963
|
+
accountId,
|
|
964
|
+
blockHash: "0xa5da536dfbe8125eb146114e2ee0d0bdef2b20483aacbf30fed6b60f092059e6",
|
|
965
|
+
blockHeight: 13472395,
|
|
966
|
+
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
967
|
+
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
968
|
+
value: new BigNumber("1"),
|
|
969
|
+
fee: new BigNumber("5555937568147380"),
|
|
970
|
+
contract: "0x76BE3b62873462d2142405439777e971754E8E77",
|
|
971
|
+
tokenId: "10371",
|
|
972
|
+
standard: "ERC1155",
|
|
973
|
+
date: new Date("2021-10-23T07:14:45.000Z"),
|
|
974
|
+
transactionSequenceNumber: 41,
|
|
975
|
+
type: "NFT_OUT",
|
|
976
|
+
extra: {},
|
|
977
|
+
},
|
|
978
|
+
];
|
|
979
|
+
expect(etherscanERC1155EventToOperations(accountId, etherscanOp)).toEqual(expectedOperations);
|
|
980
|
+
});
|
|
981
|
+
});
|
|
982
|
+
});
|
|
983
|
+
});
|
|
984
|
+
//# sourceMappingURL=adapters.unit.test.js.map
|