fix: multichain cold start issue with RPCClient #1355
Merged
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.



Explanation
The issue happens because the multichain-api-client is getting the session for the first RPC request that we run, this affects the user experience forcing the user to go back to the Dapp until the session is delivered.
I've replaced usage in RPCClient from this.provider to this.transport which does not trigger this extra RPC request.
This also makes the use of this.provider in multichain, no longer needed. We're basically using all the transport stuff from multichain-api-client but not the provider itself, not even for default transports now.
For the previous, I'd propose to create a separate PR to remove provider from the SDK and just use transports but will require a bunch of tests to be re-visited
References
Checklist
Note
RPC calls now use transport.request (not provider) and invocation starts before opening the deeplink; tests updated accordingly.
invokeMethodnow instantiatesRPCClientwithtransportand startsinvokeMethodbefore opening the deeplink whensecure && !preferDesktop; returns the invoke promise.ExtendedTransportinstead of provider; redirects write/personal methods viatransport.requestusingwallet_invokeMethod, returningresponse.resultand handlingresponse.error.transport.requestand expectations for redirect/fallback paths; retain fetch-based assertions for readonly cases.Written by Cursor Bugbot for commit 90a2ca8. This will update automatically on new commits. Configure here.