@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,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFirmwareRange = exports.validateParams = void 0;
|
|
4
|
+
exports.validateParams = [
|
|
5
|
+
{
|
|
6
|
+
description: 'array',
|
|
7
|
+
type: 'array',
|
|
8
|
+
value: [],
|
|
9
|
+
success: true,
|
|
10
|
+
allowEmpty: true,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
description: 'array invalid (empty)',
|
|
14
|
+
type: 'array',
|
|
15
|
+
value: [],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
description: 'array-buffer',
|
|
19
|
+
type: 'array-buffer',
|
|
20
|
+
value: new ArrayBuffer(0),
|
|
21
|
+
success: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
description: 'array-buffer invalid',
|
|
25
|
+
type: 'array-buffer',
|
|
26
|
+
value: Buffer.from('foo'),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
description: 'array-buffer invalid',
|
|
30
|
+
type: 'array-buffer',
|
|
31
|
+
value: [],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: 'array-buffer invalid',
|
|
35
|
+
type: 'array-buffer',
|
|
36
|
+
value: 'foo',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
description: 'array-buffer invalid',
|
|
40
|
+
type: 'array-buffer',
|
|
41
|
+
value: 0,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
description: 'uint valid (zero string)',
|
|
45
|
+
type: 'uint',
|
|
46
|
+
value: '0',
|
|
47
|
+
success: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
description: 'uint valid (zero number)',
|
|
51
|
+
type: 'uint',
|
|
52
|
+
value: 0,
|
|
53
|
+
success: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
description: 'uint valid (positive string)',
|
|
57
|
+
type: 'uint',
|
|
58
|
+
value: '10',
|
|
59
|
+
success: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
description: 'uint valid (positive number)',
|
|
63
|
+
type: 'uint',
|
|
64
|
+
value: 10,
|
|
65
|
+
success: true,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
description: 'negative string uint valid (allowNegative)',
|
|
69
|
+
type: 'uint',
|
|
70
|
+
allowNegative: true,
|
|
71
|
+
value: '-1',
|
|
72
|
+
success: true,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
description: 'negative number uint valid (allowNegative)',
|
|
76
|
+
type: 'uint',
|
|
77
|
+
allowNegative: true,
|
|
78
|
+
value: -1,
|
|
79
|
+
success: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
description: 'uint invalid (decimal number)',
|
|
83
|
+
type: 'uint',
|
|
84
|
+
value: 10.1,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
description: 'uint invalid (decimal string)',
|
|
88
|
+
type: 'uint',
|
|
89
|
+
value: '10.1',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
description: 'uint invalid (negative number)',
|
|
93
|
+
type: 'uint',
|
|
94
|
+
value: -1,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
description: 'uint invalid (negative string)',
|
|
98
|
+
type: 'uint',
|
|
99
|
+
value: '-1',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
description: 'uint invalid not safe integer',
|
|
103
|
+
type: 'uint',
|
|
104
|
+
value: Number.MAX_SAFE_INTEGER + 2,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
description: 'uint invalid leading zeros',
|
|
108
|
+
type: 'uint',
|
|
109
|
+
value: '01',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
description: 'uint invalid digits',
|
|
113
|
+
type: 'uint',
|
|
114
|
+
value: '123f',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
description: 'uint invalid type',
|
|
118
|
+
type: 'uint',
|
|
119
|
+
value: true,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
description: 'not required param without value (null)',
|
|
123
|
+
type: 'number',
|
|
124
|
+
value: null,
|
|
125
|
+
success: true,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
description: 'not required param without value (undefined)',
|
|
129
|
+
type: 'string',
|
|
130
|
+
value: null,
|
|
131
|
+
success: true,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
description: 'required param without type and false negative value (0)',
|
|
135
|
+
required: true,
|
|
136
|
+
value: 0,
|
|
137
|
+
success: true,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
description: 'required param without type and false negative value (false)',
|
|
141
|
+
required: true,
|
|
142
|
+
value: false,
|
|
143
|
+
success: true,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
description: 'required param without value (null)',
|
|
147
|
+
required: true,
|
|
148
|
+
value: null,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
description: 'required param without value (undefined)',
|
|
152
|
+
required: true,
|
|
153
|
+
value: undefined,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
description: 'param with union of types (string)',
|
|
157
|
+
type: ['string', 'boolean', 'number'],
|
|
158
|
+
value: 'true',
|
|
159
|
+
success: true,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
description: 'param with union of types (boolean)',
|
|
163
|
+
type: ['string', 'boolean', 'number'],
|
|
164
|
+
value: true,
|
|
165
|
+
success: true,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
description: 'param with union of types (invalid value)',
|
|
169
|
+
type: ['string', 'boolean', 'number', 'array', 'array-buffer'],
|
|
170
|
+
value: Buffer.from('00'),
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
const DEFAULT_RANGE = {
|
|
174
|
+
1: { min: '1.0.0', max: '0' },
|
|
175
|
+
2: { min: '2.0.0', max: '0' },
|
|
176
|
+
};
|
|
177
|
+
const DEFAULT_COIN_INFO = {
|
|
178
|
+
support: { trezor1: '1.6.2', trezor2: '2.1.0' },
|
|
179
|
+
shortcut: 'btc',
|
|
180
|
+
type: 'bitcoin',
|
|
181
|
+
};
|
|
182
|
+
const EMPTY_CONFIG = {
|
|
183
|
+
supportedFirmware: [],
|
|
184
|
+
};
|
|
185
|
+
exports.getFirmwareRange = [
|
|
186
|
+
{
|
|
187
|
+
description: 'default range. coinInfo and config.json data not found',
|
|
188
|
+
config: EMPTY_CONFIG,
|
|
189
|
+
params: ['signTransaction', null, DEFAULT_RANGE],
|
|
190
|
+
result: DEFAULT_RANGE,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
description: 'range from coinInfo',
|
|
194
|
+
config: EMPTY_CONFIG,
|
|
195
|
+
params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
|
|
196
|
+
result: { 1: { min: '1.6.2', max: '0' }, 2: { min: '2.1.0', max: '0' } },
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
description: 'coinInfo without support',
|
|
200
|
+
config: EMPTY_CONFIG,
|
|
201
|
+
params: ['signTransaction', { shortcut: 'btc', type: 'bitcoin' }, DEFAULT_RANGE],
|
|
202
|
+
result: { 1: { min: '0', max: '0' }, 2: { min: '0', max: '0' } },
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
description: 'coinInfo without T1 support',
|
|
206
|
+
config: EMPTY_CONFIG,
|
|
207
|
+
params: [
|
|
208
|
+
'signTransaction',
|
|
209
|
+
{ support: { trezor1: null, trezor2: '2.1.0' }, shortcut: 'btc', type: 'bitcoin' },
|
|
210
|
+
DEFAULT_RANGE,
|
|
211
|
+
],
|
|
212
|
+
result: { 1: { min: '0', max: '0' }, 2: { min: '2.1.0', max: '0' } },
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
description: 'coinInfo without T2 support',
|
|
216
|
+
config: EMPTY_CONFIG,
|
|
217
|
+
params: [
|
|
218
|
+
'signTransaction',
|
|
219
|
+
{ support: { trezor1: '1.6.2', trezor2: null }, shortcut: 'btc', type: 'bitcoin' },
|
|
220
|
+
DEFAULT_RANGE,
|
|
221
|
+
],
|
|
222
|
+
result: { 1: { min: '1.6.2', max: '0' }, 2: { min: '0', max: '0' } },
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
description: 'coinInfo support is lower than default',
|
|
226
|
+
config: EMPTY_CONFIG,
|
|
227
|
+
params: [
|
|
228
|
+
'signTransaction',
|
|
229
|
+
DEFAULT_COIN_INFO,
|
|
230
|
+
{ 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
|
|
231
|
+
],
|
|
232
|
+
result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
description: 'range from config.json (by coinType and coin as string)',
|
|
236
|
+
config: {
|
|
237
|
+
supportedFirmware: [
|
|
238
|
+
{ coinType: 'bitcoin', methods: ['showAddress'], min: ['1.12.0', '2.6.0'] },
|
|
239
|
+
{ coinType: 'bitcoin', min: ['1.10.0', '2.5.0'] },
|
|
240
|
+
{ coin: 'btc', min: ['1.11.0', '2.4.0'] },
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
|
|
244
|
+
result: { 1: { min: '1.11.0', max: '0' }, 2: { min: '2.5.0', max: '0' } },
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
description: 'range from config.json (by coin as string)',
|
|
248
|
+
config: {
|
|
249
|
+
supportedFirmware: [
|
|
250
|
+
{ coin: 'btc', methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
|
|
251
|
+
{ coin: 'btc', min: ['1.10.0', '2.4.0'] },
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
|
|
255
|
+
result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
description: 'range from config.json (by coin as array)',
|
|
259
|
+
config: {
|
|
260
|
+
supportedFirmware: [
|
|
261
|
+
{ coin: ['btc'], methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
|
|
262
|
+
{ coin: ['btc'], min: ['1.10.0', '2.4.0'] },
|
|
263
|
+
],
|
|
264
|
+
},
|
|
265
|
+
params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
|
|
266
|
+
result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
description: 'range from config.json (by methods)',
|
|
270
|
+
config: {
|
|
271
|
+
supportedFirmware: [
|
|
272
|
+
{ min: ['1.11.0', '2.5.0'] },
|
|
273
|
+
{ coin: ['btc'], methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
|
|
274
|
+
{ coin: ['ltc'], methods: ['signTransaction'], min: ['1.11.0', '2.5.0'] },
|
|
275
|
+
{ coinType: 'bitcoin', methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
|
|
276
|
+
{ methods: ['signTransaction'], min: ['1.10.0', '2.4.0'] },
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
|
|
280
|
+
result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
description: 'range from config.json (by capabilities)',
|
|
284
|
+
config: {
|
|
285
|
+
supportedFirmware: [
|
|
286
|
+
{ min: ['1.11.0', '2.5.0'] },
|
|
287
|
+
{ coin: ['btc'], methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
|
|
288
|
+
{ coin: ['ltc'], methods: ['signTransaction'], min: ['1.11.0', '2.5.0'] },
|
|
289
|
+
{ coinType: 'bitcoin', methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
|
|
290
|
+
{ capabilities: ['decreaseOutput'], min: ['1.10.0', '2.4.0'] },
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
params: ['decreaseOutput', DEFAULT_COIN_INFO, DEFAULT_RANGE],
|
|
294
|
+
result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
description: 'range from config.json is lower than coinInfo',
|
|
298
|
+
config: {
|
|
299
|
+
supportedFirmware: [{ methods: ['signTransaction'], min: ['1.6.2', '2.1.0'] }],
|
|
300
|
+
},
|
|
301
|
+
params: [
|
|
302
|
+
'signTransaction',
|
|
303
|
+
{ support: { trezor1: '1.10.0', trezor2: '2.4.0' }, shortcut: 'btc', type: 'bitcoin' },
|
|
304
|
+
DEFAULT_RANGE,
|
|
305
|
+
],
|
|
306
|
+
result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
description: 'range from config.json using max',
|
|
310
|
+
config: {
|
|
311
|
+
supportedFirmware: [{ methods: ['signTransaction'], max: ['1.10.0', '2.4.0'] }],
|
|
312
|
+
},
|
|
313
|
+
params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
|
|
314
|
+
result: { 1: { min: '1.6.2', max: '1.10.0' }, 2: { min: '2.1.0', max: '2.4.0' } },
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
description: 'range from config.json using max (values lower than default)',
|
|
318
|
+
config: {
|
|
319
|
+
supportedFirmware: [{ methods: ['signTransaction'], max: ['1.0.1', '2.0.1'] }],
|
|
320
|
+
},
|
|
321
|
+
params: [
|
|
322
|
+
'signTransaction',
|
|
323
|
+
DEFAULT_COIN_INFO,
|
|
324
|
+
{
|
|
325
|
+
1: { min: '1.0.0', max: '1.10.0' },
|
|
326
|
+
2: { min: '1.0.0', max: '2.10.0' },
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
result: { 1: { min: '1.6.2', max: '1.10.0' }, 2: { min: '2.1.0', max: '2.10.0' } },
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
description: 'xrp + getAccountInfo: coinInfo range IS replaced by config.json range',
|
|
333
|
+
params: [
|
|
334
|
+
'getAccountInfo',
|
|
335
|
+
{ support: { trezor1: '1.0.1', trezor2: '2.0.1' }, shortcut: 'xrp', type: 'ripple' },
|
|
336
|
+
DEFAULT_RANGE,
|
|
337
|
+
],
|
|
338
|
+
result: { 1: { min: '0', max: '0' }, 2: { min: '2.1.0', max: '0' } },
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
description: 'btc + getAccountInfo: coinInfo range IS NOT replaced by config.json range',
|
|
342
|
+
params: ['getAccountInfo', null, DEFAULT_RANGE],
|
|
343
|
+
result: DEFAULT_RANGE,
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
description: 'eip1559: coinInfo range is replaced by config.json range',
|
|
347
|
+
params: [
|
|
348
|
+
'eip1559',
|
|
349
|
+
{ support: { trezor1: '1.6.2', trezor2: '2.1.0' }, shortcut: 'eth', type: 'ethereum' },
|
|
350
|
+
DEFAULT_RANGE,
|
|
351
|
+
],
|
|
352
|
+
result: { 1: { min: '1.10.4', max: '0' }, 2: { min: '2.4.2', max: '0' } },
|
|
353
|
+
},
|
|
354
|
+
];
|
|
355
|
+
//# sourceMappingURL=paramsValidator.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CoinInfo, FirmwareRange } from '../../types';
|
|
2
|
+
declare type ParamType = 'string' | 'number' | 'array' | 'array-buffer' | 'boolean' | 'uint' | 'object';
|
|
3
|
+
declare type Param = {
|
|
4
|
+
name: string;
|
|
5
|
+
type?: ParamType | ParamType[];
|
|
6
|
+
required?: boolean;
|
|
7
|
+
allowEmpty?: boolean;
|
|
8
|
+
allowNegative?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function validateParams<P extends Record<string, any>>(params: P, schema: Param[]): P;
|
|
11
|
+
export declare const validateCoinPath: (path: number[], coinInfo?: CoinInfo | undefined) => void;
|
|
12
|
+
export declare const getFirmwareRange: (method: string, coinInfo: CoinInfo | null | undefined, currentRange: FirmwareRange) => FirmwareRange;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=paramsValidator.d.ts.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFirmwareRange = exports.validateCoinPath = exports.validateParams = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const pathUtils_1 = require("../../utils/pathUtils");
|
|
6
|
+
const versionUtils_1 = require("../../utils/versionUtils");
|
|
7
|
+
const config_1 = require("../../data/config");
|
|
8
|
+
const invalidParameter = (message) => constants_1.ERRORS.TypedError('Method_InvalidParameter', message);
|
|
9
|
+
function validateParams(params, schema) {
|
|
10
|
+
schema.forEach(field => {
|
|
11
|
+
const value = params[field.name];
|
|
12
|
+
if (field.required && value == null) {
|
|
13
|
+
throw invalidParameter(`Parameter "${field.name}" is missing.`);
|
|
14
|
+
}
|
|
15
|
+
if (!field.type || value == null)
|
|
16
|
+
return;
|
|
17
|
+
const { name, type } = field;
|
|
18
|
+
if (Array.isArray(type)) {
|
|
19
|
+
const p = {};
|
|
20
|
+
p[name] = value;
|
|
21
|
+
const success = type.reduce((count, t) => {
|
|
22
|
+
try {
|
|
23
|
+
validateParams(p, [{ name: field.name, type: t }]);
|
|
24
|
+
return count + 1;
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
return count;
|
|
28
|
+
}
|
|
29
|
+
}, 0);
|
|
30
|
+
if (!success) {
|
|
31
|
+
throw invalidParameter(`Parameter "${name}" has invalid type. Union of "${type.join('|')}" expected.`);
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (type === 'array') {
|
|
36
|
+
if (!Array.isArray(value)) {
|
|
37
|
+
throw invalidParameter(`Parameter "${name}" has invalid type. "${type}" expected.`);
|
|
38
|
+
}
|
|
39
|
+
if (!field.allowEmpty && value.length < 1) {
|
|
40
|
+
throw invalidParameter(`Parameter "${name}" is empty.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (type === 'uint') {
|
|
44
|
+
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
45
|
+
throw invalidParameter(`Parameter "${name}" has invalid type. "string|number" expected.`);
|
|
46
|
+
}
|
|
47
|
+
if ((typeof value === 'number' && !Number.isSafeInteger(value)) ||
|
|
48
|
+
!/^(?:[1-9]\d*|\d)$/.test(value.toString().replace(/^-/, field.allowNegative ? '' : '-'))) {
|
|
49
|
+
throw invalidParameter(`Parameter "${name}" has invalid value "${value}". Integer representation expected.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (type === 'array-buffer') {
|
|
53
|
+
if (!(value instanceof ArrayBuffer)) {
|
|
54
|
+
throw invalidParameter(`Parameter "${name}" has invalid type. "ArrayBuffer" expected.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (typeof value !== type) {
|
|
58
|
+
throw invalidParameter(`Parameter "${name}" has invalid type. "${type}" expected.`);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return params;
|
|
62
|
+
}
|
|
63
|
+
exports.validateParams = validateParams;
|
|
64
|
+
const validateCoinPath = (path, coinInfo) => {
|
|
65
|
+
if (coinInfo && coinInfo.slip44 !== (0, pathUtils_1.fromHardened)(path[1])) {
|
|
66
|
+
throw invalidParameter('Parameters "path" and "coin" do not match.');
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.validateCoinPath = validateCoinPath;
|
|
70
|
+
const getFirmwareRange = (method, coinInfo, currentRange) => {
|
|
71
|
+
const current = JSON.parse(JSON.stringify(currentRange));
|
|
72
|
+
if (coinInfo) {
|
|
73
|
+
if (!coinInfo.support || typeof coinInfo.support.trezor1 !== 'string') {
|
|
74
|
+
current['1'].min = '0';
|
|
75
|
+
}
|
|
76
|
+
else if ((0, versionUtils_1.versionCompare)(coinInfo.support.trezor1, current['1'].min) > 0) {
|
|
77
|
+
current['1'].min = coinInfo.support.trezor1;
|
|
78
|
+
}
|
|
79
|
+
if (!coinInfo.support || typeof coinInfo.support.trezor2 !== 'string') {
|
|
80
|
+
current['2'].min = '0';
|
|
81
|
+
}
|
|
82
|
+
else if ((0, versionUtils_1.versionCompare)(coinInfo.support.trezor2, current['2'].min) > 0) {
|
|
83
|
+
current['2'].min = coinInfo.support.trezor2;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const coinType = coinInfo ? coinInfo.type : null;
|
|
87
|
+
const shortcut = coinInfo ? coinInfo.shortcut.toLowerCase() : null;
|
|
88
|
+
const { supportedFirmware } = config_1.config;
|
|
89
|
+
const ranges = supportedFirmware
|
|
90
|
+
.filter(rule => {
|
|
91
|
+
if (rule.methods) {
|
|
92
|
+
return rule.methods.includes(method);
|
|
93
|
+
}
|
|
94
|
+
if (rule.capabilities) {
|
|
95
|
+
return rule.capabilities.includes(method);
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
})
|
|
99
|
+
.filter(c => {
|
|
100
|
+
if (c.coinType) {
|
|
101
|
+
return c.coinType === coinType;
|
|
102
|
+
}
|
|
103
|
+
if (c.coin) {
|
|
104
|
+
return (typeof c.coin === 'string' ? [c.coin] : c.coin).includes(shortcut);
|
|
105
|
+
}
|
|
106
|
+
return c.methods || c.capabilities;
|
|
107
|
+
});
|
|
108
|
+
ranges.forEach(range => {
|
|
109
|
+
const { min, max } = range;
|
|
110
|
+
if (min) {
|
|
111
|
+
const [t1, t2] = min;
|
|
112
|
+
if (t1 === '0' ||
|
|
113
|
+
current['1'].min === '0' ||
|
|
114
|
+
(0, versionUtils_1.versionCompare)(current['1'].min, t1) < 0) {
|
|
115
|
+
current['1'].min = t1;
|
|
116
|
+
}
|
|
117
|
+
if (t2 === '0' ||
|
|
118
|
+
current['2'].min === '0' ||
|
|
119
|
+
(0, versionUtils_1.versionCompare)(current['2'].min, t2) < 0) {
|
|
120
|
+
current['2'].min = t2;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (max) {
|
|
124
|
+
const [t1, t2] = max;
|
|
125
|
+
if (t1 === '0' ||
|
|
126
|
+
current['1'].max === '0' ||
|
|
127
|
+
(0, versionUtils_1.versionCompare)(current['1'].max, t1) < 0) {
|
|
128
|
+
current['1'].max = t1;
|
|
129
|
+
}
|
|
130
|
+
if (t2 === '0' ||
|
|
131
|
+
current['2'].max === '0' ||
|
|
132
|
+
(0, versionUtils_1.versionCompare)(current['2'].max, t2) < 0) {
|
|
133
|
+
current['2'].max = t2;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return current;
|
|
138
|
+
};
|
|
139
|
+
exports.getFirmwareRange = getFirmwareRange;
|
|
140
|
+
//# sourceMappingURL=paramsValidator.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import { Discovery } from './common/Discovery';
|
|
3
|
+
import { TransactionComposer } from './bitcoin';
|
|
4
|
+
import type { ComposeOutput, ComposeResult } from '@trezor/utxo-lib';
|
|
5
|
+
import type { BitcoinNetworkInfo, DiscoveryAccount, AccountUtxo } from '../types';
|
|
6
|
+
import type { SignedTransaction, PrecomposeParams, PrecomposedTransaction } from '../types/api/composeTransaction';
|
|
7
|
+
declare type Params = {
|
|
8
|
+
outputs: ComposeOutput[];
|
|
9
|
+
coinInfo: BitcoinNetworkInfo;
|
|
10
|
+
push: boolean;
|
|
11
|
+
account?: PrecomposeParams['account'];
|
|
12
|
+
feeLevels?: PrecomposeParams['feeLevels'];
|
|
13
|
+
baseFee?: PrecomposeParams['baseFee'];
|
|
14
|
+
floorBaseFee?: PrecomposeParams['floorBaseFee'];
|
|
15
|
+
sequence?: PrecomposeParams['sequence'];
|
|
16
|
+
skipPermutation?: PrecomposeParams['skipPermutation'];
|
|
17
|
+
};
|
|
18
|
+
export default class ComposeTransaction extends AbstractMethod<'composeTransaction', Params> {
|
|
19
|
+
discovery?: Discovery;
|
|
20
|
+
init(): void;
|
|
21
|
+
precompose(account: PrecomposeParams['account'], feeLevels: PrecomposeParams['feeLevels']): Promise<PrecomposedTransaction[]>;
|
|
22
|
+
run(): Promise<SignedTransaction | PrecomposedTransaction[]>;
|
|
23
|
+
selectAccount(): Promise<{
|
|
24
|
+
account: DiscoveryAccount;
|
|
25
|
+
utxo: AccountUtxo[];
|
|
26
|
+
}>;
|
|
27
|
+
selectFee(account: DiscoveryAccount, utxo: AccountUtxo[]): Promise<SignedTransaction | "change-account">;
|
|
28
|
+
_selectFeeUiResponse(composer: TransactionComposer): Promise<SignedTransaction | 'change-account'>;
|
|
29
|
+
_sign(tx: ComposeResult): Promise<import("../types/api/signTransaction").SignedTransaction>;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=composeTransaction.d.ts.map
|