@trezor/connect 9.1.1 → 9.1.3
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 +17 -3
- package/README.md +2 -2
- package/lib/api/backupDevice.d.ts +1 -1
- package/lib/api/binanceGetAddress.d.ts +1 -0
- package/lib/api/binanceGetAddress.js +4 -4
- package/lib/api/binanceGetPublicKey.d.ts +1 -0
- package/lib/api/binanceGetPublicKey.js +3 -1
- package/lib/api/binanceSignTransaction.d.ts +2 -1
- package/lib/api/binanceSignTransaction.js +3 -1
- package/lib/api/bitcoin/Fees.d.ts +2 -2
- package/lib/api/bitcoin/Fees.js +32 -90
- package/lib/api/bitcoin/TransactionComposer.d.ts +1 -2
- package/lib/api/bitcoin/TransactionComposer.js +3 -2
- package/lib/api/bitcoin/refTx.d.ts +10 -2
- package/lib/api/bitcoin/refTx.js +46 -19
- package/lib/api/blockchainDisconnect.d.ts +1 -0
- package/lib/api/blockchainDisconnect.js +3 -1
- package/lib/api/blockchainEstimateFee.js +1 -1
- package/lib/api/blockchainSetCustomBackend.d.ts +1 -0
- package/lib/api/blockchainSetCustomBackend.js +3 -1
- package/lib/api/cancelCoinjoinAuthorization.d.ts +1 -0
- package/lib/api/cancelCoinjoinAuthorization.js +3 -1
- package/lib/api/cardanoGetAddress.d.ts +1 -0
- package/lib/api/cardanoGetAddress.js +4 -4
- package/lib/api/cardanoGetNativeScriptHash.d.ts +1 -0
- package/lib/api/cardanoGetNativeScriptHash.js +3 -1
- package/lib/api/cardanoGetPublicKey.d.ts +1 -0
- package/lib/api/cardanoGetPublicKey.js +4 -2
- package/lib/api/cardanoSignTransaction.d.ts +1 -0
- package/lib/api/cardanoSignTransaction.js +3 -1
- package/lib/api/checkFirmwareAuthenticity.js +2 -1
- package/lib/api/cipherKeyValue.d.ts +1 -0
- package/lib/api/cipherKeyValue.js +3 -1
- package/lib/api/composeTransaction.d.ts +3 -0
- package/lib/api/composeTransaction.js +9 -7
- package/lib/api/eosGetPublicKey.d.ts +1 -0
- package/lib/api/eosGetPublicKey.js +3 -1
- package/lib/api/eosSignTransaction.d.ts +1 -0
- package/lib/api/eosSignTransaction.js +3 -1
- package/lib/api/ethereum/ethereumDefinitions.d.ts +28 -6
- package/lib/api/ethereum/ethereumDefinitions.js +60 -1
- package/lib/api/ethereum/ethereumSignTx.d.ts +1 -1
- package/lib/api/ethereumGetAddress.d.ts +2 -0
- package/lib/api/ethereumGetAddress.js +28 -26
- package/lib/api/ethereumGetPublicKey.d.ts +1 -0
- package/lib/api/ethereumGetPublicKey.js +8 -10
- package/lib/api/ethereumSignMessage.d.ts +10 -1
- package/lib/api/ethereumSignMessage.js +14 -13
- package/lib/api/ethereumSignTransaction.d.ts +6 -0
- package/lib/api/ethereumSignTransaction.js +18 -5
- package/lib/api/ethereumSignTypedData.d.ts +6 -0
- package/lib/api/ethereumSignTypedData.js +15 -13
- package/lib/api/ethereumVerifyMessage.d.ts +1 -0
- package/lib/api/ethereumVerifyMessage.js +3 -1
- package/lib/api/getAccountInfo.d.ts +1 -0
- package/lib/api/getAccountInfo.js +3 -1
- package/lib/api/getAddress.d.ts +1 -0
- package/lib/api/getAddress.js +8 -10
- package/lib/api/getFeatures.d.ts +1 -1
- package/lib/api/getOwnershipId.d.ts +1 -0
- package/lib/api/getOwnershipId.js +3 -1
- package/lib/api/getOwnershipProof.d.ts +1 -0
- package/lib/api/getOwnershipProof.js +3 -1
- package/lib/api/getPublicKey.d.ts +1 -0
- package/lib/api/getPublicKey.js +4 -2
- package/lib/api/nemGetAddress.d.ts +1 -0
- package/lib/api/nemGetAddress.js +4 -4
- package/lib/api/nemSignTransaction.d.ts +1 -0
- package/lib/api/nemSignTransaction.js +3 -1
- package/lib/api/rebootToBootloader.d.ts +2 -1
- package/lib/api/rebootToBootloader.js +3 -1
- package/lib/api/requestLogin.d.ts +1 -0
- package/lib/api/requestLogin.js +3 -1
- package/lib/api/resetDevice.d.ts +1 -0
- package/lib/api/resetDevice.js +3 -1
- package/lib/api/rippleGetAddress.d.ts +1 -0
- package/lib/api/rippleGetAddress.js +4 -4
- package/lib/api/rippleSignTransaction.d.ts +1 -0
- package/lib/api/rippleSignTransaction.js +3 -1
- package/lib/api/showDeviceTutorial.d.ts +1 -0
- package/lib/api/showDeviceTutorial.js +3 -1
- package/lib/api/signMessage.d.ts +1 -0
- package/lib/api/signMessage.js +5 -1
- package/lib/api/signTransaction.d.ts +1 -0
- package/lib/api/signTransaction.js +16 -4
- package/lib/api/stellarGetAddress.d.ts +1 -0
- package/lib/api/stellarGetAddress.js +4 -4
- package/lib/api/stellarSignTransaction.d.ts +1 -0
- package/lib/api/stellarSignTransaction.js +3 -1
- package/lib/api/tezosGetAddress.d.ts +1 -0
- package/lib/api/tezosGetAddress.js +4 -4
- package/lib/api/tezosGetPublicKey.d.ts +1 -0
- package/lib/api/tezosGetPublicKey.js +3 -1
- package/lib/api/tezosSignTransaction.d.ts +1 -0
- package/lib/api/tezosSignTransaction.js +3 -1
- package/lib/api/verifyMessage.d.ts +1 -0
- package/lib/api/verifyMessage.js +7 -2
- package/lib/api/wipeDevice.d.ts +2 -1
- package/lib/api/wipeDevice.js +3 -1
- package/lib/backend/Blockchain.d.ts +1 -3
- package/lib/backend/Blockchain.js +10 -6
- package/lib/constants/index.d.ts +1 -1
- package/lib/constants/index.js +1 -1
- package/lib/core/AbstractMethod.d.ts +3 -1
- package/lib/core/AbstractMethod.js +3 -1
- package/lib/core/index.js +9 -1
- package/lib/data/DataManager.js +4 -1
- package/lib/data/analyticsInfo.js +1 -1
- package/lib/data/coinInfo.d.ts +9 -0
- package/lib/data/coinInfo.js +10 -41
- package/lib/data/config.js +5 -1
- package/lib/data/defaultFeeLevels.d.ts +17 -0
- package/lib/data/defaultFeeLevels.js +84 -0
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +2 -2
- package/lib/device/Device.js +9 -7
- package/lib/device/DeviceCommands.js +6 -1
- package/lib/events/popup.d.ts +8 -1
- package/lib/events/popup.js +1 -0
- package/lib/events/ui-request.d.ts +2 -2
- package/lib/types/account.d.ts +1 -20
- package/lib/types/api/bitcoin/index.d.ts +2 -0
- package/lib/types/api/blockchainEstimateFee.d.ts +2 -5
- package/lib/types/coinInfo.d.ts +5 -17
- package/lib/types/device.d.ts +5 -2
- package/lib/types/device.js +7 -2
- package/lib/types/fees.d.ts +26 -0
- package/lib/types/fees.js +3 -0
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.js +1 -0
- package/lib/utils/assetUtils.js +3 -1
- package/lib/utils/urlUtils.d.ts +10 -3
- package/lib/utils/urlUtils.js +5 -9
- package/package.json +10 -8
|
@@ -10,7 +10,6 @@ class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
10
10
|
init() {
|
|
11
11
|
this.requiredPermissions = ['read'];
|
|
12
12
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Cardano'), this.firmwareRange);
|
|
13
|
-
this.info = 'Export Cardano public key';
|
|
14
13
|
this.hasBundle = !!this.payload.bundle;
|
|
15
14
|
const payload = !this.payload.bundle
|
|
16
15
|
? { ...this.payload, bundle: [this.payload] }
|
|
@@ -32,6 +31,9 @@ class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
32
31
|
};
|
|
33
32
|
});
|
|
34
33
|
}
|
|
34
|
+
get info() {
|
|
35
|
+
return 'Export Cardano public key';
|
|
36
|
+
}
|
|
35
37
|
async confirmation() {
|
|
36
38
|
if (this.confirmed)
|
|
37
39
|
return true;
|
|
@@ -56,7 +58,7 @@ class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
56
58
|
await this.getPopupPromise().promise;
|
|
57
59
|
const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
|
|
58
60
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
|
|
59
|
-
view: '
|
|
61
|
+
view: 'no-backup',
|
|
60
62
|
}));
|
|
61
63
|
const uiResp = await uiPromise.promise;
|
|
62
64
|
return uiResp.payload;
|
|
@@ -44,6 +44,7 @@ export type CardanoSignTransactionParams = {
|
|
|
44
44
|
};
|
|
45
45
|
export default class CardanoSignTransaction extends AbstractMethod<'cardanoSignTransaction', CardanoSignTransactionParams> {
|
|
46
46
|
init(): void;
|
|
47
|
+
get info(): string;
|
|
47
48
|
_isFeatureSupported(feature: keyof typeof CardanoSignTransactionFeatures): boolean;
|
|
48
49
|
_ensureFeatureIsSupported(feature: keyof typeof CardanoSignTransactionFeatures): void;
|
|
49
50
|
_ensureFirmwareSupportsParams(): void;
|
|
@@ -28,7 +28,6 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
28
28
|
init() {
|
|
29
29
|
this.requiredPermissions = ['read', 'write'];
|
|
30
30
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Cardano'), this.firmwareRange);
|
|
31
|
-
this.info = 'Sign Cardano transaction';
|
|
32
31
|
const { payload } = this;
|
|
33
32
|
if (payload.metadata) {
|
|
34
33
|
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Metadata field has been replaced by auxiliaryData.');
|
|
@@ -151,6 +150,9 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
151
150
|
includeNetworkId: payload.includeNetworkId,
|
|
152
151
|
};
|
|
153
152
|
}
|
|
153
|
+
get info() {
|
|
154
|
+
return 'Sign Cardano transaction';
|
|
155
|
+
}
|
|
154
156
|
_isFeatureSupported(feature) {
|
|
155
157
|
return this.device.atLeast(CardanoSignTransactionFeatures[feature]);
|
|
156
158
|
}
|
|
@@ -7,6 +7,7 @@ const firmware_1 = require("./firmware");
|
|
|
7
7
|
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const assets_1 = require("../utils/assets");
|
|
10
|
+
const types_1 = require("../types");
|
|
10
11
|
class CheckFirmwareAuthenticity extends AbstractMethod_1.AbstractMethod {
|
|
11
12
|
init() {
|
|
12
13
|
this.useEmptyPassphrase = true;
|
|
@@ -22,7 +23,7 @@ class CheckFirmwareAuthenticity extends AbstractMethod_1.AbstractMethod {
|
|
|
22
23
|
throw constants_1.ERRORS.TypedError('Runtime', 'checkFirmwareAuthenticity: No release found for device firmware');
|
|
23
24
|
}
|
|
24
25
|
const baseUrl = `https://data.trezor.io/firmware/${device.features.major_version}`;
|
|
25
|
-
const fwUrl = `${baseUrl}/trezor-${deviceVersion}${device.firmwareType ===
|
|
26
|
+
const fwUrl = `${baseUrl}/trezor-${deviceVersion}${device.firmwareType === types_1.FirmwareType.BitcoinOnly ? '-bitcoinonly.bin' : '.bin'}`;
|
|
26
27
|
const fw = await (0, assets_1.httpRequest)(fwUrl, 'binary');
|
|
27
28
|
if (!fw) {
|
|
28
29
|
throw constants_1.ERRORS.TypedError('Runtime', 'checkFirmwareAuthenticity: firmware binary not found');
|
|
@@ -3,6 +3,7 @@ import type { PROTO } from '../constants';
|
|
|
3
3
|
export default class CipherKeyValue extends AbstractMethod<'cipherKeyValue', PROTO.CipherKeyValue[]> {
|
|
4
4
|
hasBundle?: boolean;
|
|
5
5
|
init(): void;
|
|
6
|
+
get info(): string;
|
|
6
7
|
run(): Promise<PROTO.CipheredKeyValue | PROTO.CipheredKeyValue[]>;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=cipherKeyValue.d.ts.map
|
|
@@ -8,7 +8,6 @@ class CipherKeyValue extends AbstractMethod_1.AbstractMethod {
|
|
|
8
8
|
init() {
|
|
9
9
|
this.requiredPermissions = ['read', 'write'];
|
|
10
10
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
|
|
11
|
-
this.info = 'Cipher key value';
|
|
12
11
|
this.hasBundle = !!this.payload.bundle;
|
|
13
12
|
const payload = !this.payload.bundle
|
|
14
13
|
? { ...this.payload, bundle: [this.payload] }
|
|
@@ -37,6 +36,9 @@ class CipherKeyValue extends AbstractMethod_1.AbstractMethod {
|
|
|
37
36
|
};
|
|
38
37
|
});
|
|
39
38
|
}
|
|
39
|
+
get info() {
|
|
40
|
+
return 'Cipher key value';
|
|
41
|
+
}
|
|
40
42
|
async run() {
|
|
41
43
|
const responses = [];
|
|
42
44
|
const cmd = this.device.getCommands();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
1
2
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
3
|
import { Discovery } from './common/Discovery';
|
|
3
4
|
import { TransactionComposer } from './bitcoin';
|
|
@@ -14,10 +15,12 @@ type Params = {
|
|
|
14
15
|
floorBaseFee?: PrecomposeParams['floorBaseFee'];
|
|
15
16
|
sequence?: PrecomposeParams['sequence'];
|
|
16
17
|
skipPermutation?: PrecomposeParams['skipPermutation'];
|
|
18
|
+
total: BigNumber;
|
|
17
19
|
};
|
|
18
20
|
export default class ComposeTransaction extends AbstractMethod<'composeTransaction', Params> {
|
|
19
21
|
discovery?: Discovery;
|
|
20
22
|
init(): void;
|
|
23
|
+
get info(): string;
|
|
21
24
|
precompose(account: PrecomposeParams['account'], feeLevels: PrecomposeParams['feeLevels']): Promise<PrecomposedTransaction[]>;
|
|
22
25
|
run(): Promise<SignedTransaction | PrecomposedTransaction[]>;
|
|
23
26
|
selectAccount(): Promise<{
|
|
@@ -43,13 +43,6 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
43
43
|
}
|
|
44
44
|
outputs.push(output);
|
|
45
45
|
});
|
|
46
|
-
const sendMax = outputs.find(o => o.type === 'send-max') !== undefined;
|
|
47
|
-
if (sendMax) {
|
|
48
|
-
this.info = 'Send maximum amount';
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
this.info = `Send ${(0, formatUtils_1.formatAmount)(total.toString(), coinInfo)}`;
|
|
52
|
-
}
|
|
53
46
|
this.useDevice = !payload.account && !payload.feeLevels;
|
|
54
47
|
this.useUi = this.useDevice;
|
|
55
48
|
this.params = {
|
|
@@ -62,8 +55,17 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
62
55
|
sequence: payload.sequence,
|
|
63
56
|
skipPermutation: payload.skipPermutation,
|
|
64
57
|
push: typeof payload.push === 'boolean' ? payload.push : false,
|
|
58
|
+
total,
|
|
65
59
|
};
|
|
66
60
|
}
|
|
61
|
+
get info() {
|
|
62
|
+
var _a;
|
|
63
|
+
const sendMax = ((_a = this.params) === null || _a === void 0 ? void 0 : _a.outputs.find(o => o.type === 'send-max')) !== undefined;
|
|
64
|
+
if (sendMax) {
|
|
65
|
+
return 'Send maximum amount';
|
|
66
|
+
}
|
|
67
|
+
return `Send ${(0, formatUtils_1.formatAmount)(this.params.total.toString(), this.params.coinInfo)}`;
|
|
68
|
+
}
|
|
67
69
|
async precompose(account, feeLevels) {
|
|
68
70
|
const { coinInfo, outputs, baseFee, skipPermutation } = this.params;
|
|
69
71
|
const address_n = pathUtils.validatePath(account.path);
|
|
@@ -4,6 +4,7 @@ export default class EosGetPublicKey extends AbstractMethod<'eosGetPublicKey', P
|
|
|
4
4
|
hasBundle?: boolean;
|
|
5
5
|
confirmed?: boolean;
|
|
6
6
|
init(): void;
|
|
7
|
+
get info(): string;
|
|
7
8
|
confirmation(): Promise<boolean>;
|
|
8
9
|
run(): Promise<import("..").EosPublicKey | import("..").EosPublicKey[]>;
|
|
9
10
|
}
|
|
@@ -9,7 +9,6 @@ class EosGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
9
9
|
init() {
|
|
10
10
|
this.requiredPermissions = ['read'];
|
|
11
11
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('EOS'), this.firmwareRange);
|
|
12
|
-
this.info = 'Export Eos public key';
|
|
13
12
|
this.hasBundle = !!this.payload.bundle;
|
|
14
13
|
const payload = !this.payload.bundle
|
|
15
14
|
? { ...this.payload, bundle: [this.payload] }
|
|
@@ -27,6 +26,9 @@ class EosGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
27
26
|
};
|
|
28
27
|
});
|
|
29
28
|
}
|
|
29
|
+
get info() {
|
|
30
|
+
return 'Export Eos public key';
|
|
31
|
+
}
|
|
30
32
|
async confirmation() {
|
|
31
33
|
if (this.confirmed)
|
|
32
34
|
return true;
|
|
@@ -10,7 +10,6 @@ class EosSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
10
10
|
init() {
|
|
11
11
|
this.requiredPermissions = ['read', 'write'];
|
|
12
12
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('EOS'), this.firmwareRange);
|
|
13
|
-
this.info = 'Sign EOS transaction';
|
|
14
13
|
const { payload } = this;
|
|
15
14
|
(0, paramsValidator_1.validateParams)(payload, [
|
|
16
15
|
{ name: 'path', required: true },
|
|
@@ -25,6 +24,9 @@ class EosSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
25
24
|
ack,
|
|
26
25
|
};
|
|
27
26
|
}
|
|
27
|
+
get info() {
|
|
28
|
+
return 'Sign EOS transaction';
|
|
29
|
+
}
|
|
28
30
|
async run() {
|
|
29
31
|
const response = await helper.signTx(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, this.params.chain_id, this.params.header, this.params.ack);
|
|
30
32
|
return {
|
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
import { EthereumDefinitions } from '@trezor/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
2
|
+
import { EthereumNetworkInfo } from '../../types';
|
|
3
|
+
interface GetEthereumDefinitions {
|
|
4
|
+
chainId?: number;
|
|
5
|
+
slip44?: number;
|
|
6
|
+
contractAddress?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const getEthereumDefinitions: ({ chainId, slip44, contractAddress, }: GetEthereumDefinitions) => Promise<EthereumDefinitions>;
|
|
9
|
+
export interface EthereumNetworkDefinitionDecoded {
|
|
10
|
+
chain_id: number;
|
|
11
|
+
name: string;
|
|
12
|
+
slip44: number;
|
|
13
|
+
symbol: string;
|
|
14
|
+
}
|
|
15
|
+
export interface EthereumTokenDefinitionDecoded {
|
|
16
|
+
address: string;
|
|
17
|
+
chain_id: number;
|
|
18
|
+
decimals: number;
|
|
19
|
+
name: string;
|
|
20
|
+
symbol: string;
|
|
21
|
+
}
|
|
22
|
+
export interface EthereumDefinitionDecoded {
|
|
23
|
+
network?: EthereumNetworkDefinitionDecoded;
|
|
24
|
+
token?: EthereumTokenDefinitionDecoded;
|
|
25
|
+
}
|
|
26
|
+
export declare const decodeEthereumDefinition: (encodedDefinition: EthereumDefinitions) => EthereumDefinitionDecoded;
|
|
27
|
+
export declare const ethereumNetworkInfoFromDefinition: (definition: EthereumNetworkDefinitionDecoded) => EthereumNetworkInfo;
|
|
28
|
+
export {};
|
|
7
29
|
//# sourceMappingURL=ethereumDefinitions.d.ts.map
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEthereumDefinitions = void 0;
|
|
3
|
+
exports.ethereumNetworkInfoFromDefinition = exports.decodeEthereumDefinition = exports.getEthereumDefinitions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch"));
|
|
6
|
+
const protocol_1 = require("@trezor/protocol");
|
|
7
|
+
const protobuf_1 = require("@trezor/protobuf");
|
|
8
|
+
const DataManager_1 = require("../../data/DataManager");
|
|
9
|
+
const paramsValidator_1 = require("../common/paramsValidator");
|
|
10
|
+
const coinInfo_1 = require("../../data/coinInfo");
|
|
6
11
|
const getEthereumDefinitions = async ({ chainId, slip44, contractAddress, }) => {
|
|
7
12
|
const definitions = {};
|
|
8
13
|
if (!chainId && !slip44) {
|
|
@@ -40,4 +45,58 @@ const getEthereumDefinitions = async ({ chainId, slip44, contractAddress, }) =>
|
|
|
40
45
|
return definitions;
|
|
41
46
|
};
|
|
42
47
|
exports.getEthereumDefinitions = getEthereumDefinitions;
|
|
48
|
+
const decodeEthereumDefinition = (encodedDefinition) => {
|
|
49
|
+
const decoded = {
|
|
50
|
+
network: undefined,
|
|
51
|
+
token: undefined,
|
|
52
|
+
};
|
|
53
|
+
['encoded_token', 'encoded_network'].forEach(key => {
|
|
54
|
+
const encodedPayload = encodedDefinition[key];
|
|
55
|
+
if (!encodedPayload) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const { definitionType, protobufPayload } = protocol_1.trzd.decode(encodedPayload);
|
|
59
|
+
const messages = DataManager_1.DataManager.getProtobufMessages();
|
|
60
|
+
const proto = (0, protobuf_1.parseConfigure)(messages);
|
|
61
|
+
const type = definitionType === 0 ? 'EthereumNetworkInfo' : 'EthereumTokenInfo';
|
|
62
|
+
const Message = proto.lookupType(type);
|
|
63
|
+
const decodedDefinition = (0, protobuf_1.decode)(Message, protobufPayload);
|
|
64
|
+
if (key === 'encoded_network') {
|
|
65
|
+
(0, paramsValidator_1.validateParams)(decodedDefinition, [
|
|
66
|
+
{ name: 'chain_id', type: 'number', required: true },
|
|
67
|
+
{ name: 'name', type: 'string', required: true },
|
|
68
|
+
{ name: 'slip44', type: 'number', required: true },
|
|
69
|
+
{ name: 'symbol', type: 'string', required: true },
|
|
70
|
+
]);
|
|
71
|
+
decoded.network = decodedDefinition;
|
|
72
|
+
}
|
|
73
|
+
else if (key === 'encoded_token') {
|
|
74
|
+
(0, paramsValidator_1.validateParams)(decodedDefinition, [
|
|
75
|
+
{ name: 'address', type: 'string', required: true },
|
|
76
|
+
{ name: 'chain_id', type: 'number', required: true },
|
|
77
|
+
{ name: 'name', type: 'string', required: true },
|
|
78
|
+
{ name: 'decimals', type: 'number', required: true },
|
|
79
|
+
{ name: 'symbol', type: 'string', required: true },
|
|
80
|
+
]);
|
|
81
|
+
decoded.token = decodedDefinition;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return decoded;
|
|
85
|
+
};
|
|
86
|
+
exports.decodeEthereumDefinition = decodeEthereumDefinition;
|
|
87
|
+
const ethereumNetworkInfoFromDefinition = (definition) => ({
|
|
88
|
+
...coinInfo_1.ethereumNetworkInfoBase,
|
|
89
|
+
chainId: definition.chain_id,
|
|
90
|
+
label: definition.name,
|
|
91
|
+
name: definition.name,
|
|
92
|
+
slip44: definition.slip44,
|
|
93
|
+
shortcut: definition.symbol,
|
|
94
|
+
support: {
|
|
95
|
+
connect: true,
|
|
96
|
+
trezor1: '1.6.2',
|
|
97
|
+
trezor2: '2.0.7',
|
|
98
|
+
},
|
|
99
|
+
blockchainLink: undefined,
|
|
100
|
+
});
|
|
101
|
+
exports.ethereumNetworkInfoFromDefinition = ethereumNetworkInfoFromDefinition;
|
|
43
102
|
//# sourceMappingURL=ethereumDefinitions.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthereumDefinitions } from '@trezor/
|
|
1
|
+
import { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
2
2
|
import type { TypedCall } from '../../device/DeviceCommands';
|
|
3
3
|
import type { EthereumAccessList } from '../../types/api/ethereum';
|
|
4
4
|
export declare const ethereumSignTx: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, gas_price: string, nonce: string, chain_id: number, data?: string, tx_type?: number, definitions?: EthereumDefinitions) => Promise<{
|
|
@@ -11,6 +11,8 @@ export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddre
|
|
|
11
11
|
progress: number;
|
|
12
12
|
confirmed?: boolean;
|
|
13
13
|
init(): void;
|
|
14
|
+
initAsync(): Promise<void>;
|
|
15
|
+
get info(): string;
|
|
14
16
|
getButtonRequestData(code: string): {
|
|
15
17
|
type: "address";
|
|
16
18
|
serializedPath: string;
|
|
@@ -40,19 +40,6 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
40
40
|
network,
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
|
-
if (this.params.length === 1) {
|
|
44
|
-
this.info = (0, ethereumUtils_1.getNetworkLabel)('Export #NETWORK address', this.params[0].network);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const requestedNetworks = this.params.map(b => b.network);
|
|
48
|
-
const uniqNetworks = (0, coinInfo_1.getUniqueNetworks)(requestedNetworks);
|
|
49
|
-
if (uniqNetworks.length === 1 && uniqNetworks[0]) {
|
|
50
|
-
this.info = (0, ethereumUtils_1.getNetworkLabel)('Export multiple #NETWORK addresses', uniqNetworks[0]);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
this.info = 'Export multiple addresses';
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
43
|
const useEventListener = payload.useEventListener &&
|
|
57
44
|
this.params.length === 1 &&
|
|
58
45
|
typeof this.params[0].address === 'string' &&
|
|
@@ -60,6 +47,34 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
60
47
|
this.confirmed = useEventListener;
|
|
61
48
|
this.useUi = !useEventListener;
|
|
62
49
|
}
|
|
50
|
+
async initAsync() {
|
|
51
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
52
|
+
if (!this.params[i].network) {
|
|
53
|
+
const slip44 = (0, pathUtils_1.getSlip44ByPath)(this.params[i].address_n);
|
|
54
|
+
const definitions = await (0, ethereumDefinitions_1.getEthereumDefinitions)({
|
|
55
|
+
slip44,
|
|
56
|
+
});
|
|
57
|
+
const decoded = (0, ethereumDefinitions_1.decodeEthereumDefinition)(definitions);
|
|
58
|
+
if (decoded.network) {
|
|
59
|
+
this.params[i].network = (0, ethereumDefinitions_1.ethereumNetworkInfoFromDefinition)(decoded.network);
|
|
60
|
+
}
|
|
61
|
+
if (definitions.encoded_network) {
|
|
62
|
+
this.params[i].encoded_network = definitions.encoded_network;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
get info() {
|
|
68
|
+
if (this.params.length === 1) {
|
|
69
|
+
return (0, ethereumUtils_1.getNetworkLabel)('Export #NETWORK address', this.params[0].network);
|
|
70
|
+
}
|
|
71
|
+
const requestedNetworks = this.params.map(b => b.network);
|
|
72
|
+
const uniqNetworks = (0, coinInfo_1.getUniqueNetworks)(requestedNetworks);
|
|
73
|
+
if (uniqNetworks.length === 1 && uniqNetworks[0]) {
|
|
74
|
+
return (0, ethereumUtils_1.getNetworkLabel)('Export multiple #NETWORK addresses', uniqNetworks[0]);
|
|
75
|
+
}
|
|
76
|
+
return 'Export multiple addresses';
|
|
77
|
+
}
|
|
63
78
|
getButtonRequestData(code) {
|
|
64
79
|
if (code === 'ButtonRequest_Address') {
|
|
65
80
|
return {
|
|
@@ -100,24 +115,12 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
100
115
|
});
|
|
101
116
|
}
|
|
102
117
|
async run() {
|
|
103
|
-
var _a;
|
|
104
118
|
const responses = [];
|
|
105
119
|
for (let i = 0; i < this.params.length; i++) {
|
|
106
120
|
const batch = this.params[i];
|
|
107
|
-
const slip44 = (0, pathUtils_1.getSlip44ByPath)(batch.address_n);
|
|
108
|
-
const definitions = await (0, ethereumDefinitions_1.getEthereumDefinitions)({
|
|
109
|
-
chainId: (_a = batch === null || batch === void 0 ? void 0 : batch.network) === null || _a === void 0 ? void 0 : _a.chainId,
|
|
110
|
-
slip44,
|
|
111
|
-
});
|
|
112
|
-
const definitionParams = {
|
|
113
|
-
...(definitions.encoded_network && {
|
|
114
|
-
encoded_network: definitions.encoded_network,
|
|
115
|
-
}),
|
|
116
|
-
};
|
|
117
121
|
if (batch.show_display) {
|
|
118
122
|
const silent = await this._call({
|
|
119
123
|
...batch,
|
|
120
|
-
...definitionParams,
|
|
121
124
|
show_display: false,
|
|
122
125
|
});
|
|
123
126
|
if (typeof batch.address === 'string') {
|
|
@@ -132,7 +135,6 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
132
135
|
}
|
|
133
136
|
const response = await this._call({
|
|
134
137
|
...batch,
|
|
135
|
-
...definitionParams,
|
|
136
138
|
});
|
|
137
139
|
responses.push(response);
|
|
138
140
|
if (this.hasBundle) {
|
|
@@ -8,6 +8,7 @@ export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPub
|
|
|
8
8
|
hasBundle?: boolean;
|
|
9
9
|
confirmed?: boolean;
|
|
10
10
|
init(): void;
|
|
11
|
+
get info(): string;
|
|
11
12
|
confirmation(): Promise<boolean>;
|
|
12
13
|
run(): Promise<import("../types/api/getPublicKey").HDNodeResponse | import("../types/api/getPublicKey").HDNodeResponse[]>;
|
|
13
14
|
}
|
|
@@ -28,19 +28,17 @@ class EthereumGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
28
28
|
network,
|
|
29
29
|
};
|
|
30
30
|
});
|
|
31
|
+
}
|
|
32
|
+
get info() {
|
|
31
33
|
if (this.params.length === 1) {
|
|
32
|
-
|
|
34
|
+
return (0, ethereumUtils_1.getNetworkLabel)('Export #NETWORK public key', this.params[0].network);
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.info = (0, ethereumUtils_1.getNetworkLabel)('Export multiple #NETWORK public keys', uniqNetworks[0]);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
this.info = 'Export multiple public keys';
|
|
42
|
-
}
|
|
36
|
+
const requestedNetworks = this.params.map(b => b.network);
|
|
37
|
+
const uniqNetworks = (0, coinInfo_1.getUniqueNetworks)(requestedNetworks);
|
|
38
|
+
if (uniqNetworks.length === 1 && uniqNetworks[0]) {
|
|
39
|
+
return (0, ethereumUtils_1.getNetworkLabel)('Export multiple #NETWORK public keys', uniqNetworks[0]);
|
|
43
40
|
}
|
|
41
|
+
return 'Export multiple public keys';
|
|
44
42
|
}
|
|
45
43
|
async confirmation() {
|
|
46
44
|
if (this.confirmed)
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import type { PROTO } from '../constants';
|
|
3
|
-
|
|
3
|
+
import type { EthereumNetworkInfo } from '../types';
|
|
4
|
+
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
5
|
+
type Params = PROTO.EthereumSignMessage & {
|
|
6
|
+
network?: EthereumNetworkInfo;
|
|
7
|
+
definitions?: EthereumDefinitions;
|
|
8
|
+
};
|
|
9
|
+
export default class EthereumSignMessage extends AbstractMethod<'ethereumSignMessage', Params> {
|
|
4
10
|
init(): void;
|
|
11
|
+
initAsync(): Promise<void>;
|
|
12
|
+
get info(): string;
|
|
5
13
|
run(): Promise<PROTO.EthereumMessageSignature>;
|
|
6
14
|
}
|
|
15
|
+
export {};
|
|
7
16
|
//# sourceMappingURL=ethereumSignMessage.d.ts.map
|
|
@@ -19,7 +19,6 @@ class EthereumSignMessage extends AbstractMethod_1.AbstractMethod {
|
|
|
19
19
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
20
20
|
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
21
21
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, network, this.firmwareRange);
|
|
22
|
-
this.info = (0, ethereumUtils_1.getNetworkLabel)('Sign #NETWORK message', network);
|
|
23
22
|
const messageHex = payload.hex
|
|
24
23
|
? (0, formatUtils_1.messageToHex)(payload.message)
|
|
25
24
|
: Buffer.from(payload.message, 'utf8').toString('hex');
|
|
@@ -28,22 +27,24 @@ class EthereumSignMessage extends AbstractMethod_1.AbstractMethod {
|
|
|
28
27
|
message: messageHex,
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
|
-
async
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
30
|
+
async initAsync() {
|
|
31
|
+
if (this.params.network)
|
|
32
|
+
return;
|
|
33
|
+
const { address_n } = this.params;
|
|
35
34
|
const slip44 = (0, pathUtils_1.getSlip44ByPath)(address_n);
|
|
36
|
-
|
|
37
|
-
chainId: network === null || network === void 0 ? void 0 : network.chainId,
|
|
35
|
+
this.params.definitions = await (0, ethereumDefinitions_1.getEthereumDefinitions)({
|
|
38
36
|
slip44,
|
|
39
37
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
}
|
|
39
|
+
get info() {
|
|
40
|
+
return (0, ethereumUtils_1.getNetworkLabel)('Sign #NETWORK message', (0, coinInfo_1.getEthereumNetwork)(this.params.address_n));
|
|
41
|
+
}
|
|
42
|
+
async run() {
|
|
43
|
+
var _a;
|
|
44
|
+
const cmd = this.device.getCommands();
|
|
45
|
+
const { address_n, message } = this.params;
|
|
45
46
|
const response = await cmd.typedCall('EthereumSignMessage', 'EthereumMessageSignature', {
|
|
46
|
-
|
|
47
|
+
encoded_network: (_a = this.params.definitions) === null || _a === void 0 ? void 0 : _a.encoded_network,
|
|
47
48
|
address_n,
|
|
48
49
|
message,
|
|
49
50
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import type { EthereumTransaction, EthereumTransactionEIP1559 } from '../types/api/ethereum';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../types';
|
|
4
|
+
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
3
5
|
type Params = {
|
|
4
6
|
path: number[];
|
|
5
7
|
tx: ({
|
|
@@ -7,9 +9,13 @@ type Params = {
|
|
|
7
9
|
} & EthereumTransaction) | ({
|
|
8
10
|
type: 'eip1559';
|
|
9
11
|
} & EthereumTransactionEIP1559);
|
|
12
|
+
network?: EthereumNetworkInfo;
|
|
13
|
+
definitions?: EthereumDefinitions;
|
|
10
14
|
};
|
|
11
15
|
export default class EthereumSignTransaction extends AbstractMethod<'ethereumSignTransaction', Params> {
|
|
12
16
|
init(): void;
|
|
17
|
+
initAsync(): Promise<void>;
|
|
18
|
+
get info(): string;
|
|
13
19
|
run(): Promise<{
|
|
14
20
|
v: string;
|
|
15
21
|
r: string;
|
|
@@ -35,7 +35,6 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
35
35
|
]);
|
|
36
36
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
37
37
|
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
38
|
-
this.info = (0, ethereumUtils_1.getNetworkLabel)('Sign #NETWORK transaction', network);
|
|
39
38
|
const tx = payload.transaction;
|
|
40
39
|
const isEIP1559 = tx.maxFeePerGas && tx.maxPriorityFeePerGas;
|
|
41
40
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(isEIP1559 ? 'eip1559' : this.name, network, this.firmwareRange);
|
|
@@ -70,16 +69,30 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
70
69
|
type: isEIP1559 ? 'eip1559' : 'legacy',
|
|
71
70
|
...strip(tx),
|
|
72
71
|
},
|
|
72
|
+
network,
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
async
|
|
76
|
-
|
|
75
|
+
async initAsync() {
|
|
76
|
+
if (this.params.tx.chainId === 1 && !this.params.tx.data) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
77
79
|
const slip44 = (0, pathUtils_1.getSlip44ByPath)(this.params.path);
|
|
78
80
|
const definitions = await (0, ethereumDefinitions_1.getEthereumDefinitions)({
|
|
79
|
-
chainId: tx.chainId,
|
|
81
|
+
chainId: this.params.tx.chainId,
|
|
80
82
|
slip44,
|
|
81
|
-
contractAddress: tx.data ? tx.to : undefined,
|
|
83
|
+
contractAddress: this.params.tx.data ? this.params.tx.to : undefined,
|
|
82
84
|
});
|
|
85
|
+
this.params.definitions = definitions;
|
|
86
|
+
const decoded = (0, ethereumDefinitions_1.decodeEthereumDefinition)(definitions);
|
|
87
|
+
if (decoded.network) {
|
|
88
|
+
this.params.network = (0, ethereumDefinitions_1.ethereumNetworkInfoFromDefinition)(decoded.network);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
get info() {
|
|
92
|
+
return (0, ethereumUtils_1.getNetworkLabel)('Sign #NETWORK transaction', this.params.network);
|
|
93
|
+
}
|
|
94
|
+
run() {
|
|
95
|
+
const { tx, definitions } = this.params;
|
|
83
96
|
return tx.type === 'eip1559'
|
|
84
97
|
? helper.ethereumSignTxEIP1559(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, tx.to, tx.value, tx.gasLimit, tx.maxFeePerGas, tx.maxPriorityFeePerGas, tx.nonce, tx.chainId, tx.data, tx.accessList, definitions)
|
|
85
98
|
: helper.ethereumSignTx(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, tx.to, tx.value, tx.gasLimit, tx.gasPrice, tx.nonce, tx.chainId, tx.data, tx.txType, definitions);
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import type { EthereumSignTypedDataTypes, EthereumSignTypedData as EthereumSignTypedDataParams, EthereumSignTypedHash as EthereumSignTypedHashParams } from '../types/api/ethereum';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../types';
|
|
4
|
+
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
3
5
|
type Params = (Omit<EthereumSignTypedDataParams<EthereumSignTypedDataTypes>, 'path'> | Omit<EthereumSignTypedHashParams<EthereumSignTypedDataTypes>, 'path'>) & {
|
|
4
6
|
address_n: number[];
|
|
7
|
+
network?: EthereumNetworkInfo;
|
|
8
|
+
definitions?: EthereumDefinitions;
|
|
5
9
|
};
|
|
6
10
|
export default class EthereumSignTypedData extends AbstractMethod<'ethereumSignTypedData', Params> {
|
|
7
11
|
init(): void;
|
|
12
|
+
initAsync(): Promise<void>;
|
|
13
|
+
get info(): string;
|
|
8
14
|
run(): Promise<{
|
|
9
15
|
address: string;
|
|
10
16
|
signature: string;
|