Skip to content
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

Merged
merged 9 commits into from
Feb 12, 2021
Merged

Conversation

rekmarks
Copy link
Member

@rekmarks rekmarks commented Oct 26, 2020

Implement wallet_addEthereumChain in background, per EIP-3085.

  • UI is WIP in a number of different PRs

Fixes #5101

@rekmarks rekmarks added the DO-NOT-MERGE Pull requests that should not be merged label Oct 26, 2020
@danjm danjm added this to the v8.1.next? milestone Nov 2, 2020
@danjm danjm requested a review from Gudahtt November 3, 2020 17:14
@danjm danjm self-requested a review November 3, 2020 17:27
@danjm danjm self-assigned this Nov 3, 2020
@rekmarks rekmarks force-pushed the custom-network-rpc-method branch 6 times, most recently from b583df3 to 187dca2 Compare November 14, 2020 18:06
pattarapon23
pattarapon23 previously approved these changes Nov 14, 2020
@metamaskbot
Copy link
Collaborator

Builds ready [187dca2]
Page Load Metrics (400 ± 51 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint308945157
domContentLoaded27363139810751
load27563340010751
domInteractive27363039710751

@MetaMask MetaMask deleted a comment from pattarapon23 Nov 14, 2020
@rekmarks rekmarks force-pushed the custom-network-rpc-method branch 2 times, most recently from 7d596aa to 11bf9e8 Compare December 15, 2020 18:44
@rekmarks rekmarks assigned brad-decker and unassigned Gudahtt and danjm Dec 15, 2020
@Gudahtt
Copy link
Member

Gudahtt commented Jan 6, 2021

I believe this addresses #5101

@brad-decker brad-decker force-pushed the custom-network-rpc-method branch 3 times, most recently from b4bbd83 to 3acb000 Compare January 19, 2021 23:08
@metamaskbot
Copy link
Collaborator

Builds ready [3acb000]
Page Load Metrics (672 ± 66 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaintNaNNaNNaNNaNNaN
domContentLoaded36286466613263
load36487167213766
domInteractive36286366513263

@brad-decker brad-decker force-pushed the custom-network-rpc-method branch 2 times, most recently from b606037 to 53028e1 Compare January 20, 2021 17:21
@brad-decker
Copy link
Contributor

@rekmarks 335b9ab implements the switch network approval. This is the only change since you last looked.

@metamaskbot
Copy link
Collaborator

Builds ready [335b9ab]
Page Load Metrics (522 ± 40 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint43805484
domContentLoaded3476235218440
load3486245228440
domInteractive3476225218440

@brad-decker brad-decker force-pushed the custom-network-rpc-method branch from 335b9ab to 53c77ed Compare February 4, 2021 18:38
@metamaskbot
Copy link
Collaborator

Builds ready [b9c39cb]
Page Load Metrics (756 ± 60 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint5410882126
domContentLoaded46884475412560
load46984575612560
domInteractive46884475312460

@brad-decker
Copy link
Contributor

@danjm @Gudahtt -- I believe this is ready for review and if found to be good I'll comment out the code that makes the API active. Once we're ready to launch the feature I'll do a small PR to add that code back in.

* or throws an error in case of failure.
*/
export async function jsonRpcRequest(rpcUrl, rpcMethod, rpcParams = []) {
let fetchUrl = rpcUrl;
Copy link
Contributor

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.
*/
Copy link
Contributor

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',
Copy link
Contributor

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?

Copy link
Contributor

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,
},
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

@danjm danjm left a 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

@brad-decker brad-decker force-pushed the custom-network-rpc-method branch from b9c39cb to bb63145 Compare February 10, 2021 21:42
@metamaskbot
Copy link
Collaborator

Builds ready [bb63145]
Page Load Metrics (590 ± 22 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint448962136
domContentLoaded5107455894622
load5127465904622
domInteractive5107455894622

@brad-decker brad-decker requested a review from danjm February 10, 2021 22:19
danjm
danjm previously approved these changes Feb 11, 2021
Copy link
Contributor

@danjm danjm left a 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

@metamaskbot
Copy link
Collaborator

Builds ready [d04ab15]
Page Load Metrics (610 ± 36 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint468360115
domContentLoaded4688246097536
load4708266107536
domInteractive4688246087536

@brad-decker brad-decker merged commit e48053a into develop Feb 12, 2021
@brad-decker brad-decker deleted the custom-network-rpc-method branch February 12, 2021 15:26
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2021
@Gudahtt Gudahtt removed the DO-NOT-MERGE Pull requests that should not be merged label Feb 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API for dapp to request network change
7 participants