@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,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeData = exports.getFieldType = exports.parseArrayType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bignumber_js_1 = (0, tslib_1.__importDefault)(require("bignumber.js"));
|
|
6
|
+
const errors_1 = require("../../../constants/errors");
|
|
7
|
+
const constants_1 = require("../../../constants");
|
|
8
|
+
exports.parseArrayType = [
|
|
9
|
+
{
|
|
10
|
+
description: 'should parse sized arrays',
|
|
11
|
+
input: 'uint8[26]',
|
|
12
|
+
output: {
|
|
13
|
+
entryTypeName: 'uint8',
|
|
14
|
+
arraySize: 26,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
description: 'should parse dynamic arrays',
|
|
19
|
+
input: 'int32[]',
|
|
20
|
+
output: {
|
|
21
|
+
entryTypeName: 'int32',
|
|
22
|
+
arraySize: null,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
description: 'should parse nested arrays',
|
|
27
|
+
input: 'int32[5][12]',
|
|
28
|
+
output: {
|
|
29
|
+
entryTypeName: 'int32[5]',
|
|
30
|
+
arraySize: 12,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: 'should throw error for non-array type',
|
|
35
|
+
input: 'bytes',
|
|
36
|
+
error: [errors_1.TrezorError, 'could not be parsed'],
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
exports.getFieldType = [
|
|
40
|
+
{
|
|
41
|
+
description: `should parse uints`,
|
|
42
|
+
input: {
|
|
43
|
+
typeName: 'uint256',
|
|
44
|
+
types: {},
|
|
45
|
+
},
|
|
46
|
+
output: {
|
|
47
|
+
data_type: constants_1.PROTO.EthereumDataType.UINT,
|
|
48
|
+
size: 32,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
description: `should parse ints`,
|
|
53
|
+
input: {
|
|
54
|
+
typeName: 'int8',
|
|
55
|
+
types: {},
|
|
56
|
+
},
|
|
57
|
+
output: {
|
|
58
|
+
data_type: constants_1.PROTO.EthereumDataType.INT,
|
|
59
|
+
size: 1,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
description: `should parse booleans`,
|
|
64
|
+
input: {
|
|
65
|
+
typeName: 'bool',
|
|
66
|
+
types: {},
|
|
67
|
+
},
|
|
68
|
+
output: {
|
|
69
|
+
data_type: constants_1.PROTO.EthereumDataType.BOOL,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
description: `should parse address`,
|
|
74
|
+
input: {
|
|
75
|
+
typeName: 'address',
|
|
76
|
+
types: {},
|
|
77
|
+
},
|
|
78
|
+
output: {
|
|
79
|
+
data_type: constants_1.PROTO.EthereumDataType.ADDRESS,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
description: `should parse dynamic bytes`,
|
|
84
|
+
input: {
|
|
85
|
+
typeName: 'bytes',
|
|
86
|
+
types: {},
|
|
87
|
+
},
|
|
88
|
+
output: {
|
|
89
|
+
data_type: constants_1.PROTO.EthereumDataType.BYTES,
|
|
90
|
+
size: undefined,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
description: `should parse fixed-size bytes`,
|
|
95
|
+
input: {
|
|
96
|
+
typeName: 'bytes18',
|
|
97
|
+
types: {},
|
|
98
|
+
},
|
|
99
|
+
output: {
|
|
100
|
+
data_type: constants_1.PROTO.EthereumDataType.BYTES,
|
|
101
|
+
size: 18,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
description: `should parse array types`,
|
|
106
|
+
input: {
|
|
107
|
+
typeName: 'uint256[57]',
|
|
108
|
+
types: {},
|
|
109
|
+
},
|
|
110
|
+
output: {
|
|
111
|
+
data_type: constants_1.PROTO.EthereumDataType.ARRAY,
|
|
112
|
+
size: 57,
|
|
113
|
+
entry_type: {
|
|
114
|
+
data_type: constants_1.PROTO.EthereumDataType.UINT,
|
|
115
|
+
size: 32,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
description: `should parse dynamic array types`,
|
|
121
|
+
input: {
|
|
122
|
+
typeName: 'uint256[]',
|
|
123
|
+
types: {},
|
|
124
|
+
},
|
|
125
|
+
output: {
|
|
126
|
+
data_type: constants_1.PROTO.EthereumDataType.ARRAY,
|
|
127
|
+
size: undefined,
|
|
128
|
+
entry_type: {
|
|
129
|
+
data_type: constants_1.PROTO.EthereumDataType.UINT,
|
|
130
|
+
size: 32,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
description: 'should parse nested arrays',
|
|
136
|
+
input: {
|
|
137
|
+
typeName: 'int32[5][12]',
|
|
138
|
+
types: {},
|
|
139
|
+
},
|
|
140
|
+
output: {
|
|
141
|
+
data_type: constants_1.PROTO.EthereumDataType.ARRAY,
|
|
142
|
+
size: 12,
|
|
143
|
+
entry_type: {
|
|
144
|
+
data_type: constants_1.PROTO.EthereumDataType.ARRAY,
|
|
145
|
+
size: 5,
|
|
146
|
+
entry_type: {
|
|
147
|
+
data_type: constants_1.PROTO.EthereumDataType.INT,
|
|
148
|
+
size: 4,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
description: `should parse Struct types`,
|
|
155
|
+
input: {
|
|
156
|
+
typeName: 'ExampleStruct',
|
|
157
|
+
types: {
|
|
158
|
+
ExampleStruct: [
|
|
159
|
+
{ name: 'message', type: 'string' },
|
|
160
|
+
{ name: 'cost', type: 'int8' },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
output: {
|
|
165
|
+
data_type: constants_1.PROTO.EthereumDataType.STRUCT,
|
|
166
|
+
size: 2,
|
|
167
|
+
struct_name: 'ExampleStruct',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
description: `should throw if Struct type not defined`,
|
|
172
|
+
input: {
|
|
173
|
+
typeName: 'MissingType',
|
|
174
|
+
types: {},
|
|
175
|
+
},
|
|
176
|
+
error: [errors_1.TrezorError, 'No type definition specified: MissingType'],
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
exports.encodeData = [
|
|
180
|
+
{
|
|
181
|
+
description: 'should remove leading `0x` from byte hex-string',
|
|
182
|
+
input: {
|
|
183
|
+
typeName: 'bytes',
|
|
184
|
+
data: '0x0123456789abcdef',
|
|
185
|
+
},
|
|
186
|
+
output: '0123456789abcdef',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
description: 'should pad hex to nearest byte',
|
|
190
|
+
input: {
|
|
191
|
+
typeName: 'bytes',
|
|
192
|
+
data: '0x1',
|
|
193
|
+
},
|
|
194
|
+
output: '01',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
description: 'should encode bytes from Buffer',
|
|
198
|
+
input: {
|
|
199
|
+
typeName: 'bytes',
|
|
200
|
+
data: Buffer.from('0123456789abcdef', 'hex'),
|
|
201
|
+
},
|
|
202
|
+
output: '0123456789abcdef',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
description: 'should encode bytes from ArrayBuffer',
|
|
206
|
+
input: {
|
|
207
|
+
typeName: 'bytes',
|
|
208
|
+
data: new Uint8Array([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]).buffer,
|
|
209
|
+
},
|
|
210
|
+
output: '0123456789abcdef',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
description: 'should remove leading `0x` from Ethereum address',
|
|
214
|
+
input: {
|
|
215
|
+
typeName: 'address',
|
|
216
|
+
data: '0x000000000000000000000000000000000000dead',
|
|
217
|
+
},
|
|
218
|
+
output: '000000000000000000000000000000000000dead',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
description: `should encode unsigned integers`,
|
|
222
|
+
input: {
|
|
223
|
+
typeName: 'uint8',
|
|
224
|
+
data: 255,
|
|
225
|
+
},
|
|
226
|
+
output: 'ff',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
description: `should encode positive signed integers`,
|
|
230
|
+
input: {
|
|
231
|
+
typeName: 'int8',
|
|
232
|
+
data: 127,
|
|
233
|
+
},
|
|
234
|
+
output: '7f',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
description: `should encode negative signed integers`,
|
|
238
|
+
input: {
|
|
239
|
+
typeName: 'int8',
|
|
240
|
+
data: -1,
|
|
241
|
+
},
|
|
242
|
+
output: 'ff',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
description: `should encode int from bigint`,
|
|
246
|
+
input: {
|
|
247
|
+
typeName: 'int256',
|
|
248
|
+
data: -(1n << 254n) + 1n,
|
|
249
|
+
},
|
|
250
|
+
output: 'c000000000000000000000000000000000000000000000000000000000000001',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
description: `should encode int from string`,
|
|
254
|
+
input: {
|
|
255
|
+
typeName: 'int256',
|
|
256
|
+
data: `${-(1n << 254n) + 1n}`,
|
|
257
|
+
},
|
|
258
|
+
output: 'c000000000000000000000000000000000000000000000000000000000000001',
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
description: `should encode int from BigNumber`,
|
|
262
|
+
input: {
|
|
263
|
+
typeName: 'int256',
|
|
264
|
+
data: new bignumber_js_1.default(2).pow(254).negated().plus(1),
|
|
265
|
+
},
|
|
266
|
+
output: 'c000000000000000000000000000000000000000000000000000000000000001',
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
description: `should encode uint from hex-string`,
|
|
270
|
+
input: {
|
|
271
|
+
typeName: 'uint256',
|
|
272
|
+
data: '0xc000000000000000000000000000000000000000000000000000000000000001',
|
|
273
|
+
},
|
|
274
|
+
output: 'c000000000000000000000000000000000000000000000000000000000000001',
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
description: `should throw overflow error when signed int is too large`,
|
|
278
|
+
input: {
|
|
279
|
+
typeName: 'int8',
|
|
280
|
+
data: 128,
|
|
281
|
+
},
|
|
282
|
+
error: [errors_1.TrezorError, 'overflow'],
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
description: `should throw overflow error when signed int is too small`,
|
|
286
|
+
input: {
|
|
287
|
+
typeName: 'int8',
|
|
288
|
+
data: -129,
|
|
289
|
+
},
|
|
290
|
+
error: [errors_1.TrezorError, 'overflow'],
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
description: `should throw overflow error when unsigned int is too large`,
|
|
294
|
+
input: {
|
|
295
|
+
typeName: 'uint8',
|
|
296
|
+
data: 256,
|
|
297
|
+
},
|
|
298
|
+
error: [errors_1.TrezorError, 'overflow'],
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
description: `should throw error when unsigned int is negative`,
|
|
302
|
+
input: {
|
|
303
|
+
typeName: 'uint8',
|
|
304
|
+
data: -1,
|
|
305
|
+
},
|
|
306
|
+
error: [errors_1.TrezorError, 'negative'],
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
description: 'should encode string as utf-8',
|
|
310
|
+
input: {
|
|
311
|
+
typeName: 'string',
|
|
312
|
+
data: 'Trezor Model T is an amazing piece of hardware. 😋😋',
|
|
313
|
+
},
|
|
314
|
+
output: '5472657a6f72204d6f64656c205420697320616e20616d617a696e67207069656365206f662068617264776172652e20f09f988bf09f988b',
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
description: 'should encode bool as a single byte',
|
|
318
|
+
input: {
|
|
319
|
+
typeName: 'bool',
|
|
320
|
+
data: true,
|
|
321
|
+
},
|
|
322
|
+
output: '01',
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
description: 'should encode bool as a single byte',
|
|
326
|
+
input: {
|
|
327
|
+
typeName: 'bool',
|
|
328
|
+
data: false,
|
|
329
|
+
},
|
|
330
|
+
output: '00',
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
description: 'should throw for array types',
|
|
334
|
+
input: {
|
|
335
|
+
typeName: 'bool[1]',
|
|
336
|
+
data: [true],
|
|
337
|
+
},
|
|
338
|
+
error: [errors_1.TrezorError, 'Unsupported'],
|
|
339
|
+
},
|
|
340
|
+
];
|
|
341
|
+
//# sourceMappingURL=ethereumSignTypedData.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TypedCall } from '../../device/DeviceCommands';
|
|
2
|
+
import type { EthereumAccessList } from '../../types/api/ethereumSignTransaction';
|
|
3
|
+
export declare const ethereumSignTx: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, gas_price: string, nonce: string, chain_id: number, data?: string | undefined, tx_type?: number | undefined) => Promise<{
|
|
4
|
+
v: string;
|
|
5
|
+
r: string;
|
|
6
|
+
s: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const ethereumSignTxEIP1559: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, max_gas_fee: string, max_priority_fee: string, nonce: string, chain_id: number, data?: string | undefined, access_list?: EthereumAccessList[] | undefined) => Promise<{
|
|
9
|
+
v: string;
|
|
10
|
+
r: string;
|
|
11
|
+
s: string;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=ethereumSignTx.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ethereumSignTxEIP1559 = exports.ethereumSignTx = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const splitString = (str, len) => {
|
|
6
|
+
if (str == null) {
|
|
7
|
+
return ['', ''];
|
|
8
|
+
}
|
|
9
|
+
const first = str.slice(0, len);
|
|
10
|
+
const second = str.slice(len);
|
|
11
|
+
return [first, second];
|
|
12
|
+
};
|
|
13
|
+
const processTxRequest = async (typedCall, request, data, chain_id) => {
|
|
14
|
+
if (!request.data_length) {
|
|
15
|
+
let v = request.signature_v;
|
|
16
|
+
const r = request.signature_r;
|
|
17
|
+
const s = request.signature_s;
|
|
18
|
+
if (v == null || r == null || s == null) {
|
|
19
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'processTxRequest: Unexpected request');
|
|
20
|
+
}
|
|
21
|
+
if (chain_id && v <= 1) {
|
|
22
|
+
v += 2 * chain_id + 35;
|
|
23
|
+
}
|
|
24
|
+
return Promise.resolve({
|
|
25
|
+
v: `0x${v.toString(16)}`,
|
|
26
|
+
r: `0x${r}`,
|
|
27
|
+
s: `0x${s}`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const [first, rest] = splitString(data, request.data_length * 2);
|
|
31
|
+
const response = await typedCall('EthereumTxAck', 'EthereumTxRequest', { data_chunk: first });
|
|
32
|
+
return processTxRequest(typedCall, response.message, rest, chain_id);
|
|
33
|
+
};
|
|
34
|
+
const stripLeadingZeroes = (str) => {
|
|
35
|
+
while (/^00/.test(str)) {
|
|
36
|
+
str = str.slice(2);
|
|
37
|
+
}
|
|
38
|
+
return str;
|
|
39
|
+
};
|
|
40
|
+
const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_price, nonce, chain_id, data, tx_type) => {
|
|
41
|
+
const length = data == null ? 0 : data.length / 2;
|
|
42
|
+
const [first, rest] = splitString(data, 1024 * 2);
|
|
43
|
+
let message = {
|
|
44
|
+
address_n,
|
|
45
|
+
chain_id,
|
|
46
|
+
nonce: stripLeadingZeroes(nonce),
|
|
47
|
+
gas_price: stripLeadingZeroes(gas_price),
|
|
48
|
+
gas_limit: stripLeadingZeroes(gas_limit),
|
|
49
|
+
to,
|
|
50
|
+
value: stripLeadingZeroes(value),
|
|
51
|
+
};
|
|
52
|
+
if (length !== 0) {
|
|
53
|
+
message = {
|
|
54
|
+
...message,
|
|
55
|
+
data_length: length,
|
|
56
|
+
data_initial_chunk: first,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (tx_type !== null) {
|
|
60
|
+
message = {
|
|
61
|
+
...message,
|
|
62
|
+
tx_type,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const response = await typedCall('EthereumSignTx', 'EthereumTxRequest', message);
|
|
66
|
+
return processTxRequest(typedCall, response.message, rest, chain_id);
|
|
67
|
+
};
|
|
68
|
+
exports.ethereumSignTx = ethereumSignTx;
|
|
69
|
+
const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit, max_gas_fee, max_priority_fee, nonce, chain_id, data, access_list) => {
|
|
70
|
+
const length = data == null ? 0 : data.length / 2;
|
|
71
|
+
const [first, rest] = splitString(data, 1024 * 2);
|
|
72
|
+
const message = {
|
|
73
|
+
address_n,
|
|
74
|
+
nonce: stripLeadingZeroes(nonce),
|
|
75
|
+
max_gas_fee: stripLeadingZeroes(max_gas_fee),
|
|
76
|
+
max_priority_fee: stripLeadingZeroes(max_priority_fee),
|
|
77
|
+
gas_limit: stripLeadingZeroes(gas_limit),
|
|
78
|
+
to,
|
|
79
|
+
value: stripLeadingZeroes(value),
|
|
80
|
+
data_length: length,
|
|
81
|
+
data_initial_chunk: first,
|
|
82
|
+
chain_id,
|
|
83
|
+
access_list: (access_list || []).map(a => ({
|
|
84
|
+
address: a.address,
|
|
85
|
+
storage_keys: a.storageKeys,
|
|
86
|
+
})),
|
|
87
|
+
};
|
|
88
|
+
const response = await typedCall('EthereumSignTxEIP1559', 'EthereumTxRequest', message);
|
|
89
|
+
return processTxRequest(typedCall, response.message, rest);
|
|
90
|
+
};
|
|
91
|
+
exports.ethereumSignTxEIP1559 = ethereumSignTxEIP1559;
|
|
92
|
+
//# sourceMappingURL=ethereumSignTx.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PROTO } from '../../constants';
|
|
2
|
+
import type { EthereumSignTypedDataTypes } from '../../types/api/ethereumSignTypedData';
|
|
3
|
+
export declare function parseArrayType(arrayTypeName: string): {
|
|
4
|
+
entryTypeName: string;
|
|
5
|
+
arraySize: number | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function encodeData(typeName: string, data: any): string;
|
|
8
|
+
export declare function getFieldType(typeName: string, types: EthereumSignTypedDataTypes): PROTO.EthereumFieldType;
|
|
9
|
+
//# sourceMappingURL=ethereumSignTypedData.d.ts.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFieldType = exports.encodeData = exports.parseArrayType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bignumber_js_1 = (0, tslib_1.__importDefault)(require("bignumber.js"));
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
const formatUtils_1 = require("../../utils/formatUtils");
|
|
8
|
+
const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/);
|
|
9
|
+
const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
|
|
10
|
+
const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
|
|
11
|
+
function parseArrayType(arrayTypeName) {
|
|
12
|
+
const arrayMatch = paramTypeArray.exec(arrayTypeName);
|
|
13
|
+
if (arrayMatch === null) {
|
|
14
|
+
throw constants_1.ERRORS.TypedError('Runtime', `typename ${arrayTypeName} could not be parsed as an EIP-712 array`);
|
|
15
|
+
}
|
|
16
|
+
const [_, entryTypeName, arraySize] = arrayMatch;
|
|
17
|
+
return {
|
|
18
|
+
entryTypeName,
|
|
19
|
+
arraySize: parseInt(arraySize, 10) || null,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.parseArrayType = parseArrayType;
|
|
23
|
+
function twosComplement(number, bytes) {
|
|
24
|
+
if (bytes < 1 || bytes > 32) {
|
|
25
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'Int byte size must be between 1 and 32 (8 and 256 bits)');
|
|
26
|
+
}
|
|
27
|
+
const minValue = new bignumber_js_1.default(2).exponentiatedBy(bytes * 8 - 1).negated();
|
|
28
|
+
const maxValue = minValue.negated().minus(1);
|
|
29
|
+
const bigNumber = new bignumber_js_1.default(number);
|
|
30
|
+
if (bigNumber.isGreaterThan(maxValue) || bigNumber.isLessThan(minValue)) {
|
|
31
|
+
throw constants_1.ERRORS.TypedError('Runtime', `Overflow when trying to convert number ${number} into ${bytes} bytes`);
|
|
32
|
+
}
|
|
33
|
+
if (bigNumber.isPositive()) {
|
|
34
|
+
return bigNumber;
|
|
35
|
+
}
|
|
36
|
+
return bigNumber.minus(minValue).minus(minValue);
|
|
37
|
+
}
|
|
38
|
+
function intToHex(number, bytes, signed) {
|
|
39
|
+
let bigNumber = new bignumber_js_1.default(number);
|
|
40
|
+
if (signed) {
|
|
41
|
+
bigNumber = twosComplement(bigNumber, bytes);
|
|
42
|
+
}
|
|
43
|
+
if (bigNumber.isNegative()) {
|
|
44
|
+
throw constants_1.ERRORS.TypedError('Runtime', `Cannot convert negative number to unsigned interger: ${number}`);
|
|
45
|
+
}
|
|
46
|
+
const hex = bigNumber.toString(16);
|
|
47
|
+
const hexChars = bytes * 2;
|
|
48
|
+
if (hex.length > hexChars) {
|
|
49
|
+
throw constants_1.ERRORS.TypedError('Runtime', `Overflow when trying to convert number ${number} into ${bytes} bytes`);
|
|
50
|
+
}
|
|
51
|
+
return hex.padStart(bytes * 2, '0');
|
|
52
|
+
}
|
|
53
|
+
function encodeData(typeName, data) {
|
|
54
|
+
if (paramTypeBytes.test(typeName) || typeName === 'address') {
|
|
55
|
+
return (0, formatUtils_1.messageToHex)(data);
|
|
56
|
+
}
|
|
57
|
+
if (typeName === 'string') {
|
|
58
|
+
return Buffer.from(data, 'utf-8').toString('hex');
|
|
59
|
+
}
|
|
60
|
+
const numberMatch = paramTypeNumber.exec(typeName);
|
|
61
|
+
if (numberMatch) {
|
|
62
|
+
const [_, intType, bits] = numberMatch;
|
|
63
|
+
const bytes = Math.ceil(parseInt(bits, 10) / 8);
|
|
64
|
+
return intToHex(data, bytes, intType === 'int');
|
|
65
|
+
}
|
|
66
|
+
if (typeName === 'bool') {
|
|
67
|
+
return data ? '01' : '00';
|
|
68
|
+
}
|
|
69
|
+
throw constants_1.ERRORS.TypedError('Runtime', `Unsupported data type for direct field encoding: ${typeName}`);
|
|
70
|
+
}
|
|
71
|
+
exports.encodeData = encodeData;
|
|
72
|
+
const paramTypesMap = {
|
|
73
|
+
string: constants_1.PROTO.EthereumDataType.STRING,
|
|
74
|
+
bool: constants_1.PROTO.EthereumDataType.BOOL,
|
|
75
|
+
address: constants_1.PROTO.EthereumDataType.ADDRESS,
|
|
76
|
+
};
|
|
77
|
+
function getFieldType(typeName, types) {
|
|
78
|
+
const arrayMatch = paramTypeArray.exec(typeName);
|
|
79
|
+
if (arrayMatch) {
|
|
80
|
+
const [_, arrayItemTypeName, arraySize] = arrayMatch;
|
|
81
|
+
const entryType = getFieldType(arrayItemTypeName, types);
|
|
82
|
+
return {
|
|
83
|
+
data_type: constants_1.PROTO.EthereumDataType.ARRAY,
|
|
84
|
+
size: parseInt(arraySize, 10) || undefined,
|
|
85
|
+
entry_type: entryType,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const numberMatch = paramTypeNumber.exec(typeName);
|
|
89
|
+
if (numberMatch) {
|
|
90
|
+
const [_, type, bits] = numberMatch;
|
|
91
|
+
return {
|
|
92
|
+
data_type: type === 'uint' ? constants_1.PROTO.EthereumDataType.UINT : constants_1.PROTO.EthereumDataType.INT,
|
|
93
|
+
size: Math.floor(parseInt(bits, 10) / 8),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const bytesMatch = paramTypeBytes.exec(typeName);
|
|
97
|
+
if (bytesMatch) {
|
|
98
|
+
const [_, size] = bytesMatch;
|
|
99
|
+
return {
|
|
100
|
+
data_type: constants_1.PROTO.EthereumDataType.BYTES,
|
|
101
|
+
size: parseInt(size, 10) || undefined,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const fixedSizeTypeMatch = paramTypesMap[typeName];
|
|
105
|
+
if (fixedSizeTypeMatch) {
|
|
106
|
+
return {
|
|
107
|
+
data_type: fixedSizeTypeMatch,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (typeName in types) {
|
|
111
|
+
return {
|
|
112
|
+
data_type: constants_1.PROTO.EthereumDataType.STRUCT,
|
|
113
|
+
size: types[typeName].length,
|
|
114
|
+
struct_name: typeName,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
throw constants_1.ERRORS.TypedError('Runtime', `No type definition specified: ${typeName}`);
|
|
118
|
+
}
|
|
119
|
+
exports.getFieldType = getFieldType;
|
|
120
|
+
//# sourceMappingURL=ethereumSignTypedData.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import { PROTO } from '../constants';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../types';
|
|
4
|
+
declare type Params = PROTO.EthereumGetAddress & {
|
|
5
|
+
address?: string;
|
|
6
|
+
network?: EthereumNetworkInfo;
|
|
7
|
+
};
|
|
8
|
+
export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddress', Params[]> {
|
|
9
|
+
hasBundle?: boolean;
|
|
10
|
+
progress: number;
|
|
11
|
+
confirmed?: boolean;
|
|
12
|
+
init(): void;
|
|
13
|
+
getButtonRequestData(code: string): {
|
|
14
|
+
type: "address";
|
|
15
|
+
serializedPath: string;
|
|
16
|
+
address: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
confirmation(): Promise<boolean>;
|
|
19
|
+
noBackupConfirmation(): Promise<boolean>;
|
|
20
|
+
_call({ address_n, show_display }: Params): Promise<{
|
|
21
|
+
path: number[];
|
|
22
|
+
serializedPath: string;
|
|
23
|
+
address: string;
|
|
24
|
+
}>;
|
|
25
|
+
run(): Promise<import("../types").Address | import("../types").Address[]>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=ethereumGetAddress.d.ts.map
|