@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
package/src/bridge/js.ts
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
2
2
|
import {
|
|
3
|
-
DeviceCommunication,
|
|
4
3
|
makeAccountBridgeReceive,
|
|
5
4
|
makeScanAccounts,
|
|
6
5
|
} from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
6
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
7
7
|
import type { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
|
|
8
8
|
import { broadcast } from "../broadcast";
|
|
9
9
|
import { createTransaction } from "../createTransaction";
|
|
10
10
|
import { estimateMaxSpendable } from "../estimateMaxSpendable";
|
|
11
11
|
import { getTransactionStatus } from "../getTransactionStatus";
|
|
12
|
-
import
|
|
12
|
+
import resolver from "../hw-getAddress";
|
|
13
13
|
import { hydrate, preload } from "../preload";
|
|
14
14
|
import { prepareTransaction } from "../prepareTransaction";
|
|
15
15
|
import { buildSignOperation } from "../signOperation";
|
|
16
16
|
import { getAccountShape, sync } from "../synchronization";
|
|
17
|
+
import { EvmAddress, EvmSignature, EvmSigner } from "../signer";
|
|
17
18
|
import type { Transaction as EvmTransaction, Transaction } from "../types";
|
|
18
19
|
|
|
19
20
|
const updateTransaction: AccountBridge<EvmTransaction>["updateTransaction"] = (
|
|
20
21
|
transaction,
|
|
21
|
-
patch
|
|
22
|
+
patch,
|
|
22
23
|
) => {
|
|
23
24
|
return { ...transaction, ...patch } as EvmTransaction;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export function buildCurrencyBridge(
|
|
27
|
-
|
|
28
|
+
signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>,
|
|
28
29
|
): CurrencyBridge {
|
|
30
|
+
const getAddress = resolver(signerContext);
|
|
31
|
+
|
|
29
32
|
const scanAccounts = makeScanAccounts({
|
|
30
33
|
getAccountShape,
|
|
31
|
-
deviceCommunication,
|
|
32
34
|
getAddressFn: getAddress,
|
|
33
35
|
});
|
|
34
36
|
|
|
@@ -40,13 +42,12 @@ export function buildCurrencyBridge(
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
export function buildAccountBridge(
|
|
43
|
-
|
|
45
|
+
signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>,
|
|
44
46
|
): AccountBridge<Transaction> {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
const signOperation = buildSignOperation(deviceCommunication);
|
|
47
|
+
const getAddress = resolver(signerContext);
|
|
48
|
+
|
|
49
|
+
const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress));
|
|
50
|
+
const signOperation = buildSignOperation(signerContext);
|
|
50
51
|
|
|
51
52
|
return {
|
|
52
53
|
createTransaction,
|
|
@@ -61,17 +62,9 @@ export function buildAccountBridge(
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
* FIXME: unsued network and cacheFn are passed to createBridges because of how the
|
|
66
|
-
* libs/ledger-live-common/scripts/sync-families-dispatch.mjs script works.
|
|
67
|
-
*/
|
|
68
|
-
export function createBridges(
|
|
69
|
-
deviceCommunication: DeviceCommunication,
|
|
70
|
-
_network: unknown,
|
|
71
|
-
_cacheFn: unknown
|
|
72
|
-
) {
|
|
65
|
+
export function createBridges(signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>) {
|
|
73
66
|
return {
|
|
74
|
-
currencyBridge: buildCurrencyBridge(
|
|
75
|
-
accountBridge: buildAccountBridge(
|
|
67
|
+
currencyBridge: buildCurrencyBridge(signerContext),
|
|
68
|
+
accountBridge: buildAccountBridge(signerContext),
|
|
76
69
|
};
|
|
77
70
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { FeeTooHigh } from "@ledgerhq/errors";
|
|
2
|
-
import type {
|
|
3
|
-
AccountRaw,
|
|
4
|
-
CurrenciesData,
|
|
5
|
-
DatasetTest,
|
|
6
|
-
} from "@ledgerhq/types-live";
|
|
2
|
+
import type { AccountRaw, CurrenciesData, DatasetTest } from "@ledgerhq/types-live";
|
|
7
3
|
import { BigNumber } from "bignumber.js";
|
|
8
4
|
import ethereumScanAccounts1 from "./datasets/ethereum.scanAccounts.1";
|
|
9
5
|
import { ethereum1 } from "./datasets/ethereum1";
|
|
@@ -54,10 +50,7 @@ const ethereum: CurrenciesData<Transaction> = {
|
|
|
54
50
|
}),
|
|
55
51
|
expectedStatus: (account, _, status) => {
|
|
56
52
|
return {
|
|
57
|
-
amount: BigNumber.max(
|
|
58
|
-
account.balance.minus(status.estimatedFees),
|
|
59
|
-
0
|
|
60
|
-
),
|
|
53
|
+
amount: BigNumber.max(account.balance.minus(status.estimatedFees), 0),
|
|
61
54
|
errors: {},
|
|
62
55
|
warnings: {},
|
|
63
56
|
};
|
|
@@ -77,7 +70,7 @@ export const dataset: DatasetTest<Transaction> = {
|
|
|
77
70
|
|
|
78
71
|
describe("EVM bridge", () => {
|
|
79
72
|
test.todo(
|
|
80
|
-
"This is an empty test to make jest command pass. Remove it once there is a real test."
|
|
73
|
+
"This is an empty test to make jest command pass. Remove it once there is a real test.",
|
|
81
74
|
);
|
|
82
75
|
});
|
|
83
76
|
|
package/src/broadcast.ts
CHANGED
|
@@ -19,20 +19,16 @@ export const broadcast: AccountBridge<EvmTransaction>["broadcast"] = async ({
|
|
|
19
19
|
blockNumber: txResponse.blockNumber,
|
|
20
20
|
blockHeight: txResponse.blockNumber,
|
|
21
21
|
blockHash: txResponse.blockHash,
|
|
22
|
-
date: new Date(
|
|
23
|
-
txResponse.timestamp ? txResponse.timestamp * 1000 : Date.now()
|
|
24
|
-
),
|
|
22
|
+
date: new Date(txResponse.timestamp ? txResponse.timestamp * 1000 : Date.now()),
|
|
25
23
|
subOperations:
|
|
26
|
-
operation.subOperations?.map(
|
|
24
|
+
operation.subOperations?.map(subOp => ({
|
|
27
25
|
...subOp,
|
|
28
26
|
id: encodeOperationId(subOp.accountId, txResponse.hash, subOp.type),
|
|
29
27
|
hash: txResponse.hash,
|
|
30
28
|
blockNumber: txResponse.blockNumber,
|
|
31
29
|
blockHeight: txResponse.blockNumber,
|
|
32
30
|
blockHash: txResponse.blockHash,
|
|
33
|
-
date: new Date(
|
|
34
|
-
txResponse.timestamp ? txResponse.timestamp * 1000 : Date.now()
|
|
35
|
-
),
|
|
31
|
+
date: new Date(txResponse.timestamp ? txResponse.timestamp * 1000 : Date.now()),
|
|
36
32
|
})) || [],
|
|
37
33
|
} as Operation;
|
|
38
34
|
};
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
|
|
2
2
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
3
|
-
import {
|
|
4
|
-
Account,
|
|
5
|
-
Operation,
|
|
6
|
-
OperationType,
|
|
7
|
-
TokenAccount,
|
|
8
|
-
} from "@ledgerhq/types-live";
|
|
3
|
+
import { Account, Operation, OperationType, TokenAccount } from "@ledgerhq/types-live";
|
|
9
4
|
import BigNumber from "bignumber.js";
|
|
10
5
|
import eip55 from "eip55";
|
|
11
6
|
import { getEstimatedFees } from "./logic";
|
|
@@ -17,7 +12,7 @@ import { Transaction as EvmTransaction } from "./types";
|
|
|
17
12
|
export const buildOptimisticCoinOperation = (
|
|
18
13
|
account: Account,
|
|
19
14
|
transaction: EvmTransaction,
|
|
20
|
-
transactionType?: OperationType
|
|
15
|
+
transactionType?: OperationType,
|
|
21
16
|
): Operation => {
|
|
22
17
|
const type = transactionType ?? "OUT";
|
|
23
18
|
const estimatedFees = getEstimatedFees(transaction);
|
|
@@ -49,13 +44,11 @@ export const buildOptimisticCoinOperation = (
|
|
|
49
44
|
export const buildOptimisticTokenOperation = (
|
|
50
45
|
account: Account,
|
|
51
46
|
tokenAccount: TokenAccount,
|
|
52
|
-
transaction: EvmTransaction
|
|
47
|
+
transaction: EvmTransaction,
|
|
53
48
|
): Operation => {
|
|
54
49
|
const type = "OUT";
|
|
55
50
|
const estimatedFees = getEstimatedFees(transaction);
|
|
56
|
-
const value = transaction.useAllAmount
|
|
57
|
-
? tokenAccount.balance
|
|
58
|
-
: transaction.amount;
|
|
51
|
+
const value = transaction.useAllAmount ? tokenAccount.balance : transaction.amount;
|
|
59
52
|
|
|
60
53
|
const coinOperation = buildOptimisticCoinOperation(
|
|
61
54
|
account,
|
|
@@ -64,7 +57,7 @@ export const buildOptimisticTokenOperation = (
|
|
|
64
57
|
recipient: tokenAccount.token.contractAddress,
|
|
65
58
|
amount: new BigNumber(0),
|
|
66
59
|
},
|
|
67
|
-
"FEES"
|
|
60
|
+
"FEES",
|
|
68
61
|
);
|
|
69
62
|
// keys marked with a <-- will be updated by the broadcast method
|
|
70
63
|
const operation: Operation = {
|
|
@@ -97,12 +90,9 @@ export const buildOptimisticTokenOperation = (
|
|
|
97
90
|
*/
|
|
98
91
|
export const buildOptimisticOperation = (
|
|
99
92
|
account: Account,
|
|
100
|
-
transaction: EvmTransaction
|
|
93
|
+
transaction: EvmTransaction,
|
|
101
94
|
): Operation => {
|
|
102
|
-
const subAccount = findSubAccountById(
|
|
103
|
-
account,
|
|
104
|
-
transaction?.subAccountId || ""
|
|
105
|
-
);
|
|
95
|
+
const subAccount = findSubAccountById(account, transaction?.subAccountId || "");
|
|
106
96
|
const isTokenTransaction = subAccount?.type === "TokenAccount";
|
|
107
97
|
|
|
108
98
|
return isTokenTransaction
|
package/src/cli-transaction.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { NetworkRequestCall } from "@ledgerhq/coin-framework/network";
|
|
2
|
-
import { LRUCacheFn } from "@ledgerhq/coin-framework/cache";
|
|
3
|
-
|
|
4
1
|
// Needed by sync-families-dispatch script
|
|
5
2
|
// libs/ledger-live-common/scripts/sync-families-dispatch.mjs
|
|
6
|
-
export default function makeCliTools(
|
|
7
|
-
_network: NetworkRequestCall,
|
|
8
|
-
_cache: LRUCacheFn
|
|
9
|
-
) {
|
|
3
|
+
export default function makeCliTools() {
|
|
10
4
|
return {};
|
|
11
5
|
}
|
package/src/createTransaction.ts
CHANGED
|
@@ -8,18 +8,17 @@ import { DEFAULT_GAS_LIMIT } from "./transaction";
|
|
|
8
8
|
* By default the transaction is an EIP-1559 transaction.
|
|
9
9
|
* @see prepareTransaction that will make sure it's compatible or not
|
|
10
10
|
*/
|
|
11
|
-
export const createTransaction: AccountBridge<EvmTransaction>["createTransaction"] =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
11
|
+
export const createTransaction: AccountBridge<EvmTransaction>["createTransaction"] = account => ({
|
|
12
|
+
family: "evm",
|
|
13
|
+
mode: "send",
|
|
14
|
+
amount: new BigNumber(0),
|
|
15
|
+
useAllAmount: false,
|
|
16
|
+
recipient: "",
|
|
17
|
+
maxFeePerGas: new BigNumber(0),
|
|
18
|
+
maxPriorityFeePerGas: new BigNumber(0),
|
|
19
|
+
gasLimit: DEFAULT_GAS_LIMIT,
|
|
20
|
+
nonce: account.operationsCount + 1,
|
|
21
|
+
chainId: (account as Account).currency?.ethereumLikeInfo?.chainId || 0,
|
|
22
|
+
feesStrategy: "medium",
|
|
23
|
+
type: 2,
|
|
24
|
+
});
|
package/src/errors.ts
CHANGED
|
@@ -3,3 +3,9 @@ import { createCustomErrorClass } from "@ledgerhq/errors";
|
|
|
3
3
|
export const EtherscanAPIError = createCustomErrorClass("EtherscanAPIError");
|
|
4
4
|
export const GasEstimationError = createCustomErrorClass("GasEstimationError");
|
|
5
5
|
export const InsufficientFunds = createCustomErrorClass("InsufficientFunds");
|
|
6
|
+
|
|
7
|
+
// GasTracker errors
|
|
8
|
+
export const NoGasTrackerFound = createCustomErrorClass("NoGasTrackerFound");
|
|
9
|
+
export const GasTrackerDoesNotSupportEIP1559 = createCustomErrorClass(
|
|
10
|
+
"GasTrackerDoesNotSupportEIP1559",
|
|
11
|
+
);
|
|
@@ -4,16 +4,19 @@ import { createTransaction } from "./createTransaction";
|
|
|
4
4
|
import { prepareTransaction } from "./prepareTransaction";
|
|
5
5
|
import { Transaction as EvmTransaction } from "./types";
|
|
6
6
|
|
|
7
|
-
export const estimateMaxSpendable: AccountBridge<EvmTransaction>["estimateMaxSpendable"] =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
export const estimateMaxSpendable: AccountBridge<EvmTransaction>["estimateMaxSpendable"] = async ({
|
|
8
|
+
account,
|
|
9
|
+
parentAccount,
|
|
10
|
+
transaction,
|
|
11
|
+
}) => {
|
|
12
|
+
const mainAccount = getMainAccount(account, parentAccount);
|
|
13
|
+
const estimatedTx = {
|
|
14
|
+
...createTransaction(mainAccount),
|
|
15
|
+
...transaction,
|
|
16
|
+
useAllAmount: true,
|
|
17
|
+
} as EvmTransaction;
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
const { amount } = await prepareTransaction(mainAccount, estimatedTx);
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
return amount;
|
|
22
|
+
};
|
|
@@ -13,11 +13,7 @@ import { ethers } from "ethers";
|
|
|
13
13
|
import BigNumber from "bignumber.js";
|
|
14
14
|
import { Account, AccountBridge, SubAccount } from "@ledgerhq/types-live";
|
|
15
15
|
import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
|
|
16
|
-
import {
|
|
17
|
-
eip1559TransactionHasFees,
|
|
18
|
-
getEstimatedFees,
|
|
19
|
-
legacyTransactionHasFees,
|
|
20
|
-
} from "./logic";
|
|
16
|
+
import { eip1559TransactionHasFees, getEstimatedFees, legacyTransactionHasFees } from "./logic";
|
|
21
17
|
import {
|
|
22
18
|
EvmTransactionEIP1559,
|
|
23
19
|
EvmTransactionLegacy,
|
|
@@ -40,7 +36,7 @@ const ethAddressRegEx = /^(0x)?[0-9a-fA-F]{40}$/;
|
|
|
40
36
|
*/
|
|
41
37
|
export const validateRecipient = (
|
|
42
38
|
account: Account,
|
|
43
|
-
tx: EvmTransaction
|
|
39
|
+
tx: EvmTransaction,
|
|
44
40
|
): Array<ValidationIssues> => {
|
|
45
41
|
const errors: ValidationIssues = {};
|
|
46
42
|
const warnings: ValidationIssues = {};
|
|
@@ -79,7 +75,7 @@ export const validateRecipient = (
|
|
|
79
75
|
export const validateAmount = (
|
|
80
76
|
account: Account | SubAccount,
|
|
81
77
|
transaction: EvmTransaction,
|
|
82
|
-
totalSpent: BigNumber
|
|
78
|
+
totalSpent: BigNumber,
|
|
83
79
|
): Array<ValidationIssues> => {
|
|
84
80
|
const errors: ValidationIssues = {};
|
|
85
81
|
const warnings: ValidationIssues = {};
|
|
@@ -92,10 +88,7 @@ export const validateAmount = (
|
|
|
92
88
|
const canHaveZeroAmount = isSmartContractInteraction && transactionHasFees;
|
|
93
89
|
|
|
94
90
|
// if no amount or 0
|
|
95
|
-
if (
|
|
96
|
-
(!transaction.amount || transaction.amount.isZero()) &&
|
|
97
|
-
!canHaveZeroAmount
|
|
98
|
-
) {
|
|
91
|
+
if ((!transaction.amount || transaction.amount.isZero()) && !canHaveZeroAmount) {
|
|
99
92
|
errors.amount = new AmountRequired(); // "Amount required"
|
|
100
93
|
} else if (totalSpent.isGreaterThan(account.balance)) {
|
|
101
94
|
// if not enough to make the transaction
|
|
@@ -111,7 +104,7 @@ export const validateGas = (
|
|
|
111
104
|
account: Account,
|
|
112
105
|
tx: EvmTransaction,
|
|
113
106
|
gasLimit: BigNumber,
|
|
114
|
-
estimatedFees: BigNumber
|
|
107
|
+
estimatedFees: BigNumber,
|
|
115
108
|
): Array<ValidationIssues> => {
|
|
116
109
|
const errors: ValidationIssues = {};
|
|
117
110
|
const warnings: ValidationIssues = {};
|
|
@@ -141,46 +134,42 @@ export const validateGas = (
|
|
|
141
134
|
/**
|
|
142
135
|
* Validate a transaction and get all possibles errors and warnings about it
|
|
143
136
|
*/
|
|
144
|
-
export const getTransactionStatus: AccountBridge<EvmTransaction>["getTransactionStatus"] =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const errors: ValidationIssues = {
|
|
167
|
-
...recipientErr,
|
|
168
|
-
...gasErr,
|
|
169
|
-
...amountErr,
|
|
170
|
-
};
|
|
171
|
-
const warnings: ValidationIssues = {
|
|
172
|
-
...recipientWarn,
|
|
173
|
-
...gasWarn,
|
|
174
|
-
...amountWarn,
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
errors,
|
|
179
|
-
warnings,
|
|
180
|
-
estimatedFees,
|
|
181
|
-
amount,
|
|
182
|
-
totalSpent,
|
|
183
|
-
};
|
|
137
|
+
export const getTransactionStatus: AccountBridge<EvmTransaction>["getTransactionStatus"] = async (
|
|
138
|
+
account,
|
|
139
|
+
tx,
|
|
140
|
+
) => {
|
|
141
|
+
const subAccount = findSubAccountById(account, tx.subAccountId || "");
|
|
142
|
+
const isTokenTransaction = subAccount?.type === "TokenAccount";
|
|
143
|
+
const { gasLimit, additionalFees, amount } = tx;
|
|
144
|
+
const estimatedFees = getEstimatedFees(tx);
|
|
145
|
+
const totalFees = estimatedFees.plus(additionalFees || 0);
|
|
146
|
+
const totalSpent = isTokenTransaction ? tx.amount : tx.amount.plus(totalFees);
|
|
147
|
+
|
|
148
|
+
// Recipient related errors and warnings
|
|
149
|
+
const [recipientErr, recipientWarn] = validateRecipient(account, tx);
|
|
150
|
+
// Amount related errors and warnings
|
|
151
|
+
const [amountErr, amountWarn] = validateAmount(subAccount || account, tx, totalSpent);
|
|
152
|
+
// Gas related errors and warnings
|
|
153
|
+
const [gasErr, gasWarn] = validateGas(account, tx, gasLimit, totalFees);
|
|
154
|
+
|
|
155
|
+
const errors: ValidationIssues = {
|
|
156
|
+
...recipientErr,
|
|
157
|
+
...gasErr,
|
|
158
|
+
...amountErr,
|
|
184
159
|
};
|
|
160
|
+
const warnings: ValidationIssues = {
|
|
161
|
+
...recipientWarn,
|
|
162
|
+
...gasWarn,
|
|
163
|
+
...amountWarn,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
errors,
|
|
168
|
+
warnings,
|
|
169
|
+
estimatedFees,
|
|
170
|
+
amount,
|
|
171
|
+
totalSpent,
|
|
172
|
+
};
|
|
173
|
+
};
|
|
185
174
|
|
|
186
175
|
export default getTransactionStatus;
|
package/src/hw-getAddress.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import type { Resolver } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
2
|
-
import Eth from "@ledgerhq/hw-app-eth";
|
|
3
1
|
import eip55 from "eip55";
|
|
2
|
+
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
3
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
4
|
+
import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
|
|
5
|
+
import { EvmAddress, EvmSignature, EvmSigner } from "./signer";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
publicKey,
|
|
19
|
-
chainCode,
|
|
20
|
-
path,
|
|
7
|
+
const resolver = (
|
|
8
|
+
signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>,
|
|
9
|
+
): GetAddressFn => {
|
|
10
|
+
return async (deviceId: string, { path, verify }: GetAddressOptions) => {
|
|
11
|
+
const { address, publicKey, chainCode } = (await signerContext(deviceId, signer =>
|
|
12
|
+
signer.getAddress(path, verify, false),
|
|
13
|
+
)) as EvmAddress;
|
|
14
|
+
return {
|
|
15
|
+
address: eip55.encode(address),
|
|
16
|
+
publicKey,
|
|
17
|
+
chainCode,
|
|
18
|
+
path,
|
|
19
|
+
};
|
|
21
20
|
};
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
export default
|
|
23
|
+
export default resolver;
|
package/src/logic.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
|
4
4
|
import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
5
5
|
import { Account, SubAccount } from "@ledgerhq/types-live";
|
|
6
6
|
import { listTokensForCryptoCurrency } from "@ledgerhq/cryptoassets/tokens";
|
|
7
|
-
import { getOptimismAdditionalFees } from "./api/rpc.common";
|
|
7
|
+
import { getOptimismAdditionalFees } from "./api/rpc/rpc.common";
|
|
8
8
|
import {
|
|
9
9
|
Transaction as EvmTransaction,
|
|
10
10
|
EvmTransactionEIP1559,
|
|
@@ -39,15 +39,12 @@ export const getEstimatedFees = (tx: EvmTransaction): BigNumber => {
|
|
|
39
39
|
*/
|
|
40
40
|
export const getAdditionalLayer2Fees = async (
|
|
41
41
|
currency: CryptoCurrency,
|
|
42
|
-
transaction: EvmTransaction
|
|
42
|
+
transaction: EvmTransaction,
|
|
43
43
|
): Promise<BigNumber | undefined> => {
|
|
44
44
|
switch (currency.id) {
|
|
45
45
|
case "optimism":
|
|
46
46
|
case "optimism_goerli": {
|
|
47
|
-
const additionalFees = await getOptimismAdditionalFees(
|
|
48
|
-
currency,
|
|
49
|
-
transaction
|
|
50
|
-
);
|
|
47
|
+
const additionalFees = await getOptimismAdditionalFees(currency, transaction);
|
|
51
48
|
return additionalFees;
|
|
52
49
|
}
|
|
53
50
|
default:
|
|
@@ -72,7 +69,7 @@ const updatableSubAccountProperties: { name: string; isOps: boolean }[] = [
|
|
|
72
69
|
*/
|
|
73
70
|
export const mergeSubAccounts = (
|
|
74
71
|
initialAccount: Account | undefined,
|
|
75
|
-
newSubAccounts: Partial<SubAccount>[]
|
|
72
|
+
newSubAccounts: Partial<SubAccount>[],
|
|
76
73
|
): Array<Partial<SubAccount> | SubAccount> => {
|
|
77
74
|
const oldSubAccounts: Array<Partial<SubAccount> | SubAccount> | undefined =
|
|
78
75
|
initialAccount?.subAccounts;
|
|
@@ -135,14 +132,7 @@ export const mergeSubAccounts = (
|
|
|
135
132
|
export const getSyncHash = (currency: CryptoCurrency): string => {
|
|
136
133
|
const tokens = listTokensForCryptoCurrency(currency);
|
|
137
134
|
const basicTokensListString = tokens
|
|
138
|
-
.map(
|
|
139
|
-
(token) =>
|
|
140
|
-
token.id +
|
|
141
|
-
token.contractAddress +
|
|
142
|
-
token.name +
|
|
143
|
-
token.ticker +
|
|
144
|
-
token.delisted
|
|
145
|
-
)
|
|
135
|
+
.map(token => token.id + token.contractAddress + token.name + token.ticker + token.delisted)
|
|
146
136
|
.join("");
|
|
147
137
|
|
|
148
138
|
return ethers.utils.sha256(Buffer.from(basicTokensListString));
|
package/src/preload.ts
CHANGED
|
@@ -7,24 +7,18 @@ import network from "@ledgerhq/live-network/network";
|
|
|
7
7
|
import { getEnv } from "@ledgerhq/live-env";
|
|
8
8
|
|
|
9
9
|
export const fetchERC20Tokens: (
|
|
10
|
-
currency: CryptoCurrency
|
|
11
|
-
) => Promise<ERC20Token[]> = async
|
|
10
|
+
currency: CryptoCurrency,
|
|
11
|
+
) => Promise<ERC20Token[]> = async currency => {
|
|
12
12
|
const { ethereumLikeInfo } = currency;
|
|
13
13
|
|
|
14
|
-
const url = `${getEnv("DYNAMIC_CAL_BASE_URL")}/evm/${
|
|
15
|
-
ethereumLikeInfo?.chainId || 0
|
|
16
|
-
}/erc20.json`;
|
|
14
|
+
const url = `${getEnv("DYNAMIC_CAL_BASE_URL")}/evm/${ethereumLikeInfo?.chainId || 0}/erc20.json`;
|
|
17
15
|
const dynamicTokens: ERC20Token[] | null = await network({
|
|
18
16
|
method: "GET",
|
|
19
17
|
url,
|
|
20
18
|
})
|
|
21
19
|
.then(({ data }: { data: ERC20Token[] }) => (data.length ? data : null))
|
|
22
|
-
.catch(
|
|
23
|
-
log(
|
|
24
|
-
"error",
|
|
25
|
-
"EVM Family: Couldn't fetch dynamic CAL tokens from " + url,
|
|
26
|
-
e
|
|
27
|
-
);
|
|
20
|
+
.catch(e => {
|
|
21
|
+
log("error", "EVM Family: Couldn't fetch dynamic CAL tokens from " + url, e);
|
|
28
22
|
return null;
|
|
29
23
|
});
|
|
30
24
|
if (dynamicTokens) return dynamicTokens;
|
|
@@ -33,11 +27,7 @@ export const fetchERC20Tokens: (
|
|
|
33
27
|
const tokens = tokensByChainId[ethereumLikeInfo?.chainId || ""];
|
|
34
28
|
if (tokens) return tokens;
|
|
35
29
|
|
|
36
|
-
log(
|
|
37
|
-
"warning",
|
|
38
|
-
`EVM Family: No tokens found in CAL for currency: ${currency.id}`,
|
|
39
|
-
currency
|
|
40
|
-
);
|
|
30
|
+
log("warning", `EVM Family: No tokens found in CAL for currency: ${currency.id}`, currency);
|
|
41
31
|
return [];
|
|
42
32
|
};
|
|
43
33
|
|