Open oleiba opened 4 years ago
Actually the provider
should additionally be passed as a property itself in the constructor argument:
const snxjs = new SynthetixJs({ networkId, provider, signer })
See here: https://github.com/Synthetixio/synthetix-js/blob/master/src/contractSettings.js#L22
But your point still stands - we can export the providers from Infura to make them more useful. This is especially important after the change from Infura that no longer allows access to archive nodes by default - see https://github.com/ethers-io/ethers.js/issues/715.
Thanks for filing, I'll keep this open until we can prioritize and address it. cc @clementbalestrat
Currently, it seems there's no straight forward way to inject a provider when initializing SynthetixJS.
One can inject a signer, which can accept a provider in its constructor, but in order for the provider to implement the needed interface - it seems we must use either of
ethers
' provider classes. The problem is that the only field exported by SynthetixJS fromethers
isutils
. I suggest to also exportproviders
fromethers
, so one can easily inject its own custom provider: