-
-
Notifications
You must be signed in to change notification settings - Fork 198
feat: add support for non infura rpc read calls #1370
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
base: main
Are you sure you want to change the base?
Conversation
I'm not seeing where eth_accounts and eth_chainId are cached. Both actually shouldn't be callable via wallet_invokeMethod in the first place though |
Good point. We will need to do the caching and expose "simulations" of these methods in our backwards compatibility layer |
t.it('should redirect to provider for methods in METHODS_TO_REDIRECT', async () => { | ||
const redirectOptions: InvokeMethodOptions = { | ||
scope: 'eip155:1' as Scope, | ||
request: { | ||
method: RPC_METHODS.ETH_SENDTRANSACTION, | ||
params: { to: '0x123', value: '0x100' }, | ||
}, | ||
}; | ||
mockTransport.request.mockResolvedValue({ result: '0xhash' }); | ||
const result = await rpcClient.invokeMethod(redirectOptions); | ||
t.expect(result).toBe('0xhash'); | ||
t.expect(mockTransport.request).toHaveBeenCalledWith({ | ||
method: 'wallet_invokeMethod', | ||
params: redirectOptions, | ||
}); | ||
t.expect(mockFetch).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we preserve this test but make it
should redirect to provider for EVM methods not in EVM_RPC_PASSTHROUGH_METHODS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's one that tests this via personal_sign
. Perhaps we just rename that test title?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah lets rename it
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1370 +/- ##
=======================================
Coverage 74.99% 74.99%
=======================================
Files 184 184
Lines 4519 4519
Branches 1108 1108
=======================================
Hits 3389 3389
Misses 1130 1130 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ead-calls # Conflicts: # packages/sdk-multichain/src/domain/multichain/api/constants.ts # packages/sdk-multichain/src/multichain/rpc/client.test.ts # packages/sdk-multichain/src/multichain/rpc/client.ts
if (SDK_HANDLED_METHODS.has(method)) { | ||
return this.handleWithSdkState(options); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay leaving this here for now, but we should consider whether to pull this into a separate method since these methods don't technically go through wallet_invokeMethod
|
Going to wait for new monorepo and then migrate these changes over |
Explanation
RPC_URLS_MAP
toRpcUrlsMap
api.readonlyRPCMap
entries over built in infura endpoint entriesRpcClient
toRequestRouter
RpcClient
and move rpc node request logic thereMissingRpcEndpointErr
fromRpcClient
when no endpoint exists for target scopeRpcClient
is unable to serve the requestReferences
See: https://consensyssoftware.atlassian.net/browse/WAPI-780
Checklist
Note
Adds a RequestRouter and RpcClient to handle readonly RPC methods via configured RPC endpoints (favoring custom map over Infura), renames RPC_URLS_MAP to RpcUrlsMap, and updates tests accordingly.
RequestRouter
to dispatch RPC calls: routesRPC_HANDLED_METHODS
to RPC nodes,SDK_HANDLED_METHODS
to SDK (placeholder), others to wallet; falls back to wallet if no RPC endpoint.RpcClient
to perform JSON-RPC over HTTP to endpoints derived fromapi.readonlyRPCMap
(preferred) and Infura viagetInfuraRpcUrls
.MultichainSDK.invokeMethod
now usesRequestRouter
+RpcClient
instead ofRPCClient
.RPC_URLS_MAP
->RpcUrlsMap
and keys byCaipChainId
; updates usages inconstants
,infura
, andMultichainOptions
.RPC_HANDLED_METHODS
andSDK_HANDLED_METHODS
inapi/constants
.rpc/client.test
with newrpc/handlers/rpcClient.test
and addsrpc/requestRouter.test
; updatesinvoke.test
to useRequestRouter
.Written by Cursor Bugbot for commit 9fdc2bb. This will update automatically on new commits. Configure here.