@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
package/src/signOperation.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { Observable } from "rxjs";
|
|
2
1
|
import {
|
|
3
2
|
Account,
|
|
4
3
|
SignOperationFnSignature,
|
|
5
4
|
SignOperationEvent,
|
|
6
5
|
DeviceId,
|
|
7
6
|
} from "@ledgerhq/types-live";
|
|
7
|
+
import { Observable } from "rxjs";
|
|
8
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
8
9
|
import { ledgerService } from "@ledgerhq/hw-app-eth";
|
|
9
|
-
import { ResolutionConfig } from "@ledgerhq/hw-app-eth/lib/services/types";
|
|
10
10
|
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
11
|
+
import { isNFTActive } from "@ledgerhq/coin-framework/nft/support";
|
|
12
|
+
import { LoadConfig, ResolutionConfig } from "@ledgerhq/hw-app-eth/lib/services/types";
|
|
11
13
|
import { buildOptimisticOperation } from "./buildOptimisticOperation";
|
|
14
|
+
import { EvmAddress, EvmSignature, EvmSigner } from "./signer";
|
|
12
15
|
import { prepareForSignOperation } from "./prepareTransaction";
|
|
13
16
|
import { getSerializedTransaction } from "./transaction";
|
|
14
17
|
import { Transaction } from "./types";
|
|
15
|
-
import { EvmAddress, EvmSignature, EvmSigner } from "./signer";
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Transforms the ECDSA signature paremeter v hexadecimal string received
|
|
@@ -65,12 +67,17 @@ export const buildSignOperation =
|
|
|
65
67
|
const resolutionConfig: ResolutionConfig = {
|
|
66
68
|
externalPlugins: true,
|
|
67
69
|
erc20: true,
|
|
70
|
+
nft: isNFTActive(account.currency),
|
|
68
71
|
domains: transaction.recipientDomain ? [transaction.recipientDomain] : [],
|
|
69
72
|
};
|
|
73
|
+
const loadConfig: LoadConfig = {
|
|
74
|
+
cryptoassetsBaseURL: getEnv("DYNAMIC_CAL_BASE_URL"),
|
|
75
|
+
nftExplorerBaseURL: getEnv("NFT_ETH_METADATA_SERVICE") + "/v1/ethereum",
|
|
76
|
+
};
|
|
70
77
|
// Look for resolutions for external plugins and ERC20
|
|
71
78
|
const resolution = await ledgerService.resolveTransaction(
|
|
72
79
|
serializedTxHexString,
|
|
73
|
-
|
|
80
|
+
loadConfig,
|
|
74
81
|
resolutionConfig,
|
|
75
82
|
);
|
|
76
83
|
|
|
@@ -78,10 +85,15 @@ export const buildSignOperation =
|
|
|
78
85
|
type: "device-signature-requested",
|
|
79
86
|
});
|
|
80
87
|
|
|
81
|
-
const sig = (await signerContext(deviceId, signer =>
|
|
88
|
+
const sig = (await signerContext(deviceId, signer => {
|
|
89
|
+
signer.setLoadConfig(loadConfig);
|
|
82
90
|
// Request signature on the nano
|
|
83
|
-
signer.signTransaction(
|
|
84
|
-
|
|
91
|
+
return signer.signTransaction(
|
|
92
|
+
account.freshAddressPath,
|
|
93
|
+
serializedTxHexString,
|
|
94
|
+
resolution,
|
|
95
|
+
);
|
|
96
|
+
})) as EvmSignature;
|
|
85
97
|
|
|
86
98
|
o.next({ type: "device-signature-granted" }); // Signature is done
|
|
87
99
|
|
|
@@ -90,7 +102,7 @@ export const buildSignOperation =
|
|
|
90
102
|
const signature = await getSerializedTransaction(preparedTransaction, {
|
|
91
103
|
r: "0x" + sig.r,
|
|
92
104
|
s: "0x" + sig.s,
|
|
93
|
-
v: applyEIP155(sig.v, chainId),
|
|
105
|
+
v: applyEIP155(typeof sig.v === "number" ? sig.v.toString(16) : sig.v, chainId),
|
|
94
106
|
});
|
|
95
107
|
|
|
96
108
|
const operation = buildOptimisticOperation(account, {
|
|
@@ -110,6 +122,7 @@ export const buildSignOperation =
|
|
|
110
122
|
|
|
111
123
|
main().then(
|
|
112
124
|
() => o.complete(),
|
|
125
|
+
/* istanbul ignore next: don't test throwing an error */
|
|
113
126
|
e => o.error(e),
|
|
114
127
|
);
|
|
115
128
|
});
|
package/src/signer.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { DomainServiceResolution } from "@ledgerhq/domain-service/types";
|
|
2
|
+
import { EIP712Message } from "@ledgerhq/types-live";
|
|
2
3
|
|
|
3
4
|
export type EvmAddress = {
|
|
4
5
|
publicKey: string;
|
|
5
6
|
address: string;
|
|
6
7
|
chainCode?: string;
|
|
7
8
|
};
|
|
9
|
+
|
|
8
10
|
export type EvmSignature = {
|
|
9
11
|
s: string;
|
|
10
|
-
v: string;
|
|
12
|
+
v: string | number;
|
|
11
13
|
r: string;
|
|
12
14
|
};
|
|
13
15
|
|
|
@@ -25,11 +27,52 @@ type LedgerEthTransactionResolution = {
|
|
|
25
27
|
domains: DomainServiceResolution[];
|
|
26
28
|
};
|
|
27
29
|
|
|
30
|
+
// Duplicate type definition from hw-app-eth.
|
|
31
|
+
type LoadConfig = {
|
|
32
|
+
// Backend service responsible for signed NFT APDUS
|
|
33
|
+
nftExplorerBaseURL?: string | null;
|
|
34
|
+
// example of payload https://cdn.live.ledger.com/plugins/ethereum/1.json
|
|
35
|
+
// fetch against an api (base url is an api that hosts /plugins/ethereum/${chainId}.json )
|
|
36
|
+
// set to null will disable it
|
|
37
|
+
pluginBaseURL?: string | null;
|
|
38
|
+
// provide manually some extra plugins to add for the resolution (e.g. for dev purpose)
|
|
39
|
+
// object will be merged with the returned value of the Ledger cdn payload
|
|
40
|
+
extraPlugins?: any | null;
|
|
41
|
+
cryptoassetsBaseURL?: string | null;
|
|
42
|
+
};
|
|
43
|
+
|
|
28
44
|
export interface EvmSigner {
|
|
45
|
+
setLoadConfig(loadConfig: LoadConfig): void;
|
|
29
46
|
getAddress(path: string, boolDisplay?: boolean, boolChaincode?: boolean): Promise<EvmAddress>;
|
|
30
47
|
signTransaction(
|
|
31
48
|
path: string,
|
|
32
49
|
rawTxHex: string,
|
|
33
50
|
resolution?: LedgerEthTransactionResolution | null,
|
|
34
51
|
): Promise<EvmSignature>;
|
|
52
|
+
signPersonalMessage(
|
|
53
|
+
path: string,
|
|
54
|
+
messageHex: string,
|
|
55
|
+
): Promise<{
|
|
56
|
+
v: number;
|
|
57
|
+
s: string;
|
|
58
|
+
r: string;
|
|
59
|
+
}>;
|
|
60
|
+
signEIP712HashedMessage(
|
|
61
|
+
path: string,
|
|
62
|
+
domainSeparatorHex: string,
|
|
63
|
+
hashStructMessageHex: string,
|
|
64
|
+
): Promise<{
|
|
65
|
+
v: number;
|
|
66
|
+
s: string;
|
|
67
|
+
r: string;
|
|
68
|
+
}>;
|
|
69
|
+
signEIP712Message(
|
|
70
|
+
path: string,
|
|
71
|
+
jsonMessage: EIP712Message,
|
|
72
|
+
fullImplem?: boolean,
|
|
73
|
+
): Promise<{
|
|
74
|
+
v: number;
|
|
75
|
+
s: string;
|
|
76
|
+
r: string;
|
|
77
|
+
}>;
|
|
35
78
|
}
|
package/src/specs.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
/* istanbul ignore file: don't test the test. */
|
|
2
|
+
|
|
1
3
|
import expect from "expect";
|
|
2
4
|
import invariant from "invariant";
|
|
3
5
|
import sample from "lodash/sample";
|
|
4
6
|
import BigNumber from "bignumber.js";
|
|
5
|
-
import { MutationSpec, TransactionDestinationTestInput } from "@ledgerhq/coin-framework/bot/types";
|
|
6
|
-
import { DeviceModelId } from "@ledgerhq/devices";
|
|
7
|
-
import { CryptoCurrencyIds } from "@ledgerhq/types-live";
|
|
8
|
-
import { cryptocurrenciesById } from "@ledgerhq/cryptoassets/currencies";
|
|
9
7
|
import { botTest, genericTestDestination, pickSiblings } from "@ledgerhq/coin-framework/bot/specs";
|
|
8
|
+
import {
|
|
9
|
+
AppSpec,
|
|
10
|
+
MutationSpec,
|
|
11
|
+
TransactionDestinationTestInput,
|
|
12
|
+
} from "@ledgerhq/coin-framework/bot/types";
|
|
13
|
+
import { DeviceModelId } from "@ledgerhq/devices";
|
|
10
14
|
import {
|
|
11
15
|
getCryptoCurrencyById,
|
|
12
16
|
parseCurrencyUnit,
|
|
13
17
|
} from "@ledgerhq/coin-framework/currencies/index";
|
|
18
|
+
import { CryptoCurrencyIds } from "@ledgerhq/types-live";
|
|
19
|
+
import { cryptocurrenciesById } from "@ledgerhq/cryptoassets/currencies";
|
|
14
20
|
import { acceptTransaction } from "./speculos-deviceActions";
|
|
15
21
|
import { Transaction as EvmTransaction } from "./types";
|
|
16
22
|
|
|
@@ -298,8 +304,7 @@ const evmBasicMutations: ({
|
|
|
298
304
|
|
|
299
305
|
export default Object.values(cryptocurrenciesById)
|
|
300
306
|
.filter(currency => currency.family === "evm")
|
|
301
|
-
.reduce((acc, currency) => {
|
|
302
|
-
// @ts-expect-error FIXME: fix typings
|
|
307
|
+
.reduce<Record<CryptoCurrencyIds, AppSpec<EvmTransaction>>>((acc, currency) => {
|
|
303
308
|
acc[currency.id] = {
|
|
304
309
|
name: currency.name,
|
|
305
310
|
currency,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/* istanbul ignore file: not reaching userland - bot only. */
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
deviceActionFlow,
|
|
4
5
|
formatDeviceAmount,
|
|
5
6
|
SpeculosButton,
|
|
6
7
|
} from "@ledgerhq/coin-framework/bot/specs";
|
|
7
8
|
import type { DeviceAction } from "@ledgerhq/coin-framework/bot/types";
|
|
9
|
+
import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
|
|
8
10
|
import type { Transaction } from "./types";
|
|
9
11
|
|
|
10
12
|
// FIXME: fix types
|
package/src/synchronization.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { log } from "@ledgerhq/logs";
|
|
1
2
|
import {
|
|
2
3
|
decodeAccountId,
|
|
4
|
+
decodeTokenAccountId,
|
|
3
5
|
emptyHistoryCache,
|
|
4
6
|
encodeAccountId,
|
|
5
7
|
encodeTokenAccountId,
|
|
@@ -10,15 +12,22 @@ import {
|
|
|
10
12
|
GetAccountShape,
|
|
11
13
|
makeSync,
|
|
12
14
|
mergeOps,
|
|
15
|
+
mergeNfts,
|
|
13
16
|
} from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
14
|
-
import { log } from "@ledgerhq/logs";
|
|
15
|
-
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
16
17
|
import { Account, Operation, SubAccount } from "@ledgerhq/types-live";
|
|
17
|
-
|
|
18
|
+
import { decodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
19
|
+
import { nftsFromOperations } from "@ledgerhq/coin-framework/nft/helpers";
|
|
20
|
+
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
18
21
|
import { getBalanceAndBlock, getBlock, getTokenBalance, getTransaction } from "./api/rpc";
|
|
19
|
-
import { getSyncHash, mergeSubAccounts } from "./logic";
|
|
22
|
+
import { attachOperations, getSyncHash, mergeSubAccounts } from "./logic";
|
|
20
23
|
import { getExplorerApi } from "./api/explorer";
|
|
21
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Number of blocks that are considered "unsafe" due to a potential reorg.
|
|
27
|
+
* Everything older than this number, should be considered immutable.
|
|
28
|
+
*/
|
|
29
|
+
export const SAFE_REORG_THRESHOLD = 80;
|
|
30
|
+
|
|
22
31
|
/**
|
|
23
32
|
* Main synchronization process
|
|
24
33
|
* Get the main Account and the potential TokenAccounts linked to it
|
|
@@ -47,15 +56,17 @@ export const getAccountShape: GetAccountShape = async infos => {
|
|
|
47
56
|
return (acc?.blockHeight || 0) > (curr?.blockHeight || 0) ? acc : curr;
|
|
48
57
|
}, null);
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
const lastCoinOperations = await (async () => {
|
|
59
|
+
const { lastCoinOperations, lastTokenOperations, lastNftOperations } = await (async () => {
|
|
52
60
|
try {
|
|
53
|
-
const {
|
|
54
|
-
return await
|
|
61
|
+
const { getLastOperations } = getExplorerApi(currency);
|
|
62
|
+
return await getLastOperations(
|
|
55
63
|
currency,
|
|
56
64
|
address,
|
|
57
65
|
accountId,
|
|
58
|
-
latestSyncedOperation?.blockHeight
|
|
66
|
+
latestSyncedOperation?.blockHeight
|
|
67
|
+
? Math.max(latestSyncedOperation.blockHeight - SAFE_REORG_THRESHOLD, 0)
|
|
68
|
+
: 0,
|
|
69
|
+
blockHeight,
|
|
59
70
|
);
|
|
60
71
|
} catch (e) {
|
|
61
72
|
log("EVM Family", "Failed to get latest transactions", {
|
|
@@ -67,9 +78,8 @@ export const getAccountShape: GetAccountShape = async infos => {
|
|
|
67
78
|
}
|
|
68
79
|
})();
|
|
69
80
|
|
|
70
|
-
const newSubAccounts = await getSubAccounts(infos, accountId,
|
|
71
|
-
// Merging potential new subAccouns while preserving the
|
|
72
|
-
const subAccounts = mergeSubAccounts(initialAccount, newSubAccounts);
|
|
81
|
+
const newSubAccounts = await getSubAccounts(infos, accountId, lastTokenOperations);
|
|
82
|
+
const subAccounts = mergeSubAccounts(initialAccount, newSubAccounts); // Merging potential new subAccouns while preserving the references
|
|
73
83
|
|
|
74
84
|
// Trying to confirm pending operations that we are sure of
|
|
75
85
|
// because they were made in the live
|
|
@@ -79,9 +89,27 @@ export const getAccountShape: GetAccountShape = async infos => {
|
|
|
79
89
|
const confirmedOperations = await Promise.all(confirmPendingOperations).then(ops =>
|
|
80
90
|
ops.filter((op): op is Operation => !!op),
|
|
81
91
|
);
|
|
82
|
-
|
|
92
|
+
|
|
93
|
+
// Coin operations with children ops like token & nft ops attached to it
|
|
94
|
+
const lastCoinOperationsWithAttachements = attachOperations(
|
|
95
|
+
lastCoinOperations,
|
|
96
|
+
lastTokenOperations,
|
|
97
|
+
lastNftOperations,
|
|
98
|
+
);
|
|
99
|
+
const newOperations = [...confirmedOperations, ...lastCoinOperationsWithAttachements];
|
|
83
100
|
const operations = mergeOps(initialAccount?.operations || [], newOperations);
|
|
84
|
-
const
|
|
101
|
+
const operationsWithPendings = mergeOps(operations, initialAccount?.pendingOperations || []);
|
|
102
|
+
|
|
103
|
+
// Merging potential new nfts while preserving the references.
|
|
104
|
+
//
|
|
105
|
+
// ⚠️ NFTs are aggregated manually to get the account "balance" for each of them.
|
|
106
|
+
// Because of that, we're not creating NFTs in an incremental way,
|
|
107
|
+
// but always creating them based on *all* operations.
|
|
108
|
+
const nfts = mergeNfts(
|
|
109
|
+
initialAccount?.nfts || [],
|
|
110
|
+
// Adding pendings ops to this to temporarly remove an NFT from an account if actively being transfered
|
|
111
|
+
nftsFromOperations(operationsWithPendings),
|
|
112
|
+
).filter(nft => nft.amount.gt(0));
|
|
85
113
|
|
|
86
114
|
return {
|
|
87
115
|
type: "Account",
|
|
@@ -93,7 +121,8 @@ export const getAccountShape: GetAccountShape = async infos => {
|
|
|
93
121
|
operations,
|
|
94
122
|
operationsCount: operations.length,
|
|
95
123
|
subAccounts,
|
|
96
|
-
|
|
124
|
+
nfts,
|
|
125
|
+
lastSyncDate: new Date(),
|
|
97
126
|
} as Partial<Account>;
|
|
98
127
|
};
|
|
99
128
|
|
|
@@ -103,55 +132,26 @@ export const getAccountShape: GetAccountShape = async infos => {
|
|
|
103
132
|
export const getSubAccounts = async (
|
|
104
133
|
infos: AccountShapeInfo,
|
|
105
134
|
accountId: string,
|
|
106
|
-
|
|
135
|
+
lastTokenOperations: Operation[],
|
|
107
136
|
): Promise<Partial<SubAccount>[]> => {
|
|
108
|
-
const {
|
|
109
|
-
|
|
110
|
-
// Get the latest operation from all subaccounts
|
|
111
|
-
const latestSyncedOperation = shouldSyncFromScratch
|
|
112
|
-
? null
|
|
113
|
-
: initialAccount?.subAccounts
|
|
114
|
-
?.flatMap(({ operations }) => operations)
|
|
115
|
-
.reduce<Operation | null>((acc, curr) => {
|
|
116
|
-
if (!acc) {
|
|
117
|
-
return curr;
|
|
118
|
-
}
|
|
119
|
-
return (acc?.blockHeight || 0) > (curr?.blockHeight || 0) ? acc : curr;
|
|
120
|
-
}, null);
|
|
121
|
-
|
|
122
|
-
// This method could not be working if the integration doesn't have an API to retreive the operations
|
|
123
|
-
const lastERC20OperationsAndCurrencies = await (async () => {
|
|
124
|
-
try {
|
|
125
|
-
const { getLastTokenOperations } = getExplorerApi(currency);
|
|
126
|
-
return await getLastTokenOperations(
|
|
127
|
-
currency,
|
|
128
|
-
address,
|
|
129
|
-
accountId,
|
|
130
|
-
latestSyncedOperation?.blockHeight || 0,
|
|
131
|
-
);
|
|
132
|
-
} catch (e) {
|
|
133
|
-
log("EVM Family", "Failed to get latest ERC20 transactions", {
|
|
134
|
-
address,
|
|
135
|
-
currency,
|
|
136
|
-
error: e,
|
|
137
|
-
});
|
|
138
|
-
throw e;
|
|
139
|
-
}
|
|
140
|
-
})();
|
|
137
|
+
const { currency } = infos;
|
|
141
138
|
|
|
142
139
|
// Creating a Map of Operations by TokenCurrencies in order to know which TokenAccounts should be synced as well
|
|
143
|
-
const erc20OperationsByToken =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
const erc20OperationsByToken = lastTokenOperations.reduce<Map<TokenCurrency, Operation[]>>(
|
|
141
|
+
(acc, operation) => {
|
|
142
|
+
const { accountId } = decodeOperationId(operation.id);
|
|
143
|
+
const { token } = decodeTokenAccountId(accountId);
|
|
144
|
+
if (!token) return acc;
|
|
147
145
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
if (!acc.has(token)) {
|
|
147
|
+
acc.set(token, []);
|
|
148
|
+
}
|
|
149
|
+
acc.get(token)?.push(operation);
|
|
152
150
|
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
return acc;
|
|
152
|
+
},
|
|
153
|
+
new Map<TokenCurrency, Operation[]>(),
|
|
154
|
+
);
|
|
155
155
|
|
|
156
156
|
// Fetching all TokenAccounts possible and providing already filtered operations
|
|
157
157
|
const subAccountsPromises: Promise<Partial<SubAccount>>[] = [];
|
|
@@ -227,6 +227,20 @@ export const getOperationStatus = async (
|
|
|
227
227
|
blockHash,
|
|
228
228
|
blockHeight,
|
|
229
229
|
date,
|
|
230
|
+
subOperations: op.subOperations?.map(subOp => ({
|
|
231
|
+
...subOp,
|
|
232
|
+
transactionSequenceNumber: nonce,
|
|
233
|
+
blockHash,
|
|
234
|
+
blockHeight,
|
|
235
|
+
date,
|
|
236
|
+
})),
|
|
237
|
+
nftOperations: op.nftOperations?.map(nftOp => ({
|
|
238
|
+
...nftOp,
|
|
239
|
+
transactionSequenceNumber: nonce,
|
|
240
|
+
blockHash,
|
|
241
|
+
blockHeight,
|
|
242
|
+
date,
|
|
243
|
+
})),
|
|
230
244
|
} as Operation;
|
|
231
245
|
} catch (e) {
|
|
232
246
|
return null;
|
package/src/transaction.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
3
4
|
import {
|
|
4
5
|
formatTransactionStatusCommon as formatTransactionStatus,
|
|
5
6
|
fromTransactionCommonRaw,
|
|
@@ -7,11 +8,12 @@ import {
|
|
|
7
8
|
toTransactionCommonRaw,
|
|
8
9
|
toTransactionStatusRawCommon as toTransactionStatusRaw,
|
|
9
10
|
} from "@ledgerhq/coin-framework/transaction/common";
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import { ethers } from "ethers";
|
|
13
|
-
import ERC20ABI from "./abis/erc20.abi.json";
|
|
11
|
+
import { getAccountUnit } from "@ledgerhq/coin-framework/account/index";
|
|
12
|
+
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
|
|
14
13
|
import { transactionToEthersTransaction } from "./adapters";
|
|
14
|
+
import ERC1155ABI from "./abis/erc1155.abi.json";
|
|
15
|
+
import ERC721ABI from "./abis/erc721.abi.json";
|
|
16
|
+
import ERC20ABI from "./abis/erc20.abi.json";
|
|
15
17
|
import type {
|
|
16
18
|
Transaction as EvmTransaction,
|
|
17
19
|
EvmTransactionEIP1559,
|
|
@@ -22,6 +24,7 @@ import type {
|
|
|
22
24
|
|
|
23
25
|
export const DEFAULT_GAS_LIMIT = new BigNumber(21000);
|
|
24
26
|
|
|
27
|
+
/* istanbul ignore next: don't test CLI text helpers */
|
|
25
28
|
/**
|
|
26
29
|
* Format the transaction for the CLI
|
|
27
30
|
*/
|
|
@@ -78,6 +81,15 @@ export const fromTransactionRaw = (rawTx: EvmTransactionRaw): EvmTransaction =>
|
|
|
78
81
|
tx.additionalFees = new BigNumber(rawTx.additionalFees);
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
if (rawTx.nft) {
|
|
85
|
+
tx.nft = {
|
|
86
|
+
tokenId: rawTx.nft.tokenId,
|
|
87
|
+
contract: rawTx.nft.contract,
|
|
88
|
+
quantity: new BigNumber(rawTx.nft.quantity),
|
|
89
|
+
collectionName: rawTx.nft.collectionName,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
81
93
|
return tx as EvmTransaction;
|
|
82
94
|
};
|
|
83
95
|
|
|
@@ -117,6 +129,15 @@ export const toTransactionRaw = (tx: EvmTransaction): EvmTransactionRaw => {
|
|
|
117
129
|
txRaw.additionalFees = tx.additionalFees.toFixed();
|
|
118
130
|
}
|
|
119
131
|
|
|
132
|
+
if (tx.nft) {
|
|
133
|
+
txRaw.nft = {
|
|
134
|
+
tokenId: tx.nft.tokenId,
|
|
135
|
+
contract: tx.nft.contract,
|
|
136
|
+
quantity: tx.nft.quantity.toFixed(),
|
|
137
|
+
collectionName: tx.nft.collectionName,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
120
141
|
return txRaw as EvmTransactionRaw;
|
|
121
142
|
};
|
|
122
143
|
|
|
@@ -124,14 +145,47 @@ export const toTransactionRaw = (tx: EvmTransaction): EvmTransactionRaw => {
|
|
|
124
145
|
* Returns the data necessary to execute smart contracts.
|
|
125
146
|
* As of now, only used to create ERC20 transfers' data
|
|
126
147
|
*/
|
|
127
|
-
export const getTransactionData = (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
148
|
+
export const getTransactionData = (
|
|
149
|
+
account: Account,
|
|
150
|
+
transaction: EvmTransaction,
|
|
151
|
+
): Buffer | undefined => {
|
|
152
|
+
switch (transaction.mode) {
|
|
153
|
+
case "send": {
|
|
154
|
+
const contract = new ethers.utils.Interface(ERC20ABI);
|
|
155
|
+
const data = contract.encodeFunctionData("transfer", [
|
|
156
|
+
transaction.recipient,
|
|
157
|
+
transaction.amount.toFixed(),
|
|
158
|
+
]);
|
|
159
|
+
|
|
160
|
+
// removing 0x prefix
|
|
161
|
+
return Buffer.from(data.slice(2), "hex");
|
|
162
|
+
}
|
|
163
|
+
case "erc721": {
|
|
164
|
+
const contract = new ethers.utils.Interface(ERC721ABI);
|
|
165
|
+
const data = contract.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)", [
|
|
166
|
+
account.freshAddress,
|
|
167
|
+
transaction.recipient,
|
|
168
|
+
transaction.nft.tokenId,
|
|
169
|
+
"0x",
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
// removing 0x prefix
|
|
173
|
+
return Buffer.from(data.slice(2), "hex");
|
|
174
|
+
}
|
|
175
|
+
case "erc1155": {
|
|
176
|
+
const contract = new ethers.utils.Interface(ERC1155ABI);
|
|
177
|
+
const data = contract.encodeFunctionData("safeTransferFrom", [
|
|
178
|
+
account.freshAddress,
|
|
179
|
+
transaction.recipient,
|
|
180
|
+
transaction.nft.tokenId,
|
|
181
|
+
transaction.nft.quantity.isFinite() ? transaction.nft.quantity.toFixed() : 0,
|
|
182
|
+
"0x",
|
|
183
|
+
]);
|
|
184
|
+
|
|
185
|
+
// removing 0x prefix
|
|
186
|
+
return Buffer.from(data.slice(2), "hex");
|
|
187
|
+
}
|
|
188
|
+
}
|
|
135
189
|
};
|
|
136
190
|
|
|
137
191
|
/**
|
|
@@ -185,5 +239,4 @@ export default {
|
|
|
185
239
|
toTransactionStatusRaw,
|
|
186
240
|
formatTransactionStatus,
|
|
187
241
|
fromTransactionStatusRaw,
|
|
188
|
-
getSerializedTransaction,
|
|
189
242
|
};
|