wevm / wagmi

React Hooks for Ethereum
https://wagmi.sh
MIT License
5.79k stars 968 forks source link

Metamask sdk unhandled error : packages/connectors/src/metaMask.ts #4104

Closed abhiseanetwork closed 1 week ago

abhiseanetwork commented 1 week ago

Check existing issues

Describe the bug

metamask sdk return error: MetaMask - RPC Error: User rejected the request.

file : packages/connectors/src/metaMask.ts wagmi awaits:

const requestedAccounts = (await sdk.connect());
accounts = requestedAccounts.map((x)=>( ...))

unhandled if requestedAccounts is undefined

which in turn throws error in wagmi client: error TypeError: Cannot read properties of undefined (reading 'map')

Link to Minimal Reproducible Example

No response

Steps To Reproduce

  1. use connector through wagmi- metamask sdk and desktop connection
  2. reject user connector by cancelling the metamask connection request
  3. useConnect hook will throw error : TypeError: Cannot read properties of undefined (reading 'map')

What Wagmi package(s) are you using?

wagmi

Wagmi Package(s) Version(s)

2.10.6

Viem Version

2.16.2

TypeScript Version

5.1.6

Anything else?

No response

github-actions[bot] commented 1 week ago

Hello @abhiseanetwork.

Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository.

Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster.

Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue.