Skip to content

Commit

Permalink
Fix potential double loading of identity Wasm (#945)
Browse files Browse the repository at this point in the history
* fix potential double loading of identity wasm

* linter: fix format

---------

Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
eike-hass and begonaalvarezd authored Jan 18, 2024
1 parent 5e3f847 commit 1498be6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/src/services/identityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { CHRYSALIS, STARDUST } from "~models/config/protocolVersion";
import * as identity from "@iota/identity-wasm/web";

export class IdentityService {
private initLibraryPromise: Promise<void> | undefined;

/**
* Resolves DID into it's DID document (Chrysalis).
* @param {string} did DID to be resolved
Expand Down Expand Up @@ -66,6 +68,10 @@ export class IdentityService {
}

public async initLibrary(path = "/wasm/identity_wasm_bg.wasm") {
return await identity.init(path);
if (!this.initLibraryPromise) {
this.initLibraryPromise = identity.init(path);
}

return this.initLibraryPromise;
}
}

0 comments on commit 1498be6

Please sign in to comment.