@onekeyfe/hwk-ledger-adapter 1.1.29-alpha.2 → 1.1.29
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/index.d.mts +17 -22
- package/dist/index.d.ts +17 -22
- package/dist/index.js +145 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -143
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CHAIN_FINGERPRINT_PATHS,
|
|
4
4
|
DEVICE,
|
|
5
|
-
DEVICE_CONNECT_RETRY_DELAY_MS,
|
|
6
5
|
DeviceJobQueue,
|
|
7
6
|
EConnectorInteraction,
|
|
8
7
|
HardwareErrorCode as HardwareErrorCode3,
|
|
@@ -14,7 +13,7 @@ import {
|
|
|
14
13
|
deriveDeviceFingerprint,
|
|
15
14
|
failure as failure2,
|
|
16
15
|
rehydrateConnectorError,
|
|
17
|
-
success
|
|
16
|
+
success as success2
|
|
18
17
|
} from "@onekeyfe/hwk-adapter-core";
|
|
19
18
|
|
|
20
19
|
// src/errors.ts
|
|
@@ -452,7 +451,7 @@ function mapLedgerError(err, opts) {
|
|
|
452
451
|
}
|
|
453
452
|
|
|
454
453
|
// src/adapter/methods/allNetworkGetAddress.ts
|
|
455
|
-
import { HardwareErrorCode as HardwareErrorCode2, failure,
|
|
454
|
+
import { HardwareErrorCode as HardwareErrorCode2, failure, success } from "@onekeyfe/hwk-adapter-core";
|
|
456
455
|
|
|
457
456
|
// src/utils/sdkEventBus.ts
|
|
458
457
|
var listeners = /* @__PURE__ */ new Set();
|
|
@@ -503,10 +502,10 @@ function debugError(...args) {
|
|
|
503
502
|
var LEDGER_BTC_NETWORK_COIN_MAP = {
|
|
504
503
|
tbtc: "Testnet",
|
|
505
504
|
bch: "Bcash",
|
|
505
|
+
doge: "Dogecoin",
|
|
506
506
|
ltc: "Litecoin",
|
|
507
507
|
neurai: "Neurai"
|
|
508
508
|
};
|
|
509
|
-
var LEDGER_UNSUPPORTED_ALLNETWORK_NETWORKS = /* @__PURE__ */ new Set(["doge", "dogecoin"]);
|
|
510
509
|
function createAllNetworkGetAddress({
|
|
511
510
|
callChain,
|
|
512
511
|
getChainFingerprint
|
|
@@ -517,46 +516,49 @@ function createAllNetworkGetAddress({
|
|
|
517
516
|
const commonParams = {
|
|
518
517
|
autoInstallApp: params.autoInstallApp
|
|
519
518
|
};
|
|
519
|
+
const responses = [];
|
|
520
520
|
const chainFingerprints = /* @__PURE__ */ new Map();
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
callItem: async ({ method, chain, item }) => {
|
|
521
|
+
for (const item of params.bundle) {
|
|
522
|
+
const method = getAllNetworkMethod(item);
|
|
523
|
+
if (!method) {
|
|
524
|
+
responses.push(buildUnsupportedMethodResponse(item));
|
|
525
|
+
} else {
|
|
526
|
+
const chain = getFingerprintChain(method);
|
|
528
527
|
const itemDeviceId = getItemDeviceId(item) ?? chainFingerprints.get(chain) ?? "";
|
|
529
|
-
|
|
528
|
+
const normalizedItem = normalizeLedgerAllNetworkItem(method, item);
|
|
529
|
+
const response = await callAllNetworkItem(
|
|
530
530
|
callChain,
|
|
531
|
+
getChainFingerprint,
|
|
531
532
|
connectId,
|
|
532
533
|
itemDeviceId,
|
|
534
|
+
chain,
|
|
533
535
|
method,
|
|
534
|
-
|
|
536
|
+
normalizedItem,
|
|
535
537
|
commonParams,
|
|
536
|
-
installContext
|
|
537
|
-
|
|
538
|
-
},
|
|
539
|
-
attachIdentity: async ({ item, chain, payload }) => attachLedgerIdentity(
|
|
540
|
-
getChainFingerprint,
|
|
541
|
-
connectId,
|
|
542
|
-
item,
|
|
543
|
-
chain,
|
|
544
|
-
payload,
|
|
545
|
-
chainFingerprints
|
|
546
|
-
),
|
|
547
|
-
shouldAbortBundle: isTopLevelAllNetworkFailure,
|
|
548
|
-
buildTopLevelFailure: (response) => {
|
|
549
|
-
const code = response.payload?.code ?? HardwareErrorCode2.DeviceMismatch;
|
|
550
|
-
return failure(
|
|
551
|
-
code,
|
|
552
|
-
response.payload?.error ?? "All-network get-address aborted",
|
|
553
|
-
response.payload?.params
|
|
538
|
+
installContext,
|
|
539
|
+
chainFingerprints
|
|
554
540
|
);
|
|
541
|
+
if (isTopLevelAllNetworkFailure(response)) {
|
|
542
|
+
const code = response.payload?.code ?? HardwareErrorCode2.DeviceMismatch;
|
|
543
|
+
const result2 = failure(
|
|
544
|
+
code,
|
|
545
|
+
response.payload?.error ?? "All-network get-address aborted",
|
|
546
|
+
response.payload?.params
|
|
547
|
+
);
|
|
548
|
+
debugLog("[LedgerAdapter][RES]", {
|
|
549
|
+
method: "allNetworkGetAddress",
|
|
550
|
+
success: false,
|
|
551
|
+
payload: result2
|
|
552
|
+
});
|
|
553
|
+
return result2;
|
|
554
|
+
}
|
|
555
|
+
responses.push(response);
|
|
555
556
|
}
|
|
556
|
-
}
|
|
557
|
+
}
|
|
558
|
+
const result = success(responses);
|
|
557
559
|
debugLog("[LedgerAdapter][RES]", {
|
|
558
560
|
method: "allNetworkGetAddress",
|
|
559
|
-
success:
|
|
561
|
+
success: true,
|
|
560
562
|
payload: result
|
|
561
563
|
});
|
|
562
564
|
return result;
|
|
@@ -573,16 +575,25 @@ function getItemDeviceId(item) {
|
|
|
573
575
|
const { deviceId } = item;
|
|
574
576
|
return typeof deviceId === "string" && deviceId.length > 0 ? deviceId : void 0;
|
|
575
577
|
}
|
|
576
|
-
function
|
|
577
|
-
|
|
578
|
+
function getAllNetworkMethod(item) {
|
|
579
|
+
switch (item.methodName) {
|
|
580
|
+
case "evmGetAddress":
|
|
581
|
+
case "btcGetAddress":
|
|
582
|
+
case "btcGetPublicKey":
|
|
583
|
+
case "solGetAddress":
|
|
584
|
+
case "tronGetAddress":
|
|
585
|
+
return item.methodName;
|
|
586
|
+
default:
|
|
587
|
+
return void 0;
|
|
588
|
+
}
|
|
578
589
|
}
|
|
579
|
-
function
|
|
590
|
+
function buildUnsupportedMethodResponse(item) {
|
|
580
591
|
return {
|
|
581
592
|
...item,
|
|
582
593
|
success: false,
|
|
583
594
|
payload: {
|
|
584
|
-
code: HardwareErrorCode2.
|
|
585
|
-
error: `
|
|
595
|
+
code: HardwareErrorCode2.InvalidParams,
|
|
596
|
+
error: `Unsupported allNetwork method: ${String(item.methodName)}`
|
|
586
597
|
}
|
|
587
598
|
};
|
|
588
599
|
}
|
|
@@ -597,8 +608,21 @@ function normalizeLedgerAllNetworkItem(method, item) {
|
|
|
597
608
|
const coin = LEDGER_BTC_NETWORK_COIN_MAP[item.network];
|
|
598
609
|
return coin ? { ...item, coin } : item;
|
|
599
610
|
}
|
|
600
|
-
async function
|
|
601
|
-
const
|
|
611
|
+
async function callAllNetworkItem(callChain, getChainFingerprint, connectId, deviceId, chain, method, item, commonParams, installContext, chainFingerprints) {
|
|
612
|
+
const response = await callAllNetworkMethod(
|
|
613
|
+
callChain,
|
|
614
|
+
connectId,
|
|
615
|
+
deviceId,
|
|
616
|
+
method,
|
|
617
|
+
item,
|
|
618
|
+
commonParams,
|
|
619
|
+
installContext
|
|
620
|
+
);
|
|
621
|
+
if (!response.success) {
|
|
622
|
+
return { ...item, success: false, payload: response.payload };
|
|
623
|
+
}
|
|
624
|
+
const payload = response.payload;
|
|
625
|
+
const fingerprint = deviceId || chainFingerprints.get(chain) || await bootstrapChainFingerprint(getChainFingerprint, connectId, chain);
|
|
602
626
|
if (!fingerprint) {
|
|
603
627
|
return buildFingerprintBootstrapFailure(item, chain);
|
|
604
628
|
}
|
|
@@ -608,12 +632,6 @@ async function attachLedgerIdentity(getChainFingerprint, connectId, item, chain,
|
|
|
608
632
|
success: true,
|
|
609
633
|
payload: {
|
|
610
634
|
...payload,
|
|
611
|
-
deviceIdentity: {
|
|
612
|
-
vendor: "ledger",
|
|
613
|
-
type: "chainFingerprint",
|
|
614
|
-
chain,
|
|
615
|
-
value: fingerprint
|
|
616
|
-
},
|
|
617
635
|
chainFingerprint: fingerprint,
|
|
618
636
|
chainFingerprintChain: chain
|
|
619
637
|
}
|
|
@@ -633,6 +651,23 @@ function buildFingerprintBootstrapFailure(item, chain) {
|
|
|
633
651
|
}
|
|
634
652
|
};
|
|
635
653
|
}
|
|
654
|
+
function getFingerprintChain(method) {
|
|
655
|
+
switch (method) {
|
|
656
|
+
case "evmGetAddress":
|
|
657
|
+
return "evm";
|
|
658
|
+
case "btcGetAddress":
|
|
659
|
+
case "btcGetPublicKey":
|
|
660
|
+
return "btc";
|
|
661
|
+
case "solGetAddress":
|
|
662
|
+
return "sol";
|
|
663
|
+
case "tronGetAddress":
|
|
664
|
+
return "tron";
|
|
665
|
+
default:
|
|
666
|
+
throw Object.assign(new Error(`Unsupported allNetwork method: ${method}`), {
|
|
667
|
+
code: HardwareErrorCode2.InvalidParams
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
}
|
|
636
671
|
async function callAllNetworkMethod(callChain, connectId, deviceId, method, item, commonParams, installContext) {
|
|
637
672
|
switch (method) {
|
|
638
673
|
case "evmGetAddress":
|
|
@@ -938,7 +973,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
938
973
|
if (session.deviceInfo) {
|
|
939
974
|
this._discoveredDevices.set(connectId, session.deviceInfo);
|
|
940
975
|
}
|
|
941
|
-
const result =
|
|
976
|
+
const result = success2(connectId);
|
|
942
977
|
debugLog("[LedgerAdapter][RES]", { method: "connectDevice", success: true, payload: result });
|
|
943
978
|
return result;
|
|
944
979
|
} catch (err) {
|
|
@@ -984,7 +1019,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
984
1019
|
await this._ensureDevicePermission(connectId, deviceId);
|
|
985
1020
|
const cached = this._discoveredDevices.get(connectId) ?? Array.from(this._discoveredDevices.values()).find((d) => d.deviceId === deviceId);
|
|
986
1021
|
if (cached) {
|
|
987
|
-
const result =
|
|
1022
|
+
const result = success2(cached);
|
|
988
1023
|
debugLog("[LedgerAdapter][RES]", {
|
|
989
1024
|
method: "getDeviceInfo",
|
|
990
1025
|
success: true,
|
|
@@ -1033,201 +1068,181 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1033
1068
|
commonParams,
|
|
1034
1069
|
installContext
|
|
1035
1070
|
);
|
|
1036
|
-
return
|
|
1071
|
+
return success2(result);
|
|
1037
1072
|
} catch (err) {
|
|
1038
1073
|
return this.errorToFailure(err);
|
|
1039
1074
|
}
|
|
1040
1075
|
}
|
|
1041
|
-
static normalizeCallArgs(connectId, deviceId, params) {
|
|
1042
|
-
return {
|
|
1043
|
-
connectId: connectId ?? "",
|
|
1044
|
-
deviceId: deviceId ?? "",
|
|
1045
|
-
params: params ?? {}
|
|
1046
|
-
};
|
|
1047
|
-
}
|
|
1048
|
-
static splitCommonParams(params) {
|
|
1049
|
-
if (params && typeof params === "object") {
|
|
1050
|
-
const {
|
|
1051
|
-
autoInstallApp,
|
|
1052
|
-
passphraseState: _passphraseState,
|
|
1053
|
-
useEmptyPassphrase: _useEmptyPassphrase,
|
|
1054
|
-
...rest
|
|
1055
|
-
} = params;
|
|
1056
|
-
return {
|
|
1057
|
-
commonParams: {
|
|
1058
|
-
autoInstallApp: typeof autoInstallApp === "boolean" ? autoInstallApp : void 0
|
|
1059
|
-
},
|
|
1060
|
-
rest
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
return { commonParams: {}, rest: params ?? {} };
|
|
1064
|
-
}
|
|
1065
|
-
callChainWithMergedParams(connectId, deviceId, chain, method, params) {
|
|
1066
|
-
const normalized = _LedgerAdapter.normalizeCallArgs(connectId, deviceId, params);
|
|
1067
|
-
const { commonParams, rest } = _LedgerAdapter.splitCommonParams(normalized.params);
|
|
1068
|
-
return this.callChain(
|
|
1069
|
-
normalized.connectId,
|
|
1070
|
-
normalized.deviceId,
|
|
1071
|
-
chain,
|
|
1072
|
-
method,
|
|
1073
|
-
rest,
|
|
1074
|
-
commonParams
|
|
1075
|
-
);
|
|
1076
|
-
}
|
|
1077
1076
|
// ---------------------------------------------------------------------------
|
|
1078
1077
|
// EVM chain methods
|
|
1079
1078
|
// ---------------------------------------------------------------------------
|
|
1080
|
-
evmGetAddress(connectId, deviceId, params) {
|
|
1081
|
-
return this.
|
|
1079
|
+
evmGetAddress(connectId, deviceId, params, commonParams) {
|
|
1080
|
+
return this.callChain(
|
|
1082
1081
|
connectId,
|
|
1083
1082
|
deviceId,
|
|
1084
1083
|
"evm",
|
|
1085
1084
|
"evmGetAddress",
|
|
1086
|
-
params
|
|
1085
|
+
params,
|
|
1086
|
+
commonParams
|
|
1087
1087
|
);
|
|
1088
1088
|
}
|
|
1089
|
-
evmSignTransaction(connectId, deviceId, params) {
|
|
1090
|
-
return this.
|
|
1089
|
+
evmSignTransaction(connectId, deviceId, params, commonParams) {
|
|
1090
|
+
return this.callChain(
|
|
1091
1091
|
connectId,
|
|
1092
1092
|
deviceId,
|
|
1093
1093
|
"evm",
|
|
1094
1094
|
"evmSignTransaction",
|
|
1095
|
-
params
|
|
1095
|
+
params,
|
|
1096
|
+
commonParams
|
|
1096
1097
|
);
|
|
1097
1098
|
}
|
|
1098
|
-
evmSignMessage(connectId, deviceId, params) {
|
|
1099
|
-
return this.
|
|
1099
|
+
evmSignMessage(connectId, deviceId, params, commonParams) {
|
|
1100
|
+
return this.callChain(
|
|
1100
1101
|
connectId,
|
|
1101
1102
|
deviceId,
|
|
1102
1103
|
"evm",
|
|
1103
1104
|
"evmSignMessage",
|
|
1104
|
-
params
|
|
1105
|
+
params,
|
|
1106
|
+
commonParams
|
|
1105
1107
|
);
|
|
1106
1108
|
}
|
|
1107
|
-
evmSignTypedData(connectId, deviceId, params) {
|
|
1108
|
-
return this.
|
|
1109
|
+
evmSignTypedData(connectId, deviceId, params, commonParams) {
|
|
1110
|
+
return this.callChain(
|
|
1109
1111
|
connectId,
|
|
1110
1112
|
deviceId,
|
|
1111
1113
|
"evm",
|
|
1112
1114
|
"evmSignTypedData",
|
|
1113
|
-
params
|
|
1115
|
+
params,
|
|
1116
|
+
commonParams
|
|
1114
1117
|
);
|
|
1115
1118
|
}
|
|
1116
1119
|
// ---------------------------------------------------------------------------
|
|
1117
1120
|
// BTC chain methods
|
|
1118
1121
|
// ---------------------------------------------------------------------------
|
|
1119
|
-
btcGetAddress(connectId, deviceId, params) {
|
|
1120
|
-
return this.
|
|
1122
|
+
btcGetAddress(connectId, deviceId, params, commonParams) {
|
|
1123
|
+
return this.callChain(
|
|
1121
1124
|
connectId,
|
|
1122
1125
|
deviceId,
|
|
1123
1126
|
"btc",
|
|
1124
1127
|
"btcGetAddress",
|
|
1125
|
-
params
|
|
1128
|
+
params,
|
|
1129
|
+
commonParams
|
|
1126
1130
|
);
|
|
1127
1131
|
}
|
|
1128
|
-
btcGetPublicKey(connectId, deviceId, params) {
|
|
1129
|
-
return this.
|
|
1132
|
+
btcGetPublicKey(connectId, deviceId, params, commonParams) {
|
|
1133
|
+
return this.callChain(
|
|
1130
1134
|
connectId,
|
|
1131
1135
|
deviceId,
|
|
1132
1136
|
"btc",
|
|
1133
1137
|
"btcGetPublicKey",
|
|
1134
|
-
params
|
|
1138
|
+
params,
|
|
1139
|
+
commonParams
|
|
1135
1140
|
);
|
|
1136
1141
|
}
|
|
1137
|
-
btcSignTransaction(connectId, deviceId, params) {
|
|
1138
|
-
return this.
|
|
1142
|
+
btcSignTransaction(connectId, deviceId, params, commonParams) {
|
|
1143
|
+
return this.callChain(
|
|
1139
1144
|
connectId,
|
|
1140
1145
|
deviceId,
|
|
1141
1146
|
"btc",
|
|
1142
1147
|
"btcSignTransaction",
|
|
1143
|
-
params
|
|
1148
|
+
params,
|
|
1149
|
+
commonParams
|
|
1144
1150
|
);
|
|
1145
1151
|
}
|
|
1146
|
-
btcSignPsbt(connectId, deviceId, params) {
|
|
1147
|
-
return this.
|
|
1152
|
+
btcSignPsbt(connectId, deviceId, params, commonParams) {
|
|
1153
|
+
return this.callChain(
|
|
1148
1154
|
connectId,
|
|
1149
1155
|
deviceId,
|
|
1150
1156
|
"btc",
|
|
1151
1157
|
"btcSignPsbt",
|
|
1152
|
-
params
|
|
1158
|
+
params,
|
|
1159
|
+
commonParams
|
|
1153
1160
|
);
|
|
1154
1161
|
}
|
|
1155
|
-
btcSignMessage(connectId, deviceId, params) {
|
|
1156
|
-
return this.
|
|
1162
|
+
btcSignMessage(connectId, deviceId, params, commonParams) {
|
|
1163
|
+
return this.callChain(
|
|
1157
1164
|
connectId,
|
|
1158
1165
|
deviceId,
|
|
1159
1166
|
"btc",
|
|
1160
1167
|
"btcSignMessage",
|
|
1161
|
-
params
|
|
1168
|
+
params,
|
|
1169
|
+
commonParams
|
|
1162
1170
|
);
|
|
1163
1171
|
}
|
|
1164
|
-
btcGetMasterFingerprint(connectId, deviceId,
|
|
1165
|
-
return this.
|
|
1172
|
+
btcGetMasterFingerprint(connectId, deviceId, commonParams) {
|
|
1173
|
+
return this.callChain(
|
|
1166
1174
|
connectId,
|
|
1167
1175
|
deviceId,
|
|
1168
1176
|
"btc",
|
|
1169
1177
|
"btcGetMasterFingerprint",
|
|
1170
|
-
|
|
1178
|
+
{},
|
|
1179
|
+
commonParams
|
|
1171
1180
|
);
|
|
1172
1181
|
}
|
|
1173
1182
|
// ---------------------------------------------------------------------------
|
|
1174
1183
|
// SOL chain methods
|
|
1175
1184
|
// ---------------------------------------------------------------------------
|
|
1176
|
-
solGetAddress(connectId, deviceId, params) {
|
|
1177
|
-
return this.
|
|
1185
|
+
solGetAddress(connectId, deviceId, params, commonParams) {
|
|
1186
|
+
return this.callChain(
|
|
1178
1187
|
connectId,
|
|
1179
1188
|
deviceId,
|
|
1180
1189
|
"sol",
|
|
1181
1190
|
"solGetAddress",
|
|
1182
|
-
params
|
|
1191
|
+
params,
|
|
1192
|
+
commonParams
|
|
1183
1193
|
);
|
|
1184
1194
|
}
|
|
1185
|
-
solSignTransaction(connectId, deviceId, params) {
|
|
1186
|
-
return this.
|
|
1195
|
+
solSignTransaction(connectId, deviceId, params, commonParams) {
|
|
1196
|
+
return this.callChain(
|
|
1187
1197
|
connectId,
|
|
1188
1198
|
deviceId,
|
|
1189
1199
|
"sol",
|
|
1190
1200
|
"solSignTransaction",
|
|
1191
|
-
params
|
|
1201
|
+
params,
|
|
1202
|
+
commonParams
|
|
1192
1203
|
);
|
|
1193
1204
|
}
|
|
1194
|
-
solSignMessage(connectId, deviceId, params) {
|
|
1195
|
-
return this.
|
|
1205
|
+
solSignMessage(connectId, deviceId, params, commonParams) {
|
|
1206
|
+
return this.callChain(
|
|
1196
1207
|
connectId,
|
|
1197
1208
|
deviceId,
|
|
1198
1209
|
"sol",
|
|
1199
1210
|
"solSignMessage",
|
|
1200
|
-
params
|
|
1211
|
+
params,
|
|
1212
|
+
commonParams
|
|
1201
1213
|
);
|
|
1202
1214
|
}
|
|
1203
1215
|
// ---------------------------------------------------------------------------
|
|
1204
1216
|
// TRON chain methods
|
|
1205
1217
|
// ---------------------------------------------------------------------------
|
|
1206
|
-
tronGetAddress(connectId, deviceId, params) {
|
|
1207
|
-
return this.
|
|
1218
|
+
tronGetAddress(connectId, deviceId, params, commonParams) {
|
|
1219
|
+
return this.callChain(
|
|
1208
1220
|
connectId,
|
|
1209
1221
|
deviceId,
|
|
1210
1222
|
"tron",
|
|
1211
1223
|
"tronGetAddress",
|
|
1212
|
-
params
|
|
1224
|
+
params,
|
|
1225
|
+
commonParams
|
|
1213
1226
|
);
|
|
1214
1227
|
}
|
|
1215
|
-
tronSignTransaction(connectId, deviceId, params) {
|
|
1216
|
-
return this.
|
|
1228
|
+
tronSignTransaction(connectId, deviceId, params, commonParams) {
|
|
1229
|
+
return this.callChain(
|
|
1217
1230
|
connectId,
|
|
1218
1231
|
deviceId,
|
|
1219
1232
|
"tron",
|
|
1220
1233
|
"tronSignTransaction",
|
|
1221
|
-
params
|
|
1234
|
+
params,
|
|
1235
|
+
commonParams
|
|
1222
1236
|
);
|
|
1223
1237
|
}
|
|
1224
|
-
tronSignMessage(connectId, deviceId, params) {
|
|
1225
|
-
return this.
|
|
1238
|
+
tronSignMessage(connectId, deviceId, params, commonParams) {
|
|
1239
|
+
return this.callChain(
|
|
1226
1240
|
connectId,
|
|
1227
1241
|
deviceId,
|
|
1228
1242
|
"tron",
|
|
1229
1243
|
"tronSignMessage",
|
|
1230
|
-
params
|
|
1244
|
+
params,
|
|
1245
|
+
commonParams
|
|
1231
1246
|
);
|
|
1232
1247
|
}
|
|
1233
1248
|
// ---------------------------------------------------------------------------
|
|
@@ -1238,7 +1253,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1238
1253
|
async installApp(connectId, appName) {
|
|
1239
1254
|
try {
|
|
1240
1255
|
await this.connectorCall(connectId, "installApp", { appName });
|
|
1241
|
-
return
|
|
1256
|
+
return success2(void 0);
|
|
1242
1257
|
} catch (err) {
|
|
1243
1258
|
return this.errorToFailure(err);
|
|
1244
1259
|
}
|
|
@@ -1246,7 +1261,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1246
1261
|
async listInstalledApps(connectId) {
|
|
1247
1262
|
try {
|
|
1248
1263
|
const result = await this.connectorCall(connectId, "listInstalledApps", {});
|
|
1249
|
-
return
|
|
1264
|
+
return success2(result);
|
|
1250
1265
|
} catch (err) {
|
|
1251
1266
|
return this.errorToFailure(err);
|
|
1252
1267
|
}
|
|
@@ -1255,7 +1270,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1255
1270
|
async listInstalledNames(connectId) {
|
|
1256
1271
|
try {
|
|
1257
1272
|
const result = await this.connectorCall(connectId, "listInstalledNames", {});
|
|
1258
|
-
return
|
|
1273
|
+
return success2(result);
|
|
1259
1274
|
} catch (err) {
|
|
1260
1275
|
return this.errorToFailure(err);
|
|
1261
1276
|
}
|
|
@@ -1263,7 +1278,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1263
1278
|
async listAvailableApps(connectId) {
|
|
1264
1279
|
try {
|
|
1265
1280
|
const result = await this.connectorCall(connectId, "listAvailableApps", {});
|
|
1266
|
-
return
|
|
1281
|
+
return success2(result);
|
|
1267
1282
|
} catch (err) {
|
|
1268
1283
|
return this.errorToFailure(err);
|
|
1269
1284
|
}
|
|
@@ -1271,7 +1286,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1271
1286
|
async getLedgerFirmwareVersion(connectId) {
|
|
1272
1287
|
try {
|
|
1273
1288
|
const result = await this.connectorCall(connectId, "getFirmwareVersion", {});
|
|
1274
|
-
return
|
|
1289
|
+
return success2(result);
|
|
1275
1290
|
} catch (err) {
|
|
1276
1291
|
return this.errorToFailure(err);
|
|
1277
1292
|
}
|
|
@@ -1279,7 +1294,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1279
1294
|
async getLedgerDeviceInfo(connectId) {
|
|
1280
1295
|
try {
|
|
1281
1296
|
const result = await this.connectorCall(connectId, "getDeviceInfo", {});
|
|
1282
|
-
return
|
|
1297
|
+
return success2(result);
|
|
1283
1298
|
} catch (err) {
|
|
1284
1299
|
return this.errorToFailure(err);
|
|
1285
1300
|
}
|
|
@@ -1326,7 +1341,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1326
1341
|
chain,
|
|
1327
1342
|
(method, params) => this.connectorCall(connectId, method, params, void 0, deviceId)
|
|
1328
1343
|
);
|
|
1329
|
-
return
|
|
1344
|
+
return success2(fingerprint);
|
|
1330
1345
|
} catch (err) {
|
|
1331
1346
|
debugError("[LedgerAdapter] getChainFingerprint error:", chain, err);
|
|
1332
1347
|
return this.errorToFailure(err);
|
|
@@ -1574,7 +1589,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1574
1589
|
if (devices.length === 0) {
|
|
1575
1590
|
for (let i = 0; i < 3 && !internalSignal.aborted; i += 1) {
|
|
1576
1591
|
await new Promise((resolve) => {
|
|
1577
|
-
setTimeout(resolve,
|
|
1592
|
+
setTimeout(resolve, 1e3);
|
|
1578
1593
|
});
|
|
1579
1594
|
devices = await this.searchDevices();
|
|
1580
1595
|
if (devices.length > 0) break;
|
|
@@ -2258,7 +2273,6 @@ var LedgerAdapter = _LedgerAdapter;
|
|
|
2258
2273
|
import {
|
|
2259
2274
|
EConnectorInteraction as EConnectorInteraction4,
|
|
2260
2275
|
HardwareErrorCode as HardwareErrorCode8,
|
|
2261
|
-
isKnownNonTargetHardwareVendor,
|
|
2262
2276
|
serializeConnectorError
|
|
2263
2277
|
} from "@onekeyfe/hwk-adapter-core";
|
|
2264
2278
|
|
|
@@ -4155,7 +4169,7 @@ var LedgerConnectorBase = class {
|
|
|
4155
4169
|
async searchDevices() {
|
|
4156
4170
|
const dm = await this._getDeviceManager();
|
|
4157
4171
|
const descriptors = await this._discoverDescriptors(dm);
|
|
4158
|
-
const resolvedDescriptors = descriptors.
|
|
4172
|
+
const resolvedDescriptors = descriptors.map((d) => ({
|
|
4159
4173
|
descriptor: d,
|
|
4160
4174
|
connectId: this._resolveConnectId(d)
|
|
4161
4175
|
}));
|