@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/synchronization.ts
CHANGED
|
@@ -14,36 +14,16 @@ import {
|
|
|
14
14
|
import { log } from "@ledgerhq/logs";
|
|
15
15
|
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
16
16
|
import { Account, Operation, SubAccount } from "@ledgerhq/types-live";
|
|
17
|
-
import etherscanLikeApi from "./api/etherscan";
|
|
18
|
-
import {
|
|
19
|
-
getBalanceAndBlock,
|
|
20
|
-
getBlock,
|
|
21
|
-
getTokenBalance,
|
|
22
|
-
getTransaction,
|
|
23
|
-
} from "./api/rpc";
|
|
24
|
-
import { getSyncHash, mergeSubAccounts } from "./logic";
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const getExplorerApi = (currency: CryptoCurrency) => {
|
|
30
|
-
const apiType = currency.ethereumLikeInfo?.explorer?.type;
|
|
31
|
-
|
|
32
|
-
switch (apiType) {
|
|
33
|
-
case "etherscan":
|
|
34
|
-
case "blockscout":
|
|
35
|
-
return etherscanLikeApi;
|
|
36
|
-
|
|
37
|
-
default:
|
|
38
|
-
throw new Error("API type not supported");
|
|
39
|
-
}
|
|
40
|
-
};
|
|
18
|
+
import { getBalanceAndBlock, getBlock, getTokenBalance, getTransaction } from "./api/rpc";
|
|
19
|
+
import { getSyncHash, mergeSubAccounts } from "./logic";
|
|
20
|
+
import { getExplorerApi } from "./api/explorer";
|
|
41
21
|
|
|
42
22
|
/**
|
|
43
23
|
* Main synchronization process
|
|
44
24
|
* Get the main Account and the potential TokenAccounts linked to it
|
|
45
25
|
*/
|
|
46
|
-
export const getAccountShape: GetAccountShape = async
|
|
26
|
+
export const getAccountShape: GetAccountShape = async infos => {
|
|
47
27
|
const { initialAccount, address, derivationMode, currency } = infos;
|
|
48
28
|
const { blockHeight, balance } = await getBalanceAndBlock(currency, address);
|
|
49
29
|
const accountId = encodeAccountId({
|
|
@@ -75,7 +55,7 @@ export const getAccountShape: GetAccountShape = async (infos) => {
|
|
|
75
55
|
currency,
|
|
76
56
|
address,
|
|
77
57
|
accountId,
|
|
78
|
-
latestSyncedOperation?.blockHeight || 0
|
|
58
|
+
latestSyncedOperation?.blockHeight || 0,
|
|
79
59
|
);
|
|
80
60
|
} catch (e) {
|
|
81
61
|
log("EVM Family", "Failed to get latest transactions", {
|
|
@@ -87,11 +67,7 @@ export const getAccountShape: GetAccountShape = async (infos) => {
|
|
|
87
67
|
}
|
|
88
68
|
})();
|
|
89
69
|
|
|
90
|
-
const newSubAccounts = await getSubAccounts(
|
|
91
|
-
infos,
|
|
92
|
-
accountId,
|
|
93
|
-
shouldSyncFromScratch
|
|
94
|
-
);
|
|
70
|
+
const newSubAccounts = await getSubAccounts(infos, accountId, shouldSyncFromScratch);
|
|
95
71
|
// Merging potential new subAccouns while preserving the reference (returned value will be initialAccount.subAccounts)
|
|
96
72
|
const subAccounts = mergeSubAccounts(initialAccount, newSubAccounts);
|
|
97
73
|
|
|
@@ -99,11 +75,9 @@ export const getAccountShape: GetAccountShape = async (infos) => {
|
|
|
99
75
|
// because they were made in the live
|
|
100
76
|
// Useful for integrations without explorers
|
|
101
77
|
const confirmPendingOperations =
|
|
102
|
-
initialAccount?.pendingOperations?.map((op)
|
|
103
|
-
|
|
104
|
-
)
|
|
105
|
-
const confirmedOperations = await Promise.all(confirmPendingOperations).then(
|
|
106
|
-
(ops) => ops.filter((op): op is Operation => !!op)
|
|
78
|
+
initialAccount?.pendingOperations?.map(op => getOperationStatus(currency, op)) || [];
|
|
79
|
+
const confirmedOperations = await Promise.all(confirmPendingOperations).then(ops =>
|
|
80
|
+
ops.filter((op): op is Operation => !!op),
|
|
107
81
|
);
|
|
108
82
|
const newOperations = [...confirmedOperations, ...lastCoinOperations];
|
|
109
83
|
const operations = mergeOps(initialAccount?.operations || [], newOperations);
|
|
@@ -129,7 +103,7 @@ export const getAccountShape: GetAccountShape = async (infos) => {
|
|
|
129
103
|
export const getSubAccounts = async (
|
|
130
104
|
infos: AccountShapeInfo,
|
|
131
105
|
accountId: string,
|
|
132
|
-
shouldSyncFromScratch = false
|
|
106
|
+
shouldSyncFromScratch = false,
|
|
133
107
|
): Promise<Partial<SubAccount>[]> => {
|
|
134
108
|
const { initialAccount, address, currency } = infos;
|
|
135
109
|
|
|
@@ -142,9 +116,7 @@ export const getSubAccounts = async (
|
|
|
142
116
|
if (!acc) {
|
|
143
117
|
return curr;
|
|
144
118
|
}
|
|
145
|
-
return (acc?.blockHeight || 0) > (curr?.blockHeight || 0)
|
|
146
|
-
? acc
|
|
147
|
-
: curr;
|
|
119
|
+
return (acc?.blockHeight || 0) > (curr?.blockHeight || 0) ? acc : curr;
|
|
148
120
|
}, null);
|
|
149
121
|
|
|
150
122
|
// This method could not be working if the integration doesn't have an API to retreive the operations
|
|
@@ -155,7 +127,7 @@ export const getSubAccounts = async (
|
|
|
155
127
|
currency,
|
|
156
128
|
address,
|
|
157
129
|
accountId,
|
|
158
|
-
latestSyncedOperation?.blockHeight || 0
|
|
130
|
+
latestSyncedOperation?.blockHeight || 0,
|
|
159
131
|
);
|
|
160
132
|
} catch (e) {
|
|
161
133
|
log("EVM Family", "Failed to get latest ERC20 transactions", {
|
|
@@ -184,9 +156,7 @@ export const getSubAccounts = async (
|
|
|
184
156
|
// Fetching all TokenAccounts possible and providing already filtered operations
|
|
185
157
|
const subAccountsPromises: Promise<Partial<SubAccount>>[] = [];
|
|
186
158
|
for (const [token, ops] of erc20OperationsByToken.entries()) {
|
|
187
|
-
subAccountsPromises.push(
|
|
188
|
-
getSubAccountShape(currency, accountId, token, ops)
|
|
189
|
-
);
|
|
159
|
+
subAccountsPromises.push(getSubAccountShape(currency, accountId, token, ops));
|
|
190
160
|
}
|
|
191
161
|
|
|
192
162
|
return Promise.all(subAccountsPromises);
|
|
@@ -199,15 +169,11 @@ export const getSubAccountShape = async (
|
|
|
199
169
|
currency: CryptoCurrency,
|
|
200
170
|
parentId: string,
|
|
201
171
|
token: TokenCurrency,
|
|
202
|
-
operations: Operation[]
|
|
172
|
+
operations: Operation[],
|
|
203
173
|
): Promise<Partial<SubAccount>> => {
|
|
204
174
|
const { xpubOrAddress: address } = decodeAccountId(parentId);
|
|
205
175
|
const tokenAccountId = encodeTokenAccountId(parentId, token);
|
|
206
|
-
const balance = await getTokenBalance(
|
|
207
|
-
currency,
|
|
208
|
-
address,
|
|
209
|
-
token.contractAddress
|
|
210
|
-
);
|
|
176
|
+
const balance = await getTokenBalance(currency, address, token.contractAddress);
|
|
211
177
|
|
|
212
178
|
return {
|
|
213
179
|
type: "TokenAccount",
|
|
@@ -230,7 +196,7 @@ export const getSubAccountShape = async (
|
|
|
230
196
|
*/
|
|
231
197
|
export const getOperationStatus = async (
|
|
232
198
|
currency: CryptoCurrency,
|
|
233
|
-
op: Operation
|
|
199
|
+
op: Operation,
|
|
234
200
|
): Promise<Operation | null> => {
|
|
235
201
|
try {
|
|
236
202
|
const {
|
|
@@ -251,10 +217,7 @@ export const getOperationStatus = async (
|
|
|
251
217
|
}
|
|
252
218
|
|
|
253
219
|
// Without timestamp, we directly look for the block
|
|
254
|
-
const { timestamp: blockTimestamp } = await getBlock(
|
|
255
|
-
currency,
|
|
256
|
-
blockHeight
|
|
257
|
-
);
|
|
220
|
+
const { timestamp: blockTimestamp } = await getBlock(currency, blockHeight);
|
|
258
221
|
return new Date(blockTimestamp * 1000);
|
|
259
222
|
})();
|
|
260
223
|
|
|
@@ -288,22 +251,20 @@ export const postSync = (initial: Account, synced: Account): Account => {
|
|
|
288
251
|
|
|
289
252
|
return {
|
|
290
253
|
...synced,
|
|
291
|
-
subAccounts: synced.subAccounts?.map(
|
|
254
|
+
subAccounts: synced.subAccounts?.map(subAccount => {
|
|
292
255
|
// If the subAccount is new, just return the freshly synced subAccount
|
|
293
256
|
if (!initialSubAccountsIds.has(subAccount.id)) return subAccount;
|
|
294
257
|
|
|
295
258
|
return {
|
|
296
259
|
...subAccount,
|
|
297
260
|
pendingOperations: subAccount.pendingOperations.filter(
|
|
298
|
-
|
|
261
|
+
tokenPendingOperation =>
|
|
299
262
|
// if the pending operation got removed from the main account, remove it as well
|
|
300
263
|
coinPendingOperationsHashes.has(tokenPendingOperation.hash) &&
|
|
301
264
|
// if the transaction has been confirmed, remove it
|
|
302
|
-
!subAccount.operations.some(
|
|
303
|
-
(op) => op.hash === tokenPendingOperation.hash
|
|
304
|
-
) &&
|
|
265
|
+
!subAccount.operations.some(op => op.hash === tokenPendingOperation.hash) &&
|
|
305
266
|
// common rule for pending operations retention in the live
|
|
306
|
-
shouldRetainPendingOperation(synced, tokenPendingOperation)
|
|
267
|
+
shouldRetainPendingOperation(synced, tokenPendingOperation),
|
|
307
268
|
),
|
|
308
269
|
};
|
|
309
270
|
}),
|
package/src/testUtils.ts
CHANGED
|
@@ -11,18 +11,13 @@ import {
|
|
|
11
11
|
} from "@ledgerhq/coin-framework/derivation";
|
|
12
12
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
13
13
|
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
14
|
-
import {
|
|
15
|
-
Account,
|
|
16
|
-
Operation,
|
|
17
|
-
SubAccount,
|
|
18
|
-
TokenAccount,
|
|
19
|
-
} from "@ledgerhq/types-live";
|
|
14
|
+
import { Account, Operation, SubAccount, TokenAccount } from "@ledgerhq/types-live";
|
|
20
15
|
import BigNumber from "bignumber.js";
|
|
21
16
|
|
|
22
17
|
export const makeAccount = (
|
|
23
18
|
address: string,
|
|
24
19
|
currency: CryptoCurrency,
|
|
25
|
-
subAccounts: SubAccount[] = []
|
|
20
|
+
subAccounts: SubAccount[] = [],
|
|
26
21
|
): Account => {
|
|
27
22
|
const id = `js:2:${currency.id}:${address}:`;
|
|
28
23
|
const { derivationMode, xpubOrAddress } = decodeAccountId(id);
|
|
@@ -40,11 +35,7 @@ export const makeAccount = (
|
|
|
40
35
|
const account: Account = {
|
|
41
36
|
type: "Account",
|
|
42
37
|
name:
|
|
43
|
-
currency.name +
|
|
44
|
-
" " +
|
|
45
|
-
(derivationMode || "legacy") +
|
|
46
|
-
" " +
|
|
47
|
-
shortAddressPreview(xpubOrAddress),
|
|
38
|
+
currency.name + " " + (derivationMode || "legacy") + " " + shortAddressPreview(xpubOrAddress),
|
|
48
39
|
xpub: xpubOrAddress,
|
|
49
40
|
subAccounts,
|
|
50
41
|
seedIdentifier: xpubOrAddress,
|
|
@@ -86,10 +77,7 @@ export const makeAccount = (
|
|
|
86
77
|
return account;
|
|
87
78
|
};
|
|
88
79
|
|
|
89
|
-
export const makeTokenAccount = (
|
|
90
|
-
address: string,
|
|
91
|
-
tokenCurrency: TokenCurrency
|
|
92
|
-
): TokenAccount => {
|
|
80
|
+
export const makeTokenAccount = (address: string, tokenCurrency: TokenCurrency): TokenAccount => {
|
|
93
81
|
const { parentCurrency: currency } = tokenCurrency;
|
|
94
82
|
const account = makeAccount(address, currency);
|
|
95
83
|
|
|
@@ -128,9 +116,7 @@ export const makeTokenAccount = (
|
|
|
128
116
|
export const makeOperation = (partialOp?: Partial<Operation>): Operation => {
|
|
129
117
|
const accountId = partialOp?.accountId ?? "js:2:ethereum:0xkvn:";
|
|
130
118
|
const { xpubOrAddress } = decodeAccountId(
|
|
131
|
-
accountId.includes("+")
|
|
132
|
-
? decodeTokenAccountId(accountId).accountId
|
|
133
|
-
: accountId
|
|
119
|
+
accountId.includes("+") ? decodeTokenAccountId(accountId).accountId : accountId,
|
|
134
120
|
);
|
|
135
121
|
const hash = partialOp?.hash ?? "0xhash";
|
|
136
122
|
const type = partialOp?.type ?? "OUT";
|
package/src/transaction.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const DEFAULT_GAS_LIMIT = new BigNumber(21000);
|
|
|
27
27
|
*/
|
|
28
28
|
export const formatTransaction = (
|
|
29
29
|
{ mode, amount, recipient, useAllAmount }: EvmTransaction,
|
|
30
|
-
account: Account
|
|
30
|
+
account: Account,
|
|
31
31
|
): string =>
|
|
32
32
|
`
|
|
33
33
|
${mode.toUpperCase()} ${
|
|
@@ -45,9 +45,7 @@ ${mode.toUpperCase()} ${
|
|
|
45
45
|
/**
|
|
46
46
|
* Serializer raw to transaction
|
|
47
47
|
*/
|
|
48
|
-
export const fromTransactionRaw = (
|
|
49
|
-
rawTx: EvmTransactionRaw
|
|
50
|
-
): EvmTransaction => {
|
|
48
|
+
export const fromTransactionRaw = (rawTx: EvmTransactionRaw): EvmTransaction => {
|
|
51
49
|
const common = fromTransactionCommonRaw(rawTx);
|
|
52
50
|
const tx: Partial<EvmTransaction> = {
|
|
53
51
|
...common,
|
|
@@ -126,9 +124,7 @@ export const toTransactionRaw = (tx: EvmTransaction): EvmTransactionRaw => {
|
|
|
126
124
|
* Returns the data necessary to execute smart contracts.
|
|
127
125
|
* As of now, only used to create ERC20 transfers' data
|
|
128
126
|
*/
|
|
129
|
-
export const getTransactionData = (
|
|
130
|
-
transaction: EvmTransaction
|
|
131
|
-
): Buffer | undefined => {
|
|
127
|
+
export const getTransactionData = (transaction: EvmTransaction): Buffer | undefined => {
|
|
132
128
|
const contract = new ethers.utils.Interface(ERC20ABI);
|
|
133
129
|
const data = contract.encodeFunctionData("transfer", [
|
|
134
130
|
transaction.recipient,
|
|
@@ -144,7 +140,7 @@ export const getTransactionData = (
|
|
|
144
140
|
*/
|
|
145
141
|
export const getTypedTransaction = (
|
|
146
142
|
transaction: EvmTransaction,
|
|
147
|
-
feeData: FeeData
|
|
143
|
+
feeData: FeeData,
|
|
148
144
|
): EvmTransaction => {
|
|
149
145
|
// If the blockchain is supporting EIP-1559, use maxFeePerGas & maxPriorityFeePerGas
|
|
150
146
|
if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) {
|
|
@@ -172,13 +168,13 @@ export const getTypedTransaction = (
|
|
|
172
168
|
*/
|
|
173
169
|
export const getSerializedTransaction = (
|
|
174
170
|
tx: EvmTransaction,
|
|
175
|
-
signature?: Partial<ethers.Signature
|
|
171
|
+
signature?: Partial<ethers.Signature>,
|
|
176
172
|
): string => {
|
|
177
173
|
const unsignedEthersTransaction = transactionToEthersTransaction(tx);
|
|
178
174
|
|
|
179
175
|
return ethers.utils.serializeTransaction(
|
|
180
176
|
unsignedEthersTransaction,
|
|
181
|
-
signature as ethers.Signature
|
|
177
|
+
signature as ethers.Signature,
|
|
182
178
|
);
|
|
183
179
|
};
|
|
184
180
|
|
package/src/types.ts
CHANGED
|
@@ -8,6 +8,10 @@ import {
|
|
|
8
8
|
|
|
9
9
|
export type EvmTransactionMode = "send";
|
|
10
10
|
|
|
11
|
+
export type GasOptions = {
|
|
12
|
+
[key in "slow" | "medium" | "fast"]: FeeData;
|
|
13
|
+
};
|
|
14
|
+
|
|
11
15
|
export type EvmTransactionBase = TransactionCommon & {
|
|
12
16
|
family: "evm";
|
|
13
17
|
mode: EvmTransactionMode;
|
|
@@ -24,6 +28,8 @@ export type EvmTransactionBase = TransactionCommon & {
|
|
|
24
28
|
// additional fees can be expected on some Layer 2 chains.
|
|
25
29
|
// It's an additional cost to take into account while estimating the cost of the tx.
|
|
26
30
|
additionalFees?: BigNumber;
|
|
31
|
+
// available gas options for the transaction, used to display sensible default fees choices to the user
|
|
32
|
+
gasOptions?: GasOptions;
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
export type EvmTransactionLegacy = EvmTransactionBase & {
|
|
File without changes
|
|
File without changes
|