-
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
New settings custom rpc form #6490
Conversation
d523d9d
to
817f4c2
Compare
} else { | ||
setRpcTarget(rpcUrl, chainId, ticker, networkName, { | ||
blockExplorerUrl: blockExplorerUrl || rpcPrefs.blockExplorerUrl, | ||
...rpcPrefs, |
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 isn't actually setting the blockExplorerUrl
in rpcPrefs
, which is being passed to setRpcTarget
in the background as undefined.
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.
@tmashuang So when you submit a custom rpc form with a block explorer url, you don't have anything set in any of the rpc objects in the state.metamask.frequentRpcListDetail
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.
No, it's not there either. I was looking at it from the provider params, state.metamask.provider
when the network is selected.
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.
@tmashuang This should be fixed now.
9b67e59
to
0eda003
Compare
app/scripts/metamask-controller.js
Outdated
await this.preferencesController.updateRpc({ rpcUrl, chainId, ticker, nickname }) | ||
this.networkController.setRpcTarget(rpcUrl, chainId, ticker, nickname) | ||
async updateAndSetCustomRpc (rpcUrl, chainId, ticker = 'ETH', nickname, rpcPrefs) { | ||
console.log('updateAndSetCustomRpc rpcUrl, chainId, ticker, nickname, rpcPrefs', rpcUrl, chainId, ticker, nickname, rpcPrefs) |
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.
console.log
here
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.
Fixed in 0707b27
if (!!chainId && !Number.isNaN(parseInt(chainId))) { | ||
checkedChainId = chainId | ||
addToFrequentRpcList (url, chainId, ticker = 'ETH', nickname = '', rpcPrefs = {}) { | ||
console.log('addToFrequentRpcList url, chainId, ticker, nickname, rpcPrefs', url, chainId, ticker, nickname, rpcPrefs) |
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.
console.log
here
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.
fixed in 0707b27
return { | ||
setSelectedSettingsRpcUrl: newRpcUrl => dispatch(setSelectedSettingsRpcUrl(newRpcUrl)), | ||
setRpcTarget: (newRpc, chainId, ticker, nickname, rpcPrefs) => { | ||
console.log('setRpcTarget newRpc, chainId, ticker, nickname, rpcPrefs', newRpc, chainId, ticker, nickname, rpcPrefs) |
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.
console.log
here
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.
fixed in 0707b27
displayWarning: warning => dispatch(displayWarning(warning)), | ||
setNetworksTabAddMode: isInAddMode => dispatch(setNetworksTabAddMode(isInAddMode)), | ||
editRpc: (oldRpc, newRpc, chainId, ticker, nickname, rpcPrefs) => { | ||
console.log('editRpc oldRpc, newRpc, chainId, ticker, nickname, rpcPrefs', oldRpc, newRpc, chainId, ticker, nickname, rpcPrefs) |
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.
console.log
here
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.
fixed in 0707b27
ui/app/store/actions.js
Outdated
return (dispatch) => { | ||
log.debug(`background.updateAndSetCustomRpc: ${newRpc} ${chainId} ${ticker} ${nickname}`) | ||
background.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, (err, result) => { | ||
console.log('updateAndSetCustomRpc newRpc, chainId, ticker, nickname || newRpc, rpcPrefs', newRpc, chainId, ticker, nickname || newRpc, rpcPrefs) |
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.
console.log
here
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.
fix during rebase
Updated to resolve a conflict from #6583 (commit will be removed in the squash+merge anyhow) |
onClick: () => { | ||
global.platform.openWindow({ url: genAccountLink(address, network, rpcPrefs) }) | ||
}, | ||
}, this.context.t('blockExplorerView', rpcPrefs.blockExplorerUrl && [rpcPrefs.blockExplorerUrl])), |
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 am getting View account at $1
on the modal screen when on the default Ethereum networks. Could we do
}, this.context.t('blockExplorerView', rpcPrefs.blockExplorerUrl && [rpcPrefs.blockExplorerUrl])), | |
}, rpcrpcPrefs.blockExplorerUrl ? this.context.t('blockExplorerView [rpcPrefs.blockExplorerUrl])) : this.context.t('viewOnEtherscan'), |
and with [rpcPrefs.blockExplorerUrl]
could we parse the url with Regex for just the domain? For my first ugly stab at it,
const expression = /(\w+\.)/gi
const regex = new RegExp(expression)
customBlockExplorer.match(regex)[0].charAt(0).toUpperCase() + customBlockExplorer.match(regex)[0].slice(1).replace(/[^a-zA-Z ]/gi, '')
Edit: probably this [^https?\:\/\/]\w+
might be simpler but doesn't catch some edge cases.
Also, needs the same logic for
text: this.context.t('viewOnEtherscan'), |
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.
Fixed in ed81fed
"message": "Block Explorer" | ||
}, | ||
"blockExplorerView": { | ||
"message": "View account at $1", |
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.
at vs on?
"message": "View account at $1", | |
"message": "View account on $1", |
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.
@danjm addressed a similar comment below and I believe $1
will also be a URL here:
I don't know what the correct grammar is here. $1 will always be a [URL]. "View at http://example.com" sounds a bit more correct... but I don't know why and I might be wrong.
I believe that Dan's correct here and that "at" sounds more natural.
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.
A few small comments and a few quick suggestions
app/_locales/en/messages.json
Outdated
}, | ||
"blockExplorerView": { | ||
"message": "View account at $1", | ||
"description": "$1 replaced by url for custom block explorer" |
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.
"description": "$1 replaced by url for custom block explorer" | |
"description": "$1 replaced by URL for custom block explorer" |
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.
fixed in 5083384
app/_locales/en/messages.json
Outdated
@@ -245,6 +258,9 @@ | |||
"cancelN": { | |||
"message": "Cancel all $1 transactions" | |||
}, | |||
"chainId": { | |||
"message": "Chain Id" |
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.
"message": "Chain Id" | |
"message": "Chain ID" |
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.
fixed in 5083384
"message": "Block Explorer" | ||
}, | ||
"blockExplorerView": { | ||
"message": "View account at $1", |
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.
@danjm addressed a similar comment below and I believe $1
will also be a URL here:
I don't know what the correct grammar is here. $1 will always be a [URL]. "View at http://example.com" sounds a bit more correct... but I don't know why and I might be wrong.
I believe that Dan's correct here and that "at" sounds more natural.
@@ -188,3 +190,17 @@ export function getStatusKey (transaction) { | |||
|
|||
return transaction.status | |||
} | |||
|
|||
/** | |||
* An external block explorer url at which a transaction can be viewed. |
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.
* An external block explorer url at which a transaction can be viewed. | |
* Returns an external block explorer URL at which a transaction can be viewed. |
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.
fixed in 29c5762
|
||
export default class NetworksTab extends PureComponent { | ||
static contextTypes = { | ||
t: PropTypes.func, |
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.
t: PropTypes.func, | |
t: PropTypes.func.isRequired, |
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 think we should try to add .isRequired
to all appropriate prop types going forward. I've suggested them here for the contextTypes
only since I know that these are required and suggesting it for the correct props would require more thought—if you want to add them quickly go for it, but this is more a "moving forward" suggestion.
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.
fixed in 29c5762
export default class NetworksTab extends PureComponent { | ||
static contextTypes = { | ||
t: PropTypes.func, | ||
metricsEvent: PropTypes.func, |
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.
metricsEvent: PropTypes.func, | |
metricsEvent: PropTypes.func.isRequired, |
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.
See note above (attached to t
)
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.
fixed in 29c5762
this.setErrorTo(stateKey, '') | ||
} else { | ||
const appendedRpc = `http://${url}` | ||
const validWhenAppended = validUrl.isWebUri(appendedRpc) && !url.match(/^https*:\/\/$/) |
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.
const validWhenAppended = validUrl.isWebUri(appendedRpc) && !url.match(/^https*:\/\/$/) | |
const validWhenAppended = validUrl.isWebUri(appendedRpc) && !url.match(/^https?:\/\/$/) |
This regex will allow zero or more 's' characters following 'http' (i.e., *
) when it should be zero or 1 (i.e., ?
).[1]
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.
fixed in 29c5762
|
||
export default class NetworksTab extends PureComponent { | ||
static contextTypes = { | ||
t: PropTypes.func, |
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.
t: PropTypes.func, | |
t: PropTypes.func.isRequired, |
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.
fixed in 29c5762
export default class NetworksTab extends PureComponent { | ||
static contextTypes = { | ||
t: PropTypes.func, | ||
metricsEvent: PropTypes.func, |
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.
metricsEvent: PropTypes.func, | |
metricsEvent: PropTypes.func.isRequired, |
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.
fixed in 29c5762
Also with #6583 merged, a few functions might need to be updated |
5a29eee
to
039acca
Compare
039acca
to
29c5762
Compare
LGTM |
resolves #6209
This PR implements the new designs for the Custom RPC form. This PR incorporates everything that was included in the previous #6483 PR, and included additions of the customizable block explorer. It should also incorporate fixes to all the feedback from @bdresser and @cjeria
demo: