@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,332 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import {
|
|
3
|
+
encodeERC1155OperationId,
|
|
4
|
+
encodeERC721OperationId,
|
|
5
|
+
} from "@ledgerhq/coin-framework/nft/nftOperationId";
|
|
6
|
+
import { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
7
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
8
|
+
import { encodeNftId } from "@ledgerhq/coin-framework/nft/nftId";
|
|
9
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
10
|
+
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
11
|
+
import { makeAccount, makeTokenAccount } from "../fixtures/common.fixtures";
|
|
12
|
+
import buildOptimisticOperation from "../../buildOptimisticOperation";
|
|
13
|
+
import { Transaction as EvmTransaction } from "../../types";
|
|
14
|
+
import * as API from "../../api/rpc/rpc.common";
|
|
15
|
+
import { getEstimatedFees } from "../../logic";
|
|
16
|
+
import broadcast from "../../broadcast";
|
|
17
|
+
|
|
18
|
+
const currency: CryptoCurrency = getCryptoCurrencyById("ethereum");
|
|
19
|
+
const tokenCurrency = getTokenById("ethereum/erc20/usd__coin");
|
|
20
|
+
const tokenAccount: TokenAccount = makeTokenAccount(
|
|
21
|
+
"0x055C1e159E345cB4197e3844a86A61E0a801d856", // jacquie.eth
|
|
22
|
+
tokenCurrency,
|
|
23
|
+
);
|
|
24
|
+
const account: Account = makeAccount(
|
|
25
|
+
"0x055C1e159E345cB4197e3844a86A61E0a801d856", // jacquie.eth
|
|
26
|
+
currency,
|
|
27
|
+
[tokenAccount],
|
|
28
|
+
);
|
|
29
|
+
const mockedBroadcastResponse = {
|
|
30
|
+
hash: "0xH4sH",
|
|
31
|
+
blockNumber: 420,
|
|
32
|
+
blockHash: "0xBl0cKH4sH",
|
|
33
|
+
timestamp: Date.now() / 1000, // block timestamps are in seconds
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe("EVM Family", () => {
|
|
37
|
+
describe("broadcast.ts", () => {
|
|
38
|
+
beforeAll(() => {
|
|
39
|
+
jest
|
|
40
|
+
.spyOn(API, "broadcastTransaction")
|
|
41
|
+
.mockImplementation(async () => mockedBroadcastResponse as any);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterAll(() => {
|
|
45
|
+
jest.restoreAllMocks();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("broadcast", () => {
|
|
49
|
+
it("should broadcast the coin transaction and fill the blank in the optimistic transaction", async () => {
|
|
50
|
+
const coinTransaction: EvmTransaction = {
|
|
51
|
+
amount: new BigNumber(100),
|
|
52
|
+
useAllAmount: false,
|
|
53
|
+
subAccountId: "id",
|
|
54
|
+
recipient: "0x51DF0aF74a0DBae16cB845B46dAF2a35cB1D4168", // michel.eth
|
|
55
|
+
feesStrategy: "custom",
|
|
56
|
+
family: "evm",
|
|
57
|
+
mode: "send",
|
|
58
|
+
nonce: 0,
|
|
59
|
+
gasLimit: new BigNumber(21000),
|
|
60
|
+
chainId: 1,
|
|
61
|
+
maxFeePerGas: new BigNumber(100),
|
|
62
|
+
maxPriorityFeePerGas: new BigNumber(100),
|
|
63
|
+
type: 2,
|
|
64
|
+
};
|
|
65
|
+
const estimatedFees = getEstimatedFees(coinTransaction);
|
|
66
|
+
const optimisticCoinOperation = buildOptimisticOperation(account, coinTransaction);
|
|
67
|
+
|
|
68
|
+
const finalOperation = await broadcast({
|
|
69
|
+
account,
|
|
70
|
+
signedOperation: {
|
|
71
|
+
operation: optimisticCoinOperation,
|
|
72
|
+
signature: "0xS1gn4tUR3",
|
|
73
|
+
expirationDate: null,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(API.broadcastTransaction).toBeCalled();
|
|
78
|
+
expect(finalOperation).toEqual({
|
|
79
|
+
id: encodeOperationId(account.id, mockedBroadcastResponse.hash, "OUT"),
|
|
80
|
+
hash: mockedBroadcastResponse.hash,
|
|
81
|
+
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
82
|
+
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
83
|
+
blockHash: mockedBroadcastResponse.blockHash,
|
|
84
|
+
value: coinTransaction.amount.plus(estimatedFees),
|
|
85
|
+
fee: estimatedFees,
|
|
86
|
+
type: "OUT",
|
|
87
|
+
senders: [account.freshAddress],
|
|
88
|
+
recipients: [coinTransaction.recipient],
|
|
89
|
+
accountId: account.id,
|
|
90
|
+
transactionSequenceNumber: 0,
|
|
91
|
+
subOperations: [],
|
|
92
|
+
nftOperations: [],
|
|
93
|
+
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
94
|
+
extra: {},
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("should broadcast the token transaction and fill the blank in the optimistic transaction", async () => {
|
|
99
|
+
const tokenTransaction: EvmTransaction = {
|
|
100
|
+
amount: new BigNumber(100),
|
|
101
|
+
useAllAmount: false,
|
|
102
|
+
subAccountId: tokenAccount.id,
|
|
103
|
+
recipient: "0x51DF0aF74a0DBae16cB845B46dAF2a35cB1D4168", // michel.eth
|
|
104
|
+
data: Buffer.from(
|
|
105
|
+
"a9059cbb00000000000000000000000059569e96d0e3d9728dc07bf5c1443809e6f237fd0000000000000000000000000000000000000000000000000c06701668d322ac",
|
|
106
|
+
"hex",
|
|
107
|
+
),
|
|
108
|
+
feesStrategy: "custom",
|
|
109
|
+
family: "evm",
|
|
110
|
+
mode: "send",
|
|
111
|
+
nonce: 0,
|
|
112
|
+
gasLimit: new BigNumber(60000),
|
|
113
|
+
chainId: 1,
|
|
114
|
+
maxFeePerGas: new BigNumber(100),
|
|
115
|
+
maxPriorityFeePerGas: new BigNumber(100),
|
|
116
|
+
type: 2,
|
|
117
|
+
};
|
|
118
|
+
const estimatedFees = getEstimatedFees(tokenTransaction);
|
|
119
|
+
const optimisticTokenOperation = buildOptimisticOperation(account, tokenTransaction);
|
|
120
|
+
|
|
121
|
+
const finalOperation = await broadcast({
|
|
122
|
+
account,
|
|
123
|
+
signedOperation: {
|
|
124
|
+
operation: optimisticTokenOperation,
|
|
125
|
+
signature: "0xS1gn4tUR3",
|
|
126
|
+
expirationDate: null,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
expect(API.broadcastTransaction).toBeCalled();
|
|
131
|
+
expect(finalOperation).toEqual({
|
|
132
|
+
id: encodeOperationId(account.id, mockedBroadcastResponse.hash, "FEES"),
|
|
133
|
+
hash: mockedBroadcastResponse.hash,
|
|
134
|
+
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
135
|
+
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
136
|
+
blockHash: mockedBroadcastResponse.blockHash,
|
|
137
|
+
value: estimatedFees,
|
|
138
|
+
fee: estimatedFees,
|
|
139
|
+
type: "FEES",
|
|
140
|
+
senders: [account.freshAddress],
|
|
141
|
+
recipients: [tokenCurrency?.contractAddress || ""],
|
|
142
|
+
accountId: account.id,
|
|
143
|
+
transactionSequenceNumber: 0,
|
|
144
|
+
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
145
|
+
nftOperations: [],
|
|
146
|
+
subOperations: [
|
|
147
|
+
{
|
|
148
|
+
id: encodeOperationId(tokenAccount.id, mockedBroadcastResponse.hash, "OUT"),
|
|
149
|
+
hash: mockedBroadcastResponse.hash,
|
|
150
|
+
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
151
|
+
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
152
|
+
blockHash: mockedBroadcastResponse.blockHash,
|
|
153
|
+
value: new BigNumber(100),
|
|
154
|
+
fee: estimatedFees,
|
|
155
|
+
type: "OUT",
|
|
156
|
+
senders: [account.freshAddress],
|
|
157
|
+
recipients: [tokenTransaction.recipient],
|
|
158
|
+
accountId: tokenAccount.id,
|
|
159
|
+
transactionSequenceNumber: 0,
|
|
160
|
+
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
161
|
+
contract: tokenAccount.token.contractAddress,
|
|
162
|
+
extra: {},
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
extra: {},
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("should broadcast the ERC721 transaction and fill the blank in the optimistic transaction", async () => {
|
|
170
|
+
const nft = {
|
|
171
|
+
contract: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
|
|
172
|
+
tokenId: "1",
|
|
173
|
+
quantity: new BigNumber(1),
|
|
174
|
+
collectionName: "BAYC",
|
|
175
|
+
};
|
|
176
|
+
const erc721Transaction: EvmTransaction = {
|
|
177
|
+
family: "evm",
|
|
178
|
+
mode: "erc721",
|
|
179
|
+
amount: new BigNumber(100),
|
|
180
|
+
useAllAmount: false,
|
|
181
|
+
subAccountId: tokenAccount.id,
|
|
182
|
+
recipient: "0x51DF0aF74a0DBae16cB845B46dAF2a35cB1D4168", // michel.eth
|
|
183
|
+
data: Buffer.from(
|
|
184
|
+
"b88d4fde0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d00000000000000000000000051df0af74a0dbae16cb845b46daf2a35cb1d4168000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000",
|
|
185
|
+
"hex",
|
|
186
|
+
),
|
|
187
|
+
feesStrategy: "custom",
|
|
188
|
+
nonce: 0,
|
|
189
|
+
gasLimit: new BigNumber(60000),
|
|
190
|
+
chainId: 1,
|
|
191
|
+
nft,
|
|
192
|
+
maxFeePerGas: new BigNumber(100),
|
|
193
|
+
maxPriorityFeePerGas: new BigNumber(100),
|
|
194
|
+
type: 2,
|
|
195
|
+
};
|
|
196
|
+
const estimatedFees = getEstimatedFees(erc721Transaction);
|
|
197
|
+
const optimisticErc721Operation = buildOptimisticOperation(account, erc721Transaction);
|
|
198
|
+
|
|
199
|
+
const finalOperation = await broadcast({
|
|
200
|
+
account,
|
|
201
|
+
signedOperation: {
|
|
202
|
+
operation: optimisticErc721Operation,
|
|
203
|
+
signature: "0xS1gn4tUR3",
|
|
204
|
+
expirationDate: null,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
const nftId = encodeNftId(account.id, nft.contract, nft.tokenId, account.currency.id);
|
|
208
|
+
|
|
209
|
+
expect(API.broadcastTransaction).toBeCalled();
|
|
210
|
+
expect(finalOperation).toEqual({
|
|
211
|
+
id: encodeOperationId(account.id, mockedBroadcastResponse.hash, "FEES"),
|
|
212
|
+
hash: mockedBroadcastResponse.hash,
|
|
213
|
+
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
214
|
+
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
215
|
+
blockHash: mockedBroadcastResponse.blockHash,
|
|
216
|
+
value: estimatedFees,
|
|
217
|
+
fee: estimatedFees,
|
|
218
|
+
type: "FEES",
|
|
219
|
+
senders: [account.freshAddress],
|
|
220
|
+
recipients: [nft.contract],
|
|
221
|
+
accountId: account.id,
|
|
222
|
+
transactionSequenceNumber: 0,
|
|
223
|
+
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
224
|
+
subOperations: [],
|
|
225
|
+
nftOperations: [
|
|
226
|
+
{
|
|
227
|
+
id: encodeERC721OperationId(nftId, mockedBroadcastResponse.hash, "NFT_OUT", 0),
|
|
228
|
+
hash: mockedBroadcastResponse.hash,
|
|
229
|
+
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
230
|
+
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
231
|
+
blockHash: mockedBroadcastResponse.blockHash,
|
|
232
|
+
value: nft.quantity,
|
|
233
|
+
fee: estimatedFees,
|
|
234
|
+
type: "NFT_OUT",
|
|
235
|
+
senders: [account.freshAddress],
|
|
236
|
+
recipients: [erc721Transaction.recipient],
|
|
237
|
+
accountId: account.id,
|
|
238
|
+
transactionSequenceNumber: 0,
|
|
239
|
+
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
240
|
+
contract: nft.contract,
|
|
241
|
+
tokenId: nft.tokenId,
|
|
242
|
+
standard: "ERC721",
|
|
243
|
+
extra: {},
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
extra: {},
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("should broadcast the ERC1155 transaction and fill the blank in the optimistic transaction", async () => {
|
|
251
|
+
const nft = {
|
|
252
|
+
contract: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
|
|
253
|
+
tokenId: "1",
|
|
254
|
+
quantity: new BigNumber(10),
|
|
255
|
+
collectionName: "BAYC",
|
|
256
|
+
};
|
|
257
|
+
const erc1155Transaction: EvmTransaction = {
|
|
258
|
+
family: "evm",
|
|
259
|
+
mode: "erc1155",
|
|
260
|
+
amount: new BigNumber(100),
|
|
261
|
+
useAllAmount: false,
|
|
262
|
+
subAccountId: tokenAccount.id,
|
|
263
|
+
recipient: "0x51DF0aF74a0DBae16cB845B46dAF2a35cB1D4168", // michel.eth
|
|
264
|
+
data: Buffer.from(
|
|
265
|
+
"f242432a0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d00000000000000000000000051df0af74a0dbae16cb845b46daf2a35cb1d41680000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
|
|
266
|
+
"hex",
|
|
267
|
+
),
|
|
268
|
+
feesStrategy: "custom",
|
|
269
|
+
nonce: 0,
|
|
270
|
+
gasLimit: new BigNumber(60000),
|
|
271
|
+
chainId: 1,
|
|
272
|
+
nft,
|
|
273
|
+
maxFeePerGas: new BigNumber(100),
|
|
274
|
+
maxPriorityFeePerGas: new BigNumber(100),
|
|
275
|
+
type: 2,
|
|
276
|
+
};
|
|
277
|
+
const estimatedFees = getEstimatedFees(erc1155Transaction);
|
|
278
|
+
const optimisticErc721Operation = buildOptimisticOperation(account, erc1155Transaction);
|
|
279
|
+
|
|
280
|
+
const finalOperation = await broadcast({
|
|
281
|
+
account,
|
|
282
|
+
signedOperation: {
|
|
283
|
+
operation: optimisticErc721Operation,
|
|
284
|
+
signature: "0xS1gn4tUR3",
|
|
285
|
+
expirationDate: null,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
const nftId = encodeNftId(account.id, nft.contract, nft.tokenId, account.currency.id);
|
|
289
|
+
|
|
290
|
+
expect(API.broadcastTransaction).toBeCalled();
|
|
291
|
+
expect(finalOperation).toEqual({
|
|
292
|
+
id: encodeOperationId(account.id, mockedBroadcastResponse.hash, "FEES"),
|
|
293
|
+
hash: mockedBroadcastResponse.hash,
|
|
294
|
+
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
295
|
+
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
296
|
+
blockHash: mockedBroadcastResponse.blockHash,
|
|
297
|
+
value: estimatedFees,
|
|
298
|
+
fee: estimatedFees,
|
|
299
|
+
type: "FEES",
|
|
300
|
+
senders: [account.freshAddress],
|
|
301
|
+
recipients: [nft.contract],
|
|
302
|
+
accountId: account.id,
|
|
303
|
+
transactionSequenceNumber: 0,
|
|
304
|
+
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
305
|
+
subOperations: [],
|
|
306
|
+
nftOperations: [
|
|
307
|
+
{
|
|
308
|
+
id: encodeERC1155OperationId(nftId, mockedBroadcastResponse.hash, "NFT_OUT", 0),
|
|
309
|
+
hash: mockedBroadcastResponse.hash,
|
|
310
|
+
blockNumber: mockedBroadcastResponse.blockNumber,
|
|
311
|
+
blockHeight: mockedBroadcastResponse.blockNumber,
|
|
312
|
+
blockHash: mockedBroadcastResponse.blockHash,
|
|
313
|
+
value: nft.quantity,
|
|
314
|
+
fee: estimatedFees,
|
|
315
|
+
type: "NFT_OUT",
|
|
316
|
+
senders: [account.freshAddress],
|
|
317
|
+
recipients: [erc1155Transaction.recipient],
|
|
318
|
+
accountId: account.id,
|
|
319
|
+
transactionSequenceNumber: 0,
|
|
320
|
+
date: new Date(mockedBroadcastResponse.timestamp * 1000),
|
|
321
|
+
contract: nft.contract,
|
|
322
|
+
tokenId: nft.tokenId,
|
|
323
|
+
standard: "ERC1155",
|
|
324
|
+
extra: {},
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
extra: {},
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
});
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import {
|
|
3
|
+
encodeERC1155OperationId,
|
|
4
|
+
encodeERC721OperationId,
|
|
5
|
+
} from "@ledgerhq/coin-framework/nft/nftOperationId";
|
|
6
|
+
import { encodeNftId } from "@ledgerhq/coin-framework/nft/nftId";
|
|
1
7
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
2
8
|
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
3
|
-
import
|
|
4
|
-
import buildOptimisticOperation from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Transaction as EvmTransaction } from "../types";
|
|
9
|
+
import { makeAccount, makeTokenAccount } from "../fixtures/common.fixtures";
|
|
10
|
+
import buildOptimisticOperation from "../../buildOptimisticOperation";
|
|
11
|
+
import { Transaction as EvmTransaction } from "../../types";
|
|
12
|
+
import { getEstimatedFees } from "../../logic";
|
|
8
13
|
|
|
9
14
|
const currency = getCryptoCurrencyById("ethereum");
|
|
10
15
|
const tokenCurrency = getTokenById("ethereum/erc20/usd__coin");
|
|
@@ -177,6 +182,140 @@ describe("EVM Family", () => {
|
|
|
177
182
|
extra: {},
|
|
178
183
|
});
|
|
179
184
|
});
|
|
185
|
+
|
|
186
|
+
it("should create an ERC721 optimistic transaction waiting for the broadcast to be completed", () => {
|
|
187
|
+
const nft = {
|
|
188
|
+
contract: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
|
|
189
|
+
tokenId: "1",
|
|
190
|
+
quantity: new BigNumber(1),
|
|
191
|
+
collectionName: "BAYC",
|
|
192
|
+
};
|
|
193
|
+
const erc721Transaction: EvmTransaction = {
|
|
194
|
+
family: "evm",
|
|
195
|
+
mode: "erc721",
|
|
196
|
+
amount: new BigNumber(0),
|
|
197
|
+
useAllAmount: false,
|
|
198
|
+
recipient: "0x51DF0aF74a0DBae16cB845B46dAF2a35cB1D4168", // michel.eth
|
|
199
|
+
data: Buffer.from(
|
|
200
|
+
"b88d4fde0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d00000000000000000000000051df0af74a0dbae16cb845b46daf2a35cb1d4168000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000",
|
|
201
|
+
"hex",
|
|
202
|
+
),
|
|
203
|
+
feesStrategy: "custom",
|
|
204
|
+
nonce: 0,
|
|
205
|
+
gasLimit: new BigNumber(60000),
|
|
206
|
+
chainId: 1,
|
|
207
|
+
nft,
|
|
208
|
+
maxFeePerGas: new BigNumber(100),
|
|
209
|
+
maxPriorityFeePerGas: new BigNumber(100),
|
|
210
|
+
type: 2,
|
|
211
|
+
};
|
|
212
|
+
const estimatedFees = getEstimatedFees(erc721Transaction);
|
|
213
|
+
const optimistic = buildOptimisticOperation(account, erc721Transaction);
|
|
214
|
+
const nftId = encodeNftId(account.id, nft.contract, nft.tokenId, account.currency.id);
|
|
215
|
+
|
|
216
|
+
expect(optimistic).toEqual({
|
|
217
|
+
id: encodeOperationId(account.id, "", "FEES"),
|
|
218
|
+
hash: "",
|
|
219
|
+
type: "FEES",
|
|
220
|
+
value: estimatedFees,
|
|
221
|
+
fee: estimatedFees,
|
|
222
|
+
blockHash: null,
|
|
223
|
+
blockHeight: null,
|
|
224
|
+
senders: [account.freshAddress],
|
|
225
|
+
recipients: [nft.contract],
|
|
226
|
+
accountId: account.id,
|
|
227
|
+
transactionSequenceNumber: 0,
|
|
228
|
+
date: expect.any(Date),
|
|
229
|
+
nftOperations: [
|
|
230
|
+
{
|
|
231
|
+
id: encodeERC721OperationId(nftId, "", "NFT_OUT", 0),
|
|
232
|
+
hash: "",
|
|
233
|
+
type: "NFT_OUT",
|
|
234
|
+
value: nft.quantity,
|
|
235
|
+
fee: estimatedFees,
|
|
236
|
+
blockHash: null,
|
|
237
|
+
blockHeight: null,
|
|
238
|
+
senders: [account.freshAddress],
|
|
239
|
+
recipients: [erc721Transaction.recipient],
|
|
240
|
+
accountId: account.id,
|
|
241
|
+
transactionSequenceNumber: 0,
|
|
242
|
+
date: expect.any(Date),
|
|
243
|
+
contract: nft.contract,
|
|
244
|
+
standard: "ERC721",
|
|
245
|
+
tokenId: nft.tokenId,
|
|
246
|
+
extra: {},
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
extra: {},
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("should create an ERC1155 optimistic transaction waiting for the broadcast to be completed", () => {
|
|
254
|
+
const nft = {
|
|
255
|
+
contract: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
|
|
256
|
+
tokenId: "1",
|
|
257
|
+
quantity: new BigNumber(10),
|
|
258
|
+
collectionName: "BAYC",
|
|
259
|
+
};
|
|
260
|
+
const erc1155Transaction: EvmTransaction = {
|
|
261
|
+
family: "evm",
|
|
262
|
+
mode: "erc1155",
|
|
263
|
+
amount: new BigNumber(0),
|
|
264
|
+
useAllAmount: false,
|
|
265
|
+
recipient: "0x51DF0aF74a0DBae16cB845B46dAF2a35cB1D4168", // michel.eth
|
|
266
|
+
data: Buffer.from(
|
|
267
|
+
"b88d4fde0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d00000000000000000000000051df0af74a0dbae16cb845b46daf2a35cb1d4168000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000",
|
|
268
|
+
"hex",
|
|
269
|
+
),
|
|
270
|
+
feesStrategy: "custom",
|
|
271
|
+
nonce: 0,
|
|
272
|
+
gasLimit: new BigNumber(60000),
|
|
273
|
+
chainId: 1,
|
|
274
|
+
nft,
|
|
275
|
+
maxFeePerGas: new BigNumber(100),
|
|
276
|
+
maxPriorityFeePerGas: new BigNumber(100),
|
|
277
|
+
type: 2,
|
|
278
|
+
};
|
|
279
|
+
const estimatedFees = getEstimatedFees(erc1155Transaction);
|
|
280
|
+
const optimistic = buildOptimisticOperation(account, erc1155Transaction);
|
|
281
|
+
const nftId = encodeNftId(account.id, nft.contract, nft.tokenId, account.currency.id);
|
|
282
|
+
|
|
283
|
+
expect(optimistic).toEqual({
|
|
284
|
+
id: encodeOperationId(account.id, "", "FEES"),
|
|
285
|
+
hash: "",
|
|
286
|
+
type: "FEES",
|
|
287
|
+
value: estimatedFees,
|
|
288
|
+
fee: estimatedFees,
|
|
289
|
+
blockHash: null,
|
|
290
|
+
blockHeight: null,
|
|
291
|
+
senders: [account.freshAddress],
|
|
292
|
+
recipients: [nft.contract],
|
|
293
|
+
accountId: account.id,
|
|
294
|
+
transactionSequenceNumber: 0,
|
|
295
|
+
date: expect.any(Date),
|
|
296
|
+
nftOperations: [
|
|
297
|
+
{
|
|
298
|
+
id: encodeERC1155OperationId(nftId, "", "NFT_OUT", 0),
|
|
299
|
+
hash: "",
|
|
300
|
+
type: "NFT_OUT",
|
|
301
|
+
value: nft.quantity,
|
|
302
|
+
fee: estimatedFees,
|
|
303
|
+
blockHash: null,
|
|
304
|
+
blockHeight: null,
|
|
305
|
+
senders: [account.freshAddress],
|
|
306
|
+
recipients: [erc1155Transaction.recipient],
|
|
307
|
+
accountId: account.id,
|
|
308
|
+
transactionSequenceNumber: 0,
|
|
309
|
+
date: expect.any(Date),
|
|
310
|
+
contract: nft.contract,
|
|
311
|
+
standard: "ERC1155",
|
|
312
|
+
tokenId: nft.tokenId,
|
|
313
|
+
extra: {},
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
extra: {},
|
|
317
|
+
});
|
|
318
|
+
});
|
|
180
319
|
});
|
|
181
320
|
});
|
|
182
321
|
});
|
package/src/__tests__/{createTransaction.unit.test.ts → unit/createTransaction.unit.test.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
2
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
1
|
import BigNumber from "bignumber.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
4
|
+
import { createTransaction } from "../../createTransaction";
|
|
5
|
+
import { makeAccount } from "../fixtures/common.fixtures";
|
|
6
6
|
|
|
7
7
|
const currencyWithChainId = getCryptoCurrencyById("ethereum");
|
|
8
8
|
const currencyWithoutChainId = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
2
1
|
import BigNumber from "bignumber.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
2
|
+
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
3
|
+
import { makeAccount, makeTokenAccount } from "../fixtures/common.fixtures";
|
|
4
|
+
import getDeviceTransactionConfig from "../../deviceTransactionConfig";
|
|
5
|
+
import getTransactionStatus from "../../getTransactionStatus";
|
|
6
|
+
import { Transaction as EvmTransaction } from "../../types";
|
|
7
7
|
|
|
8
8
|
const currency = getCryptoCurrencyById("ethereum");
|
|
9
9
|
const tokenCurrency = getTokenById("ethereum/erc20/usd__coin");
|
|
@@ -240,6 +240,131 @@ describe("EVM Family", () => {
|
|
|
240
240
|
{ type: "fees", label: "Max fees" },
|
|
241
241
|
]);
|
|
242
242
|
});
|
|
243
|
+
|
|
244
|
+
it("should return the right fields and infos for an NFT transaction mode 'erc721'", async () => {
|
|
245
|
+
const nftTransaction: EvmTransaction = {
|
|
246
|
+
family: "evm",
|
|
247
|
+
mode: "erc721",
|
|
248
|
+
amount: new BigNumber(0),
|
|
249
|
+
useAllAmount: false,
|
|
250
|
+
recipient: "0x8E9eDe486d8208705C67095dd0b4839dEB127132", // pascalgauthier.eth
|
|
251
|
+
feesStrategy: "custom",
|
|
252
|
+
nonce: 0,
|
|
253
|
+
gasLimit: new BigNumber(21000),
|
|
254
|
+
chainId: 1,
|
|
255
|
+
nft: {
|
|
256
|
+
contract: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
|
|
257
|
+
tokenId: "1",
|
|
258
|
+
quantity: new BigNumber(1),
|
|
259
|
+
collectionName: "BAYC",
|
|
260
|
+
},
|
|
261
|
+
maxFeePerGas: new BigNumber(100),
|
|
262
|
+
maxPriorityFeePerGas: new BigNumber(100),
|
|
263
|
+
type: 2,
|
|
264
|
+
};
|
|
265
|
+
const status = await getTransactionStatus(account, nftTransaction);
|
|
266
|
+
|
|
267
|
+
expect(
|
|
268
|
+
getDeviceTransactionConfig({
|
|
269
|
+
account: tokenAccount,
|
|
270
|
+
parentAccount: account,
|
|
271
|
+
transaction: nftTransaction,
|
|
272
|
+
status,
|
|
273
|
+
}),
|
|
274
|
+
).toEqual([
|
|
275
|
+
{
|
|
276
|
+
type: "text",
|
|
277
|
+
label: "Type",
|
|
278
|
+
value: `NFT Transfer`,
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
type: "text",
|
|
282
|
+
label: "To",
|
|
283
|
+
value: nftTransaction.recipient,
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
type: "text",
|
|
287
|
+
label: "Collection Name",
|
|
288
|
+
value: nftTransaction.nft.collectionName,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
type: "address",
|
|
292
|
+
label: "NFT Address",
|
|
293
|
+
address: nftTransaction.nft.contract,
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
type: "text",
|
|
297
|
+
label: "NFT ID",
|
|
298
|
+
value: nftTransaction.nft.tokenId,
|
|
299
|
+
},
|
|
300
|
+
{ type: "fees", label: "Max fees" },
|
|
301
|
+
]);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it("should return the right fields and infos for an NFT transaction mode 'erc1155'", async () => {
|
|
305
|
+
const nftTransaction: EvmTransaction = {
|
|
306
|
+
family: "evm",
|
|
307
|
+
mode: "erc1155",
|
|
308
|
+
amount: new BigNumber(0),
|
|
309
|
+
useAllAmount: false,
|
|
310
|
+
recipient: "0x8E9eDe486d8208705C67095dd0b4839dEB127132", // pascalgauthier.eth
|
|
311
|
+
feesStrategy: "custom",
|
|
312
|
+
nonce: 0,
|
|
313
|
+
gasLimit: new BigNumber(21000),
|
|
314
|
+
chainId: 1,
|
|
315
|
+
nft: {
|
|
316
|
+
contract: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
|
|
317
|
+
tokenId: "1",
|
|
318
|
+
quantity: new BigNumber(10),
|
|
319
|
+
collectionName: "BAYC",
|
|
320
|
+
},
|
|
321
|
+
maxFeePerGas: new BigNumber(100),
|
|
322
|
+
maxPriorityFeePerGas: new BigNumber(100),
|
|
323
|
+
type: 2,
|
|
324
|
+
};
|
|
325
|
+
const status = await getTransactionStatus(account, nftTransaction);
|
|
326
|
+
|
|
327
|
+
expect(
|
|
328
|
+
getDeviceTransactionConfig({
|
|
329
|
+
account: tokenAccount,
|
|
330
|
+
parentAccount: account,
|
|
331
|
+
transaction: nftTransaction,
|
|
332
|
+
status,
|
|
333
|
+
}),
|
|
334
|
+
).toEqual([
|
|
335
|
+
{
|
|
336
|
+
type: "text",
|
|
337
|
+
label: "Type",
|
|
338
|
+
value: `NFT Transfer`,
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
type: "text",
|
|
342
|
+
label: "To",
|
|
343
|
+
value: nftTransaction.recipient,
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
type: "text",
|
|
347
|
+
label: "Collection Name",
|
|
348
|
+
value: nftTransaction.nft.collectionName,
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
type: "text",
|
|
352
|
+
label: "Quantity",
|
|
353
|
+
value: nftTransaction.nft.quantity.toFixed(),
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
type: "address",
|
|
357
|
+
label: "NFT Address",
|
|
358
|
+
address: nftTransaction.nft.contract,
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
type: "text",
|
|
362
|
+
label: "NFT ID",
|
|
363
|
+
value: nftTransaction.nft.tokenId,
|
|
364
|
+
},
|
|
365
|
+
{ type: "fees", label: "Max fees" },
|
|
366
|
+
]);
|
|
367
|
+
});
|
|
243
368
|
});
|
|
244
369
|
});
|
|
245
370
|
});
|
package/src/__tests__/{estimateMaxSpendable.unit.test.ts → unit/estimateMaxSpendable.unit.test.ts}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
2
1
|
import BigNumber from "bignumber.js";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
3
|
+
import { makeAccount, makeTokenAccount } from "../fixtures/common.fixtures";
|
|
4
|
+
import { EvmTransactionEIP1559, EvmTransactionLegacy } from "../../types";
|
|
5
|
+
import { estimateMaxSpendable } from "../../estimateMaxSpendable";
|
|
6
|
+
import * as rpcAPI from "../../api/rpc/rpc.common";
|
|
7
7
|
|
|
8
8
|
const tokenAccount = {
|
|
9
9
|
...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
|