@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
|
@@ -2,26 +2,20 @@ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
|
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
3
|
import { ethers } from "ethers";
|
|
4
4
|
import ERC20ABI from "../abis/erc20.abi.json";
|
|
5
|
-
import * as rpcAPI from "../api/rpc.common";
|
|
6
|
-
import {
|
|
7
|
-
prepareForSignOperation,
|
|
8
|
-
prepareTransaction,
|
|
9
|
-
} from "../prepareTransaction";
|
|
5
|
+
import * as rpcAPI from "../api/rpc/rpc.common";
|
|
6
|
+
import { prepareForSignOperation, prepareTransaction } from "../prepareTransaction";
|
|
10
7
|
import { makeAccount, makeTokenAccount } from "../testUtils";
|
|
11
|
-
import { Transaction as EvmTransaction } from "../types";
|
|
8
|
+
import { Transaction as EvmTransaction, GasOptions } from "../types";
|
|
12
9
|
|
|
13
10
|
const currency = getCryptoCurrencyById("ethereum");
|
|
14
|
-
const tokenAccount = makeTokenAccount(
|
|
15
|
-
"0xkvn",
|
|
16
|
-
getTokenById("ethereum/erc20/usd__coin")
|
|
17
|
-
);
|
|
11
|
+
const tokenAccount = makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin"));
|
|
18
12
|
const account = makeAccount("0xkvn", currency, [tokenAccount]);
|
|
19
13
|
const transaction: EvmTransaction = {
|
|
20
14
|
amount: new BigNumber(100),
|
|
21
15
|
useAllAmount: false,
|
|
22
16
|
subAccountId: "id",
|
|
23
17
|
recipient: "0x6bfD74C0996F269Bcece59191EFf667b3dFD73b9",
|
|
24
|
-
feesStrategy: "
|
|
18
|
+
feesStrategy: "medium",
|
|
25
19
|
family: "evm",
|
|
26
20
|
mode: "send",
|
|
27
21
|
gasPrice: new BigNumber(0),
|
|
@@ -38,16 +32,14 @@ const expectedData = (recipient: string, amount: BigNumber): Buffer =>
|
|
|
38
32
|
new ethers.utils.Interface(ERC20ABI)
|
|
39
33
|
.encodeFunctionData("transfer", [recipient, amount.toFixed()])
|
|
40
34
|
.slice(2),
|
|
41
|
-
"hex"
|
|
35
|
+
"hex",
|
|
42
36
|
);
|
|
43
37
|
|
|
44
38
|
describe("EVM Family", () => {
|
|
45
39
|
describe("prepareTransaction.ts", () => {
|
|
46
40
|
beforeEach(() => {
|
|
47
41
|
// These mocks will be overriden in some tests
|
|
48
|
-
jest
|
|
49
|
-
.spyOn(rpcAPI, "getGasEstimation")
|
|
50
|
-
.mockImplementation(async () => new BigNumber(21000));
|
|
42
|
+
jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => new BigNumber(21000));
|
|
51
43
|
// These mocks will be overriden in some tests
|
|
52
44
|
jest.spyOn(rpcAPI, "getFeesEstimation").mockImplementation(async () => ({
|
|
53
45
|
gasPrice: new BigNumber(1),
|
|
@@ -63,11 +55,9 @@ describe("EVM Family", () => {
|
|
|
63
55
|
describe("prepareTransaction", () => {
|
|
64
56
|
describe("Coins", () => {
|
|
65
57
|
it("should have a gasLimit = 0 when recipient has an error", async () => {
|
|
66
|
-
jest
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
throw new Error();
|
|
70
|
-
});
|
|
58
|
+
jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
|
|
59
|
+
throw new Error();
|
|
60
|
+
});
|
|
71
61
|
|
|
72
62
|
const tx = await prepareTransaction(account, {
|
|
73
63
|
...transaction,
|
|
@@ -86,11 +76,9 @@ describe("EVM Family", () => {
|
|
|
86
76
|
});
|
|
87
77
|
|
|
88
78
|
it("should have a gasLimit = 0 when amount has an error", async () => {
|
|
89
|
-
jest
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
throw new Error();
|
|
93
|
-
});
|
|
79
|
+
jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
|
|
80
|
+
throw new Error();
|
|
81
|
+
});
|
|
94
82
|
|
|
95
83
|
const tx = await prepareTransaction(account, {
|
|
96
84
|
...transaction,
|
|
@@ -120,13 +108,11 @@ describe("EVM Family", () => {
|
|
|
120
108
|
});
|
|
121
109
|
|
|
122
110
|
it("should return a legacy coin transaction", async () => {
|
|
123
|
-
jest
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
maxPriorityFeePerGas: null,
|
|
129
|
-
}));
|
|
111
|
+
jest.spyOn(rpcAPI, "getFeesEstimation").mockImplementationOnce(async () => ({
|
|
112
|
+
gasPrice: new BigNumber(1),
|
|
113
|
+
maxFeePerGas: null,
|
|
114
|
+
maxPriorityFeePerGas: null,
|
|
115
|
+
}));
|
|
130
116
|
|
|
131
117
|
const tx = await prepareTransaction(account, transaction);
|
|
132
118
|
|
|
@@ -147,10 +133,7 @@ describe("EVM Family", () => {
|
|
|
147
133
|
useAllAmount: true,
|
|
148
134
|
};
|
|
149
135
|
|
|
150
|
-
const tx = await prepareTransaction(
|
|
151
|
-
accountWithBalance,
|
|
152
|
-
transactionWithUseAllAmount
|
|
153
|
-
);
|
|
136
|
+
const tx = await prepareTransaction(accountWithBalance, transactionWithUseAllAmount);
|
|
154
137
|
const estimatedFees = new BigNumber(21000); // 21000 gasLimit * 1 maxFeePerGas
|
|
155
138
|
|
|
156
139
|
expect(tx).toEqual({
|
|
@@ -189,11 +172,9 @@ describe("EVM Family", () => {
|
|
|
189
172
|
|
|
190
173
|
describe("Tokens", () => {
|
|
191
174
|
it("should have a gasLimit = 0 and no data when recipient has an error", async () => {
|
|
192
|
-
jest
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
throw new Error();
|
|
196
|
-
});
|
|
175
|
+
jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
|
|
176
|
+
throw new Error();
|
|
177
|
+
});
|
|
197
178
|
|
|
198
179
|
const tx = await prepareTransaction(account, {
|
|
199
180
|
...tokenTransaction,
|
|
@@ -213,11 +194,9 @@ describe("EVM Family", () => {
|
|
|
213
194
|
});
|
|
214
195
|
|
|
215
196
|
it("should have a gasLimit = 0 when amount has an error", async () => {
|
|
216
|
-
jest
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
throw new Error();
|
|
220
|
-
});
|
|
197
|
+
jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
|
|
198
|
+
throw new Error();
|
|
199
|
+
});
|
|
221
200
|
|
|
222
201
|
const tx = await prepareTransaction(account, {
|
|
223
202
|
...tokenTransaction,
|
|
@@ -262,10 +241,7 @@ describe("EVM Family", () => {
|
|
|
262
241
|
amount: tokenAccountWithBalance.balance,
|
|
263
242
|
useAllAmount: true,
|
|
264
243
|
subAccountId: tokenAccountWithBalance.id,
|
|
265
|
-
data: expectedData(
|
|
266
|
-
tokenTransaction.recipient,
|
|
267
|
-
tokenAccountWithBalance.balance
|
|
268
|
-
),
|
|
244
|
+
data: expectedData(tokenTransaction.recipient, tokenAccountWithBalance.balance),
|
|
269
245
|
maxFeePerGas: new BigNumber(1),
|
|
270
246
|
maxPriorityFeePerGas: new BigNumber(1),
|
|
271
247
|
gasPrice: undefined,
|
|
@@ -299,11 +275,8 @@ describe("EVM Family", () => {
|
|
|
299
275
|
expect.objectContaining({
|
|
300
276
|
recipient: tokenAccount.token.contractAddress,
|
|
301
277
|
amount: new BigNumber(0),
|
|
302
|
-
data: expectedData(
|
|
303
|
-
|
|
304
|
-
tokenAccountWithBalance.balance
|
|
305
|
-
),
|
|
306
|
-
})
|
|
278
|
+
data: expectedData(tokenTransaction.recipient, tokenAccountWithBalance.balance),
|
|
279
|
+
}),
|
|
307
280
|
);
|
|
308
281
|
});
|
|
309
282
|
|
|
@@ -320,10 +293,7 @@ describe("EVM Family", () => {
|
|
|
320
293
|
|
|
321
294
|
expect(tx).toEqual({
|
|
322
295
|
...tokenTransaction,
|
|
323
|
-
data: expectedData(
|
|
324
|
-
tokenTransaction.recipient,
|
|
325
|
-
tokenTransaction.amount
|
|
326
|
-
),
|
|
296
|
+
data: expectedData(tokenTransaction.recipient, tokenTransaction.amount),
|
|
327
297
|
maxFeePerGas: new BigNumber(1),
|
|
328
298
|
maxPriorityFeePerGas: new BigNumber(1),
|
|
329
299
|
type: 2,
|
|
@@ -331,13 +301,11 @@ describe("EVM Family", () => {
|
|
|
331
301
|
});
|
|
332
302
|
|
|
333
303
|
it("should return a legacy token transaction", async () => {
|
|
334
|
-
jest
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
maxPriorityFeePerGas: null,
|
|
340
|
-
}));
|
|
304
|
+
jest.spyOn(rpcAPI, "getFeesEstimation").mockImplementationOnce(async () => ({
|
|
305
|
+
gasPrice: new BigNumber(1),
|
|
306
|
+
maxFeePerGas: null,
|
|
307
|
+
maxPriorityFeePerGas: null,
|
|
308
|
+
}));
|
|
341
309
|
|
|
342
310
|
const tokenAccountWithBalance = {
|
|
343
311
|
...tokenAccount,
|
|
@@ -351,22 +319,111 @@ describe("EVM Family", () => {
|
|
|
351
319
|
|
|
352
320
|
expect(tx).toEqual({
|
|
353
321
|
...tokenTransaction,
|
|
354
|
-
data: expectedData(
|
|
355
|
-
tokenTransaction.recipient,
|
|
356
|
-
tokenTransaction.amount
|
|
357
|
-
),
|
|
322
|
+
data: expectedData(tokenTransaction.recipient, tokenTransaction.amount),
|
|
358
323
|
gasPrice: new BigNumber(1),
|
|
359
324
|
type: 0,
|
|
360
325
|
});
|
|
361
326
|
});
|
|
362
327
|
});
|
|
328
|
+
|
|
329
|
+
describe("When feesStrategy provided", () => {
|
|
330
|
+
it("should call getFeesEstimation once", async () => {
|
|
331
|
+
const tx = await prepareTransaction(account, {
|
|
332
|
+
...transaction,
|
|
333
|
+
feesStrategy: undefined,
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
expect(rpcAPI.getFeesEstimation).toBeCalledTimes(1);
|
|
337
|
+
|
|
338
|
+
expect(tx).toEqual({
|
|
339
|
+
...transaction,
|
|
340
|
+
feesStrategy: undefined,
|
|
341
|
+
additionalFees: undefined,
|
|
342
|
+
maxFeePerGas: new BigNumber(1),
|
|
343
|
+
maxPriorityFeePerGas: new BigNumber(1),
|
|
344
|
+
type: 2,
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
describe("When custom feesStrategy provided", () => {
|
|
350
|
+
it("should use transaction provided data for fees", async () => {
|
|
351
|
+
const tx = await prepareTransaction(account, {
|
|
352
|
+
...transaction,
|
|
353
|
+
feesStrategy: "custom",
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
expect(rpcAPI.getFeesEstimation).toBeCalledTimes(0);
|
|
357
|
+
|
|
358
|
+
expect(tx).toEqual({
|
|
359
|
+
...transaction,
|
|
360
|
+
additionalFees: undefined,
|
|
361
|
+
feesStrategy: "custom",
|
|
362
|
+
gasPrice: new BigNumber(0),
|
|
363
|
+
type: 0,
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
describe("When gasOptions provided", () => {
|
|
369
|
+
it("should call getFeesEstimation once", async () => {
|
|
370
|
+
const tx = await prepareTransaction(account, {
|
|
371
|
+
...transaction,
|
|
372
|
+
gasOptions: undefined,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
expect(rpcAPI.getFeesEstimation).toBeCalledTimes(1);
|
|
376
|
+
|
|
377
|
+
expect(tx).toEqual({
|
|
378
|
+
...transaction,
|
|
379
|
+
maxFeePerGas: new BigNumber(1),
|
|
380
|
+
maxPriorityFeePerGas: new BigNumber(1),
|
|
381
|
+
type: 2,
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
describe("When gasOptions provided", () => {
|
|
387
|
+
const gasOptions: GasOptions = {
|
|
388
|
+
slow: {
|
|
389
|
+
maxFeePerGas: new BigNumber(10),
|
|
390
|
+
maxPriorityFeePerGas: new BigNumber(1),
|
|
391
|
+
gasPrice: null,
|
|
392
|
+
},
|
|
393
|
+
medium: {
|
|
394
|
+
maxFeePerGas: new BigNumber(20),
|
|
395
|
+
maxPriorityFeePerGas: new BigNumber(2),
|
|
396
|
+
gasPrice: null,
|
|
397
|
+
},
|
|
398
|
+
fast: {
|
|
399
|
+
maxFeePerGas: new BigNumber(30),
|
|
400
|
+
maxPriorityFeePerGas: new BigNumber(3),
|
|
401
|
+
gasPrice: null,
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
it("should use gasOptions values for fee data", async () => {
|
|
405
|
+
const tx = await prepareTransaction(account, {
|
|
406
|
+
...transaction,
|
|
407
|
+
gasOptions,
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
expect(rpcAPI.getFeesEstimation).toBeCalledTimes(0);
|
|
411
|
+
|
|
412
|
+
expect(tx).toEqual({
|
|
413
|
+
...transaction,
|
|
414
|
+
gasOptions,
|
|
415
|
+
additionalFees: undefined,
|
|
416
|
+
maxFeePerGas: new BigNumber(20),
|
|
417
|
+
maxPriorityFeePerGas: new BigNumber(2),
|
|
418
|
+
type: 2,
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
});
|
|
363
422
|
});
|
|
364
423
|
|
|
365
424
|
describe("prepareForSignOperation", () => {
|
|
366
425
|
beforeEach(() => {
|
|
367
|
-
jest
|
|
368
|
-
.spyOn(rpcAPI, "getTransactionCount")
|
|
369
|
-
.mockImplementation(() => Promise.resolve(10));
|
|
426
|
+
jest.spyOn(rpcAPI, "getTransactionCount").mockImplementation(() => Promise.resolve(10));
|
|
370
427
|
});
|
|
371
428
|
afterEach(() => {
|
|
372
429
|
jest.restoreAllMocks();
|
|
@@ -380,9 +437,7 @@ describe("EVM Family", () => {
|
|
|
380
437
|
});
|
|
381
438
|
|
|
382
439
|
it("should update a token transaction with the correct recipient", async () => {
|
|
383
|
-
expect(
|
|
384
|
-
await prepareForSignOperation(account, tokenTransaction)
|
|
385
|
-
).toEqual({
|
|
440
|
+
expect(await prepareForSignOperation(account, tokenTransaction)).toEqual({
|
|
386
441
|
...tokenTransaction,
|
|
387
442
|
amount: new BigNumber(0),
|
|
388
443
|
recipient: tokenAccount.token.contractAddress,
|
|
@@ -3,7 +3,7 @@ import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
|
|
3
3
|
import { AssertionError, fail } from "assert";
|
|
4
4
|
import BigNumber from "bignumber.js";
|
|
5
5
|
import { ethers } from "ethers";
|
|
6
|
-
import * as RPC_API from "../api/rpc.common";
|
|
6
|
+
import * as RPC_API from "../api/rpc/rpc.common";
|
|
7
7
|
import { GasEstimationError, InsufficientFunds } from "../errors";
|
|
8
8
|
import { makeAccount } from "../testUtils";
|
|
9
9
|
import { Transaction as EvmTransaction, EvmTransactionLegacy } from "../types";
|
|
@@ -25,7 +25,7 @@ const fakeCurrencyWithoutRPC: Partial<CryptoCurrency> = {
|
|
|
25
25
|
};
|
|
26
26
|
const account = makeAccount(
|
|
27
27
|
"0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d",
|
|
28
|
-
fakeCurrency as CryptoCurrency
|
|
28
|
+
fakeCurrency as CryptoCurrency,
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
const mockedNetwork = {
|
|
@@ -35,7 +35,7 @@ const mockedNetwork = {
|
|
|
35
35
|
|
|
36
36
|
jest.mock("@ledgerhq/live-promise");
|
|
37
37
|
(delay as jest.Mock).mockImplementation(
|
|
38
|
-
() => new Promise(
|
|
38
|
+
() => new Promise(resolve => setTimeout(resolve, 1)), // mocking the delay supposed to happen after each try
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
describe("EVM Family", () => {
|
|
@@ -52,7 +52,7 @@ describe("EVM Family", () => {
|
|
|
52
52
|
.mockResolvedValue(null);
|
|
53
53
|
jest
|
|
54
54
|
.spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "resolveName")
|
|
55
|
-
.mockImplementation(async
|
|
55
|
+
.mockImplementation(async address => address);
|
|
56
56
|
jest
|
|
57
57
|
.spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "perform")
|
|
58
58
|
.mockImplementation(async (method, params) => {
|
|
@@ -80,8 +80,7 @@ describe("EVM Family", () => {
|
|
|
80
80
|
return ethers.BigNumber.from(5);
|
|
81
81
|
case "getBlock":
|
|
82
82
|
return {
|
|
83
|
-
parentHash:
|
|
84
|
-
"0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
|
|
83
|
+
parentHash: "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
|
|
85
84
|
number: 1,
|
|
86
85
|
timestamp: 123,
|
|
87
86
|
difficulty: null,
|
|
@@ -119,18 +118,13 @@ describe("EVM Family", () => {
|
|
|
119
118
|
describe("withApi", () => {
|
|
120
119
|
it("should throw if the currency doesn't have an RPC node", async () => {
|
|
121
120
|
try {
|
|
122
|
-
await RPC_API.withApi(
|
|
123
|
-
fakeCurrencyWithoutRPC as CryptoCurrency,
|
|
124
|
-
(() => {}) as any
|
|
125
|
-
);
|
|
121
|
+
await RPC_API.withApi(fakeCurrencyWithoutRPC as CryptoCurrency, (() => {}) as any);
|
|
126
122
|
fail("Promise should have been rejected");
|
|
127
123
|
} catch (e) {
|
|
128
124
|
if (e instanceof AssertionError) {
|
|
129
125
|
throw e;
|
|
130
126
|
}
|
|
131
|
-
expect((e as Error).message).toEqual(
|
|
132
|
-
"Currency doesn't have an RPC node provided"
|
|
133
|
-
);
|
|
127
|
+
expect((e as Error).message).toEqual("Currency doesn't have an RPC node provided");
|
|
134
128
|
}
|
|
135
129
|
});
|
|
136
130
|
|
|
@@ -143,10 +137,7 @@ describe("EVM Family", () => {
|
|
|
143
137
|
}
|
|
144
138
|
return true;
|
|
145
139
|
});
|
|
146
|
-
const response = await RPC_API.withApi(
|
|
147
|
-
fakeCurrency as CryptoCurrency,
|
|
148
|
-
spy
|
|
149
|
-
);
|
|
140
|
+
const response = await RPC_API.withApi(fakeCurrency as CryptoCurrency, spy);
|
|
150
141
|
|
|
151
142
|
expect(response).toBe(true);
|
|
152
143
|
// it should fail DEFAULT_RETRIES_RPC_METHODS times and succeed on the next try, therefore the +1
|
|
@@ -179,12 +170,7 @@ describe("EVM Family", () => {
|
|
|
179
170
|
|
|
180
171
|
describe("getBalanceAndBlock", () => {
|
|
181
172
|
it("should return the expected payload", async () => {
|
|
182
|
-
expect(
|
|
183
|
-
await RPC_API.getBalanceAndBlock(
|
|
184
|
-
fakeCurrency as CryptoCurrency,
|
|
185
|
-
"0xkvn"
|
|
186
|
-
)
|
|
187
|
-
).toEqual({
|
|
173
|
+
expect(await RPC_API.getBalanceAndBlock(fakeCurrency as CryptoCurrency, "0xkvn")).toEqual({
|
|
188
174
|
blockHeight: 69,
|
|
189
175
|
balance: new BigNumber(420),
|
|
190
176
|
});
|
|
@@ -196,8 +182,8 @@ describe("EVM Family", () => {
|
|
|
196
182
|
expect(
|
|
197
183
|
await RPC_API.getTransaction(
|
|
198
184
|
fakeCurrency as CryptoCurrency,
|
|
199
|
-
"0x435b00d28a10febbcfefbdea080134d08ef843df122d5bc9174b09de7fce6a59"
|
|
200
|
-
)
|
|
185
|
+
"0x435b00d28a10febbcfefbdea080134d08ef843df122d5bc9174b09de7fce6a59",
|
|
186
|
+
),
|
|
201
187
|
).toEqual({
|
|
202
188
|
accessList: null,
|
|
203
189
|
blockHash: null,
|
|
@@ -224,8 +210,8 @@ describe("EVM Family", () => {
|
|
|
224
210
|
expect(
|
|
225
211
|
await RPC_API.getCoinBalance(
|
|
226
212
|
fakeCurrency as CryptoCurrency,
|
|
227
|
-
"0x435b00d28a10febbcfefbdea080134d08ef843df122d5bc9174b09de7fce6a59"
|
|
228
|
-
)
|
|
213
|
+
"0x435b00d28a10febbcfefbdea080134d08ef843df122d5bc9174b09de7fce6a59",
|
|
214
|
+
),
|
|
229
215
|
).toEqual(new BigNumber(420));
|
|
230
216
|
});
|
|
231
217
|
});
|
|
@@ -237,8 +223,8 @@ describe("EVM Family", () => {
|
|
|
237
223
|
await RPC_API.getTokenBalance(
|
|
238
224
|
fakeCurrency as CryptoCurrency,
|
|
239
225
|
"0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d",
|
|
240
|
-
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
241
|
-
)
|
|
226
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
227
|
+
),
|
|
242
228
|
).toEqual(new BigNumber(420));
|
|
243
229
|
});
|
|
244
230
|
});
|
|
@@ -248,8 +234,8 @@ describe("EVM Family", () => {
|
|
|
248
234
|
expect(
|
|
249
235
|
await RPC_API.getTransactionCount(
|
|
250
236
|
fakeCurrency as CryptoCurrency,
|
|
251
|
-
"0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d"
|
|
252
|
-
)
|
|
237
|
+
"0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d",
|
|
238
|
+
),
|
|
253
239
|
).toEqual(5);
|
|
254
240
|
});
|
|
255
241
|
});
|
|
@@ -264,7 +250,7 @@ describe("EVM Family", () => {
|
|
|
264
250
|
gasPrice: new BigNumber(0),
|
|
265
251
|
data: Buffer.from(""),
|
|
266
252
|
type: 0,
|
|
267
|
-
} as EvmTransactionLegacy)
|
|
253
|
+
} as EvmTransactionLegacy),
|
|
268
254
|
).toEqual(new BigNumber(5));
|
|
269
255
|
});
|
|
270
256
|
|
|
@@ -292,7 +278,7 @@ describe("EVM Family", () => {
|
|
|
292
278
|
it("should return the expected payload for an EIP1559 tx", async () => {
|
|
293
279
|
jest
|
|
294
280
|
.spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "send")
|
|
295
|
-
.mockImplementationOnce(async
|
|
281
|
+
.mockImplementationOnce(async method => {
|
|
296
282
|
if (method === "eth_feeHistory") {
|
|
297
283
|
return {
|
|
298
284
|
reward: [
|
|
@@ -307,9 +293,7 @@ describe("EVM Family", () => {
|
|
|
307
293
|
}
|
|
308
294
|
});
|
|
309
295
|
|
|
310
|
-
expect(
|
|
311
|
-
await RPC_API.getFeesEstimation(fakeCurrency as CryptoCurrency)
|
|
312
|
-
).toEqual({
|
|
296
|
+
expect(await RPC_API.getFeesEstimation(fakeCurrency as CryptoCurrency)).toEqual({
|
|
313
297
|
maxFeePerGas: new BigNumber("6000000014"),
|
|
314
298
|
maxPriorityFeePerGas: new BigNumber("5999999988"),
|
|
315
299
|
gasPrice: null,
|
|
@@ -319,7 +303,7 @@ describe("EVM Family", () => {
|
|
|
319
303
|
it("should return the expected payload for an EIP1559 tx when network returns 0 priority fee", async () => {
|
|
320
304
|
jest
|
|
321
305
|
.spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "send")
|
|
322
|
-
.mockImplementationOnce(async
|
|
306
|
+
.mockImplementationOnce(async method => {
|
|
323
307
|
if (method === "eth_feeHistory") {
|
|
324
308
|
return {
|
|
325
309
|
reward: [
|
|
@@ -334,9 +318,7 @@ describe("EVM Family", () => {
|
|
|
334
318
|
}
|
|
335
319
|
});
|
|
336
320
|
|
|
337
|
-
expect(
|
|
338
|
-
await RPC_API.getFeesEstimation(fakeCurrency as CryptoCurrency)
|
|
339
|
-
).toEqual({
|
|
321
|
+
expect(await RPC_API.getFeesEstimation(fakeCurrency as CryptoCurrency)).toEqual({
|
|
340
322
|
maxFeePerGas: new BigNumber("1000000026"),
|
|
341
323
|
maxPriorityFeePerGas: new BigNumber(1e9),
|
|
342
324
|
gasPrice: null,
|
|
@@ -346,12 +328,11 @@ describe("EVM Family", () => {
|
|
|
346
328
|
it("should return the expected payload for a legacy tx", async () => {
|
|
347
329
|
jest
|
|
348
330
|
.spyOn(ethers.providers.StaticJsonRpcProvider.prototype, "perform")
|
|
349
|
-
.mockImplementationOnce(async
|
|
331
|
+
.mockImplementationOnce(async method => {
|
|
350
332
|
switch (method) {
|
|
351
333
|
case "getBlock":
|
|
352
334
|
return {
|
|
353
|
-
parentHash:
|
|
354
|
-
"0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
|
|
335
|
+
parentHash: "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
|
|
355
336
|
number: 1,
|
|
356
337
|
timestamp: 123,
|
|
357
338
|
difficulty: null,
|
|
@@ -368,7 +349,7 @@ describe("EVM Family", () => {
|
|
|
368
349
|
await RPC_API.getFeesEstimation({
|
|
369
350
|
...fakeCurrency,
|
|
370
351
|
id: "optimism",
|
|
371
|
-
} as CryptoCurrency)
|
|
352
|
+
} as CryptoCurrency),
|
|
372
353
|
).toEqual({
|
|
373
354
|
maxFeePerGas: null,
|
|
374
355
|
maxPriorityFeePerGas: null,
|
|
@@ -382,10 +363,7 @@ describe("EVM Family", () => {
|
|
|
382
363
|
const serializedTransaction =
|
|
383
364
|
"0x02f873012d85010c388d0085077715912682520894c2907efcce4011c491bbeda8a0fa63ba7aab596c87038d7ea4c6800080c001a0bbffe7ba303ab03f697d64672c4a288ae863df8a62ffc67ba72872ce8c227f6fa01261e7c9f06af13631f03fad9b88d3c48931d353b6b41b4072fddcca5ec41629";
|
|
384
365
|
expect(
|
|
385
|
-
await RPC_API.broadcastTransaction(
|
|
386
|
-
fakeCurrency as CryptoCurrency,
|
|
387
|
-
serializedTransaction
|
|
388
|
-
)
|
|
366
|
+
await RPC_API.broadcastTransaction(fakeCurrency as CryptoCurrency, serializedTransaction),
|
|
389
367
|
).toEqual({
|
|
390
368
|
...ethers.utils.parseTransaction(serializedTransaction),
|
|
391
369
|
confirmations: 0,
|
|
@@ -398,10 +376,7 @@ describe("EVM Family", () => {
|
|
|
398
376
|
"0x02f873012d85010c388d0085077715912682520894c2907efcce4011c491bbeda8a0fa63ba7aab596c87038d7ea4c6800080c001a0bbffe7ba303ab03f697d64672c4a288ae863df8a62ffc67ba72872ce8c227f6fa01261e7c9f06af13631f03fad9b88d3c48931d353b6b41b4072fddcca5ec41628";
|
|
399
377
|
|
|
400
378
|
try {
|
|
401
|
-
await RPC_API.broadcastTransaction(
|
|
402
|
-
fakeCurrency as CryptoCurrency,
|
|
403
|
-
serializedTransaction
|
|
404
|
-
);
|
|
379
|
+
await RPC_API.broadcastTransaction(fakeCurrency as CryptoCurrency, serializedTransaction);
|
|
405
380
|
fail("Promise should have been rejected");
|
|
406
381
|
} catch (e) {
|
|
407
382
|
if (e instanceof AssertionError) {
|
|
@@ -416,10 +391,7 @@ describe("EVM Family", () => {
|
|
|
416
391
|
"0x02f873012d85010c388d0085077715912682520894c2907efcce4011c491bbeda8a0fa63ba7aab596c87038d7ea4c6800080c001a0bbffe7ba303ab03f697d64672c4a288ae863df8a62ffc67ba72872ce8c227f6fa01261e7c9f06af13631f03fad9b88d3c48931d353b6b41b4072fddcca5ec41625";
|
|
417
392
|
|
|
418
393
|
try {
|
|
419
|
-
await RPC_API.broadcastTransaction(
|
|
420
|
-
fakeCurrency as CryptoCurrency,
|
|
421
|
-
serializedTransaction
|
|
422
|
-
);
|
|
394
|
+
await RPC_API.broadcastTransaction(fakeCurrency as CryptoCurrency, serializedTransaction);
|
|
423
395
|
fail("Promise should have been rejected");
|
|
424
396
|
} catch (e) {
|
|
425
397
|
if (e instanceof AssertionError) {
|
|
@@ -432,30 +404,24 @@ describe("EVM Family", () => {
|
|
|
432
404
|
|
|
433
405
|
describe("getBlock", () => {
|
|
434
406
|
it("should return the expected payload", async () => {
|
|
435
|
-
expect(await RPC_API.getBlock(fakeCurrency as CryptoCurrency, 0)).toEqual(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
baseFeePerGas: ethers.BigNumber.from(123),
|
|
447
|
-
}
|
|
448
|
-
);
|
|
407
|
+
expect(await RPC_API.getBlock(fakeCurrency as CryptoCurrency, 0)).toEqual({
|
|
408
|
+
parentHash: "0x474dee0136108e9412e9d84197b468bb057a8dad0f2024fc55adebc4a28fa8c5",
|
|
409
|
+
number: 1,
|
|
410
|
+
timestamp: 123,
|
|
411
|
+
difficulty: null,
|
|
412
|
+
_difficulty: null,
|
|
413
|
+
gasLimit: ethers.BigNumber.from(1),
|
|
414
|
+
gasUsed: ethers.BigNumber.from(2),
|
|
415
|
+
extraData: "0x",
|
|
416
|
+
baseFeePerGas: ethers.BigNumber.from(123),
|
|
417
|
+
});
|
|
449
418
|
});
|
|
450
419
|
});
|
|
451
420
|
|
|
452
421
|
describe("getSubAccount", () => {
|
|
453
422
|
it("should return the expected payload", async () => {
|
|
454
423
|
expect(
|
|
455
|
-
await RPC_API.getSubAccount(
|
|
456
|
-
fakeCurrency as CryptoCurrency,
|
|
457
|
-
account.freshAddress
|
|
458
|
-
)
|
|
424
|
+
await RPC_API.getSubAccount(fakeCurrency as CryptoCurrency, account.freshAddress),
|
|
459
425
|
).toEqual({
|
|
460
426
|
balance: new BigNumber(420),
|
|
461
427
|
blockHeight: 69,
|
|
@@ -482,8 +448,8 @@ describe("EVM Family", () => {
|
|
|
482
448
|
type: 2,
|
|
483
449
|
chainId: 1,
|
|
484
450
|
nonce: 52,
|
|
485
|
-
} as EvmTransaction
|
|
486
|
-
)
|
|
451
|
+
} as EvmTransaction,
|
|
452
|
+
),
|
|
487
453
|
).toEqual(new BigNumber(420));
|
|
488
454
|
});
|
|
489
455
|
|
|
@@ -503,8 +469,8 @@ describe("EVM Family", () => {
|
|
|
503
469
|
type: 2,
|
|
504
470
|
chainId: 1,
|
|
505
471
|
nonce: 52,
|
|
506
|
-
} as EvmTransaction
|
|
507
|
-
)
|
|
472
|
+
} as EvmTransaction,
|
|
473
|
+
),
|
|
508
474
|
).toEqual(new BigNumber(0));
|
|
509
475
|
});
|
|
510
476
|
|
|
@@ -524,8 +490,8 @@ describe("EVM Family", () => {
|
|
|
524
490
|
type: 2,
|
|
525
491
|
chainId: 1,
|
|
526
492
|
nonce: 52,
|
|
527
|
-
} as EvmTransaction
|
|
528
|
-
)
|
|
493
|
+
} as EvmTransaction,
|
|
494
|
+
),
|
|
529
495
|
).toEqual(new BigNumber(0));
|
|
530
496
|
});
|
|
531
497
|
});
|