@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,497 +0,0 @@
|
|
|
1
|
-
import { encodeAccountId, encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
2
|
-
import { findTokenById } from "@ledgerhq/cryptoassets";
|
|
3
|
-
import { Operation } from "@ledgerhq/types-live";
|
|
4
|
-
import BigNumber from "bignumber.js";
|
|
5
|
-
import { ethers } from "ethers";
|
|
6
|
-
import {
|
|
7
|
-
etherscanERC20EventToOperation,
|
|
8
|
-
etherscanOperationToOperation,
|
|
9
|
-
transactionToEthersTransaction,
|
|
10
|
-
} from "../adapters";
|
|
11
|
-
import {
|
|
12
|
-
EtherscanERC20Event,
|
|
13
|
-
EtherscanOperation,
|
|
14
|
-
EvmTransactionEIP1559,
|
|
15
|
-
EvmTransactionLegacy,
|
|
16
|
-
} from "../types";
|
|
17
|
-
|
|
18
|
-
const testData = Buffer.from("testBufferString").toString("hex");
|
|
19
|
-
const eip1559Tx: EvmTransactionEIP1559 = {
|
|
20
|
-
amount: new BigNumber(100),
|
|
21
|
-
useAllAmount: false,
|
|
22
|
-
subAccountId: "id",
|
|
23
|
-
recipient: "0xkvn",
|
|
24
|
-
feesStrategy: "custom",
|
|
25
|
-
family: "evm",
|
|
26
|
-
mode: "send",
|
|
27
|
-
nonce: 0,
|
|
28
|
-
gasLimit: new BigNumber(21000),
|
|
29
|
-
chainId: 1,
|
|
30
|
-
data: Buffer.from(testData, "hex"),
|
|
31
|
-
maxFeePerGas: new BigNumber(10000),
|
|
32
|
-
maxPriorityFeePerGas: new BigNumber(10000),
|
|
33
|
-
type: 2,
|
|
34
|
-
};
|
|
35
|
-
const legacyTx: EvmTransactionLegacy = {
|
|
36
|
-
amount: new BigNumber(100),
|
|
37
|
-
useAllAmount: false,
|
|
38
|
-
subAccountId: "id",
|
|
39
|
-
recipient: "0xkvn",
|
|
40
|
-
feesStrategy: "custom",
|
|
41
|
-
family: "evm",
|
|
42
|
-
mode: "send",
|
|
43
|
-
nonce: 0,
|
|
44
|
-
gasLimit: new BigNumber(21000),
|
|
45
|
-
chainId: 1,
|
|
46
|
-
data: Buffer.from(testData, "hex"),
|
|
47
|
-
gasPrice: new BigNumber(10000),
|
|
48
|
-
type: 0,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
describe("EVM Family", () => {
|
|
52
|
-
describe("adapters.ts", () => {
|
|
53
|
-
describe("transactionToEthersTransaction", () => {
|
|
54
|
-
it("should build convert an EIP1559 ledger live transaction to an ethers transaction", () => {
|
|
55
|
-
const ethers1559Tx: ethers.Transaction = {
|
|
56
|
-
to: "0xkvn",
|
|
57
|
-
nonce: 0,
|
|
58
|
-
gasLimit: ethers.BigNumber.from(21000),
|
|
59
|
-
data: "0x" + testData,
|
|
60
|
-
value: ethers.BigNumber.from(100),
|
|
61
|
-
chainId: 1,
|
|
62
|
-
type: 2,
|
|
63
|
-
maxFeePerGas: ethers.BigNumber.from(10000),
|
|
64
|
-
maxPriorityFeePerGas: ethers.BigNumber.from(10000),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
expect(transactionToEthersTransaction(eip1559Tx)).toEqual(ethers1559Tx);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("should build convert an legacy ledger live transaction to an ethers transaction", () => {
|
|
71
|
-
const legacyEthersTx: ethers.Transaction = {
|
|
72
|
-
to: "0xkvn",
|
|
73
|
-
nonce: 0,
|
|
74
|
-
gasLimit: ethers.BigNumber.from(21000),
|
|
75
|
-
data: "0x" + testData,
|
|
76
|
-
value: ethers.BigNumber.from(100),
|
|
77
|
-
chainId: 1,
|
|
78
|
-
type: 0,
|
|
79
|
-
gasPrice: ethers.BigNumber.from(10000),
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
expect(transactionToEthersTransaction(legacyTx)).toEqual(legacyEthersTx);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
describe("etherscanOperationToOperation", () => {
|
|
87
|
-
it("should convert a etherscan-like smart contract operation (from their API) to a Ledger Live Operation", () => {
|
|
88
|
-
const etherscanOp: EtherscanOperation = {
|
|
89
|
-
blockNumber: "14923692",
|
|
90
|
-
timeStamp: "1654646570",
|
|
91
|
-
hash: "0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338",
|
|
92
|
-
nonce: "7",
|
|
93
|
-
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
94
|
-
transactionIndex: "27",
|
|
95
|
-
from: "0x9aa99c23f67c81701c772b106b4f83f6e858dd2e",
|
|
96
|
-
to: "0xc5102fe9359fd9a28f877a67e36b0f050d81a3cc",
|
|
97
|
-
value: "0",
|
|
98
|
-
gas: "6000000",
|
|
99
|
-
gasPrice: "125521409858",
|
|
100
|
-
isError: "0",
|
|
101
|
-
txreceipt_status: "1",
|
|
102
|
-
input:
|
|
103
|
-
"0xa9059cbb000000000000000000000000313143c4088a47c469d06fe3fa5fd4196be6a4d600000000000000000000000000000000000000000003b8e97d229a2d54800000",
|
|
104
|
-
contractAddress: "",
|
|
105
|
-
cumulativeGasUsed: "1977481",
|
|
106
|
-
gasUsed: "57168",
|
|
107
|
-
confirmations: "122471",
|
|
108
|
-
methodId: "0xa9059cbb",
|
|
109
|
-
functionName: "transfer(address _to, uint256 _value)",
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const accountId = encodeAccountId({
|
|
113
|
-
type: "js",
|
|
114
|
-
version: "2",
|
|
115
|
-
currencyId: "ethereum",
|
|
116
|
-
xpubOrAddress: "0x9aa99c23f67c81701c772b106b4f83f6e858dd2e",
|
|
117
|
-
derivationMode: "",
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const expectedOperation: Operation = {
|
|
121
|
-
id: "js:2:ethereum:0x9aa99c23f67c81701c772b106b4f83f6e858dd2e:-0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338-FEES",
|
|
122
|
-
hash: "0xaa45b4858ba44230a5fce5a29570a5dec2bf1f0ba95bacdec4fe8f2c4fa99338",
|
|
123
|
-
accountId,
|
|
124
|
-
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
125
|
-
blockHeight: 14923692,
|
|
126
|
-
recipients: ["0xc5102fE9359FD9a28f877a67E36B0F050d81a3CC"],
|
|
127
|
-
senders: ["0x9AA99C23F67c81701C772B106b4F83f6e858dd2E"],
|
|
128
|
-
value: new BigNumber("7175807958762144"),
|
|
129
|
-
fee: new BigNumber("7175807958762144"),
|
|
130
|
-
date: new Date("2022-06-08T00:02:50.000Z"),
|
|
131
|
-
transactionSequenceNumber: 7,
|
|
132
|
-
type: "FEES",
|
|
133
|
-
extra: {},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
expect(etherscanOperationToOperation(accountId, etherscanOp)).toEqual(expectedOperation);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("should convert a etherscan-like coin out operation (from their API) to a Ledger Live Operation", () => {
|
|
140
|
-
const etherscanOp: EtherscanOperation = {
|
|
141
|
-
blockNumber: "13807766",
|
|
142
|
-
timeStamp: "1639544926",
|
|
143
|
-
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
144
|
-
nonce: "11898499",
|
|
145
|
-
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
146
|
-
transactionIndex: "394",
|
|
147
|
-
from: "0x829bd824b016326a401d083b33d092293333a830",
|
|
148
|
-
to: "0x26e3fd2dec89bf645ba7b41c4ddfad8454ee6245",
|
|
149
|
-
value: "143141441418750645",
|
|
150
|
-
gas: "210000",
|
|
151
|
-
gasPrice: "68363841693",
|
|
152
|
-
isError: "0",
|
|
153
|
-
txreceipt_status: "1",
|
|
154
|
-
input: "0x",
|
|
155
|
-
contractAddress: "",
|
|
156
|
-
cumulativeGasUsed: "14788393",
|
|
157
|
-
gasUsed: "21000",
|
|
158
|
-
confirmations: "2582470",
|
|
159
|
-
methodId: "0x",
|
|
160
|
-
functionName: "",
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const accountId = encodeAccountId({
|
|
164
|
-
type: "js",
|
|
165
|
-
version: "2",
|
|
166
|
-
currencyId: "ethereum",
|
|
167
|
-
xpubOrAddress: "0x829BD824B016326A401d083B33D092293333A830",
|
|
168
|
-
derivationMode: "",
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const expectedOperation: Operation = {
|
|
172
|
-
id: "js:2:ethereum:0x829BD824B016326A401d083B33D092293333A830:-0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944-OUT",
|
|
173
|
-
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
174
|
-
accountId,
|
|
175
|
-
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
176
|
-
blockHeight: 13807766,
|
|
177
|
-
recipients: ["0x26E3fd2dEc89bF645BA7b41c4DdFad8454Ee6245"],
|
|
178
|
-
senders: ["0x829BD824B016326A401d083B33D092293333A830"],
|
|
179
|
-
value: new BigNumber("143141441418750645").plus("1435640675553000"),
|
|
180
|
-
fee: new BigNumber("1435640675553000"),
|
|
181
|
-
date: new Date("2021-12-15T05:08:46.000Z"),
|
|
182
|
-
transactionSequenceNumber: 11898499,
|
|
183
|
-
type: "OUT",
|
|
184
|
-
extra: {},
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
expect(etherscanOperationToOperation(accountId, etherscanOp)).toEqual(expectedOperation);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("should convert a etherscan-like coin in operation (from their API) to a Ledger Live Operation", () => {
|
|
191
|
-
const etherscanOp: EtherscanOperation = {
|
|
192
|
-
blockNumber: "13807766",
|
|
193
|
-
timeStamp: "1639544926",
|
|
194
|
-
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
195
|
-
nonce: "11898499",
|
|
196
|
-
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
197
|
-
transactionIndex: "394",
|
|
198
|
-
from: "0x26e3fd2dec89bf645ba7b41c4ddfad8454ee6245",
|
|
199
|
-
to: "0x829bd824b016326a401d083b33d092293333a830",
|
|
200
|
-
value: "143141441418750645",
|
|
201
|
-
gas: "210000",
|
|
202
|
-
gasPrice: "68363841693",
|
|
203
|
-
isError: "0",
|
|
204
|
-
txreceipt_status: "1",
|
|
205
|
-
input: "0x",
|
|
206
|
-
contractAddress: "",
|
|
207
|
-
cumulativeGasUsed: "14788393",
|
|
208
|
-
gasUsed: "21000",
|
|
209
|
-
confirmations: "2582470",
|
|
210
|
-
methodId: "0x",
|
|
211
|
-
functionName: "",
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
const accountId = encodeAccountId({
|
|
215
|
-
type: "js",
|
|
216
|
-
version: "2",
|
|
217
|
-
currencyId: "ethereum",
|
|
218
|
-
xpubOrAddress: "0x829BD824B016326A401d083B33D092293333A830",
|
|
219
|
-
derivationMode: "",
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
const expectedOperation: Operation = {
|
|
223
|
-
id: "js:2:ethereum:0x829BD824B016326A401d083B33D092293333A830:-0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944-IN",
|
|
224
|
-
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
225
|
-
accountId,
|
|
226
|
-
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
227
|
-
blockHeight: 13807766,
|
|
228
|
-
recipients: ["0x829BD824B016326A401d083B33D092293333A830"],
|
|
229
|
-
senders: ["0x26E3fd2dEc89bF645BA7b41c4DdFad8454Ee6245"],
|
|
230
|
-
value: new BigNumber("143141441418750645"),
|
|
231
|
-
fee: new BigNumber("1435640675553000"),
|
|
232
|
-
date: new Date("2021-12-15T05:08:46.000Z"),
|
|
233
|
-
transactionSequenceNumber: 11898499,
|
|
234
|
-
type: "IN",
|
|
235
|
-
extra: {},
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
expect(etherscanOperationToOperation(accountId, etherscanOp)).toEqual(expectedOperation);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("should convert a etherscan-like coin none operation (from their API) to a Ledger Live Operation", () => {
|
|
242
|
-
const etherscanOp: EtherscanOperation = {
|
|
243
|
-
blockNumber: "13807766",
|
|
244
|
-
timeStamp: "1639544926",
|
|
245
|
-
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
246
|
-
nonce: "11898499",
|
|
247
|
-
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
248
|
-
transactionIndex: "394",
|
|
249
|
-
from: "0x6bfd74c0996f269bcece59191eff667b3dfd73b9",
|
|
250
|
-
to: "0x02a357476a300c89ce27d7d4c7e57bbd2dd3f006",
|
|
251
|
-
value: "143141441418750645",
|
|
252
|
-
gas: "210000",
|
|
253
|
-
gasPrice: "68363841693",
|
|
254
|
-
isError: "0",
|
|
255
|
-
txreceipt_status: "1",
|
|
256
|
-
input: "0x",
|
|
257
|
-
contractAddress: "",
|
|
258
|
-
cumulativeGasUsed: "14788393",
|
|
259
|
-
gasUsed: "21000",
|
|
260
|
-
confirmations: "2582470",
|
|
261
|
-
methodId: "0x",
|
|
262
|
-
functionName: "",
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const accountId = encodeAccountId({
|
|
266
|
-
type: "js",
|
|
267
|
-
version: "2",
|
|
268
|
-
currencyId: "ethereum",
|
|
269
|
-
xpubOrAddress: "0x829BD824B016326A401d083B33D092293333A830",
|
|
270
|
-
derivationMode: "",
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
const expectedOperation: Operation = {
|
|
274
|
-
id: "js:2:ethereum:0x829BD824B016326A401d083B33D092293333A830:-0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944-NONE",
|
|
275
|
-
hash: "0x8d3e871469ce549c5a80b8c8beaae0d502ecea85bb43eb84703cebeea7d25944",
|
|
276
|
-
accountId,
|
|
277
|
-
blockHash: "0xad04a8ed598c9c270f7ffd9a113224bc16fc285af814a2dc735c261620bad669",
|
|
278
|
-
blockHeight: 13807766,
|
|
279
|
-
recipients: ["0x02a357476A300c89Ce27D7D4C7E57Bbd2DD3f006"],
|
|
280
|
-
senders: ["0x6bfD74C0996F269Bcece59191EFf667b3dFD73b9"],
|
|
281
|
-
value: new BigNumber("143141441418750645"),
|
|
282
|
-
fee: new BigNumber("1435640675553000"),
|
|
283
|
-
date: new Date("2021-12-15T05:08:46.000Z"),
|
|
284
|
-
transactionSequenceNumber: 11898499,
|
|
285
|
-
type: "NONE",
|
|
286
|
-
extra: {},
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
expect(etherscanOperationToOperation(accountId, etherscanOp)).toEqual(expectedOperation);
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
describe("etherscanERC20EventToOperation", () => {
|
|
294
|
-
it("should return null for an unknown token", () => {
|
|
295
|
-
const etherscanOp: EtherscanERC20Event = {
|
|
296
|
-
blockNumber: "16240731",
|
|
297
|
-
timeStamp: "1671717983",
|
|
298
|
-
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
299
|
-
nonce: "53",
|
|
300
|
-
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
301
|
-
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
302
|
-
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb41",
|
|
303
|
-
to: "0xc2907efcce4011c491bbeda8a0fa63ba7aab596c",
|
|
304
|
-
value: "2000000",
|
|
305
|
-
tokenName: "USD Coin",
|
|
306
|
-
tokenSymbol: "USDC",
|
|
307
|
-
tokenDecimal: "6",
|
|
308
|
-
transactionIndex: "65",
|
|
309
|
-
gas: "79381",
|
|
310
|
-
gasPrice: "24314367325",
|
|
311
|
-
gasUsed: "65613",
|
|
312
|
-
cumulativeGasUsed: "4557746",
|
|
313
|
-
input: "deprecated",
|
|
314
|
-
confirmations: "150032",
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
const accountId = encodeAccountId({
|
|
318
|
-
type: "js",
|
|
319
|
-
version: "2",
|
|
320
|
-
currencyId: "ethereum",
|
|
321
|
-
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
322
|
-
derivationMode: "",
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
expect(etherscanERC20EventToOperation(accountId, etherscanOp)).toEqual(null);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it("should convert a etherscan-like usdc out event (from their API) to a Ledger Live Operation", () => {
|
|
329
|
-
const etherscanOp: EtherscanERC20Event = {
|
|
330
|
-
blockNumber: "16240731",
|
|
331
|
-
timeStamp: "1671717983",
|
|
332
|
-
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
333
|
-
nonce: "53",
|
|
334
|
-
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
335
|
-
from: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
336
|
-
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
337
|
-
to: "0xc2907efcce4011c491bbeda8a0fa63ba7aab596c",
|
|
338
|
-
value: "2000000",
|
|
339
|
-
tokenName: "USD Coin",
|
|
340
|
-
tokenSymbol: "USDC",
|
|
341
|
-
tokenDecimal: "6",
|
|
342
|
-
transactionIndex: "65",
|
|
343
|
-
gas: "79381",
|
|
344
|
-
gasPrice: "24314367325",
|
|
345
|
-
gasUsed: "65613",
|
|
346
|
-
cumulativeGasUsed: "4557746",
|
|
347
|
-
input: "deprecated",
|
|
348
|
-
confirmations: "150032",
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
const accountId = encodeAccountId({
|
|
352
|
-
type: "js",
|
|
353
|
-
version: "2",
|
|
354
|
-
currencyId: "ethereum",
|
|
355
|
-
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
356
|
-
derivationMode: "",
|
|
357
|
-
});
|
|
358
|
-
const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
|
|
359
|
-
const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency!);
|
|
360
|
-
|
|
361
|
-
const expectedOperation: Operation = {
|
|
362
|
-
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-OUT",
|
|
363
|
-
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
364
|
-
accountId: tokenAccountId,
|
|
365
|
-
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
366
|
-
blockHeight: 16240731,
|
|
367
|
-
senders: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
368
|
-
recipients: ["0xC2907EFccE4011C491BbedA8A0fA63BA7aab596C"],
|
|
369
|
-
value: new BigNumber("2000000"),
|
|
370
|
-
fee: new BigNumber("1595338583295225"),
|
|
371
|
-
contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
372
|
-
date: new Date("2022-12-22T14:06:23.000Z"),
|
|
373
|
-
transactionSequenceNumber: 53,
|
|
374
|
-
type: "OUT",
|
|
375
|
-
extra: {},
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
expect(etherscanERC20EventToOperation(accountId, etherscanOp)).toEqual({
|
|
379
|
-
operation: expectedOperation,
|
|
380
|
-
tokenCurrency,
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
it("should convert a etherscan-like usdc in event (from their API) to a Ledger Live Operation", () => {
|
|
385
|
-
const etherscanOp: EtherscanERC20Event = {
|
|
386
|
-
blockNumber: "16240731",
|
|
387
|
-
timeStamp: "1671717983",
|
|
388
|
-
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
389
|
-
nonce: "53",
|
|
390
|
-
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
391
|
-
from: "0xc2907efcce4011c491bbeda8a0fa63ba7aab596c",
|
|
392
|
-
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
393
|
-
to: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
394
|
-
value: "2000000",
|
|
395
|
-
tokenName: "USD Coin",
|
|
396
|
-
tokenSymbol: "USDC",
|
|
397
|
-
tokenDecimal: "6",
|
|
398
|
-
transactionIndex: "65",
|
|
399
|
-
gas: "79381",
|
|
400
|
-
gasPrice: "24314367325",
|
|
401
|
-
gasUsed: "65613",
|
|
402
|
-
cumulativeGasUsed: "4557746",
|
|
403
|
-
input: "deprecated",
|
|
404
|
-
confirmations: "150032",
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
const accountId = encodeAccountId({
|
|
408
|
-
type: "js",
|
|
409
|
-
version: "2",
|
|
410
|
-
currencyId: "ethereum",
|
|
411
|
-
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
412
|
-
derivationMode: "",
|
|
413
|
-
});
|
|
414
|
-
const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
|
|
415
|
-
const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency!);
|
|
416
|
-
|
|
417
|
-
const expectedOperation: Operation = {
|
|
418
|
-
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-IN",
|
|
419
|
-
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
420
|
-
accountId: tokenAccountId,
|
|
421
|
-
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
422
|
-
blockHeight: 16240731,
|
|
423
|
-
senders: ["0xC2907EFccE4011C491BbedA8A0fA63BA7aab596C"],
|
|
424
|
-
recipients: ["0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"],
|
|
425
|
-
value: new BigNumber("2000000"),
|
|
426
|
-
fee: new BigNumber("1595338583295225"),
|
|
427
|
-
contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
428
|
-
date: new Date("2022-12-22T14:06:23.000Z"),
|
|
429
|
-
transactionSequenceNumber: 53,
|
|
430
|
-
type: "IN",
|
|
431
|
-
extra: {},
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
expect(etherscanERC20EventToOperation(accountId, etherscanOp)).toEqual({
|
|
435
|
-
operation: expectedOperation,
|
|
436
|
-
tokenCurrency,
|
|
437
|
-
});
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it("should convert a etherscan-like usdc none event (from their API) to a Ledger Live Operation", () => {
|
|
441
|
-
const etherscanOp: EtherscanERC20Event = {
|
|
442
|
-
blockNumber: "16240731",
|
|
443
|
-
timeStamp: "1671717983",
|
|
444
|
-
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
445
|
-
nonce: "53",
|
|
446
|
-
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
447
|
-
from: "0x6bfd74c0996f269bcece59191eff667b3dfd73b9",
|
|
448
|
-
contractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
449
|
-
to: "0x02a357476a300c89ce27d7d4c7e57bbd2dd3f006",
|
|
450
|
-
value: "2000000",
|
|
451
|
-
tokenName: "USD Coin",
|
|
452
|
-
tokenSymbol: "USDC",
|
|
453
|
-
tokenDecimal: "6",
|
|
454
|
-
transactionIndex: "65",
|
|
455
|
-
gas: "79381",
|
|
456
|
-
gasPrice: "24314367325",
|
|
457
|
-
gasUsed: "65613",
|
|
458
|
-
cumulativeGasUsed: "4557746",
|
|
459
|
-
input: "deprecated",
|
|
460
|
-
confirmations: "150032",
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
const accountId = encodeAccountId({
|
|
464
|
-
type: "js",
|
|
465
|
-
version: "2",
|
|
466
|
-
currencyId: "ethereum",
|
|
467
|
-
xpubOrAddress: "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d",
|
|
468
|
-
derivationMode: "",
|
|
469
|
-
});
|
|
470
|
-
const tokenCurrency = findTokenById("ethereum/erc20/usd__coin");
|
|
471
|
-
const tokenAccountId = encodeTokenAccountId(accountId, tokenCurrency!);
|
|
472
|
-
|
|
473
|
-
const expectedOperation: Operation = {
|
|
474
|
-
id: "js:2:ethereum:0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d:+ethereum%2Ferc20%2Fusd__coin-0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf-NONE",
|
|
475
|
-
hash: "0x02b972f304dc24c9bc362e6435c4ad654241f9af916689a4790145c9bcbdf4cf",
|
|
476
|
-
accountId: tokenAccountId,
|
|
477
|
-
blockHash: "0x58ee7556044cd139e569c87c173a6dedbfbeb9ada6693ee6090fd510acee9c21",
|
|
478
|
-
blockHeight: 16240731,
|
|
479
|
-
recipients: ["0x02a357476A300c89Ce27D7D4C7E57Bbd2DD3f006"],
|
|
480
|
-
senders: ["0x6bfD74C0996F269Bcece59191EFf667b3dFD73b9"],
|
|
481
|
-
value: new BigNumber("2000000"),
|
|
482
|
-
fee: new BigNumber("1595338583295225"),
|
|
483
|
-
contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
484
|
-
date: new Date("2022-12-22T14:06:23.000Z"),
|
|
485
|
-
transactionSequenceNumber: 53,
|
|
486
|
-
type: "NONE",
|
|
487
|
-
extra: {},
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
expect(etherscanERC20EventToOperation(accountId, etherscanOp)).toEqual({
|
|
491
|
-
operation: expectedOperation,
|
|
492
|
-
tokenCurrency,
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
});
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
2
|
-
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
3
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
|
-
import { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
5
|
-
import BigNumber from "bignumber.js";
|
|
6
|
-
import * as API from "../api/rpc/rpc.common";
|
|
7
|
-
import broadcast from "../broadcast";
|
|
8
|
-
import buildOptimisticOperation from "../buildOptimisticOperation";
|
|
9
|
-
import { getEstimatedFees } from "../logic";
|
|
10
|
-
import { makeAccount, makeTokenAccount } from "../testUtils";
|
|
11
|
-
import { Transaction as EvmTransaction } from "../types";
|
|
12
|
-
|
|
13
|
-
const currency: CryptoCurrency = getCryptoCurrencyById("ethereum");
|
|
14
|
-
const tokenCurrency = getTokenById("ethereum/erc20/usd__coin");
|
|
15
|
-
const tokenAccount: TokenAccount = makeTokenAccount(
|
|
16
|
-
"0x055C1e159E345cB4197e3844a86A61E0a801d856", // jacquie.eth
|
|
17
|
-
tokenCurrency,
|
|
18
|
-
);
|
|
19
|
-
const account: Account = makeAccount(
|
|
20
|
-
"0x055C1e159E345cB4197e3844a86A61E0a801d856", // jacquie.eth
|
|
21
|
-
currency,
|
|
22
|
-
[tokenAccount],
|
|
23
|
-
);
|
|
24
|
-
const mockedBroadcastResponse = {
|
|
25
|
-
hash: "0xH4sH",
|
|
26
|
-
blockNumber: 420,
|
|
27
|
-
blockHash: "0xBl0cKH4sH",
|
|
28
|
-
timestamp: Date.now() / 1000, // block timestamps are in seconds
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
describe("EVM Family", () => {
|
|
32
|
-
describe("broadcast.ts", () => {
|
|
33
|
-
beforeAll(() => {
|
|
34
|
-
jest
|
|
35
|
-
.spyOn(API, "broadcastTransaction")
|
|
36
|
-
.mockImplementation(async () => mockedBroadcastResponse as any);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
afterAll(() => {
|
|
40
|
-
jest.restoreAllMocks();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe("broadcast", () => {
|
|
44
|
-
it("should broadcast the coin transaction and fill the blank in the optimistic transaction", async () => {
|
|
45
|
-
const coinTransaction: EvmTransaction = {
|
|
46
|
-
amount: new BigNumber(100),
|
|
47
|
-
useAllAmount: false,
|
|
48
|
-
subAccountId: "id",
|
|
49
|
-
recipient: "0x51DF0aF74a0DBae16cB845B46dAF2a35cB1D4168", // michel.eth
|
|
50
|
-
feesStrategy: "custom",
|
|
51
|
-
family: "evm",
|
|
52
|
-
mode: "send",
|
|
53
|
-
nonce: 0,
|
|
54
|
-
gasLimit: new BigNumber(21000),
|
|
55
|
-
chainId: 1,
|
|
56
|
-
maxFeePerGas: new BigNumber(100),
|
|
57
|
-
maxPriorityFeePerGas: new BigNumber(100),
|
|
58
|
-
type: 2,
|
|
59
|
-
};
|
|
60
|
-
const estimatedFees = getEstimatedFees(coinTransaction);
|
|
61
|
-
const optimisticCoinOperation = buildOptimisticOperation(account, coinTransaction);
|
|
62
|
-
|
|
63
|
-
const finalOperation = await broadcast({
|
|
64
|
-
account,
|
|
65
|
-
signedOperation: {
|
|
66
|
-
operation: optimisticCoinOperation,
|
|
67
|
-
signature: "0xS1gn4tUR3",
|
|
68
|
-
expirationDate: null,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
expect(API.broadcastTransaction).toBeCalled();
|
|
73
|
-
expect(finalOperation).toEqual({
|
|
74
|
-
id: encodeOperationId(account.id, mockedBroadcastResponse.hash, "OUT"),
|
|
75
|
-
hash: mockedBroadcastResponse.hash,
|
|
76
|
-
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
77
|
-
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
78
|
-
blockHash: mockedBroadcastResponse.blockHash,
|
|
79
|
-
value: coinTransaction.amount.plus(estimatedFees),
|
|
80
|
-
fee: estimatedFees,
|
|
81
|
-
type: "OUT",
|
|
82
|
-
senders: [account.freshAddress],
|
|
83
|
-
recipients: [coinTransaction.recipient],
|
|
84
|
-
accountId: account.id,
|
|
85
|
-
transactionSequenceNumber: 0,
|
|
86
|
-
subOperations: [],
|
|
87
|
-
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
88
|
-
extra: {},
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("should broadcast the token transaction and fill the blank in the optimistic transaction", async () => {
|
|
93
|
-
const tokenTransaction: EvmTransaction = {
|
|
94
|
-
amount: new BigNumber(100),
|
|
95
|
-
useAllAmount: false,
|
|
96
|
-
subAccountId: tokenAccount.id,
|
|
97
|
-
recipient: "0x51DF0aF74a0DBae16cB845B46dAF2a35cB1D4168", // michel.eth
|
|
98
|
-
data: Buffer.from(
|
|
99
|
-
"a9059cbb00000000000000000000000059569e96d0e3d9728dc07bf5c1443809e6f237fd0000000000000000000000000000000000000000000000000c06701668d322ac",
|
|
100
|
-
"hex",
|
|
101
|
-
),
|
|
102
|
-
feesStrategy: "custom",
|
|
103
|
-
family: "evm",
|
|
104
|
-
mode: "send",
|
|
105
|
-
nonce: 0,
|
|
106
|
-
gasLimit: new BigNumber(60000),
|
|
107
|
-
chainId: 1,
|
|
108
|
-
maxFeePerGas: new BigNumber(100),
|
|
109
|
-
maxPriorityFeePerGas: new BigNumber(100),
|
|
110
|
-
type: 2,
|
|
111
|
-
};
|
|
112
|
-
const estimatedFees = getEstimatedFees(tokenTransaction);
|
|
113
|
-
const optimisticTokenOperation = buildOptimisticOperation(account, tokenTransaction);
|
|
114
|
-
|
|
115
|
-
const finalOperation = await broadcast({
|
|
116
|
-
account,
|
|
117
|
-
signedOperation: {
|
|
118
|
-
operation: optimisticTokenOperation,
|
|
119
|
-
signature: "0xS1gn4tUR3",
|
|
120
|
-
expirationDate: null,
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
expect(API.broadcastTransaction).toBeCalled();
|
|
125
|
-
expect(finalOperation).toEqual({
|
|
126
|
-
id: encodeOperationId(account.id, mockedBroadcastResponse.hash, "FEES"),
|
|
127
|
-
hash: mockedBroadcastResponse.hash,
|
|
128
|
-
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
129
|
-
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
130
|
-
blockHash: mockedBroadcastResponse.blockHash,
|
|
131
|
-
value: estimatedFees,
|
|
132
|
-
fee: estimatedFees,
|
|
133
|
-
type: "FEES",
|
|
134
|
-
senders: [account.freshAddress],
|
|
135
|
-
recipients: [tokenCurrency?.contractAddress || ""],
|
|
136
|
-
accountId: account.id,
|
|
137
|
-
transactionSequenceNumber: 0,
|
|
138
|
-
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
139
|
-
subOperations: [
|
|
140
|
-
{
|
|
141
|
-
id: encodeOperationId(tokenAccount.id, mockedBroadcastResponse.hash, "OUT"),
|
|
142
|
-
hash: mockedBroadcastResponse.hash,
|
|
143
|
-
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
144
|
-
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
145
|
-
blockHash: mockedBroadcastResponse.blockHash,
|
|
146
|
-
value: new BigNumber(100),
|
|
147
|
-
fee: estimatedFees,
|
|
148
|
-
type: "OUT",
|
|
149
|
-
senders: [account.freshAddress],
|
|
150
|
-
recipients: [tokenTransaction.recipient],
|
|
151
|
-
accountId: tokenAccount.id,
|
|
152
|
-
transactionSequenceNumber: 0,
|
|
153
|
-
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
154
|
-
contract: tokenAccount.token.contractAddress,
|
|
155
|
-
extra: {},
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
extra: {},
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
});
|