@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,11 +1,7 @@
|
|
|
1
1
|
import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
|
|
2
2
|
import { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
3
3
|
import BigNumber from "bignumber.js";
|
|
4
|
-
import {
|
|
5
|
-
getFeesEstimation,
|
|
6
|
-
getGasEstimation,
|
|
7
|
-
getTransactionCount,
|
|
8
|
-
} from "./api/rpc";
|
|
4
|
+
import { getFeesEstimation, getGasEstimation, getTransactionCount } from "./api/rpc";
|
|
9
5
|
import { validateRecipient } from "./getTransactionStatus";
|
|
10
6
|
import { getAdditionalLayer2Fees, getEstimatedFees } from "./logic";
|
|
11
7
|
import { getTransactionData, getTypedTransaction } from "./transaction";
|
|
@@ -18,7 +14,7 @@ import { Transaction as EvmTransaction } from "./types";
|
|
|
18
14
|
*/
|
|
19
15
|
export const prepareCoinTransaction = async (
|
|
20
16
|
account: Account,
|
|
21
|
-
typedTransaction: EvmTransaction
|
|
17
|
+
typedTransaction: EvmTransaction,
|
|
22
18
|
): Promise<EvmTransaction> => {
|
|
23
19
|
// A `useAllAmount` transaction is a specific case of the live, and because we're in the
|
|
24
20
|
// context of a coinTransaction, no smart contract should be involed
|
|
@@ -36,13 +32,10 @@ export const prepareCoinTransaction = async (
|
|
|
36
32
|
gasLimit,
|
|
37
33
|
};
|
|
38
34
|
const estimatedFees = getEstimatedFees(draftTransaction);
|
|
39
|
-
const additionalFees = await getAdditionalLayer2Fees(
|
|
40
|
-
account.currency,
|
|
41
|
-
draftTransaction
|
|
42
|
-
);
|
|
35
|
+
const additionalFees = await getAdditionalLayer2Fees(account.currency, draftTransaction);
|
|
43
36
|
const amount = BigNumber.max(
|
|
44
37
|
account.balance.minus(estimatedFees).minus(additionalFees || 0),
|
|
45
|
-
0
|
|
38
|
+
0,
|
|
46
39
|
);
|
|
47
40
|
|
|
48
41
|
return {
|
|
@@ -58,7 +51,7 @@ export const prepareCoinTransaction = async (
|
|
|
58
51
|
// E.g. A DApp is creating an invalid transaction, swaping more Tokens than the user actually have -> fail
|
|
59
52
|
// This value of 0 should be catched by `getTransactionStatus`
|
|
60
53
|
// and displayed in the UI as `set the gas manually`
|
|
61
|
-
() => new BigNumber(0)
|
|
54
|
+
() => new BigNumber(0),
|
|
62
55
|
);
|
|
63
56
|
const additionalFees = await getAdditionalLayer2Fees(account.currency, {
|
|
64
57
|
...typedTransaction,
|
|
@@ -79,12 +72,10 @@ export const prepareCoinTransaction = async (
|
|
|
79
72
|
export const prepareTokenTransaction = async (
|
|
80
73
|
account: Account,
|
|
81
74
|
tokenAccount: TokenAccount,
|
|
82
|
-
typedTransaction: EvmTransaction
|
|
75
|
+
typedTransaction: EvmTransaction,
|
|
83
76
|
): Promise<EvmTransaction> => {
|
|
84
77
|
const [recipientErrors] = validateRecipient(account, typedTransaction);
|
|
85
|
-
const amount = typedTransaction.useAllAmount
|
|
86
|
-
? tokenAccount.balance
|
|
87
|
-
: typedTransaction.amount;
|
|
78
|
+
const amount = typedTransaction.useAllAmount ? tokenAccount.balance : typedTransaction.amount;
|
|
88
79
|
const data = !Object.keys(recipientErrors).length
|
|
89
80
|
? getTransactionData({ ...typedTransaction, amount })
|
|
90
81
|
: undefined;
|
|
@@ -123,15 +114,29 @@ export const prepareTokenTransaction = async (
|
|
|
123
114
|
*/
|
|
124
115
|
export const prepareTransaction = async (
|
|
125
116
|
account: Account,
|
|
126
|
-
transaction: EvmTransaction
|
|
117
|
+
transaction: EvmTransaction,
|
|
127
118
|
): Promise<EvmTransaction> => {
|
|
128
119
|
const { currency } = account;
|
|
129
120
|
// Get the current network status fees
|
|
130
|
-
const feeData = await
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
121
|
+
const feeData = await (async () => {
|
|
122
|
+
if (transaction.feesStrategy === "custom") {
|
|
123
|
+
return {
|
|
124
|
+
gasPrice: transaction.gasPrice ?? null,
|
|
125
|
+
maxFeePerGas: transaction.maxFeePerGas ?? null,
|
|
126
|
+
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ?? null,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!transaction.feesStrategy) {
|
|
131
|
+
return getFeesEstimation(currency);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const gasOption = transaction.gasOptions?.[transaction.feesStrategy];
|
|
135
|
+
|
|
136
|
+
return gasOption ?? getFeesEstimation(currency);
|
|
137
|
+
})();
|
|
138
|
+
|
|
139
|
+
const subAccount = findSubAccountById(account, transaction.subAccountId || "");
|
|
135
140
|
const isTokenTransaction = subAccount?.type === "TokenAccount";
|
|
136
141
|
const typedTransaction = getTypedTransaction(transaction, feeData);
|
|
137
142
|
|
|
@@ -148,17 +153,11 @@ export const prepareTransaction = async (
|
|
|
148
153
|
*/
|
|
149
154
|
export const prepareForSignOperation = async (
|
|
150
155
|
account: Account,
|
|
151
|
-
transaction: EvmTransaction
|
|
156
|
+
transaction: EvmTransaction,
|
|
152
157
|
): Promise<EvmTransaction> => {
|
|
153
|
-
const nonce = await getTransactionCount(
|
|
154
|
-
account.currency,
|
|
155
|
-
account.freshAddress
|
|
156
|
-
);
|
|
158
|
+
const nonce = await getTransactionCount(account.currency, account.freshAddress);
|
|
157
159
|
|
|
158
|
-
const subAccount = findSubAccountById(
|
|
159
|
-
account,
|
|
160
|
-
transaction.subAccountId || ""
|
|
161
|
-
);
|
|
160
|
+
const subAccount = findSubAccountById(account, transaction.subAccountId || "");
|
|
162
161
|
const isTokenTransaction = subAccount?.type === "TokenAccount";
|
|
163
162
|
|
|
164
163
|
return isTokenTransaction
|
package/src/signOperation.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
|
-
import Eth, { ledgerService } from "@ledgerhq/hw-app-eth";
|
|
3
2
|
import {
|
|
4
3
|
Account,
|
|
5
4
|
SignOperationFnSignature,
|
|
6
5
|
SignOperationEvent,
|
|
6
|
+
DeviceId,
|
|
7
7
|
} from "@ledgerhq/types-live";
|
|
8
|
+
import { ledgerService } from "@ledgerhq/hw-app-eth";
|
|
8
9
|
import { ResolutionConfig } from "@ledgerhq/hw-app-eth/lib/services/types";
|
|
10
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
9
11
|
import { buildOptimisticOperation } from "./buildOptimisticOperation";
|
|
10
12
|
import { prepareForSignOperation } from "./prepareTransaction";
|
|
11
13
|
import { getSerializedTransaction } from "./transaction";
|
|
12
14
|
import { Transaction } from "./types";
|
|
13
|
-
import {
|
|
15
|
+
import { EvmAddress, EvmSignature, EvmSigner } from "./signer";
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Transforms the ECDSA signature paremeter v hexadecimal string received
|
|
@@ -42,86 +44,72 @@ export const applyEIP155 = (vAsHex: string, chainId: number): number => {
|
|
|
42
44
|
* Sign Transaction with Ledger hardware
|
|
43
45
|
*/
|
|
44
46
|
export const buildSignOperation =
|
|
45
|
-
(
|
|
47
|
+
(
|
|
48
|
+
signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>,
|
|
49
|
+
): SignOperationFnSignature<Transaction> =>
|
|
46
50
|
({
|
|
47
51
|
account,
|
|
48
52
|
deviceId,
|
|
49
53
|
transaction,
|
|
50
54
|
}: {
|
|
51
55
|
account: Account;
|
|
52
|
-
deviceId:
|
|
56
|
+
deviceId: DeviceId;
|
|
53
57
|
transaction: Transaction;
|
|
54
58
|
}): Observable<SignOperationEvent> =>
|
|
55
|
-
|
|
56
|
-
(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const preparedTransaction = await prepareForSignOperation(
|
|
60
|
-
account,
|
|
61
|
-
transaction
|
|
62
|
-
);
|
|
63
|
-
const serializedTxHexString =
|
|
64
|
-
getSerializedTransaction(preparedTransaction).slice(2); // Remove 0x prefix
|
|
59
|
+
new Observable(o => {
|
|
60
|
+
async function main() {
|
|
61
|
+
const preparedTransaction = await prepareForSignOperation(account, transaction);
|
|
62
|
+
const serializedTxHexString = getSerializedTransaction(preparedTransaction).slice(2); // Remove 0x prefix
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
resolutionConfig
|
|
79
|
-
);
|
|
64
|
+
// Configure type of resolutions necessary for the clear signing
|
|
65
|
+
const resolutionConfig: ResolutionConfig = {
|
|
66
|
+
externalPlugins: true,
|
|
67
|
+
erc20: true,
|
|
68
|
+
domains: transaction.recipientDomain ? [transaction.recipientDomain] : [],
|
|
69
|
+
};
|
|
70
|
+
// Look for resolutions for external plugins and ERC20
|
|
71
|
+
const resolution = await ledgerService.resolveTransaction(
|
|
72
|
+
serializedTxHexString,
|
|
73
|
+
{},
|
|
74
|
+
resolutionConfig,
|
|
75
|
+
);
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
o.next({
|
|
78
|
+
type: "device-signature-requested",
|
|
79
|
+
});
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
account.freshAddressPath,
|
|
90
|
-
serializedTxHexString,
|
|
91
|
-
resolution
|
|
92
|
-
);
|
|
81
|
+
const sig = (await signerContext(deviceId, signer =>
|
|
82
|
+
// Request signature on the nano
|
|
83
|
+
signer.signTransaction(account.freshAddressPath, serializedTxHexString, resolution),
|
|
84
|
+
)) as EvmSignature;
|
|
93
85
|
|
|
94
|
-
|
|
86
|
+
o.next({ type: "device-signature-granted" }); // Signature is done
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
v: applyEIP155(sig.v, chainId),
|
|
104
|
-
}
|
|
105
|
-
);
|
|
88
|
+
const { chainId = 0 } = account.currency.ethereumLikeInfo || {};
|
|
89
|
+
// Create a new serialized tx with the signature now
|
|
90
|
+
const signature = await getSerializedTransaction(preparedTransaction, {
|
|
91
|
+
r: "0x" + sig.r,
|
|
92
|
+
s: "0x" + sig.s,
|
|
93
|
+
v: applyEIP155(sig.v, chainId),
|
|
94
|
+
});
|
|
106
95
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
96
|
+
const operation = buildOptimisticOperation(account, {
|
|
97
|
+
...transaction,
|
|
98
|
+
nonce: preparedTransaction.nonce,
|
|
99
|
+
});
|
|
111
100
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
101
|
+
o.next({
|
|
102
|
+
type: "signed",
|
|
103
|
+
signedOperation: {
|
|
104
|
+
operation,
|
|
105
|
+
signature,
|
|
106
|
+
expirationDate: null,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
121
110
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
);
|
|
111
|
+
main().then(
|
|
112
|
+
() => o.complete(),
|
|
113
|
+
e => o.error(e),
|
|
114
|
+
);
|
|
115
|
+
});
|
package/src/signer.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DomainServiceResolution } from "@ledgerhq/domain-service/types";
|
|
2
|
+
|
|
3
|
+
export type EvmAddress = {
|
|
4
|
+
publicKey: string;
|
|
5
|
+
address: string;
|
|
6
|
+
chainCode?: string;
|
|
7
|
+
};
|
|
8
|
+
export type EvmSignature = {
|
|
9
|
+
s: string;
|
|
10
|
+
v: string;
|
|
11
|
+
r: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Duplicate type definition from hw-app-eth.
|
|
15
|
+
type LedgerEthTransactionResolution = {
|
|
16
|
+
// device serialized data that contains ERC20 data (hex format)
|
|
17
|
+
erc20Tokens: Array<string>;
|
|
18
|
+
// device serialized data that contains NFT data (hex format)
|
|
19
|
+
nfts: Array<string>;
|
|
20
|
+
// device serialized data that contains external plugin data (hex format)
|
|
21
|
+
externalPlugin: Array<{ payload: string; signature: string }>;
|
|
22
|
+
// device serialized data that contains plugin data (hex format)
|
|
23
|
+
plugin: Array<string>;
|
|
24
|
+
// device serialized data that contain trusted names data (hex format)
|
|
25
|
+
domains: DomainServiceResolution[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export interface EvmSigner {
|
|
29
|
+
getAddress(path: string, boolDisplay?: boolean, boolChaincode?: boolean): Promise<EvmAddress>;
|
|
30
|
+
signTransaction(
|
|
31
|
+
path: string,
|
|
32
|
+
rawTxHex: string,
|
|
33
|
+
resolution?: LedgerEthTransactionResolution | null,
|
|
34
|
+
): Promise<EvmSignature>;
|
|
35
|
+
}
|
package/src/specs.ts
CHANGED
|
@@ -2,18 +2,11 @@ import expect from "expect";
|
|
|
2
2
|
import invariant from "invariant";
|
|
3
3
|
import sample from "lodash/sample";
|
|
4
4
|
import BigNumber from "bignumber.js";
|
|
5
|
-
import {
|
|
6
|
-
MutationSpec,
|
|
7
|
-
TransactionDestinationTestInput,
|
|
8
|
-
} from "@ledgerhq/coin-framework/bot/types";
|
|
5
|
+
import { MutationSpec, TransactionDestinationTestInput } from "@ledgerhq/coin-framework/bot/types";
|
|
9
6
|
import { DeviceModelId } from "@ledgerhq/devices";
|
|
10
7
|
import { CryptoCurrencyIds } from "@ledgerhq/types-live";
|
|
11
8
|
import { cryptocurrenciesById } from "@ledgerhq/cryptoassets/currencies";
|
|
12
|
-
import {
|
|
13
|
-
botTest,
|
|
14
|
-
genericTestDestination,
|
|
15
|
-
pickSiblings,
|
|
16
|
-
} from "@ledgerhq/coin-framework/bot/specs";
|
|
9
|
+
import { botTest, genericTestDestination, pickSiblings } from "@ledgerhq/coin-framework/bot/specs";
|
|
17
10
|
import {
|
|
18
11
|
getCryptoCurrencyById,
|
|
19
12
|
parseCurrencyUnit,
|
|
@@ -43,9 +36,7 @@ const minBalancePerCurrencyId: Record<CryptoCurrencyIds, BigNumber> = {
|
|
|
43
36
|
*
|
|
44
37
|
* ⚠️ Some blockchains specific rules are included
|
|
45
38
|
*/
|
|
46
|
-
const testCoinDestination = (
|
|
47
|
-
args: TransactionDestinationTestInput<EvmTransaction>
|
|
48
|
-
) => {
|
|
39
|
+
const testCoinDestination = (args: TransactionDestinationTestInput<EvmTransaction>) => {
|
|
49
40
|
const { sendingAccount } = args;
|
|
50
41
|
const { currency } = sendingAccount;
|
|
51
42
|
|
|
@@ -83,17 +74,14 @@ const testCoinBalance: MutationSpec<EvmTransaction>["test"] = ({
|
|
|
83
74
|
// value + gasLimit * gasPrice <-- gasPrice can be wrong here.
|
|
84
75
|
const underValuedFeesCurrencies = ["optimism", "optimism_goerli"];
|
|
85
76
|
const overValuedFeesCurrencies = ["arbitrum", "arbitrum_goerli"];
|
|
86
|
-
const currenciesWithFlakyBehaviour = [
|
|
87
|
-
...underValuedFeesCurrencies,
|
|
88
|
-
...overValuedFeesCurrencies,
|
|
89
|
-
];
|
|
77
|
+
const currenciesWithFlakyBehaviour = [...underValuedFeesCurrencies, ...overValuedFeesCurrencies];
|
|
90
78
|
|
|
91
79
|
// Classic test verifying exactly the balance
|
|
92
80
|
if (!currenciesWithFlakyBehaviour.includes(account.currency.id)) {
|
|
93
81
|
botTest("account balance moved with operation value", () =>
|
|
94
82
|
expect(account.balance.toString()).toBe(
|
|
95
|
-
accountBeforeTransaction.balance.minus(operation.value).toString()
|
|
96
|
-
)
|
|
83
|
+
accountBeforeTransaction.balance.minus(operation.value).toString(),
|
|
84
|
+
),
|
|
97
85
|
);
|
|
98
86
|
} else {
|
|
99
87
|
// fallback test verifying the balance moved between the maximum and minimum possible values of the operation
|
|
@@ -105,7 +93,7 @@ const testCoinBalance: MutationSpec<EvmTransaction>["test"] = ({
|
|
|
105
93
|
// has lost *at least* the operation value + fee
|
|
106
94
|
if (underValuedFeesCurrencies.includes(account.currency.id)) {
|
|
107
95
|
const maxBalance = accountBeforeTransaction.balance.minus(
|
|
108
|
-
operation.value.minus(operation.fee) // type OUT operations value includes fees so we remove it
|
|
96
|
+
operation.value.minus(operation.fee), // type OUT operations value includes fees so we remove it
|
|
109
97
|
);
|
|
110
98
|
|
|
111
99
|
expect({
|
|
@@ -121,10 +109,10 @@ const testCoinBalance: MutationSpec<EvmTransaction>["test"] = ({
|
|
|
121
109
|
// previous balance minus operation value + fee
|
|
122
110
|
if (overValuedFeesCurrencies.includes(account.currency.id)) {
|
|
123
111
|
const minBalance = accountBeforeTransaction.balance.minus(
|
|
124
|
-
operation.value // type OUT operations value includes fees
|
|
112
|
+
operation.value, // type OUT operations value includes fees
|
|
125
113
|
);
|
|
126
114
|
const maxBalance = accountBeforeTransaction.balance.minus(
|
|
127
|
-
operation.value.minus(operation.fee)
|
|
115
|
+
operation.value.minus(operation.fee),
|
|
128
116
|
);
|
|
129
117
|
|
|
130
118
|
expect({
|
|
@@ -135,7 +123,7 @@ const testCoinBalance: MutationSpec<EvmTransaction>["test"] = ({
|
|
|
135
123
|
lessThanMaxBalance: true,
|
|
136
124
|
});
|
|
137
125
|
}
|
|
138
|
-
}
|
|
126
|
+
},
|
|
139
127
|
);
|
|
140
128
|
}
|
|
141
129
|
};
|
|
@@ -146,10 +134,9 @@ const transactionCheck =
|
|
|
146
134
|
const currency = getCryptoCurrencyById(currencyId);
|
|
147
135
|
invariant(
|
|
148
136
|
maxSpendable.gt(
|
|
149
|
-
minBalancePerCurrencyId[currency.id] ||
|
|
150
|
-
parseCurrencyUnit(currency.units[0], "1")
|
|
137
|
+
minBalancePerCurrencyId[currency.id] || parseCurrencyUnit(currency.units[0], "1"),
|
|
151
138
|
),
|
|
152
|
-
`${currencyId} balance is too low
|
|
139
|
+
`${currencyId} balance is too low`,
|
|
153
140
|
);
|
|
154
141
|
};
|
|
155
142
|
|
|
@@ -187,15 +174,13 @@ const evmBasicMutations: ({
|
|
|
187
174
|
// workaround for buggy explorer behavior (nodes desync)
|
|
188
175
|
invariant(
|
|
189
176
|
Date.now() - operation.date.getTime() > 60000,
|
|
190
|
-
"operation time to be older than 60s"
|
|
177
|
+
"operation time to be older than 60s",
|
|
191
178
|
);
|
|
192
179
|
const estimatedGas = transaction.gasLimit.times(
|
|
193
|
-
transaction.gasPrice || transaction.maxFeePerGas || 0
|
|
180
|
+
transaction.gasPrice || transaction.maxFeePerGas || 0,
|
|
194
181
|
);
|
|
195
182
|
botTest("operation fee is not exceeding estimated gas", () =>
|
|
196
|
-
expect(operation.fee.toNumber()).toBeLessThanOrEqual(
|
|
197
|
-
estimatedGas.toNumber()
|
|
198
|
-
)
|
|
183
|
+
expect(operation.fee.toNumber()).toBeLessThanOrEqual(estimatedGas.toNumber()),
|
|
199
184
|
);
|
|
200
185
|
|
|
201
186
|
testCoinBalance({
|
|
@@ -239,15 +224,13 @@ const evmBasicMutations: ({
|
|
|
239
224
|
// workaround for buggy explorer behavior (nodes desync)
|
|
240
225
|
invariant(
|
|
241
226
|
Date.now() - operation.date.getTime() > 60000,
|
|
242
|
-
"operation time to be older than 60s"
|
|
227
|
+
"operation time to be older than 60s",
|
|
243
228
|
);
|
|
244
229
|
const estimatedGas = transaction.gasLimit.times(
|
|
245
|
-
transaction.gasPrice || transaction.maxFeePerGas || 0
|
|
230
|
+
transaction.gasPrice || transaction.maxFeePerGas || 0,
|
|
246
231
|
);
|
|
247
232
|
botTest("operation fee is not exceeding estimated gas", () =>
|
|
248
|
-
expect(operation.fee.toNumber()).toBeLessThanOrEqual(
|
|
249
|
-
estimatedGas.toNumber()
|
|
250
|
-
)
|
|
233
|
+
expect(operation.fee.toNumber()).toBeLessThanOrEqual(estimatedGas.toNumber()),
|
|
251
234
|
);
|
|
252
235
|
|
|
253
236
|
testCoinBalance({
|
|
@@ -264,9 +247,7 @@ const evmBasicMutations: ({
|
|
|
264
247
|
name: "move some ERC20",
|
|
265
248
|
maxRun: 1,
|
|
266
249
|
transaction: ({ account, siblings, bridge }) => {
|
|
267
|
-
const erc20Account = sample(
|
|
268
|
-
(account.subAccounts || []).filter((a) => a.balance.gt(0))
|
|
269
|
-
);
|
|
250
|
+
const erc20Account = sample((account.subAccounts || []).filter(a => a.balance.gt(0)));
|
|
270
251
|
invariant(erc20Account, "no erc20 account");
|
|
271
252
|
const sibling = pickSiblings(siblings, 3);
|
|
272
253
|
const recipient = sibling.freshAddress;
|
|
@@ -282,9 +263,7 @@ const evmBasicMutations: ({
|
|
|
282
263
|
useAllAmount: true,
|
|
283
264
|
}
|
|
284
265
|
: {
|
|
285
|
-
amount: erc20Account!.balance
|
|
286
|
-
.times(Math.random())
|
|
287
|
-
.integerValue(),
|
|
266
|
+
amount: erc20Account!.balance.times(Math.random()).integerValue(),
|
|
288
267
|
},
|
|
289
268
|
],
|
|
290
269
|
};
|
|
@@ -293,28 +272,24 @@ const evmBasicMutations: ({
|
|
|
293
272
|
// workaround for buggy explorer behavior (nodes desync)
|
|
294
273
|
invariant(
|
|
295
274
|
Date.now() - operation.date.getTime() > 60000,
|
|
296
|
-
"operation time to be older than 60s"
|
|
275
|
+
"operation time to be older than 60s",
|
|
297
276
|
);
|
|
298
277
|
invariant(accountBeforeTransaction.subAccounts, "sub accounts before");
|
|
299
278
|
const erc20accountBefore = accountBeforeTransaction.subAccounts?.find(
|
|
300
|
-
|
|
279
|
+
s => s.id === transaction.subAccountId,
|
|
301
280
|
);
|
|
302
281
|
invariant(erc20accountBefore, "erc20 acc was here before");
|
|
303
282
|
invariant(account.subAccounts, "sub accounts");
|
|
304
|
-
const erc20account = account.subAccounts!.find(
|
|
305
|
-
(s) => s.id === transaction.subAccountId
|
|
306
|
-
);
|
|
283
|
+
const erc20account = account.subAccounts!.find(s => s.id === transaction.subAccountId);
|
|
307
284
|
invariant(erc20account, "erc20 acc is still here");
|
|
308
285
|
|
|
309
286
|
if (transaction.useAllAmount) {
|
|
310
|
-
botTest("erc20 account is empty", () =>
|
|
311
|
-
expect(erc20account!.balance.toString()).toBe("0")
|
|
312
|
-
);
|
|
287
|
+
botTest("erc20 account is empty", () => expect(erc20account!.balance.toString()).toBe("0"));
|
|
313
288
|
} else {
|
|
314
289
|
botTest("account balance moved with tx amount", () =>
|
|
315
290
|
expect(erc20account!.balance.toString()).toBe(
|
|
316
|
-
erc20accountBefore!.balance.minus(transaction.amount).toString()
|
|
317
|
-
)
|
|
291
|
+
erc20accountBefore!.balance.minus(transaction.amount).toString(),
|
|
292
|
+
),
|
|
318
293
|
);
|
|
319
294
|
}
|
|
320
295
|
},
|
|
@@ -322,7 +297,7 @@ const evmBasicMutations: ({
|
|
|
322
297
|
];
|
|
323
298
|
|
|
324
299
|
export default Object.values(cryptocurrenciesById)
|
|
325
|
-
.filter(
|
|
300
|
+
.filter(currency => currency.family === "evm")
|
|
326
301
|
.reduce((acc, currency) => {
|
|
327
302
|
// @ts-expect-error FIXME: fix typings
|
|
328
303
|
acc[currency.id] = {
|
|
@@ -8,75 +8,66 @@ import type { DeviceAction } from "@ledgerhq/coin-framework/bot/types";
|
|
|
8
8
|
import type { Transaction } from "./types";
|
|
9
9
|
|
|
10
10
|
// FIXME: fix types
|
|
11
|
-
const maxFeesExpectedValue = ({
|
|
12
|
-
account,
|
|
13
|
-
status,
|
|
14
|
-
}: {
|
|
15
|
-
account: any;
|
|
16
|
-
status: any;
|
|
17
|
-
}) => formatDeviceAmount(account.currency, status.estimatedFees);
|
|
11
|
+
const maxFeesExpectedValue = ({ account, status }: { account: any; status: any }) =>
|
|
12
|
+
formatDeviceAmount(account.currency, status.estimatedFees);
|
|
18
13
|
|
|
19
|
-
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const subAccount = findSubAccountById(
|
|
35
|
-
account,
|
|
36
|
-
transaction.subAccountId || ""
|
|
37
|
-
);
|
|
14
|
+
export const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
|
|
15
|
+
steps: [
|
|
16
|
+
{
|
|
17
|
+
title: "Review",
|
|
18
|
+
button: SpeculosButton.RIGHT,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
title: "Type",
|
|
22
|
+
button: SpeculosButton.RIGHT,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: "Amount",
|
|
26
|
+
button: SpeculosButton.RIGHT,
|
|
27
|
+
expectedValue: ({ account, status, transaction }) => {
|
|
28
|
+
const subAccount = findSubAccountById(account, transaction.subAccountId || "");
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
if (subAccount && subAccount.type === "TokenAccount") {
|
|
31
|
+
return formatDeviceAmount(subAccount.token, status.amount);
|
|
32
|
+
}
|
|
42
33
|
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
title: "Contract",
|
|
48
|
-
button: SpeculosButton.RIGHT,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
title: "Network",
|
|
52
|
-
button: SpeculosButton.RIGHT,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
title: "Max fees",
|
|
56
|
-
button: SpeculosButton.RIGHT,
|
|
57
|
-
expectedValue: maxFeesExpectedValue,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
// Legacy (ETC..)
|
|
61
|
-
title: "Max Fees",
|
|
62
|
-
button: SpeculosButton.RIGHT,
|
|
63
|
-
expectedValue: maxFeesExpectedValue,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
title: "Address",
|
|
67
|
-
button: SpeculosButton.RIGHT,
|
|
68
|
-
expectedValue: ({ transaction }) => transaction.recipient,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
title: "Accept",
|
|
72
|
-
button: SpeculosButton.BOTH,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
title: "Approve",
|
|
76
|
-
button: SpeculosButton.BOTH,
|
|
34
|
+
return formatDeviceAmount(account.currency, status.amount);
|
|
77
35
|
},
|
|
78
|
-
|
|
79
|
-
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: "Contract",
|
|
39
|
+
button: SpeculosButton.RIGHT,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: "Network",
|
|
43
|
+
button: SpeculosButton.RIGHT,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: "Max fees",
|
|
47
|
+
button: SpeculosButton.RIGHT,
|
|
48
|
+
expectedValue: maxFeesExpectedValue,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
// Legacy (ETC..)
|
|
52
|
+
title: "Max Fees",
|
|
53
|
+
button: SpeculosButton.RIGHT,
|
|
54
|
+
expectedValue: maxFeesExpectedValue,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
title: "Address",
|
|
58
|
+
button: SpeculosButton.RIGHT,
|
|
59
|
+
expectedValue: ({ transaction }) => transaction.recipient,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: "Accept",
|
|
63
|
+
button: SpeculosButton.BOTH,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
title: "Approve",
|
|
67
|
+
button: SpeculosButton.BOTH,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
});
|
|
80
71
|
|
|
81
72
|
export default {
|
|
82
73
|
acceptTransaction,
|