Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Dec 3, 2024
1 parent 5aa71a4 commit ccfb806
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function generateStatusListCredentialModuleTests(
expect(written2.toJSON()).toEqual(statusListCredential2.toJSON());
});

test('Generates a `DIDDocument` and cretes and then updates a `StatusListCredential` owned by this DID', async () => {
test('Generates a `DIDDocument` and creates and then updates a `StatusListCredential` owned by this DID', async () => {
const did = DID.random();

const keyPair = Ed25519Keypair.random();
Expand Down
4 changes: 2 additions & 2 deletions packages/dock-blockchain-modules/src/attest/module.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AbstractAttestModule } from '@docknetwork/credential-sdk/modules';
import { ensureTargetKeypair, injectDock } from '../common';
import { targetKeypair, injectDock } from '../common';
import DockInternalAttestModule from './internal';

export default class DockAttestModule extends injectDock(AbstractAttestModule) {
Expand All @@ -21,7 +21,7 @@ export default class DockAttestModule extends injectDock(AbstractAttestModule) {
* @param signingKeyRef
*/
async setClaimTx(iri, targetDid, didKeypair) {
ensureTargetKeypair(targetDid, didKeypair);
targetKeypair(targetDid, didKeypair);
const currentPriority = (await this.dockOnly.attest(targetDid)).priority?.value ?? 0;

return await this.dockOnly.tx.setClaim(
Expand Down
12 changes: 6 additions & 6 deletions packages/dock-blockchain-modules/src/common/keypair.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ export const allSigners = (didKeypair) => [].concat(didKeypair).map((keyPair) =>
export const firstSigner = (didKeypair) => {
const signers = allSigners(didKeypair);
if (signers.length !== 1) {
throw new Error(`Must provide 1 valid did keypair, received ${signers.length}`);
throw new Error(`Must provide 1 valid DID keypair, received ${signers.length}`);
}

return signers[0];
};

export const ensureTargetKeypair = (targetDid, didKeypair) => {
const includes = allSigners(didKeypair)
.some(
export const targetKeypair = (targetDid, didKeypair) => {
const signerKp = allSigners(didKeypair)
.find(
(keyPair) => keyPair.did.eq(targetDid),
);

if (!includes) {
if (signerKp == null) {
throw new Error(`No keypair provided for ${targetDid}`);
}

return didKeypair;
return signerKp;
};

0 comments on commit ccfb806

Please sign in to comment.