@trezor/connect 9.0.11 → 9.1.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 +22 -3
- package/README.md +20 -3
- 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/createPendingTx.d.ts +1 -0
- package/lib/api/bitcoin/createPendingTx.js +1 -0
- 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 +8 -0
- package/lib/api/cancelCoinjoinAuthorization.js +27 -0
- 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 +2 -0
- package/lib/api/cardanoGetPublicKey.js +12 -1
- 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 +5 -2
- 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 +3 -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 +2 -0
- package/lib/api/getPublicKey.js +12 -1
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +6 -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 +4 -2
- 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 +8 -0
- package/lib/api/showDeviceTutorial.js +23 -0
- 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/errors.d.ts +0 -3
- package/lib/constants/errors.js +1 -4
- 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.d.ts +5 -6
- package/lib/core/index.js +53 -51
- package/lib/core/method.d.ts +1 -1
- package/lib/data/DataManager.js +4 -1
- package/lib/data/analyticsInfo.js +1 -1
- package/lib/data/coinInfo.d.ts +9 -1
- package/lib/data/coinInfo.js +16 -54
- package/lib/data/config.js +12 -2
- 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 +10 -12
- package/lib/device/Device.js +69 -102
- package/lib/device/DeviceCommands.d.ts +4 -3
- package/lib/device/DeviceCommands.js +46 -19
- package/lib/device/DeviceList.d.ts +15 -25
- package/lib/device/DeviceList.js +224 -258
- package/lib/events/popup.d.ts +8 -1
- package/lib/events/popup.js +1 -0
- package/lib/events/transport.d.ts +2 -9
- package/lib/events/transport.js +3 -10
- package/lib/events/ui-request.d.ts +2 -2
- package/lib/factory.js +2 -0
- package/lib/index.js +7 -7
- 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/api/cancelCoinjoinAuthorization.d.ts +8 -0
- package/lib/types/api/cancelCoinjoinAuthorization.js +3 -0
- package/lib/types/api/index.d.ts +4 -0
- package/lib/types/api/showDeviceTutorial.d.ts +4 -0
- package/lib/types/api/showDeviceTutorial.js +3 -0
- package/lib/types/coinInfo.d.ts +5 -17
- package/lib/types/device.d.ts +5 -2
- package/lib/types/device.js +8 -0
- 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/types/settings.d.ts +1 -1
- package/lib/utils/assetUtils.js +3 -1
- package/lib/utils/debug.js +2 -1
- package/lib/utils/deviceFeaturesUtils.d.ts +2 -1
- package/lib/utils/deviceFeaturesUtils.js +12 -1
- package/lib/utils/urlUtils.d.ts +10 -3
- package/lib/utils/urlUtils.js +5 -9
- package/lib/workers/workers-browser.d.ts +1 -3
- package/lib/workers/workers-browser.js +1 -7
- package/lib/workers/workers-react-native.d.ts +1 -3
- package/lib/workers/workers-react-native.js +1 -7
- package/lib/workers/workers.d.ts +1 -5
- package/lib/workers/workers.js +1 -5
- package/package.json +17 -12
- package/lib/device/DescriptorStream.d.ts +0 -28
- package/lib/device/DescriptorStream.js +0 -139
- package/lib/utils/objectUtils.d.ts +0 -10
- package/lib/utils/objectUtils.js +0 -37
- package/lib/workers/RNUsbPlugin.d.ts +0 -31
- package/lib/workers/RNUsbPlugin.js +0 -65
package/lib/core/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initTransport = exports.
|
|
3
|
+
exports.initTransport = exports.initCore = exports.Core = exports.onCall = exports.handleMessage = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
|
+
const transport_1 = require("@trezor/transport");
|
|
6
7
|
const DataManager_1 = require("../data/DataManager");
|
|
7
8
|
const DeviceList_1 = require("../device/DeviceList");
|
|
8
9
|
const analyticsInfo_1 = require("../data/analyticsInfo");
|
|
@@ -22,6 +23,7 @@ const _callMethods = [];
|
|
|
22
23
|
let _preferredDevice;
|
|
23
24
|
let _interactionTimeout;
|
|
24
25
|
let _deviceListInitTimeout;
|
|
26
|
+
let _overridePromise;
|
|
25
27
|
const _log = (0, debug_1.initLog)('Core');
|
|
26
28
|
const postMessage = (message) => {
|
|
27
29
|
if (message.event === events_2.RESPONSE_EVENT) {
|
|
@@ -54,17 +56,8 @@ const findUiPromise = (promiseEvent) => _uiPromises.find(p => p.id === promiseEv
|
|
|
54
56
|
const removeUiPromise = (promise) => {
|
|
55
57
|
_uiPromises = _uiPromises.filter(p => p !== promise);
|
|
56
58
|
};
|
|
57
|
-
const handleMessage = (message
|
|
58
|
-
_log.debug('handleMessage',
|
|
59
|
-
const safeMessages = [
|
|
60
|
-
events_2.IFRAME.CALL,
|
|
61
|
-
events_2.POPUP.CLOSED,
|
|
62
|
-
events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
63
|
-
events_2.TRANSPORT.DISABLE_WEBUSB,
|
|
64
|
-
];
|
|
65
|
-
if (!isTrustedOrigin && safeMessages.indexOf(message.type) === -1) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
59
|
+
const handleMessage = (message) => {
|
|
60
|
+
_log.debug('handleMessage', message);
|
|
68
61
|
switch (message.type) {
|
|
69
62
|
case events_2.POPUP.HANDSHAKE:
|
|
70
63
|
getPopupPromise(false).resolve();
|
|
@@ -72,10 +65,10 @@ const handleMessage = (message, isTrustedOrigin = false) => {
|
|
|
72
65
|
case events_2.POPUP.CLOSED:
|
|
73
66
|
onPopupClosed(message.payload ? message.payload.error : null);
|
|
74
67
|
break;
|
|
75
|
-
case
|
|
68
|
+
case transport_1.TRANSPORT.DISABLE_WEBUSB:
|
|
76
69
|
disableWebUSBTransport();
|
|
77
70
|
break;
|
|
78
|
-
case
|
|
71
|
+
case transport_1.TRANSPORT.REQUEST_DEVICE:
|
|
79
72
|
_deviceList === null || _deviceList === void 0 ? void 0 : _deviceList.enumerate();
|
|
80
73
|
break;
|
|
81
74
|
case events_2.UI.RECEIVE_DEVICE:
|
|
@@ -173,13 +166,17 @@ const onCall = async (message) => {
|
|
|
173
166
|
method.getPopupPromise = getPopupPromise;
|
|
174
167
|
method.createUiPromise = createUiPromise;
|
|
175
168
|
method.init();
|
|
169
|
+
_callMethods.push(method);
|
|
170
|
+
if (method.initAsync) {
|
|
171
|
+
method.initAsyncPromise = method.initAsync();
|
|
172
|
+
await method.initAsyncPromise;
|
|
173
|
+
}
|
|
176
174
|
}
|
|
177
175
|
catch (error) {
|
|
178
176
|
postMessage((0, events_2.createPopupMessage)(events_2.POPUP.CANCEL_POPUP_REQUEST));
|
|
179
177
|
postMessage((0, events_2.createResponseMessage)(responseID, false, { error }));
|
|
180
178
|
return Promise.resolve();
|
|
181
179
|
}
|
|
182
|
-
_callMethods.push(method);
|
|
183
180
|
if (!method.useDevice) {
|
|
184
181
|
try {
|
|
185
182
|
if (method.useUi) {
|
|
@@ -230,7 +227,8 @@ const onCall = async (message) => {
|
|
|
230
227
|
call.overridden = true;
|
|
231
228
|
});
|
|
232
229
|
const overrideError = constants_1.ERRORS.TypedError('Method_Override');
|
|
233
|
-
|
|
230
|
+
_overridePromise = device.override(overrideError);
|
|
231
|
+
await _overridePromise;
|
|
234
232
|
if (method.overridden) {
|
|
235
233
|
postMessage((0, events_2.createResponseMessage)(method.responseID, false, { error: overrideError }));
|
|
236
234
|
throw overrideError;
|
|
@@ -313,6 +311,7 @@ const onCall = async (message) => {
|
|
|
313
311
|
return Promise.reject(constants_1.ERRORS.TypedError('Method_Cancel'));
|
|
314
312
|
}
|
|
315
313
|
}
|
|
314
|
+
const isDeviceUnlocked = device.features.unlocked;
|
|
316
315
|
try {
|
|
317
316
|
const invalidDeviceState = method.useDeviceState
|
|
318
317
|
? await device.validateState(method.network, method.preauthorized)
|
|
@@ -337,8 +336,7 @@ const onCall = async (message) => {
|
|
|
337
336
|
}
|
|
338
337
|
}
|
|
339
338
|
catch (error) {
|
|
340
|
-
if (error.message ===
|
|
341
|
-
PIN_TRIES < MAX_PIN_TRIES) {
|
|
339
|
+
if (error.message === 'PIN invalid' && PIN_TRIES < MAX_PIN_TRIES) {
|
|
342
340
|
PIN_TRIES++;
|
|
343
341
|
postMessage((0, events_2.createUiMessage)(events_2.UI.INVALID_PIN, { device: device.toMessageObject() }));
|
|
344
342
|
return inner();
|
|
@@ -346,6 +344,9 @@ const onCall = async (message) => {
|
|
|
346
344
|
device.setInternalState(undefined);
|
|
347
345
|
return Promise.reject(error);
|
|
348
346
|
}
|
|
347
|
+
if (!isDeviceUnlocked && device.features.unlocked) {
|
|
348
|
+
postMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CHANGED, device.toMessageObject()));
|
|
349
|
+
}
|
|
349
350
|
if (method.useUi) {
|
|
350
351
|
await getPopupPromise().promise;
|
|
351
352
|
}
|
|
@@ -360,6 +361,9 @@ const onCall = async (message) => {
|
|
|
360
361
|
return Promise.reject(error);
|
|
361
362
|
}
|
|
362
363
|
};
|
|
364
|
+
if (_overridePromise) {
|
|
365
|
+
await _overridePromise;
|
|
366
|
+
}
|
|
363
367
|
await device.run(inner, {
|
|
364
368
|
keepSession: method.keepSession,
|
|
365
369
|
useEmptyPassphrase: method.useEmptyPassphrase,
|
|
@@ -372,13 +376,16 @@ const onCall = async (message) => {
|
|
|
372
376
|
_deviceList.addAuthPenalty(device);
|
|
373
377
|
}
|
|
374
378
|
if (method) {
|
|
375
|
-
if (_deviceList && error.message ===
|
|
376
|
-
_deviceList.enumerate();
|
|
379
|
+
if (_deviceList && error.message === transport_1.TRANSPORT_ERROR.SESSION_WRONG_PREVIOUS) {
|
|
380
|
+
await _deviceList.enumerate();
|
|
377
381
|
}
|
|
378
382
|
messageResponse = (0, events_2.createResponseMessage)(method.responseID, false, { error });
|
|
379
383
|
}
|
|
380
384
|
}
|
|
381
385
|
finally {
|
|
386
|
+
if (_overridePromise) {
|
|
387
|
+
await _overridePromise;
|
|
388
|
+
}
|
|
382
389
|
const response = messageResponse;
|
|
383
390
|
if (response) {
|
|
384
391
|
if (method.name === 'rebootToBootloader' && response.success) {
|
|
@@ -469,7 +476,7 @@ const onPopupClosed = (customErrorMessage) => {
|
|
|
469
476
|
_deviceList.allDevices().forEach(d => {
|
|
470
477
|
d.keepSession = false;
|
|
471
478
|
if (d.isUsedHere()) {
|
|
472
|
-
d.interruptionFromUser(error);
|
|
479
|
+
_overridePromise = d.interruptionFromUser(error);
|
|
473
480
|
}
|
|
474
481
|
else {
|
|
475
482
|
const uiPromise = findUiPromise(events_2.DEVICE.DISCONNECT);
|
|
@@ -557,30 +564,31 @@ const initDeviceList = async (settings) => {
|
|
|
557
564
|
_deviceList.on(events_2.DEVICE.CHANGED, device => {
|
|
558
565
|
postMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CHANGED, device));
|
|
559
566
|
});
|
|
560
|
-
_deviceList.on(
|
|
567
|
+
_deviceList.on(transport_1.TRANSPORT.ERROR, error => {
|
|
561
568
|
_log.warn('TRANSPORT.ERROR', error);
|
|
562
569
|
if (_deviceList) {
|
|
563
570
|
_deviceList.disconnectDevices();
|
|
564
571
|
_deviceList.dispose();
|
|
565
572
|
}
|
|
566
573
|
_deviceList = undefined;
|
|
567
|
-
postMessage((0, events_2.createTransportMessage)(
|
|
574
|
+
postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.ERROR, { error }));
|
|
568
575
|
if (settings.transportReconnect) {
|
|
569
576
|
const { promise, timeout } = (0, promiseUtils_1.resolveAfter)(1000, null);
|
|
570
577
|
_deviceListInitTimeout = timeout;
|
|
571
|
-
|
|
572
|
-
|
|
578
|
+
promise.then(() => {
|
|
579
|
+
initDeviceList(settings);
|
|
580
|
+
});
|
|
573
581
|
}
|
|
574
582
|
});
|
|
575
|
-
_deviceList.on(
|
|
576
|
-
|
|
583
|
+
_deviceList.on(transport_1.TRANSPORT.START, transportType => postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.START, transportType)));
|
|
584
|
+
_deviceList.init();
|
|
577
585
|
if (_deviceList) {
|
|
578
586
|
await _deviceList.waitForTransportFirstEvent();
|
|
579
587
|
}
|
|
580
588
|
}
|
|
581
589
|
catch (error) {
|
|
582
590
|
_deviceList = undefined;
|
|
583
|
-
postMessage((0, events_2.createTransportMessage)(
|
|
591
|
+
postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.ERROR, { error }));
|
|
584
592
|
if (!settings.transportReconnect) {
|
|
585
593
|
throw error;
|
|
586
594
|
}
|
|
@@ -593,8 +601,8 @@ const initDeviceList = async (settings) => {
|
|
|
593
601
|
}
|
|
594
602
|
};
|
|
595
603
|
class Core extends events_1.default {
|
|
596
|
-
handleMessage(message
|
|
597
|
-
(0, exports.handleMessage)(message
|
|
604
|
+
handleMessage(message) {
|
|
605
|
+
(0, exports.handleMessage)(message);
|
|
598
606
|
}
|
|
599
607
|
async dispose() {
|
|
600
608
|
(0, BlockchainLink_1.dispose)();
|
|
@@ -610,27 +618,18 @@ class Core extends events_1.default {
|
|
|
610
618
|
return _callMethods;
|
|
611
619
|
}
|
|
612
620
|
getTransportInfo() {
|
|
613
|
-
if (_deviceList) {
|
|
614
|
-
return
|
|
621
|
+
if (!_deviceList) {
|
|
622
|
+
return undefined;
|
|
615
623
|
}
|
|
616
|
-
return
|
|
617
|
-
type: '',
|
|
618
|
-
version: '',
|
|
619
|
-
outdated: true,
|
|
620
|
-
};
|
|
624
|
+
return _deviceList.getTransportInfo();
|
|
621
625
|
}
|
|
622
626
|
}
|
|
623
627
|
exports.Core = Core;
|
|
624
|
-
const initCore = () => {
|
|
625
|
-
_core = new Core();
|
|
626
|
-
return _core;
|
|
627
|
-
};
|
|
628
|
-
exports.initCore = initCore;
|
|
629
|
-
const init = async (settings) => {
|
|
628
|
+
const initCore = async (settings) => {
|
|
630
629
|
try {
|
|
631
630
|
await DataManager_1.DataManager.load(settings);
|
|
632
631
|
(0, debug_1.enableLog)(DataManager_1.DataManager.getSettings('debug'));
|
|
633
|
-
|
|
632
|
+
_core = new Core();
|
|
634
633
|
_interactionTimeout = new interactionTimeout_1.InteractionTimeout(settings.popup ? settings.interactionTimeout : 0);
|
|
635
634
|
return _core;
|
|
636
635
|
}
|
|
@@ -639,7 +638,7 @@ const init = async (settings) => {
|
|
|
639
638
|
throw error;
|
|
640
639
|
}
|
|
641
640
|
};
|
|
642
|
-
exports.
|
|
641
|
+
exports.initCore = initCore;
|
|
643
642
|
const initTransport = async (settings) => {
|
|
644
643
|
try {
|
|
645
644
|
if (!settings.transportReconnect) {
|
|
@@ -656,17 +655,20 @@ const initTransport = async (settings) => {
|
|
|
656
655
|
};
|
|
657
656
|
exports.initTransport = initTransport;
|
|
658
657
|
const disableWebUSBTransport = async () => {
|
|
659
|
-
var _a
|
|
658
|
+
var _a;
|
|
660
659
|
if (!_deviceList)
|
|
661
660
|
return;
|
|
662
661
|
if (_deviceList.transportType() !== 'WebUsbTransport')
|
|
663
662
|
return;
|
|
664
663
|
const settings = DataManager_1.DataManager.getSettings();
|
|
665
|
-
if (
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
664
|
+
if (settings.transports) {
|
|
665
|
+
const transportStr = (_a = settings.transports) === null || _a === void 0 ? void 0 : _a.filter(transport => typeof transport !== 'object');
|
|
666
|
+
if (transportStr.includes('WebUsbTransport')) {
|
|
667
|
+
settings.transports.splice(settings.transports.indexOf('WebUsbTransport'), 1);
|
|
668
|
+
}
|
|
669
|
+
if (!transportStr.includes('BridgeTransport')) {
|
|
670
|
+
settings.transports.unshift('BridgeTransport');
|
|
671
|
+
}
|
|
670
672
|
}
|
|
671
673
|
try {
|
|
672
674
|
await _deviceList.dispose();
|
package/lib/core/method.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import * as Methods from '../api';
|
|
|
2
2
|
import type { IFrameCallMessage } from '../events';
|
|
3
3
|
export declare const getMethod: (message: IFrameCallMessage & {
|
|
4
4
|
id?: number;
|
|
5
|
-
}) => Methods.applyFlags | Methods.applySettings | Methods.authorizeCoinjoin | Methods.backupDevice | Methods.binanceGetAddress | Methods.binanceGetPublicKey | Methods.binanceSignTransaction | Methods.blockchainDisconnect | Methods.blockchainEstimateFee | Methods.blockchainGetAccountBalanceHistory | Methods.blockchainGetCurrentFiatRates | Methods.blockchainGetFiatRatesForTimestamps | Methods.blockchainGetTransactions | Methods.blockchainSetCustomBackend | Methods.blockchainSubscribe | Methods.blockchainSubscribeFiatRates | Methods.blockchainUnsubscribe | Methods.blockchainUnsubscribeFiatRates | Methods.cardanoGetAddress | Methods.cardanoGetNativeScriptHash | Methods.cardanoGetPublicKey | Methods.cardanoSignTransaction | Methods.changePin | Methods.cipherKeyValue | Methods.composeTransaction | Methods.eosGetPublicKey | Methods.eosSignTransaction | Methods.ethereumGetAddress | Methods.ethereumGetPublicKey | Methods.ethereumSignMessage | Methods.ethereumSignTransaction | Methods.ethereumSignTypedData | Methods.ethereumVerifyMessage | Methods.firmwareUpdate | Methods.getAccountInfo | Methods.getAddress | Methods.getCoinInfo | Methods.getDeviceState | Methods.getFeatures | Methods.getFirmwareHash | Methods.getOwnershipId | Methods.getOwnershipProof | Methods.getPublicKey | Methods.getSettings | Methods.nemGetAddress | Methods.nemSignTransaction | Methods.pushTransaction | Methods.rebootToBootloader | Methods.recoveryDevice | Methods.requestLogin | Methods.resetDevice | Methods.rippleGetAddress | Methods.rippleSignTransaction | Methods.setBusy | Methods.setProxy | Methods.signMessage | Methods.signTransaction | Methods.stellarGetAddress | Methods.stellarSignTransaction | Methods.tezosGetAddress | Methods.tezosGetPublicKey | Methods.tezosSignTransaction | Methods.unlockPath | Methods.verifyMessage | Methods.wipeDevice | Methods.checkFirmwareAuthenticity;
|
|
5
|
+
}) => Methods.applyFlags | Methods.applySettings | Methods.authorizeCoinjoin | Methods.cancelCoinjoinAuthorization | Methods.showDeviceTutorial | Methods.backupDevice | Methods.binanceGetAddress | Methods.binanceGetPublicKey | Methods.binanceSignTransaction | Methods.blockchainDisconnect | Methods.blockchainEstimateFee | Methods.blockchainGetAccountBalanceHistory | Methods.blockchainGetCurrentFiatRates | Methods.blockchainGetFiatRatesForTimestamps | Methods.blockchainGetTransactions | Methods.blockchainSetCustomBackend | Methods.blockchainSubscribe | Methods.blockchainSubscribeFiatRates | Methods.blockchainUnsubscribe | Methods.blockchainUnsubscribeFiatRates | Methods.cardanoGetAddress | Methods.cardanoGetNativeScriptHash | Methods.cardanoGetPublicKey | Methods.cardanoSignTransaction | Methods.changePin | Methods.cipherKeyValue | Methods.composeTransaction | Methods.eosGetPublicKey | Methods.eosSignTransaction | Methods.ethereumGetAddress | Methods.ethereumGetPublicKey | Methods.ethereumSignMessage | Methods.ethereumSignTransaction | Methods.ethereumSignTypedData | Methods.ethereumVerifyMessage | Methods.firmwareUpdate | Methods.getAccountInfo | Methods.getAddress | Methods.getCoinInfo | Methods.getDeviceState | Methods.getFeatures | Methods.getFirmwareHash | Methods.getOwnershipId | Methods.getOwnershipProof | Methods.getPublicKey | Methods.getSettings | Methods.nemGetAddress | Methods.nemSignTransaction | Methods.pushTransaction | Methods.rebootToBootloader | Methods.recoveryDevice | Methods.requestLogin | Methods.resetDevice | Methods.rippleGetAddress | Methods.rippleSignTransaction | Methods.setBusy | Methods.setProxy | Methods.signMessage | Methods.signTransaction | Methods.stellarGetAddress | Methods.stellarSignTransaction | Methods.tezosGetAddress | Methods.tezosGetPublicKey | Methods.tezosSignTransaction | Methods.unlockPath | Methods.verifyMessage | Methods.wipeDevice | Methods.checkFirmwareAuthenticity;
|
|
6
6
|
//# sourceMappingURL=method.d.ts.map
|
package/lib/data/DataManager.js
CHANGED
|
@@ -19,7 +19,10 @@ class DataManager {
|
|
|
19
19
|
await Promise.all(assetPromises);
|
|
20
20
|
this.messages = await (0, assets_1.httpRequest)(`${config_1.config.messages}${ts}`, 'json');
|
|
21
21
|
(0, transportInfo_1.parseBridgeJSON)(this.assets.bridge);
|
|
22
|
-
(0, coinInfo_1.parseCoinsJson)(
|
|
22
|
+
(0, coinInfo_1.parseCoinsJson)({
|
|
23
|
+
...this.assets.coins,
|
|
24
|
+
eth: this.assets.coinsEth,
|
|
25
|
+
});
|
|
23
26
|
(0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t1'], 1);
|
|
24
27
|
(0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t2'], 2);
|
|
25
28
|
}
|
|
@@ -19,7 +19,7 @@ const enhancePostMessageWithAnalytics = (callback, message, data) => {
|
|
|
19
19
|
passphraseProtection: ((_b = device === null || device === void 0 ? void 0 : device.features) === null || _b === void 0 ? void 0 : _b.passphrase_protection) || '',
|
|
20
20
|
backupType: ((_c = device === null || device === void 0 ? void 0 : device.features) === null || _c === void 0 ? void 0 : _c.backup_type) || 'Bip39',
|
|
21
21
|
language: ((_d = device === null || device === void 0 ? void 0 : device.features) === null || _d === void 0 ? void 0 : _d.language) || '',
|
|
22
|
-
model: ((_e = device === null || device === void 0 ? void 0 : device.features) === null || _e === void 0 ? void 0 : _e.
|
|
22
|
+
model: ((_e = device === null || device === void 0 ? void 0 : device.features) === null || _e === void 0 ? void 0 : _e.internal_model) || '',
|
|
23
23
|
vendor: ((_f = device === null || device === void 0 ? void 0 : device.features) === null || _f === void 0 ? void 0 : _f.vendor) || '',
|
|
24
24
|
firmwareRevision: ((_g = device === null || device === void 0 ? void 0 : device.features) === null || _g === void 0 ? void 0 : _g.revision) || '',
|
|
25
25
|
firmwareType: (device === null || device === void 0 ? void 0 : device.firmwareType) || '',
|
package/lib/data/coinInfo.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CoinInfo, BitcoinNetworkInfo, EthereumNetworkInfo, MiscNetworkInfo } from '../types/coinInfo';
|
|
2
|
-
export declare function cloneCoinInfo<T>(info: T): T;
|
|
3
2
|
export declare const getBitcoinNetwork: (pathOrName: number[] | string) => BitcoinNetworkInfo | undefined;
|
|
4
3
|
export declare const getEthereumNetwork: (pathOrName: number[] | string) => EthereumNetworkInfo | undefined;
|
|
5
4
|
export declare const getMiscNetwork: (pathOrName: number[] | string) => MiscNetworkInfo | undefined;
|
|
@@ -31,6 +30,15 @@ export declare const fixCoinInfoNetwork: (ci: BitcoinNetworkInfo, path: number[]
|
|
|
31
30
|
export declare const getCoinInfoByHash: (hash: string, networkInfo: any) => BitcoinNetworkInfo;
|
|
32
31
|
export declare const getCoinInfo: (currency: string) => BitcoinNetworkInfo | EthereumNetworkInfo | MiscNetworkInfo | undefined;
|
|
33
32
|
export declare const getCoinName: (path: number[]) => string;
|
|
33
|
+
export declare const ethereumNetworkInfoBase: {
|
|
34
|
+
blockTime: number;
|
|
35
|
+
minFee: number;
|
|
36
|
+
maxFee: number;
|
|
37
|
+
dustLimit: number;
|
|
38
|
+
defaultFees: import("..").FeeLevel[];
|
|
39
|
+
type: "ethereum";
|
|
40
|
+
decimals: number;
|
|
41
|
+
};
|
|
34
42
|
export declare const parseCoinsJson: (json: any) => void;
|
|
35
43
|
export declare const getUniqueNetworks: (networks: (CoinInfo | undefined)[]) => CoinInfo[];
|
|
36
44
|
export declare const getAllNetworks: () => (BitcoinNetworkInfo | EthereumNetworkInfo | MiscNetworkInfo)[];
|
package/lib/data/coinInfo.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAllNetworks = exports.getUniqueNetworks = exports.parseCoinsJson = exports.getCoinName = exports.getCoinInfo = exports.getCoinInfoByHash = exports.fixCoinInfoNetwork = exports.getBech32Network = exports.getSegwitNetwork = exports.getMiscNetwork = exports.getEthereumNetwork = exports.getBitcoinNetwork =
|
|
3
|
+
exports.getAllNetworks = exports.getUniqueNetworks = exports.parseCoinsJson = exports.ethereumNetworkInfoBase = exports.getCoinName = exports.getCoinInfo = exports.getCoinInfoByHash = exports.fixCoinInfoNetwork = exports.getBech32Network = exports.getSegwitNetwork = exports.getMiscNetwork = exports.getEthereumNetwork = exports.getBitcoinNetwork = void 0;
|
|
4
|
+
const defaultFeeLevels_1 = require("./defaultFeeLevels");
|
|
4
5
|
const constants_1 = require("../constants");
|
|
5
6
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
7
|
+
const utils_1 = require("@trezor/utils");
|
|
6
8
|
const bitcoinNetworks = [];
|
|
7
9
|
const ethereumNetworks = [];
|
|
8
10
|
const miscNetworks = [];
|
|
9
|
-
function cloneCoinInfo(info) {
|
|
10
|
-
const jsonString = JSON.stringify(info);
|
|
11
|
-
if (jsonString === undefined) {
|
|
12
|
-
return info;
|
|
13
|
-
}
|
|
14
|
-
return JSON.parse(jsonString);
|
|
15
|
-
}
|
|
16
|
-
exports.cloneCoinInfo = cloneCoinInfo;
|
|
17
11
|
const getBitcoinNetwork = (pathOrName) => {
|
|
18
|
-
const networks =
|
|
12
|
+
const networks = (0, utils_1.cloneObject)(bitcoinNetworks);
|
|
19
13
|
if (typeof pathOrName === 'string') {
|
|
20
14
|
const name = pathOrName.toLowerCase();
|
|
21
15
|
return networks.find(n => n.name.toLowerCase() === name ||
|
|
@@ -27,7 +21,7 @@ const getBitcoinNetwork = (pathOrName) => {
|
|
|
27
21
|
};
|
|
28
22
|
exports.getBitcoinNetwork = getBitcoinNetwork;
|
|
29
23
|
const getEthereumNetwork = (pathOrName) => {
|
|
30
|
-
const networks =
|
|
24
|
+
const networks = (0, utils_1.cloneObject)(ethereumNetworks);
|
|
31
25
|
if (typeof pathOrName === 'string') {
|
|
32
26
|
const name = pathOrName.toLowerCase();
|
|
33
27
|
return networks.find(n => n.name.toLowerCase() === name || n.shortcut.toLowerCase() === name);
|
|
@@ -37,7 +31,7 @@ const getEthereumNetwork = (pathOrName) => {
|
|
|
37
31
|
};
|
|
38
32
|
exports.getEthereumNetwork = getEthereumNetwork;
|
|
39
33
|
const getMiscNetwork = (pathOrName) => {
|
|
40
|
-
const networks =
|
|
34
|
+
const networks = (0, utils_1.cloneObject)(miscNetworks);
|
|
41
35
|
if (typeof pathOrName === 'string') {
|
|
42
36
|
const name = pathOrName.toLowerCase();
|
|
43
37
|
return networks.find(n => n.name.toLowerCase() === name || n.shortcut.toLowerCase() === name);
|
|
@@ -73,7 +67,7 @@ const getBech32Network = (coin) => {
|
|
|
73
67
|
};
|
|
74
68
|
exports.getBech32Network = getBech32Network;
|
|
75
69
|
const fixCoinInfoNetwork = (ci, path) => {
|
|
76
|
-
const coinInfo =
|
|
70
|
+
const coinInfo = (0, utils_1.cloneObject)(ci);
|
|
77
71
|
if (path[0] === (0, pathUtils_1.toHardened)(84)) {
|
|
78
72
|
const bech32Network = (0, exports.getBech32Network)(coinInfo);
|
|
79
73
|
if (bech32Network) {
|
|
@@ -108,7 +102,7 @@ const detectBtcVersion = (data) => {
|
|
|
108
102
|
return 'btc';
|
|
109
103
|
};
|
|
110
104
|
const getCoinInfoByHash = (hash, networkInfo) => {
|
|
111
|
-
const networks =
|
|
105
|
+
const networks = (0, utils_1.cloneObject)(bitcoinNetworks);
|
|
112
106
|
const result = networks.find(info => hash.toLowerCase() === info.hashGenesisBlock.toLowerCase());
|
|
113
107
|
if (!result) {
|
|
114
108
|
throw constants_1.ERRORS.TypedError('Method_UnknownCoin', `Coin info not found for hash: ${hash} ${networkInfo.hashGenesisBlock}`);
|
|
@@ -158,14 +152,11 @@ const parseBitcoinNetworksJson = (json) => {
|
|
|
158
152
|
bitcoinNetworks.push({
|
|
159
153
|
type: 'bitcoin',
|
|
160
154
|
blockchainLink: coin.blockchain_link,
|
|
161
|
-
blocktime: Math.round(coin.blocktime_seconds / 60),
|
|
162
155
|
cashAddrPrefix: coin.cashaddr_prefix,
|
|
163
156
|
label: coin.coin_label,
|
|
164
157
|
name: coin.coin_name,
|
|
165
158
|
shortcut,
|
|
166
159
|
curveName: coin.curve_name,
|
|
167
|
-
defaultFees: coin.default_fee_b,
|
|
168
|
-
dustLimit: coin.dust_limit,
|
|
169
160
|
forceBip143: coin.force_bip143,
|
|
170
161
|
hashGenesisBlock: coin.hash_genesis_block,
|
|
171
162
|
maxAddressLength: coin.max_address_length,
|
|
@@ -181,74 +172,45 @@ const parseBitcoinNetworksJson = (json) => {
|
|
|
181
172
|
taproot: coin.taproot,
|
|
182
173
|
network,
|
|
183
174
|
isBitcoin,
|
|
184
|
-
maxFee: Math.round(coin.maxfee_kb / 1000),
|
|
185
|
-
minFee: Math.round(coin.minfee_kb / 1000),
|
|
186
|
-
blocks: Math.round(coin.blocktime_seconds / 60),
|
|
187
175
|
decimals: coin.decimals,
|
|
176
|
+
...(0, defaultFeeLevels_1.getBitcoinFeeLevels)(coin),
|
|
188
177
|
});
|
|
189
178
|
});
|
|
190
179
|
};
|
|
180
|
+
exports.ethereumNetworkInfoBase = {
|
|
181
|
+
type: 'ethereum',
|
|
182
|
+
decimals: 16,
|
|
183
|
+
...(0, defaultFeeLevels_1.getEthereumFeeLevels)(),
|
|
184
|
+
};
|
|
191
185
|
const parseEthereumNetworksJson = (json) => {
|
|
192
186
|
Object.keys(json).forEach(key => {
|
|
193
187
|
const network = json[key];
|
|
194
188
|
ethereumNetworks.push({
|
|
195
|
-
|
|
189
|
+
...exports.ethereumNetworkInfoBase,
|
|
196
190
|
blockchainLink: network.blockchain_link,
|
|
197
|
-
blocktime: -1,
|
|
198
|
-
chain: network.chain,
|
|
199
191
|
chainId: network.chain_id,
|
|
200
|
-
defaultFees: [
|
|
201
|
-
{
|
|
202
|
-
label: 'normal',
|
|
203
|
-
feePerUnit: '5000000000',
|
|
204
|
-
feeLimit: '21000',
|
|
205
|
-
},
|
|
206
|
-
],
|
|
207
|
-
minFee: 1,
|
|
208
|
-
maxFee: 10000,
|
|
209
192
|
label: network.name,
|
|
210
193
|
name: network.name,
|
|
211
194
|
shortcut: network.shortcut,
|
|
212
|
-
rskip60: network.rskip60,
|
|
213
195
|
slip44: network.slip44,
|
|
214
196
|
support: network.support,
|
|
215
|
-
network: undefined,
|
|
216
|
-
decimals: 16,
|
|
217
197
|
});
|
|
218
198
|
});
|
|
219
199
|
};
|
|
220
200
|
const parseMiscNetworksJSON = (json, type) => {
|
|
221
201
|
Object.keys(json).forEach(key => {
|
|
222
202
|
const network = json[key];
|
|
223
|
-
let minFee = -1;
|
|
224
|
-
let maxFee = -1;
|
|
225
|
-
let defaultFees = { Normal: -1 };
|
|
226
|
-
const shortcut = network.shortcut.toLowerCase();
|
|
227
|
-
if (shortcut === 'xrp' || shortcut === 'txrp') {
|
|
228
|
-
minFee = 10;
|
|
229
|
-
maxFee = 10000;
|
|
230
|
-
defaultFees = { Normal: 12 };
|
|
231
|
-
}
|
|
232
|
-
if (shortcut === 'ada' || shortcut === 'tada') {
|
|
233
|
-
minFee = 44;
|
|
234
|
-
maxFee = 16384 * 44 + 155381;
|
|
235
|
-
defaultFees = { Normal: 44 };
|
|
236
|
-
}
|
|
237
203
|
miscNetworks.push({
|
|
238
204
|
type: type || 'misc',
|
|
239
205
|
blockchainLink: network.blockchain_link,
|
|
240
|
-
blocktime: -1,
|
|
241
206
|
curve: network.curve,
|
|
242
|
-
defaultFees,
|
|
243
|
-
minFee,
|
|
244
|
-
maxFee,
|
|
245
207
|
label: network.name,
|
|
246
208
|
name: network.name,
|
|
247
209
|
shortcut: network.shortcut,
|
|
248
210
|
slip44: network.slip44,
|
|
249
211
|
support: network.support,
|
|
250
|
-
network: undefined,
|
|
251
212
|
decimals: network.decimals,
|
|
213
|
+
...(0, defaultFeeLevels_1.getMiscFeeLevels)(network),
|
|
252
214
|
});
|
|
253
215
|
});
|
|
254
216
|
};
|
package/lib/data/config.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.config = void 0;
|
|
4
4
|
const constants_1 = require("@trezor/transport/lib/constants");
|
|
5
5
|
exports.config = {
|
|
6
|
-
webusb: constants_1.
|
|
6
|
+
webusb: constants_1.TREZOR_USB_DESCRIPTORS,
|
|
7
7
|
whitelist: [
|
|
8
8
|
{ origin: 'chrome-extension://imloifkgjagghnncjkhggdhalmcnfklk', priority: 1 },
|
|
9
9
|
{ origin: 'chrome-extension://niebkpllfhmpfbffbfifagfgoamhpflf', priority: 1 },
|
|
@@ -47,6 +47,10 @@ exports.config = {
|
|
|
47
47
|
name: 'coins',
|
|
48
48
|
url: './data/coins.json',
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
name: 'coinsEth',
|
|
52
|
+
url: './data/coins-eth.json',
|
|
53
|
+
},
|
|
50
54
|
{
|
|
51
55
|
name: 'bridge',
|
|
52
56
|
url: './data/bridge/releases.json',
|
|
@@ -101,7 +105,7 @@ exports.config = {
|
|
|
101
105
|
],
|
|
102
106
|
},
|
|
103
107
|
{
|
|
104
|
-
coin: ['eth', 'tgor'],
|
|
108
|
+
coin: ['eth', 'tsep', 'tgor'],
|
|
105
109
|
min: ['1.8.0', '2.1.0'],
|
|
106
110
|
comment: ['There were protobuf backwards incompatible changes.'],
|
|
107
111
|
},
|
|
@@ -184,6 +188,7 @@ exports.config = {
|
|
|
184
188
|
capabilities: ['coinjoin'],
|
|
185
189
|
methods: [
|
|
186
190
|
'authorizeCoinjoin',
|
|
191
|
+
'cancelCoinjoinAuthorization',
|
|
187
192
|
'getOwnershipId',
|
|
188
193
|
'getOwnershipProof',
|
|
189
194
|
'setBusy',
|
|
@@ -191,6 +196,11 @@ exports.config = {
|
|
|
191
196
|
],
|
|
192
197
|
min: ['1.12.1', '2.5.3'],
|
|
193
198
|
},
|
|
199
|
+
{
|
|
200
|
+
methods: ['showDeviceTutorial'],
|
|
201
|
+
min: ['0', '2.6.1'],
|
|
202
|
+
comment: ['Only on T2B1'],
|
|
203
|
+
},
|
|
194
204
|
],
|
|
195
205
|
};
|
|
196
206
|
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FeeLevel, FeeInfo } from '../types';
|
|
2
|
+
interface CoinsJsonData {
|
|
3
|
+
shortcut: string;
|
|
4
|
+
blocktime_seconds: number;
|
|
5
|
+
default_fee_b: Record<'High' | 'Normal' | 'Economy' | 'Low', number>;
|
|
6
|
+
maxfee_kb: number;
|
|
7
|
+
minfee_kb: number;
|
|
8
|
+
dust_limit: number;
|
|
9
|
+
}
|
|
10
|
+
export type FeeInfoWithLevels = FeeInfo & {
|
|
11
|
+
defaultFees: FeeLevel[];
|
|
12
|
+
};
|
|
13
|
+
export declare const getBitcoinFeeLevels: (coin: CoinsJsonData) => FeeInfoWithLevels;
|
|
14
|
+
export declare const getEthereumFeeLevels: () => FeeInfoWithLevels;
|
|
15
|
+
export declare const getMiscFeeLevels: (data: CoinsJsonData) => FeeInfoWithLevels;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=defaultFeeLevels.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMiscFeeLevels = exports.getEthereumFeeLevels = exports.getBitcoinFeeLevels = void 0;
|
|
4
|
+
const BLOCKS_FOR_FEE_LEVEL = {
|
|
5
|
+
btc: {
|
|
6
|
+
high: 1,
|
|
7
|
+
normal: 6,
|
|
8
|
+
economy: 36,
|
|
9
|
+
low: 144,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
const getDefaultBlocksForFeeLevel = (shortcut, label) => BLOCKS_FOR_FEE_LEVEL[shortcut] && BLOCKS_FOR_FEE_LEVEL[shortcut][label]
|
|
13
|
+
? BLOCKS_FOR_FEE_LEVEL[shortcut][label]
|
|
14
|
+
: -1;
|
|
15
|
+
const getBitcoinFeeLevels = (coin) => {
|
|
16
|
+
const defaultFees = coin.default_fee_b;
|
|
17
|
+
const shortcut = coin.shortcut.toLowerCase();
|
|
18
|
+
const keys = Object.keys(defaultFees);
|
|
19
|
+
const levels = keys
|
|
20
|
+
.sort((levelA, levelB) => defaultFees[levelB] - defaultFees[levelA])
|
|
21
|
+
.map(level => {
|
|
22
|
+
const label = level.toLowerCase();
|
|
23
|
+
return {
|
|
24
|
+
label,
|
|
25
|
+
feePerUnit: defaultFees[level].toString(),
|
|
26
|
+
blocks: getDefaultBlocksForFeeLevel(shortcut, label),
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
blockTime: Math.max(1, Math.round(coin.blocktime_seconds / 60)),
|
|
31
|
+
dustLimit: coin.dust_limit,
|
|
32
|
+
maxFee: Math.round(coin.maxfee_kb / 1000),
|
|
33
|
+
minFee: Math.round(coin.minfee_kb / 1000),
|
|
34
|
+
defaultFees: levels,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.getBitcoinFeeLevels = getBitcoinFeeLevels;
|
|
38
|
+
const getEthereumFeeLevels = () => ({
|
|
39
|
+
blockTime: -1,
|
|
40
|
+
defaultFees: [
|
|
41
|
+
{
|
|
42
|
+
label: 'normal',
|
|
43
|
+
feePerUnit: '5000000000',
|
|
44
|
+
feeLimit: '21000',
|
|
45
|
+
blocks: -1,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
minFee: 1,
|
|
49
|
+
maxFee: 10000,
|
|
50
|
+
dustLimit: -1,
|
|
51
|
+
});
|
|
52
|
+
exports.getEthereumFeeLevels = getEthereumFeeLevels;
|
|
53
|
+
const RIPPLE_FEE_INFO = {
|
|
54
|
+
blockTime: -1,
|
|
55
|
+
defaultFees: [{ label: 'normal', feePerUnit: '12', blocks: -1 }],
|
|
56
|
+
minFee: 10,
|
|
57
|
+
maxFee: 10000,
|
|
58
|
+
dustLimit: -1,
|
|
59
|
+
};
|
|
60
|
+
const CARDANO_FEE_INFO = {
|
|
61
|
+
blockTime: -1,
|
|
62
|
+
defaultFees: [{ label: 'normal', feePerUnit: '44', blocks: -1 }],
|
|
63
|
+
minFee: 44,
|
|
64
|
+
maxFee: 16384 * 44 + 155381,
|
|
65
|
+
dustLimit: -1,
|
|
66
|
+
};
|
|
67
|
+
const MISC_FEE_LEVELS = {
|
|
68
|
+
xrp: RIPPLE_FEE_INFO,
|
|
69
|
+
txrp: RIPPLE_FEE_INFO,
|
|
70
|
+
ada: CARDANO_FEE_INFO,
|
|
71
|
+
tada: CARDANO_FEE_INFO,
|
|
72
|
+
};
|
|
73
|
+
const getMiscFeeLevels = (data) => {
|
|
74
|
+
const shortcut = data.shortcut.toLowerCase();
|
|
75
|
+
return (MISC_FEE_LEVELS[shortcut] || {
|
|
76
|
+
blockTime: -1,
|
|
77
|
+
minFee: -1,
|
|
78
|
+
maxFee: -1,
|
|
79
|
+
defaultFees: [{ label: 'normal', feePerUnit: '-1', blocks: -1 }],
|
|
80
|
+
dustLimit: -1,
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
exports.getMiscFeeLevels = getMiscFeeLevels;
|
|
84
|
+
//# sourceMappingURL=defaultFeeLevels.js.map
|
package/lib/data/version.d.ts
CHANGED
package/lib/data/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.
|
|
4
|
+
exports.VERSION = '9.1.2';
|
|
5
5
|
const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
|
|
6
6
|
exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
|
|
7
7
|
//# sourceMappingURL=version.js.map
|