From 1b8266c0a1ca0f0575ee794e5988ee7eb5b9800d Mon Sep 17 00:00:00 2001 From: dafuga Date: Fri, 16 Aug 2024 12:09:11 -0700 Subject: [PATCH] chore: adding the ability to pass the snapOrigin as a wallet plugin argument --- src/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/index.ts b/src/index.ts index efac9d5..edb7ffe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,11 +22,17 @@ export type GetSnapsResponse = Record export * from './metamask' +interface WalletPluginMetaMaskConfig { + snapOrigin?: string +} + const defaultSnapOrigin = 'local:http://localhost:8080' // const defaultSnapOrigin = 'npm:@greymass/test-snap' export class WalletPluginMetaMask extends AbstractWalletPlugin implements WalletPlugin { public id = 'wallet-plugin-metamask' + public snapOrigin: string + readonly config: WalletPluginConfig = { requiresChainSelect: true, requiresPermissionSelect: true, @@ -39,6 +45,12 @@ export class WalletPluginMetaMask extends AbstractWalletPlugin implements Wallet download: '', }) + constructor(walletPluginMetaMaskConfig?: WalletPluginMetaMaskConfig) { + super() + + this.snapOrigin = walletPluginMetaMaskConfig?.snapOrigin || defaultSnapOrigin + } + login(context: LoginContext): Cancelable { const promise = this.metamaskLogin(context) return cancelable(promise, (canceled) => {