Skip to content

Commit

Permalink
adding custom call method to kwill wrapper + add shareToGrantee param…
Browse files Browse the repository at this point in the history
…eter to createCredential
  • Loading branch information
Mohammed-Mamoun98 committed Dec 9, 2024
1 parent aeda550 commit 6d9c0a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/issuer-sdk-demo/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createCredentialPermissioned,
createHuman,
editCredential,
shareCredentialByGrant,
} from "@idos-network/issuer-sdk-js";
import * as Base64 from "@stablelib/base64";
import * as Utf8 from "@stablelib/utf8";
Expand Down Expand Up @@ -75,14 +76,26 @@ export async function createProfile(
export async function createCredentialByWriteGrant(
humanId: string,
userEncryptionPublicKey: string,
sharedToGrantee = "0x86D603BcE418A44b7F5fBf434a5c4f3215Dc5847",
) {
const issuer = await getIssuerConfig();

await createCredentialByGrant(issuer, {
const credential = {
humanId,
plaintextContent: vcContent,
publicNotes: JSON.stringify({ ...publicNotes, id: crypto.randomUUID() }),
receiverEncryptionPublicKey: Base64.decode(userEncryptionPublicKey),
};

const res = await createCredentialByGrant(issuer, credential);
if (!sharedToGrantee) return res;
await shareCredentialByGrant(issuer, {
...credential,
originalCredentialId: res.id,
lockedUntil: Math.floor(Date.now() / 1000) + 100,
grantee: sharedToGrantee,
id: crypto.randomUUID(),
publicNotes: "",
});
}

Expand Down
5 changes: 5 additions & 0 deletions packages/idos-sdk-js/src/lib/kwil-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ export class KwilWrapper {
return human;
}

async customCall(method: string) {
const result = (await this.call(method, null)) as unknown;
return result;
}

async hasProfile(address: string): Promise<boolean> {
// biome-ignore lint/suspicious/noExplicitAny: TBD
const result = (await this.call("has_profile", { address }, undefined, false)) as any;
Expand Down

0 comments on commit 6d9c0a6

Please sign in to comment.