Conversation
devop: show onboard when not initialized
WalkthroughThis pull request updates the extension package version in the package.json and introduces asynchronous modifications to several blockchain account request methods. The methods in the Bitcoin, Kadena, Polkadot, and Solana providers are modified to use async functions that check for KeyRing initialization before processing account access. When not initialized, an error is returned and a throttled onboarding function is triggered. In addition, the Ethereum network configuration files have been updated by replacing WebSocket URLs with HTTPS endpoints. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant M as Method
participant K as KeyRing
participant O as OpenOnboard
C->>M: Request account access
M->>K: Check initialization (async)
alt Not Initialized
M-->>C: Return "Enkrypt not initialized" error
M->>O: Call throttled openOnboard()
M->>M: Handle pending promises
else Initialized
M->>C: Process account access
end
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
|
💼 Build Files |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/extension/src/providers/solana/methods/sol_connect.ts (1)
11-11: Confirm throttle behavior.
By default, lodash’sthrottletriggers on the leading edge. Verify if you also need to invoke the function at the trailing edge for a smoother user experience.packages/extension/src/providers/bitcoin/methods/btc_requestAccounts.ts (1)
11-11: Check throttle configuration.
Confirm if the default leading-edge behavior meets your needs. Consider enabling the trailing-edge option if you want to ensure the call is fired after the cooldown.packages/extension/src/providers/kadena/methods/kda_requestAccounts.ts (1)
20-20: Throttle interval check.
The 10-second interval may be sufficient for limiting repeated calls. Keep an eye on user feedback to fine-tune timing.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
packages/extension/package.json(1 hunks)packages/extension/src/providers/bitcoin/methods/btc_requestAccounts.ts(3 hunks)packages/extension/src/providers/ethereum/networks/aa.ts(1 hunks)packages/extension/src/providers/ethereum/networks/aat.ts(1 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)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: buildAll
- GitHub Check: test
🔇 Additional comments (20)
packages/extension/src/providers/ethereum/networks/aat.ts (1)
17-17: Protocol change from WebSocket to HTTPThe network endpoint has been updated from WebSocket to HTTP protocol. This change aligns with modern practices as HTTP endpoints typically offer better reliability, firewall compatibility, and are more commonly used in wallet providers.
packages/extension/package.json (1)
3-3: Version bump to 2.4.3Version has been updated from 2.4.2 to 2.4.3, which aligns with the PR title "Release: v2.4.3". This minor version increment appropriately reflects the non-breaking changes in this release.
packages/extension/src/providers/ethereum/networks/aa.ts (1)
17-17: Protocol change from WebSocket to HTTPThe network endpoint has been updated from WebSocket to HTTP protocol, consistent with the change made to the test network. This standardization improves maintenance and provides more reliable connectivity.
packages/extension/src/providers/polkadot/methods/dot_accounts_get.ts (5)
12-13: New imports for onboarding functionalityAdded imports for the onboarding utility and throttle functionality, which support the enhanced error handling introduced in this update.
16-16: Throttled onboarding implementationGood implementation of throttling the onboarding function to prevent multiple calls within a short timeframe (10 seconds), which improves user experience.
21-26: Method signature changed to asyncThe function has been properly updated to use async/await pattern, which is necessary for the new initialization check.
29-30: KeyRing initialization checkAdded important initialization check that will help prevent errors when attempting to access accounts before the extension is fully initialized.
67-71: Enhanced error handling for uninitialized stateThis new conditional block properly handles the case when KeyRing is not initialized by:
- Returning an appropriate error message
- Triggering the throttled onboarding process
- Continuing to process any remaining promises
This significantly improves user experience by guiding users through the onboarding flow when needed.
packages/extension/src/providers/solana/methods/sol_connect.ts (4)
6-7: Import statements look correct.
These new imports foropenOnboardandthrottleare valid additions for introducing a throttled onboarding flow.
16-21: Async method signature is well-defined.
Switching toasyncallows returning aPromise<void>and utilizingawaitfor asynchronous checks. Overall, this improves error handling flow.
32-32: Consider handling potential exceptions.
Ifthis.KeyRing.isInitialized()rejects due to unexpected errors, it might leave the state in an undeclared status. You may consider wrapping the call in a try/catch block to manage any thrown exceptions gracefully.
46-50: Immediate return upon non-initialized state is appropriate.
Ending further processing helps prevent invalid states. ThrottlingopenOnboardensures the onboarding pop-up is not triggered repeatedly.packages/extension/src/providers/bitcoin/methods/btc_requestAccounts.ts (4)
7-8: Imports are suitably added.
TheopenOnboardfunction andthrottlefrom lodash are introduced to manage repeated onboarding prompts effectively.
16-21: Async method usage is correct.
Converting to anasyncfunction aligns well with the new onboarding logic. Good job synchronizing the interface return type with the actual asynchronous flow.
32-32: Evaluate exception handling for KeyRing.
IfisInitialized()throws an error, it may skip the flow entirely. Adding a try/catch guard could help avoid pending state issues.
46-50: Early exit for initialization failure is sensible.
Properly returning here avoids further invalid account access attempts and triggers the throttled onboarding process.packages/extension/src/providers/kadena/methods/kda_requestAccounts.ts (4)
16-17: New imports verified.
openOnboardandthrottlefrom lodash are introduced consistently with other provider methods in this PR.
27-32: Async method signature.
Upgrading toasyncimproves clarity for the returnedPromise<void>. This follows best practices for asynchronous flows.
35-35: Consider potential runtime errors.
TieisInitializedinto a higher-level error handling strategy to recover seamlessly ifthis.KeyRing.isInitialized()encounters connectivity or unexpected errors.
102-106: Proper early termination when uninitialized.
Short-circuiting further account handling is a solid approach. Triggering the throttled onboarding here matches the revised flow in other providers.
|
1 similar comment
|
Summary by CodeRabbit
Chores
New Features