Skip to content

Commit

Permalink
chore: adding the ability to pass the snapOrigin as a wallet plugin a…
Browse files Browse the repository at this point in the history
…rgument
  • Loading branch information
dafuga committed Aug 16, 2024
1 parent cc90d78 commit 1b8266c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ export type GetSnapsResponse = Record<string, Snap>

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,
Expand All @@ -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<WalletPluginLoginResponse> {
const promise = this.metamaskLogin(context)
return cancelable(promise, (canceled) => {
Expand Down

0 comments on commit 1b8266c

Please sign in to comment.