Allow passing a URL to EtherscanProvider
and InfuraProvider
(possibly others)
#3355
gabrielKerekes
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We use HTTP proxies to hide our Etherscan/Infura API keys and so we need to set custom URLs for
EtherscanProvider
andInfuraProvider
.However there is currently no straightforward way to pass a URL to either of the providers. The solution we came up with is simply extending the providers and overriding some of the functions. E.g.:
and
The problem with
_EtherscanProvider
is that we can't inject the URL into the constructor becausesuper
calls thegetBaseUrl
function. I.e. the following doesn't work becausegetBaseUrl
is called beforethis.url
gets set:Accessing
this
before thesuper
call is not allowed.Notice also that our
_InfuraProvider
is extendingJsonRpcProvider
notInfuraProvider
sinceJsonRpcProvider
accepts a URL in the constructor which wasn't possible withInfuraProvider
. If we were to extendInfuraProvider
directly we could do the following:But again it wouldn't be possible to inject the url since the
getUrl
isstatic
.Is there a better way to allow us to proxy our requests? If not, what is the reasoning behind the current design of the providers and what do you think of updating the providers so that a URL can be passed in via their constructors?
Beta Was this translation helpful? Give feedback.
All reactions