@trezor/connect 9.6.0 → 9.6.1-beta.2
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 +37 -8
- package/README.md +1 -1
- package/lib/api/blockchainEstimateFee.js +1 -0
- package/lib/api/discoverAccounts.js +10 -2
- package/lib/api/eos/eosSignTx.d.ts +3 -3
- package/lib/api/ethereum/api/ethereumSignMessage.js +1 -1
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +1 -1
- package/lib/api/firmware/getBinary.js +2 -2
- package/lib/api/getAddress.d.ts +1 -0
- package/lib/api/getAddress.js +1 -0
- package/lib/api/getCoinInfo.d.ts +3 -3
- package/lib/api/getNonce.d.ts +9 -0
- package/lib/api/getNonce.js +15 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +4 -2
- package/lib/api/nem/nemSignTx.d.ts +1 -1
- package/lib/api/resetDevice.d.ts +2 -3
- package/lib/api/resetDevice.js +47 -49
- package/lib/api/signMessage.js +1 -1
- package/lib/api/signTransaction.js +6 -1
- package/lib/backend/Blockchain.d.ts +1 -0
- package/lib/backend/fees/BitcoinFeeLevels.d.ts +2 -4
- package/lib/backend/fees/BitcoinFeeLevels.js +11 -73
- package/lib/backend/fees/EthereumFeeLevels.d.ts +1 -3
- package/lib/backend/fees/EthereumFeeLevels.js +8 -5
- package/lib/backend/fees/MiscFeeLevels.d.ts +0 -3
- package/lib/backend/fees/MiscFeeLevels.js +2 -2
- package/lib/constants/errors.d.ts +1 -0
- package/lib/constants/errors.js +1 -0
- package/lib/core/AbstractMethod.d.ts +1 -1
- package/lib/core/index.js +43 -53
- package/lib/core/onCallFirmwareUpdate.js +2 -2
- package/lib/data/coinInfo.d.ts +11 -11
- package/lib/data/coinInfo.js +1 -1
- package/lib/data/connectSettings.js +0 -3
- package/lib/data/defaultFeeLevels.d.ts +3 -1
- package/lib/data/defaultFeeLevels.js +22 -12
- package/lib/data/deviceAuthenticityConfig.js +4 -1
- package/lib/data/firmwareInfo.d.ts +1 -0
- package/lib/data/firmwareInfo.js +14 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +20 -21
- package/lib/device/Device.js +78 -123
- package/lib/device/DeviceCurrentSession.d.ts +441 -4027
- package/lib/device/DeviceCurrentSession.js +75 -44
- package/lib/device/DeviceList.d.ts +3 -8
- package/lib/device/DeviceList.js +21 -77
- package/lib/device/TransportManager.d.ts +2 -6
- package/lib/device/TransportManager.js +11 -7
- package/lib/device/checkFirmwareRevision.js +2 -2
- package/lib/device/workflow/index.d.ts +2 -0
- package/lib/device/workflow/index.js +6 -0
- package/lib/device/workflow/validateState.d.ts +3 -0
- package/lib/device/workflow/validateState.js +97 -0
- package/lib/events/device.d.ts +19 -1
- package/lib/events/device.js +2 -0
- package/lib/events/index.d.ts +4 -0
- package/lib/events/ui-request.d.ts +24 -3
- package/lib/events/ui-request.js +3 -0
- package/lib/events/ui-response.d.ts +11 -1
- package/lib/events/ui-response.js +1 -0
- package/lib/factory.js +1 -0
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/lib/types/api/applySettings.d.ts +1 -0
- package/lib/types/api/discoverAccounts.d.ts +17 -4
- package/lib/types/api/discoverAccounts.js +2 -0
- package/lib/types/api/getNonce.d.ts +4 -0
- package/lib/types/api/getNonce.js +3 -0
- package/lib/types/api/index.d.ts +2 -0
- package/lib/types/coinInfo.d.ts +6 -6
- package/lib/types/coinInfo.js +2 -0
- package/lib/types/device.d.ts +3 -4
- package/lib/types/fees.d.ts +1 -1
- package/lib/types/fees.js +1 -1
- package/lib/types/params.d.ts +1 -0
- package/lib/types/settings.d.ts +0 -1
- package/lib/types/workflow.d.ts +8 -0
- package/lib/types/workflow.js +3 -0
- package/lib/utils/formatUtils.d.ts +1 -0
- package/lib/utils/formatUtils.js +9 -1
- package/lib/utils/uiPromiseManager.d.ts +2 -0
- package/package.json +17 -17
- package/lib/data/downloadReleasesMetadata.d.ts +0 -7
- package/lib/data/downloadReleasesMetadata.js +0 -18
- package/lib/data/models.d.ts +0 -8
- package/lib/data/models.js +0 -49
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,49 @@
|
|
|
1
1
|
| Package | Stable | Canary |
|
|
2
2
|
| :------------------------------: | :----: | :----------: |
|
|
3
|
-
| npm @trezor/connect | 9.6.0 |
|
|
4
|
-
| npm @trezor/connect-web | 9.6.0 |
|
|
5
|
-
| npm @trezor/connect-webextension | 9.6.0 |
|
|
6
|
-
| npm @trezor/connect-mobile |
|
|
3
|
+
| npm @trezor/connect | 9.6.0 | 9.6.1-beta.2 |
|
|
4
|
+
| npm @trezor/connect-web | 9.6.0 | 9.6.1-beta.2 |
|
|
5
|
+
| npm @trezor/connect-webextension | 9.6.0 | 9.6.1-beta.2 |
|
|
6
|
+
| npm @trezor/connect-mobile | 9.6.0 | 9.6.1-beta.2 |
|
|
7
7
|
|
|
8
|
-
| Deployment | Stable |
|
|
9
|
-
| :----------------: | :----: |
|
|
10
|
-
| connect.trezor.io/ | 9.6.0 |
|
|
8
|
+
| Deployment | Stable | Canary |
|
|
9
|
+
| :----------------: | :----: | :----------: |
|
|
10
|
+
| connect.trezor.io/ | 9.6.0 | 9.6.1-beta.2 |
|
|
11
11
|
|
|
12
12
|
Use the persistent link [connect.trezor.io/9](https://connect.trezor.io/9/) to access the latest stable version of Connect Explorer.
|
|
13
13
|
|
|
14
|
+
# 9.6.1-beta.2
|
|
15
|
+
|
|
16
|
+
Minor improvements and fixes regarding the [New Connect flow in Trezor Suite](https://connect.trezor.io/9/guides/new-connect-flow-in-trezor-suite/).
|
|
17
|
+
|
|
18
|
+
## Fixes
|
|
19
|
+
|
|
20
|
+
- Webusb sync between tabs in browser fixed in connect-popup (dd50a1a, f558513, cdd73c5)
|
|
21
|
+
- fix(connect-web): empty settings in init in suite-desktop mode (3f61be1)
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- Works on the new communication protocol continue:
|
|
26
|
+
- feat(connect): add ThpState and ThpMessageResponse to DeviceCurrentSession (5919fe9)
|
|
27
|
+
- feat(connect): add UI response for THP pairing tag (6084994)
|
|
28
|
+
- feat(connect): add getNonce (72a1417)
|
|
29
|
+
- feat(connect): decode hex in message signing (2f41cc6)
|
|
30
|
+
- feat(connect-mobile): add appName and appIcon to deeplink (7f96299)
|
|
31
|
+
- feat(connect-explorer): add appIcon (04dd6d6)
|
|
32
|
+
- feat(connect): add backendType to discovery progress events (a3b804e)
|
|
33
|
+
- feat(connect): track npmVersion in analytics (6cc1058)
|
|
34
|
+
|
|
35
|
+
## Chores
|
|
36
|
+
|
|
37
|
+
- chore: update jest to v30 (6d27a2c)
|
|
38
|
+
- chore: update trends deps (a9f0997)
|
|
39
|
+
- chore: add/remove used/unused packages (60fb96b)
|
|
40
|
+
- chore: add missing workspace libs (bc6a681)
|
|
41
|
+
- refactor(connect): split Device related code to workflow modules (dd9ffde)
|
|
42
|
+
|
|
14
43
|
# 9.6.0
|
|
15
44
|
|
|
16
45
|
Starting with Connect version 9.6.0, we are introducing a new integration with Trezor Suite. The new flow is designed to provide a more seamless and user-friendly experience for users interacting with Trezor devices.
|
|
17
|
-
To learn more, please take a look at the full [New Connect flow in Trezor Suite](https://connect.trezor.io/9
|
|
46
|
+
To learn more, please take a look at the full [New Connect flow in Trezor Suite](https://connect.trezor.io/9/guides/new-connect-flow-in-trezor-suite/) article.
|
|
18
47
|
We encourage you to try out the new flow to make sure everything works as expected. If you encounter any issues, please let us know.
|
|
19
48
|
|
|
20
49
|
This requires one change in the manifest - there is an additional required field `appName` that is used in the permission prompt. Optionally, you can also provide an `appIcon` which will be shown in the future.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.6.
|
|
3
|
+
API version 9.6.1-beta.2
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/test-connect.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -51,6 +51,7 @@ class BlockchainEstimateFee extends AbstractMethod_1.AbstractMethod {
|
|
|
51
51
|
blockTime: coinInfo.blockTime,
|
|
52
52
|
minFee: coinInfo.minFee,
|
|
53
53
|
maxFee: coinInfo.maxFee,
|
|
54
|
+
minPriorityFee: coinInfo.minPriorityFee,
|
|
54
55
|
dustLimit: coinInfo.type === 'bitcoin' ? coinInfo.dustLimit : undefined,
|
|
55
56
|
levels: [],
|
|
56
57
|
};
|
|
@@ -157,7 +157,15 @@ class DiscoverAccounts extends AbstractMethod_1.AbstractMethod {
|
|
|
157
157
|
? []
|
|
158
158
|
: await blockchain.getAccountUtxo(descriptor);
|
|
159
159
|
this.updateProgress(accountKey, index + 1, info.empty);
|
|
160
|
-
this.sendProgress({
|
|
160
|
+
this.sendProgress({
|
|
161
|
+
...info,
|
|
162
|
+
descriptor,
|
|
163
|
+
...descRest,
|
|
164
|
+
utxo,
|
|
165
|
+
...accountKey,
|
|
166
|
+
index,
|
|
167
|
+
backendType: request.coinInfo.blockchainLink?.type,
|
|
168
|
+
});
|
|
161
169
|
if (info.empty) {
|
|
162
170
|
await descPromise.catch(() => { });
|
|
163
171
|
return { nonempty: index - skip };
|
|
@@ -166,7 +174,7 @@ class DiscoverAccounts extends AbstractMethod_1.AbstractMethod {
|
|
|
166
174
|
catch (error) {
|
|
167
175
|
descPromise.catch(() => { });
|
|
168
176
|
this.updateProgress(accountKey, index + 1, true);
|
|
169
|
-
this.sendProgress({ ...accountKey, index, error: error.message });
|
|
177
|
+
this.sendProgress({ ...accountKey, index, error: error.message, code: error.code });
|
|
170
178
|
return { nonempty: index - skip, error };
|
|
171
179
|
}
|
|
172
180
|
index++;
|
|
@@ -81,8 +81,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
81
81
|
parent: string;
|
|
82
82
|
auth: {
|
|
83
83
|
keys: {
|
|
84
|
-
type?: number | undefined;
|
|
85
84
|
address_n?: number[] | undefined;
|
|
85
|
+
type?: number | undefined;
|
|
86
86
|
weight: number;
|
|
87
87
|
key: string;
|
|
88
88
|
}[];
|
|
@@ -119,8 +119,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
119
119
|
name: string;
|
|
120
120
|
owner: {
|
|
121
121
|
keys: {
|
|
122
|
-
type?: number | undefined;
|
|
123
122
|
address_n?: number[] | undefined;
|
|
123
|
+
type?: number | undefined;
|
|
124
124
|
weight: number;
|
|
125
125
|
key: string;
|
|
126
126
|
}[];
|
|
@@ -140,8 +140,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
140
140
|
creator: string;
|
|
141
141
|
active: {
|
|
142
142
|
keys: {
|
|
143
|
-
type?: number | undefined;
|
|
144
143
|
address_n?: number[] | undefined;
|
|
144
|
+
type?: number | undefined;
|
|
145
145
|
weight: number;
|
|
146
146
|
key: string;
|
|
147
147
|
}[];
|
|
@@ -44,7 +44,7 @@ class EthereumSignMessage extends AbstractMethod_1.AbstractMethod {
|
|
|
44
44
|
type: 'message',
|
|
45
45
|
coin: this.params.network?.shortcut ?? 'ETH',
|
|
46
46
|
serializedPath: (0, pathUtils_1.getSerializedPath)(this.params.address_n),
|
|
47
|
-
message: this.payload.message,
|
|
47
|
+
message: this.payload.hex ? (0, formatUtils_1.hexToText)(this.payload.message) : this.payload.message,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -74,6 +74,7 @@ declare const Params: import("@trezor/schema-utils").TIntersect<[import("@trezor
|
|
|
74
74
|
blockTime: import("@trezor/schema-utils").TNumber;
|
|
75
75
|
minFee: import("@trezor/schema-utils").TNumber;
|
|
76
76
|
maxFee: import("@trezor/schema-utils").TNumber;
|
|
77
|
+
minPriorityFee: import("@trezor/schema-utils").TNumber;
|
|
77
78
|
defaultFees: import("@trezor/schema-utils").TArray<import("@trezor/schema-utils").TObject<{
|
|
78
79
|
label: import("@trezor/schema-utils").TUnion<[import("@trezor/schema-utils").TLiteral<"high">, import("@trezor/schema-utils").TLiteral<"normal">, import("@trezor/schema-utils").TLiteral<"economy">, import("@trezor/schema-utils").TLiteral<"low">, import("@trezor/schema-utils").TLiteral<"custom">]>;
|
|
79
80
|
blocks: import("@trezor/schema-utils").TNumber;
|
|
@@ -83,7 +84,6 @@ declare const Params: import("@trezor/schema-utils").TIntersect<[import("@trezor
|
|
|
83
84
|
baseFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
84
85
|
maxFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
85
86
|
maxPriorityFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
86
|
-
maxWaitTimeEstimate: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TNumber>;
|
|
87
87
|
}>>;
|
|
88
88
|
}>, import("@trezor/schema-utils").TObject<{
|
|
89
89
|
type: import("@trezor/schema-utils").TLiteral<"ethereum">;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBinaryOptional = exports.getBinary = void 0;
|
|
4
|
+
const utils_1 = require("@trezor/utils");
|
|
4
5
|
const assets_1 = require("../../utils/assets");
|
|
5
|
-
const ALL_SLASHES_AT_THE_END_REGEX = /\/+$/;
|
|
6
6
|
const getBinary = ({ baseUrl, btcOnly, release }) => {
|
|
7
7
|
const fwUrl = release[btcOnly ? 'url_bitcoinonly' : 'url'];
|
|
8
|
-
const sanitizedBaseUrl =
|
|
8
|
+
const sanitizedBaseUrl = (0, utils_1.removeTrailingSlashes)(baseUrl);
|
|
9
9
|
const url = `${sanitizedBaseUrl}/${fwUrl}`;
|
|
10
10
|
return (0, assets_1.httpRequest)(url, 'binary');
|
|
11
11
|
};
|
package/lib/api/getAddress.d.ts
CHANGED
package/lib/api/getAddress.js
CHANGED
package/lib/api/getCoinInfo.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
14
14
|
blockTime: number;
|
|
15
15
|
minFee: number;
|
|
16
16
|
maxFee: number;
|
|
17
|
+
minPriorityFee: number;
|
|
17
18
|
name: string;
|
|
18
19
|
shortcut: string;
|
|
19
20
|
slip44: number;
|
|
@@ -34,7 +35,6 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
34
35
|
baseFeePerGas?: string | undefined;
|
|
35
36
|
maxFeePerGas?: string | undefined;
|
|
36
37
|
maxPriorityFeePerGas?: string | undefined;
|
|
37
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
38
38
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
39
39
|
blocks: number;
|
|
40
40
|
feePerUnit: string;
|
|
@@ -77,6 +77,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
77
77
|
blockTime: number;
|
|
78
78
|
minFee: number;
|
|
79
79
|
maxFee: number;
|
|
80
|
+
minPriorityFee: number;
|
|
80
81
|
name: string;
|
|
81
82
|
shortcut: string;
|
|
82
83
|
slip44: number;
|
|
@@ -97,7 +98,6 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
97
98
|
baseFeePerGas?: string | undefined;
|
|
98
99
|
maxFeePerGas?: string | undefined;
|
|
99
100
|
maxPriorityFeePerGas?: string | undefined;
|
|
100
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
101
101
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
102
102
|
blocks: number;
|
|
103
103
|
feePerUnit: string;
|
|
@@ -115,6 +115,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
115
115
|
blockTime: number;
|
|
116
116
|
minFee: number;
|
|
117
117
|
maxFee: number;
|
|
118
|
+
minPriorityFee: number;
|
|
118
119
|
name: string;
|
|
119
120
|
shortcut: string;
|
|
120
121
|
slip44: number;
|
|
@@ -135,7 +136,6 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
135
136
|
baseFeePerGas?: string | undefined;
|
|
136
137
|
maxFeePerGas?: string | undefined;
|
|
137
138
|
maxPriorityFeePerGas?: string | undefined;
|
|
138
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
139
139
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
140
140
|
blocks: number;
|
|
141
141
|
feePerUnit: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PROTO } from '../constants';
|
|
2
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
|
+
export default class GetNonce extends AbstractMethod<'getNonce', PROTO.GetNonce> {
|
|
4
|
+
init(): void;
|
|
5
|
+
run(): Promise<{
|
|
6
|
+
nonce: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=getNonce.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
class GetNonce extends AbstractMethod_1.AbstractMethod {
|
|
5
|
+
init() {
|
|
6
|
+
this.useDeviceState = false;
|
|
7
|
+
}
|
|
8
|
+
async run() {
|
|
9
|
+
const cmd = this.device.getCommands();
|
|
10
|
+
const response = await cmd.typedCall('GetNonce', 'Nonce');
|
|
11
|
+
return response.message;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = GetNonce;
|
|
15
|
+
//# sourceMappingURL=getNonce.js.map
|
package/lib/api/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { default as getCoinInfo } from './getCoinInfo';
|
|
|
32
32
|
export { default as getDeviceState } from './getDeviceState';
|
|
33
33
|
export { default as getFeatures } from './getFeatures';
|
|
34
34
|
export { default as getFirmwareHash } from './getFirmwareHash';
|
|
35
|
+
export { default as getNonce } from './getNonce';
|
|
35
36
|
export { default as getOwnershipId } from './getOwnershipId';
|
|
36
37
|
export { default as getOwnershipProof } from './getOwnershipProof';
|
|
37
38
|
export { default as getPublicKey } from './getPublicKey';
|
package/lib/api/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.wipeDevice = void 0;
|
|
3
|
+
exports.unlockPath = exports.signTransaction = exports.signMessage = exports.setProxy = exports.setBusy = exports.setBrightness = exports.loadDevice = exports.resetDevice = exports.requestLogin = exports.recoveryDevice = exports.pushTransaction = exports.getSettings = exports.getPublicKey = exports.getOwnershipProof = exports.getOwnershipId = exports.getNonce = exports.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.getAccountDescriptor = exports.discoverAccounts = exports.composeTransaction = exports.cipherKeyValue = exports.changeWipeCode = exports.changePin = exports.changeLanguage = exports.blockchainUnsubscribeFiatRates = exports.blockchainUnsubscribe = exports.blockchainSubscribeFiatRates = exports.blockchainSubscribe = exports.blockchainSetCustomBackend = exports.blockchainGetTransactions = exports.blockchainGetFiatRatesForTimestamps = exports.blockchainEvmRpcCall = exports.blockchainGetInfo = exports.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.bleUnpair = exports.backupDevice = exports.showDeviceTutorial = exports.cancelCoinjoinAuthorization = exports.authorizeCoinjoin = exports.authenticateDevice = exports.applySettings = exports.applyFlags = void 0;
|
|
4
|
+
exports.wipeDevice = exports.verifyMessage = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
var applyFlags_1 = require("./applyFlags");
|
|
7
7
|
Object.defineProperty(exports, "applyFlags", { enumerable: true, get: function () { return tslib_1.__importDefault(applyFlags_1).default; } });
|
|
@@ -71,6 +71,8 @@ var getFeatures_1 = require("./getFeatures");
|
|
|
71
71
|
Object.defineProperty(exports, "getFeatures", { enumerable: true, get: function () { return tslib_1.__importDefault(getFeatures_1).default; } });
|
|
72
72
|
var getFirmwareHash_1 = require("./getFirmwareHash");
|
|
73
73
|
Object.defineProperty(exports, "getFirmwareHash", { enumerable: true, get: function () { return tslib_1.__importDefault(getFirmwareHash_1).default; } });
|
|
74
|
+
var getNonce_1 = require("./getNonce");
|
|
75
|
+
Object.defineProperty(exports, "getNonce", { enumerable: true, get: function () { return tslib_1.__importDefault(getNonce_1).default; } });
|
|
74
76
|
var getOwnershipId_1 = require("./getOwnershipId");
|
|
75
77
|
Object.defineProperty(exports, "getOwnershipId", { enumerable: true, get: function () { return tslib_1.__importDefault(getOwnershipId_1).default; } });
|
|
76
78
|
var getOwnershipProof_1 = require("./getOwnershipProof");
|
|
@@ -37,13 +37,13 @@ export declare const createTx: (tx: $T.NEMTransaction, address_n: number[], chun
|
|
|
37
37
|
levy?: PROTO.NEMMosaicLevy | undefined;
|
|
38
38
|
divisibility?: number | undefined;
|
|
39
39
|
transferable?: boolean | undefined;
|
|
40
|
+
networks?: number[] | undefined;
|
|
40
41
|
ticker?: string | undefined;
|
|
41
42
|
levy_address?: string | undefined;
|
|
42
43
|
levy_namespace?: string | undefined;
|
|
43
44
|
levy_mosaic?: string | undefined;
|
|
44
45
|
supply?: number | undefined;
|
|
45
46
|
mutable_supply?: boolean | undefined;
|
|
46
|
-
networks?: number[] | undefined;
|
|
47
47
|
description: string;
|
|
48
48
|
namespace: string;
|
|
49
49
|
mosaic: string;
|
package/lib/api/resetDevice.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { PROTO } from '../constants';
|
|
2
2
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
3
|
export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.ResetDevice> {
|
|
4
|
-
private isEntropyCheckSuccessful;
|
|
5
4
|
init(): void;
|
|
6
5
|
get info(): string;
|
|
7
6
|
get confirmation(): {
|
|
8
7
|
view: "device-management";
|
|
9
8
|
label: string;
|
|
10
9
|
};
|
|
11
|
-
private
|
|
12
|
-
private
|
|
10
|
+
private resetDeviceWorkflow;
|
|
11
|
+
private entropyCheckWorkflow;
|
|
13
12
|
run(): Promise<{
|
|
14
13
|
message: string;
|
|
15
14
|
}>;
|
package/lib/api/resetDevice.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
|
-
const errors_groups_1 = require("@trezor/transport/lib/errors-groups");
|
|
5
4
|
const utils_1 = require("@trezor/utils");
|
|
6
5
|
const verifyEntropy_1 = require("../api/firmware/verifyEntropy");
|
|
7
6
|
const constants_1 = require("../constants");
|
|
@@ -10,7 +9,6 @@ const events_1 = require("../events");
|
|
|
10
9
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
11
10
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
12
11
|
class ResetDevice extends AbstractMethod_1.AbstractMethod {
|
|
13
|
-
isEntropyCheckSuccessful = false;
|
|
14
12
|
init() {
|
|
15
13
|
this.allowDeviceMode = [events_1.UI.INITIALIZE, events_1.UI.SEEDLESS];
|
|
16
14
|
this.useDeviceState = false;
|
|
@@ -40,65 +38,65 @@ class ResetDevice extends AbstractMethod_1.AbstractMethod {
|
|
|
40
38
|
label: 'Do you really you want to create a new wallet?',
|
|
41
39
|
};
|
|
42
40
|
}
|
|
43
|
-
async
|
|
41
|
+
async resetDeviceWorkflow() {
|
|
44
42
|
const cmd = this.device.getCommands();
|
|
45
43
|
const entropy = (0, verifyEntropy_1.generateEntropy)(32).toString('hex');
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await cmd.typedCall('EntropyAck', ['EntropyCheckReady', 'Success'], { entropy });
|
|
49
|
-
return {
|
|
50
|
-
...entropyRequest.message,
|
|
51
|
-
host_entropy: entropy,
|
|
52
|
-
};
|
|
44
|
+
await cmd.typedCall('ResetDevice', 'EntropyRequest', this.params);
|
|
45
|
+
await cmd.typedCall('EntropyAck', 'Success', { entropy });
|
|
53
46
|
}
|
|
54
|
-
async
|
|
47
|
+
async entropyCheckWorkflow() {
|
|
55
48
|
const cmd = this.device.getCommands();
|
|
56
49
|
const paths = ["m/84'/0'/0'", "m/44'/60'/0'"];
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
const handleErr = (error) => {
|
|
51
|
+
throw error.cause === 'transport-error'
|
|
52
|
+
? error
|
|
53
|
+
: constants_1.ERRORS.TypedError('Failure_EntropyCheck', error.message);
|
|
54
|
+
};
|
|
55
|
+
let entropy = (0, verifyEntropy_1.generateEntropy)(32).toString('hex');
|
|
56
|
+
let commitment = await cmd
|
|
57
|
+
.typedCall('ResetDevice', 'EntropyRequest', this.params)
|
|
58
|
+
.then(response => response.message.entropy_commitment);
|
|
59
|
+
await cmd.typedCall('EntropyAck', 'EntropyCheckReady', { entropy });
|
|
60
|
+
const tries = (0, utils_1.getRandomInt)(1, 5);
|
|
61
|
+
for (let i = 0; i < tries; i++) {
|
|
62
|
+
const xpubs = {};
|
|
63
|
+
for (const path of paths) {
|
|
64
|
+
const pubKey = await cmd
|
|
65
|
+
.getPublicKey({ address_n: (0, pathUtils_1.validatePath)(path) })
|
|
66
|
+
.catch(handleErr);
|
|
67
|
+
xpubs[path] = pubKey.xpub;
|
|
68
|
+
}
|
|
69
|
+
const { prev_entropy, entropy_commitment } = await cmd
|
|
70
|
+
.typedCall('EntropyCheckContinue', 'EntropyRequest', {})
|
|
71
|
+
.then(response => response.message)
|
|
72
|
+
.catch(handleErr);
|
|
73
|
+
const res = await (0, verifyEntropy_1.verifyEntropy)({
|
|
74
|
+
type: this.params.backup_type,
|
|
75
|
+
strength: this.params.strength,
|
|
76
|
+
commitment,
|
|
77
|
+
hostEntropy: entropy,
|
|
78
|
+
trezorEntropy: prev_entropy,
|
|
79
|
+
xpubs,
|
|
80
|
+
});
|
|
81
|
+
if (res.error) {
|
|
82
|
+
await this.device.getCurrentSession().cancelCall();
|
|
83
|
+
throw constants_1.ERRORS.TypedError('Failure_EntropyCheck', res.error);
|
|
84
|
+
}
|
|
85
|
+
entropy = (0, verifyEntropy_1.generateEntropy)(32).toString('hex');
|
|
86
|
+
commitment = entropy_commitment;
|
|
87
|
+
await cmd.typedCall('EntropyAck', 'EntropyCheckReady', { entropy }).catch(handleErr);
|
|
75
88
|
}
|
|
76
|
-
|
|
89
|
+
await cmd.typedCall('EntropyCheckContinue', 'Success', { finish: true });
|
|
77
90
|
}
|
|
78
91
|
async run() {
|
|
79
|
-
const cmd = this.device.getCommands();
|
|
80
92
|
if (this.params.entropy_check && this.device.unavailableCapabilities['entropyCheck']) {
|
|
81
93
|
this.params.entropy_check = false;
|
|
82
94
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (this.params.entropy_check) {
|
|
86
|
-
const tries = (0, utils_1.getRandomInt)(1, 5);
|
|
87
|
-
for (let i = 0; i < tries; i++) {
|
|
88
|
-
entropyData = await this.entropyCheck(entropyData);
|
|
89
|
-
}
|
|
90
|
-
this.isEntropyCheckSuccessful = true;
|
|
91
|
-
await cmd.typedCall('EntropyCheckContinue', 'Success', { finish: true });
|
|
92
|
-
}
|
|
95
|
+
if (this.params.entropy_check) {
|
|
96
|
+
await this.entropyCheckWorkflow();
|
|
93
97
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
errors_groups_1.ERRORS_WITHOUT_DEVICE_INTERACTION.includes(error.message)) {
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
if (this.isEntropyCheckSuccessful === true)
|
|
100
|
-
throw error;
|
|
101
|
-
throw constants_1.ERRORS.TypedError('Failure_EntropyCheck', error.message);
|
|
98
|
+
else {
|
|
99
|
+
await this.resetDeviceWorkflow();
|
|
102
100
|
}
|
|
103
101
|
return { message: 'Success' };
|
|
104
102
|
}
|
package/lib/api/signMessage.js
CHANGED
|
@@ -44,7 +44,7 @@ class SignMessage extends AbstractMethod_1.AbstractMethod {
|
|
|
44
44
|
type: 'message',
|
|
45
45
|
serializedPath: (0, pathUtils_1.getSerializedPath)(this.params.address_n.slice(0, 4)),
|
|
46
46
|
coin: this.coinInfo?.shortcut ?? 'BTC',
|
|
47
|
-
message: this.payload.message,
|
|
47
|
+
message: this.payload.hex ? (0, formatUtils_1.hexToText)(this.payload.message) : this.payload.message,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -51,6 +51,11 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
51
51
|
this.preauthorized = payload.preauthorized;
|
|
52
52
|
const inputs = (0, bitcoin_1.validateTrezorInputs)(payload.inputs, coinInfo);
|
|
53
53
|
const outputs = (0, bitcoin_1.validateTrezorOutputs)(payload.outputs, coinInfo);
|
|
54
|
+
if (payload.paymentRequests && payload.paymentRequests.length > 0) {
|
|
55
|
+
outputs.forEach(output => {
|
|
56
|
+
output.payment_req_index = 0;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
54
59
|
if (payload.refTxs && payload.account?.transactions) {
|
|
55
60
|
console.warn('two sources of referential transactions were passed. payload.refTxs have precedence');
|
|
56
61
|
}
|
|
@@ -72,7 +77,7 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
72
77
|
this.params = {
|
|
73
78
|
inputs,
|
|
74
79
|
outputs,
|
|
75
|
-
paymentRequests: payload.paymentRequests
|
|
80
|
+
paymentRequests: payload.paymentRequests ?? [],
|
|
76
81
|
refTxs,
|
|
77
82
|
addresses: payload.account ? payload.account.addresses : undefined,
|
|
78
83
|
options: {
|
|
@@ -51,6 +51,7 @@ export declare class Blockchain {
|
|
|
51
51
|
estimateFee(request: Parameters<typeof this.link.estimateFee>[0]): Promise<{
|
|
52
52
|
feePerUnit: string;
|
|
53
53
|
feePerTx?: string;
|
|
54
|
+
feePayer?: string;
|
|
54
55
|
feeLimit?: string;
|
|
55
56
|
eip1559?: import("@trezor/blockchain-link-types/lib/blockbook-api").Eip1559Fees;
|
|
56
57
|
}[]>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { BitcoinNetworkInfo } from '../../types';
|
|
2
2
|
import { Blockchain } from '../Blockchain';
|
|
3
|
-
import {
|
|
3
|
+
import { MiscFeeLevels } from './MiscFeeLevels';
|
|
4
4
|
export declare class BitcoinFeeLevels extends MiscFeeLevels {
|
|
5
5
|
coinInfo: BitcoinNetworkInfo;
|
|
6
|
-
longTermFeeRate
|
|
7
|
-
blocks: Blocks;
|
|
6
|
+
longTermFeeRate: string;
|
|
8
7
|
constructor(coinInfo: BitcoinNetworkInfo);
|
|
9
8
|
load(blockchain: Blockchain): Promise<{
|
|
10
9
|
feePerTx?: string | undefined;
|
|
@@ -12,7 +11,6 @@ export declare class BitcoinFeeLevels extends MiscFeeLevels {
|
|
|
12
11
|
baseFeePerGas?: string | undefined;
|
|
13
12
|
maxFeePerGas?: string | undefined;
|
|
14
13
|
maxPriorityFeePerGas?: string | undefined;
|
|
15
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
16
14
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
17
15
|
blocks: number;
|
|
18
16
|
feePerUnit: string;
|
|
@@ -3,88 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BitcoinFeeLevels = void 0;
|
|
4
4
|
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
5
5
|
const MiscFeeLevels_1 = require("./MiscFeeLevels");
|
|
6
|
-
const
|
|
7
|
-
const fee = new bigNumber_1.BigNumber(feePerUnit);
|
|
8
|
-
const lower = blocks.find(block => typeof block === 'string' && fee.gte(block));
|
|
9
|
-
if (!lower)
|
|
10
|
-
return -1;
|
|
11
|
-
return blocks.indexOf(lower);
|
|
12
|
-
};
|
|
13
|
-
const convertFeeRate = (fee, minFee) => {
|
|
14
|
-
const feePerKB = new bigNumber_1.BigNumber(fee);
|
|
15
|
-
if (feePerKB.isNaN() || feePerKB.lte('0'))
|
|
16
|
-
return;
|
|
17
|
-
const feePerB = feePerKB.div(1000);
|
|
18
|
-
if (feePerB.lt(minFee))
|
|
19
|
-
return minFee.toString();
|
|
20
|
-
return feePerB.isInteger() ? feePerB.toString() : feePerB.toFixed(2);
|
|
21
|
-
};
|
|
22
|
-
const fillGap = (from, step, size) => {
|
|
23
|
-
const fill = [];
|
|
24
|
-
for (let i = from + step; i <= from + size; i += step) {
|
|
25
|
-
fill.push(i);
|
|
26
|
-
}
|
|
27
|
-
return fill;
|
|
28
|
-
};
|
|
29
|
-
const findNearest = (requested, blocks) => {
|
|
30
|
-
if (typeof blocks[requested] === 'string')
|
|
31
|
-
return blocks[requested];
|
|
32
|
-
const len = blocks.length;
|
|
33
|
-
let index = requested;
|
|
34
|
-
while (typeof blocks[index] !== 'string' && index < len) {
|
|
35
|
-
index++;
|
|
36
|
-
}
|
|
37
|
-
if (typeof blocks[index] === 'string') {
|
|
38
|
-
return blocks[index];
|
|
39
|
-
}
|
|
40
|
-
index = requested;
|
|
41
|
-
while (typeof blocks[index] !== 'string' && index > 0) {
|
|
42
|
-
index--;
|
|
43
|
-
}
|
|
44
|
-
return blocks[index];
|
|
45
|
-
};
|
|
46
|
-
const findLowest = (blocks) => blocks
|
|
47
|
-
.slice(0)
|
|
48
|
-
.reverse()
|
|
49
|
-
.find(item => typeof item === 'string');
|
|
6
|
+
const defaultFeeLevels_1 = require("../../data/defaultFeeLevels");
|
|
50
7
|
class BitcoinFeeLevels extends MiscFeeLevels_1.MiscFeeLevels {
|
|
51
8
|
coinInfo;
|
|
52
9
|
longTermFeeRate;
|
|
53
|
-
blocks = [];
|
|
54
10
|
constructor(coinInfo) {
|
|
55
11
|
super(coinInfo);
|
|
56
12
|
this.coinInfo = coinInfo;
|
|
13
|
+
this.longTermFeeRate = defaultFeeLevels_1.DEFAULT_BITCOIN_LONGTERM_FEE_RATE;
|
|
57
14
|
}
|
|
58
15
|
async load(blockchain) {
|
|
59
|
-
let blocks = fillGap(0, 1, 10);
|
|
60
|
-
if (this.levels.length > 1) {
|
|
61
|
-
blocks = this.levels
|
|
62
|
-
.map(l => l.blocks)
|
|
63
|
-
.reduce((result, bl) => {
|
|
64
|
-
if (result.length === 0)
|
|
65
|
-
return result.concat([bl]);
|
|
66
|
-
const from = result[result.length - 1];
|
|
67
|
-
const gap = bl - from;
|
|
68
|
-
const incr = gap <= 30 ? 1 : 6;
|
|
69
|
-
const fill = fillGap(from, incr, gap);
|
|
70
|
-
return result.concat(fill);
|
|
71
|
-
}, []);
|
|
72
|
-
}
|
|
73
|
-
const oneDayBlocks = 6 * 24;
|
|
74
|
-
blocks.push(...fillGap(oneDayBlocks, oneDayBlocks / 2, oneDayBlocks * 6));
|
|
75
16
|
try {
|
|
17
|
+
const { minFee, maxFee } = this.coinInfo;
|
|
18
|
+
const blocks = this.levels.map(level => level.blocks).filter(b => b > 0);
|
|
76
19
|
const response = await blockchain.estimateFee({ blocks });
|
|
77
|
-
response.forEach(({ feePerUnit }, index) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
level.blocks = this.blocks.indexOf(updatedValue);
|
|
84
|
-
level.feePerUnit = updatedValue;
|
|
85
|
-
}
|
|
20
|
+
response.forEach(({ feePerUnit: feePerKB }, index) => {
|
|
21
|
+
const feePerB = new bigNumber_1.BigNumber(feePerKB).div(1000).toNumber();
|
|
22
|
+
if (isNaN(feePerB) || feePerB < 0)
|
|
23
|
+
return;
|
|
24
|
+
const trimmedFeePerUnit = Math.min(maxFee, Math.max(minFee, feePerB));
|
|
25
|
+
this.levels[index].feePerUnit = trimmedFeePerUnit.toString();
|
|
86
26
|
});
|
|
87
|
-
this.longTermFeeRate = findLowest(this.blocks);
|
|
88
27
|
this.wasFetchedSuccessfully = true;
|
|
89
28
|
}
|
|
90
29
|
catch {
|
|
@@ -93,11 +32,10 @@ class BitcoinFeeLevels extends MiscFeeLevels_1.MiscFeeLevels {
|
|
|
93
32
|
}
|
|
94
33
|
updateBitcoinCustomFee(feePerUnit) {
|
|
95
34
|
this.levels = this.levels.filter(l => l.label !== 'custom');
|
|
96
|
-
const blocks = findBlocksForFee(feePerUnit, this.blocks);
|
|
97
35
|
this.levels.push({
|
|
98
36
|
label: 'custom',
|
|
99
37
|
feePerUnit,
|
|
100
|
-
blocks,
|
|
38
|
+
blocks: -1,
|
|
101
39
|
});
|
|
102
40
|
}
|
|
103
41
|
}
|