-
Notifications
You must be signed in to change notification settings - Fork 50
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
improve: Suppress RPC provider key from error messages #1037
base: master
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.
fwiw I am surprised how many instances we had of this in the code 🤔
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.
damn nice catch...
Wish we could add a linting rule to prevent this somehow @james-a-morris any ideas? |
dcad519
to
b50a0ba
Compare
Good idea on linting this! |
function getProviderHostname(provider: ethers.providers.StaticJsonRpcProvider): string { | ||
return new URL(provider.connection.url).hostname; | ||
} |
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.
We have getOriginFromUrl( )
- should we introduce this second one? We can probably overload or make a similar function called getOriginFromProvider(provider: ...)
// @dev To avoid accidentally leaking RPC keys in log messages, resolve the RPC provider hostname | ||
// centrally. There should be no instances of `provider.connection.url` in log messages or errors. | ||
function getProviderHostname(provider: ethers.providers.StaticJsonRpcProvider): string { | ||
return new URL(provider.connection.url).hostname; |
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.
The hostname
will clip away the network protocol & potential port. Using origin
will futureproof us if we ever want to intermingle differing protocols or separate ports on the same host.
I think we should put all usages to |
No description provided.