From 1498be6d8019b7e596d57a742f1856cce383e786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eike=20Ha=C3=9F?= Date: Thu, 18 Jan 2024 18:38:38 +0100 Subject: [PATCH] Fix potential double loading of identity Wasm (#945) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix potential double loading of identity wasm * linter: fix format --------- Co-authored-by: Begoña Álvarez de la Cruz --- client/src/services/identityService.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/services/identityService.ts b/client/src/services/identityService.ts index 887eea416..2c5f861f3 100644 --- a/client/src/services/identityService.ts +++ b/client/src/services/identityService.ts @@ -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 | undefined; + /** * Resolves DID into it's DID document (Chrysalis). * @param {string} did DID to be resolved @@ -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; } }