-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
1193: single object argument for request
method
#2590
Conversation
Hi! I'm a bot, and I wanted to automerge your PR, but couldn't because of the following issue(s):
|
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.
Just a question.
.request('eth_getBlockByNumber', ['latest', 'true']) | ||
.request({ | ||
method: 'eth_getBlockByNumber', | ||
params: ['latest', 'true'], |
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.
This line can also be written like this, right?
params: {
latest: true
}
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.
This example seems a little more straight-forward to understand when written as an object instead of an array.
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.
Hm, I don't know if the params can be given in object form. I imagine it's just following: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber
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.
By the method's interface the params can certainly be given as an object, but whatever the specific RPC method's definition says, goes.
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.
Ah nevermind, I confused myself. However the type annotation (on line 32) here makes it seems like params can either be an array of anything or an object?
params?: Array<any> | { [key: string]: 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.
But in the official JSON-RPC, it seems like it is always an array.
EIPS/eip-1193.md
Outdated
type RequestParams = Array<any> | { [key: string]: any }; | ||
interface RequestArguments { | ||
method: string; | ||
params?: Array<any> | { [key: string]: 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.
This part confuses me because it seems to indicate that the params
property can either be an array of stuff or an object. But the JSON-RPC only ever lists them out as arrays.
@adrianmcli the ethereum json rpc api has traditionally accepted an array for params, however the official json-rpc spec does specify that params can also be passed as a by-name object. The real reason why I recently made it optional was not only this realization but also to support graphql queries in the future so Hope that adds some clarity :) |
@adrianmcli @ryanio, I'm thinking we should just change Any thoughts on that? I might just push a commit so we can get a feel for it. |
EIPS/eip-1193.md
Outdated
type RequestParams = Array<any> | { [key: string]: any }; | ||
interface RequestArguments { | ||
method: string; | ||
params?: Array<any> | { [key: string]: 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.
Same comments as above about any
. Always prefer unknown
.
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.
My bad for not clarifying: all references to any
were changed to unknown
in 7753ce8
I'm not personally a fan of this change as it hurts the ergonomics of using these functions and doesn't actually solve the versioning problem (which I do agree is a problem that should be solved). While options objects give a bit more flexibility in terms of versioning, you still need some larger versioning mechanism in place to make this useful and if you have a versioning system you can just have versioned function signatures. |
That being said, ergonomics are not a blocker for me on 1193, so if that is what everyone else wants I'll capitulate. |
@MicahZoltu, I also find ergonomics important, although I personally find the difference negligible in this case, especially in light of the gains in extensibility. On that note, this change is only meant to address extensibility, not versioning. I still firmly support the creation of a Provider versioning EIP, and may put my time where my mouth is, too. Thanks for the review; I always appreciate your input! |
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.
Looks great, thank you!
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.
Great to see this moving forward
Hi, I'm a bot! This change was automatically merged because: - It only modifies existing Draft or Last Call EIP(s) - The PR was approved or written by at least one author of each modified EIP - The build is passing
Hi, I'm a bot! This change was automatically merged because: - It only modifies existing Draft or Last Call EIP(s) - The PR was approved or written by at least one author of each modified EIP - The build is passing
Hi, I'm a bot! This change was automatically merged because: - It only modifies existing Draft or Last Call EIP(s) - The PR was approved or written by at least one author of each modified EIP - The build is passing
File: https://github.com/rekmarks/EIPs/blob/1193-request-arg/EIPS/eip-1193.md
New signature for the
request
method:Example call:
See document for further details.
This is motivated by discussions with @frozeman and others, and enables a future for the Provider interface generally and the
request
method specifically where any of the following holds:request
calls, for reasons we are unable to anticipate todayIf we want EIP 1193 to function "in perpetuity", why not make the
request
method maximally flexible?