Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent multiple iframes creation #365

Merged
merged 8 commits into from
Dec 2, 2024
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ await provider.send("eth_requestAccounts", []);
const signer = await provider.getSigner();

// Initialize the SDK
// Note: `idOS.init` must only be called once; calling it again will throw an error.
Mohammed-Mamoun98 marked this conversation as resolved.
Show resolved Hide resolved
const idos = await idOS.init({enclaveOptions: {container: "#idos-container"}});
await idos.setSigner("EVM", signer);

Expand Down
2 changes: 2 additions & 0 deletions packages/idos-sdk-js/src/lib/idos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class idOS {
}

static async init(params: InitParams): Promise<idOS> {
if (idOS.initializing) throw new Error("idOS instance already initialized.");
Mohammed-Mamoun98 marked this conversation as resolved.
Show resolved Hide resolved
idOS.initializing = true;

const idos = new idOS({
Expand Down Expand Up @@ -109,6 +110,7 @@ export class idOS {

async reset({ enclave = false } = {}): Promise<void> {
this.store.reset();
idOS.initializing = false;
if (enclave) await this.enclave.reset();
}

Expand Down
Loading