Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/bridge-controller/src/constants/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const DEFAULT_FEATURE_FLAG_CONFIG: FeatureFlagsPlatformConfig = {
maxRefreshCount: DEFAULT_MAX_REFRESH_COUNT,
support: false,
chains: {},
chainRanking: [],
};

export const DEFAULT_BRIDGE_CONTROLLER_STATE: BridgeControllerState = {
Expand Down
3 changes: 3 additions & 0 deletions packages/bridge-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type {
BitcoinTradeDataSchema,
BridgeAssetSchema,
ChainConfigurationSchema,
ChainRankingSchema,
FeatureId,
FeeDataSchema,
PlatformConfigSchema,
Expand Down Expand Up @@ -65,6 +66,8 @@ export enum AssetType {

export type ChainConfiguration = Infer<typeof ChainConfigurationSchema>;

export type ChainRanking = Infer<typeof ChainRankingSchema>;

export type L1GasFees = {
l1GasFeesInHexWei?: string; // l1 fees for approval and trade in hex wei, appended by BridgeController.#appendL1GasFees
};
Expand Down
15 changes: 14 additions & 1 deletion packages/bridge-controller/src/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
pattern,
intersection,
} from '@metamask/superstruct';
import { CaipAssetTypeStruct, isStrictHexString } from '@metamask/utils';
import { CaipAssetTypeStruct, CaipChainIdStruct, isStrictHexString } from '@metamask/utils';

export enum FeeType {
METABRIDGE = 'metabridge',
Expand Down Expand Up @@ -101,6 +101,15 @@ const DefaultPairSchema = type({
other: record(string(), string()),
});

export const ChainRankingItemSchema = type({
/**
* The CAIP-2 chain identifier (e.g., "eip155:1" for Ethereum mainnet)
*/
chainId: CaipChainIdStruct,
});

export const ChainRankingSchema = array(ChainRankingItemSchema);

export const ChainConfigurationSchema = type({
isActiveSrc: boolean(),
isActiveDest: boolean(),
Expand Down Expand Up @@ -154,6 +163,10 @@ export const PlatformConfigSchema = type({
minimumVersion: VersionStringSchema,
}),
),
/**
* Array of chain objects ordered by preference/ranking
*/
chainRanking: ChainRankingSchema,
});

export const validateFeatureFlagsResponse = (
Expand Down
Loading