Skip to content

Commit

Permalink
More tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Feb 11, 2025
1 parent a954234 commit c6255b0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
25 changes: 25 additions & 0 deletions packages/credential-sdk/src/types/accumulator/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ export class CheqdMainnetAccumulatorPublicKeyRef extends CheqdAccumulatorPublicK
}

export class DockOrCheqdAccumulatorPublicKeyRef extends TypedTuple {
constructor(...args) {
super(...args);

if (this[0].isCheqd) {
return CheqdAccumulatorPublicKeyRef.from(this);
} else if (
this[0].isDock
&& this[1] instanceof DockAccumulatorPublicKeyId
) {
return DockAccumulatorPublicKeyRef.from(this);
} else {
throw new Error(`Must be dock or cheqd, got: \`${this[0]}\``);
}
}

static Classes = [
NamespaceDid,
anyOf(DockAccumulatorPublicKeyId, CheqdAccumulatorPublicKeyId),
Expand All @@ -59,6 +74,16 @@ export class CheqdMainnetAccumulatorParamsRef extends CheqdAccumulatorParamsRef
}

export class DockOrCheqdAccumulatorParamsRef extends TypedTuple {
constructor(...args) {
super(...args);

if (this[0].isCheqd) {
return CheqdAccumulatorParamsRef.from(this);
} else if (this[0].isDock && this[1] instanceof DockAccumulatorParamsId) {
return DockAccumulatorParamsRef.from(this);
}
}

static Classes = [
NamespaceDid,
anyOf(DockAccumulatorParamsId, CheqdAccumulatorParamsId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,15 @@ export class CheqdMainnetOffchainSignatureParamsRef extends CheqdDLRRef {
}

export class DockOrCheqdOffchainSignatureParamsRef extends TypedTuple {
constructor(...args) {
super(...args);

if (this[0].isCheqd) {
return CheqdOffchainSignatureParamsRef.from(this);
} else if (this[0].isDock && this[1] instanceof DockParamsId) {
return DockOffchainSignatureParamsRef.from(this);
}
}

static Classes = [NamespaceDid, anyOf(DockParamsId, CheqdParamsId)];
}
16 changes: 12 additions & 4 deletions packages/credential-sdk/tests/__snapshots__/document.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,9 @@ exports[`DID document workflow \`DIDDocument\` 3`] = `
"metadata": {
"curveType": "Bls12381",
"paramsRef": [
"did:dock:5GdBBJdo3EWbbVpehRMUkGqfyEm7TJ7ugGCoPKNXzqrgPQqT",
{
"did": "0xc9b4c22c2f5738b0adaf605a8233cdc2451c5ece045c25a3bc2b4c840fe9b11d",
},
0,
],
"participantId": null,
Expand All @@ -691,7 +693,9 @@ exports[`DID document workflow \`DIDDocument\` 3`] = `
"metadata": {
"curveType": "Bls12381",
"paramsRef": [
"did:dock:5GdBBJdo3EWbbVpehRMUkGqfyEm7TJ7ugGCoPKNXzqrgPQqT",
{
"did": "0xc9b4c22c2f5738b0adaf605a8233cdc2451c5ece045c25a3bc2b4c840fe9b11d",
},
1,
],
"participantId": null,
Expand Down Expand Up @@ -735,7 +739,9 @@ exports[`DID document workflow \`DIDDocument\` 3`] = `
"metadata": {
"curveType": "Bls12381",
"paramsRef": [
"did:dock:5GdBBJdo3EWbbVpehRMUkGqfyEm7TJ7ugGCoPKNXzqrgPQqT",
{
"did": "0xc9b4c22c2f5738b0adaf605a8233cdc2451c5ece045c25a3bc2b4c840fe9b11d",
},
2,
],
"participantId": null,
Expand All @@ -749,7 +755,9 @@ exports[`DID document workflow \`DIDDocument\` 3`] = `
"metadata": {
"curveType": "Bls12381",
"paramsRef": [
"did:dock:5GdBBJdo3EWbbVpehRMUkGqfyEm7TJ7ugGCoPKNXzqrgPQqT",
{
"did": "0xc9b4c22c2f5738b0adaf605a8233cdc2451c5ece045c25a3bc2b4c840fe9b11d",
},
3,
],
"participantId": null,
Expand Down

0 comments on commit c6255b0

Please sign in to comment.