You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
InfuraProvider <= UrlJsonRpcProvider <= StaticJsonRpcProvider <= JsonRpcProvider <= and so on :)
InfuraProvider expects 2 arguments, a network and an API key. JsonRpcProvider expects a connection object or a URL. When we create an InfuraProvider, the connection information is automatically created through UrlJsonRpcProvider constructor. However, there is currently no way to customise the connection information.
My suggestion is to add a 3rd argument to UrlJsonRpcProvider constructor, so that we can be able to customise the connection information. Something like:
constructor(network?: Networkish,apiKey?: any,connectionInfo?:ConnectionInfo={}){logger.checkAbstract(new.target,UrlJsonRpcProvider);// Normalize the Network and API Keynetwork=getStatic<(network: Networkish)=>Network>(new.target,"getNetwork")(network);apiKey=getStatic<(apiKey: string)=>string>(new.target,"getApiKey")(apiKey);constconnection={ ...getStatic<getUrlFunc>(new.target,"getUrl")(network,apiKey), ...conectionInfo};super(connection,network);if(typeof(apiKey)==="string"){defineReadOnly(this,"apiKey",apiKey);}elseif(apiKey!=null){Object.keys(apiKey).forEach((key)=>{defineReadOnly<any,any>(this,key,apiKey[key]);});}}
This would benefit any provider that inherits UrlJsonRpcProvider such as Infura, Alchemy, etc.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The
InfuraProvider
class hierarchy is as follows:InfuraProvider
<=UrlJsonRpcProvider
<=StaticJsonRpcProvider
<=JsonRpcProvider
<= and so on :)InfuraProvider
expects 2 arguments, a network and an API key.JsonRpcProvider
expects a connection object or a URL. When we create an InfuraProvider, the connection information is automatically created throughUrlJsonRpcProvider
constructor. However, there is currently no way to customise the connection information.My suggestion is to add a 3rd argument to
UrlJsonRpcProvider
constructor, so that we can be able to customise the connection information. Something like:This would benefit any provider that inherits
UrlJsonRpcProvider
such as Infura, Alchemy, etc.Any thoughts ?
Beta Was this translation helpful? Give feedback.
All reactions