@metamask/bridge-controller 43.0.0 → 43.2.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 +25 -1
- package/dist/bridge-controller.cjs +18 -0
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +18 -0
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/constants/bridge.cjs +1 -2
- package/dist/constants/bridge.cjs.map +1 -1
- package/dist/constants/bridge.d.cts +0 -1
- package/dist/constants/bridge.d.cts.map +1 -1
- package/dist/constants/bridge.d.mts +0 -1
- package/dist/constants/bridge.d.mts.map +1 -1
- package/dist/constants/bridge.mjs +0 -1
- package/dist/constants/bridge.mjs.map +1 -1
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +20 -1
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +100 -0
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +100 -0
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs +19 -0
- package/dist/selectors.mjs.map +1 -1
- package/dist/utils/metrics/properties.cjs +6 -0
- package/dist/utils/metrics/properties.cjs.map +1 -1
- package/dist/utils/metrics/properties.d.cts +6 -0
- package/dist/utils/metrics/properties.d.cts.map +1 -1
- package/dist/utils/metrics/properties.d.mts +6 -0
- package/dist/utils/metrics/properties.d.mts.map +1 -1
- package/dist/utils/metrics/properties.mjs +6 -0
- package/dist/utils/metrics/properties.mjs.map +1 -1
- package/dist/utils/slippage.cjs +49 -0
- package/dist/utils/slippage.cjs.map +1 -0
- package/dist/utils/slippage.d.cts +23 -0
- package/dist/utils/slippage.d.cts.map +1 -0
- package/dist/utils/slippage.d.mts +23 -0
- package/dist/utils/slippage.d.mts.map +1 -0
- package/dist/utils/slippage.mjs +45 -0
- package/dist/utils/slippage.mjs.map +1 -0
- package/dist/utils/validators.cjs +2 -0
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +10 -0
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +10 -0
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +2 -0
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -16,5 +16,11 @@ export declare const getRequestParams: ({ destChainId, srcTokenAddress, destToke
|
|
|
16
16
|
token_address_destination: `${string}:${string}/${string}:${string}` | null;
|
|
17
17
|
};
|
|
18
18
|
export declare const isHardwareWallet: (selectedAccount?: AccountsControllerState['internalAccounts']['accounts'][string]) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @param slippage - The slippage percentage
|
|
21
|
+
* @returns Whether the default slippage was overridden by the user
|
|
22
|
+
*
|
|
23
|
+
* @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.
|
|
24
|
+
*/
|
|
19
25
|
export declare const isCustomSlippage: (slippage: GenericQuoteRequest['slippage']) => boolean;
|
|
20
26
|
//# sourceMappingURL=properties.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.d.mts","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB;AAEnD,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,oBAAgB;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,mEAA+D;AAEtG,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,EAAE,wBAAoB;AAChF,OAAO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AAqB,EAAE,aAAa,EAAE,MAAM,EAAE,wBAAoB;AAChF,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,wBAAoB;AAO1E,eAAO,MAAM,yBAAyB,EAAE,OAAO,CAC7C,MAAM,CAAC,MAAM,YAAY,EAAE,SAAS,CAAC,CAOtC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAC/C,MAAM,CACJ,MAAM,OAAO,yBAAyB,EACtC,CACE,WAAW,EAAE,OAAO,CAAC,mBAAmB,CAAC,KACtC,WAAW,CAAC,MAAM,WAAW,CAAC,GAAG,SAAS,CAChD,CAeF,CAAC;AAEF,eAAO,MAAM,WAAW,gBACT,mBAAmB,CAAC,YAAY,CAAC,gBAChC,mBAAmB,CAAC,aAAa,CAAC,oBAMjD,CAAC;AAEF,eAAO,MAAM,oBAAoB,iBACjB,QAAQ,mBAAmB,CAAC,oBAG3C,CAAC;AAEF,eAAO,MAAM,mBAAmB,2BAG7B,cAAc,MAAM,GAAG,MAAM,CAAC,CAAC,OAAO,CAAC,KAAG,GAAG,MAAM,IAAI,MAAM,EACnC,CAAC;AAE9B,eAAO,MAAM,gBAAgB,wDAKxB,qBAAqB,CAAC,cAAc,CAAC,kBACxB,WAAW;;;;;CAiB5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,qBACT,uBAAuB,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,YAGlF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAc,mBAAmB,CAAC,UAAU,CAAC,YAEzE,CAAC"}
|
|
@@ -47,6 +47,12 @@ export const getRequestParams = ({ destChainId, srcTokenAddress, destTokenAddres
|
|
|
47
47
|
export const isHardwareWallet = (selectedAccount) => {
|
|
48
48
|
return selectedAccount?.metadata?.keyring.type?.includes('Hardware') ?? false;
|
|
49
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* @param slippage - The slippage percentage
|
|
52
|
+
* @returns Whether the default slippage was overridden by the user
|
|
53
|
+
*
|
|
54
|
+
* @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.
|
|
55
|
+
*/
|
|
50
56
|
export const isCustomSlippage = (slippage) => {
|
|
51
57
|
return slippage !== DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;
|
|
52
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAG9C,OAAO,EAAE,+BAA+B,EAAE,mCAA+B;AAGzE,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,sBAAkB;AACnE,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACpB,+BAA2B;AAE5B,MAAM,CAAC,MAAM,yBAAyB,GAElC;IACF,eAAe,EAAE,cAAc;IAC/B,gBAAgB,EAAE,mBAAmB;IACrC,UAAU,EAAE,cAAc;IAC1B,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAOpC;IACF,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU;QACR,CAAC,CAAC,sBAAsB,CAAC,eAAe,IAAI,EAAE,EAAE,UAAU,CAAC;QAC3D,CAAC,CAAC,SAAS;IACf,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,EAAE,WAAW,EAAE,EAAE,EAAE,CACtD,WAAW;QACT,CAAC,CAAC,sBAAsB,CAAC,gBAAgB,IAAI,EAAE,EAAE,WAAW,CAAC;QAC7D,CAAC,CAAC,SAAS;IACf,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAC7B,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;IAC1D,W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AAO;gBACjD,IAAI,CAAC;YACP,CAAC,CAAC,CAAC,wBAAwB,CAAC,cAAc,CAAC,EAAE,OAAO,IAAI,IAAI,CAAC;QAC/D,yBAAyB,EAAE,gBAAgB;YACzC,CAAC,CAAC,CAAC,sBAAsB,CACrB,gBAAgB,EAChB,WAAW,IAAI,cAAc,CAC9B,IAAI,IAAI,CAAC;YACZ,CAAC,CAAC,IAAI;KACT,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,eAAiF,EACjF,EAAE;IACF,OAAO,eAAe,EAAE,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;AAChF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAyC,EAAE,EAAE;IAC5E,OAAO,QAAQ,KAAK,+BAA+B,CAAC,YAAY,CAAC,QAAQ,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["import type { CaipChainId } from '@metamask/utils';\n\nimport { MetricsSwapType } from './constants';\nimport type { InputKeys, InputValues } from './types';\nimport type { AccountsControllerState } from '../../../../accounts-controller/src/AccountsController';\nimport { DEFAULT_BRIDGE_CONTROLLER_STATE } from '../../constants/bridge';\nimport type { BridgeControllerState, QuoteResponse, TxData } from '../../types';\nimport { type GenericQuoteRequest, type QuoteRequest } from '../../types';\nimport { getNativeAssetForChainId, isCrossChain } from '../bridge';\nimport {\n formatAddressToAssetId,\n formatChainIdToCaip,\n} from '../caip-formatters';\n\nexport const toInputChangedPropertyKey: Partial<\n Record<keyof QuoteRequest, InputKeys>\n> = {\n srcTokenAddress: 'token_source',\n destTokenAddress: 'token_destination',\n srcChainId: 'chain_source',\n destChainId: 'chain_destination',\n slippage: 'slippage',\n};\n\nexport const toInputChangedPropertyValue: Partial<\n Record<\n keyof typeof toInputChangedPropertyKey,\n (\n input_value: Partial<GenericQuoteRequest>,\n ) => InputValues[keyof InputValues] | undefined\n >\n> = {\n srcTokenAddress: ({ srcTokenAddress, srcChainId }) =>\n srcChainId\n ? formatAddressToAssetId(srcTokenAddress ?? '', srcChainId)\n : undefined,\n destTokenAddress: ({ destTokenAddress, destChainId }) =>\n destChainId\n ? formatAddressToAssetId(destTokenAddress ?? '', destChainId)\n : undefined,\n srcChainId: ({ srcChainId }) =>\n srcChainId ? formatChainIdToCaip(srcChainId) : undefined,\n destChainId: ({ destChainId }) =>\n destChainId ? formatChainIdToCaip(destChainId) : undefined,\n slippage: ({ slippage }) => (slippage ? Number(slippage) : slippage),\n};\n\nexport const getSwapType = (\n srcChainId?: GenericQuoteRequest['srcChainId'],\n destChainId?: GenericQuoteRequest['destChainId'],\n) => {\n if (srcChainId && !isCrossChain(srcChainId, destChainId ?? srcChainId)) {\n return MetricsSwapType.SINGLE;\n }\n return MetricsSwapType.CROSSCHAIN;\n};\n\nexport const getSwapTypeFromQuote = (\n quoteRequest: Partial<GenericQuoteRequest>,\n) => {\n return getSwapType(quoteRequest.srcChainId, quoteRequest.destChainId);\n};\n\nexport const formatProviderLabel = ({\n bridgeId,\n bridges,\n}: QuoteResponse<TxData | string>['quote']): `${string}_${string}` =>\n `${bridgeId}_${bridges[0]}`;\n\nexport const getRequestParams = (\n {\n destChainId,\n srcTokenAddress,\n destTokenAddress,\n }: BridgeControllerState['quoteRequest'],\n srcChainIdCaip: CaipChainId,\n) => {\n return {\n chain_id_source: srcChainIdCaip,\n chain_id_destination: destChainId ? formatChainIdToCaip(destChainId) : null,\n token_address_source: srcTokenAddress\n ? (formatAddressToAssetId(srcTokenAddress, srcChainIdCaip) ??\n getNativeAssetForChainId(srcChainIdCaip)?.assetId ??\n null)\n : (getNativeAssetForChainId(srcChainIdCaip)?.assetId ?? null),\n token_address_destination: destTokenAddress\n ? (formatAddressToAssetId(\n destTokenAddress,\n destChainId ?? srcChainIdCaip,\n ) ?? null)\n : null,\n };\n};\n\nexport const isHardwareWallet = (\n selectedAccount?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n return selectedAccount?.metadata?.keyring.type?.includes('Hardware') ?? false;\n};\n\nexport const isCustomSlippage = (slippage: GenericQuoteRequest['slippage']) => {\n return slippage !== DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"properties.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAG9C,OAAO,EAAE,+BAA+B,EAAE,mCAA+B;AAGzE,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,sBAAkB;AACnE,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACpB,+BAA2B;AAE5B,MAAM,CAAC,MAAM,yBAAyB,GAElC;IACF,eAAe,EAAE,cAAc;IAC/B,gBAAgB,EAAE,mBAAmB;IACrC,UAAU,EAAE,cAAc;IAC1B,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAOpC;IACF,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU;QACR,CAAC,CAAC,sBAAsB,CAAC,eAAe,IAAI,EAAE,EAAE,UAAU,CAAC;QAC3D,CAAC,CAAC,SAAS;IACf,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,EAAE,WAAW,EAAE,EAAE,EAAE,CACtD,WAAW;QACT,CAAC,CAAC,sBAAsB,CAAC,gBAAgB,IAAI,EAAE,EAAE,WAAW,CAAC;QAC7D,CAAC,CAAC,SAAS;IACf,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAC7B,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;IAC1D,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAC/B,WAAW,CAAC,C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CAAC,EAAE,OAAO,IAAI,IAAI,CAAC;QAC/D,yBAAyB,EAAE,gBAAgB;YACzC,CAAC,CAAC,CAAC,sBAAsB,CACrB,gBAAgB,EAChB,WAAW,IAAI,cAAc,CAC9B,IAAI,IAAI,CAAC;YACZ,CAAC,CAAC,IAAI;KACT,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,eAAiF,EACjF,EAAE;IACF,OAAO,eAAe,EAAE,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;AAChF,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAyC,EAAE,EAAE;IAC5E,OAAO,QAAQ,KAAK,+BAA+B,CAAC,YAAY,CAAC,QAAQ,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["import type { CaipChainId } from '@metamask/utils';\n\nimport { MetricsSwapType } from './constants';\nimport type { InputKeys, InputValues } from './types';\nimport type { AccountsControllerState } from '../../../../accounts-controller/src/AccountsController';\nimport { DEFAULT_BRIDGE_CONTROLLER_STATE } from '../../constants/bridge';\nimport type { BridgeControllerState, QuoteResponse, TxData } from '../../types';\nimport { type GenericQuoteRequest, type QuoteRequest } from '../../types';\nimport { getNativeAssetForChainId, isCrossChain } from '../bridge';\nimport {\n formatAddressToAssetId,\n formatChainIdToCaip,\n} from '../caip-formatters';\n\nexport const toInputChangedPropertyKey: Partial<\n Record<keyof QuoteRequest, InputKeys>\n> = {\n srcTokenAddress: 'token_source',\n destTokenAddress: 'token_destination',\n srcChainId: 'chain_source',\n destChainId: 'chain_destination',\n slippage: 'slippage',\n};\n\nexport const toInputChangedPropertyValue: Partial<\n Record<\n keyof typeof toInputChangedPropertyKey,\n (\n input_value: Partial<GenericQuoteRequest>,\n ) => InputValues[keyof InputValues] | undefined\n >\n> = {\n srcTokenAddress: ({ srcTokenAddress, srcChainId }) =>\n srcChainId\n ? formatAddressToAssetId(srcTokenAddress ?? '', srcChainId)\n : undefined,\n destTokenAddress: ({ destTokenAddress, destChainId }) =>\n destChainId\n ? formatAddressToAssetId(destTokenAddress ?? '', destChainId)\n : undefined,\n srcChainId: ({ srcChainId }) =>\n srcChainId ? formatChainIdToCaip(srcChainId) : undefined,\n destChainId: ({ destChainId }) =>\n destChainId ? formatChainIdToCaip(destChainId) : undefined,\n slippage: ({ slippage }) => (slippage ? Number(slippage) : slippage),\n};\n\nexport const getSwapType = (\n srcChainId?: GenericQuoteRequest['srcChainId'],\n destChainId?: GenericQuoteRequest['destChainId'],\n) => {\n if (srcChainId && !isCrossChain(srcChainId, destChainId ?? srcChainId)) {\n return MetricsSwapType.SINGLE;\n }\n return MetricsSwapType.CROSSCHAIN;\n};\n\nexport const getSwapTypeFromQuote = (\n quoteRequest: Partial<GenericQuoteRequest>,\n) => {\n return getSwapType(quoteRequest.srcChainId, quoteRequest.destChainId);\n};\n\nexport const formatProviderLabel = ({\n bridgeId,\n bridges,\n}: QuoteResponse<TxData | string>['quote']): `${string}_${string}` =>\n `${bridgeId}_${bridges[0]}`;\n\nexport const getRequestParams = (\n {\n destChainId,\n srcTokenAddress,\n destTokenAddress,\n }: BridgeControllerState['quoteRequest'],\n srcChainIdCaip: CaipChainId,\n) => {\n return {\n chain_id_source: srcChainIdCaip,\n chain_id_destination: destChainId ? formatChainIdToCaip(destChainId) : null,\n token_address_source: srcTokenAddress\n ? (formatAddressToAssetId(srcTokenAddress, srcChainIdCaip) ??\n getNativeAssetForChainId(srcChainIdCaip)?.assetId ??\n null)\n : (getNativeAssetForChainId(srcChainIdCaip)?.assetId ?? null),\n token_address_destination: destTokenAddress\n ? (formatAddressToAssetId(\n destTokenAddress,\n destChainId ?? srcChainIdCaip,\n ) ?? null)\n : null,\n };\n};\n\nexport const isHardwareWallet = (\n selectedAccount?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n return selectedAccount?.metadata?.keyring.type?.includes('Hardware') ?? false;\n};\n\n/**\n * @param slippage - The slippage percentage\n * @returns Whether the default slippage was overridden by the user\n *\n * @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.\n */\nexport const isCustomSlippage = (slippage: GenericQuoteRequest['slippage']) => {\n return slippage !== DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;\n};\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultSlippagePercentage = exports.BRIDGE_DEFAULT_SLIPPAGE = void 0;
|
|
4
|
+
const bridge_1 = require("./bridge.cjs");
|
|
5
|
+
exports.BRIDGE_DEFAULT_SLIPPAGE = 0.5;
|
|
6
|
+
const SWAP_SOLANA_SLIPPAGE = undefined;
|
|
7
|
+
const SWAP_EVM_STABLECOIN_SLIPPAGE = 0.5;
|
|
8
|
+
const SWAP_EVM_DEFAULT_SLIPPAGE = 2;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the appropriate slippage based on the transaction context
|
|
11
|
+
*
|
|
12
|
+
* Rules:
|
|
13
|
+
* - Bridge (cross-chain): Always 0.5%
|
|
14
|
+
* - Swap on Solana: Always undefined (AUTO mode)
|
|
15
|
+
* - Swap on EVM stablecoin pairs (same chain only): 0.5%
|
|
16
|
+
* - Swap on EVM other pairs: 2%
|
|
17
|
+
*
|
|
18
|
+
* @param options - the options for the destination chain
|
|
19
|
+
* @param options.srcTokenAddress - the source token address
|
|
20
|
+
* @param options.destTokenAddress - the destination token address
|
|
21
|
+
* @param options.srcChainId - the source chain id
|
|
22
|
+
* @param options.destChainId - the destination chain id
|
|
23
|
+
* @param srcStablecoins - the list of stablecoins on the source chain
|
|
24
|
+
* @param destStablecoins - the list of stablecoins on the destination chain
|
|
25
|
+
|
|
26
|
+
* @returns the default slippage percentage for the chain and token pair
|
|
27
|
+
*/
|
|
28
|
+
const getDefaultSlippagePercentage = ({ srcTokenAddress, destTokenAddress, srcChainId, destChainId, }, srcStablecoins, destStablecoins) => {
|
|
29
|
+
if (!srcChainId || (0, bridge_1.isCrossChain)(srcChainId, destChainId)) {
|
|
30
|
+
return exports.BRIDGE_DEFAULT_SLIPPAGE;
|
|
31
|
+
}
|
|
32
|
+
if ((0, bridge_1.isSolanaChainId)(srcChainId)) {
|
|
33
|
+
return SWAP_SOLANA_SLIPPAGE;
|
|
34
|
+
}
|
|
35
|
+
if (srcTokenAddress &&
|
|
36
|
+
destTokenAddress &&
|
|
37
|
+
srcStablecoins
|
|
38
|
+
?.map((stablecoin) => stablecoin.toLowerCase())
|
|
39
|
+
.includes(srcTokenAddress.toLowerCase()) &&
|
|
40
|
+
// If destChainId is undefined, treat req as a swap and fallback to srcStablecoins
|
|
41
|
+
(destStablecoins ?? srcStablecoins)
|
|
42
|
+
?.map((stablecoin) => stablecoin.toLowerCase())
|
|
43
|
+
.includes(destTokenAddress.toLowerCase())) {
|
|
44
|
+
return SWAP_EVM_STABLECOIN_SLIPPAGE;
|
|
45
|
+
}
|
|
46
|
+
return SWAP_EVM_DEFAULT_SLIPPAGE;
|
|
47
|
+
};
|
|
48
|
+
exports.getDefaultSlippagePercentage = getDefaultSlippagePercentage;
|
|
49
|
+
//# sourceMappingURL=slippage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slippage.cjs","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AAG5C,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,4BAA4B,GAAG,CAC1C,EACE,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,GAMZ,EACD,cAAyB,EACzB,eAA0B,EAC1B,EAAE;IACF,IAAI,CAAC,UAAU,IAAI,IAAA,qBAAY,EAAC,UAAU,EAAE,WAAW,CAAC,EAAE;QACxD,OAAO,+BAAuB,CAAC;KAChC;IAED,IAAI,IAAA,wBAAe,EAAC,UAAU,CAAC,EAAE;QAC/B,OAAO,oBAAoB,CAAC;KAC7B;IAED,IACE,eAAe;QACf,gBAAgB;QAChB,cAAc;YACZ,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;aAC9C,QAAQ,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;QAC1C,kFAAkF;QAClF,CAAC,eAAe,IAAI,cAAc,CAAC;YACjC,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;aAC9C,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,EAC3C;QACA,OAAO,4BAA4B,CAAC;KACrC;IAED,OAAO,yBAAyB,CAAC;AACnC,CAAC,CAAC;AAtCW,QAAA,4BAA4B,gCAsCvC","sourcesContent":["import { isCrossChain, isSolanaChainId } from './bridge';\nimport type { GenericQuoteRequest } from '../types';\n\nexport const BRIDGE_DEFAULT_SLIPPAGE = 0.5;\nconst SWAP_SOLANA_SLIPPAGE = undefined;\nconst SWAP_EVM_STABLECOIN_SLIPPAGE = 0.5;\nconst SWAP_EVM_DEFAULT_SLIPPAGE = 2;\n\n/**\n * Calculates the appropriate slippage based on the transaction context\n *\n * Rules:\n * - Bridge (cross-chain): Always 0.5%\n * - Swap on Solana: Always undefined (AUTO mode)\n * - Swap on EVM stablecoin pairs (same chain only): 0.5%\n * - Swap on EVM other pairs: 2%\n *\n * @param options - the options for the destination chain\n * @param options.srcTokenAddress - the source token address\n * @param options.destTokenAddress - the destination token address\n * @param options.srcChainId - the source chain id\n * @param options.destChainId - the destination chain id\n * @param srcStablecoins - the list of stablecoins on the source chain\n * @param destStablecoins - the list of stablecoins on the destination chain\n \n * @returns the default slippage percentage for the chain and token pair\n */\nexport const getDefaultSlippagePercentage = (\n {\n srcTokenAddress,\n destTokenAddress,\n srcChainId,\n destChainId,\n }: Partial<\n Pick<\n GenericQuoteRequest,\n 'srcTokenAddress' | 'destTokenAddress' | 'srcChainId' | 'destChainId'\n >\n >,\n srcStablecoins?: string[],\n destStablecoins?: string[],\n) => {\n if (!srcChainId || isCrossChain(srcChainId, destChainId)) {\n return BRIDGE_DEFAULT_SLIPPAGE;\n }\n\n if (isSolanaChainId(srcChainId)) {\n return SWAP_SOLANA_SLIPPAGE;\n }\n\n if (\n srcTokenAddress &&\n destTokenAddress &&\n srcStablecoins\n ?.map((stablecoin) => stablecoin.toLowerCase())\n .includes(srcTokenAddress.toLowerCase()) &&\n // If destChainId is undefined, treat req as a swap and fallback to srcStablecoins\n (destStablecoins ?? srcStablecoins)\n ?.map((stablecoin) => stablecoin.toLowerCase())\n .includes(destTokenAddress.toLowerCase())\n ) {\n return SWAP_EVM_STABLECOIN_SLIPPAGE;\n }\n\n return SWAP_EVM_DEFAULT_SLIPPAGE;\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { GenericQuoteRequest } from "../types.cjs";
|
|
2
|
+
export declare const BRIDGE_DEFAULT_SLIPPAGE = 0.5;
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the appropriate slippage based on the transaction context
|
|
5
|
+
*
|
|
6
|
+
* Rules:
|
|
7
|
+
* - Bridge (cross-chain): Always 0.5%
|
|
8
|
+
* - Swap on Solana: Always undefined (AUTO mode)
|
|
9
|
+
* - Swap on EVM stablecoin pairs (same chain only): 0.5%
|
|
10
|
+
* - Swap on EVM other pairs: 2%
|
|
11
|
+
*
|
|
12
|
+
* @param options - the options for the destination chain
|
|
13
|
+
* @param options.srcTokenAddress - the source token address
|
|
14
|
+
* @param options.destTokenAddress - the destination token address
|
|
15
|
+
* @param options.srcChainId - the source chain id
|
|
16
|
+
* @param options.destChainId - the destination chain id
|
|
17
|
+
* @param srcStablecoins - the list of stablecoins on the source chain
|
|
18
|
+
* @param destStablecoins - the list of stablecoins on the destination chain
|
|
19
|
+
|
|
20
|
+
* @returns the default slippage percentage for the chain and token pair
|
|
21
|
+
*/
|
|
22
|
+
export declare const getDefaultSlippagePercentage: ({ srcTokenAddress, destTokenAddress, srcChainId, destChainId, }: Partial<Pick<GenericQuoteRequest, 'srcTokenAddress' | 'destTokenAddress' | 'srcChainId' | 'destChainId'>>, srcStablecoins?: string[], destStablecoins?: string[]) => 2 | 0.5 | undefined;
|
|
23
|
+
//# sourceMappingURL=slippage.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slippage.d.cts","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAEpD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAK3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,4BAA4B,oEAMpC,QACD,KACE,mBAAmB,EACnB,iBAAiB,GAAG,kBAAkB,GAAG,YAAY,GAAG,aAAa,CACtE,CACF,mBACgB,MAAM,EAAE,oBACP,MAAM,EAAE,wBAyB3B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { GenericQuoteRequest } from "../types.mjs";
|
|
2
|
+
export declare const BRIDGE_DEFAULT_SLIPPAGE = 0.5;
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the appropriate slippage based on the transaction context
|
|
5
|
+
*
|
|
6
|
+
* Rules:
|
|
7
|
+
* - Bridge (cross-chain): Always 0.5%
|
|
8
|
+
* - Swap on Solana: Always undefined (AUTO mode)
|
|
9
|
+
* - Swap on EVM stablecoin pairs (same chain only): 0.5%
|
|
10
|
+
* - Swap on EVM other pairs: 2%
|
|
11
|
+
*
|
|
12
|
+
* @param options - the options for the destination chain
|
|
13
|
+
* @param options.srcTokenAddress - the source token address
|
|
14
|
+
* @param options.destTokenAddress - the destination token address
|
|
15
|
+
* @param options.srcChainId - the source chain id
|
|
16
|
+
* @param options.destChainId - the destination chain id
|
|
17
|
+
* @param srcStablecoins - the list of stablecoins on the source chain
|
|
18
|
+
* @param destStablecoins - the list of stablecoins on the destination chain
|
|
19
|
+
|
|
20
|
+
* @returns the default slippage percentage for the chain and token pair
|
|
21
|
+
*/
|
|
22
|
+
export declare const getDefaultSlippagePercentage: ({ srcTokenAddress, destTokenAddress, srcChainId, destChainId, }: Partial<Pick<GenericQuoteRequest, 'srcTokenAddress' | 'destTokenAddress' | 'srcChainId' | 'destChainId'>>, srcStablecoins?: string[], destStablecoins?: string[]) => 2 | 0.5 | undefined;
|
|
23
|
+
//# sourceMappingURL=slippage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slippage.d.mts","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAEpD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAK3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,4BAA4B,oEAMpC,QACD,KACE,mBAAmB,EACnB,iBAAiB,GAAG,kBAAkB,GAAG,YAAY,GAAG,aAAa,CACtE,CACF,mBACgB,MAAM,EAAE,oBACP,MAAM,EAAE,wBAyB3B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isCrossChain, isSolanaChainId } from "./bridge.mjs";
|
|
2
|
+
export const BRIDGE_DEFAULT_SLIPPAGE = 0.5;
|
|
3
|
+
const SWAP_SOLANA_SLIPPAGE = undefined;
|
|
4
|
+
const SWAP_EVM_STABLECOIN_SLIPPAGE = 0.5;
|
|
5
|
+
const SWAP_EVM_DEFAULT_SLIPPAGE = 2;
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the appropriate slippage based on the transaction context
|
|
8
|
+
*
|
|
9
|
+
* Rules:
|
|
10
|
+
* - Bridge (cross-chain): Always 0.5%
|
|
11
|
+
* - Swap on Solana: Always undefined (AUTO mode)
|
|
12
|
+
* - Swap on EVM stablecoin pairs (same chain only): 0.5%
|
|
13
|
+
* - Swap on EVM other pairs: 2%
|
|
14
|
+
*
|
|
15
|
+
* @param options - the options for the destination chain
|
|
16
|
+
* @param options.srcTokenAddress - the source token address
|
|
17
|
+
* @param options.destTokenAddress - the destination token address
|
|
18
|
+
* @param options.srcChainId - the source chain id
|
|
19
|
+
* @param options.destChainId - the destination chain id
|
|
20
|
+
* @param srcStablecoins - the list of stablecoins on the source chain
|
|
21
|
+
* @param destStablecoins - the list of stablecoins on the destination chain
|
|
22
|
+
|
|
23
|
+
* @returns the default slippage percentage for the chain and token pair
|
|
24
|
+
*/
|
|
25
|
+
export const getDefaultSlippagePercentage = ({ srcTokenAddress, destTokenAddress, srcChainId, destChainId, }, srcStablecoins, destStablecoins) => {
|
|
26
|
+
if (!srcChainId || isCrossChain(srcChainId, destChainId)) {
|
|
27
|
+
return BRIDGE_DEFAULT_SLIPPAGE;
|
|
28
|
+
}
|
|
29
|
+
if (isSolanaChainId(srcChainId)) {
|
|
30
|
+
return SWAP_SOLANA_SLIPPAGE;
|
|
31
|
+
}
|
|
32
|
+
if (srcTokenAddress &&
|
|
33
|
+
destTokenAddress &&
|
|
34
|
+
srcStablecoins
|
|
35
|
+
?.map((stablecoin) => stablecoin.toLowerCase())
|
|
36
|
+
.includes(srcTokenAddress.toLowerCase()) &&
|
|
37
|
+
// If destChainId is undefined, treat req as a swap and fallback to srcStablecoins
|
|
38
|
+
(destStablecoins ?? srcStablecoins)
|
|
39
|
+
?.map((stablecoin) => stablecoin.toLowerCase())
|
|
40
|
+
.includes(destTokenAddress.toLowerCase())) {
|
|
41
|
+
return SWAP_EVM_STABLECOIN_SLIPPAGE;
|
|
42
|
+
}
|
|
43
|
+
return SWAP_EVM_DEFAULT_SLIPPAGE;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=slippage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slippage.mjs","sourceRoot":"","sources":["../../src/utils/slippage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,qBAAiB;AAGzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,EACE,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,WAAW,GAMZ,EACD,cAAyB,EACzB,eAA0B,EAC1B,EAAE;IACF,IAAI,CAAC,UAAU,IAAI,YAAY,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE;QACxD,OAAO,uBAAuB,CAAC;KAChC;IAED,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE;QAC/B,OAAO,oBAAoB,CAAC;KAC7B;IAED,IACE,eAAe;QACf,gBAAgB;QAChB,cAAc;YACZ,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;aAC9C,QAAQ,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;QAC1C,kFAAkF;QAClF,CAAC,eAAe,IAAI,cAAc,CAAC;YACjC,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;aAC9C,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,EAC3C;QACA,OAAO,4BAA4B,CAAC;KACrC;IAED,OAAO,yBAAyB,CAAC;AACnC,CAAC,CAAC","sourcesContent":["import { isCrossChain, isSolanaChainId } from './bridge';\nimport type { GenericQuoteRequest } from '../types';\n\nexport const BRIDGE_DEFAULT_SLIPPAGE = 0.5;\nconst SWAP_SOLANA_SLIPPAGE = undefined;\nconst SWAP_EVM_STABLECOIN_SLIPPAGE = 0.5;\nconst SWAP_EVM_DEFAULT_SLIPPAGE = 2;\n\n/**\n * Calculates the appropriate slippage based on the transaction context\n *\n * Rules:\n * - Bridge (cross-chain): Always 0.5%\n * - Swap on Solana: Always undefined (AUTO mode)\n * - Swap on EVM stablecoin pairs (same chain only): 0.5%\n * - Swap on EVM other pairs: 2%\n *\n * @param options - the options for the destination chain\n * @param options.srcTokenAddress - the source token address\n * @param options.destTokenAddress - the destination token address\n * @param options.srcChainId - the source chain id\n * @param options.destChainId - the destination chain id\n * @param srcStablecoins - the list of stablecoins on the source chain\n * @param destStablecoins - the list of stablecoins on the destination chain\n \n * @returns the default slippage percentage for the chain and token pair\n */\nexport const getDefaultSlippagePercentage = (\n {\n srcTokenAddress,\n destTokenAddress,\n srcChainId,\n destChainId,\n }: Partial<\n Pick<\n GenericQuoteRequest,\n 'srcTokenAddress' | 'destTokenAddress' | 'srcChainId' | 'destChainId'\n >\n >,\n srcStablecoins?: string[],\n destStablecoins?: string[],\n) => {\n if (!srcChainId || isCrossChain(srcChainId, destChainId)) {\n return BRIDGE_DEFAULT_SLIPPAGE;\n }\n\n if (isSolanaChainId(srcChainId)) {\n return SWAP_SOLANA_SLIPPAGE;\n }\n\n if (\n srcTokenAddress &&\n destTokenAddress &&\n srcStablecoins\n ?.map((stablecoin) => stablecoin.toLowerCase())\n .includes(srcTokenAddress.toLowerCase()) &&\n // If destChainId is undefined, treat req as a swap and fallback to srcStablecoins\n (destStablecoins ?? srcStablecoins)\n ?.map((stablecoin) => stablecoin.toLowerCase())\n .includes(destTokenAddress.toLowerCase())\n ) {\n return SWAP_EVM_STABLECOIN_SLIPPAGE;\n }\n\n return SWAP_EVM_DEFAULT_SLIPPAGE;\n};\n"]}
|
|
@@ -62,9 +62,11 @@ exports.ChainConfigurationSchema = (0, superstruct_1.type)({
|
|
|
62
62
|
isActiveDest: (0, superstruct_1.boolean)(),
|
|
63
63
|
refreshRate: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
64
64
|
topAssets: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
|
|
65
|
+
stablecoins: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
|
|
65
66
|
isUnifiedUIEnabled: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
66
67
|
isSingleSwapBridgeButtonEnabled: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
67
68
|
isGaslessSwapEnabled: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
69
|
+
noFeeAssets: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
|
|
68
70
|
});
|
|
69
71
|
exports.PriceImpactThresholdSchema = (0, superstruct_1.type)({
|
|
70
72
|
gasless: (0, superstruct_1.number)(),
|
|
@@ -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;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,KAA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AAA,YAAY,GAAG,IAAA,kBAAI,EAAC;IAC/B,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,EAAE,EAAE,gBAAgB;IACpB,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,eAAe;IACtB,IAAI,EAAE,eAAe;IACrB,QAAQ,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC5B,YAAY,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CACjC,CAAC,CAAC;AAEU,QAAA,mBAAmB,GAAG,IAAA,kBAAI,EAAC;IACtC,KAAK,EAAE,mBAAW;IAClB,gCAAgC,EAAE,IAAA,oBAAM,GAAE;IAC1C,QAAQ,EAAE,IAAA,sBAAQ,EAAC,oBAAY,CAAC;IAChC,KAAK,EAAE,IAAA,mBAAK,EAAC,CAAC,oBAAY,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC;CACvC,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","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 isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\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 QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: union([TxDataSchema, string()]),\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\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,WAAW,EAAE,CAAC,CAAU,EAAE,EAAE,CACjE,IAAA,yBAAiB,EAAC,CAAW,CAAC,CAC/B,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAAjD,QAAA,YAAY,gBAAqC;AAC9D,MAAM,uBAAuB,GAAG,IAAA,qBAAO,EAAC,IAAA,o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AI,EAAE,eAAe;IACrB,QAAQ,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC5B,YAAY,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CACjC,CAAC,CAAC;AAEU,QAAA,mBAAmB,GAAG,IAAA,kBAAI,EAAC;IACtC,KAAK,EAAE,mBAAW;IAClB,gCAAgC,EAAE,IAAA,oBAAM,GAAE;IAC1C,QAAQ,EAAE,IAAA,sBAAQ,EAAC,oBAAY,CAAC;IAChC,KAAK,EAAE,IAAA,mBAAK,EAAC,CAAC,oBAAY,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC;CACvC,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","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 QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: union([TxDataSchema, string()]),\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n"]}
|
|
@@ -57,17 +57,21 @@ export declare const ChainConfigurationSchema: import("@metamask/superstruct").S
|
|
|
57
57
|
isActiveDest: boolean;
|
|
58
58
|
refreshRate?: number | undefined;
|
|
59
59
|
topAssets?: string[] | undefined;
|
|
60
|
+
stablecoins?: string[] | undefined;
|
|
60
61
|
isUnifiedUIEnabled?: boolean | undefined;
|
|
61
62
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
62
63
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
64
|
+
noFeeAssets?: string[] | undefined;
|
|
63
65
|
}, {
|
|
64
66
|
isActiveSrc: import("@metamask/superstruct").Struct<boolean, null>;
|
|
65
67
|
isActiveDest: import("@metamask/superstruct").Struct<boolean, null>;
|
|
66
68
|
refreshRate: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
67
69
|
topAssets: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
|
|
70
|
+
stablecoins: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
|
|
68
71
|
isUnifiedUIEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
69
72
|
isSingleSwapBridgeButtonEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
70
73
|
isGaslessSwapEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
74
|
+
noFeeAssets: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
|
|
71
75
|
}>;
|
|
72
76
|
export declare const PriceImpactThresholdSchema: import("@metamask/superstruct").Struct<{
|
|
73
77
|
normal: number;
|
|
@@ -86,9 +90,11 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
86
90
|
isActiveDest: boolean;
|
|
87
91
|
refreshRate?: number | undefined;
|
|
88
92
|
topAssets?: string[] | undefined;
|
|
93
|
+
stablecoins?: string[] | undefined;
|
|
89
94
|
isUnifiedUIEnabled?: boolean | undefined;
|
|
90
95
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
91
96
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
97
|
+
noFeeAssets?: string[] | undefined;
|
|
92
98
|
}>;
|
|
93
99
|
refreshRate: number;
|
|
94
100
|
minimumVersion: string;
|
|
@@ -124,9 +130,11 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
124
130
|
isActiveDest: boolean;
|
|
125
131
|
refreshRate?: number | undefined;
|
|
126
132
|
topAssets?: string[] | undefined;
|
|
133
|
+
stablecoins?: string[] | undefined;
|
|
127
134
|
isUnifiedUIEnabled?: boolean | undefined;
|
|
128
135
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
129
136
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
137
|
+
noFeeAssets?: string[] | undefined;
|
|
130
138
|
}>, null>;
|
|
131
139
|
}>;
|
|
132
140
|
export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
@@ -136,9 +144,11 @@ export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
|
136
144
|
isActiveDest: boolean;
|
|
137
145
|
refreshRate?: number | undefined;
|
|
138
146
|
topAssets?: string[] | undefined;
|
|
147
|
+
stablecoins?: string[] | undefined;
|
|
139
148
|
isUnifiedUIEnabled?: boolean | undefined;
|
|
140
149
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
141
150
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
151
|
+
noFeeAssets?: string[] | undefined;
|
|
142
152
|
}>;
|
|
143
153
|
refreshRate: number;
|
|
144
154
|
minimumVersion: 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;AAEH,eAAO,MAAM,wBAAwB
|
|
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;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;EAUnC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;EAGrC,CAAC;AAUH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU/B,CAAC;AAEH,eAAO,MAAM,4BAA4B,SACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;CAGd,CAAC;AAE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qBAAqB,SAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAId,CAAC"}
|
|
@@ -57,17 +57,21 @@ export declare const ChainConfigurationSchema: import("@metamask/superstruct").S
|
|
|
57
57
|
isActiveDest: boolean;
|
|
58
58
|
refreshRate?: number | undefined;
|
|
59
59
|
topAssets?: string[] | undefined;
|
|
60
|
+
stablecoins?: string[] | undefined;
|
|
60
61
|
isUnifiedUIEnabled?: boolean | undefined;
|
|
61
62
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
62
63
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
64
|
+
noFeeAssets?: string[] | undefined;
|
|
63
65
|
}, {
|
|
64
66
|
isActiveSrc: import("@metamask/superstruct").Struct<boolean, null>;
|
|
65
67
|
isActiveDest: import("@metamask/superstruct").Struct<boolean, null>;
|
|
66
68
|
refreshRate: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
67
69
|
topAssets: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
|
|
70
|
+
stablecoins: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
|
|
68
71
|
isUnifiedUIEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
69
72
|
isSingleSwapBridgeButtonEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
70
73
|
isGaslessSwapEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
74
|
+
noFeeAssets: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
|
|
71
75
|
}>;
|
|
72
76
|
export declare const PriceImpactThresholdSchema: import("@metamask/superstruct").Struct<{
|
|
73
77
|
normal: number;
|
|
@@ -86,9 +90,11 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
86
90
|
isActiveDest: boolean;
|
|
87
91
|
refreshRate?: number | undefined;
|
|
88
92
|
topAssets?: string[] | undefined;
|
|
93
|
+
stablecoins?: string[] | undefined;
|
|
89
94
|
isUnifiedUIEnabled?: boolean | undefined;
|
|
90
95
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
91
96
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
97
|
+
noFeeAssets?: string[] | undefined;
|
|
92
98
|
}>;
|
|
93
99
|
refreshRate: number;
|
|
94
100
|
minimumVersion: string;
|
|
@@ -124,9 +130,11 @@ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struc
|
|
|
124
130
|
isActiveDest: boolean;
|
|
125
131
|
refreshRate?: number | undefined;
|
|
126
132
|
topAssets?: string[] | undefined;
|
|
133
|
+
stablecoins?: string[] | undefined;
|
|
127
134
|
isUnifiedUIEnabled?: boolean | undefined;
|
|
128
135
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
129
136
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
137
|
+
noFeeAssets?: string[] | undefined;
|
|
130
138
|
}>, null>;
|
|
131
139
|
}>;
|
|
132
140
|
export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
@@ -136,9 +144,11 @@ export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
|
|
|
136
144
|
isActiveDest: boolean;
|
|
137
145
|
refreshRate?: number | undefined;
|
|
138
146
|
topAssets?: string[] | undefined;
|
|
147
|
+
stablecoins?: string[] | undefined;
|
|
139
148
|
isUnifiedUIEnabled?: boolean | undefined;
|
|
140
149
|
isSingleSwapBridgeButtonEnabled?: boolean | undefined;
|
|
141
150
|
isGaslessSwapEnabled?: boolean | undefined;
|
|
151
|
+
noFeeAssets?: string[] | undefined;
|
|
142
152
|
}>;
|
|
143
153
|
refreshRate: number;
|
|
144
154
|
minimumVersion: 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,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;AAEH,eAAO,MAAM,wBAAwB
|
|
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,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;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;EAUnC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;EAGrC,CAAC;AAUH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqJH,CAAC;AAEH,eAAO,MAAM,qBAAqB,SAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAId,CAAC"}
|
|
@@ -58,9 +58,11 @@ export const ChainConfigurationSchema = type({
|
|
|
58
58
|
isActiveDest: boolean(),
|
|
59
59
|
refreshRate: optional(number()),
|
|
60
60
|
topAssets: optional(array(string())),
|
|
61
|
+
stablecoins: optional(array(string())),
|
|
61
62
|
isUnifiedUIEnabled: optional(boolean()),
|
|
62
63
|
isSingleSwapBridgeButtonEnabled: optional(boolean()),
|
|
63
64
|
isGaslessSwapEnabled: optional(boolean()),
|
|
65
|
+
noFeeAssets: optional(array(string())),
|
|
64
66
|
});
|
|
65
67
|
export const PriceImpactThresholdSchema = type({
|
|
66
68
|
gasless: number(),
|
|
@@ -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,OAIX;AAJD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,4BAAiB,CAAA;IACjB,2BAAgB,CAAA;AAClB,CAAC,EAJW,OAAO,KAAP,OAAO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,CAAC;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;IACtC,KAAK,EAAE,WAAW;IAClB,gCAAgC,EAAE,MAAM,EAAE;IAC1C,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;CACvC,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","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 isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\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 QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: union([TxDataSchema, string()]),\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB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EAAE,QAAQ,CACjB,IAAI,CAAC;QACH,kBAAkB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtC,gBAAgB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC/B,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;KACtC,CAAC,CACH;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,EAAE;IACjB,EAAE,EAAE,gBAAgB;IACpB,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,eAAe;IACtB,IAAI,EAAE,eAAe;IACrB,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC5B,YAAY,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;IACtC,KAAK,EAAE,WAAW;IAClB,gCAAgC,EAAE,MAAM,EAAE;IAC1C,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;CACvC,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","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 QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(TxDataSchema),\n trade: union([TxDataSchema, string()]),\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/bridge-controller",
|
|
3
|
-
"version": "43.
|
|
3
|
+
"version": "43.2.0",
|
|
4
4
|
"description": "Manages bridge-related quote fetching functionality for MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@ethersproject/constants": "^5.7.0",
|
|
53
53
|
"@ethersproject/contracts": "^5.7.0",
|
|
54
54
|
"@ethersproject/providers": "^5.7.0",
|
|
55
|
-
"@metamask/base-controller": "^8.
|
|
56
|
-
"@metamask/controller-utils": "^11.
|
|
55
|
+
"@metamask/base-controller": "^8.4.0",
|
|
56
|
+
"@metamask/controller-utils": "^11.14.0",
|
|
57
57
|
"@metamask/gas-fee-controller": "^24.0.0",
|
|
58
58
|
"@metamask/keyring-api": "^21.0.0",
|
|
59
59
|
"@metamask/metamask-eth-abis": "^3.1.1",
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@metamask/accounts-controller": "^33.1.0",
|
|
69
|
-
"@metamask/assets-controllers": "^75.
|
|
69
|
+
"@metamask/assets-controllers": "^75.2.0",
|
|
70
70
|
"@metamask/auto-changelog": "^3.4.4",
|
|
71
71
|
"@metamask/eth-json-rpc-provider": "^4.1.8",
|
|
72
72
|
"@metamask/network-controller": "^24.1.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.4.0",
|
|
77
77
|
"@types/jest": "^27.4.1",
|
|
78
78
|
"deepmerge": "^4.2.2",
|
|
79
79
|
"jest": "^27.5.1",
|