-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Add custom network RPC method #9724
Conversation
b583df3
to
187dca2
Compare
Builds ready [187dca2]
Page Load Metrics (400 ± 51 ms)
|
7d596aa
to
11bf9e8
Compare
I believe this addresses #5101 |
b4bbd83
to
3acb000
Compare
Builds ready [3acb000]
Page Load Metrics (672 ± 66 ms)
|
b606037
to
53028e1
Compare
Builds ready [335b9ab]
Page Load Metrics (522 ± 40 ms)
|
335b9ab
to
53c77ed
Compare
Builds ready [b9c39cb]
Page Load Metrics (756 ± 60 ms)
|
* or throws an error in case of failure. | ||
*/ | ||
export async function jsonRpcRequest(rpcUrl, rpcMethod, rpcParams = []) { | ||
let fetchUrl = rpcUrl; |
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.
Review note: this method has been moved to rpc.utils.js
but it is unchanged
* @param {Array<unknown>} [rpcParams] - The RPC method params. | ||
* @returns {Promise<unknown|undefined>} Returns the result of the RPC method call, | ||
* or throws an error in case of failure. | ||
*/ |
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.
Review note: this is the same as the jsonRpcRequest
that was removed from ui/app/helpers/utils/util.js
, the code is unchanged
'chainId', | ||
'chainName', | ||
'blockExplorerUrls', | ||
'iconUrls', |
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.
I notice that 'iconUrls'
is not included in otherKeys
, but neither is it used anywhere. Is there some reason we are allowing this in the request params even though it will go unused?
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.
It is a part of EIP-3085, the goal here being to warn for extraneous keys that are not a part of the EIP. For example: 'blockExplorerUrls' is what we want, but someone might put 'blockExplorerUrl'. Beings as blockExplorerUrls is optional, without this check we'd accept the request and add the chain to the user's MetaMask without the blockExplorer, and the dapp would be none the wiser.
chainId: existingNetwork.chainId, | ||
nickname: existingNetwork.nickname, | ||
ticker: existingNetwork.ticker, | ||
}, |
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.
Are we unable to support the updating of the block-explorer url?
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.
when we get here the user will have already added the chain to their MetaMask, and the block explorer URL will have been set. This requestData is set because updateRpcTarget requires it.
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.
I left a couple comments and questions
b9c39cb
to
bb63145
Compare
Builds ready [bb63145]
Page Load Metrics (590 ± 22 ms)
|
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 looks good to me
Builds ready [d04ab15]
Page Load Metrics (610 ± 36 ms)
|
Implement
wallet_addEthereumChain
in background, per EIP-3085.Fixes #5101