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

feat: Auto approve verified WC sessions #3455

Merged
merged 3 commits into from
Mar 25, 2024
Merged

feat: Auto approve verified WC sessions #3455

merged 3 commits into from
Mar 25, 2024

Conversation

usame-algan
Copy link
Member

@usame-algan usame-algan commented Mar 19, 2024

What it solves

Resolves #3395

How this PR fixes it

  • Stores approvals for verified dApps per chain and auto approves future sessions

How to test it

  1. Open a Safe
  2. Open a verified dApp (e.g. CowSwap)
  3. Connect CowSwap to your Safe
  4. A green message should be visible on the Approve screen
  5. Press Approve
  6. Disconnect the session and connect to CowSwap again
  7. Observe no Approve screen and automatically connecting
  8. Switch to a different chain and connect with CowSwap again
  9. Observe the session is not auto approved
  10. Oberve that the dialog closes on approval

Screenshots

Screen.Recording.2024-03-19.at.11.58.10.mov

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 Mar 19, 2024

@usame-algan
Copy link
Member Author

Two more ideas:

  • We could also auto approve for unverified domains or display a checkbox on the approval screen to "Skip this step next time"
  • We could close the WC dialog on successful approvals

Copy link

github-actions bot commented Mar 19, 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 Mar 19, 2024

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

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

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 994.24 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 Mar 19, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.38% (-0.02% 🔻)
11124/14013
🔴 Branches
58.44% (-0.06% 🔻)
2613/4471
🟡 Functions
66.09% (+0.11% 🔼)
1795/2716
🟢 Lines
80.64% (-0.07% 🔻)
10020/12425
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟡
... / index.tsx
73.08% 62.96% 53.33% 73.74%
🟢
... / index.tsx
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / sdk.ts
69.05% (-7.14% 🔻)
35.29% (-9.15% 🔻)
72.73% (-2.27% 🔻)
68% (-9.03% 🔻)
🟡
... / wallets.ts
62.86% (-3.81% 🔻)
25%
75% (-2.78% 🔻)
65.52% (-3.23% 🔻)
🔴
... / useOnboard.ts
50.38% (-0.4% 🔻)
23.81% 15%
52.99% (-0.52% 🔻)
🟢
... / index.tsx
82.35% (-8.82% 🔻)
66.67% (-16.67% 🔻)
50% (-12.5% 🔻)
83.87% (-9.68% 🔻)
🟢
... / WalletConnectWallet.ts
90.48% (-0.22% 🔻)
90.48% (-1.19% 🔻)
84%
92.5% (-0.18% 🔻)
🔴
... / GlobalPushNotifications.tsx
61.76% (-0.44% 🔻)
38.18% (-0.39% 🔻)
57.14% (-1.59% 🔻)
58.56% (-0.68% 🔻)
🟡
... / SocialWalletService.ts
60% (-9.47% 🔻)
50% (-16.67% 🔻)
46.15% (-7.18% 🔻)
61.11% (-9.22% 🔻)
🟢
... / index.tsx
87.76% (-0.24% 🔻)
73.33% 100%
90.91% (-0.2% 🔻)

Test suite run success

1412 tests passing in 195 suites.

Report generated by 🧪jest coverage report action from 4217765

Base automatically changed from wc-loading to dev March 19, 2024 12:58
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.

👍

@@ -162,7 +141,7 @@ const WcProposalForm = ({ proposal, setProposal }: ProposalFormProps): ReactElem
{isLoading === WCLoadingState.REJECT ? <CircularProgress size={20} /> : 'Reject'}
</Button>

<Button variant="contained" onClick={onApprove} className={css.button} disabled={disabled}>
<Button variant="contained" onClick={() => onApprove()} className={css.button} disabled={disabled}>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Button variant="contained" onClick={() => onApprove()} className={css.button} disabled={disabled}>
<Button variant="contained" onClick={onApprove} className={css.button} disabled={disabled}>

Copy link
Member Author

Choose a reason for hiding this comment

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

onApprove takes an optional parameter and in this case we don't want to pass it but onClick passes an event object so we have to wrap the onApprove call.

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 1 0
Ignored 0 N/A
  • Result: ✅ success

  • Annotations: 1 total


[warning] react-hooks/exhaustive-deps

verifies the list of dependencies for Hooks like useEffect and similar


Report generated by eslint-plus-action

@francovenica
Copy link
Contributor

Looks good. It works fine but I still have a question on this

Question:
I noticed that CowSwap has the green squre with the checkmark which I assume means is a trusted one.
Which apps are trusted and which ones are not? I tried with Uniswap and it seems to not be a trusted one, since it doesn't have that green checkbox, but Uniswap I think is a very well known app

Another question is, should we tell the user that "trusted apps will autoconnect after the first approve"? Should we let the user wonder why this app connects automatically and that other app does not. I don't think that the green checkbox conveys that message clearly

Comparison between Cowswap and Uniswap
image
image

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

@usame-algan
Copy link
Member Author

I noticed that CowSwap has the green squre with the checkmark which I assume means is a trusted one.
Which apps are trusted and which ones are not? I tried with Uniswap and it seems to not be a trusted one, since it doesn't have that green checkbox, but Uniswap I think is a very well known app

Another question is, should we tell the user that "trusted apps will autoconnect after the first approve"? Should we let the user wonder why this app connects automatically and that other app does not. I don't think that the green checkbox conveys that message clearly

I think a lot of legit dApps are not verified unfortunately. We discussed it this morning and decided to auto approve all dApps (verified and unverified). The only dApps we don't auto-approve are either scams or where there is a domain mismatch.

@usame-algan usame-algan merged commit 9a743d1 into dev Mar 25, 2024
14 checks passed
@usame-algan usame-algan deleted the wc-auto-approve branch March 25, 2024 14:39
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[WalletConnect] Remember session approvals
3 participants