@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
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { DeviceCommunication } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
2
1
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
3
2
|
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
3
|
import { Account } from "@ledgerhq/types-live";
|
|
5
4
|
import BigNumber from "bignumber.js";
|
|
6
5
|
import { buildSignOperation, applyEIP155 } from "../signOperation";
|
|
7
6
|
import { Transaction as EvmTransaction } from "../types";
|
|
8
|
-
import * as rpcAPI from "../api/rpc.common";
|
|
7
|
+
import * as rpcAPI from "../api/rpc/rpc.common";
|
|
9
8
|
import { getEstimatedFees } from "../logic";
|
|
10
9
|
import { makeAccount } from "../testUtils";
|
|
10
|
+
import { EvmAddress, EvmSignature, EvmSigner } from "../signer";
|
|
11
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
11
12
|
|
|
12
13
|
const currency: CryptoCurrency = {
|
|
13
14
|
...getCryptoCurrencyById("ethereum"),
|
|
@@ -18,7 +19,7 @@ const currency: CryptoCurrency = {
|
|
|
18
19
|
};
|
|
19
20
|
const account: Account = makeAccount(
|
|
20
21
|
"0x7265a60acAeaf3A5E18E10BC1128e72F27B2e176", // trump.eth
|
|
21
|
-
currency
|
|
22
|
+
currency,
|
|
22
23
|
);
|
|
23
24
|
|
|
24
25
|
const transactionEIP1559: EvmTransaction = {
|
|
@@ -38,21 +39,24 @@ const transactionEIP1559: EvmTransaction = {
|
|
|
38
39
|
};
|
|
39
40
|
const estimatedFees = getEstimatedFees(transactionEIP1559);
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
|
|
42
|
+
const mockSignerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature> = (
|
|
43
|
+
_: string,
|
|
44
|
+
fn: (signer: EvmSigner) => Promise<EvmAddress | EvmSignature>,
|
|
45
|
+
) => {
|
|
46
|
+
return fn({
|
|
47
|
+
getAddress: jest.fn(),
|
|
48
|
+
signTransaction: () =>
|
|
49
|
+
Promise.resolve({
|
|
50
|
+
r: "123",
|
|
51
|
+
s: "abc",
|
|
52
|
+
v: "27",
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
};
|
|
45
56
|
|
|
46
57
|
// Mocking here in order to be ack by the signOperation.ts file
|
|
47
58
|
jest.mock("@ledgerhq/hw-app-eth", () => ({
|
|
48
59
|
__esModule: true,
|
|
49
|
-
default: class {
|
|
50
|
-
signTransaction = () => ({
|
|
51
|
-
r: "123",
|
|
52
|
-
s: "abc",
|
|
53
|
-
v: "27",
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
60
|
ledgerService: {
|
|
57
61
|
resolveTransaction: () =>
|
|
58
62
|
Promise.resolve({
|
|
@@ -68,17 +72,15 @@ describe("EVM Family", () => {
|
|
|
68
72
|
describe("signOperation.ts", () => {
|
|
69
73
|
describe("signOperation", () => {
|
|
70
74
|
beforeAll(() => {
|
|
71
|
-
jest
|
|
72
|
-
.spyOn(rpcAPI, "getTransactionCount")
|
|
73
|
-
.mockImplementation(async () => 1);
|
|
75
|
+
jest.spyOn(rpcAPI, "getTransactionCount").mockImplementation(async () => 1);
|
|
74
76
|
});
|
|
75
77
|
|
|
76
78
|
afterAll(() => {
|
|
77
79
|
jest.restoreAllMocks();
|
|
78
80
|
});
|
|
79
81
|
|
|
80
|
-
it("should return an optimistic operation and a signed hash based on hardware ECDSA signatures returned by the app bindings",
|
|
81
|
-
const signOperation = buildSignOperation(
|
|
82
|
+
it("should return an optimistic operation and a signed hash based on hardware ECDSA signatures returned by the app bindings", done => {
|
|
83
|
+
const signOperation = buildSignOperation(mockSignerContext);
|
|
82
84
|
|
|
83
85
|
const signOpObservable = signOperation({
|
|
84
86
|
account,
|
|
@@ -86,7 +88,7 @@ describe("EVM Family", () => {
|
|
|
86
88
|
deviceId: "",
|
|
87
89
|
});
|
|
88
90
|
|
|
89
|
-
signOpObservable.subscribe(
|
|
91
|
+
signOpObservable.subscribe(obs => {
|
|
90
92
|
if (obs.type === "signed") {
|
|
91
93
|
const {
|
|
92
94
|
signedOperation: { signature, operation },
|
|
@@ -108,7 +110,7 @@ describe("EVM Family", () => {
|
|
|
108
110
|
extra: {},
|
|
109
111
|
});
|
|
110
112
|
expect(signature).toBe(
|
|
111
|
-
"0x02e601016464825208946775e49108cb77cda06fc3bef51bcd497602ad886480c080820123820abc"
|
|
113
|
+
"0x02e601016464825208946775e49108cb77cda06fc3bef51bcd497602ad886480c080820123820abc",
|
|
112
114
|
);
|
|
113
115
|
done();
|
|
114
116
|
}
|
|
@@ -135,15 +137,15 @@ describe("EVM Family", () => {
|
|
|
135
137
|
"1c", // 28
|
|
136
138
|
];
|
|
137
139
|
|
|
138
|
-
chainIds.forEach(
|
|
139
|
-
possibleHexV.forEach(
|
|
140
|
+
chainIds.forEach(chainId => {
|
|
141
|
+
possibleHexV.forEach(v => {
|
|
140
142
|
it(`should return an EIP155 compatible v for chain id ${chainId} with v = ${parseInt(
|
|
141
143
|
v,
|
|
142
|
-
16
|
|
144
|
+
16,
|
|
143
145
|
)}`, () => {
|
|
144
146
|
const eip155Logic = chainId * 2 + 35;
|
|
145
147
|
expect(
|
|
146
|
-
[eip155Logic, eip155Logic + 1] // eip155 + parity
|
|
148
|
+
[eip155Logic, eip155Logic + 1], // eip155 + parity
|
|
147
149
|
).toContain(applyEIP155(v, chainId));
|
|
148
150
|
});
|
|
149
151
|
});
|
|
@@ -5,8 +5,8 @@ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
|
5
5
|
import { AssertionError, fail } from "assert";
|
|
6
6
|
import BigNumber from "bignumber.js";
|
|
7
7
|
import { getEnv } from "../../../env";
|
|
8
|
-
import * as etherscanAPI from "../api/etherscan";
|
|
9
|
-
import * as rpcAPI from "../api/rpc.common";
|
|
8
|
+
import * as etherscanAPI from "../api/explorer/etherscan";
|
|
9
|
+
import * as rpcAPI from "../api/rpc/rpc.common";
|
|
10
10
|
import * as logic from "../logic";
|
|
11
11
|
import * as synchronization from "../synchronization";
|
|
12
12
|
import { makeAccount, makeOperation, makeTokenAccount } from "../testUtils";
|
|
@@ -41,8 +41,7 @@ const account = {
|
|
|
41
41
|
const coinOperation1 = makeOperation({
|
|
42
42
|
hash: "0xH4sH",
|
|
43
43
|
accountId: "js:2:ethereum:0xkvn:",
|
|
44
|
-
blockHash:
|
|
45
|
-
"0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
44
|
+
blockHash: "0x8df71a12a8c06b36c06c26bf6248857dd2a2b75b6edbb4e33e9477078897b282",
|
|
46
45
|
senders: ["0xd48f2332Eeed88243Cb6b1D0d65a10368A5370f0"], // johnnyhallyday.eth
|
|
47
46
|
transactionSequenceNumber: 1,
|
|
48
47
|
date: new Date(),
|
|
@@ -65,8 +64,7 @@ const coinOperation3 = makeOperation({
|
|
|
65
64
|
const tokenOperation1 = makeOperation({
|
|
66
65
|
hash: "0xH4sHT0k3n",
|
|
67
66
|
accountId: "js:2:ethereum:0xkvn:+ethereum%2Ferc20%2Fusd__coin",
|
|
68
|
-
blockHash:
|
|
69
|
-
"0x95dc138a02c1b0e3fd49305f785e8e27e88a885004af13a9b4c62ad94eed07dd",
|
|
67
|
+
blockHash: "0x95dc138a02c1b0e3fd49305f785e8e27e88a885004af13a9b4c62ad94eed07dd",
|
|
70
68
|
recipients: ["0xB0B"],
|
|
71
69
|
senders: ["0x9b744C0451D73C0958d8aA566dAd33022E4Ee797"], // sbf.eth
|
|
72
70
|
contract: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
@@ -117,14 +115,14 @@ describe("EVM Family", () => {
|
|
|
117
115
|
Promise.resolve({
|
|
118
116
|
blockHeight: 10,
|
|
119
117
|
balance: new BigNumber(100),
|
|
120
|
-
})
|
|
118
|
+
}),
|
|
121
119
|
);
|
|
122
120
|
jest.spyOn(rpcAPI, "getSubAccount").mockImplementation(() =>
|
|
123
121
|
Promise.resolve({
|
|
124
122
|
blockHeight: 10,
|
|
125
123
|
balance: new BigNumber(100),
|
|
126
124
|
nonce: 1,
|
|
127
|
-
})
|
|
125
|
+
}),
|
|
128
126
|
);
|
|
129
127
|
});
|
|
130
128
|
|
|
@@ -142,14 +140,14 @@ describe("EVM Family", () => {
|
|
|
142
140
|
ethereumLikeInfo: undefined,
|
|
143
141
|
},
|
|
144
142
|
},
|
|
145
|
-
{} as any
|
|
143
|
+
{} as any,
|
|
146
144
|
);
|
|
147
145
|
fail("Promise should have been rejected");
|
|
148
146
|
} catch (e: any) {
|
|
149
147
|
if (e instanceof AssertionError) {
|
|
150
148
|
throw e;
|
|
151
149
|
}
|
|
152
|
-
expect(e.message).
|
|
150
|
+
expect(e.message).toMatch("No explorer found for currency");
|
|
153
151
|
}
|
|
154
152
|
});
|
|
155
153
|
|
|
@@ -169,14 +167,14 @@ describe("EVM Family", () => {
|
|
|
169
167
|
},
|
|
170
168
|
},
|
|
171
169
|
},
|
|
172
|
-
{} as any
|
|
170
|
+
{} as any,
|
|
173
171
|
);
|
|
174
172
|
fail("Promise should have been rejected");
|
|
175
173
|
} catch (e: any) {
|
|
176
174
|
if (e instanceof AssertionError) {
|
|
177
175
|
throw e;
|
|
178
176
|
}
|
|
179
|
-
expect(e.message).
|
|
177
|
+
expect(e.message).toMatch("No explorer found for currency");
|
|
180
178
|
}
|
|
181
179
|
});
|
|
182
180
|
|
|
@@ -203,7 +201,7 @@ describe("EVM Family", () => {
|
|
|
203
201
|
it("should return an account with a valid id", async () => {
|
|
204
202
|
const account = await synchronization.getAccountShape(
|
|
205
203
|
getAccountShapeParameters,
|
|
206
|
-
{} as any
|
|
204
|
+
{} as any,
|
|
207
205
|
);
|
|
208
206
|
expect(decodeAccountId(account.id || "")).toEqual({
|
|
209
207
|
type: "js",
|
|
@@ -217,7 +215,7 @@ describe("EVM Family", () => {
|
|
|
217
215
|
it("should return an account with the correct balance", async () => {
|
|
218
216
|
const account = await synchronization.getAccountShape(
|
|
219
217
|
getAccountShapeParameters,
|
|
220
|
-
{} as any
|
|
218
|
+
{} as any,
|
|
221
219
|
);
|
|
222
220
|
expect(account.balance).toEqual(new BigNumber(100));
|
|
223
221
|
});
|
|
@@ -225,7 +223,7 @@ describe("EVM Family", () => {
|
|
|
225
223
|
it("should return an account with the correct operations count", async () => {
|
|
226
224
|
const account = await synchronization.getAccountShape(
|
|
227
225
|
getAccountShapeParameters,
|
|
228
|
-
{} as any
|
|
226
|
+
{} as any,
|
|
229
227
|
);
|
|
230
228
|
expect(account.operationsCount).toBe(account.operations?.length);
|
|
231
229
|
});
|
|
@@ -233,7 +231,7 @@ describe("EVM Family", () => {
|
|
|
233
231
|
it("should return an account with the correct block height", async () => {
|
|
234
232
|
const account = await synchronization.getAccountShape(
|
|
235
233
|
getAccountShapeParameters,
|
|
236
|
-
{} as any
|
|
234
|
+
{} as any,
|
|
237
235
|
);
|
|
238
236
|
expect(account.blockHeight).toBe(10);
|
|
239
237
|
});
|
|
@@ -250,18 +248,14 @@ describe("EVM Family", () => {
|
|
|
250
248
|
subAccounts: [{ ...tokenAccount, operations: tokenOperations }],
|
|
251
249
|
},
|
|
252
250
|
},
|
|
253
|
-
{} as any
|
|
251
|
+
{} as any,
|
|
254
252
|
);
|
|
255
253
|
expect(accountWithSubAccount.operations).toBe(operations);
|
|
256
|
-
expect(accountWithSubAccount?.subAccounts?.[0].operations).toBe(
|
|
257
|
-
tokenOperations
|
|
258
|
-
);
|
|
254
|
+
expect(accountWithSubAccount?.subAccounts?.[0].operations).toBe(tokenOperations);
|
|
259
255
|
});
|
|
260
256
|
|
|
261
257
|
it("should do a full sync when syncHash changes", async () => {
|
|
262
|
-
jest
|
|
263
|
-
.spyOn(logic, "getSyncHash")
|
|
264
|
-
.mockImplementationOnce(() => "0xNope");
|
|
258
|
+
jest.spyOn(logic, "getSyncHash").mockImplementationOnce(() => "0xNope");
|
|
265
259
|
|
|
266
260
|
await synchronization.getAccountShape(
|
|
267
261
|
{
|
|
@@ -269,29 +263,23 @@ describe("EVM Family", () => {
|
|
|
269
263
|
initialAccount: {
|
|
270
264
|
...account,
|
|
271
265
|
operations: [coinOperation1],
|
|
272
|
-
subAccounts: [
|
|
273
|
-
{ ...tokenAccount, operations: [tokenOperation1] },
|
|
274
|
-
],
|
|
266
|
+
subAccounts: [{ ...tokenAccount, operations: [tokenOperation1] }],
|
|
275
267
|
},
|
|
276
268
|
},
|
|
277
|
-
{} as any
|
|
269
|
+
{} as any,
|
|
278
270
|
);
|
|
279
271
|
|
|
280
|
-
expect(
|
|
281
|
-
etherscanAPI?.default.getLastCoinOperations
|
|
282
|
-
).toHaveBeenCalledWith(
|
|
272
|
+
expect(etherscanAPI?.default.getLastCoinOperations).toHaveBeenCalledWith(
|
|
283
273
|
getAccountShapeParameters.currency,
|
|
284
274
|
getAccountShapeParameters.address,
|
|
285
275
|
account.id,
|
|
286
|
-
0
|
|
276
|
+
0,
|
|
287
277
|
);
|
|
288
|
-
expect(
|
|
289
|
-
etherscanAPI?.default.getLastTokenOperations
|
|
290
|
-
).toHaveBeenCalledWith(
|
|
278
|
+
expect(etherscanAPI?.default.getLastTokenOperations).toHaveBeenCalledWith(
|
|
291
279
|
getAccountShapeParameters.currency,
|
|
292
280
|
getAccountShapeParameters.address,
|
|
293
281
|
account.id,
|
|
294
|
-
0
|
|
282
|
+
0,
|
|
295
283
|
);
|
|
296
284
|
});
|
|
297
285
|
|
|
@@ -302,29 +290,23 @@ describe("EVM Family", () => {
|
|
|
302
290
|
initialAccount: {
|
|
303
291
|
...account,
|
|
304
292
|
operations: [coinOperation1],
|
|
305
|
-
subAccounts: [
|
|
306
|
-
{ ...tokenAccount, operations: [tokenOperation1] },
|
|
307
|
-
],
|
|
293
|
+
subAccounts: [{ ...tokenAccount, operations: [tokenOperation1] }],
|
|
308
294
|
},
|
|
309
295
|
},
|
|
310
|
-
{} as any
|
|
296
|
+
{} as any,
|
|
311
297
|
);
|
|
312
298
|
|
|
313
|
-
expect(
|
|
314
|
-
etherscanAPI?.default.getLastCoinOperations
|
|
315
|
-
).toHaveBeenCalledWith(
|
|
299
|
+
expect(etherscanAPI?.default.getLastCoinOperations).toHaveBeenCalledWith(
|
|
316
300
|
getAccountShapeParameters.currency,
|
|
317
301
|
getAccountShapeParameters.address,
|
|
318
302
|
account.id,
|
|
319
|
-
coinOperation1.blockHeight
|
|
303
|
+
coinOperation1.blockHeight,
|
|
320
304
|
);
|
|
321
|
-
expect(
|
|
322
|
-
etherscanAPI?.default.getLastTokenOperations
|
|
323
|
-
).toHaveBeenCalledWith(
|
|
305
|
+
expect(etherscanAPI?.default.getLastTokenOperations).toHaveBeenCalledWith(
|
|
324
306
|
getAccountShapeParameters.currency,
|
|
325
307
|
getAccountShapeParameters.address,
|
|
326
308
|
account.id,
|
|
327
|
-
tokenOperation1.blockHeight
|
|
309
|
+
tokenOperation1.blockHeight,
|
|
328
310
|
);
|
|
329
311
|
});
|
|
330
312
|
});
|
|
@@ -333,32 +315,26 @@ describe("EVM Family", () => {
|
|
|
333
315
|
beforeAll(() => {
|
|
334
316
|
jest
|
|
335
317
|
.spyOn(etherscanAPI?.default, "getLastCoinOperations")
|
|
336
|
-
.mockImplementation(() =>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
operation: tokenOperation2,
|
|
350
|
-
},
|
|
351
|
-
])
|
|
352
|
-
);
|
|
318
|
+
.mockImplementation(() => Promise.resolve([coinOperation1, coinOperation2]));
|
|
319
|
+
jest.spyOn(etherscanAPI?.default, "getLastTokenOperations").mockImplementation(() =>
|
|
320
|
+
Promise.resolve([
|
|
321
|
+
{
|
|
322
|
+
tokenCurrency: tokenCurrency1,
|
|
323
|
+
operation: tokenOperation1,
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
tokenCurrency: tokenCurrency1,
|
|
327
|
+
operation: tokenOperation2,
|
|
328
|
+
},
|
|
329
|
+
]),
|
|
330
|
+
);
|
|
353
331
|
jest
|
|
354
332
|
.spyOn(rpcAPI, "getTokenBalance")
|
|
355
333
|
.mockImplementation(async (a, b, contractAddress) => {
|
|
356
334
|
if (contractAddress === tokenCurrency1.contractAddress) {
|
|
357
335
|
return new BigNumber(10000);
|
|
358
336
|
}
|
|
359
|
-
throw new Error(
|
|
360
|
-
"Shouldn't be trying to fetch this token balance"
|
|
361
|
-
);
|
|
337
|
+
throw new Error("Shouldn't be trying to fetch this token balance");
|
|
362
338
|
});
|
|
363
339
|
});
|
|
364
340
|
|
|
@@ -372,12 +348,9 @@ describe("EVM Family", () => {
|
|
|
372
348
|
...getAccountShapeParameters,
|
|
373
349
|
initialAccount: account,
|
|
374
350
|
},
|
|
375
|
-
{} as any
|
|
351
|
+
{} as any,
|
|
376
352
|
);
|
|
377
|
-
expect(accountShape.operations).toEqual([
|
|
378
|
-
coinOperation2,
|
|
379
|
-
coinOperation1,
|
|
380
|
-
]);
|
|
353
|
+
expect(accountShape.operations).toEqual([coinOperation2, coinOperation1]);
|
|
381
354
|
expect(accountShape?.subAccounts?.[0]?.operations).toEqual([
|
|
382
355
|
tokenOperation2,
|
|
383
356
|
tokenOperation1,
|
|
@@ -397,7 +370,7 @@ describe("EVM Family", () => {
|
|
|
397
370
|
operations,
|
|
398
371
|
},
|
|
399
372
|
},
|
|
400
|
-
{} as any
|
|
373
|
+
{} as any,
|
|
401
374
|
);
|
|
402
375
|
|
|
403
376
|
expect(accountShape).toEqual({
|
|
@@ -440,7 +413,7 @@ describe("EVM Family", () => {
|
|
|
440
413
|
jest
|
|
441
414
|
.spyOn(synchronization, "getOperationStatus")
|
|
442
415
|
.mockImplementation((currency, op) =>
|
|
443
|
-
Promise.resolve(op.hash === "0xH4sH" ? coinOperation1 : null)
|
|
416
|
+
Promise.resolve(op.hash === "0xH4sH" ? coinOperation1 : null),
|
|
444
417
|
);
|
|
445
418
|
});
|
|
446
419
|
|
|
@@ -465,7 +438,7 @@ describe("EVM Family", () => {
|
|
|
465
438
|
],
|
|
466
439
|
},
|
|
467
440
|
},
|
|
468
|
-
{} as any
|
|
441
|
+
{} as any,
|
|
469
442
|
);
|
|
470
443
|
|
|
471
444
|
expect(accountShape.operations).toEqual([coinOperation1]);
|
|
@@ -475,42 +448,38 @@ describe("EVM Family", () => {
|
|
|
475
448
|
|
|
476
449
|
describe("getSubAccounts", () => {
|
|
477
450
|
beforeEach(() => {
|
|
478
|
-
jest
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
489
|
-
});
|
|
451
|
+
jest.spyOn(rpcAPI, "getTokenBalance").mockImplementation(async (a, b, contractAddress) => {
|
|
452
|
+
switch (contractAddress) {
|
|
453
|
+
case "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": // usdc
|
|
454
|
+
return new BigNumber(1);
|
|
455
|
+
case "0xdAC17F958D2ee523a2206206994597C13D831ec7": // usdt
|
|
456
|
+
return new BigNumber(2);
|
|
457
|
+
default:
|
|
458
|
+
return new BigNumber(0);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
490
461
|
});
|
|
491
462
|
afterEach(() => {
|
|
492
463
|
jest.restoreAllMocks();
|
|
493
464
|
});
|
|
494
465
|
|
|
495
466
|
it("should return the right subAccounts", async () => {
|
|
496
|
-
jest
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
},
|
|
506
|
-
]);
|
|
467
|
+
jest.spyOn(etherscanAPI?.default, "getLastTokenOperations").mockImplementation(async () => [
|
|
468
|
+
{ tokenCurrency: tokenCurrency1, operation: tokenOperation1 },
|
|
469
|
+
{ tokenCurrency: tokenCurrency1, operation: tokenOperation2 },
|
|
470
|
+
{ tokenCurrency: tokenCurrency2, operation: tokenOperation4 },
|
|
471
|
+
{
|
|
472
|
+
tokenCurrency: undefined as any,
|
|
473
|
+
operation: ignoredTokenOperation,
|
|
474
|
+
},
|
|
475
|
+
]);
|
|
507
476
|
|
|
508
477
|
const tokenAccounts = await synchronization.getSubAccounts(
|
|
509
478
|
{
|
|
510
479
|
...getAccountShapeParameters,
|
|
511
480
|
initialAccount: account,
|
|
512
481
|
},
|
|
513
|
-
account.id
|
|
482
|
+
account.id,
|
|
514
483
|
);
|
|
515
484
|
|
|
516
485
|
const expectedUsdcAccount = {
|
|
@@ -532,10 +501,7 @@ describe("EVM Family", () => {
|
|
|
532
501
|
swapHistory: [],
|
|
533
502
|
};
|
|
534
503
|
|
|
535
|
-
expect(tokenAccounts).toEqual([
|
|
536
|
-
expectedUsdcAccount,
|
|
537
|
-
expectedUsdtAccount,
|
|
538
|
-
]);
|
|
504
|
+
expect(tokenAccounts).toEqual([expectedUsdcAccount, expectedUsdtAccount]);
|
|
539
505
|
});
|
|
540
506
|
|
|
541
507
|
it("should return a partial sub account based on blockHeight", async () => {
|
|
@@ -562,7 +528,7 @@ describe("EVM Family", () => {
|
|
|
562
528
|
...getAccountShapeParameters,
|
|
563
529
|
initialAccount: accountWithIncompleteSubAccount,
|
|
564
530
|
},
|
|
565
|
-
account.id
|
|
531
|
+
account.id,
|
|
566
532
|
);
|
|
567
533
|
|
|
568
534
|
const expectedUsdcAccount = {
|
|
@@ -581,7 +547,7 @@ describe("EVM Family", () => {
|
|
|
581
547
|
currency,
|
|
582
548
|
account.freshAddress,
|
|
583
549
|
account.id,
|
|
584
|
-
tokenOperation2.blockHeight
|
|
550
|
+
tokenOperation2.blockHeight,
|
|
585
551
|
);
|
|
586
552
|
});
|
|
587
553
|
|
|
@@ -601,32 +567,30 @@ describe("EVM Family", () => {
|
|
|
601
567
|
},
|
|
602
568
|
},
|
|
603
569
|
},
|
|
604
|
-
account.id
|
|
570
|
+
account.id,
|
|
605
571
|
);
|
|
606
572
|
fail("Promise should have been rejected");
|
|
607
573
|
} catch (e: any) {
|
|
608
574
|
if (e instanceof AssertionError) {
|
|
609
575
|
throw e;
|
|
610
576
|
}
|
|
611
|
-
expect(e.message).
|
|
577
|
+
expect(e.message).toMatch("No explorer found for currency");
|
|
612
578
|
}
|
|
613
579
|
});
|
|
614
580
|
});
|
|
615
581
|
|
|
616
582
|
describe("getSubAccountShape", () => {
|
|
617
583
|
beforeEach(() => {
|
|
618
|
-
jest
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
});
|
|
584
|
+
jest.spyOn(rpcAPI, "getTokenBalance").mockImplementation(async (a, b, contractAddress) => {
|
|
585
|
+
switch (contractAddress) {
|
|
586
|
+
case "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": // usdc
|
|
587
|
+
return new BigNumber(1);
|
|
588
|
+
case "0xdAC17F958D2ee523a2206206994597C13D831ec7": // usdt
|
|
589
|
+
return new BigNumber(2);
|
|
590
|
+
default:
|
|
591
|
+
return new BigNumber(0);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
630
594
|
});
|
|
631
595
|
afterEach(() => {
|
|
632
596
|
jest.restoreAllMocks();
|
|
@@ -637,7 +601,7 @@ describe("EVM Family", () => {
|
|
|
637
601
|
currency,
|
|
638
602
|
account.id,
|
|
639
603
|
tokenCurrency1,
|
|
640
|
-
[tokenOperation1, tokenOperation2, tokenOperation3]
|
|
604
|
+
[tokenOperation1, tokenOperation2, tokenOperation3],
|
|
641
605
|
);
|
|
642
606
|
|
|
643
607
|
expect(subAccount).toEqual({
|
|
@@ -658,9 +622,7 @@ describe("EVM Family", () => {
|
|
|
658
622
|
throw new Error();
|
|
659
623
|
});
|
|
660
624
|
|
|
661
|
-
expect(
|
|
662
|
-
await synchronization.getOperationStatus(currency, coinOperation1)
|
|
663
|
-
).toBe(null);
|
|
625
|
+
expect(await synchronization.getOperationStatus(currency, coinOperation1)).toBe(null);
|
|
664
626
|
});
|
|
665
627
|
|
|
666
628
|
it("should return null if retrieved transaction has no blockHeight", async () => {
|
|
@@ -670,12 +632,10 @@ describe("EVM Family", () => {
|
|
|
670
632
|
blockHash: "hash",
|
|
671
633
|
timestamp: 101010010,
|
|
672
634
|
nonce: 1,
|
|
673
|
-
} as any)
|
|
635
|
+
} as any),
|
|
674
636
|
);
|
|
675
637
|
|
|
676
|
-
expect(
|
|
677
|
-
await synchronization.getOperationStatus(currency, coinOperation1)
|
|
678
|
-
).toBe(null);
|
|
638
|
+
expect(await synchronization.getOperationStatus(currency, coinOperation1)).toBe(null);
|
|
679
639
|
});
|
|
680
640
|
|
|
681
641
|
it("should return the retrieved operation with network properties", async () => {
|
|
@@ -686,12 +646,10 @@ describe("EVM Family", () => {
|
|
|
686
646
|
blockHash: "hash",
|
|
687
647
|
timestamp: Date.now() / 1000,
|
|
688
648
|
nonce: 123,
|
|
689
|
-
} as any)
|
|
649
|
+
} as any),
|
|
690
650
|
);
|
|
691
651
|
|
|
692
|
-
expect(
|
|
693
|
-
await synchronization.getOperationStatus(currency, coinOperation1)
|
|
694
|
-
).toEqual({
|
|
652
|
+
expect(await synchronization.getOperationStatus(currency, coinOperation1)).toEqual({
|
|
695
653
|
...coinOperation1,
|
|
696
654
|
blockHash: "hash",
|
|
697
655
|
blockHeight: 10,
|
|
@@ -707,17 +665,13 @@ describe("EVM Family", () => {
|
|
|
707
665
|
blockNumber: 10,
|
|
708
666
|
blockHash: "hash",
|
|
709
667
|
nonce: 123,
|
|
710
|
-
} as any)
|
|
668
|
+
} as any),
|
|
711
669
|
);
|
|
712
670
|
jest
|
|
713
671
|
.spyOn(rpcAPI, "getBlock")
|
|
714
|
-
.mockImplementationOnce(
|
|
715
|
-
async () => ({ timestamp: Date.now() / 1000 } as any)
|
|
716
|
-
);
|
|
672
|
+
.mockImplementationOnce(async () => ({ timestamp: Date.now() / 1000 } as any));
|
|
717
673
|
|
|
718
|
-
expect(
|
|
719
|
-
await synchronization.getOperationStatus(currency, coinOperation1)
|
|
720
|
-
).toEqual({
|
|
674
|
+
expect(await synchronization.getOperationStatus(currency, coinOperation1)).toEqual({
|
|
721
675
|
...coinOperation1,
|
|
722
676
|
blockHash: "hash",
|
|
723
677
|
blockHeight: 10,
|
|
@@ -739,10 +693,7 @@ describe("EVM Family", () => {
|
|
|
739
693
|
};
|
|
740
694
|
|
|
741
695
|
expect(
|
|
742
|
-
synchronization.postSync(
|
|
743
|
-
{ ...account, subAccounts: [] },
|
|
744
|
-
accountWithTokenAccount
|
|
745
|
-
)
|
|
696
|
+
synchronization.postSync({ ...account, subAccounts: [] }, accountWithTokenAccount),
|
|
746
697
|
).toEqual(accountWithTokenAccount);
|
|
747
698
|
});
|
|
748
699
|
|
|
@@ -758,15 +709,15 @@ describe("EVM Family", () => {
|
|
|
758
709
|
};
|
|
759
710
|
|
|
760
711
|
// should not change anything if we maintain the pending op
|
|
761
|
-
expect(
|
|
762
|
-
|
|
763
|
-
)
|
|
712
|
+
expect(synchronization.postSync(accountWithPending, accountWithPending)).toEqual(
|
|
713
|
+
accountWithPending,
|
|
714
|
+
);
|
|
764
715
|
// Should remove the pending from tokenAccount as well if removed from main account
|
|
765
716
|
expect(
|
|
766
717
|
synchronization.postSync(accountWithPending, {
|
|
767
718
|
...accountWithPending,
|
|
768
719
|
pendingOperations: [],
|
|
769
|
-
})
|
|
720
|
+
}),
|
|
770
721
|
).toEqual(account);
|
|
771
722
|
});
|
|
772
723
|
|
|
@@ -792,7 +743,7 @@ describe("EVM Family", () => {
|
|
|
792
743
|
operations: [pendingOperation],
|
|
793
744
|
},
|
|
794
745
|
],
|
|
795
|
-
})
|
|
746
|
+
}),
|
|
796
747
|
).toEqual({
|
|
797
748
|
...accountWithPending,
|
|
798
749
|
subAccounts: [
|
|
@@ -820,12 +771,9 @@ describe("EVM Family", () => {
|
|
|
820
771
|
};
|
|
821
772
|
|
|
822
773
|
// Should remove the pending from tokenAccount if it was confirmed in the tokenAccount ops
|
|
823
|
-
expect(
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
accountWithTokenAccount
|
|
827
|
-
)
|
|
828
|
-
).toEqual(account);
|
|
774
|
+
expect(synchronization.postSync(accountWithTokenAccount, accountWithTokenAccount)).toEqual(
|
|
775
|
+
account,
|
|
776
|
+
);
|
|
829
777
|
});
|
|
830
778
|
});
|
|
831
779
|
});
|