Skip to content

Commit

Permalink
okay also added requestId in a few places
Browse files Browse the repository at this point in the history
  • Loading branch information
glitch003 committed Feb 24, 2024
1 parent 3d00e95 commit 5944cc4
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions apps/html/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- (DO NOT EDIT!) (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Fri, 23 Feb 2024 17:40:11 GMT -->
<!-- (DO NOT EDIT!) (HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Sat, 24 Feb 2024 04:18:12 GMT -->
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -62,7 +62,7 @@
</style>
</head>
<body>
(HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Fri, 23 Feb 2024 17:40:11 GMT
(HTML) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-html.mjs Sat, 24 Feb 2024 04:18:12 GMT

<!-- ==================== ALL EXPORTED VANILLA LIBRARIES ==================== -->

Expand Down
2 changes: 1 addition & 1 deletion apps/react/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ pre {
`,
}}
/>
(REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Fri, 23 Feb 2024 17:40:11 GMT
(REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Sat, 24 Feb 2024 04:18:12 GMT
<div id="root"></div>
<pre><code id="result"></code></pre>
</>
Expand Down
2 changes: 1 addition & 1 deletion packages/constants/src/lib/constants/autogen_internal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last Modified: 2024-02-23 17:37:54
// Last Modified: 2024-02-24 04:15:54
// This file is auto-generated by tools/scripts/gen-internal-dev.mjs
export const INTERNAL_DEV = [
'https://167.114.17.205:443',
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ export class LitCore {
* @returns { void }
*
*/
_throwNodeError = (res: RejectedNodePromises): void => {
_throwNodeError = (res: RejectedNodePromises, requestId: string): void => {
if (res.error) {
if (
((res.error.errorCode &&
Expand All @@ -946,13 +946,15 @@ export class LitCore {
res.error.message ||
'There was an error getting the signing shares from the nodes',
errorCode: res.error.errorCode || LIT_ERROR.UNKNOWN_ERROR.code,
requestId,
} as NodeClientErrorV0 | NodeClientErrorV1);
} else {
throwError({
message: `There was an error getting the signing shares from the nodes. Response from the nodes: ${JSON.stringify(
res
)}`,
error: LIT_ERROR.UNKNOWN_ERROR,
requestId,
});
}
};
Expand Down
23 changes: 11 additions & 12 deletions packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ export class LitNodeClientNodeJs
getSignatures = (signedData: Array<any>, requestId: string = ''): any => {
const initialKeys = [...new Set(signedData.flatMap((i) => Object.keys(i)))];

// processing signature shares for failed or invalid contents.
// processing signature shares for failed or invalid contents. mutates the signedData object.
for (const signatureResponse of signedData) {
for (const sigName of Object.keys(signatureResponse)) {
const requiredFields = ['signatureShare'];
Expand Down Expand Up @@ -1439,10 +1439,10 @@ export class LitNodeClientNodeJs
);

throwError({
message:
'total number of valid signatures shares does not match threshold',
message: `The total number of valid signatures shares ${shares.length} does not meet the threshold of ${this.config.minNodeCount}`,
errorKind: LIT_ERROR.NO_VALID_SHARES.kind,
errorCode: LIT_ERROR.NO_VALID_SHARES.code,
requestId,
});
}

Expand Down Expand Up @@ -1601,7 +1601,7 @@ export class LitNodeClientNodeJs
params = LitNodeClientNodeJs.normalizeParams(params);

let res;
let requestId = this.getRequestId();
let requestId = '';
// -- only run on a single node
if (targetNodeRange) {
res = await this.runOnTargetedNodes(params);
Expand Down Expand Up @@ -1652,7 +1652,7 @@ export class LitNodeClientNodeJs
}
// -- case: promises rejected
if (res.success === false) {
this._throwNodeError(res as RejectedNodePromises);
this._throwNodeError(res as RejectedNodePromises, requestId);
}

// -- case: promises success (TODO: check the keys of "values")
Expand Down Expand Up @@ -1865,7 +1865,7 @@ export class LitNodeClientNodeJs

// -- case: promises rejected
if (!res.success) {
this._throwNodeError(res as RejectedNodePromises);
this._throwNodeError(res as RejectedNodePromises, requestId);
}

// -- case: promises success (TODO: check the keys of "values")
Expand Down Expand Up @@ -1994,7 +1994,6 @@ export class LitNodeClientNodeJs
}

// ========== Get Node Promises ==========
let requestId;
const wrapper = async (
id: string
): Promise<SuccessNodePromises<any> | RejectedNodePromises> => {
Expand Down Expand Up @@ -2039,10 +2038,11 @@ export class LitNodeClientNodeJs
},
this.config.retryTolerance
);
const requestId = res.requestId;

// -- case: promises rejected
if (res.success === false) {
this._throwNodeError(res as RejectedNodePromises);
this._throwNodeError(res as RejectedNodePromises, requestId);
}

const signatureShares: Array<NodeBlsSigningShare> = (
Expand Down Expand Up @@ -2236,7 +2236,6 @@ export class LitNodeClientNodeJs

log('identityParam', identityParam);

let requestId;
// ========== Get Network Signature ==========
const wrapper = async (
id: string
Expand Down Expand Up @@ -2280,11 +2279,11 @@ export class LitNodeClientNodeJs
this.config.retryTolerance
);

requestId = res.requestId;
const requestId = res.requestId;

// -- case: promises rejected
if (res.success === false) {
this._throwNodeError(res as RejectedNodePromises);
this._throwNodeError(res as RejectedNodePromises, requestId);
}

const signatureShares: Array<NodeBlsSigningShare> = (
Expand Down Expand Up @@ -2621,7 +2620,7 @@ export class LitNodeClientNodeJs

// -- case: promises rejected
if (!this.#isSuccessNodePromises(res)) {
this._throwNodeError(res as RejectedNodePromises);
this._throwNodeError(res as RejectedNodePromises, requestId);
return {} as SignSessionKeyResponse;
}

Expand Down
8 changes: 6 additions & 2 deletions packages/misc/src/lib/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,28 +129,32 @@ export const throwErrorV1 = ({
status,
message,
errorCode,
requestId,
}: NodeClientErrorV1): never => {
const errConstructorFunc = function (
this: any,
errorKind: string,
status: number,
details: string[],
message?: string,
errorCode?: string
errorCode?: string,
requestId?: string
) {
this.message = message;
this.errorCode = errorCode;
this.errorKind = errorKind;
this.status = status;
this.details = details;
this.requestId = requestId;
};

throw new (errConstructorFunc as any)(
errorKind,
status,
details,
message,
errorCode
errorCode,
requestId
);
};

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/lib/ILitNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export interface ILitNodeClient {
* @returns { void }
*
*/
_throwNodeError(res: RejectedNodePromises): void;
_throwNodeError(res: RejectedNodePromises, requestId: string): void;

// ========== Shares Resolvers ==========
/**
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ export interface NodeClientErrorV1 {
errorCode: string;
details?: string[];
status?: number;
requestId?: string;
}

export interface SigShare {
Expand Down

0 comments on commit 5944cc4

Please sign in to comment.