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: CheckWallet sdk only if safe is also loaded #4637

Merged
merged 2 commits into from
Dec 16, 2024
Merged

Conversation

usame-algan
Copy link
Member

What it solves

Resolves #4636

How this PR fixes it

  • Also checks for safeLoaded when evaluating if the sdk exists or not in CheckWallet since the sdk won't exist if there is no safe opened

How to test it

This should not break existing behaviour for transaction related buttons

  1. Go to the global preferences page
  2. Activate notifications
  3. Observe the Save button is enabled

Screenshots

Screenshot 2024-12-10 at 16 43 12

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 Dec 10, 2024

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code review by ChatGPT

@@ -54,7 +54,7 @@ const CheckWallet = ({
if (!wallet) {
return Message.WalletNotConnected
}
if (!sdk) {
if (!sdk && safeLoaded) {
return Message.SDKNotInitialized
}

Choose a reason for hiding this comment

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

The condition !sdk && safeLoaded in getErrorMessage could delay error messaging if safeLoaded is not immediately true when sdk is unavailable. Ensure safeLoaded correctly represents when readiness should be checked, or consider decoupling them for clarity.

Copy link

github-actions bot commented Dec 10, 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 1 MB (🟡 +10 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 Dec 10, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.71% (+0.01% 🔼)
14378/19506
🔴 Branches
51.11% (+0.03% 🔼)
3422/6695
🔴 Functions 56.44% 2029/3595
🟡 Lines
75.28% (+0.01% 🔼)
13048/17332

Test suite run success

1676 tests passing in 228 suites.

Report generated by 🧪jest coverage report action from a211097

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code review by ChatGPT


expect(queryByText('Continue')).not.toBeDisabled()
})

it('should allow nested Safe owners', () => {
;(useIsSafeOwner as jest.MockedFunction<typeof useIsSafeOwner>).mockReturnValueOnce(false)
mockUseNestedSafeOwners.mockReturnValue([faker.finance.ethereumAddress()])

Choose a reason for hiding this comment

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

The test descriptions are inconsistent in mentioning the conditions for enabling/disabling the button. Consider standardizing the naming pattern, e.g., "disables button when SDK uninitialized and safe loaded" vs. "doesn't disable button when SDK uninitialized and safe not loaded."

@@ -44,7 +44,7 @@ const CheckWallet = ({
const sdk = useSafeSDK()
const isProposer = useIsWalletProposer()

const { safe } = useSafeInfo()
const { safe, safeLoaded } = useSafeInfo()

const isNestedSafeOwner = useIsNestedSafeOwner()

Choose a reason for hiding this comment

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

Evaluate the need to include safeLoaded in the dependency array. If safeLoaded is a state that changes, it should be included if checkNetwork depends on it; otherwise, remove it to prevent unnecessary re-renders.

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.

👍
Please make sure this component isn't used anywhere outside of an individual Safe. E.g. Safe creation.

@usame-algan
Copy link
Member Author

usame-algan commented Dec 13, 2024

Please make sure this component isn't used anywhere outside of an individual Safe. E.g. Safe creation.

I wonder why we use CheckWallet there in the first place since we just need to make sure that the users wallet is connected before they can press the Save button. I just looked into it a bit more and noticed some strange behaviour in case I have added safes. Will create another ticket to look into this separately.

Added here: #4655

@francovenica
Copy link
Contributor

LGTM

You can disable notifcations from the global settings
Checked that disabling the notifications from there it works (no more notifications arrive after disabling notifications from there)

@usame-algan usame-algan merged commit d52a5b7 into dev Dec 16, 2024
16 checks passed
@usame-algan usame-algan deleted the notifications-button branch December 16, 2024 09:47
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 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.

Notifications: Can not enable/disable notifications from the global preferences page ( dev env)
3 participants