DePayFi / widgets

💸 Payments directly into your wallet. DePay simplifies and improves Web3 Payments with the power of DeFi. Accept any token with on-the-fly conversion and state-of-the-art widgets.
https://depay.com
MIT License
97 stars 36 forks source link

Switch networks during the payment tip error with "WRONG_NETWORK" #91

Closed dingcxx closed 1 year ago

dingcxx commented 1 year ago

We have discovered an issue when switch networks during the payment. When entering the dapp, the selected wallet is ETH, but during payment, Polygon is chosen as the payment method. After successfully switching, an error message appears indicating a network error. Please refer to the video and pictures below for more details.

https://user-images.githubusercontent.com/117795329/231738584-6147686d-fc42-48af-a71c-32edc817b4e6.MP4

IMG_1990

10xSebastian commented 1 year ago

Thanks for reporting this.

Do you know which version of DePay widgets is used in the video?

10xSebastian commented 1 year ago

I quickly confirmed in metamask that network switching works, and it does:

https://user-images.githubusercontent.com/851393/231747058-6937f5de-0794-49dc-a538-28c62711f332.MP4


Here are the standards we are using to

Detect currently connected network

await window.ethereum.request({ method: 'eth_chainId' })

make sure this returns 0x89 for polygon.

Switch to the intended network

If we detect the wallet is not connected to polygon, we initiate network switch:

window.ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: '0x89' }] })

make sure subsequent requests for

await window.ethereum.request({ method: 'eth_chainId' })

return 0x89 after switching to Polygon.

dingcxx commented 1 year ago

Thanks for reporting this.

Do you know which version of DePay widgets is used in the video?

In our yarn.lock file, we are using version 10.2.8 of @depay/widgets. Due to the use of continuous integration, it is uncertain whether or not it will be updated.

I quickly confirmed in metamask that network switching works, and it does:

Here are the standards we are using to

Detect currently connected network

await window.ethereum.request({ method: 'eth_chainId' })

make sure this returns 0x89 for polygon.

Switch to the intended network

If we detect the wallet is not connected to polygon, we initiate network switch:

window.ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: '0x89' }] })

make sure subsequent requests for

await window.ethereum.request({ method: 'eth_chainId' })

return 0x89 after switching to Polygon.

This operation has been completed by a third party, and I have informed them to try it out. thank you