Skip to content

Commit

Permalink
fix: Custom network chain id not converted to hexadecimal format (#8606)
Browse files Browse the repository at this point in the history
## **Description**
This
[PR](https://github.com/MetaMask/metamask-mobile/pull/8234/files#diff-6db807cd50e056502de0cd9a1277d4a284458f3eee610d6ed1a5115da9a8cdb4)
was merged some days before the hexadecimal chain id format, and those
changes were missed when the hexadecimal chain id PR was merged.

This PR addresses the conversion to hexadecimal format and also a non
handled promise when nickname is undefined when a custom network is
added.

## **Related issues**

Fixes: NA

## **Manual testing steps**

1. Go to add custom network
2. Enter fields needed ([like Gnosis network
info](https://chainlist.org/?search=gnosis))
3. The user should see a bottom sheet to confirm the intention of adding
that network
4. The user should see a bottom sheet to switch to that network
5. User should be switched to that network if confirmed it

## **Screenshots/Recordings**

https://recordit.co/ECgXE9ZHke


### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've clearly explained what problem this PR is solving and how it
is solved.
- [ ] I've linked related issues
- [x] I've included manual testing steps
- [x] I've included screenshots/recordings if applicable
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [ ] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
tommasini authored Feb 16, 2024
1 parent 2a194b8 commit a867002
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -884,11 +884,9 @@ class NetworkSettings extends PureComponent {
: styles.button;

const url = new URL(rpcUrl);
const decimalChainId = this.getDecimalChainId(chainId);

const selectedNetwork = {
rpcUrl: url.href,
chainId: decimalChainId,
ticker,
nickname,
rpcPrefs: {
Expand All @@ -903,7 +901,7 @@ class NetworkSettings extends PureComponent {
<CustomNetwork
isNetworkModalVisible={this.state.showNetworkDetailsModal}
closeNetworkModal={this.toggleNetworkDetailsModal}
selectedNetwork={selectedNetwork}
selectedNetwork={{ ...selectedNetwork, chainId: toHex(chainId) }}
toggleWarningModal={this.toggleWarningModal}
showNetworkModal={this.showNetworkModal}
switchTab={this.tabView}
Expand Down
2 changes: 1 addition & 1 deletion app/core/RPCMethods/networkChecker.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const checkSafeNetwork = async (
alertOrigin: 'decimals',
});
}
if (matchedChain.name?.toLowerCase() !== nickname.toLowerCase()) {
if (matchedChain.name?.toLowerCase() !== nickname?.toLowerCase()) {
alerts.push({
alertError: strings('add_custom_network.unrecognized_chain_name'),
alertSeverity: BannerAlertSeverity.Warning,
Expand Down

0 comments on commit a867002

Please sign in to comment.