rainbow-me / rainbowkit

The best way to connect a wallet 🌈 🧰
https://rainbowkit.com
MIT License
2.42k stars 643 forks source link

While doing transaction from metamask User rejected request error thrown #2122

Closed Snehagupta1907 closed 2 months ago

Snehagupta1907 commented 2 months ago

Is there an existing issue for this?

RainbowKit Version

2.1.3

wagmi Version

2.6.7

Current Behavior

If the browser has phantom and metamask wallet then doing any transaction using metamask user rejected request error thrown but if we delete the phantom wallet from browsers everything works fine.

issue is here

this.selectExtension = ()=>jt(this, null, function*() { var e; if (!this.targetProvider && !this.isSelectingExtension) { this.isSelectingExtension = !0; try { let t = (e = Yf.phantom) == null ? void 0 : e.ethereum; if (t) { if (!this.detected.length) { this.setProvider(t), window.dispatchEvent(new Event("ethereum#initialized")); return } switch (yield t.request({ method: "wallet_selectEthereumProvider", params: [] })) { case "ALWAYS_USE_PHANTOM": case "CONTINUE_WITH_PHANTOM": { this.setProvider(t); break } case "CONTINUE_WITH_METAMASK": case "ALWAYS_USE_METAMASK": { let[o] = this.detected; for (let s of this.detected) s.isMetaMask && this.setProvider(s); !this.targetProvider && o && this.setProvider(o); break } } } } catch (t) { console.error(t) } finally { this.isSelectingExtension = !1 } }

Expected Behavior

We want that if the browser has any wallet irrespective, if we choose metamask and it get connected so transaction should proceed.

Steps To Reproduce

Just install both metamask and phantom try to do evm transaction from metamask.

like any send transaction method for let say on polygon amoy chain ....keeping metamask and phantom wallet in the browser

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

Use chrome browser

magiziz commented 2 months ago

@Snehagupta1907 I'm not able to reproduce this. Can you try testing it in our example dApp ? https://rainbowkit-example.vercel.app/

Snehagupta1907 commented 2 months ago

@magiziz Can you share the version cause when i am trying to use for even send transaction this error coming image image

coming from file VM of rainbowkit

Snehagupta1907 commented 2 months ago

try { let t = (e = Yf.phantom) == null ? void 0 : e.ethereum; if (t) { if (!this.detected.length) { this.setProvider(t), window.dispatchEvent(new Event("ethereum#initialized")); return } switch (yield t.request({ method: "wallet_selectEthereumProvider", params: [] })) { case "ALWAYS_USE_PHANTOM": case "CONTINUE_WITH_PHANTOM": { this.setProvider(t); break } case "CONTINUE_WITH_METAMASK": case "ALWAYS_USE_METAMASK": { let[o] = this.detected; for (let s of this.detected) s.isMetaMask && this.setProvider(s); !this.targetProvider && o && this.setProvider(o); break } } } } catch (t) { console.error(t) } finally { this.isSelectingExtension = !1 }

                This complete script of that VM
Snehagupta1907 commented 2 months ago

https://streamnft-rent.vercel.app/polygon%20amoy

try lending nft on bayc polygon amoy ....if you want i can share the nft

MatthewGreenberg commented 2 months ago

if my google chrome has both the phatom wallet and metamask extension, my application doesn't load and just crashes. Removing either one makes the app work again. Sorry if this is irrelevant to the above conversation but the interplay between those two wallets is causing me issues as well, thanks.

Snehagupta1907 commented 2 months ago

yes exactly ...if we delete one wallet it works fine but expected is that should work always irrespective of wallets in the browser

magiziz commented 2 months ago

@Snehagupta1907 The code you provided doesn't seem to use any Wagmi hooks. Can you share a minimal reproducible example which uses Wagmi and RainbowKit ? CodeSandbox or github repo link would be enough.

@MatthewGreenberg The app seems to work fine if i enable both extensions. You can test it here as well https://rainbowkit-example.vercel.app

image
Snehagupta1907 commented 2 months ago

code is using the wagmi hooks....and sorry i can't share the code repo as it's private

Snehagupta1907 commented 2 months ago

version of wagmi and rainbowkit which i am using i have shatre that above

Snehagupta1907 commented 2 months ago

can you share your code for the application if possible

Snehagupta1907 commented 2 months ago

I ahve share the code snippet where it is throwing error can you please look it up ASAP

magiziz commented 2 months ago

@Snehagupta1907 Here is the source code for the example dApp https://github.com/rainbow-me/rainbowkit/tree/main/packages/example

The code you provided is from a webpack build file and i can't see any Wagmi hooks being used. Can you share a small reproducible example which uses Wagmi and RainbowKit ?

Snehagupta1907 commented 2 months ago

image image image image

you can refer to this here clearly it is checking phantom and metamask

Snehagupta1907 commented 2 months ago

and error t is thrown...user rejected error

Snehagupta1907 commented 2 months ago

i am using ether js for contract integration

magiziz commented 2 months ago

@Snehagupta1907 I'm not able to see that you use Wagmi here. Are you manually accessing the window.ethereum API without using Wagmi ?

Snehagupta1907 commented 2 months ago

i am using wagmi...idk from which module that code is coming

magiziz commented 2 months ago

I'm going to close this issue since no minimal reproducible example was provided. Feel free to re-open this issue with a reproducible example or create a new one.