@ledgerhq/coin-evm 0.2.1 → 0.2.2-nightly.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/.eslintrc.js +11 -46
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +29 -1
- package/lib/__tests__/adapters.unit.test.d.ts +2 -0
- package/lib/__tests__/adapters.unit.test.d.ts.map +1 -0
- package/lib/__tests__/adapters.unit.test.js +455 -0
- package/lib/__tests__/adapters.unit.test.js.map +1 -0
- package/lib/__tests__/broadcast.unit.test.d.ts +2 -0
- package/lib/__tests__/broadcast.unit.test.d.ts.map +1 -0
- package/lib/__tests__/broadcast.unit.test.js +181 -0
- package/lib/__tests__/broadcast.unit.test.js.map +1 -0
- package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts +2 -0
- package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts.map +1 -0
- package/lib/__tests__/buildOptimisticOperation.unit.test.js +166 -0
- package/lib/__tests__/buildOptimisticOperation.unit.test.js.map +1 -0
- package/lib/__tests__/createTransaction.unit.test.d.ts +2 -0
- package/lib/__tests__/createTransaction.unit.test.d.ts.map +1 -0
- package/lib/__tests__/createTransaction.unit.test.js +50 -0
- package/lib/__tests__/createTransaction.unit.test.js.map +1 -0
- package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts +2 -0
- package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts.map +1 -0
- package/lib/__tests__/deviceTransactionConfig.unit.test.js +231 -0
- package/lib/__tests__/deviceTransactionConfig.unit.test.js.map +1 -0
- package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts +2 -0
- package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts.map +1 -0
- package/lib/__tests__/estimateMaxSpendable.unit.test.js +145 -0
- package/lib/__tests__/estimateMaxSpendable.unit.test.js.map +1 -0
- package/lib/__tests__/gasTracker/index.unit.test.d.ts +2 -0
- package/lib/__tests__/gasTracker/index.unit.test.d.ts.map +1 -0
- package/lib/__tests__/gasTracker/index.unit.test.js +35 -0
- package/lib/__tests__/gasTracker/index.unit.test.js.map +1 -0
- package/lib/__tests__/gasTracker/ledger.unit.test.d.ts +2 -0
- package/lib/__tests__/gasTracker/ledger.unit.test.d.ts.map +1 -0
- package/lib/__tests__/gasTracker/ledger.unit.test.js +110 -0
- package/lib/__tests__/gasTracker/ledger.unit.test.js.map +1 -0
- package/lib/__tests__/getTransactionStatus.unit.test.d.ts +2 -0
- package/lib/__tests__/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib/__tests__/getTransactionStatus.unit.test.js +216 -0
- package/lib/__tests__/getTransactionStatus.unit.test.js.map +1 -0
- package/lib/__tests__/hw-getAddress.unit.test.d.ts +2 -0
- package/lib/__tests__/hw-getAddress.unit.test.d.ts.map +1 -0
- package/lib/__tests__/hw-getAddress.unit.test.js +47 -0
- package/lib/__tests__/hw-getAddress.unit.test.js.map +1 -0
- package/lib/__tests__/logic.unit.test.d.ts +2 -0
- package/lib/__tests__/logic.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic.unit.test.js +296 -0
- package/lib/__tests__/logic.unit.test.js.map +1 -0
- package/lib/__tests__/preload.unit.test.d.ts +2 -0
- package/lib/__tests__/preload.unit.test.d.ts.map +1 -0
- package/lib/__tests__/preload.unit.test.js +149 -0
- package/lib/__tests__/preload.unit.test.js.map +1 -0
- package/lib/__tests__/prepareTransaction.unit.test.d.ts +2 -0
- package/lib/__tests__/prepareTransaction.unit.test.d.ts.map +1 -0
- package/lib/__tests__/prepareTransaction.unit.test.js +248 -0
- package/lib/__tests__/prepareTransaction.unit.test.js.map +1 -0
- package/lib/__tests__/rpc.unit.test.d.ts +2 -0
- package/lib/__tests__/rpc.unit.test.d.ts.map +1 -0
- package/lib/__tests__/rpc.unit.test.js +444 -0
- package/lib/__tests__/rpc.unit.test.js.map +1 -0
- package/lib/__tests__/signOperation.unit.test.d.ts +2 -0
- package/lib/__tests__/signOperation.unit.test.d.ts.map +1 -0
- package/lib/__tests__/signOperation.unit.test.js +160 -0
- package/lib/__tests__/signOperation.unit.test.js.map +1 -0
- package/lib/__tests__/synchronization.unit.test.d.ts +2 -0
- package/lib/__tests__/synchronization.unit.test.d.ts.map +1 -0
- package/lib/__tests__/synchronization.unit.test.js +499 -0
- package/lib/__tests__/synchronization.unit.test.js.map +1 -0
- package/lib/__tests__/transaction.unit.test.d.ts +2 -0
- package/lib/__tests__/transaction.unit.test.d.ts.map +1 -0
- package/lib/__tests__/transaction.unit.test.js +201 -0
- package/lib/__tests__/transaction.unit.test.js.map +1 -0
- package/lib/abis/erc20.abi.json +222 -0
- package/lib/abis/optimismGasPriceOracle.abi.json +252 -0
- package/lib/adapters.d.ts +21 -0
- package/lib/adapters.d.ts.map +1 -0
- package/lib/adapters.js +118 -0
- package/lib/adapters.js.map +1 -0
- package/lib/api/explorer/etherscan.d.ts +24 -0
- package/lib/api/explorer/etherscan.d.ts.map +1 -0
- package/lib/api/explorer/etherscan.js +90 -0
- package/lib/api/explorer/etherscan.js.map +1 -0
- package/lib/api/explorer/index.d.ts +26 -0
- package/lib/api/explorer/index.d.ts.map +1 -0
- package/lib/api/explorer/index.js +23 -0
- package/lib/api/explorer/index.js.map +1 -0
- package/lib/api/gasTracker/index.d.ts +13 -0
- package/lib/api/gasTracker/index.d.ts.map +1 -0
- package/lib/api/gasTracker/index.js +21 -0
- package/lib/api/gasTracker/index.js.map +1 -0
- package/lib/api/gasTracker/ledger.d.ts +9 -0
- package/lib/api/gasTracker/ledger.d.ts.map +1 -0
- package/lib/api/gasTracker/ledger.js +90 -0
- package/lib/api/gasTracker/ledger.js.map +1 -0
- package/lib/api/rpc/index.d.ts +3 -0
- package/lib/api/rpc/index.d.ts.map +1 -0
- package/lib/api/rpc/index.js +32 -0
- package/lib/api/rpc/index.js.map +1 -0
- package/lib/api/rpc/rpc.common.d.ts +93 -0
- package/lib/api/rpc/rpc.common.d.ts.map +1 -0
- package/lib/api/rpc/rpc.common.js +284 -0
- package/lib/api/rpc/rpc.common.js.map +1 -0
- package/lib/api/rpc/rpc.native.d.ts +6 -0
- package/lib/api/rpc/rpc.native.d.ts.map +1 -0
- package/lib/api/rpc/rpc.native.js +35 -0
- package/lib/api/rpc/rpc.native.js.map +1 -0
- package/lib/bridge/js.d.ts +11 -0
- package/lib/bridge/js.d.ts.map +1 -0
- package/lib/bridge/js.js +58 -0
- package/lib/bridge/js.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +14 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +85 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/broadcast.d.ts +8 -0
- package/lib/broadcast.d.ts.map +1 -0
- package/lib/broadcast.js +25 -0
- package/lib/broadcast.js.map +1 -0
- package/lib/buildOptimisticOperation.d.ts +16 -0
- package/lib/buildOptimisticOperation.d.ts.map +1 -0
- package/lib/buildOptimisticOperation.js +80 -0
- package/lib/buildOptimisticOperation.js.map +1 -0
- package/lib/cli-transaction.d.ts +2 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +9 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/createTransaction.d.ts +9 -0
- package/lib/createTransaction.d.ts.map +1 -0
- package/lib/createTransaction.js +32 -0
- package/lib/createTransaction.js.map +1 -0
- package/lib/datasets/ethereum.scanAccounts.1.d.ts +7 -0
- package/lib/datasets/ethereum.scanAccounts.1.d.ts.map +1 -0
- package/lib/datasets/ethereum.scanAccounts.1.js +51 -0
- package/lib/datasets/ethereum.scanAccounts.1.js.map +1 -0
- package/lib/datasets/ethereum1.d.ts +3 -0
- package/lib/datasets/ethereum1.d.ts.map +1 -0
- package/lib/datasets/ethereum1.js +22 -0
- package/lib/datasets/ethereum1.js.map +1 -0
- package/lib/datasets/ethereum2.d.ts +3 -0
- package/lib/datasets/ethereum2.d.ts.map +1 -0
- package/lib/datasets/ethereum2.js +22 -0
- package/lib/datasets/ethereum2.js.map +1 -0
- package/lib/datasets/ethereum_classic.d.ts +5 -0
- package/lib/datasets/ethereum_classic.d.ts.map +1 -0
- package/lib/datasets/ethereum_classic.js +69 -0
- package/lib/datasets/ethereum_classic.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +15 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +44 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +16 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +11 -0
- package/lib/errors.js.map +1 -0
- package/lib/estimateMaxSpendable.d.ts +4 -0
- package/lib/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/estimateMaxSpendable.js +23 -0
- package/lib/estimateMaxSpendable.js.map +1 -0
- package/lib/getTransactionStatus.d.ts +23 -0
- package/lib/getTransactionStatus.d.ts.map +1 -0
- package/lib/getTransactionStatus.js +132 -0
- package/lib/getTransactionStatus.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +28 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/logic.d.ts +31 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +131 -0
- package/lib/logic.js.map +1 -0
- package/lib/preload.d.ts +6 -0
- package/lib/preload.d.ts.map +1 -0
- package/lib/preload.js +58 -0
- package/lib/preload.js.map +1 -0
- package/lib/prepareTransaction.d.ts +26 -0
- package/lib/prepareTransaction.d.ts.map +1 -0
- package/lib/prepareTransaction.js +128 -0
- package/lib/prepareTransaction.js.map +1 -0
- package/lib/signOperation.d.ts +18 -0
- package/lib/signOperation.d.ts.map +1 -0
- package/lib/signOperation.js +88 -0
- package/lib/signOperation.js.map +1 -0
- package/lib/signer.d.ts +27 -0
- package/lib/signer.d.ts.map +1 -0
- package/lib/signer.js +3 -0
- package/lib/signer.js.map +1 -0
- package/lib/specs.d.ts +3 -0
- package/lib/specs.d.ts.map +1 -0
- package/lib/specs.js +238 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +8 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +66 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/synchronization.d.ts +27 -0
- package/lib/synchronization.d.ts.map +1 -0
- package/lib/synchronization.js +220 -0
- package/lib/synchronization.js.map +1 -0
- package/lib/testUtils.d.ts +6 -0
- package/lib/testUtils.d.ts.map +1 -0
- package/lib/testUtils.js +111 -0
- package/lib/testUtils.js.map +1 -0
- package/lib/transaction.d.ts +43 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +124 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types.d.ts +111 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib-es/__tests__/adapters.unit.test.d.ts +2 -0
- package/lib-es/__tests__/adapters.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/adapters.unit.test.js +450 -0
- package/lib-es/__tests__/adapters.unit.test.js.map +1 -0
- package/lib-es/__tests__/broadcast.unit.test.d.ts +2 -0
- package/lib-es/__tests__/broadcast.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/broadcast.unit.test.js +153 -0
- package/lib-es/__tests__/broadcast.unit.test.js.map +1 -0
- package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts +2 -0
- package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/buildOptimisticOperation.unit.test.js +161 -0
- package/lib-es/__tests__/buildOptimisticOperation.unit.test.js.map +1 -0
- package/lib-es/__tests__/createTransaction.unit.test.d.ts +2 -0
- package/lib-es/__tests__/createTransaction.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/createTransaction.unit.test.js +45 -0
- package/lib-es/__tests__/createTransaction.unit.test.js.map +1 -0
- package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts +2 -0
- package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/deviceTransactionConfig.unit.test.js +226 -0
- package/lib-es/__tests__/deviceTransactionConfig.unit.test.js.map +1 -0
- package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts +2 -0
- package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/estimateMaxSpendable.unit.test.js +117 -0
- package/lib-es/__tests__/estimateMaxSpendable.unit.test.js.map +1 -0
- package/lib-es/__tests__/gasTracker/index.unit.test.d.ts +2 -0
- package/lib-es/__tests__/gasTracker/index.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/gasTracker/index.unit.test.js +33 -0
- package/lib-es/__tests__/gasTracker/index.unit.test.js.map +1 -0
- package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts +2 -0
- package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/gasTracker/ledger.unit.test.js +105 -0
- package/lib-es/__tests__/gasTracker/ledger.unit.test.js.map +1 -0
- package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts +2 -0
- package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/getTransactionStatus.unit.test.js +211 -0
- package/lib-es/__tests__/getTransactionStatus.unit.test.js.map +1 -0
- package/lib-es/__tests__/hw-getAddress.unit.test.d.ts +2 -0
- package/lib-es/__tests__/hw-getAddress.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/hw-getAddress.unit.test.js +42 -0
- package/lib-es/__tests__/hw-getAddress.unit.test.js.map +1 -0
- package/lib-es/__tests__/logic.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic.unit.test.js +268 -0
- package/lib-es/__tests__/logic.unit.test.js.map +1 -0
- package/lib-es/__tests__/preload.unit.test.d.ts +2 -0
- package/lib-es/__tests__/preload.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/preload.unit.test.js +121 -0
- package/lib-es/__tests__/preload.unit.test.js.map +1 -0
- package/lib-es/__tests__/prepareTransaction.unit.test.d.ts +2 -0
- package/lib-es/__tests__/prepareTransaction.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/prepareTransaction.unit.test.js +220 -0
- package/lib-es/__tests__/prepareTransaction.unit.test.js.map +1 -0
- package/lib-es/__tests__/rpc.unit.test.d.ts +2 -0
- package/lib-es/__tests__/rpc.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/rpc.unit.test.js +416 -0
- package/lib-es/__tests__/rpc.unit.test.js.map +1 -0
- package/lib-es/__tests__/signOperation.unit.test.d.ts +2 -0
- package/lib-es/__tests__/signOperation.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/signOperation.unit.test.js +132 -0
- package/lib-es/__tests__/signOperation.unit.test.js.map +1 -0
- package/lib-es/__tests__/synchronization.unit.test.d.ts +2 -0
- package/lib-es/__tests__/synchronization.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/synchronization.unit.test.js +471 -0
- package/lib-es/__tests__/synchronization.unit.test.js.map +1 -0
- package/lib-es/__tests__/transaction.unit.test.d.ts +2 -0
- package/lib-es/__tests__/transaction.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/transaction.unit.test.js +173 -0
- package/lib-es/__tests__/transaction.unit.test.js.map +1 -0
- package/lib-es/abis/erc20.abi.json +222 -0
- package/lib-es/abis/optimismGasPriceOracle.abi.json +252 -0
- package/lib-es/adapters.d.ts +21 -0
- package/lib-es/adapters.d.ts.map +1 -0
- package/lib-es/adapters.js +109 -0
- package/lib-es/adapters.js.map +1 -0
- package/lib-es/api/explorer/etherscan.d.ts +24 -0
- package/lib-es/api/explorer/etherscan.d.ts.map +1 -0
- package/lib-es/api/explorer/etherscan.js +84 -0
- package/lib-es/api/explorer/etherscan.js.map +1 -0
- package/lib-es/api/explorer/index.d.ts +26 -0
- package/lib-es/api/explorer/index.d.ts.map +1 -0
- package/lib-es/api/explorer/index.js +16 -0
- package/lib-es/api/explorer/index.js.map +1 -0
- package/lib-es/api/gasTracker/index.d.ts +13 -0
- package/lib-es/api/gasTracker/index.d.ts.map +1 -0
- package/lib-es/api/gasTracker/index.js +17 -0
- package/lib-es/api/gasTracker/index.js.map +1 -0
- package/lib-es/api/gasTracker/ledger.d.ts +9 -0
- package/lib-es/api/gasTracker/ledger.d.ts.map +1 -0
- package/lib-es/api/gasTracker/ledger.js +83 -0
- package/lib-es/api/gasTracker/ledger.js.map +1 -0
- package/lib-es/api/rpc/index.d.ts +3 -0
- package/lib-es/api/rpc/index.d.ts.map +1 -0
- package/lib-es/api/rpc/index.js +4 -0
- package/lib-es/api/rpc/index.js.map +1 -0
- package/lib-es/api/rpc/rpc.common.d.ts +93 -0
- package/lib-es/api/rpc/rpc.common.d.ts.map +1 -0
- package/lib-es/api/rpc/rpc.common.js +267 -0
- package/lib-es/api/rpc/rpc.common.js.map +1 -0
- package/lib-es/api/rpc/rpc.native.d.ts +6 -0
- package/lib-es/api/rpc/rpc.native.d.ts.map +1 -0
- package/lib-es/api/rpc/rpc.native.js +7 -0
- package/lib-es/api/rpc/rpc.native.js.map +1 -0
- package/lib-es/bridge/js.d.ts +11 -0
- package/lib-es/bridge/js.d.ts.map +1 -0
- package/lib-es/bridge/js.js +49 -0
- package/lib-es/bridge/js.js.map +1 -0
- package/lib-es/bridge.integration.test.d.ts +14 -0
- package/lib-es/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge.integration.test.js +79 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/broadcast.d.ts +8 -0
- package/lib-es/broadcast.d.ts.map +1 -0
- package/lib-es/broadcast.js +21 -0
- package/lib-es/broadcast.js.map +1 -0
- package/lib-es/buildOptimisticOperation.d.ts +16 -0
- package/lib-es/buildOptimisticOperation.d.ts.map +1 -0
- package/lib-es/buildOptimisticOperation.js +71 -0
- package/lib-es/buildOptimisticOperation.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +2 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +6 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/createTransaction.d.ts +9 -0
- package/lib-es/createTransaction.d.ts.map +1 -0
- package/lib-es/createTransaction.js +25 -0
- package/lib-es/createTransaction.js.map +1 -0
- package/lib-es/datasets/ethereum.scanAccounts.1.d.ts +7 -0
- package/lib-es/datasets/ethereum.scanAccounts.1.d.ts.map +1 -0
- package/lib-es/datasets/ethereum.scanAccounts.1.js +49 -0
- package/lib-es/datasets/ethereum.scanAccounts.1.js.map +1 -0
- package/lib-es/datasets/ethereum1.d.ts +3 -0
- package/lib-es/datasets/ethereum1.d.ts.map +1 -0
- package/lib-es/datasets/ethereum1.js +19 -0
- package/lib-es/datasets/ethereum1.js.map +1 -0
- package/lib-es/datasets/ethereum2.d.ts +3 -0
- package/lib-es/datasets/ethereum2.d.ts.map +1 -0
- package/lib-es/datasets/ethereum2.js +19 -0
- package/lib-es/datasets/ethereum2.js.map +1 -0
- package/lib-es/datasets/ethereum_classic.d.ts +5 -0
- package/lib-es/datasets/ethereum_classic.d.ts.map +1 -0
- package/lib-es/datasets/ethereum_classic.js +67 -0
- package/lib-es/datasets/ethereum_classic.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +15 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +42 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +16 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +8 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/estimateMaxSpendable.d.ts +4 -0
- package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/estimateMaxSpendable.js +19 -0
- package/lib-es/estimateMaxSpendable.js.map +1 -0
- package/lib-es/getTransactionStatus.d.ts +23 -0
- package/lib-es/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.js +125 -0
- package/lib-es/getTransactionStatus.js.map +1 -0
- package/lib-es/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +23 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/logic.d.ts +31 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +119 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/preload.d.ts +6 -0
- package/lib-es/preload.d.ts.map +1 -0
- package/lib-es/preload.js +49 -0
- package/lib-es/preload.js.map +1 -0
- package/lib-es/prepareTransaction.d.ts +26 -0
- package/lib-es/prepareTransaction.d.ts.map +1 -0
- package/lib-es/prepareTransaction.js +118 -0
- package/lib-es/prepareTransaction.js.map +1 -0
- package/lib-es/signOperation.d.ts +18 -0
- package/lib-es/signOperation.d.ts.map +1 -0
- package/lib-es/signOperation.js +83 -0
- package/lib-es/signOperation.js.map +1 -0
- package/lib-es/signer.d.ts +27 -0
- package/lib-es/signer.d.ts.map +1 -0
- package/lib-es/signer.js +2 -0
- package/lib-es/signer.js.map +1 -0
- package/lib-es/specs.d.ts +3 -0
- package/lib-es/specs.d.ts.map +1 -0
- package/lib-es/specs.js +233 -0
- package/lib-es/specs.js.map +1 -0
- package/lib-es/speculos-deviceActions.d.ts +8 -0
- package/lib-es/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/speculos-deviceActions.js +63 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/synchronization.d.ts +27 -0
- package/lib-es/synchronization.d.ts.map +1 -0
- package/lib-es/synchronization.js +212 -0
- package/lib-es/synchronization.js.map +1 -0
- package/lib-es/testUtils.d.ts +6 -0
- package/lib-es/testUtils.d.ts.map +1 -0
- package/lib-es/testUtils.js +102 -0
- package/lib-es/testUtils.js.map +1 -0
- package/lib-es/transaction.d.ts +43 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +112 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types.d.ts +111 -0
- package/lib-es/types.d.ts.map +1 -0
- package/lib-es/types.js +2 -0
- package/lib-es/types.js.map +1 -0
- package/package.json +8 -23
- package/src/__tests__/adapters.unit.test.ts +22 -52
- package/src/__tests__/broadcast.unit.test.ts +9 -27
- package/src/__tests__/buildOptimisticOperation.unit.test.ts +4 -4
- package/src/__tests__/deviceTransactionConfig.unit.test.ts +7 -7
- package/src/__tests__/estimateMaxSpendable.unit.test.ts +2 -4
- package/src/__tests__/gasTracker/index.unit.test.ts +36 -0
- package/src/__tests__/gasTracker/ledger.unit.test.ts +108 -0
- package/src/__tests__/getTransactionStatus.unit.test.ts +35 -40
- package/src/__tests__/hw-getAddress.unit.test.ts +15 -2
- package/src/__tests__/logic.unit.test.ts +25 -72
- package/src/__tests__/preload.unit.test.ts +3 -9
- package/src/__tests__/prepareTransaction.unit.test.ts +131 -76
- package/src/__tests__/rpc.unit.test.ts +46 -80
- package/src/__tests__/signOperation.unit.test.ts +27 -25
- package/src/__tests__/synchronization.unit.test.ts +101 -153
- package/src/__tests__/transaction.unit.test.ts +6 -14
- package/src/adapters.ts +8 -18
- package/src/api/{etherscan.ts → explorer/etherscan.ts} +14 -29
- package/src/api/explorer/index.ts +34 -0
- package/src/api/gasTracker/index.ts +31 -0
- package/src/api/gasTracker/ledger.ts +103 -0
- package/src/api/{rpc.common.ts → rpc/rpc.common.ts} +41 -64
- package/src/bridge/js.ts +15 -22
- package/src/bridge.integration.test.ts +3 -10
- package/src/broadcast.ts +3 -7
- package/src/buildOptimisticOperation.ts +7 -17
- package/src/cli-transaction.ts +1 -7
- package/src/createTransaction.ts +14 -15
- package/src/deviceTransactionConfig.ts +1 -1
- package/src/errors.ts +6 -0
- package/src/estimateMaxSpendable.ts +14 -11
- package/src/getTransactionStatus.ts +41 -52
- package/src/hw-getAddress.ts +18 -19
- package/src/logic.ts +5 -15
- package/src/preload.ts +6 -16
- package/src/prepareTransaction.ts +30 -31
- package/src/signOperation.ts +57 -69
- package/src/signer.ts +35 -0
- package/src/specs.ts +27 -52
- package/src/speculos-deviceActions.ts +56 -65
- package/src/synchronization.ts +21 -60
- package/src/testUtils.ts +5 -19
- package/src/transaction.ts +6 -10
- package/src/types.ts +6 -0
- /package/src/api/{rpc.ts → rpc/index.ts} +0 -0
- /package/src/api/{rpc.native.ts → rpc/rpc.native.ts} +0 -0
|
@@ -18,13 +18,8 @@ import { EvmTransactionEIP1559, EvmTransactionLegacy } from "../types";
|
|
|
18
18
|
|
|
19
19
|
const recipient = "0xe2ca7390e76c5A992749bB622087310d2e63ca29"; // rambo.eth
|
|
20
20
|
const testData = Buffer.from("testBufferString").toString("hex");
|
|
21
|
-
const tokenAccount = makeTokenAccount(
|
|
22
|
-
|
|
23
|
-
getTokenById("ethereum/erc20/usd__coin")
|
|
24
|
-
);
|
|
25
|
-
const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"), [
|
|
26
|
-
tokenAccount,
|
|
27
|
-
]);
|
|
21
|
+
const tokenAccount = makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin"));
|
|
22
|
+
const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"), [tokenAccount]);
|
|
28
23
|
const legacyTx: EvmTransactionLegacy = {
|
|
29
24
|
amount: new BigNumber(100),
|
|
30
25
|
useAllAmount: false,
|
|
@@ -66,7 +61,7 @@ describe("EVM Family", () => {
|
|
|
66
61
|
expect(res.errors).toEqual(
|
|
67
62
|
expect.objectContaining({
|
|
68
63
|
recipient: new RecipientRequired(),
|
|
69
|
-
})
|
|
64
|
+
}),
|
|
70
65
|
);
|
|
71
66
|
});
|
|
72
67
|
|
|
@@ -78,7 +73,7 @@ describe("EVM Family", () => {
|
|
|
78
73
|
recipient: new InvalidAddress("", {
|
|
79
74
|
currency: account.currency,
|
|
80
75
|
}),
|
|
81
|
-
})
|
|
76
|
+
}),
|
|
82
77
|
);
|
|
83
78
|
});
|
|
84
79
|
|
|
@@ -93,7 +88,7 @@ describe("EVM Family", () => {
|
|
|
93
88
|
recipient: new InvalidAddress("", {
|
|
94
89
|
currency: account.currency,
|
|
95
90
|
}),
|
|
96
|
-
})
|
|
91
|
+
}),
|
|
97
92
|
);
|
|
98
93
|
});
|
|
99
94
|
|
|
@@ -103,7 +98,7 @@ describe("EVM Family", () => {
|
|
|
103
98
|
expect(res.warnings).toEqual(
|
|
104
99
|
expect.objectContaining({
|
|
105
100
|
recipient: new ETHAddressNonEIP(),
|
|
106
|
-
})
|
|
101
|
+
}),
|
|
107
102
|
);
|
|
108
103
|
});
|
|
109
104
|
});
|
|
@@ -120,7 +115,7 @@ describe("EVM Family", () => {
|
|
|
120
115
|
expect(res.errors).toEqual(
|
|
121
116
|
expect.objectContaining({
|
|
122
117
|
amount: new AmountRequired(),
|
|
123
|
-
})
|
|
118
|
+
}),
|
|
124
119
|
);
|
|
125
120
|
});
|
|
126
121
|
|
|
@@ -131,7 +126,7 @@ describe("EVM Family", () => {
|
|
|
131
126
|
};
|
|
132
127
|
const res = await getTransactionStatus(
|
|
133
128
|
{ ...account, balance: new BigNumber(10000000) },
|
|
134
|
-
tx
|
|
129
|
+
tx,
|
|
135
130
|
);
|
|
136
131
|
|
|
137
132
|
expect(res.errors).toEqual({});
|
|
@@ -155,7 +150,7 @@ describe("EVM Family", () => {
|
|
|
155
150
|
},
|
|
156
151
|
],
|
|
157
152
|
},
|
|
158
|
-
tx
|
|
153
|
+
tx,
|
|
159
154
|
);
|
|
160
155
|
|
|
161
156
|
expect(res.errors).toEqual({});
|
|
@@ -164,13 +159,13 @@ describe("EVM Family", () => {
|
|
|
164
159
|
it("should detect account not having enough balance for a tx and have an error", async () => {
|
|
165
160
|
const res = await getTransactionStatus(
|
|
166
161
|
{ ...account, balance: new BigNumber(0) },
|
|
167
|
-
eip1559Tx
|
|
162
|
+
eip1559Tx,
|
|
168
163
|
);
|
|
169
164
|
|
|
170
165
|
expect(res.errors).toEqual(
|
|
171
166
|
expect.objectContaining({
|
|
172
167
|
amount: new NotEnoughBalance(),
|
|
173
|
-
})
|
|
168
|
+
}),
|
|
174
169
|
);
|
|
175
170
|
});
|
|
176
171
|
});
|
|
@@ -183,7 +178,7 @@ describe("EVM Family", () => {
|
|
|
183
178
|
expect(res.errors).toEqual(
|
|
184
179
|
expect.objectContaining({
|
|
185
180
|
gasPrice: new FeeNotLoaded(),
|
|
186
|
-
})
|
|
181
|
+
}),
|
|
187
182
|
);
|
|
188
183
|
});
|
|
189
184
|
|
|
@@ -194,7 +189,7 @@ describe("EVM Family", () => {
|
|
|
194
189
|
expect(res.errors).toEqual(
|
|
195
190
|
expect.objectContaining({
|
|
196
191
|
gasPrice: new FeeNotLoaded(),
|
|
197
|
-
})
|
|
192
|
+
}),
|
|
198
193
|
);
|
|
199
194
|
});
|
|
200
195
|
|
|
@@ -205,7 +200,7 @@ describe("EVM Family", () => {
|
|
|
205
200
|
expect(res.errors).toEqual(
|
|
206
201
|
expect.objectContaining({
|
|
207
202
|
gasLimit: new FeeNotLoaded(),
|
|
208
|
-
})
|
|
203
|
+
}),
|
|
209
204
|
);
|
|
210
205
|
});
|
|
211
206
|
|
|
@@ -216,7 +211,7 @@ describe("EVM Family", () => {
|
|
|
216
211
|
expect(res.errors).toEqual(
|
|
217
212
|
expect.objectContaining({
|
|
218
213
|
gasLimit: new FeeNotLoaded(),
|
|
219
|
-
})
|
|
214
|
+
}),
|
|
220
215
|
);
|
|
221
216
|
});
|
|
222
217
|
|
|
@@ -227,29 +222,29 @@ describe("EVM Family", () => {
|
|
|
227
222
|
expect(res.errors).toEqual(
|
|
228
223
|
expect.objectContaining({
|
|
229
224
|
gasLimit: new GasLessThanEstimate(),
|
|
230
|
-
})
|
|
225
|
+
}),
|
|
231
226
|
);
|
|
232
227
|
});
|
|
233
228
|
|
|
234
229
|
it("should detect gas being too high in a 1559 tx for the account balance and have an error", async () => {
|
|
235
230
|
const notEnoughBalanceResponse = await getTransactionStatus(
|
|
236
231
|
{ ...account, balance: new BigNumber(2099999) },
|
|
237
|
-
eip1559Tx
|
|
232
|
+
eip1559Tx,
|
|
238
233
|
);
|
|
239
234
|
const enoughhBalanceResponse = await getTransactionStatus(
|
|
240
235
|
{ ...account, balance: new BigNumber(2100000) },
|
|
241
|
-
eip1559Tx
|
|
236
|
+
eip1559Tx,
|
|
242
237
|
);
|
|
243
238
|
|
|
244
239
|
expect(notEnoughBalanceResponse.errors).toEqual(
|
|
245
240
|
expect.objectContaining({
|
|
246
241
|
gasPrice: new NotEnoughGas(),
|
|
247
|
-
})
|
|
242
|
+
}),
|
|
248
243
|
);
|
|
249
244
|
expect(enoughhBalanceResponse.errors).not.toEqual(
|
|
250
245
|
expect.objectContaining({
|
|
251
246
|
gasPrice: new NotEnoughGas(),
|
|
252
|
-
})
|
|
247
|
+
}),
|
|
253
248
|
);
|
|
254
249
|
});
|
|
255
250
|
|
|
@@ -259,79 +254,79 @@ describe("EVM Family", () => {
|
|
|
259
254
|
{
|
|
260
255
|
...eip1559Tx,
|
|
261
256
|
maxPriorityFeePerGas: new BigNumber(0),
|
|
262
|
-
}
|
|
257
|
+
},
|
|
263
258
|
);
|
|
264
259
|
|
|
265
260
|
expect(res.errors).toEqual(
|
|
266
261
|
expect.objectContaining({
|
|
267
262
|
maxPriorityFee: new PriorityFeeTooLow(),
|
|
268
|
-
})
|
|
263
|
+
}),
|
|
269
264
|
);
|
|
270
265
|
});
|
|
271
266
|
|
|
272
267
|
it("should detect gas being too high in a legacy tx for the account balance and have an error", async () => {
|
|
273
268
|
const notEnoughBalanceResponse = await getTransactionStatus(
|
|
274
269
|
{ ...account, balance: new BigNumber(2099999) },
|
|
275
|
-
legacyTx
|
|
270
|
+
legacyTx,
|
|
276
271
|
);
|
|
277
272
|
const enoughhBalanceResponse = await getTransactionStatus(
|
|
278
273
|
{ ...account, balance: new BigNumber(2100001) },
|
|
279
|
-
legacyTx
|
|
274
|
+
legacyTx,
|
|
280
275
|
);
|
|
281
276
|
|
|
282
277
|
expect(notEnoughBalanceResponse.errors).toEqual(
|
|
283
278
|
expect.objectContaining({
|
|
284
279
|
gasPrice: new NotEnoughGas(),
|
|
285
|
-
})
|
|
280
|
+
}),
|
|
286
281
|
);
|
|
287
282
|
expect(enoughhBalanceResponse.errors).not.toEqual(
|
|
288
283
|
expect.objectContaining({
|
|
289
284
|
gasPrice: new NotEnoughGas(),
|
|
290
|
-
})
|
|
285
|
+
}),
|
|
291
286
|
);
|
|
292
287
|
});
|
|
293
288
|
|
|
294
289
|
it("should not detect gas being too high in a 1559 tx when there is no recipient and have an error", async () => {
|
|
295
290
|
const notEnoughBalanceResponse = await getTransactionStatus(
|
|
296
291
|
{ ...account, balance: new BigNumber(2099999) },
|
|
297
|
-
{ ...eip1559Tx, recipient: "" }
|
|
292
|
+
{ ...eip1559Tx, recipient: "" },
|
|
298
293
|
);
|
|
299
294
|
const enoughhBalanceResponse = await getTransactionStatus(
|
|
300
295
|
{ ...account, balance: new BigNumber(2100000) },
|
|
301
|
-
{ ...eip1559Tx, recipient: "" }
|
|
296
|
+
{ ...eip1559Tx, recipient: "" },
|
|
302
297
|
);
|
|
303
298
|
|
|
304
299
|
expect(notEnoughBalanceResponse.errors).not.toEqual(
|
|
305
300
|
expect.objectContaining({
|
|
306
301
|
gasPrice: new NotEnoughGas(),
|
|
307
|
-
})
|
|
302
|
+
}),
|
|
308
303
|
);
|
|
309
304
|
expect(enoughhBalanceResponse.errors).not.toEqual(
|
|
310
305
|
expect.objectContaining({
|
|
311
306
|
gasPrice: new NotEnoughGas(),
|
|
312
|
-
})
|
|
307
|
+
}),
|
|
313
308
|
);
|
|
314
309
|
});
|
|
315
310
|
|
|
316
311
|
it("should not detect gas being too high in a legacy tx when there is no recipient and have an error", async () => {
|
|
317
312
|
const notEnoughBalanceResponse = await getTransactionStatus(
|
|
318
313
|
{ ...account, balance: new BigNumber(2099999) },
|
|
319
|
-
{ ...legacyTx, recipient: "" }
|
|
314
|
+
{ ...legacyTx, recipient: "" },
|
|
320
315
|
);
|
|
321
316
|
const enoughhBalanceResponse = await getTransactionStatus(
|
|
322
317
|
{ ...account, balance: new BigNumber(2100001) },
|
|
323
|
-
{ ...legacyTx, recipient: "" }
|
|
318
|
+
{ ...legacyTx, recipient: "" },
|
|
324
319
|
);
|
|
325
320
|
|
|
326
321
|
expect(notEnoughBalanceResponse.errors).not.toEqual(
|
|
327
322
|
expect.objectContaining({
|
|
328
323
|
gasPrice: new NotEnoughGas(),
|
|
329
|
-
})
|
|
324
|
+
}),
|
|
330
325
|
);
|
|
331
326
|
expect(enoughhBalanceResponse.errors).not.toEqual(
|
|
332
327
|
expect.objectContaining({
|
|
333
328
|
gasPrice: new NotEnoughGas(),
|
|
334
|
-
})
|
|
329
|
+
}),
|
|
335
330
|
);
|
|
336
331
|
});
|
|
337
332
|
});
|
|
@@ -347,7 +342,7 @@ describe("EVM Family", () => {
|
|
|
347
342
|
estimatedFees: new BigNumber(2100000),
|
|
348
343
|
amount: legacyTx.amount,
|
|
349
344
|
totalSpent: new BigNumber(2100000).plus(legacyTx.amount),
|
|
350
|
-
})
|
|
345
|
+
}),
|
|
351
346
|
);
|
|
352
347
|
});
|
|
353
348
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import eip55 from "eip55";
|
|
2
|
-
import
|
|
2
|
+
import resolver from "../hw-getAddress";
|
|
3
|
+
import { EvmAddress, EvmSignature, EvmSigner } from "../signer";
|
|
3
4
|
|
|
4
5
|
const address = "0xc3f95102D5c8F2c83e49Ce3Acfb905eDfb7f37dE";
|
|
5
6
|
jest.mock(
|
|
@@ -10,12 +11,24 @@ jest.mock(
|
|
|
10
11
|
publicKey: "",
|
|
11
12
|
address: address.toLowerCase(),
|
|
12
13
|
});
|
|
13
|
-
}
|
|
14
|
+
},
|
|
14
15
|
);
|
|
16
|
+
const mockSignerFactory = (
|
|
17
|
+
_: string,
|
|
18
|
+
fn: (signer: EvmSigner) => Promise<EvmAddress | EvmSignature>,
|
|
19
|
+
) =>
|
|
20
|
+
fn({
|
|
21
|
+
getAddress: async () => ({
|
|
22
|
+
publicKey: "",
|
|
23
|
+
address: address.toLowerCase(),
|
|
24
|
+
}),
|
|
25
|
+
signTransaction: jest.fn(),
|
|
26
|
+
});
|
|
15
27
|
|
|
16
28
|
describe("EVM Family", () => {
|
|
17
29
|
describe("hw-getAddress.ts", () => {
|
|
18
30
|
it("should return an eip 55 encoded address", async () => {
|
|
31
|
+
const getAddress = resolver(mockSignerFactory);
|
|
19
32
|
const response = await getAddress({} as any, {} as any);
|
|
20
33
|
expect(response.address).toBe(address);
|
|
21
34
|
expect(eip55.verify(response.address)).toBe(true);
|
|
@@ -2,7 +2,7 @@ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
|
2
2
|
import * as cryptoAssetsTokens from "@ledgerhq/cryptoassets/tokens";
|
|
3
3
|
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
4
|
import BigNumber from "bignumber.js";
|
|
5
|
-
import * as RPC_API from "../api/rpc.common";
|
|
5
|
+
import * as RPC_API from "../api/rpc/rpc.common";
|
|
6
6
|
import {
|
|
7
7
|
eip1559TransactionHasFees,
|
|
8
8
|
getAdditionalLayer2Fees,
|
|
@@ -147,18 +147,14 @@ describe("EVM Family", () => {
|
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
it("should try to get additionalFees for a valid layer 2", async () => {
|
|
150
|
-
const spy = jest
|
|
151
|
-
.spyOn(RPC_API, "getOptimismAdditionalFees")
|
|
152
|
-
.mockImplementation(jest.fn());
|
|
150
|
+
const spy = jest.spyOn(RPC_API, "getOptimismAdditionalFees").mockImplementation(jest.fn());
|
|
153
151
|
|
|
154
152
|
await getAdditionalLayer2Fees(optimism, {} as any);
|
|
155
153
|
expect(spy).toBeCalled();
|
|
156
154
|
});
|
|
157
155
|
|
|
158
156
|
it("should not try to get additionalFees for an invalid layer 2", async () => {
|
|
159
|
-
const spy = jest
|
|
160
|
-
.spyOn(RPC_API, "getOptimismAdditionalFees")
|
|
161
|
-
.mockImplementation(jest.fn());
|
|
157
|
+
const spy = jest.spyOn(RPC_API, "getOptimismAdditionalFees").mockImplementation(jest.fn());
|
|
162
158
|
|
|
163
159
|
await getAdditionalLayer2Fees(ethereum, {} as any);
|
|
164
160
|
expect(spy).not.toBeCalled();
|
|
@@ -168,10 +164,7 @@ describe("EVM Family", () => {
|
|
|
168
164
|
describe("mergeSubAccounts", () => {
|
|
169
165
|
it("should merge 2 different sub accounts", () => {
|
|
170
166
|
const tokenAccount1 = {
|
|
171
|
-
...makeTokenAccount(
|
|
172
|
-
"0xkvn",
|
|
173
|
-
getTokenById("ethereum/erc20/usd__coin")
|
|
174
|
-
),
|
|
167
|
+
...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
|
|
175
168
|
balance: new BigNumber(1),
|
|
176
169
|
operations: [],
|
|
177
170
|
};
|
|
@@ -180,11 +173,7 @@ describe("EVM Family", () => {
|
|
|
180
173
|
balance: new BigNumber(2),
|
|
181
174
|
operations: [],
|
|
182
175
|
};
|
|
183
|
-
const account = makeAccount(
|
|
184
|
-
"0xkvn",
|
|
185
|
-
getCryptoCurrencyById("ethereum"),
|
|
186
|
-
[tokenAccount1]
|
|
187
|
-
);
|
|
176
|
+
const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"), [tokenAccount1]);
|
|
188
177
|
|
|
189
178
|
const newSubAccounts = mergeSubAccounts(account, [tokenAccount2]);
|
|
190
179
|
expect(newSubAccounts).toEqual([tokenAccount1, tokenAccount2]);
|
|
@@ -195,10 +184,7 @@ describe("EVM Family", () => {
|
|
|
195
184
|
|
|
196
185
|
it("should merge 2 different sub accounts and update the first one", () => {
|
|
197
186
|
const tokenAccount1 = {
|
|
198
|
-
...makeTokenAccount(
|
|
199
|
-
"0xkvn",
|
|
200
|
-
getTokenById("ethereum/erc20/usd__coin")
|
|
201
|
-
),
|
|
187
|
+
...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
|
|
202
188
|
balance: new BigNumber(1),
|
|
203
189
|
operations: [],
|
|
204
190
|
};
|
|
@@ -228,16 +214,9 @@ describe("EVM Family", () => {
|
|
|
228
214
|
balance: new BigNumber(2),
|
|
229
215
|
operations: [],
|
|
230
216
|
};
|
|
231
|
-
const account = makeAccount(
|
|
232
|
-
"0xkvn",
|
|
233
|
-
getCryptoCurrencyById("ethereum"),
|
|
234
|
-
[tokenAccount1]
|
|
235
|
-
);
|
|
217
|
+
const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"), [tokenAccount1]);
|
|
236
218
|
|
|
237
|
-
const newSubAccounts = mergeSubAccounts(account, [
|
|
238
|
-
tokenAccount1Bis,
|
|
239
|
-
tokenAccount2,
|
|
240
|
-
]);
|
|
219
|
+
const newSubAccounts = mergeSubAccounts(account, [tokenAccount1Bis, tokenAccount2]);
|
|
241
220
|
expect(newSubAccounts).toEqual([tokenAccount1Bis, tokenAccount2]);
|
|
242
221
|
expect(newSubAccounts).not.toBe(account.subAccounts); // shouldn't mutate original account
|
|
243
222
|
expect(account.subAccounts).toEqual([tokenAccount1]); // shouldn't mutate original account
|
|
@@ -253,10 +232,7 @@ describe("EVM Family", () => {
|
|
|
253
232
|
hash: "0xAgAinAnotHeRH4sh",
|
|
254
233
|
});
|
|
255
234
|
const tokenAccount1 = {
|
|
256
|
-
...makeTokenAccount(
|
|
257
|
-
"0xkvn",
|
|
258
|
-
getTokenById("ethereum/erc20/usd__coin")
|
|
259
|
-
),
|
|
235
|
+
...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
|
|
260
236
|
balance: new BigNumber(1),
|
|
261
237
|
operations: [op1, op2],
|
|
262
238
|
operationsCount: 2,
|
|
@@ -266,31 +242,20 @@ describe("EVM Family", () => {
|
|
|
266
242
|
operations: [op3, op1, op2],
|
|
267
243
|
operationsCount: 3,
|
|
268
244
|
};
|
|
269
|
-
const account = makeAccount(
|
|
270
|
-
"0xkvn",
|
|
271
|
-
getCryptoCurrencyById("ethereum"),
|
|
272
|
-
[tokenAccount1]
|
|
273
|
-
);
|
|
245
|
+
const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"), [tokenAccount1]);
|
|
274
246
|
|
|
275
247
|
const newSubAccounts = mergeSubAccounts(account, [tokenAccount1Bis]);
|
|
276
248
|
expect(newSubAccounts).not.toBe(account.subAccounts); // shouldn't mutate original account
|
|
277
249
|
expect(account.subAccounts).toEqual([tokenAccount1]); // shouldn't mutate original account
|
|
278
250
|
expect(newSubAccounts[0]).not.toBe(account.subAccounts?.[0]); // changing the ref as change happened
|
|
279
|
-
expect(newSubAccounts[0]?.operations?.[1]).toBe(
|
|
280
|
-
|
|
281
|
-
); // keeping the reference for the ops though
|
|
282
|
-
expect(newSubAccounts[0]?.operations?.[2]).toBe(
|
|
283
|
-
account.subAccounts?.[0]?.operations?.[1]
|
|
284
|
-
); // keeping the reference for the ops though
|
|
251
|
+
expect(newSubAccounts[0]?.operations?.[1]).toBe(account.subAccounts?.[0]?.operations?.[0]); // keeping the reference for the ops though
|
|
252
|
+
expect(newSubAccounts[0]?.operations?.[2]).toBe(account.subAccounts?.[0]?.operations?.[1]); // keeping the reference for the ops though
|
|
285
253
|
expect(newSubAccounts).toEqual([tokenAccount1Bis]);
|
|
286
254
|
});
|
|
287
255
|
|
|
288
256
|
it("should return only new sub accounts", () => {
|
|
289
257
|
const tokenAccount = {
|
|
290
|
-
...makeTokenAccount(
|
|
291
|
-
"0xkvn",
|
|
292
|
-
getTokenById("ethereum/erc20/usd__coin")
|
|
293
|
-
),
|
|
258
|
+
...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
|
|
294
259
|
balance: new BigNumber(1),
|
|
295
260
|
};
|
|
296
261
|
const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"));
|
|
@@ -303,17 +268,10 @@ describe("EVM Family", () => {
|
|
|
303
268
|
|
|
304
269
|
it("should dedup sub accounts", () => {
|
|
305
270
|
const tokenAccount = {
|
|
306
|
-
...makeTokenAccount(
|
|
307
|
-
"0xkvn",
|
|
308
|
-
getTokenById("ethereum/erc20/usd__coin")
|
|
309
|
-
),
|
|
271
|
+
...makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin")),
|
|
310
272
|
balance: new BigNumber(1),
|
|
311
273
|
};
|
|
312
|
-
const account = makeAccount(
|
|
313
|
-
"0xkvn",
|
|
314
|
-
getCryptoCurrencyById("ethereum"),
|
|
315
|
-
[tokenAccount]
|
|
316
|
-
);
|
|
274
|
+
const account = makeAccount("0xkvn", getCryptoCurrencyById("ethereum"), [tokenAccount]);
|
|
317
275
|
|
|
318
276
|
const newSubAccounts = mergeSubAccounts(account, [
|
|
319
277
|
tokenAccount,
|
|
@@ -332,9 +290,7 @@ describe("EVM Family", () => {
|
|
|
332
290
|
});
|
|
333
291
|
|
|
334
292
|
it("should provide a valid sha256 hash", () => {
|
|
335
|
-
expect(getSyncHash(currency)).toStrictEqual(
|
|
336
|
-
expect.stringMatching(/^0x[A-Fa-f0-9]{64}$/)
|
|
337
|
-
);
|
|
293
|
+
expect(getSyncHash(currency)).toStrictEqual(expect.stringMatching(/^0x[A-Fa-f0-9]{64}$/));
|
|
338
294
|
});
|
|
339
295
|
|
|
340
296
|
it("should provide a hash not dependent on reference", () => {
|
|
@@ -342,11 +298,9 @@ describe("EVM Family", () => {
|
|
|
342
298
|
.spyOn(cryptoAssetsTokens, "listTokensForCryptoCurrency")
|
|
343
299
|
.mockImplementationOnce((currency): TokenCurrency[] => {
|
|
344
300
|
const { listTokensForCryptoCurrency } = jest.requireActual(
|
|
345
|
-
"@ledgerhq/cryptoassets/tokens"
|
|
346
|
-
);
|
|
347
|
-
return listTokensForCryptoCurrency(currency).map(
|
|
348
|
-
(t: TokenCurrency) => ({ ...t })
|
|
301
|
+
"@ledgerhq/cryptoassets/tokens",
|
|
349
302
|
);
|
|
303
|
+
return listTokensForCryptoCurrency(currency).map((t: TokenCurrency) => ({ ...t }));
|
|
350
304
|
});
|
|
351
305
|
expect(getSyncHash(currency)).toEqual(getSyncHash(currency));
|
|
352
306
|
});
|
|
@@ -354,9 +308,9 @@ describe("EVM Family", () => {
|
|
|
354
308
|
it("should provide a new hash if a token is removed", () => {
|
|
355
309
|
jest
|
|
356
310
|
.spyOn(cryptoAssetsTokens, "listTokensForCryptoCurrency")
|
|
357
|
-
.mockImplementationOnce(
|
|
311
|
+
.mockImplementationOnce(currency => {
|
|
358
312
|
const { listTokensForCryptoCurrency } = jest.requireActual(
|
|
359
|
-
"@ledgerhq/cryptoassets/tokens"
|
|
313
|
+
"@ledgerhq/cryptoassets/tokens",
|
|
360
314
|
);
|
|
361
315
|
const list: TokenCurrency[] = listTokensForCryptoCurrency(currency);
|
|
362
316
|
return list.slice(0, list.length - 2);
|
|
@@ -367,12 +321,11 @@ describe("EVM Family", () => {
|
|
|
367
321
|
it("should provide a new hash if a token is modified", () => {
|
|
368
322
|
jest
|
|
369
323
|
.spyOn(cryptoAssetsTokens, "listTokensForCryptoCurrency")
|
|
370
|
-
.mockImplementationOnce(
|
|
324
|
+
.mockImplementationOnce(currency => {
|
|
371
325
|
const { listTokensForCryptoCurrency } = jest.requireActual(
|
|
372
|
-
"@ledgerhq/cryptoassets/tokens"
|
|
326
|
+
"@ledgerhq/cryptoassets/tokens",
|
|
373
327
|
);
|
|
374
|
-
const [first, ...rest]: TokenCurrency[] =
|
|
375
|
-
listTokensForCryptoCurrency(currency);
|
|
328
|
+
const [first, ...rest]: TokenCurrency[] = listTokensForCryptoCurrency(currency);
|
|
376
329
|
const modifedFirst = { ...first, delisted: !first.delisted };
|
|
377
330
|
return [modifedFirst, ...rest];
|
|
378
331
|
});
|
|
@@ -383,9 +336,9 @@ describe("EVM Family", () => {
|
|
|
383
336
|
it("should provide a new hash if a token is added", () => {
|
|
384
337
|
jest
|
|
385
338
|
.spyOn(cryptoAssetsTokens, "listTokensForCryptoCurrency")
|
|
386
|
-
.mockImplementationOnce(
|
|
339
|
+
.mockImplementationOnce(currency => {
|
|
387
340
|
const { listTokensForCryptoCurrency } = jest.requireActual(
|
|
388
|
-
"@ledgerhq/cryptoassets/tokens"
|
|
341
|
+
"@ledgerhq/cryptoassets/tokens",
|
|
389
342
|
);
|
|
390
343
|
return [
|
|
391
344
|
...listTokensForCryptoCurrency(currency),
|
|
@@ -90,9 +90,7 @@ describe("EVM Family", () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it("should return empty [] if dynamic CAL fails and local CAL fails", async () => {
|
|
93
|
-
jest
|
|
94
|
-
.spyOn(evms, "tokens", "get")
|
|
95
|
-
.mockImplementationOnce(() => ({} as any));
|
|
93
|
+
jest.spyOn(evms, "tokens", "get").mockImplementationOnce(() => ({} as any));
|
|
96
94
|
|
|
97
95
|
const tokens = await fetchERC20Tokens(currency1);
|
|
98
96
|
expect(tokens).toEqual([]);
|
|
@@ -101,9 +99,7 @@ describe("EVM Family", () => {
|
|
|
101
99
|
|
|
102
100
|
describe("preload", () => {
|
|
103
101
|
it("should register tokens", async () => {
|
|
104
|
-
jest
|
|
105
|
-
.spyOn(CALTokensAPI, "addTokens")
|
|
106
|
-
.mockImplementationOnce(() => null);
|
|
102
|
+
jest.spyOn(CALTokensAPI, "addTokens").mockImplementationOnce(() => null);
|
|
107
103
|
|
|
108
104
|
const tokens = await preload(currency1);
|
|
109
105
|
|
|
@@ -124,9 +120,7 @@ describe("EVM Family", () => {
|
|
|
124
120
|
});
|
|
125
121
|
|
|
126
122
|
it("should register tokens", async () => {
|
|
127
|
-
jest
|
|
128
|
-
.spyOn(CALTokensAPI, "addTokens")
|
|
129
|
-
.mockImplementationOnce(() => null);
|
|
123
|
+
jest.spyOn(CALTokensAPI, "addTokens").mockImplementationOnce(() => null);
|
|
130
124
|
|
|
131
125
|
await hydrate([usdcDefinition]);
|
|
132
126
|
|