Skip to content

Commit

Permalink
feat: add mina_requestAccounts provider method and return an empty ar…
Browse files Browse the repository at this point in the history
…ray in response to mina_accounts if the wallet is not connected
  • Loading branch information
DeMonkeyCoder committed Oct 22, 2024
1 parent 1b34dba commit 1c8ad4b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/web-provider/src/mina-network/mina-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,22 @@ export class MinaProvider extends EventEmitter {
if (!initialized) {
throw this.createProviderRpcError(4100, "Unauthorized")
}

const enabled = await this._vault.getEnabled({ origin: requestOrigin })
if (!enabled) {
console.log(args)
if (args.method === "mina_accounts") {
return [] as T
}
}

// check if wallet is locked first
await this.checkAndUnlock()
const enabled = await this._vault.getEnabled({ origin: requestOrigin })
if (!enabled) await this.enable({ origin: requestOrigin })

switch (args.method) {
case "mina_accounts":
case "mina_requestAccounts":
return (await this._vault.getAccounts()) as unknown as T
case "mina_addChain": {
throw this.createProviderRpcError(4200, "Unsupported Method")
Expand Down

0 comments on commit 1c8ad4b

Please sign in to comment.