refactor: WebViewManager/Handler improvements#18
Merged
andreydobrikov merged 4 commits intomainfrom Mar 13, 2026
Merged
Conversation
Generic SendRequest - less code duplication Proper disposal Cancellation token handling void Task -> Task as void is an antipattern that swallows exceptions. Format changes
lucasloisp
reviewed
Mar 13, 2026
| //Wallet Methods | ||
| //TBD | ||
| internal async Task<IframeResponse> CreateEthereumWallet(string accessToken, string solanaAddress = null) | ||
| public void Dispose() |
Collaborator
There was a problem hiding this comment.
I think we should cancel in-flight requests first (the ones in _requestResponseMap) and only dispose disposeCts after.
Task.Delay in each request is linked to the _disposeCts so that should go first.
lucasloisp
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors wallet creation, connection, recovery, and signing logic in the
EmbeddedWalletManagerto centralize error handling and response parsing. The main improvement is the introduction of a genericUnwrapResult<TData>helper method, which simplifies and unifies how results and errors from iframe responses are handled. Additionally, minor changes were made to how asynchronous calls are triggered in the iframe handler and webview handler.Refactoring wallet operation methods:
UnwrapResult<TData>method to extract data from successful iframe responses or throw aPrivyWalletExceptionwith a detailed error message, replacing repetitive error handling logic in wallet creation, connection, recovery, RPC request, and signing methods. (SDK/Runtime/EmbeddedWallet/EmbeddedWalletManager.cs)CreateEthereumWallet,CreateSolanaWallet,CreateAdditionalWallet,ConnectWallet,RecoverWalletThenTryConnecting, RPC request, and signing methods to useUnwrapResult<TData>, significantly reducing duplicated code and improving maintainability. (SDK/Runtime/EmbeddedWallet/EmbeddedWalletManager.cs) [1] [2] [3]Asynchronous call improvements:
_webViewManager.PingReadyUntilSuccessful()in bothInjectIframeandOnPageLoadedto use discard assignment (_ = ...), clarifying that the result is intentionally ignored and improving code clarity. (SDK/Runtime/EmbeddedWallet/BrowserDomIframeHandler.cs,SDK/Runtime/EmbeddedWallet/WebviewHandler.cs) [1] [2]