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: Wallet Connect #1294

Merged
merged 2 commits into from
Dec 4, 2024
Merged

fix: Wallet Connect #1294

merged 2 commits into from
Dec 4, 2024

Conversation

alexrisch
Copy link
Collaborator

@alexrisch alexrisch commented Dec 4, 2024

Removed Second Signature Handling
Removed check for isOnXmtp network
Removed unused translations

Summary by CodeRabbit

Release Notes

  • New Features

    • Streamlined connection process by removing the onXmtp property, simplifying user interface prompts.
  • Bug Fixes

    • Eliminated unnecessary complexity in the connection logic, enhancing overall user experience.
  • Documentation

    • Updated translations to reflect the removal of the secondSignature prompt, reducing user information overload.

Removed Second Signature Handling
Removed check for isOnXmtp network
Removed unused translations
@alexrisch alexrisch requested a review from a team as a code owner December 4, 2024 17:41
Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Warning

Rate limit exceeded

@alexrisch has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 62262b5 and cf94c83.

Walkthrough

The changes in this pull request primarily involve the removal of the onXmtp property from various components related to the wallet connection functionality. This includes updates to the IConnectViaWalletStoreProps, state management, and component logic across multiple files. The modifications streamline the connection process by eliminating unnecessary checks and simplifying the overall structure, while maintaining the core functionality and error handling mechanisms.

Changes

File Change Summary
components/Onboarding/ConnectViaWallet/ConnectViaWallet.store.tsx Removed onXmtp property from IConnectViaWalletStoreProps and its usage in createConnectViaWalletStore. Updated IConnectViaWalletStoreState accordingly.
components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx Removed onXmtp from state destructuring in ConnectViaWalletStateWrapper and ConnectViaWalletUI. Simplified logic for setting title and subtitle based on state.
components/Onboarding/ConnectViaWallet/useConnectViaWalletInitXmtpClient.tsx Removed retrieval of onXmtp state from connectViewWalletStore. Preserved core initialization logic and error handling.
components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts Updated import paths and removed onXmtp state variable and associated logic. Modified return value to exclude onXmtp.
i18n/translations/en.ts Removed secondSignature property from connectViaWallet translations, simplifying user interface prompts.

Possibly related PRs

  • fix: rainbow connect + translations + remove unused code #1128: The changes in this PR involve modifications to the ConnectViaWalletContextProvider and related components, which are directly connected to the onXmtp property removal in the main PR, as both deal with the wallet connection functionality.
  • Bug: Search Bar Text is the same color as search bar #1124: This PR also addresses changes in the useInitConnectViaWalletState function, which is relevant to the removal of the onXmtp state variable in the main PR, indicating a direct relationship in the context of wallet initialization and state management.

Suggested labels

2.0.7

Suggested reviewers

  • thierryskoda

Poem

🐰 In the meadow where wallets connect,
A change was made, oh what a perfect effect!
The onXmtp gone, the path now is clear,
Simplified steps, let’s all give a cheer!
With titles and subtitles, straightforward and bright,
The journey to connect is now just right! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Dec 4, 2024

Performance Comparison Report

  • Current: 10f6515 - 2024-12-04 18:10:28Z
  • Baseline: release/3.0.0 (d67b353) - 2024-12-04 18:09:05Z

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Type Duration Count
Avatar Image 10 runs render 1.2 ms → 1.4 ms (+0.2 ms, +16.7%) 🔴 1 → 1
Avatar Image 50 runs render 1.1 ms → 1.1 ms (-0.0 ms, -3.6%) 1 → 1
Empty Avatar 10 runs render 0.8 ms → 1.0 ms (+0.2 ms, +25.0%) 🔴 1 → 1
Empty Avatar 50 runs render 0.6 ms → 0.7 ms (+0.1 ms, +24.1%) 🔴 1 → 1
Text Component with color prop - 10 runs render 0.3 ms → 0.4 ms (+0.1 ms, +33.3%) 🔴 1 → 1
Text Component with default props - 10 runs render 0.2 ms → 0.5 ms (+0.3 ms, +150.0%) 🔴 1 → 1
Text Component with translation key - 10 runs render 0.2 ms → 0.3 ms (+0.1 ms, +50.0%) 🔴 1 → 1
Text Component with weight and size - 10 runs render 0.5 ms → 0.4 ms (-0.1 ms, -20.0%) 🟢 1 → 1
Show details
Name Type Duration Count
Avatar Image 10 runs render Baseline
Mean: 1.2 ms
Stdev: 0.4 ms (35.1%)
Runs: 1 2 1 1 1 2 1 1 1 1
Warmup runs: 2

Current
Mean: 1.4 ms
Stdev: 0.5 ms (36.9%)
Runs: 1 1 2 1 2 2 1 1 2 1
Warmup runs: 2
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Avatar Image 50 runs render Baseline
Mean: 1.1 ms
Stdev: 0.4 ms (34.4%)
Runs: 1 0 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1
Warmup runs: 1

Current
Mean: 1.1 ms
Stdev: 0.3 ms (31.5%)
Runs: 2 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 0 1 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 10 runs render Baseline
Mean: 0.8 ms
Stdev: 0.4 ms (52.7%)
Runs: 1 0 1 0 1 1 1 1 1 1
Warmup runs: 3

Current
Mean: 1.0 ms
Stdev: 0.0 ms (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Warmup runs: 2
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 50 runs render Baseline
Mean: 0.6 ms
Stdev: 0.5 ms (86.0%)
Runs: 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0
Warmup runs: 1

Current
Mean: 0.7 ms
Stdev: 0.5 ms (63.0%)
Runs: 1 1 1 0 1 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0 1 1 1 1 1 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with color prop - 10 runs render Baseline
Mean: 0.3 ms
Stdev: 0.5 ms (161.0%)
Runs: 1 0 1 0 0 0 0 0 0 1
Warmup runs: 0

Current
Mean: 0.4 ms
Stdev: 0.5 ms (129.1%)
Runs: 1 1 0 0 0 0 1 0 1 0
Warmup runs: 0
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with default props - 10 runs render Baseline
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 0 0 0 1 0 0 1 0 0 0
Warmup runs: 0

Current
Mean: 0.5 ms
Stdev: 0.5 ms (105.4%)
Runs: 1 0 1 1 0 0 1 0 0 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with translation key - 10 runs render Baseline
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 1 0 0 1 0 0 0 0 0 0
Warmup runs: 1

Current
Mean: 0.3 ms
Stdev: 0.5 ms (161.0%)
Runs: 0 1 0 0 1 0 0 1 0 0
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with weight and size - 10 runs render Baseline
Mean: 0.5 ms
Stdev: 0.5 ms (105.4%)
Runs: 1 1 0 1 0 0 0 1 0 1
Warmup runs: 0

Current
Mean: 0.4 ms
Stdev: 0.5 ms (129.1%)
Runs: 1 0 0 0 0 1 1 0 0 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Render Count Changes

There are no entries

Render Issues

There are no entries

Added Scenarios

There are no entries

Removed Scenarios

There are no entries

Generated by 🚫 dangerJS against cf94c83

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts (1)

95-96: Consider adding debug logging for initialization steps

The logging message could be more detailed to help with debugging. Consider adding intermediate logs for key initialization steps.

-          `[Connect Wallet] User connected wallet ${thirdwebWallet?.id} (${address}). V3 database ${hasV3 ? "already" : "not"} present`
+          `[Connect Wallet] User connected wallet ${thirdwebWallet?.id} (${address}). Status: V3 database ${hasV3 ? "already" : "not"} present, Inbox ID retrieved successfully`
components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx (3)

156-164: Simplify conditional logic further

The current if-else structure can be simplified as it's checking mutually exclusive conditions.

-  if (!alreadyV3Db) {
-    title = translate("connectViaWallet.sign");
-    subtitle = translate("connectViaWallet.firstSignature.explanation");
-  }
-  else if (alreadyV3Db) {
-    title = translate("connectViaWallet.firstSignature.title");
-    subtitle = translate("connectViaWallet.firstSignature.explanation");
-  }
+  title = alreadyV3Db 
+    ? translate("connectViaWallet.firstSignature.title")
+    : translate("connectViaWallet.sign");
+  subtitle = translate("connectViaWallet.firstSignature.explanation");

Line range hint 126-139: Review primaryButtonAction logic

The primaryButtonAction still contains logic for waitingForNextSignature but the second signature handling has been removed. This appears to be inconsistent with the PR objectives.

-  const primaryButtonAction = useCallback(() => {
-    if (waitingForNextSignature) {
-      logger.debug("[Connect Wallet] User clicked on second sign button");
-      connectViewWalletStore.getState().setLoading(true);
-      connectViewWalletStore.getState().setClickedSignature(true);
-    } else {
-      logger.debug("[Connect Wallet] User clicked on initial sign button");
-      connectViewWalletStore.getState().setLoading(true);
-      initXmtpClient();
-    }
-  }, [waitingForNextSignature, connectViewWalletStore, initXmtpClient]);
+  const primaryButtonAction = useCallback(() => {
+    logger.debug("[Connect Wallet] User clicked on sign button");
+    connectViewWalletStore.getState().setLoading(true);
+    initXmtpClient();
+  }, [connectViewWalletStore, initXmtpClient]);

Remove second signature states and their related logic

The verification confirms that second signature states are still present and actively used across multiple files:

  • ConnectViaWallet.store.tsx:
    • Contains state definitions: numberOfSignaturesDone, waitingForNextSignature
    • Includes setters: setNumberOfSignaturesDone, setWaitingForNextSignature
  • ConnectViaWallet.tsx:
    • Uses these states in component logic and effects
  • useConnectViaWalletInitXmtpClient.tsx:
    • Contains logic depending on waitingForNextSignature and numberOfSignaturesDone

These states and their related logic should be removed as part of removing second signature handling.

🔗 Analysis chain

Line range hint 108-120: Verify state management completeness

The component still destructures waitingForNextSignature and signaturesDone from the store, but these states should be removed as part of removing second signature handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining references to second signature states
rg "waitingForNextSignature|signaturesDone|numberOfSignaturesDone" -A 2

Length of output: 4283

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d67b353 and 62262b5.

📒 Files selected for processing (5)
  • components/Onboarding/ConnectViaWallet/ConnectViaWallet.store.tsx (0 hunks)
  • components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx (2 hunks)
  • components/Onboarding/ConnectViaWallet/useConnectViaWalletInitXmtpClient.tsx (0 hunks)
  • components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts (3 hunks)
  • i18n/translations/en.ts (0 hunks)
💤 Files with no reviewable changes (3)
  • components/Onboarding/ConnectViaWallet/ConnectViaWallet.store.tsx
  • i18n/translations/en.ts
  • components/Onboarding/ConnectViaWallet/useConnectViaWalletInitXmtpClient.tsx
🔇 Additional comments (4)
components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts (3)

13-15: LGTM: Clean import organization

The new imports are properly organized and provide necessary utilities for error handling and XMTP integration.


116-116: Verify consumers of useInitConnectViaWalletState

The removal of onXmtp from the return value is a breaking change. Ensure all consumers are updated accordingly.


85-90: Verify error handling for getInboxId

The Promise.all now only retrieves inboxId. While this simplifies the code, ensure that getInboxId's error handling is robust since it's a critical path for wallet initialization.

✅ Verification successful

Error handling for getInboxId is properly implemented

The code has appropriate error handling:

  • The getInboxId call is wrapped in a try-catch block
  • Errors are properly logged with logger.error
  • Errors are propagated to the UI via onErrorConnecting
  • The initialization state is properly cleaned up in the finally block
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check error handling in getInboxId implementation
ast-grep --pattern 'function getInboxId($_) {
  try {
    $$$
  } catch($_) {
    $$$
  }
}'

Length of output: 94


Script:

#!/bin/bash
# Let's try to find the getInboxId implementation with a broader search
rg "getInboxId" -A 10

Length of output: 6376


Script:

#!/bin/bash
# Let's check the implementation and error handling in Client.getOrCreateInboxId
rg "Client\.getOrCreateInboxId" -A 5 -B 5

# Also check if there's any try-catch around the usage of getInboxId in useInitConnectViaWalletState
rg -A 10 -B 5 "useInitConnectViaWalletState"

Length of output: 5466


Script:

#!/bin/bash
# Let's check the error handling in the component where getInboxId is used
rg -A 20 -B 5 "const \[inboxId\]" components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts

Length of output: 980

components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx (1)

82-83: LGTM: Clean state destructuring

The state destructuring has been properly updated to remove onXmtp, aligning with the changes in useInitConnectViaWalletState.

@alexrisch alexrisch merged commit 80637a7 into release/3.0.0 Dec 4, 2024
6 checks passed
@alexrisch alexrisch deleted the ar/fix-wallet-connect-flow branch December 4, 2024 19:14
technoplato pushed a commit that referenced this pull request Dec 17, 2024
* fix: Wallet Connect

Removed Second Signature Handling
Removed check for isOnXmtp network
Removed unused translations

* remove commented code and promise.all
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.

2 participants