@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,7 +1,9 @@
|
|
|
1
|
+
/* istanbul ignore file: pure exports, test unecessary */
|
|
2
|
+
|
|
1
3
|
import { AccountRaw } from "@ledgerhq/types-live";
|
|
2
4
|
|
|
3
5
|
export const ethereum1: AccountRaw = {
|
|
4
|
-
id: "js:1:
|
|
6
|
+
id: "js:1:ethereum_as_evm_test_only:0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5:",
|
|
5
7
|
seedIdentifier: "0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5",
|
|
6
8
|
name: "Ethereum legacy xpub6Bem...JyAdpYZy",
|
|
7
9
|
derivationMode: "",
|
|
@@ -11,7 +13,7 @@ export const ethereum1: AccountRaw = {
|
|
|
11
13
|
freshAddresses: [],
|
|
12
14
|
pendingOperations: [],
|
|
13
15
|
operations: [],
|
|
14
|
-
currencyId: "
|
|
16
|
+
currencyId: "ethereum_as_evm_test_only",
|
|
15
17
|
unitMagnitude: 18,
|
|
16
18
|
balance: "",
|
|
17
19
|
blockHeight: 0,
|
|
@@ -51,6 +51,71 @@ function getDeviceTransactionConfig({
|
|
|
51
51
|
},
|
|
52
52
|
);
|
|
53
53
|
break;
|
|
54
|
+
|
|
55
|
+
case "erc721":
|
|
56
|
+
fields.push(
|
|
57
|
+
{
|
|
58
|
+
type: "text",
|
|
59
|
+
label: "Type",
|
|
60
|
+
value: `NFT Transfer`,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "text",
|
|
64
|
+
label: "To",
|
|
65
|
+
value: transaction.recipient,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: "text",
|
|
69
|
+
label: "Collection Name",
|
|
70
|
+
value: transaction.nft.collectionName,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: "address",
|
|
74
|
+
label: "NFT Address",
|
|
75
|
+
address: transaction.nft.contract,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "text",
|
|
79
|
+
label: "NFT ID",
|
|
80
|
+
value: transaction.nft.tokenId,
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case "erc1155":
|
|
86
|
+
fields.push(
|
|
87
|
+
{
|
|
88
|
+
type: "text",
|
|
89
|
+
label: "Type",
|
|
90
|
+
value: `NFT Transfer`,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "text",
|
|
94
|
+
label: "To",
|
|
95
|
+
value: transaction.recipient,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "text",
|
|
99
|
+
label: "Collection Name",
|
|
100
|
+
value: transaction.nft.collectionName,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: "text",
|
|
104
|
+
label: "Quantity",
|
|
105
|
+
value: transaction.nft.quantity.toFixed(),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: "address",
|
|
109
|
+
label: "NFT Address",
|
|
110
|
+
address: transaction.nft.contract,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: "text",
|
|
114
|
+
label: "NFT ID",
|
|
115
|
+
value: transaction.nft.tokenId,
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
break;
|
|
54
119
|
}
|
|
55
120
|
|
|
56
121
|
fields.push({
|
package/src/errors.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createCustomErrorClass } from "@ledgerhq/errors";
|
|
2
2
|
|
|
3
|
+
// Etherscan API
|
|
3
4
|
export const EtherscanAPIError = createCustomErrorClass("EtherscanAPIError");
|
|
5
|
+
|
|
6
|
+
// Gas
|
|
4
7
|
export const GasEstimationError = createCustomErrorClass("GasEstimationError");
|
|
5
8
|
export const InsufficientFunds = createCustomErrorClass("InsufficientFunds");
|
|
6
9
|
|
|
@@ -9,3 +12,8 @@ export const NoGasTrackerFound = createCustomErrorClass("NoGasTrackerFound");
|
|
|
9
12
|
export const GasTrackerDoesNotSupportEIP1559 = createCustomErrorClass(
|
|
10
13
|
"GasTrackerDoesNotSupportEIP1559",
|
|
11
14
|
);
|
|
15
|
+
|
|
16
|
+
// Nfts
|
|
17
|
+
export const NotOwnedNft = createCustomErrorClass("NotOwnedNft");
|
|
18
|
+
export const NotEnoughNftOwned = createCustomErrorClass("NotEnoughNftOwned");
|
|
19
|
+
export const QuantityNeedsToBePositive = createCustomErrorClass("QuantityNeedsToBePositive");
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
EvmTransactionLegacy,
|
|
20
20
|
Transaction as EvmTransaction,
|
|
21
21
|
} from "./types";
|
|
22
|
+
import { NotEnoughNftOwned, NotOwnedNft, QuantityNeedsToBePositive } from "./errors";
|
|
22
23
|
|
|
23
24
|
type ValidatedTransactionFields =
|
|
24
25
|
| "recipient"
|
|
@@ -131,6 +132,28 @@ export const validateGas = (
|
|
|
131
132
|
return [errors, warnings];
|
|
132
133
|
};
|
|
133
134
|
|
|
135
|
+
export const validateNft = (account: Account, tx: EvmTransaction): Array<ValidationIssues> => {
|
|
136
|
+
if (!tx.nft) return [{}, {}];
|
|
137
|
+
|
|
138
|
+
const errors: ValidationIssues = {};
|
|
139
|
+
const warnings: ValidationIssues = {};
|
|
140
|
+
|
|
141
|
+
const quantityIsPositive = tx.nft.quantity.gt(0);
|
|
142
|
+
const nftFromAccount = account.nfts?.find(
|
|
143
|
+
nft => nft.tokenId === tx.nft.tokenId && nft.contract === tx.nft.contract,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
if (!nftFromAccount) {
|
|
147
|
+
errors.amount = new NotOwnedNft();
|
|
148
|
+
} else if (!quantityIsPositive) {
|
|
149
|
+
errors.amount = new QuantityNeedsToBePositive();
|
|
150
|
+
} else if (nftFromAccount.amount.lt(tx.nft.quantity)) {
|
|
151
|
+
errors.amount = new NotEnoughNftOwned();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return [errors, warnings];
|
|
155
|
+
};
|
|
156
|
+
|
|
134
157
|
/**
|
|
135
158
|
* Validate a transaction and get all possibles errors and warnings about it
|
|
136
159
|
*/
|
|
@@ -151,16 +174,19 @@ export const getTransactionStatus: AccountBridge<EvmTransaction>["getTransaction
|
|
|
151
174
|
const [amountErr, amountWarn] = validateAmount(subAccount || account, tx, totalSpent);
|
|
152
175
|
// Gas related errors and warnings
|
|
153
176
|
const [gasErr, gasWarn] = validateGas(account, tx, gasLimit, totalFees);
|
|
177
|
+
const [nftErr, nftWarn] = validateNft(account, tx);
|
|
154
178
|
|
|
155
179
|
const errors: ValidationIssues = {
|
|
156
180
|
...recipientErr,
|
|
157
181
|
...gasErr,
|
|
158
182
|
...amountErr,
|
|
183
|
+
...nftErr,
|
|
159
184
|
};
|
|
160
185
|
const warnings: ValidationIssues = {
|
|
161
186
|
...recipientWarn,
|
|
162
187
|
...gasWarn,
|
|
163
188
|
...amountWarn,
|
|
189
|
+
...nftWarn,
|
|
164
190
|
};
|
|
165
191
|
|
|
166
192
|
return {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
3
|
+
import { isEIP712Message } from "@ledgerhq/evm-tools/message/EIP712/index";
|
|
4
|
+
import { Account, AnyMessage, DeviceId, TypedEvmMessage } from "@ledgerhq/types-live";
|
|
5
|
+
import { EvmSignature, EvmSigner } from "./signer";
|
|
6
|
+
|
|
7
|
+
export const prepareMessageToSign = ({ message }: { message: string }): TypedEvmMessage => {
|
|
8
|
+
const parsedMessage = (() => {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(message) as Record<string, unknown>;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
return message;
|
|
13
|
+
}
|
|
14
|
+
})();
|
|
15
|
+
|
|
16
|
+
if (isEIP712Message(parsedMessage)) {
|
|
17
|
+
// With the ethers lib, EIP712Domain type should be removed otherwise
|
|
18
|
+
// you'll end up with a "ambiguous primary types" error
|
|
19
|
+
const { EIP712Domain, ...otherTypes } = parsedMessage.types;
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
standard: "EIP712",
|
|
23
|
+
message: parsedMessage,
|
|
24
|
+
domainHash: ethers.utils._TypedDataEncoder.hashDomain(parsedMessage.domain),
|
|
25
|
+
hashStruct: ethers.utils._TypedDataEncoder.hashStruct(
|
|
26
|
+
parsedMessage.primaryType,
|
|
27
|
+
otherTypes,
|
|
28
|
+
parsedMessage.message,
|
|
29
|
+
),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
standard: "EIP191",
|
|
35
|
+
message,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const signMessage =
|
|
40
|
+
(signerContext: SignerContext<EvmSigner, EvmSignature>) =>
|
|
41
|
+
async (
|
|
42
|
+
deviceId: DeviceId,
|
|
43
|
+
account: Account,
|
|
44
|
+
messageOpts: AnyMessage,
|
|
45
|
+
): Promise<{
|
|
46
|
+
rsv: { r: string; s: string; v: string | number };
|
|
47
|
+
signature: string;
|
|
48
|
+
}> => {
|
|
49
|
+
if (messageOpts.standard === "EIP191") {
|
|
50
|
+
const { r, s, v } = await signerContext(deviceId, signer => {
|
|
51
|
+
return signer.signPersonalMessage(
|
|
52
|
+
account.freshAddressPath,
|
|
53
|
+
Buffer.from(messageOpts.message).toString("hex"),
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const signature = ethers.utils.joinSignature({
|
|
58
|
+
r: `0x${r}`,
|
|
59
|
+
s: `0x${s}`,
|
|
60
|
+
v: typeof v === "string" ? parseInt(v, 16) : v,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return { rsv: { r, s, v }, signature };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (messageOpts.standard === "EIP712") {
|
|
67
|
+
const { r, s, v } = await signerContext(deviceId, async signer => {
|
|
68
|
+
try {
|
|
69
|
+
return await signer.signEIP712Message(account.freshAddressPath, messageOpts.message);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
if (e instanceof Error && "statusText" in e && e.statusText === "INS_NOT_SUPPORTED") {
|
|
72
|
+
return await signer.signEIP712HashedMessage(
|
|
73
|
+
account.freshAddressPath,
|
|
74
|
+
messageOpts.domainHash,
|
|
75
|
+
messageOpts.hashStruct,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const signature = ethers.utils.joinSignature({
|
|
83
|
+
r: `0x${r}`,
|
|
84
|
+
s: `0x${s}`,
|
|
85
|
+
v: typeof v === "string" ? parseInt(v, 16) : v,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return { rsv: { r, s, v }, signature };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
throw new Error("Unsupported message standard");
|
|
92
|
+
};
|
package/src/logic.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
3
|
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
|
+
import { isNFTActive } from "@ledgerhq/coin-framework/nft/support";
|
|
4
5
|
import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
5
|
-
import { Account, SubAccount } from "@ledgerhq/types-live";
|
|
6
|
+
import { Account, SubAccount, Operation } from "@ledgerhq/types-live";
|
|
7
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
6
8
|
import { listTokensForCryptoCurrency } from "@ledgerhq/cryptoassets/tokens";
|
|
9
|
+
import { decodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
7
10
|
import { getOptimismAdditionalFees } from "./api/rpc/rpc.common";
|
|
8
11
|
import {
|
|
12
|
+
EvmNftTransaction,
|
|
9
13
|
Transaction as EvmTransaction,
|
|
10
14
|
EvmTransactionEIP1559,
|
|
11
15
|
EvmTransactionLegacy,
|
|
@@ -128,12 +132,124 @@ export const mergeSubAccounts = (
|
|
|
128
132
|
/**
|
|
129
133
|
* Method creating a hash that will help triggering or not a full synchronization on an account.
|
|
130
134
|
* As of now, it's checking if a token has been added, removed of changed regarding important properties
|
|
135
|
+
* and if the NFTs are activated/supported on this chain
|
|
131
136
|
*/
|
|
132
137
|
export const getSyncHash = (currency: CryptoCurrency): string => {
|
|
133
138
|
const tokens = listTokensForCryptoCurrency(currency);
|
|
134
139
|
const basicTokensListString = tokens
|
|
135
140
|
.map(token => token.id + token.contractAddress + token.name + token.ticker + token.delisted)
|
|
136
141
|
.join("");
|
|
142
|
+
const isNftSupported = isNFTActive(currency);
|
|
137
143
|
|
|
138
|
-
return ethers.utils.sha256(Buffer.from(basicTokensListString));
|
|
144
|
+
return ethers.utils.sha256(Buffer.from(basicTokensListString + isNftSupported));
|
|
139
145
|
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Helper in charge of linking operations together based on transaction hash.
|
|
149
|
+
* Token operations & NFT operations are the result of a coin operation
|
|
150
|
+
* and if this coin operation is originated by our user we want
|
|
151
|
+
* to link those operations together as main & children ops.
|
|
152
|
+
*
|
|
153
|
+
* A sub operation should always be linked to a coin operation,
|
|
154
|
+
* even if the user isn't at the origin of the sub op.
|
|
155
|
+
* "NONE" coin ops can be added when necessary.
|
|
156
|
+
*
|
|
157
|
+
* ⚠️ If an NFT operation was found without a coin parent op
|
|
158
|
+
* just like if it was not initiated by the synced account
|
|
159
|
+
* and we were to find that coin op during another sync,
|
|
160
|
+
* the NONE operation created would not be removed,
|
|
161
|
+
* creating a duplicate that will cause issues.
|
|
162
|
+
* (Incorrect NFT balance & React key dup)
|
|
163
|
+
*/
|
|
164
|
+
export const attachOperations = (
|
|
165
|
+
_coinOperations: Operation[],
|
|
166
|
+
_tokenOperations: Operation[],
|
|
167
|
+
_nftOperations: Operation[],
|
|
168
|
+
): Operation[] => {
|
|
169
|
+
// Creating deep copies of each Operation[] to prevent mutating the originals
|
|
170
|
+
const coinOperations = _coinOperations.map(op => ({ ...op }));
|
|
171
|
+
const tokenOperations = _tokenOperations.map(op => ({ ...op }));
|
|
172
|
+
const nftOperations = _nftOperations.map(op => ({ ...op }));
|
|
173
|
+
|
|
174
|
+
type OperationWithRequiredChildren = Operation &
|
|
175
|
+
Required<Pick<Operation, "nftOperations" | "subOperations">>;
|
|
176
|
+
|
|
177
|
+
// Helper to create a coin operation with type NONE as a parent of an orphan child operation
|
|
178
|
+
const makeCoinOpForOrphanChildOp = (childOp: Operation): OperationWithRequiredChildren => {
|
|
179
|
+
const type = "NONE";
|
|
180
|
+
const { accountId } = decodeTokenAccountId(childOp.accountId);
|
|
181
|
+
const id = encodeOperationId(accountId, childOp.hash, type);
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
id,
|
|
185
|
+
hash: childOp.hash,
|
|
186
|
+
type,
|
|
187
|
+
value: new BigNumber(0),
|
|
188
|
+
fee: new BigNumber(0),
|
|
189
|
+
senders: [],
|
|
190
|
+
recipients: [],
|
|
191
|
+
blockHeight: childOp.blockHeight,
|
|
192
|
+
blockHash: childOp.blockHash,
|
|
193
|
+
transactionSequenceNumber: childOp.transactionSequenceNumber,
|
|
194
|
+
subOperations: [],
|
|
195
|
+
nftOperations: [],
|
|
196
|
+
accountId: "",
|
|
197
|
+
date: childOp.date,
|
|
198
|
+
extra: {},
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// Create a Map of hash => operation
|
|
203
|
+
const coinOperationsByHash: Record<string, OperationWithRequiredChildren[]> = {};
|
|
204
|
+
coinOperations.forEach(op => {
|
|
205
|
+
if (!coinOperationsByHash[op.hash]) {
|
|
206
|
+
coinOperationsByHash[op.hash] = [];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Adding arrays just in case but this is defined
|
|
210
|
+
// by the adapters so it should never be needed
|
|
211
|
+
op.subOperations = [];
|
|
212
|
+
op.nftOperations = [];
|
|
213
|
+
coinOperationsByHash[op.hash].push(op as OperationWithRequiredChildren);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// Looping through token operations to potentially copy them as a child operation of a coin operation
|
|
217
|
+
for (const tokenOperation of tokenOperations) {
|
|
218
|
+
let mainOperations = coinOperationsByHash[tokenOperation.hash];
|
|
219
|
+
if (!mainOperations?.length) {
|
|
220
|
+
const noneOperation = makeCoinOpForOrphanChildOp(tokenOperation);
|
|
221
|
+
mainOperations = [noneOperation];
|
|
222
|
+
coinOperations.push(noneOperation);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Ugly loop in loop but in theory, this can only be a 2 elements array maximum in the case of a self send
|
|
226
|
+
for (const mainOperation of mainOperations) {
|
|
227
|
+
mainOperation.subOperations.push(tokenOperation);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Looping through nft operations to potentially copy them as a child operation of a coin operation
|
|
232
|
+
for (const nftOperation of nftOperations) {
|
|
233
|
+
let mainOperations = coinOperationsByHash[nftOperation.hash];
|
|
234
|
+
if (!mainOperations?.length) {
|
|
235
|
+
const noneOperation = makeCoinOpForOrphanChildOp(nftOperation);
|
|
236
|
+
mainOperations = [noneOperation];
|
|
237
|
+
coinOperations.push(noneOperation);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Ugly loop in loop but in theory, this can only be a 2 elements array maximum in the case of a self send
|
|
241
|
+
for (const mainOperation of mainOperations) {
|
|
242
|
+
mainOperation.nftOperations.push(nftOperation);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return coinOperations;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Type guard for NFT transactions
|
|
251
|
+
*/
|
|
252
|
+
export const isNftTransaction = (
|
|
253
|
+
transaction: EvmTransaction,
|
|
254
|
+
): transaction is EvmTransaction & EvmNftTransaction =>
|
|
255
|
+
["erc1155", "erc721"].includes(transaction.mode);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CurrencyBridge,
|
|
3
|
+
NFTCollectionMetadataResponse,
|
|
4
|
+
NFTMetadataResponse,
|
|
5
|
+
} from "@ledgerhq/types-live";
|
|
6
|
+
import { isNFTActive, metadataCallBatcher } from "@ledgerhq/coin-framework/nft/support";
|
|
7
|
+
import { getCryptoCurrencyById } from "@ledgerhq/coin-framework/currencies/index";
|
|
8
|
+
import NftApi from "./api/nft";
|
|
9
|
+
|
|
10
|
+
type NftResolvers = NonNullable<CurrencyBridge["nftResolvers"]>;
|
|
11
|
+
|
|
12
|
+
export const nftMetadata: NftResolvers["nftMetadata"] = async ({
|
|
13
|
+
contract,
|
|
14
|
+
tokenId,
|
|
15
|
+
currencyId,
|
|
16
|
+
metadata,
|
|
17
|
+
}): Promise<NFTMetadataResponse> => {
|
|
18
|
+
// This is for test/mock purposes
|
|
19
|
+
if (typeof metadata !== "undefined") {
|
|
20
|
+
return {
|
|
21
|
+
status: 200,
|
|
22
|
+
result: {
|
|
23
|
+
contract,
|
|
24
|
+
tokenId,
|
|
25
|
+
...metadata,
|
|
26
|
+
},
|
|
27
|
+
} as NFTMetadataResponse;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const currency = getCryptoCurrencyById(currencyId);
|
|
31
|
+
if (!isNFTActive(currency)) {
|
|
32
|
+
throw new Error("Ethereum Bridge NFT Resolver: Unsupported currency");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const response = await metadataCallBatcher(currency, NftApi).loadNft({
|
|
36
|
+
contract,
|
|
37
|
+
tokenId,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return response;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const collectionMetadata: NftResolvers["collectionMetadata"] = async ({
|
|
44
|
+
contract,
|
|
45
|
+
currencyId,
|
|
46
|
+
metadata,
|
|
47
|
+
}): Promise<NFTCollectionMetadataResponse> => {
|
|
48
|
+
// This is for test/mock purposes
|
|
49
|
+
if (typeof metadata !== "undefined") {
|
|
50
|
+
return {
|
|
51
|
+
status: 200,
|
|
52
|
+
result: {
|
|
53
|
+
contract,
|
|
54
|
+
...metadata,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const currency = getCryptoCurrencyById(currencyId);
|
|
60
|
+
if (!isNFTActive(currency)) {
|
|
61
|
+
throw new Error("Ethereum Bridge NFT Resolver: Unsupported currency");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const response = await metadataCallBatcher(currency, NftApi).loadCollection({
|
|
65
|
+
contract,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return response;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default { nftMetadata, collectionMetadata };
|
package/src/preload.ts
CHANGED
|
@@ -23,8 +23,9 @@ export const fetchERC20Tokens: (
|
|
|
23
23
|
});
|
|
24
24
|
if (dynamicTokens) return dynamicTokens;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const tokens = tokensByChainId[
|
|
27
|
+
ethereumLikeInfo?.chainId as keyof typeof tokensByChainId
|
|
28
|
+
] as ERC20Token[];
|
|
28
29
|
if (tokens) return tokens;
|
|
29
30
|
|
|
30
31
|
log("warning", `EVM Family: No tokens found in CAL for currency: ${currency.id}`, currency);
|
|
@@ -33,7 +34,12 @@ export const fetchERC20Tokens: (
|
|
|
33
34
|
|
|
34
35
|
export async function preload(currency: CryptoCurrency): Promise<ERC20Token[]> {
|
|
35
36
|
const erc20 = await fetchERC20Tokens(currency);
|
|
36
|
-
|
|
37
|
+
// This weird thing is here to help the "clone" currencies like
|
|
38
|
+
// ethereum_as_evm_test_only & polygon_as_evm_test_only
|
|
39
|
+
// to get tokens despite the different currency_id
|
|
40
|
+
// registered in the CAL for those chain ids
|
|
41
|
+
// We should remove this after the merge
|
|
42
|
+
addTokens(erc20.map(([, ...tokenRest]) => convertERC20([currency.id, ...tokenRest])));
|
|
37
43
|
return erc20;
|
|
38
44
|
}
|
|
39
45
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
1
|
+
import { isEqual } from "lodash";
|
|
3
2
|
import BigNumber from "bignumber.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
4
|
+
import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
|
|
5
|
+
import { EvmNftTransaction, Transaction as EvmTransaction } from "./types";
|
|
7
6
|
import { getTransactionData, getTypedTransaction } from "./transaction";
|
|
8
|
-
import {
|
|
7
|
+
import { validateRecipient } from "./getTransactionStatus";
|
|
8
|
+
import { getNftCollectionMetadata } from "./api/nft";
|
|
9
|
+
import { getFeesEstimation, getGasEstimation, getTransactionCount } from "./api/rpc";
|
|
10
|
+
import { getAdditionalLayer2Fees, getEstimatedFees, isNftTransaction } from "./logic";
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Prepare basic coin transactions or smart contract interactions (other than live ERC20 transfers)
|
|
@@ -76,8 +78,9 @@ export const prepareTokenTransaction = async (
|
|
|
76
78
|
): Promise<EvmTransaction> => {
|
|
77
79
|
const [recipientErrors] = validateRecipient(account, typedTransaction);
|
|
78
80
|
const amount = typedTransaction.useAllAmount ? tokenAccount.balance : typedTransaction.amount;
|
|
81
|
+
|
|
79
82
|
const data = !Object.keys(recipientErrors).length
|
|
80
|
-
? getTransactionData({ ...typedTransaction, amount })
|
|
83
|
+
? getTransactionData(account, { ...typedTransaction, amount })
|
|
81
84
|
: undefined;
|
|
82
85
|
// As we're interacting with a smart contract,
|
|
83
86
|
// it's going to be the real recipient for the tx
|
|
@@ -99,6 +102,7 @@ export const prepareTokenTransaction = async (
|
|
|
99
102
|
|
|
100
103
|
// Recipient isn't changed here as it would change on the UI end as well
|
|
101
104
|
// The change will be handled by the `prepareForSignOperation` method
|
|
105
|
+
// right before the device signature by the signOperation step
|
|
102
106
|
return {
|
|
103
107
|
...typedTransaction,
|
|
104
108
|
amount,
|
|
@@ -108,6 +112,61 @@ export const prepareTokenTransaction = async (
|
|
|
108
112
|
};
|
|
109
113
|
};
|
|
110
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Prepare ERC721/ERC1155 transactions.
|
|
117
|
+
* Handling addition of NFT safeTransferFrom data and gas limit
|
|
118
|
+
*/
|
|
119
|
+
export const prepareNftTransaction = async (
|
|
120
|
+
account: Account,
|
|
121
|
+
typedTransaction: EvmNftTransaction & EvmTransaction,
|
|
122
|
+
): Promise<EvmTransaction> => {
|
|
123
|
+
const { currency } = account;
|
|
124
|
+
const [recipientErrors] = validateRecipient(account, typedTransaction);
|
|
125
|
+
|
|
126
|
+
const data = !Object.keys(recipientErrors).length
|
|
127
|
+
? getTransactionData(account, typedTransaction)
|
|
128
|
+
: undefined;
|
|
129
|
+
// As we're interacting with a smart contract,
|
|
130
|
+
// it's going to be the real recipient for the tx
|
|
131
|
+
const gasLimit = data
|
|
132
|
+
? await getGasEstimation(account, {
|
|
133
|
+
...typedTransaction,
|
|
134
|
+
amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
|
|
135
|
+
recipient: typedTransaction.nft.contract, // recipient is then the nft smart contract
|
|
136
|
+
data, // buffer containing the calldata bytecode
|
|
137
|
+
}).catch(() => new BigNumber(0)) // this catch returning 0 should be handled by the `getTransactionStatus` method
|
|
138
|
+
: new BigNumber(0);
|
|
139
|
+
const additionalFees = await getAdditionalLayer2Fees(account.currency, {
|
|
140
|
+
...typedTransaction,
|
|
141
|
+
amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
|
|
142
|
+
recipient: typedTransaction.nft.contract, // recipient is then the token smart contract
|
|
143
|
+
data, // buffer containing the calldata bytecode
|
|
144
|
+
gasLimit,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Providing the collection name to the transaction for the
|
|
148
|
+
// deviceTransactionConfig step (so purely UI)
|
|
149
|
+
const [collectionMetadata] = await getNftCollectionMetadata(
|
|
150
|
+
[{ contract: typedTransaction.nft.contract }],
|
|
151
|
+
currency?.ethereumLikeInfo?.chainId || 0,
|
|
152
|
+
);
|
|
153
|
+
const nft = {
|
|
154
|
+
...typedTransaction.nft,
|
|
155
|
+
collectionName: collectionMetadata.result?.tokenName || "",
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Recipient isn't changed here as it would change on the UI end as well
|
|
159
|
+
// The change will be handled by the `prepareForSignOperation` method
|
|
160
|
+
// right before the device signature by the signOperation step
|
|
161
|
+
return {
|
|
162
|
+
...typedTransaction,
|
|
163
|
+
data,
|
|
164
|
+
gasLimit,
|
|
165
|
+
additionalFees,
|
|
166
|
+
nft,
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
111
170
|
/**
|
|
112
171
|
* Method called to update a transaction into a state that would make it valid
|
|
113
172
|
* (E.g. Adding fees, add smart contract data, etc...)
|
|
@@ -137,12 +196,20 @@ export const prepareTransaction = async (
|
|
|
137
196
|
})();
|
|
138
197
|
|
|
139
198
|
const subAccount = findSubAccountById(account, transaction.subAccountId || "");
|
|
140
|
-
const isTokenTransaction = subAccount?.type === "TokenAccount";
|
|
141
199
|
const typedTransaction = getTypedTransaction(transaction, feeData);
|
|
142
200
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
201
|
+
const newTransaction = await (() => {
|
|
202
|
+
if (isNftTransaction(typedTransaction)) {
|
|
203
|
+
return prepareNftTransaction(account, typedTransaction);
|
|
204
|
+
}
|
|
205
|
+
const isTokenTransaction = subAccount?.type === "TokenAccount";
|
|
206
|
+
return isTokenTransaction
|
|
207
|
+
? prepareTokenTransaction(account, subAccount, typedTransaction)
|
|
208
|
+
: prepareCoinTransaction(account, typedTransaction);
|
|
209
|
+
})();
|
|
210
|
+
|
|
211
|
+
// maintaining reference if the transaction hasn't change
|
|
212
|
+
return isEqual(transaction, newTransaction) ? transaction : newTransaction;
|
|
146
213
|
};
|
|
147
214
|
|
|
148
215
|
/**
|
|
@@ -157,19 +224,30 @@ export const prepareForSignOperation = async (
|
|
|
157
224
|
): Promise<EvmTransaction> => {
|
|
158
225
|
const nonce = await getTransactionCount(account.currency, account.freshAddress);
|
|
159
226
|
|
|
160
|
-
|
|
227
|
+
if (isNftTransaction(transaction)) {
|
|
228
|
+
return {
|
|
229
|
+
...transaction,
|
|
230
|
+
amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
|
|
231
|
+
recipient: transaction.nft.contract, // recipient is then the NFT smart contract
|
|
232
|
+
// data as already been added by the `prepareTokenTransaction` method
|
|
233
|
+
nonce,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const subAccount = findSubAccountById(account, transaction.subAccountId ?? "");
|
|
161
238
|
const isTokenTransaction = subAccount?.type === "TokenAccount";
|
|
239
|
+
if (isTokenTransaction) {
|
|
240
|
+
return {
|
|
241
|
+
...transaction,
|
|
242
|
+
amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
|
|
243
|
+
recipient: subAccount.token.contractAddress, // recipient is then the token smart contract
|
|
244
|
+
// data as already been added by the `prepareTokenTransaction` method
|
|
245
|
+
nonce,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
162
248
|
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
recipient: subAccount.token.contractAddress, // recipient is then the token smart contract
|
|
168
|
-
// data as already been added by the `prepareTokenTransaction` method
|
|
169
|
-
nonce,
|
|
170
|
-
}
|
|
171
|
-
: {
|
|
172
|
-
...transaction,
|
|
173
|
-
nonce,
|
|
174
|
-
};
|
|
249
|
+
return {
|
|
250
|
+
...transaction,
|
|
251
|
+
nonce,
|
|
252
|
+
};
|
|
175
253
|
};
|