@metamask/bridge-controller 46.0.0 → 47.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -1
- package/dist/bridge-controller.cjs +20 -18
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts +3 -1
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts +3 -1
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +20 -18
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/constants/bridge.cjs.map +1 -1
- package/dist/constants/bridge.d.cts +2 -8
- package/dist/constants/bridge.d.cts.map +1 -1
- package/dist/constants/bridge.d.mts +2 -8
- package/dist/constants/bridge.d.mts.map +1 -1
- package/dist/constants/bridge.mjs.map +1 -1
- package/dist/selectors.d.cts +188 -0
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +188 -0
- package/dist/selectors.d.mts.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/feature-flags.d.cts +4 -0
- package/dist/utils/feature-flags.d.cts.map +1 -1
- package/dist/utils/feature-flags.d.mts +4 -0
- package/dist/utils/feature-flags.d.mts.map +1 -1
- package/dist/utils/metrics/constants.cjs +0 -1
- package/dist/utils/metrics/constants.cjs.map +1 -1
- package/dist/utils/metrics/constants.d.cts +0 -1
- package/dist/utils/metrics/constants.d.cts.map +1 -1
- package/dist/utils/metrics/constants.d.mts +0 -1
- package/dist/utils/metrics/constants.d.mts.map +1 -1
- package/dist/utils/metrics/constants.mjs +0 -1
- package/dist/utils/metrics/constants.mjs.map +1 -1
- package/dist/utils/metrics/properties.cjs.map +1 -1
- package/dist/utils/metrics/properties.d.cts +1 -1
- package/dist/utils/metrics/properties.d.cts.map +1 -1
- package/dist/utils/metrics/properties.d.mts +1 -1
- package/dist/utils/metrics/properties.d.mts.map +1 -1
- package/dist/utils/metrics/properties.mjs.map +1 -1
- package/dist/utils/metrics/types.cjs.map +1 -1
- package/dist/utils/metrics/types.d.cts +1 -3
- package/dist/utils/metrics/types.d.cts.map +1 -1
- package/dist/utils/metrics/types.d.mts +1 -3
- package/dist/utils/metrics/types.d.mts.map +1 -1
- package/dist/utils/metrics/types.mjs.map +1 -1
- package/dist/utils/validators.cjs +18 -0
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +47 -0
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +47 -0
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +18 -0
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n} from './constants';\nimport type { SortOrder, StatusTypes } from '../../types';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n};\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n};\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called\n */\nexport type RequiredEventContextFromClient = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: {\n location: MetaMetricsSwapsEventSource;\n } & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'>;\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n input_value: InputValues[keyof InputValues];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: string[]; // TODO standardize warnings\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n} from './constants';\nimport type { SortOrder, StatusTypes } from '../../types';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n};\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n};\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called\n */\nexport type RequiredEventContextFromClient = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: {\n location: MetaMetricsSwapsEventSource;\n } & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'>;\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n input_value: InputValues[keyof InputValues];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: string[]; // TODO standardize warnings\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Failed]:\n | // Tx failed before confirmation\n (TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet'\n > &\n Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { error_message: string }) // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n Pick<QuoteFetchData, 'price_impact'> &\n TxStatusData &\n TradeData & {\n actual_time_minutes: number;\n error_message?: string;\n });\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n action_type: MetricsActionType;\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
|
|
@@ -57,6 +57,18 @@ exports.BridgeAssetSchema = (0, superstruct_1.type)({
|
|
|
57
57
|
*/
|
|
58
58
|
iconUrl: (0, superstruct_1.optional)((0, superstruct_1.nullable)((0, superstruct_1.string)())),
|
|
59
59
|
});
|
|
60
|
+
const DefaultPairSchema = (0, superstruct_1.type)({
|
|
61
|
+
/**
|
|
62
|
+
* The standard default pairs. Use this if the pair is only set once.
|
|
63
|
+
* The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
|
|
64
|
+
*/
|
|
65
|
+
standard: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.string)()),
|
|
66
|
+
/**
|
|
67
|
+
* The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.
|
|
68
|
+
* The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
|
|
69
|
+
*/
|
|
70
|
+
other: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.string)()),
|
|
71
|
+
});
|
|
60
72
|
exports.ChainConfigurationSchema = (0, superstruct_1.type)({
|
|
61
73
|
isActiveSrc: (0, superstruct_1.boolean)(),
|
|
62
74
|
isActiveDest: (0, superstruct_1.boolean)(),
|
|
@@ -67,6 +79,7 @@ exports.ChainConfigurationSchema = (0, superstruct_1.type)({
|
|
|
67
79
|
isSingleSwapBridgeButtonEnabled: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
68
80
|
isGaslessSwapEnabled: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
69
81
|
noFeeAssets: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
|
|
82
|
+
defaultPairs: (0, superstruct_1.optional)(DefaultPairSchema),
|
|
70
83
|
});
|
|
71
84
|
exports.PriceImpactThresholdSchema = (0, superstruct_1.type)({
|
|
72
85
|
gasless: (0, superstruct_1.number)(),
|
|
@@ -89,6 +102,11 @@ exports.PlatformConfigSchema = (0, superstruct_1.type)({
|
|
|
89
102
|
maxRefreshCount: (0, superstruct_1.number)(),
|
|
90
103
|
support: (0, superstruct_1.boolean)(),
|
|
91
104
|
chains: (0, superstruct_1.record)((0, superstruct_1.string)(), exports.ChainConfigurationSchema),
|
|
105
|
+
/**
|
|
106
|
+
* The bip44 default pairs for the chains
|
|
107
|
+
* Key is the CAIP chainId namespace
|
|
108
|
+
*/
|
|
109
|
+
bip44DefaultPairs: (0, superstruct_1.optional)((0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.optional)(DefaultPairSchema))),
|
|
92
110
|
});
|
|
93
111
|
const validateFeatureFlagsResponse = (data) => {
|
|
94
112
|
return (0, superstruct_1.is)(data, exports.PlatformConfigSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.cjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":";;;AAAA,iEAA+D;AAE/D,uDAgB+B;AAC/B,2CAAyE;AAEzE,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,4BAAiB,CAAA;IACjB,2BAAgB,CAAA;AAClB,CAAC,EAJW,OAAO,uBAAP,OAAO,QAIlB;AAED,IAAY,SAEX;AAFD,WAAY,SAAS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E,IAAA,mBAAK,EAAC,CAAC,oBAAY,EAAE,8BAAsB,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC;CAC/D,CAAC,CAAC;AAEU,QAAA,0BAA0B,GAAG,IAAA,kBAAI,EAAC;IAC7C,KAAK,EAAE,mBAAW;IAClB,gCAAgC,EAAE,IAAA,oBAAM,GAAE;IAC1C,QAAQ,EAAE,IAAA,sBAAQ,EAAC,oBAAY,CAAC;IAChC,KAAK,EAAE,8BAAsB;CAC9B,CAAC,CAAC;AAEI,MAAM,qBAAqB,GAAG,CACnC,IAAa,EAC8B,EAAE;IAC7C,IAAA,oBAAM,EAAC,IAAI,EAAE,2BAAmB,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC;AAEK,MAAM,4BAA4B,GAAG,CAC1C,IAAa,EACqC,EAAE;IACpD,IAAA,oBAAM,EAAC,IAAI,EAAE,kCAA0B,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC","sourcesContent":["import { isValidHexAddress } from '@metamask/controller-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n boolean,\n number,\n type,\n is,\n record,\n array,\n nullable,\n optional,\n enums,\n define,\n union,\n assert,\n pattern,\n intersection,\n} from '@metamask/superstruct';\nimport { CaipAssetTypeStruct, isStrictHexString } from '@metamask/utils';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n TX_FEE = 'txFee',\n}\n\nexport enum FeatureId {\n PERPS = 'perps',\n}\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nconst HexAddressSchema = define<string>('HexAddress', (v: unknown) =>\n isValidHexAddress(v as string, { allowNonPrefixed: false }),\n);\n\nconst HexStringSchema = define<string>('HexString', (v: unknown) =>\n isStrictHexString(v as string),\n);\n\nexport const truthyString = (s: string) => Boolean(s?.length);\nconst TruthyDigitStringSchema = pattern(string(), /^\\d+$/u);\n\nconst ChainIdSchema = number();\n\nexport const BridgeAssetSchema = type({\n /**\n * The chainId of the token\n */\n chainId: ChainIdSchema,\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string(),\n /**\n * The assetId of the token\n */\n assetId: CaipAssetTypeStruct,\n /**\n * The symbol of token object\n */\n symbol: string(),\n /**\n * The name for the network\n */\n name: string(),\n decimals: number(),\n /**\n * URL for token icon\n */\n icon: optional(nullable(string())),\n /**\n * URL for token icon\n */\n iconUrl: optional(nullable(string())),\n});\n\nexport const ChainConfigurationSchema = type({\n isActiveSrc: boolean(),\n isActiveDest: boolean(),\n refreshRate: optional(number()),\n topAssets: optional(array(string())),\n stablecoins: optional(array(string())),\n isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\n noFeeAssets: optional(array(string())),\n});\n\nexport const PriceImpactThresholdSchema = type({\n gasless: number(),\n normal: number(),\n});\n\nconst GenericQuoteRequestSchema = type({\n aggIds: optional(array(string())),\n bridgeIds: optional(array(string())),\n noFee: optional(boolean()),\n});\n\nconst FeatureIdSchema = enums(Object.values(FeatureId));\n\n/**\n * This is the schema for the feature flags response from the RemoteFeatureFlagController\n */\nexport const PlatformConfigSchema = type({\n priceImpactThreshold: optional(PriceImpactThresholdSchema),\n quoteRequestOverrides: optional(\n record(FeatureIdSchema, optional(GenericQuoteRequestSchema)),\n ),\n minimumVersion: string(),\n refreshRate: number(),\n maxRefreshCount: number(),\n support: boolean(),\n chains: record(string(), ChainConfigurationSchema),\n});\n\nexport const validateFeatureFlagsResponse = (\n data: unknown,\n): data is Infer<typeof PlatformConfigSchema> => {\n return is(data, PlatformConfigSchema);\n};\n\nexport const validateSwapsTokenObject = (\n data: unknown,\n): data is Infer<typeof BridgeAssetSchema> => {\n return is(data, BridgeAssetSchema);\n};\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n});\n\nexport const ProtocolSchema = type({\n name: string(),\n displayName: optional(string()),\n icon: optional(string()),\n});\n\nexport const StepSchema = type({\n action: enums(Object.values(ActionTypes)),\n srcChainId: ChainIdSchema,\n destChainId: optional(ChainIdSchema),\n srcAsset: BridgeAssetSchema,\n destAsset: BridgeAssetSchema,\n srcAmount: string(),\n destAmount: string(),\n protocol: ProtocolSchema,\n});\n\nconst RefuelDataSchema = StepSchema;\n\nexport const QuoteSchema = type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: string(),\n feeData: type({\n [FeeType.METABRIDGE]: FeeDataSchema,\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([\n FeeDataSchema,\n type({\n maxFeePerGas: string(),\n maxPriorityFeePerGas: string(),\n }),\n ]),\n ),\n }),\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n bridgeId: string(),\n bridges: array(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n});\n\nexport const TxDataSchema = type({\n chainId: number(),\n to: HexAddressSchema,\n from: HexAddressSchema,\n value: HexStringSchema,\n data: HexStringSchema,\n gasLimit: nullable(number()),\n effectiveGas: optional(number()),\n});\n\nexport const BitcoinTradeDataSchema = type({\n unsignedPsbtBase64: string(),\n inputsToSign: nullable(array(type({}))),\n});\n\nexport const QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: union([TxDataSchema, BitcoinTradeDataSchema, string()]),\n});\n\nexport const BitcoinQuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: BitcoinTradeDataSchema,\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n\nexport const validateBitcoinQuoteResponse = (\n data: unknown,\n): data is Infer<typeof BitcoinQuoteResponseSchema> => {\n assert(data, BitcoinQuoteResponseSchema);\n return true;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"validators.cjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":";;;AAAA,iEAA+D;AAE/D,uDAgB+B;AAC/B,2CAAyE;AAEzE,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,4BAAiB,CAAA;IACjB,2BAAgB,CAAA;AAClB,CAAC,EAJW,OAAO,uBAAP,OAAO,QAIlB;AAED,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,4BAAe,CAAA;AACjB,CAAC,EAFW,SAAS,yBAAT,SAAS,QAEpB;AAED,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAED,MAAM,gBAAgB,GAAG,IAAA,oBAAM,EAAS,YAAY,EAAE,CAAC,CAAU,EAAE,EAAE,CACnE,IAAA,oCAAiB,EAAC,CAAW,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAC5D,CAAC;AAEF,MAAM,eAAe,GAAG,IAAA,oBAAM,EAAS,WA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,IAAA,sBAAQ,EAAC,oBAAY,CAAC;IAChC,KAAK,EAAE,IAAA,mBAAK,EAAC,CAAC,oBAAY,EAAE,8BAAsB,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC;CAC/D,CAAC,CAAC;AAEU,QAAA,0BAA0B,GAAG,IAAA,kBAAI,EAAC;IAC7C,KAAK,EAAE,mBAAW;IAClB,gCAAgC,EAAE,IAAA,oBAAM,GAAE;IAC1C,QAAQ,EAAE,IAAA,sBAAQ,EAAC,oBAAY,CAAC;IAChC,KAAK,EAAE,8BAAsB;CAC9B,CAAC,CAAC;AAEI,MAAM,qBAAqB,GAAG,CACnC,IAAa,EAC8B,EAAE;IAC7C,IAAA,oBAAM,EAAC,IAAI,EAAE,2BAAmB,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC;AAEK,MAAM,4BAA4B,GAAG,CAC1C,IAAa,EACqC,EAAE;IACpD,IAAA,oBAAM,EAAC,IAAI,EAAE,kCAA0B,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC","sourcesContent":["import { isValidHexAddress } from '@metamask/controller-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n boolean,\n number,\n type,\n is,\n record,\n array,\n nullable,\n optional,\n enums,\n define,\n union,\n assert,\n pattern,\n intersection,\n} from '@metamask/superstruct';\nimport { CaipAssetTypeStruct, isStrictHexString } from '@metamask/utils';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n TX_FEE = 'txFee',\n}\n\nexport enum FeatureId {\n PERPS = 'perps',\n}\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nconst HexAddressSchema = define<string>('HexAddress', (v: unknown) =>\n isValidHexAddress(v as string, { allowNonPrefixed: false }),\n);\n\nconst HexStringSchema = define<string>('HexString', (v: unknown) =>\n isStrictHexString(v as string),\n);\n\nexport const truthyString = (s: string) => Boolean(s?.length);\nconst TruthyDigitStringSchema = pattern(string(), /^\\d+$/u);\n\nconst ChainIdSchema = number();\n\nexport const BridgeAssetSchema = type({\n /**\n * The chainId of the token\n */\n chainId: ChainIdSchema,\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string(),\n /**\n * The assetId of the token\n */\n assetId: CaipAssetTypeStruct,\n /**\n * The symbol of token object\n */\n symbol: string(),\n /**\n * The name for the network\n */\n name: string(),\n decimals: number(),\n /**\n * URL for token icon\n */\n icon: optional(nullable(string())),\n /**\n * URL for token icon\n */\n iconUrl: optional(nullable(string())),\n});\n\nconst DefaultPairSchema = type({\n /**\n * The standard default pairs. Use this if the pair is only set once.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n standard: record(string(), string()),\n /**\n * The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n other: record(string(), string()),\n});\n\nexport const ChainConfigurationSchema = type({\n isActiveSrc: boolean(),\n isActiveDest: boolean(),\n refreshRate: optional(number()),\n topAssets: optional(array(string())),\n stablecoins: optional(array(string())),\n isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\n noFeeAssets: optional(array(string())),\n defaultPairs: optional(DefaultPairSchema),\n});\n\nexport const PriceImpactThresholdSchema = type({\n gasless: number(),\n normal: number(),\n});\n\nconst GenericQuoteRequestSchema = type({\n aggIds: optional(array(string())),\n bridgeIds: optional(array(string())),\n noFee: optional(boolean()),\n});\n\nconst FeatureIdSchema = enums(Object.values(FeatureId));\n\n/**\n * This is the schema for the feature flags response from the RemoteFeatureFlagController\n */\nexport const PlatformConfigSchema = type({\n priceImpactThreshold: optional(PriceImpactThresholdSchema),\n quoteRequestOverrides: optional(\n record(FeatureIdSchema, optional(GenericQuoteRequestSchema)),\n ),\n minimumVersion: string(),\n refreshRate: number(),\n maxRefreshCount: number(),\n support: boolean(),\n chains: record(string(), ChainConfigurationSchema),\n /**\n * The bip44 default pairs for the chains\n * Key is the CAIP chainId namespace\n */\n bip44DefaultPairs: optional(record(string(), optional(DefaultPairSchema))),\n});\n\nexport const validateFeatureFlagsResponse = (\n data: unknown,\n): data is Infer<typeof PlatformConfigSchema> => {\n return is(data, PlatformConfigSchema);\n};\n\nexport const validateSwapsTokenObject = (\n data: unknown,\n): data is Infer<typeof BridgeAssetSchema> => {\n return is(data, BridgeAssetSchema);\n};\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n});\n\nexport const ProtocolSchema = type({\n name: string(),\n displayName: optional(string()),\n icon: optional(string()),\n});\n\nexport const StepSchema = type({\n action: enums(Object.values(ActionTypes)),\n srcChainId: ChainIdSchema,\n destChainId: optional(ChainIdSchema),\n srcAsset: BridgeAssetSchema,\n destAsset: BridgeAssetSchema,\n srcAmount: string(),\n destAmount: string(),\n protocol: ProtocolSchema,\n});\n\nconst RefuelDataSchema = StepSchema;\n\nexport const QuoteSchema = type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: string(),\n feeData: type({\n [FeeType.METABRIDGE]: FeeDataSchema,\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([\n FeeDataSchema,\n type({\n maxFeePerGas: string(),\n maxPriorityFeePerGas: string(),\n }),\n ]),\n ),\n }),\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n bridgeId: string(),\n bridges: array(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n});\n\nexport const TxDataSchema = type({\n chainId: number(),\n to: HexAddressSchema,\n from: HexAddressSchema,\n value: HexStringSchema,\n data: HexStringSchema,\n gasLimit: nullable(number()),\n effectiveGas: optional(number()),\n});\n\nexport const BitcoinTradeDataSchema = type({\n unsignedPsbtBase64: string(),\n inputsToSign: nullable(array(type({}))),\n});\n\nexport const QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: union([TxDataSchema, BitcoinTradeDataSchema, string()]),\n});\n\nexport const BitcoinQuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: BitcoinTradeDataSchema,\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n\nexport const validateBitcoinQuoteResponse = (\n data: unknown,\n): data is Infer<typeof BitcoinQuoteResponseSchema> => {\n assert(data, BitcoinQuoteResponseSchema);\n return true;\n};\n"]}
|
|
@@ -62,6 +62,10 @@ export declare const ChainConfigurationSchema: import("@metamask/superstruct").S
|
|
|
62
62
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
63
63
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
64
64
|
noFeeAssets?: string[] | undefined;
|
|
65
|
+
defaultPairs?: {
|
|
66
|
+
standard: Record<string, string>;
|
|
67
|
+
other: Record<string, string>;
|
|
68
|
+
} | undefined;
|
|
65
69
|
}, {
|
|
66
70
|
isActiveSrc: import("@metamask/superstruct").Struct<boolean, null>;
|
|
67
71
|
isActiveDest: import("@metamask/superstruct").Struct<boolean, null>;
|
|
@@ -72,6 +76,21 @@ export declare const ChainConfigurationSchema: import("@metamask/superstruct").S
|
|
|
72
76
|
isSingleSwapBridgeButtonEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
73
77
|
isGaslessSwapEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
74
78
|
noFeeAssets: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
|
|
79
|
+
defaultPairs: import("@metamask/superstruct").Struct<{
|
|
80
|
+
standard: Record<string, string>;
|
|
81
|
+
other: Record<string, string>;
|
|
82
|
+
} | undefined, {
|
|
83
|
+
/**
|
|
84
|
+
* The standard default pairs. Use this if the pair is only set once.
|
|
85
|
+
* The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
|
|
86
|
+
*/
|
|
87
|
+
standard: import("@metamask/superstruct").Struct<Record<string, string>, null>;
|
|
88
|
+
/**
|
|
89
|
+
* The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.
|
|
90
|
+
* The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
|
|
91
|
+
*/
|
|
92
|
+
other: import("@metamask/superstruct").Struct<Record<string, string>, null>;
|
|
93
|
+
}>;
|
|
75
94
|
}>;
|
|
76
95
|
export declare const PriceImpactThresholdSchema: import("@metamask/superstruct").Struct<{
|
|
77
96
|
normal: number;
|
|
@@ -95,6 +114,10 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
95
114
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
96
115
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
97
116
|
noFeeAssets?: string[] | undefined;
|
|
117
|
+
defaultPairs?: {
|
|
118
|
+
standard: Record<string, string>;
|
|
119
|
+
other: Record<string, string>;
|
|
120
|
+
} | undefined;
|
|
98
121
|
}>;
|
|
99
122
|
refreshRate: number;
|
|
100
123
|
minimumVersion: string;
|
|
@@ -108,6 +131,10 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
108
131
|
bridgeIds?: string[] | undefined;
|
|
109
132
|
noFee?: boolean | undefined;
|
|
110
133
|
} | undefined> | undefined;
|
|
134
|
+
bip44DefaultPairs?: Record<string, {
|
|
135
|
+
standard: Record<string, string>;
|
|
136
|
+
other: Record<string, string>;
|
|
137
|
+
} | undefined> | undefined;
|
|
111
138
|
}, {
|
|
112
139
|
priceImpactThreshold: import("@metamask/superstruct").Struct<{
|
|
113
140
|
normal: number;
|
|
@@ -135,7 +162,19 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
135
162
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
136
163
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
137
164
|
noFeeAssets?: string[] | undefined;
|
|
165
|
+
defaultPairs?: {
|
|
166
|
+
standard: Record<string, string>;
|
|
167
|
+
other: Record<string, string>;
|
|
168
|
+
} | undefined;
|
|
138
169
|
}>, null>;
|
|
170
|
+
/**
|
|
171
|
+
* The bip44 default pairs for the chains
|
|
172
|
+
* Key is the CAIP chainId namespace
|
|
173
|
+
*/
|
|
174
|
+
bip44DefaultPairs: import("@metamask/superstruct").Struct<Record<string, {
|
|
175
|
+
standard: Record<string, string>;
|
|
176
|
+
other: Record<string, string>;
|
|
177
|
+
} | undefined> | undefined, null>;
|
|
139
178
|
}>;
|
|
140
179
|
export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
141
180
|
support: boolean;
|
|
@@ -149,6 +188,10 @@ export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
|
149
188
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
150
189
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
151
190
|
noFeeAssets?: string[] | undefined;
|
|
191
|
+
defaultPairs?: {
|
|
192
|
+
standard: Record<string, string>;
|
|
193
|
+
other: Record<string, string>;
|
|
194
|
+
} | undefined;
|
|
152
195
|
}>;
|
|
153
196
|
refreshRate: number;
|
|
154
197
|
minimumVersion: string;
|
|
@@ -162,6 +205,10 @@ export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
|
162
205
|
bridgeIds?: string[] | undefined;
|
|
163
206
|
noFee?: boolean | undefined;
|
|
164
207
|
} | undefined> | undefined;
|
|
208
|
+
bip44DefaultPairs?: Record<string, {
|
|
209
|
+
standard: Record<string, string>;
|
|
210
|
+
other: Record<string, string>;
|
|
211
|
+
} | undefined> | undefined;
|
|
165
212
|
};
|
|
166
213
|
export declare const validateSwapsTokenObject: (data: unknown) => data is {
|
|
167
214
|
symbol: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.cts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAqBA,oBAAY,OAAO;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,UAAU;CACjB;AAED,oBAAY,SAAS;IACnB,KAAK,UAAU;CAChB;AAED,oBAAY,WAAW;IACrB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAUD,eAAO,MAAM,YAAY,MAAO,MAAM,YAAuB,CAAC;AAK9D,eAAO,MAAM,iBAAiB;;;;;;;;;;IAC5B;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;IAGH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;
|
|
1
|
+
{"version":3,"file":"validators.d.cts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAqBA,oBAAY,OAAO;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,UAAU;CACjB;AAED,oBAAY,SAAS;IACnB,KAAK,UAAU;CAChB;AAED,oBAAY,WAAW;IACrB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AA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;;;;;;;;;;;;;;;;;;;;;;CAId,CAAC;AAEF,eAAO,MAAM,4BAA4B,SACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAId,CAAC"}
|
|
@@ -62,6 +62,10 @@ export declare const ChainConfigurationSchema: import("@metamask/superstruct").S
|
|
|
62
62
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
63
63
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
64
64
|
noFeeAssets?: string[] | undefined;
|
|
65
|
+
defaultPairs?: {
|
|
66
|
+
standard: Record<string, string>;
|
|
67
|
+
other: Record<string, string>;
|
|
68
|
+
} | undefined;
|
|
65
69
|
}, {
|
|
66
70
|
isActiveSrc: import("@metamask/superstruct").Struct<boolean, null>;
|
|
67
71
|
isActiveDest: import("@metamask/superstruct").Struct<boolean, null>;
|
|
@@ -72,6 +76,21 @@ export declare const ChainConfigurationSchema: import("@metamask/superstruct").S
|
|
|
72
76
|
isSingleSwapBridgeButtonEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
73
77
|
isGaslessSwapEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
74
78
|
noFeeAssets: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
|
|
79
|
+
defaultPairs: import("@metamask/superstruct").Struct<{
|
|
80
|
+
standard: Record<string, string>;
|
|
81
|
+
other: Record<string, string>;
|
|
82
|
+
} | undefined, {
|
|
83
|
+
/**
|
|
84
|
+
* The standard default pairs. Use this if the pair is only set once.
|
|
85
|
+
* The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
|
|
86
|
+
*/
|
|
87
|
+
standard: import("@metamask/superstruct").Struct<Record<string, string>, null>;
|
|
88
|
+
/**
|
|
89
|
+
* The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.
|
|
90
|
+
* The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
|
|
91
|
+
*/
|
|
92
|
+
other: import("@metamask/superstruct").Struct<Record<string, string>, null>;
|
|
93
|
+
}>;
|
|
75
94
|
}>;
|
|
76
95
|
export declare const PriceImpactThresholdSchema: import("@metamask/superstruct").Struct<{
|
|
77
96
|
normal: number;
|
|
@@ -95,6 +114,10 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
95
114
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
96
115
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
97
116
|
noFeeAssets?: string[] | undefined;
|
|
117
|
+
defaultPairs?: {
|
|
118
|
+
standard: Record<string, string>;
|
|
119
|
+
other: Record<string, string>;
|
|
120
|
+
} | undefined;
|
|
98
121
|
}>;
|
|
99
122
|
refreshRate: number;
|
|
100
123
|
minimumVersion: string;
|
|
@@ -108,6 +131,10 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
108
131
|
bridgeIds?: string[] | undefined;
|
|
109
132
|
noFee?: boolean | undefined;
|
|
110
133
|
} | undefined> | undefined;
|
|
134
|
+
bip44DefaultPairs?: Record<string, {
|
|
135
|
+
standard: Record<string, string>;
|
|
136
|
+
other: Record<string, string>;
|
|
137
|
+
} | undefined> | undefined;
|
|
111
138
|
}, {
|
|
112
139
|
priceImpactThreshold: import("@metamask/superstruct").Struct<{
|
|
113
140
|
normal: number;
|
|
@@ -135,7 +162,19 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
135
162
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
136
163
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
137
164
|
noFeeAssets?: string[] | undefined;
|
|
165
|
+
defaultPairs?: {
|
|
166
|
+
standard: Record<string, string>;
|
|
167
|
+
other: Record<string, string>;
|
|
168
|
+
} | undefined;
|
|
138
169
|
}>, null>;
|
|
170
|
+
/**
|
|
171
|
+
* The bip44 default pairs for the chains
|
|
172
|
+
* Key is the CAIP chainId namespace
|
|
173
|
+
*/
|
|
174
|
+
bip44DefaultPairs: import("@metamask/superstruct").Struct<Record<string, {
|
|
175
|
+
standard: Record<string, string>;
|
|
176
|
+
other: Record<string, string>;
|
|
177
|
+
} | undefined> | undefined, null>;
|
|
139
178
|
}>;
|
|
140
179
|
export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
141
180
|
support: boolean;
|
|
@@ -149,6 +188,10 @@ export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
|
149
188
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
150
189
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
151
190
|
noFeeAssets?: string[] | undefined;
|
|
191
|
+
defaultPairs?: {
|
|
192
|
+
standard: Record<string, string>;
|
|
193
|
+
other: Record<string, string>;
|
|
194
|
+
} | undefined;
|
|
152
195
|
}>;
|
|
153
196
|
refreshRate: number;
|
|
154
197
|
minimumVersion: string;
|
|
@@ -162,6 +205,10 @@ export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
|
162
205
|
bridgeIds?: string[] | undefined;
|
|
163
206
|
noFee?: boolean | undefined;
|
|
164
207
|
} | undefined> | undefined;
|
|
208
|
+
bip44DefaultPairs?: Record<string, {
|
|
209
|
+
standard: Record<string, string>;
|
|
210
|
+
other: Record<string, string>;
|
|
211
|
+
} | undefined> | undefined;
|
|
165
212
|
};
|
|
166
213
|
export declare const validateSwapsTokenObject: (data: unknown) => data is {
|
|
167
214
|
symbol: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.mts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAqBA,oBAAY,OAAO;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,UAAU;CACjB;AAED,oBAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA3BH;;mBAEG;;gBAEH;;mBAEG;;gBAEH;;mBAEG;;gBAEH;;mBAEG;;gBAEH;;mBAEG;;;gBAGH;;mBAEG;;gBAEH;;mBAEG;;;;;;;;;;;;;gBA3BH;;mBAEG;;gBAEH;;mBAEG;;gBAEH;;mBAEG;;gBAEH;;mBAEG;;gBAEH;;mBAEG;;;gBAGH;;mBAEG;;gBAEH;;mBAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoLH,CAAC;AAEH,eAAO,MAAM,qBAAqB,SAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAId,CAAC;AAEF,eAAO,MAAM,4BAA4B,SACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAId,CAAC"}
|
|
@@ -53,6 +53,18 @@ export const BridgeAssetSchema = type({
|
|
|
53
53
|
*/
|
|
54
54
|
iconUrl: optional(nullable(string())),
|
|
55
55
|
});
|
|
56
|
+
const DefaultPairSchema = type({
|
|
57
|
+
/**
|
|
58
|
+
* The standard default pairs. Use this if the pair is only set once.
|
|
59
|
+
* The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
|
|
60
|
+
*/
|
|
61
|
+
standard: record(string(), string()),
|
|
62
|
+
/**
|
|
63
|
+
* The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.
|
|
64
|
+
* The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
|
|
65
|
+
*/
|
|
66
|
+
other: record(string(), string()),
|
|
67
|
+
});
|
|
56
68
|
export const ChainConfigurationSchema = type({
|
|
57
69
|
isActiveSrc: boolean(),
|
|
58
70
|
isActiveDest: boolean(),
|
|
@@ -63,6 +75,7 @@ export const ChainConfigurationSchema = type({
|
|
|
63
75
|
isSingleSwapBridgeButtonEnabled: optional(boolean()),
|
|
64
76
|
isGaslessSwapEnabled: optional(boolean()),
|
|
65
77
|
noFeeAssets: optional(array(string())),
|
|
78
|
+
defaultPairs: optional(DefaultPairSchema),
|
|
66
79
|
});
|
|
67
80
|
export const PriceImpactThresholdSchema = type({
|
|
68
81
|
gasless: number(),
|
|
@@ -85,6 +98,11 @@ export const PlatformConfigSchema = type({
|
|
|
85
98
|
maxRefreshCount: number(),
|
|
86
99
|
support: boolean(),
|
|
87
100
|
chains: record(string(), ChainConfigurationSchema),
|
|
101
|
+
/**
|
|
102
|
+
* The bip44 default pairs for the chains
|
|
103
|
+
* Key is the CAIP chainId namespace
|
|
104
|
+
*/
|
|
105
|
+
bip44DefaultPairs: optional(record(string(), optional(DefaultPairSchema))),
|
|
88
106
|
});
|
|
89
107
|
export const validateFeatureFlagsResponse = (data) => {
|
|
90
108
|
return is(data, PlatformConfigSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mCAAmC;AAE/D,OAAO,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,IAAI,EACJ,EAAE,EACF,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACb,8BAA8B;AAC/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,wBAAwB;AAEzE,MAAM,CAAN,IAAY,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ourcesContent":["import { isValidHexAddress } from '@metamask/controller-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n boolean,\n number,\n type,\n is,\n record,\n array,\n nullable,\n optional,\n enums,\n define,\n union,\n assert,\n pattern,\n intersection,\n} from '@metamask/superstruct';\nimport { CaipAssetTypeStruct, isStrictHexString } from '@metamask/utils';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n TX_FEE = 'txFee',\n}\n\nexport enum FeatureId {\n PERPS = 'perps',\n}\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nconst HexAddressSchema = define<string>('HexAddress', (v: unknown) =>\n isValidHexAddress(v as string, { allowNonPrefixed: false }),\n);\n\nconst HexStringSchema = define<string>('HexString', (v: unknown) =>\n isStrictHexString(v as string),\n);\n\nexport const truthyString = (s: string) => Boolean(s?.length);\nconst TruthyDigitStringSchema = pattern(string(), /^\\d+$/u);\n\nconst ChainIdSchema = number();\n\nexport const BridgeAssetSchema = type({\n /**\n * The chainId of the token\n */\n chainId: ChainIdSchema,\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string(),\n /**\n * The assetId of the token\n */\n assetId: CaipAssetTypeStruct,\n /**\n * The symbol of token object\n */\n symbol: string(),\n /**\n * The name for the network\n */\n name: string(),\n decimals: number(),\n /**\n * URL for token icon\n */\n icon: optional(nullable(string())),\n /**\n * URL for token icon\n */\n iconUrl: optional(nullable(string())),\n});\n\nexport const ChainConfigurationSchema = type({\n isActiveSrc: boolean(),\n isActiveDest: boolean(),\n refreshRate: optional(number()),\n topAssets: optional(array(string())),\n stablecoins: optional(array(string())),\n isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\n noFeeAssets: optional(array(string())),\n});\n\nexport const PriceImpactThresholdSchema = type({\n gasless: number(),\n normal: number(),\n});\n\nconst GenericQuoteRequestSchema = type({\n aggIds: optional(array(string())),\n bridgeIds: optional(array(string())),\n noFee: optional(boolean()),\n});\n\nconst FeatureIdSchema = enums(Object.values(FeatureId));\n\n/**\n * This is the schema for the feature flags response from the RemoteFeatureFlagController\n */\nexport const PlatformConfigSchema = type({\n priceImpactThreshold: optional(PriceImpactThresholdSchema),\n quoteRequestOverrides: optional(\n record(FeatureIdSchema, optional(GenericQuoteRequestSchema)),\n ),\n minimumVersion: string(),\n refreshRate: number(),\n maxRefreshCount: number(),\n support: boolean(),\n chains: record(string(), ChainConfigurationSchema),\n});\n\nexport const validateFeatureFlagsResponse = (\n data: unknown,\n): data is Infer<typeof PlatformConfigSchema> => {\n return is(data, PlatformConfigSchema);\n};\n\nexport const validateSwapsTokenObject = (\n data: unknown,\n): data is Infer<typeof BridgeAssetSchema> => {\n return is(data, BridgeAssetSchema);\n};\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n});\n\nexport const ProtocolSchema = type({\n name: string(),\n displayName: optional(string()),\n icon: optional(string()),\n});\n\nexport const StepSchema = type({\n action: enums(Object.values(ActionTypes)),\n srcChainId: ChainIdSchema,\n destChainId: optional(ChainIdSchema),\n srcAsset: BridgeAssetSchema,\n destAsset: BridgeAssetSchema,\n srcAmount: string(),\n destAmount: string(),\n protocol: ProtocolSchema,\n});\n\nconst RefuelDataSchema = StepSchema;\n\nexport const QuoteSchema = type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: string(),\n feeData: type({\n [FeeType.METABRIDGE]: FeeDataSchema,\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([\n FeeDataSchema,\n type({\n maxFeePerGas: string(),\n maxPriorityFeePerGas: string(),\n }),\n ]),\n ),\n }),\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n bridgeId: string(),\n bridges: array(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n});\n\nexport const TxDataSchema = type({\n chainId: number(),\n to: HexAddressSchema,\n from: HexAddressSchema,\n value: HexStringSchema,\n data: HexStringSchema,\n gasLimit: nullable(number()),\n effectiveGas: optional(number()),\n});\n\nexport const BitcoinTradeDataSchema = type({\n unsignedPsbtBase64: string(),\n inputsToSign: nullable(array(type({}))),\n});\n\nexport const QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: union([TxDataSchema, BitcoinTradeDataSchema, string()]),\n});\n\nexport const BitcoinQuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: BitcoinTradeDataSchema,\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n\nexport const validateBitcoinQuoteResponse = (\n data: unknown,\n): data is Infer<typeof BitcoinQuoteResponseSchema> => {\n assert(data, BitcoinQuoteResponseSchema);\n return true;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mCAAmC;AAE/D,OAAO,EACL,MAAM,EACN,OAAO,EACP,MAAM,EAC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K,EAAE,KAAK,CAAC,CAAC,YAAY,EAAE,sBAAsB,EAAE,MAAM,EAAE,CAAC,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;IAC7C,KAAK,EAAE,WAAW;IAClB,gCAAgC,EAAE,MAAM,EAAE;IAC1C,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC;IAChC,KAAK,EAAE,sBAAsB;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,IAAa,EAC8B,EAAE;IAC7C,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,IAAa,EACqC,EAAE;IACpD,MAAM,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import { isValidHexAddress } from '@metamask/controller-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n boolean,\n number,\n type,\n is,\n record,\n array,\n nullable,\n optional,\n enums,\n define,\n union,\n assert,\n pattern,\n intersection,\n} from '@metamask/superstruct';\nimport { CaipAssetTypeStruct, isStrictHexString } from '@metamask/utils';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n TX_FEE = 'txFee',\n}\n\nexport enum FeatureId {\n PERPS = 'perps',\n}\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nconst HexAddressSchema = define<string>('HexAddress', (v: unknown) =>\n isValidHexAddress(v as string, { allowNonPrefixed: false }),\n);\n\nconst HexStringSchema = define<string>('HexString', (v: unknown) =>\n isStrictHexString(v as string),\n);\n\nexport const truthyString = (s: string) => Boolean(s?.length);\nconst TruthyDigitStringSchema = pattern(string(), /^\\d+$/u);\n\nconst ChainIdSchema = number();\n\nexport const BridgeAssetSchema = type({\n /**\n * The chainId of the token\n */\n chainId: ChainIdSchema,\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string(),\n /**\n * The assetId of the token\n */\n assetId: CaipAssetTypeStruct,\n /**\n * The symbol of token object\n */\n symbol: string(),\n /**\n * The name for the network\n */\n name: string(),\n decimals: number(),\n /**\n * URL for token icon\n */\n icon: optional(nullable(string())),\n /**\n * URL for token icon\n */\n iconUrl: optional(nullable(string())),\n});\n\nconst DefaultPairSchema = type({\n /**\n * The standard default pairs. Use this if the pair is only set once.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n standard: record(string(), string()),\n /**\n * The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n other: record(string(), string()),\n});\n\nexport const ChainConfigurationSchema = type({\n isActiveSrc: boolean(),\n isActiveDest: boolean(),\n refreshRate: optional(number()),\n topAssets: optional(array(string())),\n stablecoins: optional(array(string())),\n isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\n noFeeAssets: optional(array(string())),\n defaultPairs: optional(DefaultPairSchema),\n});\n\nexport const PriceImpactThresholdSchema = type({\n gasless: number(),\n normal: number(),\n});\n\nconst GenericQuoteRequestSchema = type({\n aggIds: optional(array(string())),\n bridgeIds: optional(array(string())),\n noFee: optional(boolean()),\n});\n\nconst FeatureIdSchema = enums(Object.values(FeatureId));\n\n/**\n * This is the schema for the feature flags response from the RemoteFeatureFlagController\n */\nexport const PlatformConfigSchema = type({\n priceImpactThreshold: optional(PriceImpactThresholdSchema),\n quoteRequestOverrides: optional(\n record(FeatureIdSchema, optional(GenericQuoteRequestSchema)),\n ),\n minimumVersion: string(),\n refreshRate: number(),\n maxRefreshCount: number(),\n support: boolean(),\n chains: record(string(), ChainConfigurationSchema),\n /**\n * The bip44 default pairs for the chains\n * Key is the CAIP chainId namespace\n */\n bip44DefaultPairs: optional(record(string(), optional(DefaultPairSchema))),\n});\n\nexport const validateFeatureFlagsResponse = (\n data: unknown,\n): data is Infer<typeof PlatformConfigSchema> => {\n return is(data, PlatformConfigSchema);\n};\n\nexport const validateSwapsTokenObject = (\n data: unknown,\n): data is Infer<typeof BridgeAssetSchema> => {\n return is(data, BridgeAssetSchema);\n};\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n});\n\nexport const ProtocolSchema = type({\n name: string(),\n displayName: optional(string()),\n icon: optional(string()),\n});\n\nexport const StepSchema = type({\n action: enums(Object.values(ActionTypes)),\n srcChainId: ChainIdSchema,\n destChainId: optional(ChainIdSchema),\n srcAsset: BridgeAssetSchema,\n destAsset: BridgeAssetSchema,\n srcAmount: string(),\n destAmount: string(),\n protocol: ProtocolSchema,\n});\n\nconst RefuelDataSchema = StepSchema;\n\nexport const QuoteSchema = type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: string(),\n feeData: type({\n [FeeType.METABRIDGE]: FeeDataSchema,\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([\n FeeDataSchema,\n type({\n maxFeePerGas: string(),\n maxPriorityFeePerGas: string(),\n }),\n ]),\n ),\n }),\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n bridgeId: string(),\n bridges: array(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n});\n\nexport const TxDataSchema = type({\n chainId: number(),\n to: HexAddressSchema,\n from: HexAddressSchema,\n value: HexStringSchema,\n data: HexStringSchema,\n gasLimit: nullable(number()),\n effectiveGas: optional(number()),\n});\n\nexport const BitcoinTradeDataSchema = type({\n unsignedPsbtBase64: string(),\n inputsToSign: nullable(array(type({}))),\n});\n\nexport const QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: union([TxDataSchema, BitcoinTradeDataSchema, string()]),\n});\n\nexport const BitcoinQuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: BitcoinTradeDataSchema,\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n\nexport const validateBitcoinQuoteResponse = (\n data: unknown,\n): data is Infer<typeof BitcoinQuoteResponseSchema> => {\n assert(data, BitcoinQuoteResponseSchema);\n return true;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/bridge-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "47.1.0",
|
|
4
4
|
"description": "Manages bridge-related quote fetching functionality for MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -59,21 +59,21 @@
|
|
|
59
59
|
"@metamask/metamask-eth-abis": "^3.1.1",
|
|
60
60
|
"@metamask/multichain-network-controller": "^1.0.0",
|
|
61
61
|
"@metamask/polling-controller": "^14.0.0",
|
|
62
|
-
"@metamask/utils": "^11.8.
|
|
62
|
+
"@metamask/utils": "^11.8.1",
|
|
63
63
|
"bignumber.js": "^9.1.2",
|
|
64
64
|
"reselect": "^5.1.1",
|
|
65
65
|
"uuid": "^8.3.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@metamask/accounts-controller": "^33.1.0",
|
|
69
|
-
"@metamask/assets-controllers": "^77.0.
|
|
69
|
+
"@metamask/assets-controllers": "^77.0.1",
|
|
70
70
|
"@metamask/auto-changelog": "^3.4.4",
|
|
71
71
|
"@metamask/eth-json-rpc-provider": "^5.0.0",
|
|
72
72
|
"@metamask/network-controller": "^24.2.0",
|
|
73
73
|
"@metamask/remote-feature-flag-controller": "^1.7.0",
|
|
74
74
|
"@metamask/snaps-controllers": "^14.0.1",
|
|
75
75
|
"@metamask/superstruct": "^3.1.0",
|
|
76
|
-
"@metamask/transaction-controller": "^60.
|
|
76
|
+
"@metamask/transaction-controller": "^60.5.0",
|
|
77
77
|
"@types/jest": "^27.4.1",
|
|
78
78
|
"deepmerge": "^4.2.2",
|
|
79
79
|
"jest": "^27.5.1",
|