-
Notifications
You must be signed in to change notification settings - Fork 44
Implement custom RPC Provider with Fallback #640
base: main
Are you sure you want to change the base?
Conversation
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.
Need to do the StaticJsonRpcProvider
instead of JsonRpcProvider
.
} else { | ||
const providers = (this._provider as FallbackProvider).providerConfigs.map(p => p.provider as JsonRpcProvider); | ||
var errors: Error[] = []; | ||
return Promise.race<any>( |
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.
Note that here is where we are executing the Promise.race
. Essentially, in any other method call in this class, we literally just call the underlying provider. Fallback provider does this sort of 'race-like' operation we see here internally, under the hood.
However, there is no FallbackProvider.send
method, so I've taken the liberty of implementing this myself. Assuming we had multiple provider URLs passed into constructor (and therefore we're using FallbackProvider
), we're basically executing the RPC send
call on every child provider (AS JsonRpcProvider
) belonging to our FallbackProvider
, and using a Promise.race to return the fastest one.
A delay for timeout of 10s rejects the Promise. Additionally, if all send
calls error out, we reject the Promise with a list of errors.
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.
Going to add the above in descriptive comments here.
Track nonce internally
Update June 7Work on this is deprioritized temporarily (will likely resume next week). Currently blocked by an issue with the When creating the To move forward, we have to give the images used in the |
The Problem
The Solution