@onekeyfe/hwk-ledger-adapter 1.2.8-alpha.121 → 1.2.8-alpha.122
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1030,7 +1030,6 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1030
1030
|
// need to subscribe in one place. The AppInstallProgress variant re-keys
|
|
1031
1031
|
// sessionId to connectId via `_sessions`, and drops if no mapping exists.
|
|
1032
1032
|
this.uiEventForwarder = (event) => {
|
|
1033
|
-
const operationId = this._activeOperationId();
|
|
1034
1033
|
if (event.type === EConnectorInteraction.AppInstallProgress) {
|
|
1035
1034
|
let connectId;
|
|
1036
1035
|
for (const [cid, sid] of this._sessions) {
|
|
@@ -1059,7 +1058,6 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1059
1058
|
this._installProgressLastEmittedValue = progress;
|
|
1060
1059
|
this.emitter.emit("ui-event", {
|
|
1061
1060
|
type: EConnectorInteraction.AppInstallProgress,
|
|
1062
|
-
...operationId ? { operationId } : {},
|
|
1063
1061
|
payload: {
|
|
1064
1062
|
connectId,
|
|
1065
1063
|
appName,
|
|
@@ -1068,7 +1066,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1068
1066
|
});
|
|
1069
1067
|
return;
|
|
1070
1068
|
}
|
|
1071
|
-
this.emitter.emit("ui-event",
|
|
1069
|
+
this.emitter.emit("ui-event", event);
|
|
1072
1070
|
};
|
|
1073
1071
|
this.connector = connector;
|
|
1074
1072
|
this._defaultAutoInstallApp = options?.autoInstallApp ?? false;
|
|
@@ -2058,6 +2056,12 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2058
2056
|
} else {
|
|
2059
2057
|
this._jobQueue.cancelActiveAndPending(void 0, userAbortReason);
|
|
2060
2058
|
}
|
|
2059
|
+
if (resolvedConnectId) {
|
|
2060
|
+
const sessionId = this._sessions.get(resolvedConnectId) ?? resolvedConnectId;
|
|
2061
|
+
void this.connector.cancel(sessionId);
|
|
2062
|
+
} else {
|
|
2063
|
+
for (const sid of this._sessions.values()) void this.connector.cancel(sid);
|
|
2064
|
+
}
|
|
2061
2065
|
const connectingConnectId = this._connectingConnectId;
|
|
2062
2066
|
const targetKeys = new Set(
|
|
2063
2067
|
[
|
|
@@ -2067,14 +2071,6 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2067
2071
|
].filter(Boolean)
|
|
2068
2072
|
);
|
|
2069
2073
|
const ownsPendingConnect = !connectId || activeJobId !== void 0 && queueKeys.has(activeJobId) || connectingConnectId !== void 0 && targetKeys.has(connectingConnectId);
|
|
2070
|
-
if (activeJobId === void 0 || ownsPendingConnect) {
|
|
2071
|
-
if (resolvedConnectId) {
|
|
2072
|
-
const sessionId = this._sessions.get(resolvedConnectId) ?? resolvedConnectId;
|
|
2073
|
-
void this.connector.cancel(sessionId);
|
|
2074
|
-
} else {
|
|
2075
|
-
for (const sid of this._sessions.values()) void this.connector.cancel(sid);
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
2074
|
if (this._connectingPromise && ownsPendingConnect) {
|
|
2079
2075
|
this._doConnectAbortController?.abort(userAbortReason);
|
|
2080
2076
|
}
|
|
@@ -2257,7 +2253,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2257
2253
|
} catch (err) {
|
|
2258
2254
|
this.emitter.emit(UI_REQUEST.CLOSE_UI_WINDOW, {
|
|
2259
2255
|
type: UI_REQUEST.CLOSE_UI_WINDOW,
|
|
2260
|
-
payload: {
|
|
2256
|
+
payload: {}
|
|
2261
2257
|
});
|
|
2262
2258
|
throw Object.assign(new Error("User cancelled Ledger connection"), {
|
|
2263
2259
|
_tag: ERROR_TAG.UserAborted,
|
|
@@ -2321,7 +2317,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2321
2317
|
} catch (err) {
|
|
2322
2318
|
this.emitter.emit(UI_REQUEST.CLOSE_UI_WINDOW, {
|
|
2323
2319
|
type: UI_REQUEST.CLOSE_UI_WINDOW,
|
|
2324
|
-
payload: {
|
|
2320
|
+
payload: {}
|
|
2325
2321
|
});
|
|
2326
2322
|
return false;
|
|
2327
2323
|
}
|
|
@@ -2359,7 +2355,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2359
2355
|
} catch (err) {
|
|
2360
2356
|
this.emitter.emit(UI_REQUEST.CLOSE_UI_WINDOW, {
|
|
2361
2357
|
type: UI_REQUEST.CLOSE_UI_WINDOW,
|
|
2362
|
-
payload: {
|
|
2358
|
+
payload: {}
|
|
2363
2359
|
});
|
|
2364
2360
|
return false;
|
|
2365
2361
|
}
|
|
@@ -3155,7 +3151,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
3155
3151
|
}
|
|
3156
3152
|
this.emitter.emit(UI_REQUEST.CLOSE_UI_WINDOW, {
|
|
3157
3153
|
type: UI_REQUEST.CLOSE_UI_WINDOW,
|
|
3158
|
-
payload: {
|
|
3154
|
+
payload: {}
|
|
3159
3155
|
});
|
|
3160
3156
|
return await this._runConnectorCall(
|
|
3161
3157
|
resolvedConnectId,
|
|
@@ -3222,7 +3218,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
3222
3218
|
if (err?._tag === UI_REQUEST_PREEMPTED_TAG) {
|
|
3223
3219
|
this.emitter.emit(UI_REQUEST.CLOSE_UI_WINDOW, {
|
|
3224
3220
|
type: UI_REQUEST.CLOSE_UI_WINDOW,
|
|
3225
|
-
payload: {
|
|
3221
|
+
payload: {}
|
|
3226
3222
|
});
|
|
3227
3223
|
throw Object.assign(new Error("Device permission request superseded"), {
|
|
3228
3224
|
_tag: ERROR_TAG.UserAborted,
|
|
@@ -4965,14 +4961,6 @@ var METHOD_PREFIX_TO_APP_NAME = {
|
|
|
4965
4961
|
tron: "Tron",
|
|
4966
4962
|
zcash: "Zcash"
|
|
4967
4963
|
};
|
|
4968
|
-
function withOpenAppName(event, data, appName) {
|
|
4969
|
-
if (event !== "ui-event") return data;
|
|
4970
|
-
const uiEvent = data;
|
|
4971
|
-
if (uiEvent.type !== EConnectorInteraction3.ConfirmOpenApp || uiEvent.payload.appName) {
|
|
4972
|
-
return data;
|
|
4973
|
-
}
|
|
4974
|
-
return { ...uiEvent, payload: { ...uiEvent.payload, appName } };
|
|
4975
|
-
}
|
|
4976
4964
|
var HARDWARE_ERROR_CODE_VALUES = new Set(
|
|
4977
4965
|
Object.values(HardwareErrorCode7).filter((value) => typeof value === "number")
|
|
4978
4966
|
);
|
|
@@ -5781,8 +5769,8 @@ var LedgerConnectorBase = class {
|
|
|
5781
5769
|
// ---------------------------------------------------------------------------
|
|
5782
5770
|
/**
|
|
5783
5771
|
* Return a per-call ctx with the chain's Ledger app name pre-bound to
|
|
5784
|
-
*
|
|
5785
|
-
* Falls through unchanged for unknown methods.
|
|
5772
|
+
* wrapError, so chain handlers don't need to repeat `{ defaultAppName: 'X' }`
|
|
5773
|
+
* at every catch site. Falls through unchanged for unknown methods.
|
|
5786
5774
|
*/
|
|
5787
5775
|
_ctxForMethod(method) {
|
|
5788
5776
|
const prefix = /^(evm|btc|sol|tron|zcash)/.exec(method)?.[1];
|
|
@@ -5790,8 +5778,7 @@ var LedgerConnectorBase = class {
|
|
|
5790
5778
|
if (!defaultAppName) return this._ctx;
|
|
5791
5779
|
return {
|
|
5792
5780
|
...this._ctx,
|
|
5793
|
-
wrapError: (err, opts) => this._wrapError(err, { defaultAppName, ...opts })
|
|
5794
|
-
emit: (event, data) => this._ctx.emit(event, withOpenAppName(event, data, defaultAppName))
|
|
5781
|
+
wrapError: (err, opts) => this._wrapError(err, { defaultAppName, ...opts })
|
|
5795
5782
|
};
|
|
5796
5783
|
}
|
|
5797
5784
|
_wrapError(err, opts) {
|