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

[Network-controller-upgrade ] Update Controller Version to v21 #11229

Closed
salimtb opened this issue Sep 16, 2024 · 2 comments
Closed

[Network-controller-upgrade ] Update Controller Version to v21 #11229

salimtb opened this issue Sep 16, 2024 · 2 comments
Assignees
Labels
INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. team-wallet-framework

Comments

@salimtb
Copy link
Contributor

salimtb commented Sep 16, 2024

This task involves updating the Network Controller to version 21 in MetaMask Mobile. The primary objective is to migrate the state structure from the current version to the new version, ensuring compatibility with the latest features and improvements.
Current State (Version 20):

{
  "selectedNetworkClientId": "673a4523-3c49-47cd-8d48-68dfc8a47a9c",
  "networksMetadata": {
    "mainnet": {
      "status": "available",
      "EIPS": {
        "1559": true
      }
    },
    "linea-mainnet": {
      "status": "available",
      "EIPS": {
        "1559": true
      }
    },
    "d740f3bf-4b3a-4ce5-80f0-df13071ae5fc": {
      "status": "available",
      "EIPS": {
        "1559": true
      }
    },
    "673a4523-3c49-47cd-8d48-68dfc8a47a9c": {
      "status": "available",
      "EIPS": {
        "1559": true
      }
    }
  },
  "networkConfigurations": {
    "673a4523-3c49-47cd-8d48-68dfc8a47a9c": {
      "id": "673a4523-3c49-47cd-8d48-68dfc8a47a9c",
      "rpcUrl": "https://bsc-dataseed1.binance.org/",
      "chainId": "0x38",
      "ticker": "BNB",
      "nickname": "BNB Chain",
      "rpcPrefs": {
        "blockExplorerUrl": "https://bscscan.com"
      }
    },
    "any-other-id": {
      "id": "any-other-id",
      "rpcUrl": "https://bsc-mainnet.public.blastapi.io",
      "chainId": "0x38",
      "ticker": "BNB",
      "nickname": "BNB Chain",
      "rpcPrefs": {
        "blockExplorerUrl": "https://bscscan.com"
      }
    }
  }
}

Target State (Version 21):

{
  "networkConfigurationsByChainId": {
    "0x38": {
      "chainId": "0x38",
      "rpcEndpoints": [
        {
          "networkClientId": "673a4523-3c49-47cd-8d48-68dfc8a47a9c",
          "url": "https://bsc-dataseed1.binance.org/",
          "type": "custom",
          "name": "BNB Chain"
        },
        {
          "networkClientId": "any-other-id",
          "url": "https://bsc-mainnet.public.blastapi.io",
          "type": "custom",
          "name": "BNB Chain"
        }
      ],
      "defaultRpcEndpointIndex": 0,
      "blockExplorerUrls": ["https://bscscan.com"],
      "defaultBlockExplorerUrlIndex": 0,
      "name": "Binance Smart Chain",
      "nativeCurrency": "BNB"
    }
  },
  "networksMetadata": {
    "mainnet": {
      "status": "available",
      "EIPS": { "1559": true }
    },
    "linea-mainnet": {
      "status": "available",
      "EIPS": { "1559": true }
    },
    "d740f3bf-4b3a-4ce5-80f0-df13071ae5fc": {
      "status": "available",
      "EIPS": { "1559": true }
    },
    "673a4523-3c49-47cd-8d48-68dfc8a47a9c": {
      "status": "available",
      "EIPS": { "1559": true }
    }
  },
  "selectedNetworkClientId": "673a4523-3c49-47cd-8d48-68dfc8a47a9c"
}

Key Changes:

Network Configurations:
The networkConfigurations object is replaced with networkConfigurationsByChainId.
Each chain ID now maps to an object containing rpcEndpoints, blockExplorerUrls, and other metadata.
rpcEndpoints is an array of RPC endpoint objects, each containing networkClientId, url, type, and name.
defaultRpcEndpointIndex and defaultBlockExplorerUrlIndex are added to specify the default RPC endpoint and block explorer URL.

Selected Network Client ID:
The selectedNetworkClientId remains the same but is now part of the updated state structure.
Networks Metadata:

The networksMetadata structure remains unchanged, ensuring compatibility with existing metadata.

@salimtb salimtb self-assigned this Sep 16, 2024
@metamaskbot metamaskbot added the INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. label Sep 16, 2024
@salimtb salimtb changed the title [Controller-upgrade ] Update Controller Version to v21 [Network-controller-upgrade ] Update Controller Version to v21 Sep 16, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 11, 2024
…etworks with Distinct ChainIDs and Multiple RPC URLs (#11705)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
This PR refactors our network configuration to eliminate the use of
multiple networks with the same ChainID but different RPC URLs. Instead,
we are moving towards a setup where each network is uniquely identified
by a distinct ChainID and can have multiple RPC URLs associated with it.

This PR includes three merge commits. The first primarily addresses the
Network Controller upgrade, as outlined in issue
#[11229](#11229). The
second commit contains the script for migrating the state to v21, and
the third commit includes all the UI changes along with the fix for the
e2e tests.

For more details, please refer to
[this](https://github.com/orgs/MetaMask/projects/120/views/1) .

related PRs:

- #11292
- #11622
- #11436

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes:
#[11229](#11229)
#[11232](#11232)
#[11234](#11234)
#11233

## **Manual testing steps**

1. Go to add network flow and test

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

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

### **After**


https://drive.google.com/drive/folders/149Xji42k5of5Vl8nBlI0pFYFgPnWqILH?usp=drive_link

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

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] 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.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] 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.
@mikesposito
Copy link
Member

@salimtb @cryptodev-2s can this be closed now that we merged #11705?

@salimtb
Copy link
Contributor Author

salimtb commented Oct 17, 2024

hey @mikesposito , yes this issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. team-wallet-framework
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants