Skip to content

Commit 76f7f3d

Browse files
committed
feat: add logging
1 parent a5e740e commit 76f7f3d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/core/src/core.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ class ThresholdKey implements ITKey {
335335
throw CoreError.default("Input is not supported");
336336
}
337337

338+
console.log("have shareStore from postboxkey for polynomial", shareStore.polynomialID);
339+
338340
// We determine the latest metadata on the SDK and if there has been
339341
// needed transitions to include
340342
let currentMetadata: Metadata;
@@ -353,6 +355,12 @@ class ThresholdKey implements ITKey {
353355
}
354356
}
355357

358+
console.log("latestShareDetails polyIDList", latestShareDetails.shareMetadata.polyIDList);
359+
console.log("latestShareDetails latestShare polynomialID", latestShareDetails.latestShare.polynomialID);
360+
361+
console.log("reinitializing", reinitializing);
362+
console.log("reinitializingWithNewKeyAssign", reinitializingWithNewKeyAssign);
363+
356364
// lets check if the cloud metadata has been updated or not from previously if we are reinitializing
357365
if (reinitializing && !reinitializingWithNewKeyAssign) {
358366
if (previouslyFetchedCloudMetadata.nonce < latestShareDetails.shareMetadata.nonce) {
@@ -375,11 +383,17 @@ class ThresholdKey implements ITKey {
375383
currentMetadata = latestShareDetails.shareMetadata;
376384
}
377385

386+
console.log("Final currentM etadata polyIDList", currentMetadata.polyIDList);
387+
console.log("Final currentM etadata PublicPolynomial", currentMetadata.publicPolynomials);
388+
console.log("Final currentM etadata latestShare polynomialID", currentMetadata.getLatestPublicPolynomial().getPolynomialID());
389+
378390
this.lastFetchedCloudMetadata = latestCloudMetadata;
379391
this.metadata = currentMetadata.clone();
380392
const latestShare = latestShareDetails ? latestShareDetails.latestShare : shareStore;
381393
this.inputShareStore(latestShare);
382394

395+
console.log("Final latest share polyIDList", latestShare.polyIDList);
396+
383397
if (importEd25519Seed && this.getEd25519PublicKey()) {
384398
throw CoreError.default("Ed25119 key already exists");
385399
}
@@ -402,8 +416,13 @@ class ThresholdKey implements ITKey {
402416
}): Promise<CatchupToLatestShareResult> {
403417
const { shareStore, polyID, includeLocalMetadataTransitions } = params;
404418
let shareMetadata: Metadata;
419+
console.log("catchupToLatestShare");
405420
try {
421+
console.log("shareStore PolynomialID", shareStore.polynomialID);
406422
shareMetadata = await this.getAuthMetadata({ privKey: shareStore.share.share, includeLocalMetadataTransitions });
423+
console.log("shareMetadata PolynomialID", shareMetadata.polyIDList);
424+
console.log("shareMetadata PublicPolynomial", shareMetadata.publicPolynomials);
425+
console.log("shareMetadata PublicPolynomial", shareMetadata.getLatestPublicPolynomial().getPolynomialID());
407426
} catch (error: unknown) {
408427
// delete share error
409428
const err = error as Error & { code?: number };
@@ -422,6 +441,7 @@ class ThresholdKey implements ITKey {
422441
}
423442
}
424443
const nextShare = await shareMetadata.getEncryptedShare(shareStore);
444+
console.log("have nextShare for share", shareStore.polynomialID);
425445
return await this.catchupToLatestShare({ shareStore: nextShare, polyID, includeLocalMetadataTransitions });
426446
} catch (error: unknown) {
427447
// delete share error
@@ -816,7 +836,10 @@ class ThresholdKey implements ITKey {
816836
throw CoreError.metadataUndefined();
817837
}
818838
const poly = this.metadata.getLatestPublicPolynomial();
839+
console.log("getKeyDetails polyIDList", poly);
819840
const previousPolyID = poly.getPolynomialID();
841+
console.log("share polynomialID", Object.keys(this.shares));
842+
820843
const requiredShares = poly.getThreshold() - Object.keys(this.shares[previousPolyID]).length;
821844

822845
let shareDescriptions = this.metadata.getShareDescription();

0 commit comments

Comments
 (0)