From a701806b26881ef0c1e58f7ada0751e6e8902543 Mon Sep 17 00:00:00 2001 From: stanleyyuen <102275989+stanleyyconsensys@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:49:54 +0800 Subject: [PATCH 1/2] fix: remove duplicate snap installation prompt in get-starknet if it has installed --- packages/get-starknet/src/snap.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/get-starknet/src/snap.ts b/packages/get-starknet/src/snap.ts index 17149863..6a4ab976 100644 --- a/packages/get-starknet/src/snap.ts +++ b/packages/get-starknet/src/snap.ts @@ -424,15 +424,23 @@ export class MetaMaskSnap { } async installIfNot(): Promise { + // if the snap is already installed, return true, to bypass the prompt + if (await this.isInstalled()) { + return true + } + const response = (await this.#provider.request({ method: 'wallet_requestSnaps', params: { [this.#snapId]: { version: this.#version }, }, })) as RequestSnapResponse; + + // if the snap installation is deined by end user, return false if (!response?.[this.#snapId]?.enabled) { return false; } + return true; } From 832352a48208fba0e3fc9a8295484fad7ea1a483 Mon Sep 17 00:00:00 2001 From: stanleyyuen <102275989+stanleyyconsensys@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:54:05 +0800 Subject: [PATCH 2/2] fix: lint --- packages/get-starknet/src/snap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/get-starknet/src/snap.ts b/packages/get-starknet/src/snap.ts index 6a4ab976..399e724b 100644 --- a/packages/get-starknet/src/snap.ts +++ b/packages/get-starknet/src/snap.ts @@ -426,7 +426,7 @@ export class MetaMaskSnap { async installIfNot(): Promise { // if the snap is already installed, return true, to bypass the prompt if (await this.isInstalled()) { - return true + return true; } const response = (await this.#provider.request({