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
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ describe('BridgeController SSE', function () {
isActiveDest: true,
},
},
chainRanking: [
{ chainId: 'eip155:10' },
{ chainId: 'eip155:534352' },
{ chainId: 'eip155:137' },
{ chainId: 'eip155:42161' },
{ chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' },
],
});

bridgeController = new BridgeController({
Expand Down
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 @@ -54,6 +54,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
14 changes: 11 additions & 3 deletions packages/bridge-controller/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ export type {

export { StatusTypes } from './types';

export type {
BridgeAssetV2,
BridgeControllerGetStateAction,
BridgeControllerStateChangeEvent,
} from './types';
export {
AssetType,
SortOrder,
ChainId,
RequestStatus,
BridgeUserAction,
BridgeBackgroundAction,
type BridgeControllerGetStateAction,
type BridgeControllerStateChangeEvent,
} from './types';

export {
Expand Down Expand Up @@ -123,7 +126,12 @@ export {

export { calcLatestSrcBalance } from './utils/balance';

export { fetchBridgeTokens, getClientHeaders } from './utils/fetch';
export {
fetchBridgeTokens,
getClientHeaders,
fetchTokensBySearchQuery,
fetchPopularTokens,
} from './utils/fetch';

export {
formatChainIdToCaip,
Expand Down
3 changes: 3 additions & 0 deletions packages/bridge-controller/src/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ describe('Bridge Selectors', () => {
refreshRate: 30000,
chains: {},
support: false,
chainRanking: [],
});
});

Expand All @@ -1096,6 +1097,7 @@ describe('Bridge Selectors', () => {
refreshRate: 30000,
chains: {},
support: false,
chainRanking: [],
});
});

Expand All @@ -1111,6 +1113,7 @@ describe('Bridge Selectors', () => {
maxRefreshCount: 5,
refreshRate: 30000,
chains: {},
chainRanking: [],
support: false,
});
});
Expand Down
22 changes: 21 additions & 1 deletion packages/bridge-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import type { BRIDGE_CONTROLLER_NAME } from './constants/bridge';
import type {
BitcoinTradeDataSchema,
BridgeAssetSchema,
BridgeAssetV2Schema,
ChainConfigurationSchema,
FeatureId,
FeeDataSchema,
MinimalAssetSchema,
PlatformConfigSchema,
ProtocolSchema,
QuoteResponseSchema,
Expand Down Expand Up @@ -81,7 +83,7 @@ export type TokenAmountValues = {
/**
* The amount of the token
*
* @example "1000000000000000000"
* @example "1.000143200000000000"
*/
amount: string;
/**
Expand Down Expand Up @@ -157,6 +159,24 @@ export enum SortOrder {
*/
export type BridgeAsset = Infer<typeof BridgeAssetSchema>;

export type TokenBalance = {
/**
* The users balance displayed in decimal-normalized form
* i.e. 1100000000000000000 is shown as `1.1`
*/
balance?: string;
/**
* The users balance in the user's selected currency
*/
tokenFiatAmount?: number | null;
};

/**
* This is the interface for the asset object returned by the bridge-api popular and search token endpoings
* This type is used in the fetchPopularTokens and fetchSearchTokens responses
*/
export type BridgeAssetV2 = Infer<typeof BridgeAssetV2Schema>;
export type MinimalAsset = Infer<typeof MinimalAssetSchema>;
/**
* This is the interface for the token object used in the extension client
* In addition to the {@link BridgeAsset} fields, it includes balance information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ describe('feature-flags', () => {
support: false,
minimumVersion: '0.0.0',
chains: {},
chainRanking: [],
};
expect(result).toStrictEqual(expectedBridgeConfig);
});
Expand Down
Loading
Loading