Skip to content

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

@salimtb

Description

@salimtb

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions