| name | add-network-core |
|---|---|
| domain | swaps |
| description | Core controller SSOT for adding EVM or non-EVM networks to the Bridge and BridgeStatus controllers |
- A task adds a new EVM or non-EVM network to the Core Bridge or BridgeStatus controller packages.
- The request mentions bridge controller allowlists, chain IDs, native token metadata, CAIP formatters, quote transaction schemas, trade extraction, submit/status handling, or package contract changes.
- Client work in Extension or Mobile depends on new
@metamask/bridge-controlleror@metamask/bridge-status-controllerbehavior.
Core owns the shared package contract consumed by Extension and Mobile. Treat exported types, constants, controller state, messenger actions, events, and transaction payload formats as cross-client API changes.
Before editing code, classify the network:
- EVM: uses EVM chain IDs and EVM transaction data (
TxData) for approvals and trades. - Non-EVM: uses a CAIP scope, network-specific account type, and a non-EVM transaction format signed through the appropriate account or snap path.
- Hybrid or unknown: stop and identify the bridge API transaction format, account model, signing path, and CAIP identifiers before implementation.
Confirm all are true before implementation:
- The bridge backend supports the network.
- Chain identifiers are known, including EVM decimal chain ID or non-EVM CAIP scope.
- Native token metadata is known, including symbol, decimals, token address convention, and icon availability.
- The target network has a clear signing path through existing account/keyring support.
- Extension and Mobile client support requirements are understood.
- Public package contract changes are planned for downstream consumers.
If any prerequisite is missing, stop and report the blocker instead of partially wiring the feature.
Use these references before coding:
- Non-EVM Tron Core integration:
https://github.com/MetaMask/core/pull/6862 - EVM Robinhood Chain Core integration (minimal constants-only template):
https://github.com/MetaMask/core/pull/9459 - Existing non-EVM Solana, Bitcoin, and Tron handling in
packages/bridge-controller/andpackages/bridge-status-controller/ - Existing EVM chain entries in
packages/bridge-controller/src/constants/chains.ts,packages/bridge-controller/src/constants/bridge.ts,packages/bridge-controller/src/constants/tokens.ts, andpackages/bridge-controller/src/types.ts
Review the closest EVM or non-EVM implementation in the target checkout and mirror existing naming, ordering, validation, and test style.
For a standard EVM network whose backend returns existing TxData trade and approval shapes, Core onboarding is usually limited to:
packages/bridge-controller/src/constants/chains.ts—CHAIN_IDS, display name, andNETWORK_TO_NAME_MAPpackages/bridge-controller/src/types.ts— decimalChainIdenum entrypackages/bridge-controller/src/constants/bridge.ts—ALLOWED_BRIDGE_CHAIN_IDSandDEFAULT_CHAIN_RANKINGpackages/bridge-controller/src/constants/tokens.ts— native currency symbol, network token object, andSWAPS_CHAINID_DEFAULT_TOKEN_MAPpackages/bridge-controller/CHANGELOG.md— anAddedentry underUnreleased
Robinhood Chain PR #9459 changed only these five files. It did not update validators, trade utilities, CAIP formatters, exports, BridgeStatus, or tests. Skip the extended sections below unless the network introduces a new trade or approval shape, signing path, CAIP behavior, fee behavior, or public helper.
For agent implementation or review tasks, follow this workflow exactly:
- Confirm prerequisites and classify the network as EVM, non-EVM, or hybrid/unknown.
- Review the closest existing Core implementation before editing.
- For a standard EVM network, follow the Minimal EVM Path. Update validators, trade utilities, CAIP formatters, or exports only when the network introduces behavior that existing generic EVM handling does not cover.
- Update
packages/bridge-status-controlleronly when the network changes non-EVM detection, transaction submission, snap/client request construction, or status handling. - Add a changelog entry when allowlists or public behavior change. Re-check exports and generated messenger action types only when exported helpers, types, or controller messenger contracts change.
- Run targeted package tests and note any remaining client validation gaps.
Update chain and bridge constants when the new network should be available to Bridge:
packages/bridge-controller/src/constants/chains.ts- For EVM networks, add the hex chain ID to
CHAIN_IDS, for exampleROBINHOOD: '0x1237'. - For EVM networks, add the display name constant.
- For EVM networks, add the
NETWORK_TO_NAME_MAPentry. - Do not add non-EVM scopes here unless the file already has a matching local pattern; non-EVM allowlists use keyring scopes instead.
- For EVM networks, add the hex chain ID to
packages/bridge-controller/src/types.ts- Add the bridge API numeric chain ID to the
ChainIdenum when controller code needs a numeric ID. - For EVM networks, the enum decimal value must equal the hex
CHAIN_IDSvalue, for example4663equals0x1237. - For non-EVM networks, follow the Tron pattern with entries such as
TRON = 728126428.
- Add the bridge API numeric chain ID to the
packages/bridge-controller/src/constants/bridge.ts- Add the network to
ALLOWED_BRIDGE_CHAIN_IDS. - For EVM networks, add the hex
CHAIN_IDS.<NETWORK>constant toALLOWED_BRIDGE_CHAIN_IDS. - For non-EVM networks, import and add the keyring scope, for example
TrxScope.Mainnet. - Add the
DEFAULT_CHAIN_RANKINGentry using the correct CAIP chain ID format, for exampleeip155:4663for EVM ortron:728126428for Tron.
- Add the network to
- Keep ordering consistent with existing networks.
- Keep EVM
CHAIN_IDS.*entries grouped before non-EVM keyring scopes inALLOWED_BRIDGE_CHAIN_IDS. - Place new
DEFAULT_CHAIN_RANKINGentries alongside peer networks and use the canonical display name. - Use hex
CHAIN_IDSconstants such asCHAIN_IDS.MAINNETor'0x1'for EVM allowlists. - Use EIP-155 CAIP chain IDs such as
eip155:1for feature flag ranking and CAIP-formatted asset IDs. - Prefer CAIP scopes from
@metamask/keyring-apifor non-EVM networks. - Prefer existing constants from the package before adding new local helpers.
Update native token metadata in packages/bridge-controller/src/constants/tokens.ts when the network needs package-level default token support:
- Add a network key to
CURRENCY_SYMBOLS, with the native symbol as its value, for exampleROBINHOOD: 'ETH'. - Define
<NETWORK>_SWAPS_TOKEN_OBJECT; for an ETH-native EVM chain, spreadETH_SWAPS_TOKEN_OBJECTinstead of duplicating its fields. - Map
[CHAIN_IDS.<NETWORK>]to the network token object inSWAPS_CHAINID_DEFAULT_TOKEN_MAP. - For non-EVM networks, follow the Tron pattern: add the native currency symbol such as
TRX, define a token object such asTRX_SWAPS_TOKEN_OBJECT, map[TrxScope.Mainnet]inSWAPS_CHAINID_DEFAULT_TOKEN_MAP, and add the native asset entry inSYMBOL_TO_SLIP44_MAP, for exampleTRX: 'slip44:195'. - For an ETH-native EVM network, inherit the native address convention, decimals, and icon fields from
ETH_SWAPS_TOKEN_OBJECT; do not add a new SLIP-44 mapping.
For a standard EVM network, only add the ChainId enum entry described above. Update the following internals only where the bridge API introduces a shape that does not already exist:
packages/bridge-controller/src/types.ts- Add network-specific trade data types.
- Extend
QuoteResponsegeneric defaults when the trade or approval type becomes part of the public package contract.
packages/bridge-controller/src/utils/validators.ts- Extend quote response validation schemas for new trade or approval shapes.
packages/bridge-controller/src/validators/trade.ts- Add type guards such as
is<Network>Tradefor custom non-EVM trade data. - Follow existing
isEvmTxData,isBitcoinTrade,isTronTrade, andisStellarTradepatterns.
- Add type guards such as
Keep type narrowing explicit through validators and type guards instead of broad casts.
EVM networks usually continue using existing TxData handling. Non-EVM networks often need a custom schema such as Bitcoin PSBT, Solana serialized transaction, or Tron raw_data_hex.
Update packages/bridge-controller/src/utils/trade-utils.ts:
- Update
extractTradeDataso the transaction data matches the signing path expected by the account or snap client. - Keep network-specific extraction behind the matching
is<Network>Tradetype guard. - Export new type guards or helpers from
packages/bridge-controller/src/index.tswhen clients orbridge-status-controllerneed them.
Do not access network-specific trade fields without first narrowing the trade shape.
Update packages/bridge-controller/src/utils/caip-formatters.ts and nearby bridge utilities:
- Verify
formatChainIdToCaiphandles the network correctly. EVM inputs should use the existing hex/number toeip155:<decimal>path; non-EVM inputs may need explicit mapping from bridge API numeric IDs or aliases to a CAIP scope. - Verify
formatChainIdToDechandles the network correctly for supported inputs: number, hex, CAIP chain ID, or numeric string. Non-EVM CAIP scopes may need explicit mapping back to the bridge API numeric chain ID. - Update
formatChainIdToHexonly for EVM-compatible numeric/CAIP inputs that need app-facing hex IDs. - Update
formatAddressToAssetIdwhen asset ID construction differs from the existing EVMerc20, Solanatoken, or Trontrc20behavior. - In
packages/bridge-controller/src/utils/bridge.ts, addis<Network>ChainIdhelpers and updateisNonEvmChainIdfor non-EVM networks that need shared detection. - In
packages/bridge-controller/src/utils/bridge.ts, updategetNativeAssetForChainIdwhen the network needs a native asset CAIP ID. - For non-EVM networks, include testnet scopes only when the backend and clients need them.
- For EVM networks, prefer the existing EIP-155 and hex conversion paths unless the chain needs special handling.
- Verify the same identifiers are used across constants, request formatting, and client-facing exports.
Update BridgeStatus internals only where the submit/status path differs:
packages/bridge-status-controller/src/bridge-status-controller.ts- Update
submitTxwhen the new network changes submit behavior, approval sequencing, history metadata, or polling behavior. - Preserve existing EVM submit behavior for EVM networks.
- Update
packages/bridge-status-controller/src/strategy/index.ts- In current strategy-based flows, update
validateParamsand the non-EVM branch inexecuteSubmitStrategyso the network routes tosubmitNonEvmHandler.
- In current strategy-based flows, update
packages/bridge-status-controller/src/utils/snaps.ts- Update
getClientRequestwhen a non-EVM signing request needs network-specific scope, account ID, encoded transaction data, or options. - Keep request construction aligned with
extractTradeData.
- Update
packages/bridge-status-controller/src/utils/bridge-status.tsandpackages/bridge-status-controller/src/utils/history.ts- Update only if non-EVM status or history behavior differs.
Ensure approval handling is included only when the network supports approvals.
Non-EVM transaction data must be converted to the exact format the signing path expects. For example, Tron raw transaction hex may need base64 encoding and request options derived from the raw contract type.
For EVM networks:
- Reuse existing
TxDataquote and approval types unless the backend introduces a new shape. - Add chain constants in
constants/chains.ts, the decimalChainIdenum entry intypes.ts, bridge allowlist/ranking entries inconstants/bridge.ts, and native/default token mappings inconstants/tokens.ts. - Verify quote fee logic if the network has unusual fee semantics.
- Confirm approval flow behavior for token swaps and bridge transactions.
- Do not update
bridge-status-controllersubmit strategy code unless the new EVM network changes submit behavior beyond existingTxDatahandling. - Avoid adding non-EVM CAIP or snap-specific handling unless the network actually needs it.
For non-EVM networks:
- Use the network scope from
@metamask/keyring-api. - Add SLIP-44 metadata when needed.
- Define custom transaction schemas only for real backend response shapes.
- Add type guards and extraction utilities for network-specific transaction data.
- Update CAIP conversion helpers.
- Update
isNonEvmChainIdstyle detection. - Ensure the selected account has the correct snap/account metadata for signing.
- Pass network-specific request options to the signing path only when required.
Core package changes usually gate availability through exported allowlists and package versions. Coordinate with client rollouts:
- Extension and Mobile must consume a package version that includes the new network.
- LaunchDarkly/client flags still control user-facing rollout in the consuming repos.
- Public exports and behavior changes need changelog or release note handling according to Core repo conventions.
- EVM allowlist additions in
@metamask/bridge-controllershould include apackages/bridge-controller/CHANGELOG.mdentry.
Before finishing, verify:
- Standard EVM constants and token metadata are present in the five Minimal EVM Path files.
- Existing EVM CAIP conversion and
TxDatahandling cover the new chain without code changes. - For non-EVM or custom trade shapes, type guards,
extractTradeData, and CAIP formatters are updated and tested. - BridgeStatus remains untouched for a standard EVM network and changes only when submit, status, or signing behavior differs.
CHANGELOG.mdincludes anUnreleasedentry when an allowlist changes.- Package exports and generated messenger action types are checked only when their contracts change.
- Downstream Extension and Mobile impact is explicitly called out.
Run targeted tests for the touched package areas:
yarn workspace @metamask/bridge-controller testyarn workspace @metamask/bridge-status-controller testonly when BridgeStatus is touched
Also run build/type or generated contract checks when relevant:
yarn workspace @metamask/bridge-controller buildyarn workspace @metamask/bridge-status-controller buildonly when BridgeStatus is touched- Messenger action type checks when messenger actions or controller events change
- Changelog validation when public package behavior changes
If behavior changes, add or update tests in the closest package test suites.
Constants-only EVM allowlist additions such as PR #9459 may require no new unit tests when existing generic EVM formatter and validator coverage applies. Still run the Bridge controller package tests to check for regressions.
When using this standard, return:
Prerequisites CheckNetwork ClassificationImplementation ChecklistFiles ChangedPackage Contract ImpactGating Behavior VerifiedTests RunRemaining Gaps