@onekeyfe/hwk-ledger-adapter 1.2.8-alpha.50 → 1.2.8-alpha.52
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -166,6 +166,12 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
166
166
|
* that waits on a prompt nobody will answer. Device I/O already on the wire still drains.
|
|
167
167
|
*/
|
|
168
168
|
private _cancelOperationWork;
|
|
169
|
+
/**
|
|
170
|
+
* A running call by bare connectId (or still resolving its device by identity) may be on this
|
|
171
|
+
* connection, e.g. waiting for an unlock; its later stages need it, so it stays cached for that
|
|
172
|
+
* caller like any bare call's session. A lost connection is torn down regardless.
|
|
173
|
+
*/
|
|
174
|
+
private _bareCallMayUseConnection;
|
|
169
175
|
private _releaseOperationConnection;
|
|
170
176
|
private _releaseLostOperationConnection;
|
|
171
177
|
getDeviceInfo(connectIdOrOperationId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -166,6 +166,12 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
166
166
|
* that waits on a prompt nobody will answer. Device I/O already on the wire still drains.
|
|
167
167
|
*/
|
|
168
168
|
private _cancelOperationWork;
|
|
169
|
+
/**
|
|
170
|
+
* A running call by bare connectId (or still resolving its device by identity) may be on this
|
|
171
|
+
* connection, e.g. waiting for an unlock; its later stages need it, so it stays cached for that
|
|
172
|
+
* caller like any bare call's session. A lost connection is torn down regardless.
|
|
173
|
+
*/
|
|
174
|
+
private _bareCallMayUseConnection;
|
|
169
175
|
private _releaseOperationConnection;
|
|
170
176
|
private _releaseLostOperationConnection;
|
|
171
177
|
getDeviceInfo(connectIdOrOperationId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
package/dist/index.js
CHANGED
|
@@ -927,7 +927,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
927
927
|
type: import_hwk_adapter_core4.SDK.OPERATION_ENDED,
|
|
928
928
|
payload: { operationId: operation.operationId, reason }
|
|
929
929
|
});
|
|
930
|
-
if (reason === "timeout") {
|
|
930
|
+
if (reason === "timeout" && !this._bareCallMayUseConnection(operation)) {
|
|
931
931
|
void this._releaseOperationConnection(operation);
|
|
932
932
|
}
|
|
933
933
|
}
|
|
@@ -1471,7 +1471,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1471
1471
|
const operation = this._operations.findActive(operationId);
|
|
1472
1472
|
if (operation) this._cancelOperationWork(operation);
|
|
1473
1473
|
const endedOperation = this._operations.release(operationId);
|
|
1474
|
-
if (!endedOperation) return;
|
|
1474
|
+
if (!endedOperation || this._bareCallMayUseConnection(endedOperation)) return;
|
|
1475
1475
|
const { connectId } = endedOperation;
|
|
1476
1476
|
debugLog("[LedgerAdapter][REQ]", {
|
|
1477
1477
|
method: "releaseOperation",
|
|
@@ -1509,6 +1509,15 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1509
1509
|
this._uiRegistry.cancel(void 0, void 0, operationId);
|
|
1510
1510
|
void this.connector.cancel(this._sessions.get(operation.connectId) ?? operation.connectId);
|
|
1511
1511
|
}
|
|
1512
|
+
/**
|
|
1513
|
+
* A running call by bare connectId (or still resolving its device by identity) may be on this
|
|
1514
|
+
* connection, e.g. waiting for an unlock; its later stages need it, so it stays cached for that
|
|
1515
|
+
* caller like any bare call's session. A lost connection is torn down regardless.
|
|
1516
|
+
*/
|
|
1517
|
+
_bareCallMayUseConnection(operation) {
|
|
1518
|
+
const activeKey = this._jobQueue.getActiveJob()?.deviceId;
|
|
1519
|
+
return activeKey !== void 0 && !(0, import_hwk_adapter_core4.isHardwareOperationId)(activeKey) && (activeKey === operation.connectId || activeKey === LEDGER_DEFAULT_QUEUE_KEY || operation.connectionKeys.includes(activeKey));
|
|
1520
|
+
}
|
|
1512
1521
|
async _releaseOperationConnection(operation) {
|
|
1513
1522
|
const sessionIds = /* @__PURE__ */ new Set();
|
|
1514
1523
|
for (const [connectId, sessionId] of this._sessions) {
|
|
@@ -2030,11 +2039,19 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2030
2039
|
} else {
|
|
2031
2040
|
for (const sid of this._sessions.values()) void this.connector.cancel(sid);
|
|
2032
2041
|
}
|
|
2033
|
-
|
|
2042
|
+
const connectingConnectId = this._connectingConnectId;
|
|
2043
|
+
const targetKeys = new Set(
|
|
2044
|
+
[
|
|
2045
|
+
connectId,
|
|
2046
|
+
resolvedConnectId,
|
|
2047
|
+
...pendingOperationId ? this._operations.find(pendingOperationId)?.connectionKeys ?? [] : []
|
|
2048
|
+
].filter(Boolean)
|
|
2049
|
+
);
|
|
2050
|
+
const ownsPendingConnect = !connectId || activeJobId !== void 0 && queueKeys.has(activeJobId) || connectingConnectId !== void 0 && targetKeys.has(connectingConnectId);
|
|
2051
|
+
if (this._connectingPromise && ownsPendingConnect) {
|
|
2034
2052
|
this._doConnectAbortController?.abort(userAbortReason);
|
|
2035
2053
|
}
|
|
2036
|
-
|
|
2037
|
-
if (connectingConnectId) void this.connector.cancel(connectingConnectId);
|
|
2054
|
+
if (connectingConnectId && ownsPendingConnect) void this.connector.cancel(connectingConnectId);
|
|
2038
2055
|
}
|
|
2039
2056
|
// ---------------------------------------------------------------------------
|
|
2040
2057
|
// Chain fingerprint
|