Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: (WC) do not return Safe as available on all optional Namespaces #3725

Merged
merged 4 commits into from
May 24, 2024

Conversation

schmanu
Copy link
Member

@schmanu schmanu commented May 16, 2024

What it solves

Sometimes the chainChanged event is ignored if the connected dapp did not acknowledge the new session yet.
Then the dapp is stuck with a wrong chain on which the Safe is not deployed.

How this PR fixes it

  • Only uses our workaround if the Safe is not present in the requiredNamespace

How to test it

  • Connect to uniswap with a polygon Safe
  • observe that the Safe is correctly recognized on Polygon

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

Copy link

github-actions bot commented May 16, 2024

Copy link

github-actions bot commented May 16, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link

github-actions bot commented May 16, 2024

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 1012.38 KB (🟡 +1 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Copy link

github-actions bot commented May 16, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.26% (-0.02% 🔻)
11629/14672
🔴 Branches
58.14% (-0.04% 🔻)
2751/4732
🟡 Functions
66.33% (-0.04% 🔻)
1866/2813
🟢 Lines
80.62% (-0.02% 🔻)
10480/13000
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / index.tsx
82.35% (-8.82% 🔻)
66.67% (-16.67% 🔻)
50% (-12.5% 🔻)
83.87% (-9.68% 🔻)
🟢
... / WalletConnectWallet.ts
90.36% (-0.11% 🔻)
89.47% (-1% 🔻)
84%
92.41% (-0.09% 🔻)

Test suite run success

1468 tests passing in 202 suites.

Report generated by 🧪jest coverage report action from eec99d2

@katspaugh katspaugh changed the title fix: do not return Safe as available on all optional Namespaces fix: (WC) do not return Safe as available on all optional Namespaces May 16, 2024
@schmanu schmanu requested a review from katspaugh May 16, 2024 09:50
Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦸

@schmanu schmanu self-assigned this May 16, 2024
requiredChains.map(stripEip155Prefix),
optionalChains.map(stripEip155Prefix),
)
const supportedChainIds = [currentChainId].concat(requiredChains.map(stripEip155Prefix))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't add the optional chains wouldn't that mean that the moment you switch your network the connection will be closed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I will readd those :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can not return a chainId in the namespace without an account. So we would be stuck with the same workaround in the end which caused the bug.
I feel like having to reconnect after switching to another Safe is the lesser devil than not being able to connect on any chain other than mainnet. But We should discuss this.

@francovenica
Copy link
Contributor

francovenica commented May 17, 2024

I got this alert/prompt when I tried to connect in Uniswap with Polygon which I don't think is intended

image

After accepting it (I wrote "Continue" but idk what to write because it doesn't say) didn't tirgger anymore, the only way to trigger it is by clearing the LS and cache of the safe app and trying again

Go to Uniswap, set it to ethereum there
Open the WC modal and copy the hash
Go to the safe app in a safe in Polygon
Paste the code in the WC modal to connect
The popUp should show up

@francovenica
Copy link
Contributor

I'm having different behaviors between current prod, this PR and Uniswap and I don't know if they are intended.

In prod, you can easily change from one network to the other no problem, but if you try in this PR the Uniswap app will tell you that you wallet doesn't support the networks (tried also in prod CGW since it has all networks but with same result.

Although it might be considered an issue on Uniswap side, is weird that the behavior changes depending if we use the PR or current Prod
In prod:
uni in prod

Using this PR:
uni in PR

@francovenica
Copy link
Contributor

I tried to connect to OpenSea several times. In the safe app you can see the connection (in the top bar) but in openSea, or the WC modal with the QR code doesn't even close or the WC option in the modal where you select the wallet shows a infinite loading icon.
I never got the message that OpenSea makes you sign to connect in the safe

I'm not don't know if this an issue from OpenSea side, but in current prod the connection works fine (the message pop's up, I signed, I connect just fine...)

@schmanu
Copy link
Member Author

schmanu commented May 24, 2024

I got this alert/prompt when I tried to connect in Uniswap with Polygon which I don't think is intended

image

After accepting it (I wrote "Continue" but idk what to write because it doesn't say) didn't tirgger anymore, the only way to trigger it is by clearing the LS and cache of the safe app and trying again

Go to Uniswap, set it to ethereum there Open the WC modal and copy the hash Go to the safe app in a safe in Polygon Paste the code in the WC modal to connect The popUp should show up

@francovenica
I cannot reproduce this. Tried it multiple times for me the following happens, which is also expected and correct:

  1. I open Uniswap on Ethereum Mainnet
  2. I click on connect wallet via Wallet Connect and copy the hash
  3. I go to our Safe Wallet interface and open a Safe on Polygon
  4. Now I copy the hash into the WC Modal in that Safe
  5. The Safe connects, no pop up shows and uniswap switches to Polygon

@schmanu
Copy link
Member Author

schmanu commented May 24, 2024

I'm having different behaviors between current prod, this PR and Uniswap and I don't know if they are intended.

In prod, you can easily change from one network to the other no problem, but if you try in this PR the Uniswap app will tell you that you wallet doesn't support the networks (tried also in prod CGW since it has all networks but with same result.

Although it might be considered an issue on Uniswap side, is weird that the behavior changes depending if we use the PR or current Prod In prod:

This is expected and this is actually what this fix does:

  • In current Prod we pretend that the Safe exists on all networks, but in fact it only exists on Mainnet. Switching to a network where the Safe does not exist should not be offered by Uniswap

@schmanu
Copy link
Member Author

schmanu commented May 24, 2024

I tried to connect to OpenSea several times. In the safe app you can see the connection (in the top bar) but in openSea, or the WC modal with the QR code doesn't even close or the WC option in the modal where you select the wallet shows a infinite loading icon. I never got the message that OpenSea makes you sign to connect in the safe

I'm not don't know if this an issue from OpenSea side, but in current prod the connection works fine (the message pop's up, I signed, I connect just fine...)

I also can not reproduce this:
I tried different Safes now on Mainnet, Optimism and Polygon and connection / signing the login message always worked without any issues :/

Copy link

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@francovenica
Copy link
Contributor

Well, I tried to reproduce again the issues I reported, but they are working fine now

I cannot make that prompt to show up anymore
OpenSea is connecting fine now in different networks

I already tried Curve and Safe-as-owner and those work fine as well
Checked that chaning network in the safe app disconnects the current connected dapp in the WC topbar

LGTM

@schmanu schmanu merged commit 433bb16 into dev May 24, 2024
14 checks passed
@schmanu schmanu deleted the fix/wallet-connect-chainId branch May 24, 2024 15:41
@github-actions github-actions bot locked and limited conversation to collaborators May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants