XLabs / portal-bridge-ui

Portal Bridge UI
https://www.portalbridge.com/
25 stars 37 forks source link

[bug] Flaky connectivity with Metamask #295

Open yuli-ferna opened 1 year ago

yuli-ferna commented 1 year ago

Is there an existing issue for this?

Current Behavior

Connect one leg of the bridge w/ Phantom Connect one leg of the bridge w/ Metamask In step 2 we can´t connnect to Metamask.

Evidence:

https://github.com/XLabs/portal-bridge-ui/assets/35125931/166f9b31-1829-45af-b2ae-6445c1580bcf

Expected Behavior

Use Metamask and Phantom without problem. Here's what works (but not viable for us at the moment) Connect one leg of the bridge (e.g. Solana) with browser extension Connect second leg of the bridge (e.g. Ethereum) with Wallet Connect (Metamask Mobile App)

Steps To Reproduce

Connect one leg of the bridge w/ Phantom Connect one leg of the bridge w/ Metamask Go to step 2 and press Connect Perhaps it flakes because Phantom has some takeover that tries to get you to initiate Phantom for EVM when you click Connect Metamask (this hack exists for multiple wallets like Rabby, etc.)

Environment

- OS: Windows 11
- Wallet: Metamask and Phantom
- Browser: Opera GX LVL 5 (core: 100.0.4815.82)

Anything else?

No response

yuli-ferna commented 1 year ago

The error occurs in the connect() function of the Wallet class of the @xlabs-libs/wallet-aggregator-core. I have talked to @M-Picco and he says that the problem is when you have multiple wallets for a string (or type of strings). All EVM wallets do a kind of override of window.metamask. One explanation he has is that there is a conflict there when you want to connect. Among the tests I performed is to disable Metamask, and I can perform the steps until I get to the redeem step, a transaction error occurs here. TThe only way it will work for me is to copy the source tx, activate metamask again, reload the page, go to the reedem section, put the source tx and complete the process.

Steps to reproduce: Disable Metamask Extension Connect Source with Solana + Phantom wallet Connect Target with Ethereum and choose Metamask option (It fills with Phantom address) Complete the other steps and in the Redeem steps occurs the error. Copy the Source tx and refresh the page Got to Redeem section with Metamask Wallet

Evidence:

Metamask address is the 0x8... and the Phantom address is the 0x6...

https://github.com/XLabs/portal-bridge-ui/assets/35125931/285ab41d-d933-44c6-9f3a-3eb4fc78158e