Skip to content

devop: show onboard when not initialized#630

Merged
kvhnuke merged 3 commits intodevelopfrom
fix/sol-no-account
Mar 11, 2025
Merged

devop: show onboard when not initialized#630
kvhnuke merged 3 commits intodevelopfrom
fix/sol-no-account

Conversation

@kvhnuke
Copy link
Copy Markdown
Contributor

@kvhnuke kvhnuke commented Mar 11, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced account access with clearer error notifications when the system isn't fully ready.
    • Added throttling to limit onboarding prompts, ensuring a smoother user experience.
  • Refactor

    • Optimized asynchronous operations for improved control flow during account access.
  • Chores

    • Updated the extension version to provide a more stable user experience.
  • Bug Fixes

    • Transitioned network communication from WebSocket to HTTPS for improved reliability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 11, 2025

Walkthrough

The changes update multiple account request methods across different providers (Bitcoin, Kadena, Polkadot, and Solana) by altering their signatures to be asynchronous and return a Promise<void>. Each method now uses a throttled version of the openOnboard function (via lodash’s throttle) to limit its invocation and performs an asynchronous initialization check on the KeyRing. If the KeyRing is not initialized, the methods respond with a custom “Enkrypt not initialized” error, trigger the throttled onboarding process, and manage pending promise states. Additionally, the package version in package.json is bumped from 2.4.2 to 2.4.3.

Changes

File(s) Change Summary
packages/extension/src/providers/{bitcoin,kadena,polkadot,solana}/methods/{btc_requestAccounts.ts, kda_requestAccounts.ts, dot_accounts_get.ts, sol_connect.ts} Updated method signatures to async functions returning Promise<void>. Added a throttled version of openOnboard (using lodash throttle) and an asynchronous KeyRing initialization check. If not initialized, the methods return a custom error, trigger onboarding, and call handleRemainingPromises.
packages/extension/…/package.json Updated package version from "2.4.2" to "2.4.3".
packages/extension/src/providers/ethereum/networks/{aa.ts, aat.ts} Updated node property in artheraOptions and artheraTestOptions from WebSocket URLs to HTTPS URLs.

Sequence Diagram(s)

sequenceDiagram
    participant U as User/Caller
    participant M as Request Method
    participant K as KeyRing
    participant O as Onboard Process

    U->>M: Request account access
    M->>K: Async check: isInitialized?
    alt KeyRing not initialized
        K-->>M: false
        M->>M: Return custom error ("Enkrypt not initialized")
        M->>O: Call throttled openOnboard()
        M->>M: Call handleRemainingPromises()
    else KeyRing is initialized
        K-->>M: true
        M->>M: Proceed with account access logic
    end
Loading

Possibly related PRs

  • fix: kadena balance issue #622: The changes involve modifications to the requestAccounts methods, specifically updating the method signatures to asynchronous and adding initialization checks for the KeyRing.
  • devop: switch solana asset handler to helius #578: The changes focus on asynchronous handling and error management of account requests, specifically regarding the KeyRing initialization check and the use of throttling for onboarding processes.
  • feat: recent addresses #587: The changes involve modifications to asynchronous method signatures and the introduction of initialization checks for the KeyRing, specifically in the context of account access handling.

Suggested reviewers

  • NickKelly1
  • gamalielhere

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efe129a and 63edbba.

📒 Files selected for processing (2)
  • packages/extension/src/providers/ethereum/networks/aa.ts (1 hunks)
  • packages/extension/src/providers/ethereum/networks/aat.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: buildAll
  • GitHub Check: test
🔇 Additional comments (2)
packages/extension/src/providers/ethereum/networks/aa.ts (1)

17-17:

Details

❓ Verification inconclusive

Connection type changed from WebSocket to HTTP

The connection type for the Arthera network has been changed from WebSocket (presumably wss://ws.arthera.net based on the companion change in aat.ts) to HTTP. This might affect how the application interacts with the network, particularly for operations that benefited from WebSocket's persistent connection.

Verify that all functionality works correctly with the HTTP endpoint:


🏁 Script executed:

#!/bin/bash
# Check if there are any other references to the old WebSocket endpoints that might need updating
rg "wss://ws.arthera.net" --type ts

Length of output: 35


Action Required: Confirm HTTP Endpoint Integration

The change in the Arthera network configuration updates the node connection from a WebSocket (wss://ws.arthera.net) to an HTTP endpoint (https://rpc.arthera.net). The search for "wss://ws.arthera.net" in the TypeScript files returned no additional references, which suggests the old endpoint is no longer in use. However, given the potential impact on parts of the application that may depend on persistent connections, please manually review and verify the following:

  • Ensure that all network operations previously leveraging WebSocket’s persistent connection (as indicated by companion changes in aat.ts) correctly function using the new HTTP endpoint.
  • Confirm through manual or integration testing that there are no unintended side effects or hidden dependencies on the legacy WebSocket behavior.
packages/extension/src/providers/ethereum/networks/aat.ts (1)

17-17:

Details

❓ Verification inconclusive

Connection type changed from WebSocket to HTTP

The connection type for the Arthera Test network has been changed from WebSocket (presumably wss://ws-test.arthera.net based on the companion change in aa.ts) to HTTP. Similar to the change in the main network configuration, this might affect how the application interacts with the test network.

Verify that all functionality works correctly with the HTTP endpoint:


🏁 Script executed:

#!/bin/bash
# Check if there are any other references to the old WebSocket endpoints that might need updating
rg "wss://ws-test.arthera.net" --type ts

Length of output: 40


HTTP Endpoint Configuration Update – Manual Verification Needed

The update in packages/extension/src/providers/ethereum/networks/aat.ts correctly changes the test network's connection from a WebSocket to an HTTP endpoint (node: 'https://rpc-test.arthera.net'). A search for the old WebSocket reference (wss://ws-test.arthera.net) in TypeScript files yielded no results, suggesting that the outdated endpoint isn’t used elsewhere. However, since the search output was inconclusive, please manually verify that all network interactions are functioning correctly with the updated HTTP configuration.

  • Confirm that the HTTP endpoint behaves as expected during integration testing.
  • Double-check other parts of the codebase (or run broader searches) to ensure no residual WebSocket references remain.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this 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.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 11, 2025

💼 Build Files
chrome: enkrypt-chrome-63edbba7.zip
firefox: enkrypt-firefox-63edbba7.zip

💉 Virus total analysis
chrome: 63edbba7
firefox: 63edbba7

Copy link
Copy Markdown

@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

🧹 Nitpick comments (3)
packages/extension/src/providers/kadena/methods/kda_requestAccounts.ts (1)

35-35: Consider moving initialization check.

The KeyRing initialization check happens before checking if account access is pending. While this works, it would be more consistent with the other providers if this check happened after the pending check and right before handleAccountAccess is called (around line 44).

packages/extension/src/providers/polkadot/methods/dot_accounts_get.ts (2)

21-99: Consider improving error message for better user guidance.

While the implementation is correct, the error message "Enkrypt not initialized" could be more helpful by including instructions on what the user should do next.

- _res(getCustomError('Enkrypt not initialized'));
+ _res(getCustomError('Enkrypt not initialized. Please complete the setup process in the popup window.'));
🧰 Tools
🪛 Biome (1.9.4)

[error] 65-65: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


39-45: Consider refactoring for better code organization.

The current implementation has multiple nested functions and complex promise handling. Consider refactoring handleRemainingPromises and other nested functions into class methods for better maintainability and testability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3fca1e and efe129a.

📒 Files selected for processing (5)
  • packages/extension/src/providers/bitcoin/methods/btc_requestAccounts.ts (3 hunks)
  • packages/extension/src/providers/kadena/methods/kda_requestAccounts.ts (2 hunks)
  • packages/extension/src/providers/polkadot/methods/dot_accounts_get.ts (2 hunks)
  • packages/extension/src/providers/solana/methods/sol_connect.ts (3 hunks)
  • packages/extension/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: buildAll
  • GitHub Check: test
🔇 Additional comments (17)
packages/extension/package.json (1)

3-3: Version bump looks appropriate for the feature changes.

The increment from 2.4.2 to 2.4.3 is consistent with the scope of changes in this PR that adds onboarding functionality when the extension is not initialized.

packages/extension/src/providers/solana/methods/sol_connect.ts (4)

6-11: LGTM: Good implementation of throttled onboarding.

The throttled onboarding implementation ensures that multiple rapid calls won't spam the user with multiple onboarding windows. The 10-second throttle is a reasonable choice.


16-21: LGTM: Function signature correctly updated to async.

Converting the function to async is necessary for the KeyRing initialization check. Return type properly updated to Promise.


32-32: LGTM: KeyRing initialization check added.

The asynchronous check for KeyRing initialization is crucial for the new feature.


46-50: LGTM: Proper handling for uninitialized KeyRing.

This block correctly handles the case when KeyRing is not initialized by:

  1. Returning an appropriate error message
  2. Opening the onboarding UI (throttled)
  3. Handling any remaining promises

This provides a much better user experience than silently failing.

packages/extension/src/providers/bitcoin/methods/btc_requestAccounts.ts (4)

7-11: LGTM: Good implementation of throttled onboarding.

The throttled onboarding implementation is consistent with other providers, limiting onboarding window opening to once every 10 seconds.


16-21: LGTM: Function signature correctly updated to async.

Converting the function to async is necessary for the KeyRing initialization check. Return type properly updated to Promise.


32-32: LGTM: KeyRing initialization check added.

The asynchronous check for KeyRing initialization is crucial for the new feature.


46-50: LGTM: Proper handling for uninitialized KeyRing.

This block correctly handles the case when KeyRing is not initialized by:

  1. Returning an appropriate error message
  2. Opening the onboarding UI (throttled)
  3. Handling any remaining promises

This provides a much better user experience than silently failing.

packages/extension/src/providers/kadena/methods/kda_requestAccounts.ts (3)

16-20: LGTM: Good implementation of throttled onboarding.

The throttled onboarding implementation is consistent with other providers, limiting onboarding window opening to once every 10 seconds.


27-32: LGTM: Function signature correctly updated to async.

Converting the function to async is necessary for the KeyRing initialization check. Return type properly updated to Promise.


102-106: LGTM: Proper handling for uninitialized KeyRing.

This block correctly handles the case when KeyRing is not initialized by:

  1. Returning an appropriate error message
  2. Opening the onboarding UI (throttled)
  3. Handling any remaining promises

This provides a much better user experience than silently failing.

packages/extension/src/providers/polkadot/methods/dot_accounts_get.ts (5)

12-13: Good addition of necessary imports.

The imports for openOnboard and throttle from lodash properly support the new functionality for handling uninitialized wallet states.


16-16: Well-implemented throttling mechanism.

Great use of throttle to prevent multiple onboarding windows from opening simultaneously. The 10-second delay is a reasonable choice to balance responsiveness with preventing UI spam.


21-26: Correct function signature update for async operation.

The method signature has been properly updated to be asynchronous, allowing the use of await for the KeyRing initialization check. The return type is appropriately changed to Promise<void>.


29-30: Good initialization check implementation.

Adding this explicit initialization check before proceeding with account access is a sensible validation step that will help prevent errors when the wallet isn't ready.


67-71: Well-handled uninitialized state.

The implementation correctly handles the case when KeyRing is not initialized by:

  1. Returning an appropriate error message
  2. Triggering the onboarding process with throttling
  3. Managing the promise queue properly

This will improve user experience by guiding users to initialize their wallet when needed.

@kvhnuke kvhnuke merged commit ccd9085 into develop Mar 11, 2025
@kvhnuke kvhnuke deleted the fix/sol-no-account branch March 11, 2025 21:01
This was referenced Apr 14, 2025
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