@shapeshiftoss/hdwallet-trezor 1.55.2-alpha.0 → 1.55.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/dist/bitcoin.js +99 -158
- package/dist/bitcoin.js.map +1 -1
- package/dist/ethereum.js +66 -122
- package/dist/ethereum.js.map +1 -1
- package/dist/index.js +2 -18
- package/dist/index.js.map +1 -1
- package/dist/transport.js +3 -30
- package/dist/transport.js.map +1 -1
- package/dist/trezor.js +194 -309
- package/dist/trezor.js.map +1 -1
- package/dist/utils.js +2 -29
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
package/dist/trezor.js
CHANGED
|
@@ -1,50 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.create = exports.info = exports.TrezorHDWallet = exports.TrezorHDWalletInfo = exports.isTrezor = void 0;
|
|
39
|
-
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
40
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
41
|
-
const Btc = __importStar(require("./bitcoin"));
|
|
42
|
-
const Eth = __importStar(require("./ethereum"));
|
|
43
|
-
const utils_1 = require("./utils");
|
|
44
|
-
function isTrezor(wallet) {
|
|
45
|
-
return lodash_1.default.isObject(wallet) && wallet._isTrezor;
|
|
1
|
+
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import * as Btc from "./bitcoin";
|
|
4
|
+
import * as Eth from "./ethereum";
|
|
5
|
+
import { handleError } from "./utils";
|
|
6
|
+
export function isTrezor(wallet) {
|
|
7
|
+
return _.isObject(wallet) && wallet._isTrezor;
|
|
46
8
|
}
|
|
47
|
-
exports.isTrezor = isTrezor;
|
|
48
9
|
function describeETHPath(path) {
|
|
49
10
|
const pathStr = core.addressNListToBIP32(path);
|
|
50
11
|
const unknown = {
|
|
@@ -75,7 +36,6 @@ function describeETHPath(path) {
|
|
|
75
36
|
};
|
|
76
37
|
}
|
|
77
38
|
function describeUTXOPath(path, coin, scriptType) {
|
|
78
|
-
var _a;
|
|
79
39
|
const pathStr = core.addressNListToBIP32(path);
|
|
80
40
|
const unknown = {
|
|
81
41
|
verbose: pathStr,
|
|
@@ -105,11 +65,11 @@ function describeUTXOPath(path, coin, scriptType) {
|
|
|
105
65
|
return unknown;
|
|
106
66
|
const wholeAccount = path.length === 3;
|
|
107
67
|
let script = scriptType
|
|
108
|
-
?
|
|
68
|
+
? {
|
|
109
69
|
[core.BTCInputScriptType.SpendAddress]: " (Legacy)",
|
|
110
70
|
[core.BTCInputScriptType.SpendP2SHWitness]: "",
|
|
111
71
|
[core.BTCInputScriptType.SpendWitness]: " (Segwit Native)",
|
|
112
|
-
}[scriptType]
|
|
72
|
+
}[scriptType] ?? ""
|
|
113
73
|
: "";
|
|
114
74
|
switch (coin) {
|
|
115
75
|
case "Bitcoin":
|
|
@@ -148,28 +108,20 @@ function describeUTXOPath(path, coin, scriptType) {
|
|
|
148
108
|
};
|
|
149
109
|
}
|
|
150
110
|
}
|
|
151
|
-
class TrezorHDWalletInfo {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this._supportsETHInfo = true;
|
|
155
|
-
}
|
|
111
|
+
export class TrezorHDWalletInfo {
|
|
112
|
+
_supportsBTCInfo = true;
|
|
113
|
+
_supportsETHInfo = true;
|
|
156
114
|
getVendor() {
|
|
157
115
|
return "Trezor";
|
|
158
116
|
}
|
|
159
|
-
btcSupportsCoin(coin) {
|
|
160
|
-
return
|
|
161
|
-
return Btc.btcSupportsCoin(coin);
|
|
162
|
-
});
|
|
117
|
+
async btcSupportsCoin(coin) {
|
|
118
|
+
return Btc.btcSupportsCoin(coin);
|
|
163
119
|
}
|
|
164
|
-
btcSupportsScriptType(coin, scriptType) {
|
|
165
|
-
return
|
|
166
|
-
return Btc.btcSupportsScriptType(coin, scriptType);
|
|
167
|
-
});
|
|
120
|
+
async btcSupportsScriptType(coin, scriptType) {
|
|
121
|
+
return Btc.btcSupportsScriptType(coin, scriptType);
|
|
168
122
|
}
|
|
169
|
-
btcSupportsSecureTransfer() {
|
|
170
|
-
return
|
|
171
|
-
return Btc.btcSupportsSecureTransfer();
|
|
172
|
-
});
|
|
123
|
+
async btcSupportsSecureTransfer() {
|
|
124
|
+
return Btc.btcSupportsSecureTransfer();
|
|
173
125
|
}
|
|
174
126
|
btcSupportsNativeShapeShift() {
|
|
175
127
|
return Btc.btcSupportsNativeShapeShift();
|
|
@@ -180,23 +132,17 @@ class TrezorHDWalletInfo {
|
|
|
180
132
|
btcIsSameAccount(msg) {
|
|
181
133
|
return Btc.btcIsSameAccount(msg);
|
|
182
134
|
}
|
|
183
|
-
ethSupportsNetwork(chain_id) {
|
|
184
|
-
return
|
|
185
|
-
return Eth.ethSupportsNetwork(chain_id);
|
|
186
|
-
});
|
|
135
|
+
async ethSupportsNetwork(chain_id) {
|
|
136
|
+
return Eth.ethSupportsNetwork(chain_id);
|
|
187
137
|
}
|
|
188
|
-
ethSupportsSecureTransfer() {
|
|
189
|
-
return
|
|
190
|
-
return Eth.ethSupportsSecureTransfer();
|
|
191
|
-
});
|
|
138
|
+
async ethSupportsSecureTransfer() {
|
|
139
|
+
return Eth.ethSupportsSecureTransfer();
|
|
192
140
|
}
|
|
193
141
|
ethSupportsNativeShapeShift() {
|
|
194
142
|
return Eth.ethSupportsNativeShapeShift();
|
|
195
143
|
}
|
|
196
|
-
ethSupportsEIP1559() {
|
|
197
|
-
return
|
|
198
|
-
return yield Eth.ethSupportsEIP1559();
|
|
199
|
-
});
|
|
144
|
+
async ethSupportsEIP1559() {
|
|
145
|
+
return await Eth.ethSupportsEIP1559();
|
|
200
146
|
}
|
|
201
147
|
ethGetAccountPaths(msg) {
|
|
202
148
|
return Eth.ethGetAccountPaths(msg);
|
|
@@ -245,7 +191,10 @@ class TrezorHDWalletInfo {
|
|
|
245
191
|
addressNList[0] === 0x80000000 + 49 ||
|
|
246
192
|
addressNList[0] === 0x80000000 + 84) {
|
|
247
193
|
addressNList[2] += 1;
|
|
248
|
-
return
|
|
194
|
+
return {
|
|
195
|
+
...msg,
|
|
196
|
+
addressNList,
|
|
197
|
+
};
|
|
249
198
|
}
|
|
250
199
|
return undefined;
|
|
251
200
|
}
|
|
@@ -257,219 +206,186 @@ class TrezorHDWalletInfo {
|
|
|
257
206
|
}
|
|
258
207
|
if (addressNList[0] === 0x80000000 + 44) {
|
|
259
208
|
addressNList[4] += 1;
|
|
260
|
-
return
|
|
209
|
+
return {
|
|
210
|
+
...msg,
|
|
211
|
+
addressNList,
|
|
212
|
+
hardenedPath: core.hardenedPath(addressNList),
|
|
213
|
+
relPath: core.relativePath(addressNList),
|
|
214
|
+
};
|
|
261
215
|
}
|
|
262
216
|
return undefined;
|
|
263
217
|
}
|
|
264
218
|
}
|
|
265
|
-
|
|
266
|
-
|
|
219
|
+
export class TrezorHDWallet {
|
|
220
|
+
_supportsETHInfo = true;
|
|
221
|
+
_supportsBTCInfo = true;
|
|
222
|
+
_supportsBTC = true;
|
|
223
|
+
_supportsETH = true;
|
|
224
|
+
_supportsEthSwitchChain = true;
|
|
225
|
+
_supportsAvalanche = true;
|
|
226
|
+
_supportsOptimism = false;
|
|
227
|
+
_supportsBSC = false;
|
|
228
|
+
_supportsPolygon = false;
|
|
229
|
+
_supportsGnosis = false;
|
|
230
|
+
_supportsArbitrum = true;
|
|
231
|
+
_supportsArbitrumNova = true;
|
|
232
|
+
_supportsBase = true;
|
|
233
|
+
_supportsKavaInfo = true;
|
|
234
|
+
_supportsTerraInfo = true;
|
|
235
|
+
_isTrezor = true;
|
|
236
|
+
transport;
|
|
237
|
+
featuresCache;
|
|
238
|
+
info;
|
|
267
239
|
constructor(transport) {
|
|
268
|
-
this._supportsETHInfo = true;
|
|
269
|
-
this._supportsBTCInfo = true;
|
|
270
|
-
this._supportsBTC = true;
|
|
271
|
-
this._supportsETH = true;
|
|
272
|
-
this._supportsEthSwitchChain = true;
|
|
273
|
-
this._supportsAvalanche = true;
|
|
274
|
-
this._supportsOptimism = false;
|
|
275
|
-
this._supportsBSC = false;
|
|
276
|
-
this._supportsPolygon = false;
|
|
277
|
-
this._supportsGnosis = false;
|
|
278
|
-
this._supportsArbitrum = true;
|
|
279
|
-
this._supportsArbitrumNova = true;
|
|
280
|
-
this._supportsBase = true;
|
|
281
|
-
this._supportsKavaInfo = true;
|
|
282
|
-
this._supportsTerraInfo = true;
|
|
283
|
-
this._isTrezor = true;
|
|
284
240
|
this.transport = transport;
|
|
285
241
|
this.info = new TrezorHDWalletInfo();
|
|
286
242
|
}
|
|
287
|
-
initialize() {
|
|
288
|
-
return
|
|
289
|
-
return;
|
|
290
|
-
});
|
|
243
|
+
async initialize() {
|
|
244
|
+
return;
|
|
291
245
|
}
|
|
292
|
-
isInitialized() {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return features.initialized;
|
|
296
|
-
});
|
|
246
|
+
async isInitialized() {
|
|
247
|
+
const features = await this.getFeatures(/*cached*/ true);
|
|
248
|
+
return features.initialized;
|
|
297
249
|
}
|
|
298
|
-
getDeviceID() {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return features.device_id;
|
|
305
|
-
});
|
|
250
|
+
async getDeviceID() {
|
|
251
|
+
const { device: { deviceID: transportId }, } = this.transport;
|
|
252
|
+
if (transportId)
|
|
253
|
+
return transportId;
|
|
254
|
+
const features = await this.getFeatures(/*cached*/ true);
|
|
255
|
+
return features.device_id;
|
|
306
256
|
}
|
|
307
|
-
getFirmwareVersion() {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return `v${features.major_version}.${features.minor_version}.${features.patch_version}`;
|
|
311
|
-
});
|
|
257
|
+
async getFirmwareVersion() {
|
|
258
|
+
const features = await this.getFeatures(/*cached*/ true);
|
|
259
|
+
return `v${features.major_version}.${features.minor_version}.${features.patch_version}`;
|
|
312
260
|
}
|
|
313
261
|
getVendor() {
|
|
314
262
|
return "Trezor";
|
|
315
263
|
}
|
|
316
|
-
getModel() {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
return "Trezor " + features.model;
|
|
320
|
-
});
|
|
264
|
+
async getModel() {
|
|
265
|
+
const features = await this.getFeatures(/*cached*/ true);
|
|
266
|
+
return "Trezor " + features.model;
|
|
321
267
|
}
|
|
322
|
-
getLabel() {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return typeof features.label === "string" ? features.label : "";
|
|
326
|
-
});
|
|
268
|
+
async getLabel() {
|
|
269
|
+
const features = await this.getFeatures(/*cached*/ true);
|
|
270
|
+
return typeof features.label === "string" ? features.label : "";
|
|
327
271
|
}
|
|
328
|
-
getFeatures(cached = false) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return res.payload;
|
|
336
|
-
});
|
|
272
|
+
async getFeatures(cached = false) {
|
|
273
|
+
if (cached && this.featuresCache)
|
|
274
|
+
return this.featuresCache;
|
|
275
|
+
const res = await this.transport.call("getFeatures", {});
|
|
276
|
+
handleError(this.transport, res, "Could not get Trezor features");
|
|
277
|
+
this.cacheFeatures(res.payload);
|
|
278
|
+
return res.payload;
|
|
337
279
|
}
|
|
338
280
|
cacheFeatures(features) {
|
|
339
281
|
this.featuresCache = features;
|
|
340
282
|
}
|
|
341
|
-
getPublicKeys(msg) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
283
|
+
async getPublicKeys(msg) {
|
|
284
|
+
if (!msg.length)
|
|
285
|
+
return [];
|
|
286
|
+
const res = await this.transport.call("getPublicKey", {
|
|
287
|
+
bundle: msg.map((request) => {
|
|
288
|
+
return {
|
|
289
|
+
path: request.addressNList,
|
|
290
|
+
coin: request.coin || "Bitcoin",
|
|
291
|
+
crossChain: true,
|
|
292
|
+
};
|
|
293
|
+
}),
|
|
294
|
+
});
|
|
295
|
+
handleError(this.transport, res, "Could not load xpubs from Trezor");
|
|
296
|
+
return res.payload.map((result, i) => {
|
|
297
|
+
const scriptType = msg[i].scriptType;
|
|
298
|
+
switch (scriptType) {
|
|
299
|
+
case core.BTCInputScriptType.SpendP2SHWitness:
|
|
300
|
+
case core.BTCInputScriptType.SpendWitness: {
|
|
301
|
+
const xpub = result.xpubSegwit;
|
|
302
|
+
if (!xpub)
|
|
303
|
+
throw new Error("unable to get public key");
|
|
304
|
+
return {
|
|
305
|
+
xpub,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
case core.BTCInputScriptType.SpendAddress:
|
|
309
|
+
default: {
|
|
310
|
+
const xpub = result.xpub;
|
|
311
|
+
if (!xpub)
|
|
312
|
+
throw new Error("unable to get public key");
|
|
347
313
|
return {
|
|
348
|
-
|
|
349
|
-
coin: request.coin || "Bitcoin",
|
|
350
|
-
crossChain: true,
|
|
314
|
+
xpub,
|
|
351
315
|
};
|
|
352
|
-
}),
|
|
353
|
-
});
|
|
354
|
-
(0, utils_1.handleError)(this.transport, res, "Could not load xpubs from Trezor");
|
|
355
|
-
return res.payload.map((result, i) => {
|
|
356
|
-
const scriptType = msg[i].scriptType;
|
|
357
|
-
switch (scriptType) {
|
|
358
|
-
case core.BTCInputScriptType.SpendP2SHWitness:
|
|
359
|
-
case core.BTCInputScriptType.SpendWitness: {
|
|
360
|
-
const xpub = result.xpubSegwit;
|
|
361
|
-
if (!xpub)
|
|
362
|
-
throw new Error("unable to get public key");
|
|
363
|
-
return {
|
|
364
|
-
xpub,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
case core.BTCInputScriptType.SpendAddress:
|
|
368
|
-
default: {
|
|
369
|
-
const xpub = result.xpub;
|
|
370
|
-
if (!xpub)
|
|
371
|
-
throw new Error("unable to get public key");
|
|
372
|
-
return {
|
|
373
|
-
xpub,
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
316
|
}
|
|
377
|
-
}
|
|
317
|
+
}
|
|
378
318
|
});
|
|
379
319
|
}
|
|
380
|
-
isLocked() {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return false;
|
|
388
|
-
});
|
|
320
|
+
async isLocked() {
|
|
321
|
+
const features = await this.getFeatures(false);
|
|
322
|
+
if (features.pin_protection && !features.pin_cached)
|
|
323
|
+
return true;
|
|
324
|
+
if (features.passphrase_protection && !features.passphrase_cached)
|
|
325
|
+
return true;
|
|
326
|
+
return false;
|
|
389
327
|
}
|
|
390
|
-
clearSession() {
|
|
391
|
-
|
|
392
|
-
// TrezorConnect doesn't expose session management, so this is a no-op.
|
|
393
|
-
});
|
|
328
|
+
async clearSession() {
|
|
329
|
+
// TrezorConnect doesn't expose session management, so this is a no-op.
|
|
394
330
|
}
|
|
395
|
-
sendPin(pin) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
payload: pin,
|
|
400
|
-
});
|
|
331
|
+
async sendPin(pin) {
|
|
332
|
+
await this.transport.call("uiResponse", {
|
|
333
|
+
type: "ui-receive_pin",
|
|
334
|
+
payload: pin,
|
|
401
335
|
});
|
|
402
336
|
}
|
|
403
|
-
sendPassphrase(passphrase) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
},
|
|
411
|
-
});
|
|
337
|
+
async sendPassphrase(passphrase) {
|
|
338
|
+
await this.transport.call("uiResponse", {
|
|
339
|
+
type: "ui-receive_passphrase",
|
|
340
|
+
payload: {
|
|
341
|
+
value: passphrase,
|
|
342
|
+
save: true,
|
|
343
|
+
},
|
|
412
344
|
});
|
|
413
345
|
}
|
|
414
346
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
415
|
-
sendCharacter(charater) {
|
|
416
|
-
|
|
417
|
-
throw new Error("Trezor does not suport chiphered recovery");
|
|
418
|
-
});
|
|
347
|
+
async sendCharacter(charater) {
|
|
348
|
+
throw new Error("Trezor does not suport chiphered recovery");
|
|
419
349
|
}
|
|
420
350
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
421
|
-
sendWord(word) {
|
|
422
|
-
|
|
423
|
-
throw new Error("Trezor does not yet support recoverDevice");
|
|
424
|
-
});
|
|
351
|
+
async sendWord(word) {
|
|
352
|
+
throw new Error("Trezor does not yet support recoverDevice");
|
|
425
353
|
}
|
|
426
|
-
ping(msg) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return { msg: msg.msg };
|
|
431
|
-
});
|
|
354
|
+
async ping(msg) {
|
|
355
|
+
// TrezorConnect doesn't expose the device's normal 'Core.Ping' message, so we
|
|
356
|
+
// have to fake it here:
|
|
357
|
+
return { msg: msg.msg };
|
|
432
358
|
}
|
|
433
|
-
wipe() {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
(0, utils_1.handleError)(this.transport, res, "Could not wipe Trezor");
|
|
437
|
-
});
|
|
359
|
+
async wipe() {
|
|
360
|
+
const res = await this.transport.call("wipeDevice", {});
|
|
361
|
+
handleError(this.transport, res, "Could not wipe Trezor");
|
|
438
362
|
}
|
|
439
|
-
reset(msg) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
passphraseProtection: msg.passphrase,
|
|
446
|
-
});
|
|
447
|
-
(0, utils_1.handleError)(this.transport, res, "Could not reset Trezor");
|
|
363
|
+
async reset(msg) {
|
|
364
|
+
const res = await this.transport.call("resetDevice", {
|
|
365
|
+
strength: msg.entropy,
|
|
366
|
+
label: msg.label,
|
|
367
|
+
pinProtection: msg.pin,
|
|
368
|
+
passphraseProtection: msg.passphrase,
|
|
448
369
|
});
|
|
370
|
+
handleError(this.transport, res, "Could not reset Trezor");
|
|
449
371
|
}
|
|
450
|
-
cancel() {
|
|
451
|
-
|
|
452
|
-
yield this.transport.cancel();
|
|
453
|
-
});
|
|
372
|
+
async cancel() {
|
|
373
|
+
await this.transport.cancel();
|
|
454
374
|
}
|
|
455
375
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
456
|
-
recover(msg) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
throw new Error("TrezorConnect does not expose Core.RecoverDevice... yet?");
|
|
460
|
-
});
|
|
376
|
+
async recover(msg) {
|
|
377
|
+
// https://github.com/trezor/connect/pull/320
|
|
378
|
+
throw new Error("TrezorConnect does not expose Core.RecoverDevice... yet?");
|
|
461
379
|
}
|
|
462
|
-
loadDevice(msg) {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
label: msg.label,
|
|
470
|
-
});
|
|
471
|
-
(0, utils_1.handleError)(this.transport, res, "Could not load seed into Trezor");
|
|
380
|
+
async loadDevice(msg) {
|
|
381
|
+
// https://github.com/trezor/connect/issues/363
|
|
382
|
+
const res = await this.transport.call("loadDevice", {
|
|
383
|
+
mnemonic: msg.mnemonic,
|
|
384
|
+
pin: msg.pin,
|
|
385
|
+
passphraseProtection: msg.passphrase,
|
|
386
|
+
label: msg.label,
|
|
472
387
|
});
|
|
388
|
+
handleError(this.transport, res, "Could not load seed into Trezor");
|
|
473
389
|
}
|
|
474
390
|
hasOnDevicePinEntry() {
|
|
475
391
|
return this.transport.hasPopup;
|
|
@@ -497,43 +413,29 @@ class TrezorHDWallet {
|
|
|
497
413
|
supportsBroadcast() {
|
|
498
414
|
return false;
|
|
499
415
|
}
|
|
500
|
-
btcSupportsCoin(coin) {
|
|
501
|
-
return
|
|
502
|
-
return this.info.btcSupportsCoin(coin);
|
|
503
|
-
});
|
|
416
|
+
async btcSupportsCoin(coin) {
|
|
417
|
+
return this.info.btcSupportsCoin(coin);
|
|
504
418
|
}
|
|
505
|
-
btcSupportsScriptType(coin, scriptType) {
|
|
506
|
-
return
|
|
507
|
-
return this.info.btcSupportsScriptType(coin, scriptType);
|
|
508
|
-
});
|
|
419
|
+
async btcSupportsScriptType(coin, scriptType) {
|
|
420
|
+
return this.info.btcSupportsScriptType(coin, scriptType);
|
|
509
421
|
}
|
|
510
|
-
btcGetAddress(msg) {
|
|
511
|
-
return
|
|
512
|
-
return Btc.btcGetAddress(this.transport, msg);
|
|
513
|
-
});
|
|
422
|
+
async btcGetAddress(msg) {
|
|
423
|
+
return Btc.btcGetAddress(this.transport, msg);
|
|
514
424
|
}
|
|
515
|
-
btcSignTx(msg) {
|
|
516
|
-
return
|
|
517
|
-
return Btc.btcSignTx(this, this.transport, msg);
|
|
518
|
-
});
|
|
425
|
+
async btcSignTx(msg) {
|
|
426
|
+
return Btc.btcSignTx(this, this.transport, msg);
|
|
519
427
|
}
|
|
520
|
-
btcSupportsSecureTransfer() {
|
|
521
|
-
return
|
|
522
|
-
return this.info.btcSupportsSecureTransfer();
|
|
523
|
-
});
|
|
428
|
+
async btcSupportsSecureTransfer() {
|
|
429
|
+
return this.info.btcSupportsSecureTransfer();
|
|
524
430
|
}
|
|
525
431
|
btcSupportsNativeShapeShift() {
|
|
526
432
|
return this.info.btcSupportsNativeShapeShift();
|
|
527
433
|
}
|
|
528
|
-
btcSignMessage(msg) {
|
|
529
|
-
return
|
|
530
|
-
return Btc.btcSignMessage(this.transport, msg);
|
|
531
|
-
});
|
|
434
|
+
async btcSignMessage(msg) {
|
|
435
|
+
return Btc.btcSignMessage(this.transport, msg);
|
|
532
436
|
}
|
|
533
|
-
btcVerifyMessage(msg) {
|
|
534
|
-
return
|
|
535
|
-
return Btc.btcVerifyMessage(this.transport, msg);
|
|
536
|
-
});
|
|
437
|
+
async btcVerifyMessage(msg) {
|
|
438
|
+
return Btc.btcVerifyMessage(this.transport, msg);
|
|
537
439
|
}
|
|
538
440
|
btcGetAccountPaths(msg) {
|
|
539
441
|
return Btc.btcGetAccountPaths(msg);
|
|
@@ -541,43 +443,29 @@ class TrezorHDWallet {
|
|
|
541
443
|
btcIsSameAccount(msg) {
|
|
542
444
|
return this.info.btcIsSameAccount(msg);
|
|
543
445
|
}
|
|
544
|
-
ethSignTx(msg) {
|
|
545
|
-
return
|
|
546
|
-
return Eth.ethSignTx(this, this.transport, msg);
|
|
547
|
-
});
|
|
446
|
+
async ethSignTx(msg) {
|
|
447
|
+
return Eth.ethSignTx(this, this.transport, msg);
|
|
548
448
|
}
|
|
549
|
-
ethGetAddress(msg) {
|
|
550
|
-
return
|
|
551
|
-
return Eth.ethGetAddress(this.transport, msg);
|
|
552
|
-
});
|
|
449
|
+
async ethGetAddress(msg) {
|
|
450
|
+
return Eth.ethGetAddress(this.transport, msg);
|
|
553
451
|
}
|
|
554
|
-
ethSignMessage(msg) {
|
|
555
|
-
return
|
|
556
|
-
return Eth.ethSignMessage(this.transport, msg);
|
|
557
|
-
});
|
|
452
|
+
async ethSignMessage(msg) {
|
|
453
|
+
return Eth.ethSignMessage(this.transport, msg);
|
|
558
454
|
}
|
|
559
|
-
ethVerifyMessage(msg) {
|
|
560
|
-
return
|
|
561
|
-
return Eth.ethVerifyMessage(this.transport, msg);
|
|
562
|
-
});
|
|
455
|
+
async ethVerifyMessage(msg) {
|
|
456
|
+
return Eth.ethVerifyMessage(this.transport, msg);
|
|
563
457
|
}
|
|
564
|
-
ethSupportsNetwork(chain_id) {
|
|
565
|
-
return
|
|
566
|
-
return this.info.ethSupportsNetwork(chain_id);
|
|
567
|
-
});
|
|
458
|
+
async ethSupportsNetwork(chain_id) {
|
|
459
|
+
return this.info.ethSupportsNetwork(chain_id);
|
|
568
460
|
}
|
|
569
|
-
ethSupportsSecureTransfer() {
|
|
570
|
-
return
|
|
571
|
-
return this.info.ethSupportsSecureTransfer();
|
|
572
|
-
});
|
|
461
|
+
async ethSupportsSecureTransfer() {
|
|
462
|
+
return this.info.ethSupportsSecureTransfer();
|
|
573
463
|
}
|
|
574
464
|
ethSupportsNativeShapeShift() {
|
|
575
465
|
return this.info.ethSupportsNativeShapeShift();
|
|
576
466
|
}
|
|
577
|
-
ethSupportsEIP1559() {
|
|
578
|
-
return
|
|
579
|
-
return yield this.info.ethSupportsEIP1559();
|
|
580
|
-
});
|
|
467
|
+
async ethSupportsEIP1559() {
|
|
468
|
+
return await this.info.ethSupportsEIP1559();
|
|
581
469
|
}
|
|
582
470
|
ethGetAccountPaths(msg) {
|
|
583
471
|
return this.info.ethGetAccountPaths(msg);
|
|
@@ -595,13 +483,10 @@ class TrezorHDWallet {
|
|
|
595
483
|
return this.info.ethNextAccountPath(msg);
|
|
596
484
|
}
|
|
597
485
|
}
|
|
598
|
-
|
|
599
|
-
function info() {
|
|
486
|
+
export function info() {
|
|
600
487
|
return new TrezorHDWalletInfo();
|
|
601
488
|
}
|
|
602
|
-
|
|
603
|
-
function create(transport) {
|
|
489
|
+
export function create(transport) {
|
|
604
490
|
return new TrezorHDWallet(transport);
|
|
605
491
|
}
|
|
606
|
-
exports.create = create;
|
|
607
492
|
//# sourceMappingURL=trezor.js.map
|