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