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: json rpc errors because of nonce out of sync #2833

Merged
merged 2 commits into from
May 8, 2023
Merged

Conversation

bigint
Copy link
Member

@bigint bigint commented May 8, 2023

What does this PR do?

🤖 Generated by Copilot at 2409232

This pull request refactors the user signature nonce management in the web app. It introduces a new zustand store, a new query, and a new provider component to handle the user signature nonce state. It updates various components and mutations to use the new store and query. It also adds a dependency on shared-zustand to enable syncing the user signature nonce across different tabs or windows. It removes the user signature nonce logic from the app store and the UserProfiles query.

Related issues

Fixes #2804

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking small changes to existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Explanation of the changes

🤖 Generated by Copilot at 2409232

  • Add shared-zustand dependency to enable sharing zustand stores across React contexts or iframes (link)
  • Create a new zustand store called useNonceStore to manage the user signature nonce state and persist it in local storage (link, link)
  • Create a new query called UserSigNonces to fetch the user signature nonce for the current user from the Lens API (link)
  • Create a new component called UserSigNoncesProvider that uses the UserSigNonces query and the useNonceStore hook to sync the user signature nonce across different tabs or windows (link)
  • Render the UserSigNoncesProvider component inside the Providers component to ensure that the user signature nonce is fetched and updated for every page (link, link)
  • Remove the userSigNonce and setUserSigNonce properties and selectors from the AppState interface and the useAppStore hook as they are no longer needed (link, link)
  • Remove the userSigNonces field from the UserProfiles query as it is no longer needed (link)
  • Import the useNonceStore hook and replace the useAppStore hook for the userSigNonce and setUserSigNonce selectors in various components that require signing transactions with the user signature nonce (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Increment the user signature nonce by one after calling the mutations that require a user signature and decrement it by one in case of an error in various components that require signing transactions with the user signature nonce (link, link, link, link, link, link, link, link)
  • Remove the lines that increment the user signature nonce by one after calling the mutations that do not require a user signature in various components that require signing transactions with the user signature nonce (link, link, link, link, link, link, link)

Emoji

🔒🚀🧹

@vercel
Copy link

vercel bot commented May 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
prerender ✅ Ready (Inspect) Visit Preview May 8, 2023 8:59am
ui ✅ Ready (Inspect) Visit Preview May 8, 2023 8:59am
web ✅ Ready (Inspect) Visit Preview May 8, 2023 8:59am

@socket-security
Copy link

New dependency changes detected. Learn more about Socket for GitHub ↗︎


👍 No new dependency issues detected in pull request

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] bar@* or ignore all packages with @SocketSecurity ignore-all

Pull request alert summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

📊 Modified Dependency Overview:

➕ Added Package Capability Access +/- Transitive Count Publisher
[email protected] None +0 tom-julux

@vercel vercel bot temporarily deployed to Preview – prerender May 8, 2023 08:56 Inactive
@vercel vercel bot temporarily deployed to Preview – web May 8, 2023 08:58 Inactive
@vercel vercel bot temporarily deployed to Preview – ui May 8, 2023 08:59 Inactive
@bigint bigint merged commit d421ef4 into main May 8, 2023
@bigint bigint deleted the pending-txns branch May 8, 2023 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal JSON-RPC error and Posting with Gas fee
1 participant