@trezor/connect 9.0.3 → 9.0.5
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/CHANGELOG.md +67 -0
- package/README.md +1 -1
- package/lib/api/authorizeCoinJoin.js +6 -2
- package/lib/api/binanceGetAddress.d.ts +1 -1
- package/lib/api/binanceSignTransaction.d.ts +1 -1
- package/lib/api/bitcoin/Fees.d.ts +1 -1
- package/lib/api/bitcoin/TransactionComposer.d.ts +1 -1
- package/lib/api/bitcoin/enhanceSignTx.js +1 -1
- package/lib/api/bitcoin/inputs.js +3 -2
- package/lib/api/bitcoin/refTx.js +3 -3
- package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
- package/lib/api/blockchainDisconnect.d.ts +1 -1
- package/lib/api/blockchainDisconnect.js +1 -1
- package/lib/api/blockchainEstimateFee.d.ts +1 -1
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
- package/lib/api/blockchainGetTransactions.d.ts +1 -1
- package/lib/api/blockchainSetCustomBackend.d.ts +1 -1
- package/lib/api/blockchainSetCustomBackend.js +1 -1
- package/lib/api/blockchainSubscribe.d.ts +1 -1
- package/lib/api/blockchainSubscribeFiatRates.d.ts +1 -1
- package/lib/api/blockchainUnsubscribe.d.ts +1 -1
- package/lib/api/blockchainUnsubscribeFiatRates.d.ts +1 -1
- package/lib/api/cardano/cardanoAuxiliaryData.d.ts +1 -1
- package/lib/api/cardano/cardanoAuxiliaryData.js +38 -16
- package/lib/api/cardano/cardanoCertificate.d.ts +2 -2
- package/lib/api/cardano/cardanoInputs.d.ts +3 -3
- package/lib/api/cardano/cardanoOutputs.d.ts +1 -1
- package/lib/api/cardano/cardanoTokenBundle.d.ts +1 -1
- package/lib/api/cardanoGetAddress.d.ts +1 -1
- package/lib/api/cardanoSignTransaction.d.ts +2 -1
- package/lib/api/cardanoSignTransaction.js +23 -3
- package/lib/api/common/Discovery.d.ts +2 -2
- package/lib/api/common/paramsValidator.d.ts +2 -2
- package/lib/api/composeTransaction.d.ts +1 -1
- package/lib/api/eos/eosSignTx.js +1 -1
- package/lib/api/eosSignTransaction.d.ts +1 -1
- package/lib/api/ethereumGetAddress.d.ts +1 -1
- package/lib/api/ethereumGetPublicKey.d.ts +1 -1
- package/lib/api/ethereumSignTransaction.d.ts +1 -1
- package/lib/api/ethereumSignTypedData.d.ts +1 -1
- package/lib/api/firmware/uploadFirmware.d.ts +2 -2
- package/lib/api/firmwareUpdate.d.ts +1 -1
- package/lib/api/firmwareUpdate.js +1 -1
- package/lib/api/getAccountInfo.d.ts +1 -1
- package/lib/api/getAddress.d.ts +1 -1
- package/lib/api/getCoinInfo.d.ts +2 -2
- package/lib/api/getOwnershipProof.d.ts +1 -5
- package/lib/api/getOwnershipProof.js +5 -3
- package/lib/api/getPublicKey.d.ts +1 -1
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +3 -1
- package/lib/api/nemGetAddress.d.ts +1 -1
- package/lib/api/pushTransaction.d.ts +1 -1
- package/lib/api/rippleGetAddress.d.ts +1 -1
- package/lib/api/setBusy.d.ts +7 -0
- package/lib/api/setBusy.js +31 -0
- package/lib/api/setProxy.js +3 -4
- package/lib/api/signTransaction.d.ts +2 -2
- package/lib/api/signTransaction.js +10 -3
- package/lib/api/stellarGetAddress.d.ts +1 -1
- package/lib/api/stellarSignTransaction.d.ts +1 -1
- package/lib/api/tezosGetAddress.d.ts +1 -1
- package/lib/backend/BackendManager.d.ts +21 -0
- package/lib/backend/BackendManager.js +87 -0
- package/lib/backend/Blockchain.d.ts +66 -0
- package/lib/backend/Blockchain.js +189 -0
- package/lib/backend/BlockchainLink.d.ts +6 -71
- package/lib/backend/BlockchainLink.js +12 -288
- package/lib/constants/cardano.d.ts +3 -1
- package/lib/constants/cardano.js +3 -1
- package/lib/constants/network.d.ts +1 -1
- package/lib/core/AbstractMethod.d.ts +5 -4
- package/lib/core/AbstractMethod.js +7 -5
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.js +3 -1
- package/lib/core/method.d.ts +1 -1
- package/lib/data/DataManager.d.ts +1 -1
- package/lib/data/analyticsInfo.d.ts +6 -0
- package/lib/data/analyticsInfo.js +37 -0
- package/lib/data/config.js +1 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/AbortController.d.ts +1 -1
- package/lib/device/DescriptorStream.d.ts +1 -1
- package/lib/device/Device.d.ts +2 -2
- package/lib/device/Device.js +11 -2
- package/lib/device/DeviceCommands.d.ts +8 -7
- package/lib/device/DeviceCommands.js +14 -1
- package/lib/device/DeviceList.d.ts +1 -1
- package/lib/events/blockchain.d.ts +4 -5
- package/lib/events/call.d.ts +10 -10
- package/lib/events/core.d.ts +3 -2
- package/lib/events/device.d.ts +3 -3
- package/lib/events/iframe.d.ts +2 -2
- package/lib/events/popup.d.ts +2 -2
- package/lib/events/transport.d.ts +3 -3
- package/lib/events/ui-promise.d.ts +2 -2
- package/lib/events/ui-request.d.ts +8 -6
- package/lib/events/ui-response.d.ts +2 -2
- package/lib/factory.js +1 -0
- package/lib/types/account.d.ts +2 -2
- package/lib/types/api/authorizeCoinJoin.d.ts +1 -0
- package/lib/types/api/binance/index.d.ts +1 -1
- package/lib/types/api/bitcoin/index.d.ts +6 -2
- package/lib/types/api/blockchainGetTransactions.d.ts +1 -1
- package/lib/types/api/blockchainSetCustomBackend.d.ts +1 -1
- package/lib/types/api/blockchainSubscribe.d.ts +1 -1
- package/lib/types/api/blockchainSubscribeFiatRates.d.ts +1 -1
- package/lib/types/api/cardano/index.d.ts +12 -5
- package/lib/types/api/composeTransaction.d.ts +3 -3
- package/lib/types/api/eos/index.d.ts +1 -1
- package/lib/types/api/getAddress.d.ts +1 -1
- package/lib/types/api/index.d.ts +2 -0
- package/lib/types/api/nem/index.d.ts +9 -9
- package/lib/types/api/off.d.ts +2 -2
- package/lib/types/api/on.d.ts +2 -2
- package/lib/types/api/pushTransaction.d.ts +1 -1
- package/lib/types/api/setBusy.d.ts +4 -0
- package/lib/types/api/setBusy.js +3 -0
- package/lib/types/api/setProxy.d.ts +1 -2
- package/lib/types/api/stellar/index.d.ts +2 -2
- package/lib/types/coinInfo.d.ts +3 -3
- package/lib/types/device.d.ts +13 -13
- package/lib/types/firmware.d.ts +3 -3
- package/lib/types/params.d.ts +3 -3
- package/lib/types/settings.d.ts +1 -2
- package/lib/types/utils.d.ts +2 -2
- package/lib/utils/accountUtils.d.ts +1 -1
- package/lib/utils/browserUtils.d.ts +2 -2
- package/lib/utils/debug.d.ts +1 -1
- package/lib/utils/deferred.d.ts +2 -2
- package/lib/utils/interactionTimeout.d.ts +1 -1
- package/lib/workers/RNUsbPlugin.d.ts +1 -1
- package/lib/workers/workers.d.ts +1 -1
- package/package.json +83 -78
- package/lib/utils/bufferUtils.d.ts +0 -3
- package/lib/utils/bufferUtils.js +0 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import type { PROTO } from '../constants';
|
|
3
3
|
import type { EthereumNetworkInfo } from '../types';
|
|
4
|
-
|
|
4
|
+
type Params = PROTO.EthereumGetPublicKey & {
|
|
5
5
|
network?: EthereumNetworkInfo;
|
|
6
6
|
};
|
|
7
7
|
export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPublicKey', Params[]> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import type { EthereumSignTypedDataTypes, EthereumSignTypedData as EthereumSignTypedDataParams, EthereumSignTypedHash as EthereumSignTypedHashParams } from '../types/api/ethereum';
|
|
3
|
-
|
|
3
|
+
type Params = (Omit<EthereumSignTypedDataParams<EthereumSignTypedDataTypes>, 'path'> | Omit<EthereumSignTypedHashParams<EthereumSignTypedDataTypes>, 'path'>) & {
|
|
4
4
|
address_n: number[];
|
|
5
5
|
};
|
|
6
6
|
export default class EthereumSignTypedData extends AbstractMethod<'ethereumSignTypedData', Params> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostMessage } from '../../events';
|
|
2
2
|
import { PROTO } from '../../constants';
|
|
3
3
|
import type { Device } from '../../device/Device';
|
|
4
4
|
import type { TypedCall } from '../../device/DeviceCommands';
|
|
5
|
-
export declare const uploadFirmware: (typedCall: TypedCall, postMessage:
|
|
5
|
+
export declare const uploadFirmware: (typedCall: TypedCall, postMessage: PostMessage, device: Device, { payload }: PROTO.FirmwareUpload) => Promise<PROTO.Success>;
|
|
6
6
|
//# sourceMappingURL=uploadFirmware.d.ts.map
|
|
@@ -73,7 +73,7 @@ class FirmwareUpdate extends AbstractMethod_1.AbstractMethod {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
catch (err) {
|
|
76
|
-
throw constants_1.ERRORS.TypedError('Method_FirmwareUpdate_DownloadFailed',
|
|
76
|
+
throw constants_1.ERRORS.TypedError('Method_FirmwareUpdate_DownloadFailed', `Failed to download firmware binary ${err.message}`);
|
|
77
77
|
}
|
|
78
78
|
const stripped = (0, firmware_1.stripFwHeaders)(binary);
|
|
79
79
|
await (0, firmware_1.uploadFirmware)(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: (0, firmware_1.shouldStripFwHeaders)(device.features) ? stripped : binary });
|
|
@@ -2,7 +2,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
|
|
|
2
2
|
import { Discovery } from './common/Discovery';
|
|
3
3
|
import type { CoinInfo, AccountInfo, AccountUtxo } from '../types';
|
|
4
4
|
import type { GetAccountInfo as GetAccountInfoParams } from '../types/api/getAccountInfo';
|
|
5
|
-
|
|
5
|
+
type Request = GetAccountInfoParams & {
|
|
6
6
|
address_n: number[];
|
|
7
7
|
coinInfo: CoinInfo;
|
|
8
8
|
};
|
package/lib/api/getAddress.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import { PROTO } from '../constants';
|
|
3
3
|
import type { BitcoinNetworkInfo } from '../types';
|
|
4
|
-
|
|
4
|
+
type Params = PROTO.GetAddress & {
|
|
5
5
|
address?: string;
|
|
6
6
|
coinInfo: BitcoinNetworkInfo;
|
|
7
7
|
unlockPath?: PROTO.UnlockPath;
|
package/lib/api/getCoinInfo.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import type { CoinInfo } from '../types';
|
|
3
|
-
|
|
3
|
+
type Params = {
|
|
4
4
|
coinInfo: CoinInfo;
|
|
5
5
|
};
|
|
6
6
|
export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
7
7
|
init(): void;
|
|
8
|
-
run(): Promise<
|
|
8
|
+
run(): Promise<CoinInfo>;
|
|
9
9
|
}
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=getCoinInfo.d.ts.map
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import { PROTO } from '../constants';
|
|
3
|
-
|
|
4
|
-
preauthorized?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export default class GetOwnershipProof extends AbstractMethod<'getOwnershipProof', Params[]> {
|
|
3
|
+
export default class GetOwnershipProof extends AbstractMethod<'getOwnershipProof', PROTO.GetOwnershipProof[]> {
|
|
7
4
|
hasBundle?: boolean;
|
|
8
5
|
confirmed?: boolean;
|
|
9
6
|
init(): void;
|
|
10
7
|
confirmation(): Promise<boolean>;
|
|
11
8
|
run(): Promise<import("../types/api/getOwnershipProof").OwnershipProof | import("../types/api/getOwnershipProof").OwnershipProof[]>;
|
|
12
9
|
}
|
|
13
|
-
export {};
|
|
14
10
|
//# sourceMappingURL=getOwnershipProof.d.ts.map
|
|
@@ -29,6 +29,9 @@ class GetOwnershipProof extends AbstractMethod_1.AbstractMethod {
|
|
|
29
29
|
const coinInfo = (0, coinInfo_1.getBitcoinNetwork)(batch.coin || address_n);
|
|
30
30
|
const script_type = batch.scriptType || (0, pathUtils_1.getScriptType)(address_n);
|
|
31
31
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, coinInfo, this.firmwareRange);
|
|
32
|
+
if (batch.preauthorized) {
|
|
33
|
+
this.preauthorized = batch.preauthorized;
|
|
34
|
+
}
|
|
32
35
|
return {
|
|
33
36
|
address_n,
|
|
34
37
|
coin_name: coinInfo ? coinInfo.name : undefined,
|
|
@@ -37,7 +40,6 @@ class GetOwnershipProof extends AbstractMethod_1.AbstractMethod {
|
|
|
37
40
|
user_confirmation: batch.userConfirmation,
|
|
38
41
|
ownership_ids: batch.ownershipIds,
|
|
39
42
|
commitment_data: batch.commitmentData,
|
|
40
|
-
preauthorized: batch.preauthorized,
|
|
41
43
|
};
|
|
42
44
|
});
|
|
43
45
|
}
|
|
@@ -63,8 +65,8 @@ class GetOwnershipProof extends AbstractMethod_1.AbstractMethod {
|
|
|
63
65
|
const cmd = this.device.getCommands();
|
|
64
66
|
for (let i = 0; i < this.params.length; i++) {
|
|
65
67
|
const batch = this.params[i];
|
|
66
|
-
if (
|
|
67
|
-
await cmd.
|
|
68
|
+
if (this.preauthorized) {
|
|
69
|
+
await cmd.preauthorize(true);
|
|
68
70
|
}
|
|
69
71
|
const { message } = await cmd.typedCall('GetOwnershipProof', 'OwnershipProof', batch);
|
|
70
72
|
responses.push({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import type { BitcoinNetworkInfo } from '../types';
|
|
3
3
|
import type { PROTO } from '../constants';
|
|
4
|
-
|
|
4
|
+
type Params = PROTO.GetPublicKey & {
|
|
5
5
|
coinInfo?: BitcoinNetworkInfo;
|
|
6
6
|
unlockPath?: PROTO.UnlockPath;
|
|
7
7
|
};
|
package/lib/api/index.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export { default as requestLogin } from './requestLogin';
|
|
|
51
51
|
export { default as resetDevice } from './resetDevice';
|
|
52
52
|
export { default as rippleGetAddress } from './rippleGetAddress';
|
|
53
53
|
export { default as rippleSignTransaction } from './rippleSignTransaction';
|
|
54
|
+
export { default as setBusy } from './setBusy';
|
|
54
55
|
export { default as setProxy } from './setProxy';
|
|
55
56
|
export { default as signMessage } from './signMessage';
|
|
56
57
|
export { default as signTransaction } from './signTransaction';
|
package/lib/api/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.requestLogin = exports.recoveryDevice = exports.rebootToBootloader = exports.pushTransaction = exports.nemSignTransaction = exports.nemGetAddress = exports.getSettings = exports.getPublicKey = exports.getOwnershipProof = exports.getOwnershipId = exports.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.firmwareUpdate = exports.ethereumVerifyMessage = exports.ethereumSignTypedData = exports.ethereumSignTransaction = exports.ethereumSignMessage = exports.ethereumGetPublicKey = exports.ethereumGetAddress = exports.eosSignTransaction = exports.eosGetPublicKey = exports.composeTransaction = exports.cipherKeyValue = exports.changePin = exports.cardanoSignTransaction = exports.cardanoGetPublicKey = exports.cardanoGetNativeScriptHash = exports.cardanoGetAddress = exports.blockchainUnsubscribeFiatRates = exports.blockchainUnsubscribe = exports.blockchainSubscribeFiatRates = exports.blockchainSubscribe = exports.blockchainSetCustomBackend = exports.blockchainGetTransactions = exports.blockchainGetFiatRatesForTimestamps = exports.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.binanceSignTransaction = exports.binanceGetPublicKey = exports.binanceGetAddress = exports.backupDevice = exports.authorizeCoinJoin = exports.applySettings = exports.applyFlags = void 0;
|
|
7
|
-
exports.checkFirmwareAuthenticity = exports.wipeDevice = exports.verifyMessage = exports.unlockPath = exports.tezosSignTransaction = exports.tezosGetPublicKey = exports.tezosGetAddress = exports.stellarSignTransaction = exports.stellarGetAddress = exports.signTransaction = exports.signMessage = exports.setProxy = exports.rippleSignTransaction = exports.rippleGetAddress = exports.resetDevice = void 0;
|
|
7
|
+
exports.checkFirmwareAuthenticity = exports.wipeDevice = exports.verifyMessage = exports.unlockPath = exports.tezosSignTransaction = exports.tezosGetPublicKey = exports.tezosGetAddress = exports.stellarSignTransaction = exports.stellarGetAddress = exports.signTransaction = exports.signMessage = exports.setProxy = exports.setBusy = exports.rippleSignTransaction = exports.rippleGetAddress = exports.resetDevice = void 0;
|
|
8
8
|
var applyFlags_1 = require("./applyFlags");
|
|
9
9
|
Object.defineProperty(exports, "applyFlags", { enumerable: true, get: function () { return __importDefault(applyFlags_1).default; } });
|
|
10
10
|
var applySettings_1 = require("./applySettings");
|
|
@@ -111,6 +111,8 @@ var rippleGetAddress_1 = require("./rippleGetAddress");
|
|
|
111
111
|
Object.defineProperty(exports, "rippleGetAddress", { enumerable: true, get: function () { return __importDefault(rippleGetAddress_1).default; } });
|
|
112
112
|
var rippleSignTransaction_1 = require("./rippleSignTransaction");
|
|
113
113
|
Object.defineProperty(exports, "rippleSignTransaction", { enumerable: true, get: function () { return __importDefault(rippleSignTransaction_1).default; } });
|
|
114
|
+
var setBusy_1 = require("./setBusy");
|
|
115
|
+
Object.defineProperty(exports, "setBusy", { enumerable: true, get: function () { return __importDefault(setBusy_1).default; } });
|
|
114
116
|
var setProxy_1 = require("./setProxy");
|
|
115
117
|
Object.defineProperty(exports, "setProxy", { enumerable: true, get: function () { return __importDefault(setProxy_1).default; } });
|
|
116
118
|
var signMessage_1 = require("./signMessage");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import { PROTO } from '../constants';
|
|
3
|
-
|
|
3
|
+
type Params = PROTO.NEMGetAddress & {
|
|
4
4
|
address?: string;
|
|
5
5
|
};
|
|
6
6
|
export default class NEMGetAddress extends AbstractMethod<'nemGetAddress', Params[]> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import { PROTO } from '../constants';
|
|
3
|
-
|
|
3
|
+
type Params = PROTO.RippleGetAddress & {
|
|
4
4
|
address?: string;
|
|
5
5
|
};
|
|
6
6
|
export default class RippleGetAddress extends AbstractMethod<'rippleGetAddress', Params[]> {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import { PROTO } from '../constants';
|
|
3
|
+
export default class SetBusy extends AbstractMethod<'setBusy', PROTO.SetBusy> {
|
|
4
|
+
init(): void;
|
|
5
|
+
run(): Promise<PROTO.Success>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=setBusy.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
const events_1 = require("../events");
|
|
5
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
6
|
+
class SetBusy extends AbstractMethod_1.AbstractMethod {
|
|
7
|
+
init() {
|
|
8
|
+
this.useDeviceState = false;
|
|
9
|
+
this.requiredPermissions = ['management'];
|
|
10
|
+
const { payload } = this;
|
|
11
|
+
(0, paramsValidator_1.validateParams)(payload, [{ name: 'expiry_ms', type: 'number' }]);
|
|
12
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, {
|
|
13
|
+
1: { min: '0', max: '0' },
|
|
14
|
+
2: { min: '2.5.3', max: '0' },
|
|
15
|
+
});
|
|
16
|
+
this.params = {
|
|
17
|
+
expiry_ms: payload.expiry_ms,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async run() {
|
|
21
|
+
const cmd = this.device.getCommands();
|
|
22
|
+
const { message } = await cmd.typedCall('SetBusy', 'Success', this.params);
|
|
23
|
+
if (this.keepSession && !!this.params.expiry_ms) {
|
|
24
|
+
this.device.features.busy = true;
|
|
25
|
+
this.postMessage((0, events_1.createDeviceMessage)(events_1.DEVICE.CHANGED, this.device.toMessageObject()));
|
|
26
|
+
}
|
|
27
|
+
return message;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = SetBusy;
|
|
31
|
+
//# sourceMappingURL=setBusy.js.map
|
package/lib/api/setProxy.js
CHANGED
|
@@ -9,14 +9,13 @@ class SetProxy extends AbstractMethod_1.AbstractMethod {
|
|
|
9
9
|
this.requiredPermissions = [];
|
|
10
10
|
this.useDevice = false;
|
|
11
11
|
this.useUi = false;
|
|
12
|
-
(0, paramsValidator_1.validateParams)(this.payload, [
|
|
12
|
+
(0, paramsValidator_1.validateParams)(this.payload, []);
|
|
13
13
|
}
|
|
14
14
|
async run() {
|
|
15
|
-
const { proxy
|
|
16
|
-
const isChanged = proxy !== this.payload.proxy
|
|
15
|
+
const { proxy } = DataManager_1.DataManager.getSettings();
|
|
16
|
+
const isChanged = proxy !== this.payload.proxy;
|
|
17
17
|
if (isChanged) {
|
|
18
18
|
DataManager_1.DataManager.settings.proxy = this.payload.proxy;
|
|
19
|
-
DataManager_1.DataManager.settings.useOnionLinks = this.payload.useOnionLinks;
|
|
20
19
|
await (0, BlockchainLink_1.reconnectAllBackends)();
|
|
21
20
|
}
|
|
22
21
|
return { message: 'Success' };
|
|
@@ -2,16 +2,16 @@ import { AbstractMethod } from '../core/AbstractMethod';
|
|
|
2
2
|
import { PROTO } from '../constants';
|
|
3
3
|
import type { BitcoinNetworkInfo, AccountAddresses } from '../types';
|
|
4
4
|
import type { RefTransaction, TransactionOptions } from '../types/api/bitcoin';
|
|
5
|
-
|
|
5
|
+
type Params = {
|
|
6
6
|
inputs: PROTO.TxInputType[];
|
|
7
7
|
outputs: PROTO.TxOutputType[];
|
|
8
8
|
paymentRequests: PROTO.TxAckPaymentRequest[];
|
|
9
|
+
coinjoinRequest?: PROTO.CoinJoinRequest;
|
|
9
10
|
refTxs?: RefTransaction[];
|
|
10
11
|
addresses?: AccountAddresses;
|
|
11
12
|
options: TransactionOptions;
|
|
12
13
|
coinInfo: BitcoinNetworkInfo;
|
|
13
14
|
push: boolean;
|
|
14
|
-
preauthorized?: boolean;
|
|
15
15
|
unlockPath?: PROTO.UnlockPath;
|
|
16
16
|
};
|
|
17
17
|
export default class SignTransaction extends AbstractMethod<'signTransaction', Params> {
|
|
@@ -19,6 +19,7 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
19
19
|
{ name: 'inputs', type: 'array', required: true },
|
|
20
20
|
{ name: 'outputs', type: 'array', required: true },
|
|
21
21
|
{ name: 'paymentRequests', type: 'array', allowEmpty: true },
|
|
22
|
+
{ name: 'coinjoinRequest', type: 'object' },
|
|
22
23
|
{ name: 'refTxs', type: 'array', allowEmpty: true },
|
|
23
24
|
{ name: 'account', type: 'object' },
|
|
24
25
|
{ name: 'locktime', type: 'number' },
|
|
@@ -33,6 +34,7 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
33
34
|
{ name: 'preauthorized', type: 'boolean' },
|
|
34
35
|
{ name: 'amountUnit', type: ['number', 'string'] },
|
|
35
36
|
{ name: 'unlockPath', type: 'object' },
|
|
37
|
+
{ name: 'serialize', type: 'boolean' },
|
|
36
38
|
]);
|
|
37
39
|
if (payload.unlockPath) {
|
|
38
40
|
(0, paramsValidator_1.validateParams)(payload.unlockPath, [
|
|
@@ -45,6 +47,7 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
45
47
|
throw constants_1.ERRORS.TypedError('Method_UnknownCoin');
|
|
46
48
|
}
|
|
47
49
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, coinInfo, this.firmwareRange);
|
|
50
|
+
this.preauthorized = payload.preauthorized;
|
|
48
51
|
this.info = (0, pathUtils_1.getLabel)('Sign #NETWORK transaction', coinInfo);
|
|
49
52
|
const inputs = (0, bitcoin_1.validateTrezorInputs)(payload.inputs, coinInfo);
|
|
50
53
|
const outputs = (0, bitcoin_1.validateTrezorOutputs)(payload.outputs, coinInfo);
|
|
@@ -73,10 +76,11 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
73
76
|
branch_id: payload.branchId,
|
|
74
77
|
decred_staking_ticket: payload.decredStakingTicket,
|
|
75
78
|
amount_unit: payload.amountUnit,
|
|
79
|
+
serialize: payload.serialize,
|
|
80
|
+
coinjoin_request: payload.coinjoinRequest,
|
|
76
81
|
},
|
|
77
82
|
coinInfo,
|
|
78
83
|
push: typeof payload.push === 'boolean' ? payload.push : false,
|
|
79
|
-
preauthorized: payload.preauthorized,
|
|
80
84
|
unlockPath: payload.unlockPath,
|
|
81
85
|
};
|
|
82
86
|
this.params.options = (0, bitcoin_1.enhanceSignTx)(this.params.options, coinInfo);
|
|
@@ -121,8 +125,8 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
121
125
|
else {
|
|
122
126
|
refTxs = params.refTxs;
|
|
123
127
|
}
|
|
124
|
-
if (
|
|
125
|
-
await device.getCommands().
|
|
128
|
+
if (this.preauthorized) {
|
|
129
|
+
await device.getCommands().preauthorize(true);
|
|
126
130
|
}
|
|
127
131
|
else if (params.unlockPath) {
|
|
128
132
|
await device.getCommands().unlockPath(params.unlockPath);
|
|
@@ -133,6 +137,9 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
133
137
|
refTxs,
|
|
134
138
|
typedCall: device.getCommands().typedCall.bind(device.getCommands()),
|
|
135
139
|
});
|
|
140
|
+
if (!response.serializedTx) {
|
|
141
|
+
return response;
|
|
142
|
+
}
|
|
136
143
|
if (params.options.decred_staking_ticket) {
|
|
137
144
|
await (0, bitcoin_1.verifyTicketTx)(device.getCommands().getHDNode.bind(device.getCommands()), params.inputs, params.outputs, response.serializedTx, params.coinInfo);
|
|
138
145
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import { PROTO } from '../constants';
|
|
3
|
-
|
|
3
|
+
type Params = PROTO.StellarGetAddress & {
|
|
4
4
|
address?: string;
|
|
5
5
|
};
|
|
6
6
|
export default class StellarGetAddress extends AbstractMethod<'stellarGetAddress', Params[]> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import { PROTO } from '../constants';
|
|
3
|
-
|
|
3
|
+
type Params = PROTO.TezosGetAddress & {
|
|
4
4
|
address?: string;
|
|
5
5
|
};
|
|
6
6
|
export default class TezosGetAddress extends AbstractMethod<'tezosGetAddress', Params[]> {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Blockchain, BlockchainOptions } from './Blockchain';
|
|
2
|
+
import type { CoinInfo, BlockchainLink } from '../types';
|
|
3
|
+
type CoinShortcut = CoinInfo['shortcut'];
|
|
4
|
+
export declare class BackendManager {
|
|
5
|
+
private readonly instances;
|
|
6
|
+
private readonly custom;
|
|
7
|
+
private readonly preferred;
|
|
8
|
+
get(shortcut: CoinShortcut): Blockchain | null;
|
|
9
|
+
remove(shortcut: CoinShortcut): void;
|
|
10
|
+
getOrConnect(coinInfo: CoinInfo, postMessage: BlockchainOptions['postMessage']): Promise<Blockchain>;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
reconnectAll(): Promise<Blockchain[]>;
|
|
13
|
+
isSupported(coinInfo: CoinInfo): void;
|
|
14
|
+
setCustom(shortcut: CoinShortcut, blockchainLink: BlockchainLink): void;
|
|
15
|
+
removeCustom(shortcut: CoinShortcut): void;
|
|
16
|
+
private setPreferred;
|
|
17
|
+
private removePreferred;
|
|
18
|
+
private patchCoinInfo;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=BackendManager.d.ts.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackendManager = void 0;
|
|
4
|
+
const DataManager_1 = require("../data/DataManager");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const Blockchain_1 = require("./Blockchain");
|
|
7
|
+
class BackendManager {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.instances = {};
|
|
10
|
+
this.custom = {};
|
|
11
|
+
this.preferred = {};
|
|
12
|
+
}
|
|
13
|
+
get(shortcut) {
|
|
14
|
+
var _a;
|
|
15
|
+
return (_a = this.instances[shortcut]) !== null && _a !== void 0 ? _a : null;
|
|
16
|
+
}
|
|
17
|
+
remove(shortcut) {
|
|
18
|
+
delete this.instances[shortcut];
|
|
19
|
+
}
|
|
20
|
+
async getOrConnect(coinInfo, postMessage) {
|
|
21
|
+
let backend = this.get(coinInfo.shortcut);
|
|
22
|
+
if (!backend) {
|
|
23
|
+
backend = new Blockchain_1.Blockchain({
|
|
24
|
+
coinInfo: this.patchCoinInfo(coinInfo),
|
|
25
|
+
postMessage,
|
|
26
|
+
debug: DataManager_1.DataManager.getSettings('debug'),
|
|
27
|
+
proxy: DataManager_1.DataManager.getSettings('proxy'),
|
|
28
|
+
onConnected: url => this.setPreferred(coinInfo.shortcut, url),
|
|
29
|
+
onDisconnected: () => this.remove(coinInfo.shortcut),
|
|
30
|
+
});
|
|
31
|
+
this.instances[coinInfo.shortcut] = backend;
|
|
32
|
+
try {
|
|
33
|
+
await backend.init();
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.remove(coinInfo.shortcut);
|
|
37
|
+
this.removePreferred(coinInfo.shortcut);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return backend;
|
|
42
|
+
}
|
|
43
|
+
dispose() {
|
|
44
|
+
Object.values(this.instances).forEach(i => i.disconnect());
|
|
45
|
+
}
|
|
46
|
+
reconnectAll() {
|
|
47
|
+
const params = Object.values(this.instances).map(i => [i.coinInfo, i.postMessage]);
|
|
48
|
+
Object.values(this.instances).forEach(i => i.disconnect());
|
|
49
|
+
return Promise.all(params.map(p => this.getOrConnect(...p)));
|
|
50
|
+
}
|
|
51
|
+
isSupported(coinInfo) {
|
|
52
|
+
const info = this.custom[coinInfo.shortcut] || coinInfo.blockchainLink;
|
|
53
|
+
if (!info) {
|
|
54
|
+
throw constants_1.ERRORS.TypedError('Backend_NotSupported');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
setCustom(shortcut, blockchainLink) {
|
|
58
|
+
this.removePreferred(shortcut);
|
|
59
|
+
this.custom[shortcut] = blockchainLink;
|
|
60
|
+
}
|
|
61
|
+
removeCustom(shortcut) {
|
|
62
|
+
this.removePreferred(shortcut);
|
|
63
|
+
delete this.custom[shortcut];
|
|
64
|
+
}
|
|
65
|
+
setPreferred(shortcut, url) {
|
|
66
|
+
this.preferred[shortcut] = url;
|
|
67
|
+
}
|
|
68
|
+
removePreferred(shortcut) {
|
|
69
|
+
delete this.preferred[shortcut];
|
|
70
|
+
}
|
|
71
|
+
patchCoinInfo(coinInfo) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
const custom = this.custom[coinInfo.shortcut];
|
|
74
|
+
const preferred = this.preferred[coinInfo.shortcut];
|
|
75
|
+
const url = preferred ? [preferred] : (_a = custom === null || custom === void 0 ? void 0 : custom.url) !== null && _a !== void 0 ? _a : (_b = coinInfo.blockchainLink) === null || _b === void 0 ? void 0 : _b.url;
|
|
76
|
+
return {
|
|
77
|
+
...coinInfo,
|
|
78
|
+
blockchainLink: {
|
|
79
|
+
...coinInfo.blockchainLink,
|
|
80
|
+
...custom,
|
|
81
|
+
url,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.BackendManager = BackendManager;
|
|
87
|
+
//# sourceMappingURL=BackendManager.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import BlockchainLink, { ServerInfo, SubscriptionAccountInfo, BlockchainLinkParams, BlockchainLinkResponse } from '@trezor/blockchain-link';
|
|
2
|
+
import { PostMessage } from '../events';
|
|
3
|
+
import { ERRORS } from '../constants';
|
|
4
|
+
import type { CoinInfo, Proxy } from '../types';
|
|
5
|
+
export type BlockchainOptions = {
|
|
6
|
+
coinInfo: CoinInfo;
|
|
7
|
+
postMessage: PostMessage;
|
|
8
|
+
proxy?: Proxy;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
onConnected?: (url: string) => void;
|
|
11
|
+
onDisconnected?: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare class Blockchain {
|
|
14
|
+
link: BlockchainLink;
|
|
15
|
+
serverInfo?: ServerInfo;
|
|
16
|
+
coinInfo: BlockchainOptions['coinInfo'];
|
|
17
|
+
postMessage: BlockchainOptions['postMessage'];
|
|
18
|
+
feeForBlock: BlockchainLinkResponse<'estimateFee'>;
|
|
19
|
+
feeTimestamp: number;
|
|
20
|
+
private onConnected;
|
|
21
|
+
private onDisconnected;
|
|
22
|
+
constructor(options: BlockchainOptions);
|
|
23
|
+
onError(error: ERRORS.TrezorError): void;
|
|
24
|
+
init(): Promise<void>;
|
|
25
|
+
getTransactions(txs: string[]): Promise<import("@trezor/blockchain-link").TypedRawTransaction[]>;
|
|
26
|
+
getCurrentFiatRates(params: {
|
|
27
|
+
currencies?: string[];
|
|
28
|
+
}): Promise<{
|
|
29
|
+
ts: number;
|
|
30
|
+
rates: import("@trezor/blockchain-link").FiatRates;
|
|
31
|
+
}>;
|
|
32
|
+
getFiatRatesForTimestamps(params: {
|
|
33
|
+
timestamps: number[];
|
|
34
|
+
}): Promise<{
|
|
35
|
+
tickers: {
|
|
36
|
+
ts: number;
|
|
37
|
+
rates: import("@trezor/blockchain-link").FiatRates;
|
|
38
|
+
}[];
|
|
39
|
+
}>;
|
|
40
|
+
getAccountBalanceHistory(params: BlockchainLinkParams<'getAccountBalanceHistory'>): Promise<import("@trezor/blockchain-link").AccountBalanceHistory[]>;
|
|
41
|
+
getNetworkInfo(): Promise<ServerInfo>;
|
|
42
|
+
getAccountInfo(request: BlockchainLinkParams<'getAccountInfo'>): Promise<import("@trezor/blockchain-link").AccountInfo>;
|
|
43
|
+
getAccountUtxo(descriptor: string): Promise<import("@trezor/blockchain-link").Utxo[]>;
|
|
44
|
+
estimateFee(request: {
|
|
45
|
+
blocks?: number[];
|
|
46
|
+
}): Promise<{
|
|
47
|
+
feePerUnit: string;
|
|
48
|
+
feePerTx?: string | undefined;
|
|
49
|
+
feeLimit?: string | undefined;
|
|
50
|
+
}[]>;
|
|
51
|
+
subscribe(accounts?: SubscriptionAccountInfo[]): Promise<{
|
|
52
|
+
subscribed: boolean;
|
|
53
|
+
}>;
|
|
54
|
+
subscribeFiatRates(_currency?: string): Promise<{
|
|
55
|
+
subscribed: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
unsubscribe(accounts?: SubscriptionAccountInfo[]): Promise<{
|
|
58
|
+
subscribed: boolean;
|
|
59
|
+
}>;
|
|
60
|
+
unsubscribeFiatRates(): Promise<{
|
|
61
|
+
subscribed: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
pushTransaction(tx: string): Promise<string>;
|
|
64
|
+
disconnect(): void;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=Blockchain.d.ts.map
|