@trezor/connect 9.0.0-beta.1
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/LICENSE.md +50 -0
- package/README.md +38 -0
- package/lib/api/applyFlags.d.ts +8 -0
- package/lib/api/applyFlags.js +37 -0
- package/lib/api/applySettings.d.ts +8 -0
- package/lib/api/applySettings.js +57 -0
- package/lib/api/authorizeCoinJoin.d.ts +7 -0
- package/lib/api/authorizeCoinJoin.js +45 -0
- package/lib/api/backupDevice.d.ts +7 -0
- package/lib/api/backupDevice.js +31 -0
- package/lib/api/binance/binanceSignTx.d.ts +6 -0
- package/lib/api/binance/binanceSignTx.js +91 -0
- package/lib/api/binanceGetAddress.d.ts +22 -0
- package/lib/api/binanceGetAddress.js +126 -0
- package/lib/api/binanceGetPublicKey.d.ts +10 -0
- package/lib/api/binanceGetPublicKey.js +72 -0
- package/lib/api/binanceSignTransaction.d.ts +12 -0
- package/lib/api/binanceSignTransaction.js +31 -0
- package/lib/api/bitcoin/Fees.d.ts +15 -0
- package/lib/api/bitcoin/Fees.js +175 -0
- package/lib/api/bitcoin/TransactionComposer.d.ts +36 -0
- package/lib/api/bitcoin/TransactionComposer.js +150 -0
- package/lib/api/bitcoin/__fixtures__/inputs.d.ts +112 -0
- package/lib/api/bitcoin/__fixtures__/inputs.js +102 -0
- package/lib/api/bitcoin/__fixtures__/signtxVerify.d.ts +147 -0
- package/lib/api/bitcoin/__fixtures__/signtxVerify.js +216 -0
- package/lib/api/bitcoin/enhanceSignTx.d.ts +4 -0
- package/lib/api/bitcoin/enhanceSignTx.js +63 -0
- package/lib/api/bitcoin/index.d.ts +10 -0
- package/lib/api/bitcoin/index.js +13 -0
- package/lib/api/bitcoin/inputs.d.ts +8 -0
- package/lib/api/bitcoin/inputs.js +60 -0
- package/lib/api/bitcoin/outputs.d.ts +8 -0
- package/lib/api/bitcoin/outputs.js +115 -0
- package/lib/api/bitcoin/refTx.d.ts +11 -0
- package/lib/api/bitcoin/refTx.js +220 -0
- package/lib/api/bitcoin/signtx.d.ts +25 -0
- package/lib/api/bitcoin/signtx.js +164 -0
- package/lib/api/bitcoin/signtxLegacy.d.ts +4 -0
- package/lib/api/bitcoin/signtxLegacy.js +136 -0
- package/lib/api/bitcoin/signtxVerify.d.ts +8 -0
- package/lib/api/bitcoin/signtxVerify.js +130 -0
- package/lib/api/blockchainDisconnect.d.ts +13 -0
- package/lib/api/blockchainDisconnect.js +34 -0
- package/lib/api/blockchainEstimateFee.d.ts +12 -0
- package/lib/api/blockchainEstimateFee.js +70 -0
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +12 -0
- package/lib/api/blockchainGetAccountBalanceHistory.js +41 -0
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +15 -0
- package/lib/api/blockchainGetCurrentFiatRates.js +33 -0
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +17 -0
- package/lib/api/blockchainGetFiatRatesForTimestamps.js +33 -0
- package/lib/api/blockchainGetTransactions.d.ts +12 -0
- package/lib/api/blockchainGetTransactions.js +33 -0
- package/lib/api/blockchainSetCustomBackend.d.ts +11 -0
- package/lib/api/blockchainSetCustomBackend.js +38 -0
- package/lib/api/blockchainSubscribe.d.ts +14 -0
- package/lib/api/blockchainSubscribe.js +38 -0
- package/lib/api/blockchainSubscribeFiatRates.d.ts +14 -0
- package/lib/api/blockchainSubscribeFiatRates.js +33 -0
- package/lib/api/blockchainUnsubscribe.d.ts +14 -0
- package/lib/api/blockchainUnsubscribe.js +38 -0
- package/lib/api/blockchainUnsubscribeFiatRates.d.ts +13 -0
- package/lib/api/blockchainUnsubscribeFiatRates.js +29 -0
- package/lib/api/cardano/cardanoAddressParameters.d.ts +8 -0
- package/lib/api/cardano/cardanoAddressParameters.js +100 -0
- package/lib/api/cardano/cardanoAuxiliaryData.d.ts +6 -0
- package/lib/api/cardano/cardanoAuxiliaryData.js +51 -0
- package/lib/api/cardano/cardanoCertificate.d.ts +14 -0
- package/lib/api/cardano/cardanoCertificate.js +149 -0
- package/lib/api/cardano/cardanoInputs.d.ts +13 -0
- package/lib/api/cardano/cardanoInputs.js +34 -0
- package/lib/api/cardano/cardanoOutputs.d.ts +8 -0
- package/lib/api/cardano/cardanoOutputs.js +38 -0
- package/lib/api/cardano/cardanoTokenBundle.d.ts +8 -0
- package/lib/api/cardano/cardanoTokenBundle.js +36 -0
- package/lib/api/cardano/cardanoWitnesses.d.ts +5 -0
- package/lib/api/cardano/cardanoWitnesses.js +48 -0
- package/lib/api/cardanoGetAddress.d.ts +23 -0
- package/lib/api/cardanoGetAddress.js +158 -0
- package/lib/api/cardanoGetNativeScriptHash.d.ts +12 -0
- package/lib/api/cardanoGetNativeScriptHash.js +79 -0
- package/lib/api/cardanoGetPublicKey.d.ts +10 -0
- package/lib/api/cardanoGetPublicKey.js +78 -0
- package/lib/api/cardanoSignTransaction.d.ts +48 -0
- package/lib/api/cardanoSignTransaction.js +283 -0
- package/lib/api/changePin.d.ts +7 -0
- package/lib/api/changePin.js +22 -0
- package/lib/api/cipherKeyValue.d.ts +8 -0
- package/lib/api/cipherKeyValue.js +56 -0
- package/lib/api/common/Discovery.d.ts +35 -0
- package/lib/api/common/Discovery.js +113 -0
- package/lib/api/common/__fixtures__/paramsValidator.d.ts +596 -0
- package/lib/api/common/__fixtures__/paramsValidator.js +355 -0
- package/lib/api/common/paramsValidator.d.ts +14 -0
- package/lib/api/common/paramsValidator.js +140 -0
- package/lib/api/composeTransaction.d.ts +33 -0
- package/lib/api/composeTransaction.js +270 -0
- package/lib/api/customMessage.d.ts +13 -0
- package/lib/api/customMessage.js +56 -0
- package/lib/api/eos/eosSignTx.d.ts +17 -0
- package/lib/api/eos/eosSignTx.js +347 -0
- package/lib/api/eosGetPublicKey.d.ts +10 -0
- package/lib/api/eosGetPublicKey.js +73 -0
- package/lib/api/eosSignTransaction.d.ts +16 -0
- package/lib/api/eosSignTransaction.js +36 -0
- package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.d.ts +225 -0
- package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.js +341 -0
- package/lib/api/ethereum/ethereumSignTx.d.ts +13 -0
- package/lib/api/ethereum/ethereumSignTx.js +92 -0
- package/lib/api/ethereum/ethereumSignTypedData.d.ts +9 -0
- package/lib/api/ethereum/ethereumSignTypedData.js +120 -0
- package/lib/api/ethereumGetAddress.d.ts +28 -0
- package/lib/api/ethereumGetAddress.js +133 -0
- package/lib/api/ethereumGetPublicKey.d.ts +15 -0
- package/lib/api/ethereumGetPublicKey.js +79 -0
- package/lib/api/ethereumSignMessage.d.ts +7 -0
- package/lib/api/ethereumSignMessage.js +41 -0
- package/lib/api/ethereumSignTransaction.d.ts +20 -0
- package/lib/api/ethereumSignTransaction.js +82 -0
- package/lib/api/ethereumSignTypedData.d.ts +14 -0
- package/lib/api/ethereumSignTypedData.js +151 -0
- package/lib/api/ethereumVerifyMessage.d.ts +7 -0
- package/lib/api/ethereumVerifyMessage.js +34 -0
- package/lib/api/firmware/getBinary.d.ts +20 -0
- package/lib/api/firmware/getBinary.js +37 -0
- package/lib/api/firmware/modifyFirmware.d.ts +6 -0
- package/lib/api/firmware/modifyFirmware.js +18 -0
- package/lib/api/firmwareUpdate.d.ts +15 -0
- package/lib/api/firmwareUpdate.js +89 -0
- package/lib/api/getAccountInfo.d.ts +98 -0
- package/lib/api/getAccountInfo.js +326 -0
- package/lib/api/getAddress.d.ts +28 -0
- package/lib/api/getAddress.js +152 -0
- package/lib/api/getCoinInfo.d.ts +11 -0
- package/lib/api/getCoinInfo.js +27 -0
- package/lib/api/getDeviceState.d.ts +8 -0
- package/lib/api/getDeviceState.js +15 -0
- package/lib/api/getFeatures.d.ts +6 -0
- package/lib/api/getFeatures.js +18 -0
- package/lib/api/getOwnershipId.d.ts +10 -0
- package/lib/api/getOwnershipId.js +75 -0
- package/lib/api/getOwnershipProof.d.ts +14 -0
- package/lib/api/getOwnershipProof.js +86 -0
- package/lib/api/getPublicKey.d.ts +15 -0
- package/lib/api/getPublicKey.js +84 -0
- package/lib/api/getSettings.d.ts +6 -0
- package/lib/api/getSettings.js +16 -0
- package/lib/api/index.d.ts +64 -0
- package/lib/api/index.js +134 -0
- package/lib/api/management/uploadFirmware.d.ts +6 -0
- package/lib/api/management/uploadFirmware.js +49 -0
- package/lib/api/nem/nemSignTx.d.ts +4 -0
- package/lib/api/nem/nemSignTx.js +139 -0
- package/lib/api/nemGetAddress.d.ts +22 -0
- package/lib/api/nemGetAddress.js +144 -0
- package/lib/api/nemSignTransaction.d.ts +7 -0
- package/lib/api/nemSignTransaction.js +29 -0
- package/lib/api/pushTransaction.d.ts +14 -0
- package/lib/api/pushTransaction.js +40 -0
- package/lib/api/rebootToBootloader.d.ts +8 -0
- package/lib/api/rebootToBootloader.js +43 -0
- package/lib/api/recoveryDevice.d.ts +8 -0
- package/lib/api/recoveryDevice.js +57 -0
- package/lib/api/requestLogin.d.ts +12 -0
- package/lib/api/requestLogin.js +63 -0
- package/lib/api/resetDevice.d.ts +9 -0
- package/lib/api/resetDevice.js +59 -0
- package/lib/api/rippleGetAddress.d.ts +22 -0
- package/lib/api/rippleGetAddress.js +126 -0
- package/lib/api/rippleSignTransaction.d.ts +10 -0
- package/lib/api/rippleSignTransaction.js +54 -0
- package/lib/api/setProxy.d.ts +8 -0
- package/lib/api/setProxy.js +26 -0
- package/lib/api/signMessage.d.ts +7 -0
- package/lib/api/signMessage.js +51 -0
- package/lib/api/signTransaction.d.ts +21 -0
- package/lib/api/signTransaction.js +146 -0
- package/lib/api/stellar/stellarSignTx.d.ts +5 -0
- package/lib/api/stellar/stellarSignTx.js +198 -0
- package/lib/api/stellarGetAddress.d.ts +22 -0
- package/lib/api/stellarGetAddress.js +126 -0
- package/lib/api/stellarSignTransaction.d.ts +23 -0
- package/lib/api/stellarSignTransaction.js +62 -0
- package/lib/api/tezos/tezosSignTx.d.ts +4 -0
- package/lib/api/tezos/tezosSignTx.js +237 -0
- package/lib/api/tezosGetAddress.d.ts +22 -0
- package/lib/api/tezosGetAddress.js +126 -0
- package/lib/api/tezosGetPublicKey.d.ts +10 -0
- package/lib/api/tezosGetPublicKey.js +72 -0
- package/lib/api/tezosSignTransaction.d.ts +7 -0
- package/lib/api/tezosSignTransaction.js +30 -0
- package/lib/api/verifyMessage.d.ts +7 -0
- package/lib/api/verifyMessage.js +47 -0
- package/lib/api/wipeDevice.d.ts +8 -0
- package/lib/api/wipeDevice.js +41 -0
- package/lib/backend/BlockchainLink.d.ts +75 -0
- package/lib/backend/BlockchainLink.js +298 -0
- package/lib/constants/cardano.d.ts +9 -0
- package/lib/constants/cardano.js +14 -0
- package/lib/constants/errors.d.ts +49 -0
- package/lib/constants/errors.js +62 -0
- package/lib/constants/index.d.ts +6 -0
- package/lib/constants/index.js +10 -0
- package/lib/constants/nem.d.ts +22 -0
- package/lib/constants/nem.js +28 -0
- package/lib/constants/network.d.ts +13 -0
- package/lib/constants/network.js +15 -0
- package/lib/core/AbstractMethod.d.ts +59 -0
- package/lib/core/AbstractMethod.js +159 -0
- package/lib/core/index.d.ts +16 -0
- package/lib/core/index.js +671 -0
- package/lib/core/method.d.ts +6 -0
- package/lib/core/method.js +19 -0
- package/lib/data/DataManager.d.ts +31 -0
- package/lib/data/DataManager.js +98 -0
- package/lib/data/coinInfo.d.ts +37 -0
- package/lib/data/coinInfo.js +278 -0
- package/lib/data/config.d.ts +98 -0
- package/lib/data/config.js +201 -0
- package/lib/data/connectSettings.d.ts +6 -0
- package/lib/data/connectSettings.js +150 -0
- package/lib/data/firmwareInfo.d.ts +11 -0
- package/lib/data/firmwareInfo.js +148 -0
- package/lib/data/transportInfo.d.ts +4 -0
- package/lib/data/transportInfo.js +29 -0
- package/lib/data/udevInfo.d.ts +3 -0
- package/lib/data/udevInfo.js +21 -0
- package/lib/data/version.d.ts +3 -0
- package/lib/data/version.js +7 -0
- package/lib/device/AbortController.d.ts +21 -0
- package/lib/device/AbortController.js +40 -0
- package/lib/device/DescriptorStream.d.ts +28 -0
- package/lib/device/DescriptorStream.js +139 -0
- package/lib/device/Device.d.ts +105 -0
- package/lib/device/Device.js +527 -0
- package/lib/device/DeviceCommands.d.ts +63 -0
- package/lib/device/DeviceCommands.js +465 -0
- package/lib/device/DeviceList.d.ts +76 -0
- package/lib/device/DeviceList.js +411 -0
- package/lib/events/blockchain.d.ts +56 -0
- package/lib/events/blockchain.js +18 -0
- package/lib/events/call.d.ts +41 -0
- package/lib/events/call.js +14 -0
- package/lib/events/core.d.ts +20 -0
- package/lib/events/core.js +28 -0
- package/lib/events/device.d.ts +40 -0
- package/lib/events/device.js +28 -0
- package/lib/events/iframe.d.ts +39 -0
- package/lib/events/iframe.js +18 -0
- package/lib/events/index.d.ts +62 -0
- package/lib/events/index.js +21 -0
- package/lib/events/popup.d.ts +51 -0
- package/lib/events/popup.js +22 -0
- package/lib/events/transport.d.ts +62 -0
- package/lib/events/transport.js +21 -0
- package/lib/events/ui-promise.d.ts +12 -0
- package/lib/events/ui-promise.js +3 -0
- package/lib/events/ui-request.d.ts +180 -0
- package/lib/events/ui-request.js +50 -0
- package/lib/events/ui-response.d.ts +97 -0
- package/lib/events/ui-response.js +25 -0
- package/lib/exports.d.ts +5 -0
- package/lib/exports.js +10 -0
- package/lib/factory.d.ts +20 -0
- package/lib/factory.js +122 -0
- package/lib/index-browser.d.ts +4 -0
- package/lib/index-browser.js +29 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +236 -0
- package/lib/types/account.d.ts +37 -0
- package/lib/types/account.js +3 -0
- package/lib/types/api/applyFlags.d.ts +4 -0
- package/lib/types/api/applyFlags.js +3 -0
- package/lib/types/api/applySettings.d.ts +4 -0
- package/lib/types/api/applySettings.js +3 -0
- package/lib/types/api/authorizeCoinJoin.d.ts +14 -0
- package/lib/types/api/authorizeCoinJoin.js +3 -0
- package/lib/types/api/backupDevice.d.ts +4 -0
- package/lib/types/api/backupDevice.js +3 -0
- package/lib/types/api/binanceGetAddress.d.ts +4 -0
- package/lib/types/api/binanceGetAddress.js +3 -0
- package/lib/types/api/binanceGetPublicKey.d.ts +4 -0
- package/lib/types/api/binanceGetPublicKey.js +3 -0
- package/lib/types/api/binanceSignTransaction.d.ts +31 -0
- package/lib/types/api/binanceSignTransaction.js +3 -0
- package/lib/types/api/blockchainDisconnect.d.ts +5 -0
- package/lib/types/api/blockchainDisconnect.js +3 -0
- package/lib/types/api/blockchainEstimateFee.d.ts +29 -0
- package/lib/types/api/blockchainEstimateFee.js +3 -0
- package/lib/types/api/blockchainGetAccountBalanceHistory.d.ts +4 -0
- package/lib/types/api/blockchainGetAccountBalanceHistory.js +3 -0
- package/lib/types/api/blockchainGetCurrentFiatRates.d.ts +4 -0
- package/lib/types/api/blockchainGetCurrentFiatRates.js +3 -0
- package/lib/types/api/blockchainGetFiatRatesForTimestamps.d.ts +4 -0
- package/lib/types/api/blockchainGetFiatRatesForTimestamps.js +3 -0
- package/lib/types/api/blockchainGetTransactions.d.ts +7 -0
- package/lib/types/api/blockchainGetTransactions.js +3 -0
- package/lib/types/api/blockchainSetCustomBackend.d.ts +7 -0
- package/lib/types/api/blockchainSetCustomBackend.js +3 -0
- package/lib/types/api/blockchainSubscribe.d.ts +7 -0
- package/lib/types/api/blockchainSubscribe.js +3 -0
- package/lib/types/api/blockchainSubscribeFiatRates.d.ts +7 -0
- package/lib/types/api/blockchainSubscribeFiatRates.js +3 -0
- package/lib/types/api/blockchainUnsubscribe.d.ts +5 -0
- package/lib/types/api/blockchainUnsubscribe.js +3 -0
- package/lib/types/api/blockchainUnsubscribeFiatRates.d.ts +5 -0
- package/lib/types/api/blockchainUnsubscribeFiatRates.js +3 -0
- package/lib/types/api/cancel.d.ts +2 -0
- package/lib/types/api/cancel.js +3 -0
- package/lib/types/api/cardanoGetAddress.d.ts +35 -0
- package/lib/types/api/cardanoGetAddress.js +3 -0
- package/lib/types/api/cardanoGetNativeScriptHash.d.ts +21 -0
- package/lib/types/api/cardanoGetNativeScriptHash.js +3 -0
- package/lib/types/api/cardanoGetPublicKey.d.ts +16 -0
- package/lib/types/api/cardanoGetPublicKey.js +3 -0
- package/lib/types/api/cardanoSignTransaction.d.ts +130 -0
- package/lib/types/api/cardanoSignTransaction.js +3 -0
- package/lib/types/api/changePin.d.ts +4 -0
- package/lib/types/api/changePin.js +3 -0
- package/lib/types/api/cipherKeyValue.d.ts +17 -0
- package/lib/types/api/cipherKeyValue.js +3 -0
- package/lib/types/api/composeTransaction.d.ts +92 -0
- package/lib/types/api/composeTransaction.js +3 -0
- package/lib/types/api/customMessage.d.ts +12 -0
- package/lib/types/api/customMessage.js +3 -0
- package/lib/types/api/disableWebUSB.d.ts +2 -0
- package/lib/types/api/disableWebUSB.js +3 -0
- package/lib/types/api/dispose.d.ts +2 -0
- package/lib/types/api/dispose.js +3 -0
- package/lib/types/api/eosGetPublicKey.d.ts +14 -0
- package/lib/types/api/eosGetPublicKey.js +3 -0
- package/lib/types/api/eosSignTransaction.d.ts +111 -0
- package/lib/types/api/eosSignTransaction.js +3 -0
- package/lib/types/api/ethereumGetAddress.d.ts +4 -0
- package/lib/types/api/ethereumGetAddress.js +3 -0
- package/lib/types/api/ethereumGetPublicKey.d.ts +5 -0
- package/lib/types/api/ethereumGetPublicKey.js +3 -0
- package/lib/types/api/ethereumSignMessage.d.ts +9 -0
- package/lib/types/api/ethereumSignMessage.js +3 -0
- package/lib/types/api/ethereumSignTransaction.d.ts +40 -0
- package/lib/types/api/ethereumSignTransaction.js +3 -0
- package/lib/types/api/ethereumSignTypedData.d.ts +42 -0
- package/lib/types/api/ethereumSignTypedData.js +3 -0
- package/lib/types/api/ethereumVerifyMessage.d.ts +10 -0
- package/lib/types/api/ethereumVerifyMessage.js +3 -0
- package/lib/types/api/firmwareUpdate.d.ts +14 -0
- package/lib/types/api/firmwareUpdate.js +3 -0
- package/lib/types/api/getAccountInfo.d.ts +14 -0
- package/lib/types/api/getAccountInfo.js +3 -0
- package/lib/types/api/getAddress.d.ts +13 -0
- package/lib/types/api/getAddress.js +3 -0
- package/lib/types/api/getCoinInfo.d.ts +4 -0
- package/lib/types/api/getCoinInfo.js +3 -0
- package/lib/types/api/getDeviceState.d.ts +6 -0
- package/lib/types/api/getDeviceState.js +3 -0
- package/lib/types/api/getFeatures.d.ts +4 -0
- package/lib/types/api/getFeatures.js +3 -0
- package/lib/types/api/getOwnershipId.d.ts +15 -0
- package/lib/types/api/getOwnershipId.js +3 -0
- package/lib/types/api/getOwnershipProof.d.ts +19 -0
- package/lib/types/api/getOwnershipProof.js +3 -0
- package/lib/types/api/getPublicKey.d.ts +19 -0
- package/lib/types/api/getPublicKey.js +3 -0
- package/lib/types/api/getSettings.d.ts +4 -0
- package/lib/types/api/getSettings.js +3 -0
- package/lib/types/api/index.d.ts +149 -0
- package/lib/types/api/index.js +3 -0
- package/lib/types/api/init.d.ts +5 -0
- package/lib/types/api/init.js +3 -0
- package/lib/types/api/manifest.d.ts +3 -0
- package/lib/types/api/manifest.js +3 -0
- package/lib/types/api/nemGetAddress.d.ts +7 -0
- package/lib/types/api/nemGetAddress.js +3 -0
- package/lib/types/api/nemSignTransaction.d.ts +92 -0
- package/lib/types/api/nemSignTransaction.js +3 -0
- package/lib/types/api/off.d.ts +11 -0
- package/lib/types/api/off.js +3 -0
- package/lib/types/api/on.d.ts +14 -0
- package/lib/types/api/on.js +3 -0
- package/lib/types/api/pushTransaction.d.ts +10 -0
- package/lib/types/api/pushTransaction.js +3 -0
- package/lib/types/api/rebootToBootloader.d.ts +4 -0
- package/lib/types/api/rebootToBootloader.js +3 -0
- package/lib/types/api/recoveryDevice.d.ts +7 -0
- package/lib/types/api/recoveryDevice.js +3 -0
- package/lib/types/api/removeAllListeners.d.ts +3 -0
- package/lib/types/api/removeAllListeners.js +3 -0
- package/lib/types/api/renderWebUSBButton.d.ts +2 -0
- package/lib/types/api/renderWebUSBButton.js +3 -0
- package/lib/types/api/requestLogin.d.ts +20 -0
- package/lib/types/api/requestLogin.js +3 -0
- package/lib/types/api/resetDevice.d.ts +16 -0
- package/lib/types/api/resetDevice.js +3 -0
- package/lib/types/api/rippleGetAddress.d.ts +4 -0
- package/lib/types/api/rippleGetAddress.js +3 -0
- package/lib/types/api/rippleSignTransaction.d.ts +23 -0
- package/lib/types/api/rippleSignTransaction.js +3 -0
- package/lib/types/api/setProxy.d.ts +9 -0
- package/lib/types/api/setProxy.js +3 -0
- package/lib/types/api/signMessage.d.ts +11 -0
- package/lib/types/api/signMessage.js +3 -0
- package/lib/types/api/signTransaction.d.ts +70 -0
- package/lib/types/api/signTransaction.js +3 -0
- package/lib/types/api/stellarGetAddress.d.ts +4 -0
- package/lib/types/api/stellarGetAddress.js +3 -0
- package/lib/types/api/stellarSignTransaction.d.ts +182 -0
- package/lib/types/api/stellarSignTransaction.js +3 -0
- package/lib/types/api/tezosGetAddress.d.ts +4 -0
- package/lib/types/api/tezosGetAddress.js +3 -0
- package/lib/types/api/tezosGetPublicKey.d.ts +4 -0
- package/lib/types/api/tezosGetPublicKey.js +3 -0
- package/lib/types/api/tezosSignTransaction.d.ts +61 -0
- package/lib/types/api/tezosSignTransaction.js +3 -0
- package/lib/types/api/uiResponse.d.ts +3 -0
- package/lib/types/api/uiResponse.js +3 -0
- package/lib/types/api/verifyMessage.d.ts +11 -0
- package/lib/types/api/verifyMessage.js +3 -0
- package/lib/types/api/wipeDevice.d.ts +4 -0
- package/lib/types/api/wipeDevice.js +3 -0
- package/lib/types/coinInfo.d.ts +79 -0
- package/lib/types/coinInfo.js +3 -0
- package/lib/types/device.d.ts +92 -0
- package/lib/types/device.js +3 -0
- package/lib/types/firmware.d.ts +36 -0
- package/lib/types/firmware.js +3 -0
- package/lib/types/index.d.ts +15 -0
- package/lib/types/index.js +11 -0
- package/lib/types/params.d.ts +56 -0
- package/lib/types/params.js +3 -0
- package/lib/types/settings.d.ts +34 -0
- package/lib/types/settings.js +3 -0
- package/lib/types/utils.d.ts +15 -0
- package/lib/types/utils.js +3 -0
- package/lib/utils/__fixtures__/accountUtils.d.ts +4 -0
- package/lib/utils/__fixtures__/accountUtils.js +32 -0
- package/lib/utils/__fixtures__/addressUtils.d.ts +10 -0
- package/lib/utils/__fixtures__/addressUtils.js +214 -0
- package/lib/utils/__fixtures__/ethereumUtils.d.ts +3 -0
- package/lib/utils/__fixtures__/ethereumUtils.js +20 -0
- package/lib/utils/__fixtures__/formatUtils.d.ts +3 -0
- package/lib/utils/__fixtures__/formatUtils.js +15 -0
- package/lib/utils/__fixtures__/hdnodeUtils.d.ts +186 -0
- package/lib/utils/__fixtures__/hdnodeUtils.js +206 -0
- package/lib/utils/accountUtils.d.ts +11 -0
- package/lib/utils/accountUtils.js +99 -0
- package/lib/utils/addressUtils.d.ts +3 -0
- package/lib/utils/addressUtils.js +32 -0
- package/lib/utils/assets-browser.d.ts +2 -0
- package/lib/utils/assets-browser.js +21 -0
- package/lib/utils/assets.d.ts +2 -0
- package/lib/utils/assets.js +28 -0
- package/lib/utils/bip39.d.ts +3 -0
- package/lib/utils/bip39.js +2053 -0
- package/lib/utils/browserUtils.d.ts +21 -0
- package/lib/utils/browserUtils.js +100 -0
- package/lib/utils/bufferUtils.d.ts +3 -0
- package/lib/utils/bufferUtils.js +11 -0
- package/lib/utils/debug.d.ts +24 -0
- package/lib/utils/debug.js +90 -0
- package/lib/utils/deferred.d.ts +18 -0
- package/lib/utils/deferred.js +66 -0
- package/lib/utils/deviceFeaturesUtils.d.ts +6 -0
- package/lib/utils/deviceFeaturesUtils.js +115 -0
- package/lib/utils/ethereumUtils.d.ts +3 -0
- package/lib/utils/ethereumUtils.js +12 -0
- package/lib/utils/firmwareUtils.d.ts +7 -0
- package/lib/utils/firmwareUtils.js +28 -0
- package/lib/utils/formatUtils.d.ts +8 -0
- package/lib/utils/formatUtils.js +57 -0
- package/lib/utils/hdnodeUtils.d.ts +8 -0
- package/lib/utils/hdnodeUtils.js +80 -0
- package/lib/utils/interactionTimeout.d.ts +10 -0
- package/lib/utils/interactionTimeout.js +34 -0
- package/lib/utils/objectUtils.d.ts +10 -0
- package/lib/utils/objectUtils.js +37 -0
- package/lib/utils/pathUtils.d.ts +20 -0
- package/lib/utils/pathUtils.js +159 -0
- package/lib/utils/promiseUtils.d.ts +2 -0
- package/lib/utils/promiseUtils.js +8 -0
- package/lib/utils/urlUtils.d.ts +5 -0
- package/lib/utils/urlUtils.js +27 -0
- package/lib/utils/versionUtils.d.ts +6 -0
- package/lib/utils/versionUtils.js +72 -0
- package/lib/utils/windowsUtils.d.ts +2 -0
- package/lib/utils/windowsUtils.js +6 -0
- package/lib/workers/RNUsbPlugin.d.ts +31 -0
- package/lib/workers/RNUsbPlugin.js +65 -0
- package/lib/workers/workers-browser.d.ts +8 -0
- package/lib/workers/workers-browser.js +19 -0
- package/lib/workers/workers-react-native.d.ts +8 -0
- package/lib/workers/workers-react-native.js +19 -0
- package/lib/workers/workers.d.ts +10 -0
- package/lib/workers/workers.js +17 -0
- package/package.json +62 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
6
|
+
const ethereumUtils_1 = require("../utils/ethereumUtils");
|
|
7
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
8
|
+
const formatUtils_1 = require("../utils/formatUtils");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const events_1 = require("../events");
|
|
11
|
+
class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.progress = 0;
|
|
15
|
+
}
|
|
16
|
+
init() {
|
|
17
|
+
this.requiredPermissions = ['read'];
|
|
18
|
+
this.hasBundle = !!this.payload.bundle;
|
|
19
|
+
const payload = !this.payload.bundle
|
|
20
|
+
? { ...this.payload, bundle: [this.payload] }
|
|
21
|
+
: this.payload;
|
|
22
|
+
(0, paramsValidator_1.validateParams)(payload, [
|
|
23
|
+
{ name: 'bundle', type: 'array' },
|
|
24
|
+
{ name: 'useEventListener', type: 'boolean' },
|
|
25
|
+
]);
|
|
26
|
+
this.params = payload.bundle.map(batch => {
|
|
27
|
+
(0, paramsValidator_1.validateParams)(batch, [
|
|
28
|
+
{ name: 'path', required: true },
|
|
29
|
+
{ name: 'address', type: 'string' },
|
|
30
|
+
{ name: 'showOnTrezor', type: 'boolean' },
|
|
31
|
+
]);
|
|
32
|
+
const path = (0, pathUtils_1.validatePath)(batch.path, 3);
|
|
33
|
+
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
34
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, network, this.firmwareRange);
|
|
35
|
+
return {
|
|
36
|
+
address_n: path,
|
|
37
|
+
show_display: typeof batch.showOnTrezor === 'boolean' ? batch.showOnTrezor : true,
|
|
38
|
+
address: batch.address,
|
|
39
|
+
network,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
if (this.params.length === 1) {
|
|
43
|
+
this.info = (0, ethereumUtils_1.getNetworkLabel)('Export #NETWORK address', this.params[0].network);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const requestedNetworks = this.params.map(b => b.network);
|
|
47
|
+
const uniqNetworks = (0, coinInfo_1.getUniqueNetworks)(requestedNetworks);
|
|
48
|
+
if (uniqNetworks.length === 1 && uniqNetworks[0]) {
|
|
49
|
+
this.info = (0, ethereumUtils_1.getNetworkLabel)('Export multiple #NETWORK addresses', uniqNetworks[0]);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.info = 'Export multiple addresses';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const useEventListener = payload.useEventListener &&
|
|
56
|
+
this.params.length === 1 &&
|
|
57
|
+
typeof this.params[0].address === 'string' &&
|
|
58
|
+
this.params[0].show_display;
|
|
59
|
+
this.confirmed = useEventListener;
|
|
60
|
+
this.useUi = !useEventListener;
|
|
61
|
+
}
|
|
62
|
+
getButtonRequestData(code) {
|
|
63
|
+
if (code === 'ButtonRequest_Address') {
|
|
64
|
+
return {
|
|
65
|
+
type: 'address',
|
|
66
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(this.params[this.progress].address_n),
|
|
67
|
+
address: this.params[this.progress].address || 'not-set',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async confirmation() {
|
|
72
|
+
if (this.confirmed)
|
|
73
|
+
return true;
|
|
74
|
+
await this.getPopupPromise().promise;
|
|
75
|
+
const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
|
|
76
|
+
this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
|
|
77
|
+
view: 'export-address',
|
|
78
|
+
label: this.info,
|
|
79
|
+
}));
|
|
80
|
+
const uiResp = await uiPromise.promise;
|
|
81
|
+
this.confirmed = uiResp.payload;
|
|
82
|
+
return this.confirmed;
|
|
83
|
+
}
|
|
84
|
+
async noBackupConfirmation() {
|
|
85
|
+
await this.getPopupPromise().promise;
|
|
86
|
+
const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
|
|
87
|
+
this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
|
|
88
|
+
view: 'no-backup',
|
|
89
|
+
}));
|
|
90
|
+
const uiResp = await uiPromise.promise;
|
|
91
|
+
return uiResp.payload;
|
|
92
|
+
}
|
|
93
|
+
_call({ address_n, show_display }) {
|
|
94
|
+
const cmd = this.device.getCommands();
|
|
95
|
+
return cmd.ethereumGetAddress({
|
|
96
|
+
address_n,
|
|
97
|
+
show_display,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async run() {
|
|
101
|
+
const responses = [];
|
|
102
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
103
|
+
const batch = this.params[i];
|
|
104
|
+
if (batch.show_display) {
|
|
105
|
+
const silent = await this._call({
|
|
106
|
+
...batch,
|
|
107
|
+
show_display: false,
|
|
108
|
+
});
|
|
109
|
+
if (typeof batch.address === 'string') {
|
|
110
|
+
if ((0, formatUtils_1.stripHexPrefix)(batch.address).toLowerCase() !==
|
|
111
|
+
(0, formatUtils_1.stripHexPrefix)(silent.address).toLowerCase()) {
|
|
112
|
+
throw constants_1.ERRORS.TypedError('Method_AddressNotMatch');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
batch.address = silent.address;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const response = await this._call(batch);
|
|
120
|
+
responses.push(response);
|
|
121
|
+
if (this.hasBundle) {
|
|
122
|
+
this.postMessage((0, events_1.createUiMessage)(events_1.UI.BUNDLE_PROGRESS, {
|
|
123
|
+
progress: i,
|
|
124
|
+
response,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
this.progress++;
|
|
128
|
+
}
|
|
129
|
+
return this.hasBundle ? responses : responses[0];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.default = EthereumGetAddress;
|
|
133
|
+
//# sourceMappingURL=ethereumGetAddress.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import type { PROTO } from '../constants';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../types';
|
|
4
|
+
declare type Params = PROTO.EthereumGetPublicKey & {
|
|
5
|
+
network?: EthereumNetworkInfo;
|
|
6
|
+
};
|
|
7
|
+
export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPublicKey', Params[]> {
|
|
8
|
+
hasBundle?: boolean;
|
|
9
|
+
confirmed?: boolean;
|
|
10
|
+
init(): void;
|
|
11
|
+
confirmation(): Promise<boolean>;
|
|
12
|
+
run(): Promise<import("../types/api/getPublicKey").HDNodeResponse | import("../types/api/getPublicKey").HDNodeResponse[]>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=ethereumGetPublicKey.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
6
|
+
const ethereumUtils_1 = require("../utils/ethereumUtils");
|
|
7
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
8
|
+
const events_1 = require("../events");
|
|
9
|
+
class EthereumGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
10
|
+
init() {
|
|
11
|
+
this.requiredPermissions = ['read'];
|
|
12
|
+
this.hasBundle = !!this.payload.bundle;
|
|
13
|
+
const payload = !this.payload.bundle
|
|
14
|
+
? { ...this.payload, bundle: [this.payload] }
|
|
15
|
+
: this.payload;
|
|
16
|
+
(0, paramsValidator_1.validateParams)(payload, [{ name: 'bundle', type: 'array' }]);
|
|
17
|
+
this.params = payload.bundle.map(batch => {
|
|
18
|
+
(0, paramsValidator_1.validateParams)(batch, [
|
|
19
|
+
{ name: 'path', required: true },
|
|
20
|
+
{ name: 'showOnTrezor', type: 'boolean' },
|
|
21
|
+
]);
|
|
22
|
+
const path = (0, pathUtils_1.validatePath)(batch.path, 3);
|
|
23
|
+
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
24
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, network, this.firmwareRange);
|
|
25
|
+
return {
|
|
26
|
+
address_n: path,
|
|
27
|
+
show_display: typeof batch.showOnTrezor === 'boolean' ? batch.showOnTrezor : false,
|
|
28
|
+
network,
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
if (this.params.length === 1) {
|
|
32
|
+
this.info = (0, ethereumUtils_1.getNetworkLabel)('Export #NETWORK public key', this.params[0].network);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const requestedNetworks = this.params.map(b => b.network);
|
|
36
|
+
const uniqNetworks = (0, coinInfo_1.getUniqueNetworks)(requestedNetworks);
|
|
37
|
+
if (uniqNetworks.length === 1 && uniqNetworks[0]) {
|
|
38
|
+
this.info = (0, ethereumUtils_1.getNetworkLabel)('Export multiple #NETWORK public keys', uniqNetworks[0]);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.info = 'Export multiple public keys';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async confirmation() {
|
|
46
|
+
if (this.confirmed)
|
|
47
|
+
return true;
|
|
48
|
+
await this.getPopupPromise().promise;
|
|
49
|
+
const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
|
|
50
|
+
this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
|
|
51
|
+
view: 'export-xpub',
|
|
52
|
+
label: this.info,
|
|
53
|
+
}));
|
|
54
|
+
const uiResp = await uiPromise.promise;
|
|
55
|
+
this.confirmed = uiResp.payload;
|
|
56
|
+
return this.confirmed;
|
|
57
|
+
}
|
|
58
|
+
async run() {
|
|
59
|
+
const responses = [];
|
|
60
|
+
const cmd = this.device.getCommands();
|
|
61
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
62
|
+
const batch = this.params[i];
|
|
63
|
+
const response = await cmd.ethereumGetPublicKey({
|
|
64
|
+
address_n: batch.address_n,
|
|
65
|
+
show_display: batch.show_display,
|
|
66
|
+
});
|
|
67
|
+
responses.push(response);
|
|
68
|
+
if (this.hasBundle) {
|
|
69
|
+
this.postMessage((0, events_1.createUiMessage)(events_1.UI.BUNDLE_PROGRESS, {
|
|
70
|
+
progress: i,
|
|
71
|
+
response,
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return this.hasBundle ? responses : responses[0];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = EthereumGetPublicKey;
|
|
79
|
+
//# sourceMappingURL=ethereumGetPublicKey.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import type { PROTO } from '../constants';
|
|
3
|
+
export default class EthereumSignMessage extends AbstractMethod<'ethereumSignMessage', PROTO.EthereumSignMessage> {
|
|
4
|
+
init(): void;
|
|
5
|
+
run(): Promise<PROTO.EthereumMessageSignature>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ethereumSignMessage.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
6
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
7
|
+
const ethereumUtils_1 = require("../utils/ethereumUtils");
|
|
8
|
+
const formatUtils_1 = require("../utils/formatUtils");
|
|
9
|
+
class EthereumSignMessage extends AbstractMethod_1.AbstractMethod {
|
|
10
|
+
init() {
|
|
11
|
+
this.requiredPermissions = ['read', 'write'];
|
|
12
|
+
const { payload } = this;
|
|
13
|
+
(0, paramsValidator_1.validateParams)(payload, [
|
|
14
|
+
{ name: 'path', required: true },
|
|
15
|
+
{ name: 'message', type: 'string', required: true },
|
|
16
|
+
{ name: 'hex', type: 'boolean' },
|
|
17
|
+
]);
|
|
18
|
+
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
19
|
+
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
20
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, network, this.firmwareRange);
|
|
21
|
+
this.info = (0, ethereumUtils_1.getNetworkLabel)('Sign #NETWORK message', network);
|
|
22
|
+
const messageHex = payload.hex
|
|
23
|
+
? (0, formatUtils_1.messageToHex)(payload.message)
|
|
24
|
+
: Buffer.from(payload.message, 'utf8').toString('hex');
|
|
25
|
+
this.params = {
|
|
26
|
+
address_n: path,
|
|
27
|
+
message: messageHex,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async run() {
|
|
31
|
+
const cmd = this.device.getCommands();
|
|
32
|
+
const { address_n, message } = this.params;
|
|
33
|
+
const response = await cmd.typedCall('EthereumSignMessage', 'EthereumMessageSignature', {
|
|
34
|
+
address_n,
|
|
35
|
+
message,
|
|
36
|
+
});
|
|
37
|
+
return response.message;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = EthereumSignMessage;
|
|
41
|
+
//# sourceMappingURL=ethereumSignMessage.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import type { EthereumTransaction, EthereumTransactionEIP1559 } from '../types/api/ethereumSignTransaction';
|
|
3
|
+
declare type Params = {
|
|
4
|
+
path: number[];
|
|
5
|
+
tx: ({
|
|
6
|
+
type: 'legacy';
|
|
7
|
+
} & EthereumTransaction) | ({
|
|
8
|
+
type: 'eip1559';
|
|
9
|
+
} & EthereumTransactionEIP1559);
|
|
10
|
+
};
|
|
11
|
+
export default class EthereumSignTransaction extends AbstractMethod<'ethereumSignTransaction', Params> {
|
|
12
|
+
init(): void;
|
|
13
|
+
run(): Promise<{
|
|
14
|
+
v: string;
|
|
15
|
+
r: string;
|
|
16
|
+
s: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=ethereumSignTransaction.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
5
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
6
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
7
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
8
|
+
const ethereumUtils_1 = require("../utils/ethereumUtils");
|
|
9
|
+
const formatUtils_1 = require("../utils/formatUtils");
|
|
10
|
+
const helper = (0, tslib_1.__importStar)(require("./ethereum/ethereumSignTx"));
|
|
11
|
+
const strip = value => {
|
|
12
|
+
if (typeof value === 'string') {
|
|
13
|
+
let stripped = (0, formatUtils_1.stripHexPrefix)(value);
|
|
14
|
+
if (stripped.length % 2 !== 0) {
|
|
15
|
+
stripped = `0${stripped}`;
|
|
16
|
+
}
|
|
17
|
+
return stripped;
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
return value.map(strip);
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === 'object') {
|
|
23
|
+
return Object.entries(value).reduce((acc, [k, v]) => ({ ...acc, [k]: strip(v) }), {});
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
28
|
+
init() {
|
|
29
|
+
this.requiredPermissions = ['read', 'write'];
|
|
30
|
+
const { payload } = this;
|
|
31
|
+
(0, paramsValidator_1.validateParams)(payload, [
|
|
32
|
+
{ name: 'path', required: true },
|
|
33
|
+
{ name: 'transaction', required: true },
|
|
34
|
+
]);
|
|
35
|
+
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
36
|
+
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
37
|
+
this.info = (0, ethereumUtils_1.getNetworkLabel)('Sign #NETWORK transaction', network);
|
|
38
|
+
const tx = payload.transaction;
|
|
39
|
+
const isEIP1559 = tx.maxFeePerGas && tx.maxPriorityFeePerGas;
|
|
40
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(isEIP1559 ? 'eip1559' : this.name, network, this.firmwareRange);
|
|
41
|
+
const schema = isEIP1559
|
|
42
|
+
? [
|
|
43
|
+
{ name: 'to', type: 'string', required: true },
|
|
44
|
+
{ name: 'value', type: 'string', required: true },
|
|
45
|
+
{ name: 'gasLimit', type: 'string', required: true },
|
|
46
|
+
{ name: 'maxFeePerGas', type: 'string', required: true },
|
|
47
|
+
{ name: 'maxPriorityFeePerGas', type: 'string', required: true },
|
|
48
|
+
{ name: 'nonce', type: 'string', required: true },
|
|
49
|
+
{ name: 'data', type: 'string' },
|
|
50
|
+
{ name: 'chainId', type: 'number', required: true },
|
|
51
|
+
]
|
|
52
|
+
: [
|
|
53
|
+
{ name: 'to', type: 'string', required: true },
|
|
54
|
+
{ name: 'value', type: 'string', required: true },
|
|
55
|
+
{ name: 'gasLimit', type: 'string', required: true },
|
|
56
|
+
{ name: 'gasPrice', type: 'string', required: true },
|
|
57
|
+
{ name: 'nonce', type: 'string', required: true },
|
|
58
|
+
{ name: 'data', type: 'string' },
|
|
59
|
+
{ name: 'chainId', type: 'number' },
|
|
60
|
+
{ name: 'txType', type: 'number' },
|
|
61
|
+
];
|
|
62
|
+
(0, paramsValidator_1.validateParams)(tx, schema);
|
|
63
|
+
if (typeof tx.chainId !== 'number') {
|
|
64
|
+
console.warn('TrezorConnect.ethereumSignTransaction: Missing chainId parameter!');
|
|
65
|
+
}
|
|
66
|
+
this.params = {
|
|
67
|
+
path,
|
|
68
|
+
tx: {
|
|
69
|
+
type: isEIP1559 ? 'eip1559' : 'legacy',
|
|
70
|
+
...strip(tx),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
run() {
|
|
75
|
+
const { tx } = this.params;
|
|
76
|
+
return tx.type === 'eip1559'
|
|
77
|
+
? helper.ethereumSignTxEIP1559(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, tx.to, tx.value, tx.gasLimit, tx.maxFeePerGas, tx.maxPriorityFeePerGas, tx.nonce, tx.chainId, tx.data, tx.accessList)
|
|
78
|
+
: helper.ethereumSignTx(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, tx.to, tx.value, tx.gasLimit, tx.gasPrice, tx.nonce, tx.chainId, tx.data, tx.txType);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.default = EthereumSignTransaction;
|
|
82
|
+
//# sourceMappingURL=ethereumSignTransaction.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import type { EthereumSignTypedDataTypes, EthereumSignTypedData as EthereumSignTypedDataParams, EthereumSignTypedHash as EthereumSignTypedHashParams } from '../types/api/ethereumSignTypedData';
|
|
3
|
+
declare type Params = (Omit<EthereumSignTypedDataParams<EthereumSignTypedDataTypes>, 'path'> | Omit<EthereumSignTypedHashParams<EthereumSignTypedDataTypes>, 'path'>) & {
|
|
4
|
+
address_n: number[];
|
|
5
|
+
};
|
|
6
|
+
export default class EthereumSignTypedData extends AbstractMethod<'ethereumSignTypedData', Params> {
|
|
7
|
+
init(): void;
|
|
8
|
+
run(): Promise<{
|
|
9
|
+
address: string;
|
|
10
|
+
signature: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=ethereumSignTypedData.d.ts.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
6
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
7
|
+
const ethereumUtils_1 = require("../utils/ethereumUtils");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const ethereumSignTypedData_1 = require("./ethereum/ethereumSignTypedData");
|
|
10
|
+
const formatUtils_1 = require("../utils/formatUtils");
|
|
11
|
+
class EthereumSignTypedData extends AbstractMethod_1.AbstractMethod {
|
|
12
|
+
init() {
|
|
13
|
+
this.requiredPermissions = ['read', 'write'];
|
|
14
|
+
const { payload } = this;
|
|
15
|
+
(0, paramsValidator_1.validateParams)(payload, [
|
|
16
|
+
{ name: 'path', required: true },
|
|
17
|
+
{ name: 'metamask_v4_compat', type: 'boolean', required: true },
|
|
18
|
+
{ name: 'data', type: 'object', required: true },
|
|
19
|
+
{ name: 'domain_separator_hash', type: 'string' },
|
|
20
|
+
{ name: 'message_hash', type: 'string' },
|
|
21
|
+
]);
|
|
22
|
+
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
23
|
+
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
24
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, network, this.firmwareRange);
|
|
25
|
+
this.info = (0, ethereumUtils_1.getNetworkLabel)('Sign #NETWORK typed data', network);
|
|
26
|
+
this.params = {
|
|
27
|
+
address_n: path,
|
|
28
|
+
metamask_v4_compat: payload.metamask_v4_compat,
|
|
29
|
+
data: payload.data,
|
|
30
|
+
};
|
|
31
|
+
if (payload.domain_separator_hash) {
|
|
32
|
+
this.params = {
|
|
33
|
+
...this.params,
|
|
34
|
+
domain_separator_hash: (0, formatUtils_1.messageToHex)(payload.domain_separator_hash),
|
|
35
|
+
};
|
|
36
|
+
if (payload.message_hash) {
|
|
37
|
+
this.params = {
|
|
38
|
+
...this.params,
|
|
39
|
+
message_hash: (0, formatUtils_1.messageToHex)(payload.message_hash),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else if (this.params.data.primaryType !== 'EIP712Domain') {
|
|
43
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'message_hash should only be empty when data.primaryType=EIP712Domain');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (this.params.data.primaryType === 'EIP712Domain') {
|
|
47
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)('eip712-domain-only', network, this.firmwareRange);
|
|
48
|
+
if ('message_hash' in this.params) {
|
|
49
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'message_hash should be empty when data.primaryType=EIP712Domain');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async run() {
|
|
54
|
+
const cmd = this.device.getCommands();
|
|
55
|
+
const { address_n } = this.params;
|
|
56
|
+
if (this.device.features.model === '1') {
|
|
57
|
+
(0, paramsValidator_1.validateParams)(this.params, [
|
|
58
|
+
{ name: 'domain_separator_hash', type: 'string', required: true },
|
|
59
|
+
{ name: 'message_hash', type: 'string' },
|
|
60
|
+
]);
|
|
61
|
+
const { domain_separator_hash, message_hash } = this.params;
|
|
62
|
+
const response = await cmd.typedCall('EthereumSignTypedHash', 'EthereumTypedDataSignature', {
|
|
63
|
+
address_n,
|
|
64
|
+
domain_separator_hash: domain_separator_hash,
|
|
65
|
+
message_hash,
|
|
66
|
+
});
|
|
67
|
+
const { address, signature } = response.message;
|
|
68
|
+
return {
|
|
69
|
+
address,
|
|
70
|
+
signature: `0x${signature}`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const { data, metamask_v4_compat } = this.params;
|
|
74
|
+
const { types, primaryType, domain, message } = data;
|
|
75
|
+
let response = await cmd.typedCall('EthereumSignTypedData', [
|
|
76
|
+
'EthereumTypedDataStructRequest',
|
|
77
|
+
'EthereumTypedDataValueRequest',
|
|
78
|
+
'EthereumTypedDataSignature',
|
|
79
|
+
], {
|
|
80
|
+
address_n,
|
|
81
|
+
primary_type: primaryType,
|
|
82
|
+
metamask_v4_compat,
|
|
83
|
+
});
|
|
84
|
+
while (response.type === 'EthereumTypedDataStructRequest') {
|
|
85
|
+
const { name: typeDefinitionName } = response.message;
|
|
86
|
+
const typeDefinition = types[typeDefinitionName];
|
|
87
|
+
if (typeDefinition === undefined) {
|
|
88
|
+
throw constants_1.ERRORS.TypedError('Runtime', `Type ${typeDefinitionName} was not defined in types object`);
|
|
89
|
+
}
|
|
90
|
+
const dataStruckAck = {
|
|
91
|
+
members: typeDefinition.map(({ name, type: typeName }) => ({
|
|
92
|
+
name,
|
|
93
|
+
type: (0, ethereumSignTypedData_1.getFieldType)(typeName, types),
|
|
94
|
+
})),
|
|
95
|
+
};
|
|
96
|
+
response = await cmd.typedCall('EthereumTypedDataStructAck', [
|
|
97
|
+
'EthereumTypedDataStructRequest',
|
|
98
|
+
'EthereumTypedDataValueRequest',
|
|
99
|
+
'EthereumTypedDataSignature',
|
|
100
|
+
], dataStruckAck);
|
|
101
|
+
}
|
|
102
|
+
while (response.type === 'EthereumTypedDataValueRequest') {
|
|
103
|
+
const { member_path } = response.message;
|
|
104
|
+
let memberData;
|
|
105
|
+
let memberTypeName;
|
|
106
|
+
const [rootIndex, ...nestedMemberPath] = member_path;
|
|
107
|
+
switch (rootIndex) {
|
|
108
|
+
case 0:
|
|
109
|
+
memberData = domain;
|
|
110
|
+
memberTypeName = 'EIP712Domain';
|
|
111
|
+
break;
|
|
112
|
+
case 1:
|
|
113
|
+
memberData = message;
|
|
114
|
+
memberTypeName = primaryType;
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'Root index can only be 0 or 1');
|
|
118
|
+
}
|
|
119
|
+
for (const index of nestedMemberPath) {
|
|
120
|
+
if (Array.isArray(memberData)) {
|
|
121
|
+
memberTypeName = (0, ethereumSignTypedData_1.parseArrayType)(memberTypeName).entryTypeName;
|
|
122
|
+
memberData = memberData[index];
|
|
123
|
+
}
|
|
124
|
+
else if (typeof memberData === 'object' && memberData !== null) {
|
|
125
|
+
const memberTypeDefinition = types[memberTypeName][index];
|
|
126
|
+
memberTypeName = memberTypeDefinition.type;
|
|
127
|
+
memberData = memberData[memberTypeDefinition.name];
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
let encodedData;
|
|
133
|
+
if (Array.isArray(memberData)) {
|
|
134
|
+
encodedData = (0, ethereumSignTypedData_1.encodeData)('uint16', memberData.length);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
encodedData = (0, ethereumSignTypedData_1.encodeData)(memberTypeName, memberData);
|
|
138
|
+
}
|
|
139
|
+
response = await cmd.typedCall('EthereumTypedDataValueAck', ['EthereumTypedDataValueRequest', 'EthereumTypedDataSignature'], {
|
|
140
|
+
value: encodedData,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const { address, signature } = response.message;
|
|
144
|
+
return {
|
|
145
|
+
address,
|
|
146
|
+
signature: `0x${signature}`,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.default = EthereumSignTypedData;
|
|
151
|
+
//# sourceMappingURL=ethereumSignTypedData.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import type { PROTO } from '../constants';
|
|
3
|
+
export default class EthereumVerifyMessage extends AbstractMethod<'ethereumVerifyMessage', PROTO.EthereumVerifyMessage> {
|
|
4
|
+
init(): void;
|
|
5
|
+
run(): Promise<PROTO.Success>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ethereumVerifyMessage.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
|
+
const formatUtils_1 = require("../utils/formatUtils");
|
|
6
|
+
class EthereumVerifyMessage extends AbstractMethod_1.AbstractMethod {
|
|
7
|
+
init() {
|
|
8
|
+
this.requiredPermissions = ['read', 'write'];
|
|
9
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
|
|
10
|
+
this.info = 'Verify message';
|
|
11
|
+
const { payload } = this;
|
|
12
|
+
(0, paramsValidator_1.validateParams)(payload, [
|
|
13
|
+
{ name: 'address', type: 'string', required: true },
|
|
14
|
+
{ name: 'signature', type: 'string', required: true },
|
|
15
|
+
{ name: 'message', type: 'string', required: true },
|
|
16
|
+
{ name: 'hex', type: 'boolean' },
|
|
17
|
+
]);
|
|
18
|
+
const messageHex = payload.hex
|
|
19
|
+
? (0, formatUtils_1.messageToHex)(payload.message)
|
|
20
|
+
: Buffer.from(payload.message, 'utf8').toString('hex');
|
|
21
|
+
this.params = {
|
|
22
|
+
address: (0, formatUtils_1.stripHexPrefix)(payload.address),
|
|
23
|
+
signature: (0, formatUtils_1.stripHexPrefix)(payload.signature),
|
|
24
|
+
message: messageHex,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async run() {
|
|
28
|
+
const cmd = this.device.getCommands();
|
|
29
|
+
const response = await cmd.typedCall('EthereumVerifyMessage', 'Success', this.params);
|
|
30
|
+
return response.message;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = EthereumVerifyMessage;
|
|
34
|
+
//# sourceMappingURL=ethereumVerifyMessage.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GetInfoProps } from '../../data/firmwareInfo';
|
|
2
|
+
interface GetBinaryProps extends GetInfoProps {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
btcOnly?: boolean;
|
|
5
|
+
version?: number[];
|
|
6
|
+
intermediary?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const getBinary: ({ features, releases, baseUrl, version, btcOnly, intermediary, }: GetBinaryProps) => Promise<{
|
|
9
|
+
binary: ArrayBuffer;
|
|
10
|
+
} | {
|
|
11
|
+
binary: ArrayBuffer;
|
|
12
|
+
changelog: import("../..").FirmwareRelease[] | null;
|
|
13
|
+
release: import("../..").FirmwareRelease;
|
|
14
|
+
isLatest: boolean;
|
|
15
|
+
latest: import("../..").FirmwareRelease;
|
|
16
|
+
isRequired: boolean | null;
|
|
17
|
+
isNewer: boolean | null;
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=getBinary.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBinary = void 0;
|
|
4
|
+
const utils_1 = require("@trezor/utils");
|
|
5
|
+
const assets_1 = require("../../utils/assets");
|
|
6
|
+
const firmwareUtils_1 = require("../../utils/firmwareUtils");
|
|
7
|
+
const firmwareInfo_1 = require("../../data/firmwareInfo");
|
|
8
|
+
const modifyFirmware_1 = require("./modifyFirmware");
|
|
9
|
+
const getBinary = async ({ features, releases, baseUrl, version, btcOnly, intermediary = false, }) => {
|
|
10
|
+
if (!(0, firmwareUtils_1.isStrictFeatures)(features)) {
|
|
11
|
+
throw new Error('Features of unexpected shape provided');
|
|
12
|
+
}
|
|
13
|
+
if (intermediary && features.major_version !== 2) {
|
|
14
|
+
const fw = await (0, assets_1.httpRequest)(`${baseUrl}/firmware/1/trezor-inter-1.10.0.bin`, 'binary');
|
|
15
|
+
return { binary: (0, modifyFirmware_1.modifyFirmware)({ fw, features }) };
|
|
16
|
+
}
|
|
17
|
+
const infoByBootloader = (0, firmwareInfo_1.getInfo)({ features, releases });
|
|
18
|
+
const releaseByFirmware = releases.find(r => version &&
|
|
19
|
+
utils_1.versionUtils.isVersionArray(version) &&
|
|
20
|
+
utils_1.versionUtils.isEqual(r.version, version));
|
|
21
|
+
if (!infoByBootloader || !releaseByFirmware) {
|
|
22
|
+
throw new Error('no firmware found for this device');
|
|
23
|
+
}
|
|
24
|
+
if (btcOnly && !releaseByFirmware.url_bitcoinonly) {
|
|
25
|
+
throw new Error(`firmware version ${version} does not exist in btc only variant`);
|
|
26
|
+
}
|
|
27
|
+
if (!utils_1.versionUtils.isEqual(releaseByFirmware.version, infoByBootloader.release.version)) {
|
|
28
|
+
throw new Error('version provided as param does not match firmware version found by features in bootloader');
|
|
29
|
+
}
|
|
30
|
+
const fw = await (0, assets_1.httpRequest)(`${baseUrl}/${btcOnly ? releaseByFirmware.url_bitcoinonly : releaseByFirmware.url}`, 'binary');
|
|
31
|
+
return {
|
|
32
|
+
...infoByBootloader,
|
|
33
|
+
binary: (0, modifyFirmware_1.modifyFirmware)({ fw, features }),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.getBinary = getBinary;
|
|
37
|
+
//# sourceMappingURL=getBinary.js.map
|