@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,75 @@
|
|
|
1
|
+
import BlockchainLink, { ServerInfo, SubscriptionAccountInfo, BlockchainLinkParams, BlockchainLinkResponse } from '@trezor/blockchain-link';
|
|
2
|
+
import { ERRORS } from '../constants';
|
|
3
|
+
import type { CoinInfo, Proxy } from '../types';
|
|
4
|
+
import type { CoreMessage } from '../events';
|
|
5
|
+
declare type Options = {
|
|
6
|
+
coinInfo: CoinInfo;
|
|
7
|
+
postMessage: (message: CoreMessage) => void;
|
|
8
|
+
proxy?: Proxy;
|
|
9
|
+
onionDomains?: {
|
|
10
|
+
[domain: string]: string;
|
|
11
|
+
};
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class Blockchain {
|
|
15
|
+
link: BlockchainLink;
|
|
16
|
+
serverInfo?: ServerInfo;
|
|
17
|
+
coinInfo: Options['coinInfo'];
|
|
18
|
+
onionDomains: {
|
|
19
|
+
[onion: string]: string;
|
|
20
|
+
};
|
|
21
|
+
postMessage: Options['postMessage'];
|
|
22
|
+
feeForBlock: BlockchainLinkResponse<'estimateFee'>;
|
|
23
|
+
feeTimestamp: number;
|
|
24
|
+
constructor(options: Options);
|
|
25
|
+
onError(error: ERRORS.TrezorError): void;
|
|
26
|
+
init(): Promise<void>;
|
|
27
|
+
getTransactions(txs: string[]): Promise<import("@trezor/blockchain-link").TypedRawTransaction[]>;
|
|
28
|
+
getCurrentFiatRates(params: {
|
|
29
|
+
currencies?: string[];
|
|
30
|
+
}): Promise<{
|
|
31
|
+
ts: number;
|
|
32
|
+
rates: import("@trezor/blockchain-link").FiatRates;
|
|
33
|
+
}>;
|
|
34
|
+
getFiatRatesForTimestamps(params: {
|
|
35
|
+
timestamps: number[];
|
|
36
|
+
}): Promise<{
|
|
37
|
+
tickers: {
|
|
38
|
+
ts: number;
|
|
39
|
+
rates: import("@trezor/blockchain-link").FiatRates;
|
|
40
|
+
}[];
|
|
41
|
+
}>;
|
|
42
|
+
getAccountBalanceHistory(params: BlockchainLinkParams<'getAccountBalanceHistory'>): Promise<import("@trezor/blockchain-link").AccountBalanceHistory[]>;
|
|
43
|
+
getNetworkInfo(): Promise<ServerInfo>;
|
|
44
|
+
getAccountInfo(request: BlockchainLinkParams<'getAccountInfo'>): Promise<import("@trezor/blockchain-link").AccountInfo>;
|
|
45
|
+
getAccountUtxo(descriptor: string): Promise<import("@trezor/blockchain-link").Utxo[]>;
|
|
46
|
+
estimateFee(request: {
|
|
47
|
+
blocks?: number[];
|
|
48
|
+
}): Promise<{
|
|
49
|
+
feePerUnit: string;
|
|
50
|
+
feePerTx?: string | undefined;
|
|
51
|
+
feeLimit?: string | undefined;
|
|
52
|
+
}[]>;
|
|
53
|
+
subscribe(accounts?: SubscriptionAccountInfo[]): Promise<{
|
|
54
|
+
subscribed: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
subscribeFiatRates(_currency?: string): Promise<{
|
|
57
|
+
subscribed: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
unsubscribe(accounts?: SubscriptionAccountInfo[]): Promise<{
|
|
60
|
+
subscribed: boolean;
|
|
61
|
+
}>;
|
|
62
|
+
unsubscribeFiatRates(): Promise<{
|
|
63
|
+
subscribed: boolean;
|
|
64
|
+
}>;
|
|
65
|
+
pushTransaction(tx: string): Promise<string>;
|
|
66
|
+
disconnect(): void;
|
|
67
|
+
}
|
|
68
|
+
export declare const findBackend: (name: string) => Blockchain | null;
|
|
69
|
+
export declare const setCustomBackend: (coinInfo: CoinInfo, blockchainLink: CoinInfo['blockchainLink']) => void;
|
|
70
|
+
export declare const isBackendSupported: (coinInfo: CoinInfo) => void;
|
|
71
|
+
export declare const initBlockchain: (coinInfo: CoinInfo, postMessage: Options['postMessage']) => Promise<Blockchain>;
|
|
72
|
+
export declare const reconnectAllBackends: () => Promise<Blockchain[]>;
|
|
73
|
+
export declare const dispose: () => void;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=BlockchainLink.d.ts.map
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dispose = exports.reconnectAllBackends = exports.initBlockchain = exports.isBackendSupported = exports.setCustomBackend = exports.findBackend = exports.Blockchain = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const blockchain_link_1 = (0, tslib_1.__importDefault)(require("@trezor/blockchain-link"));
|
|
6
|
+
const config_1 = require("../data/config");
|
|
7
|
+
const DataManager_1 = require("../data/DataManager");
|
|
8
|
+
const events_1 = require("../events");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const urlUtils_1 = require("../utils/urlUtils");
|
|
11
|
+
const workers_1 = require("../workers/workers");
|
|
12
|
+
const getWorker = (type) => {
|
|
13
|
+
switch (type) {
|
|
14
|
+
case 'blockbook':
|
|
15
|
+
return workers_1.BlockbookWorker;
|
|
16
|
+
case 'ripple':
|
|
17
|
+
return workers_1.RippleWorker;
|
|
18
|
+
case 'blockfrost':
|
|
19
|
+
return workers_1.BlockfrostWorker;
|
|
20
|
+
case 'electrum':
|
|
21
|
+
return workers_1.ElectrumWorker;
|
|
22
|
+
default:
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
class Blockchain {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.feeForBlock = [];
|
|
29
|
+
this.feeTimestamp = 0;
|
|
30
|
+
this.coinInfo = options.coinInfo;
|
|
31
|
+
this.postMessage = options.postMessage;
|
|
32
|
+
const { blockchainLink } = options.coinInfo;
|
|
33
|
+
if (!blockchainLink) {
|
|
34
|
+
throw constants_1.ERRORS.TypedError('Backend_NotSupported');
|
|
35
|
+
}
|
|
36
|
+
const worker = getWorker(blockchainLink.type);
|
|
37
|
+
if (!worker) {
|
|
38
|
+
throw constants_1.ERRORS.TypedError('Backend_WorkerMissing', `BlockchainLink worker not found ${blockchainLink.type}`);
|
|
39
|
+
}
|
|
40
|
+
const { onionDomains } = options;
|
|
41
|
+
this.onionDomains = onionDomains
|
|
42
|
+
? blockchainLink.url.reduce((a, url) => {
|
|
43
|
+
const onion = (0, urlUtils_1.getOnionDomain)(url, onionDomains);
|
|
44
|
+
if (onion !== url) {
|
|
45
|
+
a[onion] = url;
|
|
46
|
+
}
|
|
47
|
+
return a;
|
|
48
|
+
}, {})
|
|
49
|
+
: {};
|
|
50
|
+
const server = Object.keys(this.onionDomains).length
|
|
51
|
+
? Object.keys(this.onionDomains)
|
|
52
|
+
: blockchainLink.url;
|
|
53
|
+
this.link = new blockchain_link_1.default({
|
|
54
|
+
name: this.coinInfo.shortcut,
|
|
55
|
+
worker,
|
|
56
|
+
server,
|
|
57
|
+
debug: options.debug,
|
|
58
|
+
proxy: options.proxy,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
onError(error) {
|
|
62
|
+
this.link.dispose();
|
|
63
|
+
this.postMessage((0, events_1.createBlockchainMessage)(events_1.BLOCKCHAIN.ERROR, {
|
|
64
|
+
coin: this.coinInfo,
|
|
65
|
+
error: error.message,
|
|
66
|
+
code: error.code,
|
|
67
|
+
}));
|
|
68
|
+
removeBackend(this);
|
|
69
|
+
}
|
|
70
|
+
async init() {
|
|
71
|
+
this.link.on('connected', async () => {
|
|
72
|
+
const info = await this.link.getInfo();
|
|
73
|
+
this.serverInfo = info;
|
|
74
|
+
const shortcut = this.coinInfo.shortcut === 'tXRP' ? 'XRP' : this.coinInfo.shortcut;
|
|
75
|
+
if (info.shortcut.toLowerCase() !== shortcut.toLowerCase()) {
|
|
76
|
+
this.onError(constants_1.ERRORS.TypedError('Backend_Invalid'));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const cleanUrl = this.onionDomains[info.url];
|
|
80
|
+
setPreferredBacked(this.coinInfo, cleanUrl || info.url);
|
|
81
|
+
this.postMessage((0, events_1.createBlockchainMessage)(events_1.BLOCKCHAIN.CONNECT, {
|
|
82
|
+
coin: this.coinInfo,
|
|
83
|
+
...info,
|
|
84
|
+
cleanUrl,
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
this.link.on('disconnected', () => {
|
|
88
|
+
this.onError(constants_1.ERRORS.TypedError('Backend_Disconnected'));
|
|
89
|
+
});
|
|
90
|
+
this.link.on('error', error => {
|
|
91
|
+
this.onError(constants_1.ERRORS.TypedError('Backend_Error', error.message));
|
|
92
|
+
});
|
|
93
|
+
try {
|
|
94
|
+
await this.link.connect();
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
this.onError(constants_1.ERRORS.TypedError('Backend_Error', error.message));
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
getTransactions(txs) {
|
|
102
|
+
return Promise.all(txs.map(id => this.link.getTransaction(id)));
|
|
103
|
+
}
|
|
104
|
+
getCurrentFiatRates(params) {
|
|
105
|
+
return this.link.getCurrentFiatRates(params);
|
|
106
|
+
}
|
|
107
|
+
getFiatRatesForTimestamps(params) {
|
|
108
|
+
return this.link.getFiatRatesForTimestamps(params);
|
|
109
|
+
}
|
|
110
|
+
getAccountBalanceHistory(params) {
|
|
111
|
+
return this.link.getAccountBalanceHistory(params);
|
|
112
|
+
}
|
|
113
|
+
getNetworkInfo() {
|
|
114
|
+
return this.link.getInfo();
|
|
115
|
+
}
|
|
116
|
+
getAccountInfo(request) {
|
|
117
|
+
return this.link.getAccountInfo(request);
|
|
118
|
+
}
|
|
119
|
+
getAccountUtxo(descriptor) {
|
|
120
|
+
return this.link.getAccountUtxo(descriptor);
|
|
121
|
+
}
|
|
122
|
+
async estimateFee(request) {
|
|
123
|
+
const { blocks } = request;
|
|
124
|
+
if (blocks) {
|
|
125
|
+
const now = Date.now();
|
|
126
|
+
const outdated = now - this.feeTimestamp > 20 * 60 * 1000;
|
|
127
|
+
const unknownBlocks = blocks.filter(() => typeof this.feeForBlock !== 'string');
|
|
128
|
+
if (!outdated && unknownBlocks.length < 1) {
|
|
129
|
+
}
|
|
130
|
+
const fees = await this.link.estimateFee(request);
|
|
131
|
+
blocks.forEach((block, index) => {
|
|
132
|
+
this.feeForBlock[block] = fees[index];
|
|
133
|
+
});
|
|
134
|
+
this.feeTimestamp = now;
|
|
135
|
+
return fees;
|
|
136
|
+
}
|
|
137
|
+
return this.link.estimateFee(request);
|
|
138
|
+
}
|
|
139
|
+
async subscribe(accounts) {
|
|
140
|
+
if (this.link.listenerCount('block') === 0) {
|
|
141
|
+
this.link.on('block', block => {
|
|
142
|
+
this.postMessage((0, events_1.createBlockchainMessage)(events_1.BLOCKCHAIN.BLOCK, {
|
|
143
|
+
coin: this.coinInfo,
|
|
144
|
+
...block,
|
|
145
|
+
}));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (this.link.listenerCount('notification') === 0) {
|
|
149
|
+
this.link.on('notification', notification => {
|
|
150
|
+
this.postMessage((0, events_1.createBlockchainMessage)(events_1.BLOCKCHAIN.NOTIFICATION, {
|
|
151
|
+
coin: this.coinInfo,
|
|
152
|
+
notification,
|
|
153
|
+
}));
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
const blockSubscription = await this.link.subscribe({ type: 'block' });
|
|
157
|
+
if (!accounts) {
|
|
158
|
+
return blockSubscription;
|
|
159
|
+
}
|
|
160
|
+
return this.link.subscribe({
|
|
161
|
+
type: 'accounts',
|
|
162
|
+
accounts,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
subscribeFiatRates(_currency) {
|
|
166
|
+
if (this.link.listenerCount('fiatRates') === 0) {
|
|
167
|
+
this.link.on('fiatRates', ({ rates }) => {
|
|
168
|
+
this.postMessage((0, events_1.createBlockchainMessage)(events_1.BLOCKCHAIN.FIAT_RATES_UPDATE, {
|
|
169
|
+
coin: this.coinInfo,
|
|
170
|
+
rates,
|
|
171
|
+
}));
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return this.link.subscribe({
|
|
175
|
+
type: 'fiatRates',
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async unsubscribe(accounts) {
|
|
179
|
+
if (!accounts) {
|
|
180
|
+
this.link.removeAllListeners('block');
|
|
181
|
+
this.link.removeAllListeners('fiatRates');
|
|
182
|
+
this.link.removeAllListeners('notification');
|
|
183
|
+
await this.link.unsubscribe({ type: 'fiatRates' });
|
|
184
|
+
return this.link.unsubscribe({ type: 'block' });
|
|
185
|
+
}
|
|
186
|
+
return this.link.unsubscribe({ type: 'accounts', accounts });
|
|
187
|
+
}
|
|
188
|
+
unsubscribeFiatRates() {
|
|
189
|
+
this.link.removeAllListeners('fiatRates');
|
|
190
|
+
return this.link.unsubscribe({ type: 'fiatRates' });
|
|
191
|
+
}
|
|
192
|
+
pushTransaction(tx) {
|
|
193
|
+
return this.link.pushTransaction(tx);
|
|
194
|
+
}
|
|
195
|
+
disconnect() {
|
|
196
|
+
this.link.removeAllListeners();
|
|
197
|
+
this.link.disconnect();
|
|
198
|
+
this.onError(constants_1.ERRORS.TypedError('Backend_Disconnected'));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.Blockchain = Blockchain;
|
|
202
|
+
const instances = [];
|
|
203
|
+
const customBackends = {};
|
|
204
|
+
const preferredBackends = {};
|
|
205
|
+
const removeBackend = (backend) => {
|
|
206
|
+
const index = instances.indexOf(backend);
|
|
207
|
+
if (index >= 0) {
|
|
208
|
+
instances.splice(index, 1);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const findBackend = (name) => {
|
|
212
|
+
for (let i = 0; i < instances.length; i++) {
|
|
213
|
+
if (instances[i].coinInfo.name === name) {
|
|
214
|
+
return instances[i];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return null;
|
|
218
|
+
};
|
|
219
|
+
exports.findBackend = findBackend;
|
|
220
|
+
const setPreferredBacked = (coinInfo, url) => {
|
|
221
|
+
if (!url) {
|
|
222
|
+
delete preferredBackends[coinInfo.shortcut];
|
|
223
|
+
}
|
|
224
|
+
else if (coinInfo.blockchainLink) {
|
|
225
|
+
preferredBackends[coinInfo.shortcut] = {
|
|
226
|
+
...coinInfo,
|
|
227
|
+
blockchainLink: {
|
|
228
|
+
...coinInfo.blockchainLink,
|
|
229
|
+
url: [url],
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const setCustomBackend = (coinInfo, blockchainLink) => {
|
|
235
|
+
setPreferredBacked(coinInfo);
|
|
236
|
+
if (!blockchainLink || blockchainLink.url.length === 0) {
|
|
237
|
+
delete customBackends[coinInfo.shortcut];
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
customBackends[coinInfo.shortcut] = {
|
|
241
|
+
...coinInfo,
|
|
242
|
+
blockchainLink,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
exports.setCustomBackend = setCustomBackend;
|
|
247
|
+
const isBackendSupported = (coinInfo) => {
|
|
248
|
+
const info = customBackends[coinInfo.shortcut] || coinInfo;
|
|
249
|
+
if (!info.blockchainLink) {
|
|
250
|
+
throw constants_1.ERRORS.TypedError('Backend_NotSupported');
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
exports.isBackendSupported = isBackendSupported;
|
|
254
|
+
const initBlockchain = async (coinInfo, postMessage) => {
|
|
255
|
+
let backend = (0, exports.findBackend)(coinInfo.name);
|
|
256
|
+
if (!backend) {
|
|
257
|
+
backend = new Blockchain({
|
|
258
|
+
coinInfo: preferredBackends[coinInfo.shortcut] ||
|
|
259
|
+
customBackends[coinInfo.shortcut] ||
|
|
260
|
+
coinInfo,
|
|
261
|
+
postMessage,
|
|
262
|
+
debug: DataManager_1.DataManager.getSettings('debug'),
|
|
263
|
+
proxy: DataManager_1.DataManager.getSettings('proxy'),
|
|
264
|
+
onionDomains: DataManager_1.DataManager.getSettings('useOnionLinks') && !customBackends[coinInfo.shortcut]
|
|
265
|
+
? config_1.config.onionDomains
|
|
266
|
+
: undefined,
|
|
267
|
+
});
|
|
268
|
+
instances.push(backend);
|
|
269
|
+
try {
|
|
270
|
+
await backend.init();
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
removeBackend(backend);
|
|
274
|
+
setPreferredBacked(coinInfo);
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return backend;
|
|
279
|
+
};
|
|
280
|
+
exports.initBlockchain = initBlockchain;
|
|
281
|
+
const reconnectAllBackends = () => {
|
|
282
|
+
const params = instances.map(i => [
|
|
283
|
+
i.coinInfo,
|
|
284
|
+
i.postMessage,
|
|
285
|
+
]);
|
|
286
|
+
while (instances.length > 0) {
|
|
287
|
+
instances[0].disconnect();
|
|
288
|
+
}
|
|
289
|
+
return Promise.all(params.map(p => (0, exports.initBlockchain)(...p)));
|
|
290
|
+
};
|
|
291
|
+
exports.reconnectAllBackends = reconnectAllBackends;
|
|
292
|
+
const dispose = () => {
|
|
293
|
+
while (instances.length > 0) {
|
|
294
|
+
instances[0].disconnect();
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
exports.dispose = dispose;
|
|
298
|
+
//# sourceMappingURL=BlockchainLink.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NETWORK_IDS = exports.PROTOCOL_MAGICS = void 0;
|
|
4
|
+
var PROTOCOL_MAGICS;
|
|
5
|
+
(function (PROTOCOL_MAGICS) {
|
|
6
|
+
PROTOCOL_MAGICS[PROTOCOL_MAGICS["mainnet"] = 764824073] = "mainnet";
|
|
7
|
+
PROTOCOL_MAGICS[PROTOCOL_MAGICS["testnet"] = 1097911063] = "testnet";
|
|
8
|
+
})(PROTOCOL_MAGICS = exports.PROTOCOL_MAGICS || (exports.PROTOCOL_MAGICS = {}));
|
|
9
|
+
var NETWORK_IDS;
|
|
10
|
+
(function (NETWORK_IDS) {
|
|
11
|
+
NETWORK_IDS[NETWORK_IDS["mainnet"] = 1] = "mainnet";
|
|
12
|
+
NETWORK_IDS[NETWORK_IDS["testnet"] = 0] = "testnet";
|
|
13
|
+
})(NETWORK_IDS = exports.NETWORK_IDS || (exports.NETWORK_IDS = {}));
|
|
14
|
+
//# sourceMappingURL=cardano.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const ERROR_CODES: {
|
|
2
|
+
Init_NotInitialized: string;
|
|
3
|
+
Init_AlreadyInitialized: string;
|
|
4
|
+
Init_IframeBlocked: string;
|
|
5
|
+
Init_IframeTimeout: string;
|
|
6
|
+
Init_ManifestMissing: string;
|
|
7
|
+
Popup_ConnectionMissing: string;
|
|
8
|
+
Transport_Missing: string;
|
|
9
|
+
Transport_InvalidProtobuf: string;
|
|
10
|
+
Method_InvalidPackage: string;
|
|
11
|
+
Method_InvalidParameter: string;
|
|
12
|
+
Method_NotAllowed: string;
|
|
13
|
+
Method_PermissionsNotGranted: string;
|
|
14
|
+
Method_Cancel: string;
|
|
15
|
+
Method_Interrupted: string;
|
|
16
|
+
Method_UnknownCoin: string;
|
|
17
|
+
Method_AddressNotMatch: string;
|
|
18
|
+
Method_FirmwareUpdate_DownloadFailed: string;
|
|
19
|
+
Method_CustomMessage_Callback: string;
|
|
20
|
+
Method_Discovery_BundleException: string;
|
|
21
|
+
Method_Override: string;
|
|
22
|
+
Method_NoResponse: string;
|
|
23
|
+
Backend_NotSupported: string;
|
|
24
|
+
Backend_WorkerMissing: string;
|
|
25
|
+
Backend_Disconnected: string;
|
|
26
|
+
Backend_Invalid: string;
|
|
27
|
+
Backend_Error: string;
|
|
28
|
+
Runtime: string;
|
|
29
|
+
Device_NotFound: string;
|
|
30
|
+
Device_InitializeFailed: string;
|
|
31
|
+
Device_FwException: string;
|
|
32
|
+
Device_ModeException: string;
|
|
33
|
+
Device_Disconnected: string;
|
|
34
|
+
Device_UsedElsewhere: string;
|
|
35
|
+
Device_InvalidState: string;
|
|
36
|
+
Device_CallInProgress: string;
|
|
37
|
+
};
|
|
38
|
+
export declare class TrezorError extends Error {
|
|
39
|
+
code: string;
|
|
40
|
+
message: string;
|
|
41
|
+
constructor(code: string, message: string);
|
|
42
|
+
}
|
|
43
|
+
export declare const TypedError: (id: keyof typeof ERROR_CODES, message?: string | undefined) => TrezorError;
|
|
44
|
+
export declare const serializeError: (payload: any) => any;
|
|
45
|
+
export declare const WRONG_PREVIOUS_SESSION_ERROR_MESSAGE = "wrong previous session";
|
|
46
|
+
export declare const INVALID_PIN_ERROR_MESSAGE = "PIN invalid";
|
|
47
|
+
export declare const WEBUSB_ERROR_MESSAGE = "NetworkError: Unable to claim interface.";
|
|
48
|
+
export declare const LIBUSB_ERROR_MESSAGE = "LIBUSB_ERROR";
|
|
49
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LIBUSB_ERROR_MESSAGE = exports.WEBUSB_ERROR_MESSAGE = exports.INVALID_PIN_ERROR_MESSAGE = exports.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE = exports.serializeError = exports.TypedError = exports.TrezorError = exports.ERROR_CODES = void 0;
|
|
4
|
+
exports.ERROR_CODES = {
|
|
5
|
+
Init_NotInitialized: 'TrezorConnect not initialized',
|
|
6
|
+
Init_AlreadyInitialized: 'TrezorConnect has been already initialized',
|
|
7
|
+
Init_IframeBlocked: 'Iframe blocked',
|
|
8
|
+
Init_IframeTimeout: 'Iframe timeout',
|
|
9
|
+
Init_ManifestMissing: 'Manifest not set. Read more at https://github.com/trezor/connect/blob/develop/docs/index.md',
|
|
10
|
+
Popup_ConnectionMissing: 'Unable to establish connection with iframe',
|
|
11
|
+
Transport_Missing: 'Transport is missing',
|
|
12
|
+
Transport_InvalidProtobuf: '',
|
|
13
|
+
Method_InvalidPackage: 'This package is not suitable to work with browser. Use @trezor/connect-web package instead',
|
|
14
|
+
Method_InvalidParameter: '',
|
|
15
|
+
Method_NotAllowed: 'Method not allowed for this configuration',
|
|
16
|
+
Method_PermissionsNotGranted: 'Permissions not granted',
|
|
17
|
+
Method_Cancel: 'Cancelled',
|
|
18
|
+
Method_Interrupted: 'Popup closed',
|
|
19
|
+
Method_UnknownCoin: 'Coin not found',
|
|
20
|
+
Method_AddressNotMatch: 'Addresses do not match',
|
|
21
|
+
Method_FirmwareUpdate_DownloadFailed: 'Failed to download firmware binary',
|
|
22
|
+
Method_CustomMessage_Callback: 'Parameter "callback" is not a function',
|
|
23
|
+
Method_Discovery_BundleException: '',
|
|
24
|
+
Method_Override: 'override',
|
|
25
|
+
Method_NoResponse: 'Call resolved without response',
|
|
26
|
+
Backend_NotSupported: 'BlockchainLink settings not found in coins.json',
|
|
27
|
+
Backend_WorkerMissing: '',
|
|
28
|
+
Backend_Disconnected: 'Backend disconnected',
|
|
29
|
+
Backend_Invalid: 'Invalid backend',
|
|
30
|
+
Backend_Error: '',
|
|
31
|
+
Runtime: '',
|
|
32
|
+
Device_NotFound: 'Device not found',
|
|
33
|
+
Device_InitializeFailed: '',
|
|
34
|
+
Device_FwException: '',
|
|
35
|
+
Device_ModeException: '',
|
|
36
|
+
Device_Disconnected: 'Device disconnected',
|
|
37
|
+
Device_UsedElsewhere: 'Device is used in another window',
|
|
38
|
+
Device_InvalidState: 'Passphrase is incorrect',
|
|
39
|
+
Device_CallInProgress: 'Device call in progress',
|
|
40
|
+
};
|
|
41
|
+
class TrezorError extends Error {
|
|
42
|
+
constructor(code, message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.code = code;
|
|
45
|
+
this.message = message;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.TrezorError = TrezorError;
|
|
49
|
+
const TypedError = (id, message) => new TrezorError(id, message || exports.ERROR_CODES[id]);
|
|
50
|
+
exports.TypedError = TypedError;
|
|
51
|
+
const serializeError = (payload) => {
|
|
52
|
+
if (payload && payload.error instanceof Error) {
|
|
53
|
+
return { error: payload.error.message, code: payload.error.code };
|
|
54
|
+
}
|
|
55
|
+
return payload;
|
|
56
|
+
};
|
|
57
|
+
exports.serializeError = serializeError;
|
|
58
|
+
exports.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE = 'wrong previous session';
|
|
59
|
+
exports.INVALID_PIN_ERROR_MESSAGE = 'PIN invalid';
|
|
60
|
+
exports.WEBUSB_ERROR_MESSAGE = 'NetworkError: Unable to claim interface.';
|
|
61
|
+
exports.LIBUSB_ERROR_MESSAGE = 'LIBUSB_ERROR';
|
|
62
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROTO = exports.NEM = exports.CARDANO = exports.NETWORK = exports.ERRORS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
exports.ERRORS = (0, tslib_1.__importStar)(require("./errors"));
|
|
6
|
+
exports.NETWORK = (0, tslib_1.__importStar)(require("./network"));
|
|
7
|
+
exports.CARDANO = (0, tslib_1.__importStar)(require("./cardano"));
|
|
8
|
+
exports.NEM = (0, tslib_1.__importStar)(require("./nem"));
|
|
9
|
+
exports.PROTO = (0, tslib_1.__importStar)(require("@trezor/transport/lib/types/messages"));
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare enum Networks {
|
|
2
|
+
mainnet = 104,
|
|
3
|
+
testnet = 152,
|
|
4
|
+
mijin = 96
|
|
5
|
+
}
|
|
6
|
+
export declare enum TxType {
|
|
7
|
+
TRANSFER = 257,
|
|
8
|
+
COSIGNING = 258,
|
|
9
|
+
IMPORTANCE_TRANSFER = 2049,
|
|
10
|
+
AGGREGATE_MODIFICATION = 4097,
|
|
11
|
+
MULTISIG_SIGNATURE = 4098,
|
|
12
|
+
MULTISIG = 4100,
|
|
13
|
+
PROVISION_NAMESPACE = 8193,
|
|
14
|
+
MOSAIC_CREATION = 16385,
|
|
15
|
+
SUPPLY_CHANGE = 16386
|
|
16
|
+
}
|
|
17
|
+
export declare enum TxVersion {
|
|
18
|
+
mainnet = 1744830464,
|
|
19
|
+
testnet = -1744830464,
|
|
20
|
+
mijin = 1610612736
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=nem.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TxVersion = exports.TxType = exports.Networks = void 0;
|
|
4
|
+
var Networks;
|
|
5
|
+
(function (Networks) {
|
|
6
|
+
Networks[Networks["mainnet"] = 104] = "mainnet";
|
|
7
|
+
Networks[Networks["testnet"] = 152] = "testnet";
|
|
8
|
+
Networks[Networks["mijin"] = 96] = "mijin";
|
|
9
|
+
})(Networks = exports.Networks || (exports.Networks = {}));
|
|
10
|
+
var TxType;
|
|
11
|
+
(function (TxType) {
|
|
12
|
+
TxType[TxType["TRANSFER"] = 257] = "TRANSFER";
|
|
13
|
+
TxType[TxType["COSIGNING"] = 258] = "COSIGNING";
|
|
14
|
+
TxType[TxType["IMPORTANCE_TRANSFER"] = 2049] = "IMPORTANCE_TRANSFER";
|
|
15
|
+
TxType[TxType["AGGREGATE_MODIFICATION"] = 4097] = "AGGREGATE_MODIFICATION";
|
|
16
|
+
TxType[TxType["MULTISIG_SIGNATURE"] = 4098] = "MULTISIG_SIGNATURE";
|
|
17
|
+
TxType[TxType["MULTISIG"] = 4100] = "MULTISIG";
|
|
18
|
+
TxType[TxType["PROVISION_NAMESPACE"] = 8193] = "PROVISION_NAMESPACE";
|
|
19
|
+
TxType[TxType["MOSAIC_CREATION"] = 16385] = "MOSAIC_CREATION";
|
|
20
|
+
TxType[TxType["SUPPLY_CHANGE"] = 16386] = "SUPPLY_CHANGE";
|
|
21
|
+
})(TxType = exports.TxType || (exports.TxType = {}));
|
|
22
|
+
var TxVersion;
|
|
23
|
+
(function (TxVersion) {
|
|
24
|
+
TxVersion[TxVersion["mainnet"] = 1744830464] = "mainnet";
|
|
25
|
+
TxVersion[TxVersion["testnet"] = -1744830464] = "testnet";
|
|
26
|
+
TxVersion[TxVersion["mijin"] = 1610612736] = "mijin";
|
|
27
|
+
})(TxVersion = exports.TxVersion || (exports.TxVersion = {}));
|
|
28
|
+
//# sourceMappingURL=nem.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const TYPES: {
|
|
2
|
+
readonly bitcoin: "Bitcoin";
|
|
3
|
+
readonly ethereum: "Ethereum";
|
|
4
|
+
readonly eos: "Eos";
|
|
5
|
+
readonly nem: "NEM";
|
|
6
|
+
readonly stellar: "Stellar";
|
|
7
|
+
readonly cardano: "Cardano";
|
|
8
|
+
readonly ripple: "Ripple";
|
|
9
|
+
readonly tezos: "Tezos";
|
|
10
|
+
readonly binance: "Binance";
|
|
11
|
+
};
|
|
12
|
+
export declare type NetworkType = keyof typeof TYPES;
|
|
13
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TYPES = void 0;
|
|
4
|
+
exports.TYPES = {
|
|
5
|
+
bitcoin: 'Bitcoin',
|
|
6
|
+
ethereum: 'Ethereum',
|
|
7
|
+
eos: 'Eos',
|
|
8
|
+
nem: 'NEM',
|
|
9
|
+
stellar: 'Stellar',
|
|
10
|
+
cardano: 'Cardano',
|
|
11
|
+
ripple: 'Ripple',
|
|
12
|
+
tezos: 'Tezos',
|
|
13
|
+
binance: 'Binance',
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { NETWORK } from '../constants';
|
|
2
|
+
import { CallMethodPayload, CallMethodResponse, CoreMessage, UiRequestButtonData, UiPromise, UiPromiseResponse } from '../events';
|
|
3
|
+
import { Deferred } from '../utils/deferred';
|
|
4
|
+
import type { Device } from '../device/Device';
|
|
5
|
+
import type { FirmwareRange } from '../types';
|
|
6
|
+
export declare type Payload<M> = Extract<CallMethodPayload, {
|
|
7
|
+
method: M;
|
|
8
|
+
}> & {
|
|
9
|
+
override?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare type MethodReturnType<M extends CallMethodPayload['method']> = CallMethodResponse<M>;
|
|
12
|
+
export declare abstract class AbstractMethod<Name extends CallMethodPayload['method'], Params = undefined> {
|
|
13
|
+
responseID: number;
|
|
14
|
+
device: Device;
|
|
15
|
+
params: Params;
|
|
16
|
+
devicePath?: string;
|
|
17
|
+
deviceState?: string;
|
|
18
|
+
hasExpectedDeviceState: boolean;
|
|
19
|
+
keepSession: boolean;
|
|
20
|
+
skipFinalReload: boolean;
|
|
21
|
+
skipFirmwareCheck: boolean;
|
|
22
|
+
overridePreviousCall: boolean;
|
|
23
|
+
overridden: boolean;
|
|
24
|
+
name: Name;
|
|
25
|
+
payload: Payload<Name>;
|
|
26
|
+
info: string;
|
|
27
|
+
useUi: boolean;
|
|
28
|
+
useDevice: boolean;
|
|
29
|
+
useDeviceState: boolean;
|
|
30
|
+
useEmptyPassphrase: boolean;
|
|
31
|
+
allowSeedlessDevice: boolean;
|
|
32
|
+
firmwareRange: FirmwareRange;
|
|
33
|
+
requiredPermissions: string[];
|
|
34
|
+
allowDeviceMode: string[];
|
|
35
|
+
requireDeviceMode: string[];
|
|
36
|
+
network: NETWORK.NetworkType;
|
|
37
|
+
useCardanoDerivation: boolean;
|
|
38
|
+
confirmation?(): Promise<boolean | undefined>;
|
|
39
|
+
noBackupConfirmation?(): Promise<boolean>;
|
|
40
|
+
getButtonRequestData?(code: string): UiRequestButtonData | undefined;
|
|
41
|
+
postMessage: (message: CoreMessage) => void;
|
|
42
|
+
getPopupPromise: () => Deferred<void>;
|
|
43
|
+
createUiPromise: <T extends UiPromiseResponse['type']>(promiseId: T, device?: Device) => UiPromise<T>;
|
|
44
|
+
removeUiPromise: (promise: Deferred<any>) => void;
|
|
45
|
+
constructor(message: {
|
|
46
|
+
id?: number;
|
|
47
|
+
payload: Payload<Name>;
|
|
48
|
+
});
|
|
49
|
+
setDevice(device: Device): void;
|
|
50
|
+
requestPermissions(): Promise<boolean>;
|
|
51
|
+
checkPermissions(): void;
|
|
52
|
+
savePermissions(temporary?: boolean): void;
|
|
53
|
+
checkFirmwareRange(isUsingPopup?: boolean): Promise<"ui-device_firmware_old" | "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined>;
|
|
54
|
+
abstract init(): void;
|
|
55
|
+
abstract run(): Promise<MethodReturnType<Name>>;
|
|
56
|
+
getCustomMessages(): void;
|
|
57
|
+
dispose(): void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=AbstractMethod.d.ts.map
|