@metamask/assets-controllers 95.3.0 → 97.0.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 +46 -1
- package/dist/AccountTrackerController.d.cts +2 -2
- package/dist/AccountTrackerController.d.mts +2 -2
- package/dist/CurrencyRateController.d.cts +2 -2
- package/dist/CurrencyRateController.d.mts +2 -2
- package/dist/DeFiPositionsController/DeFiPositionsController.d.cts +2 -2
- package/dist/DeFiPositionsController/DeFiPositionsController.d.mts +2 -2
- package/dist/MultichainAssetsRatesController/MultichainAssetsRatesController.d.cts +2 -2
- package/dist/MultichainAssetsRatesController/MultichainAssetsRatesController.d.mts +2 -2
- package/dist/NftController.cjs +2 -47
- package/dist/NftController.cjs.map +1 -1
- package/dist/NftController.d.cts +0 -10
- package/dist/NftController.d.cts.map +1 -1
- package/dist/NftController.d.mts +0 -10
- package/dist/NftController.d.mts.map +1 -1
- package/dist/NftController.mjs +2 -47
- package/dist/NftController.mjs.map +1 -1
- package/dist/TokenBalancesController.d.cts +2 -2
- package/dist/TokenBalancesController.d.mts +2 -2
- package/dist/TokenDetectionController.d.cts +2 -2
- package/dist/TokenDetectionController.d.mts +2 -2
- package/dist/TokenListController.d.cts +2 -2
- package/dist/TokenListController.d.mts +2 -2
- package/dist/TokenRatesController.cjs +8 -1
- package/dist/TokenRatesController.cjs.map +1 -1
- package/dist/TokenRatesController.d.cts +4 -3
- package/dist/TokenRatesController.d.cts.map +1 -1
- package/dist/TokenRatesController.d.mts +4 -3
- package/dist/TokenRatesController.d.mts.map +1 -1
- package/dist/TokenRatesController.mjs +8 -1
- package/dist/TokenRatesController.mjs.map +1 -1
- package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.cjs +3 -53
- package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.cjs.map +1 -1
- package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.d.cts +1 -12
- package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.d.cts.map +1 -1
- package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.d.mts +1 -12
- package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.d.mts.map +1 -1
- package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.mjs +3 -53
- package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.mjs.map +1 -1
- package/dist/selectors/token-selectors.cjs +1 -1
- package/dist/selectors/token-selectors.cjs.map +1 -1
- package/dist/selectors/token-selectors.mjs +1 -1
- package/dist/selectors/token-selectors.mjs.map +1 -1
- package/dist/token-prices-service/abstract-token-prices-service.cjs.map +1 -1
- package/dist/token-prices-service/abstract-token-prices-service.d.cts +12 -1
- package/dist/token-prices-service/abstract-token-prices-service.d.cts.map +1 -1
- package/dist/token-prices-service/abstract-token-prices-service.d.mts +12 -1
- package/dist/token-prices-service/abstract-token-prices-service.d.mts.map +1 -1
- package/dist/token-prices-service/abstract-token-prices-service.mjs.map +1 -1
- package/dist/token-prices-service/codefi-v2.cjs +229 -20
- package/dist/token-prices-service/codefi-v2.cjs.map +1 -1
- package/dist/token-prices-service/codefi-v2.d.cts +78 -4
- package/dist/token-prices-service/codefi-v2.d.cts.map +1 -1
- package/dist/token-prices-service/codefi-v2.d.mts +78 -4
- package/dist/token-prices-service/codefi-v2.d.mts.map +1 -1
- package/dist/token-prices-service/codefi-v2.mjs +223 -20
- package/dist/token-prices-service/codefi-v2.mjs.map +1 -1
- package/dist/token-prices-service/index.cjs +4 -1
- package/dist/token-prices-service/index.cjs.map +1 -1
- package/dist/token-prices-service/index.d.cts +2 -2
- package/dist/token-prices-service/index.d.cts.map +1 -1
- package/dist/token-prices-service/index.d.mts +2 -2
- package/dist/token-prices-service/index.d.mts.map +1 -1
- package/dist/token-prices-service/index.mjs +1 -1
- package/dist/token-prices-service/index.mjs.map +1 -1
- package/package.json +4 -3
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ServicePolicy } from "@metamask/controller-utils";
|
|
2
|
-
import type { CaipAssetType, Hex } from "@metamask/utils";
|
|
2
|
+
import type { CaipAssetType, CaipChainId, Hex } from "@metamask/utils";
|
|
3
3
|
import type { MarketDataDetails } from "../TokenRatesController.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* A map of CAIP-2 chain IDs to their native asset identifiers (CAIP-19 format).
|
|
6
|
+
*/
|
|
7
|
+
export type NativeAssetIdentifiersMap = Record<CaipChainId, CaipAssetType>;
|
|
4
8
|
/**
|
|
5
9
|
* Represents an exchange rate.
|
|
6
10
|
*/
|
|
@@ -80,5 +84,12 @@ export type AbstractTokenPricesService<ChainId extends Hex = Hex, Currency exten
|
|
|
80
84
|
* @returns True if the API supports the currency, false otherwise.
|
|
81
85
|
*/
|
|
82
86
|
validateCurrencySupported(currency: unknown): currency is Currency;
|
|
87
|
+
/**
|
|
88
|
+
* Sets the native asset identifiers map for resolving native token CAIP-19 IDs.
|
|
89
|
+
* This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.
|
|
90
|
+
*
|
|
91
|
+
* @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.
|
|
92
|
+
*/
|
|
93
|
+
setNativeAssetIdentifiers?(nativeAssetIdentifiers: NativeAssetIdentifiersMap): void;
|
|
83
94
|
};
|
|
84
95
|
//# sourceMappingURL=abstract-token-prices-service.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-token-prices-service.d.cts","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"abstract-token-prices-service.d.cts","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAgC;AAEjE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,CAAC,QAAQ,SAAS,MAAM,IAAI;KAC5D,CAAC,IAAI,QAAQ,GAAG,YAAY;CAC9B,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,GAAG,GAAG,GAAG,IAAI;IAChE,YAAY,EAAE,GAAG,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,GAAG,GAAG,GAAG,IAClD,wBAAwB,CAAC,OAAO,CAAC,GAAG;IAClC,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEJ,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,GAAG,GAAG,GAAG,EACzB,QAAQ,SAAS,MAAM,GAAG,MAAM,IAC9B,wBAAwB,CAAC,OAAO,CAAC,GACnC,iBAAiB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,GAAG,GAAG,GAAG,EACzB,QAAQ,SAAS,MAAM,GAAG,MAAM,IAC9B,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,CAAC,CAAC,GAAG;IAC3D;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EACf,MAAM,EACN,QAAQ,GACT,EAAE;QACD,MAAM,EAAE,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,QAAQ,EAAE,QAAQ,CAAC;KACpB,GAAG,OAAO,CAAC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEzD;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EACjB,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,EAAE;QACD,YAAY,EAAE,QAAQ,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;QACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC;IAE/D;;;;;;OAMG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC;IAEnE;;;;;OAKG;IACH,yBAAyB,CAAC,CACxB,sBAAsB,EAAE,yBAAyB,GAChD,IAAI,CAAC;CACT,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ServicePolicy } from "@metamask/controller-utils";
|
|
2
|
-
import type { CaipAssetType, Hex } from "@metamask/utils";
|
|
2
|
+
import type { CaipAssetType, CaipChainId, Hex } from "@metamask/utils";
|
|
3
3
|
import type { MarketDataDetails } from "../TokenRatesController.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* A map of CAIP-2 chain IDs to their native asset identifiers (CAIP-19 format).
|
|
6
|
+
*/
|
|
7
|
+
export type NativeAssetIdentifiersMap = Record<CaipChainId, CaipAssetType>;
|
|
4
8
|
/**
|
|
5
9
|
* Represents an exchange rate.
|
|
6
10
|
*/
|
|
@@ -80,5 +84,12 @@ export type AbstractTokenPricesService<ChainId extends Hex = Hex, Currency exten
|
|
|
80
84
|
* @returns True if the API supports the currency, false otherwise.
|
|
81
85
|
*/
|
|
82
86
|
validateCurrencySupported(currency: unknown): currency is Currency;
|
|
87
|
+
/**
|
|
88
|
+
* Sets the native asset identifiers map for resolving native token CAIP-19 IDs.
|
|
89
|
+
* This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.
|
|
90
|
+
*
|
|
91
|
+
* @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.
|
|
92
|
+
*/
|
|
93
|
+
setNativeAssetIdentifiers?(nativeAssetIdentifiers: NativeAssetIdentifiersMap): void;
|
|
83
94
|
};
|
|
84
95
|
//# sourceMappingURL=abstract-token-prices-service.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-token-prices-service.d.mts","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"abstract-token-prices-service.d.mts","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAgC;AAEjE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,CAAC,QAAQ,SAAS,MAAM,IAAI;KAC5D,CAAC,IAAI,QAAQ,GAAG,YAAY;CAC9B,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,GAAG,GAAG,GAAG,IAAI;IAChE,YAAY,EAAE,GAAG,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,GAAG,GAAG,GAAG,IAClD,wBAAwB,CAAC,OAAO,CAAC,GAAG;IAClC,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEJ,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,GAAG,GAAG,GAAG,EACzB,QAAQ,SAAS,MAAM,GAAG,MAAM,IAC9B,wBAAwB,CAAC,OAAO,CAAC,GACnC,iBAAiB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,GAAG,GAAG,GAAG,EACzB,QAAQ,SAAS,MAAM,GAAG,MAAM,IAC9B,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,CAAC,CAAC,GAAG;IAC3D;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EACf,MAAM,EACN,QAAQ,GACT,EAAE;QACD,MAAM,EAAE,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,QAAQ,EAAE,QAAQ,CAAC;KACpB,GAAG,OAAO,CAAC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEzD;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EACjB,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,EAAE;QACD,YAAY,EAAE,QAAQ,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;QACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC;IAE/D;;;;;;OAMG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC;IAEnE;;;;;OAKG;IACH,yBAAyB,CAAC,CACxB,sBAAsB,EAAE,yBAAyB,GAChD,IAAI,CAAC;CACT,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-token-prices-service.mjs","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { MarketDataDetails } from '../TokenRatesController';\n\n/**\n * Represents an exchange rate.\n */\nexport type ExchangeRate = {\n name: string;\n ticker: string;\n value: number;\n currencyType: string;\n usd?: number;\n};\n\n/**\n * A map of currency to its exchange rate.\n */\nexport type ExchangeRatesByCurrency<Currency extends string> = {\n [C in Currency]: ExchangeRate;\n};\n\nexport type EvmAssetAddressWithChain<ChainId extends Hex = Hex> = {\n tokenAddress: Hex;\n chainId: ChainId;\n};\n\nexport type EvmAssetWithId<ChainId extends Hex = Hex> =\n EvmAssetAddressWithChain<ChainId> & {\n assetId: CaipAssetType;\n };\n\nexport type EvmAssetWithMarketData<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = EvmAssetAddressWithChain<ChainId> &\n MarketDataDetails & { currency: Currency };\n\n/**\n * An ideal token prices service. All implementations must confirm to this\n * interface.\n *\n * @template ChainId - A type union of valid arguments for the `chainId`\n * argument to `fetchTokenPrices`.\n * @template Currency - A type union of valid arguments for the `currency`\n * argument to `fetchTokenPrices`.\n */\nexport type AbstractTokenPricesService<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = Partial<Pick<ServicePolicy, 'onBreak' | 'onDegraded'>> & {\n /**\n * Retrieves prices in the given currency for the tokens identified by the\n * given addresses which are expected to live on the given chain.\n *\n * @param args - The arguments to this function.\n * @param args.assets - The assets to get prices for.\n * @param args.currency - The desired currency of the token prices.\n * @returns The prices for the requested tokens.\n */\n fetchTokenPrices({\n assets,\n currency,\n }: {\n assets: EvmAssetAddressWithChain<ChainId>[];\n currency: Currency;\n }): Promise<EvmAssetWithMarketData<ChainId, Currency>[]>;\n\n /**\n * Retrieves exchange rates in the given currency.\n *\n * @param args - The arguments to this function.\n * @param args.baseCurrency - The desired currency of the token prices.\n * @param args.includeUsdRate - Whether to include the USD rate in the response.\n * @param args.cryptocurrencies - The cryptocurrencies to get exchange rates for.\n * @returns The exchange rates in the requested base currency.\n */\n fetchExchangeRates({\n baseCurrency,\n includeUsdRate,\n cryptocurrencies,\n }: {\n baseCurrency: Currency;\n includeUsdRate: boolean;\n cryptocurrencies: string[];\n }): Promise<ExchangeRatesByCurrency<Currency>>;\n\n /**\n * Type guard for whether the API can return token prices for the given chain\n * ID.\n *\n * @param chainId - The chain ID to check.\n * @returns True if the API supports the chain ID, false otherwise.\n */\n validateChainIdSupported(chainId: unknown): chainId is ChainId;\n\n /**\n * Type guard for whether the API can return token prices in the given\n * currency.\n *\n * @param currency - The currency to check.\n * @returns True if the API supports the currency, false otherwise.\n */\n validateCurrencySupported(currency: unknown): currency is Currency;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"abstract-token-prices-service.mjs","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type { CaipAssetType, CaipChainId, Hex } from '@metamask/utils';\n\nimport type { MarketDataDetails } from '../TokenRatesController';\n\n/**\n * A map of CAIP-2 chain IDs to their native asset identifiers (CAIP-19 format).\n */\nexport type NativeAssetIdentifiersMap = Record<CaipChainId, CaipAssetType>;\n\n/**\n * Represents an exchange rate.\n */\nexport type ExchangeRate = {\n name: string;\n ticker: string;\n value: number;\n currencyType: string;\n usd?: number;\n};\n\n/**\n * A map of currency to its exchange rate.\n */\nexport type ExchangeRatesByCurrency<Currency extends string> = {\n [C in Currency]: ExchangeRate;\n};\n\nexport type EvmAssetAddressWithChain<ChainId extends Hex = Hex> = {\n tokenAddress: Hex;\n chainId: ChainId;\n};\n\nexport type EvmAssetWithId<ChainId extends Hex = Hex> =\n EvmAssetAddressWithChain<ChainId> & {\n assetId: CaipAssetType;\n };\n\nexport type EvmAssetWithMarketData<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = EvmAssetAddressWithChain<ChainId> &\n MarketDataDetails & { currency: Currency };\n\n/**\n * An ideal token prices service. All implementations must confirm to this\n * interface.\n *\n * @template ChainId - A type union of valid arguments for the `chainId`\n * argument to `fetchTokenPrices`.\n * @template Currency - A type union of valid arguments for the `currency`\n * argument to `fetchTokenPrices`.\n */\nexport type AbstractTokenPricesService<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = Partial<Pick<ServicePolicy, 'onBreak' | 'onDegraded'>> & {\n /**\n * Retrieves prices in the given currency for the tokens identified by the\n * given addresses which are expected to live on the given chain.\n *\n * @param args - The arguments to this function.\n * @param args.assets - The assets to get prices for.\n * @param args.currency - The desired currency of the token prices.\n * @returns The prices for the requested tokens.\n */\n fetchTokenPrices({\n assets,\n currency,\n }: {\n assets: EvmAssetAddressWithChain<ChainId>[];\n currency: Currency;\n }): Promise<EvmAssetWithMarketData<ChainId, Currency>[]>;\n\n /**\n * Retrieves exchange rates in the given currency.\n *\n * @param args - The arguments to this function.\n * @param args.baseCurrency - The desired currency of the token prices.\n * @param args.includeUsdRate - Whether to include the USD rate in the response.\n * @param args.cryptocurrencies - The cryptocurrencies to get exchange rates for.\n * @returns The exchange rates in the requested base currency.\n */\n fetchExchangeRates({\n baseCurrency,\n includeUsdRate,\n cryptocurrencies,\n }: {\n baseCurrency: Currency;\n includeUsdRate: boolean;\n cryptocurrencies: string[];\n }): Promise<ExchangeRatesByCurrency<Currency>>;\n\n /**\n * Type guard for whether the API can return token prices for the given chain\n * ID.\n *\n * @param chainId - The chain ID to check.\n * @returns True if the API supports the chain ID, false otherwise.\n */\n validateChainIdSupported(chainId: unknown): chainId is ChainId;\n\n /**\n * Type guard for whether the API can return token prices in the given\n * currency.\n *\n * @param currency - The currency to check.\n * @returns True if the API supports the currency, false otherwise.\n */\n validateCurrencySupported(currency: unknown): currency is Currency;\n\n /**\n * Sets the native asset identifiers map for resolving native token CAIP-19 IDs.\n * This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.\n *\n * @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.\n */\n setNativeAssetIdentifiers?(\n nativeAssetIdentifiers: NativeAssetIdentifiersMap,\n ): void;\n};\n"]}
|
|
@@ -10,16 +10,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _CodefiTokenPricesServiceV2_policy;
|
|
13
|
+
var _CodefiTokenPricesServiceV2_policy, _CodefiTokenPricesServiceV2_nativeAssetIdentifiers;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CodefiTokenPricesServiceV2 = exports.SUPPORTED_CHAIN_IDS = exports.SPOT_PRICES_SUPPORT_INFO = exports.getNativeTokenAddress = exports.ZERO_ADDRESS = exports.SUPPORTED_CURRENCIES = void 0;
|
|
15
|
+
exports.CodefiTokenPricesServiceV2 = exports.resetSupportedCurrenciesCache = exports.getSupportedCurrencies = exports.fetchSupportedCurrencies = exports.resetSupportedNetworksCache = exports.getSupportedNetworks = exports.fetchSupportedNetworks = exports.SUPPORTED_CHAIN_IDS = exports.SPOT_PRICES_SUPPORT_INFO = exports.getNativeTokenAddress = exports.ZERO_ADDRESS = exports.SUPPORTED_CURRENCIES = exports.SUPPORTED_CURRENCIES_FALLBACK = void 0;
|
|
16
16
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
17
17
|
const utils_1 = require("@metamask/utils");
|
|
18
18
|
/**
|
|
19
19
|
* The list of currencies that can be supplied as the `vsCurrency` parameter to
|
|
20
20
|
* the `/spot-prices` endpoint, in lowercase form.
|
|
21
|
+
* This is the fallback list used when the API is unavailable.
|
|
21
22
|
*/
|
|
22
|
-
exports.
|
|
23
|
+
exports.SUPPORTED_CURRENCIES_FALLBACK = [
|
|
23
24
|
// Bitcoin
|
|
24
25
|
'btc',
|
|
25
26
|
// Ether
|
|
@@ -195,6 +196,11 @@ exports.SUPPORTED_CURRENCIES = [
|
|
|
195
196
|
// Apechain
|
|
196
197
|
'ape',
|
|
197
198
|
];
|
|
199
|
+
/**
|
|
200
|
+
* @deprecated Use `getSupportedCurrencies()` or `fetchSupportedCurrencies()` instead.
|
|
201
|
+
* This is an alias for backward compatibility.
|
|
202
|
+
*/
|
|
203
|
+
exports.SUPPORTED_CURRENCIES = exports.SUPPORTED_CURRENCIES_FALLBACK;
|
|
198
204
|
/**
|
|
199
205
|
* Represents the zero address, commonly used as a placeholder in blockchain transactions.
|
|
200
206
|
* In the context of fetching market data, the zero address is utilized to retrieve information
|
|
@@ -211,7 +217,6 @@ const chainIdToNativeTokenAddress = {
|
|
|
211
217
|
'0x440': '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // Metis Andromeda
|
|
212
218
|
'0x1388': '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // Mantle
|
|
213
219
|
'0x64': '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d', // Gnosis
|
|
214
|
-
'0x10b3e': '0xf2b51cc1850fed939658317a22d73d3482767591', // MapleStory Universe (MSU aka Henesys)
|
|
215
220
|
'0x1e': '0x542fda317318ebf1d3deaf76e0b632741a7e677d', // Rootstock Mainnet - Native symbol: RBTC
|
|
216
221
|
'0x2611': '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', // Plasma mainnet - native symbol: XPL
|
|
217
222
|
};
|
|
@@ -249,7 +254,7 @@ exports.SPOT_PRICES_SUPPORT_INFO = {
|
|
|
249
254
|
'0xe8': 'eip155:232/erc20:0x0000000000000000000000000000000000000000', // Lens Mainnet - Native symbol: GHO
|
|
250
255
|
'0xfa': 'eip155:250/slip44:1007', // Fantom Opera - Native symbol: FTM
|
|
251
256
|
'0xfc': 'eip155:252/erc20:0x0000000000000000000000000000000000000000', // Fraxtal - native symbol: FRAX
|
|
252
|
-
'0x10b3e': 'eip155:68414/erc20:
|
|
257
|
+
'0x10b3e': 'eip155:68414/erc20:0x0000000000000000000000000000000000000000', // MapleStory Universe - no slip44
|
|
253
258
|
'0x120': 'eip155:288/slip44:60', // Boba Network (Ethereum L2) - Native symbol: ETH
|
|
254
259
|
'0x141': 'eip155:321/slip44:641', // KCC Mainnet - Native symbol: KCS
|
|
255
260
|
'0x144': 'eip155:324/slip44:60', // zkSync Era Mainnet (Ethereum L2) - Native symbol: ETH
|
|
@@ -299,13 +304,156 @@ exports.SPOT_PRICES_SUPPORT_INFO = {
|
|
|
299
304
|
* @see Used by {@link CodefiTokenPricesServiceV2} to validate that a given chain ID is supported by V2 of the Codefi Price API.
|
|
300
305
|
*/
|
|
301
306
|
exports.SUPPORTED_CHAIN_IDS = Object.keys(exports.SPOT_PRICES_SUPPORT_INFO);
|
|
302
|
-
/**
|
|
303
|
-
* The list of chain IDs that are supported by V3 of the Codefi Price API.
|
|
304
|
-
* Only includes chain IDs from SPOT_PRICES_SUPPORT_INFO that have a non-null CAIP-19 value.
|
|
305
|
-
*/
|
|
306
|
-
const SUPPORTED_CHAIN_IDS_V3 = Object.keys(exports.SPOT_PRICES_SUPPORT_INFO).filter((chainId) => exports.SPOT_PRICES_SUPPORT_INFO[chainId] !== null);
|
|
307
307
|
const BASE_URL_V1 = 'https://price.api.cx.metamask.io/v1';
|
|
308
|
+
const BASE_URL_V2 = 'https://price.api.cx.metamask.io/v2';
|
|
308
309
|
const BASE_URL_V3 = 'https://price.api.cx.metamask.io/v3';
|
|
310
|
+
/**
|
|
311
|
+
* In-memory store for the last successfully fetched supported networks.
|
|
312
|
+
*/
|
|
313
|
+
let lastFetchedSupportedNetworks = null;
|
|
314
|
+
/**
|
|
315
|
+
* Converts a CAIP-2 chain ID (e.g., 'eip155:1') to a hex chain ID (e.g., '0x1').
|
|
316
|
+
*
|
|
317
|
+
* @param caipChainId - The CAIP-2 chain ID string.
|
|
318
|
+
* @returns The hex chain ID or null if not an EIP-155 chain.
|
|
319
|
+
*/
|
|
320
|
+
function caipChainIdToHex(caipChainId) {
|
|
321
|
+
const match = caipChainId.match(/^eip155:(\d+)$/u);
|
|
322
|
+
if (!match) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
return (0, utils_1.numberToHex)(parseInt(match[1], 10));
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Fetches the list of supported networks from the API.
|
|
329
|
+
* Falls back to the hardcoded list if the fetch fails.
|
|
330
|
+
*
|
|
331
|
+
* @returns The supported networks response.
|
|
332
|
+
*/
|
|
333
|
+
async function fetchSupportedNetworks() {
|
|
334
|
+
try {
|
|
335
|
+
const url = `${BASE_URL_V2}/supportedNetworks`;
|
|
336
|
+
const response = await (0, controller_utils_1.handleFetch)(url, {
|
|
337
|
+
headers: { 'Cache-Control': 'no-cache' },
|
|
338
|
+
});
|
|
339
|
+
if (response &&
|
|
340
|
+
typeof response === 'object' &&
|
|
341
|
+
'fullSupport' in response &&
|
|
342
|
+
'partialSupport' in response) {
|
|
343
|
+
lastFetchedSupportedNetworks = response;
|
|
344
|
+
return lastFetchedSupportedNetworks;
|
|
345
|
+
}
|
|
346
|
+
// Invalid response format, fall back to hardcoded list
|
|
347
|
+
return getSupportedNetworksFallback();
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
// On any error, fall back to the hardcoded list
|
|
351
|
+
return getSupportedNetworksFallback();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
exports.fetchSupportedNetworks = fetchSupportedNetworks;
|
|
355
|
+
/**
|
|
356
|
+
* Synchronously gets the list of supported networks.
|
|
357
|
+
* Returns the last fetched value if available, otherwise returns the fallback list.
|
|
358
|
+
*
|
|
359
|
+
* @returns The supported networks response.
|
|
360
|
+
*/
|
|
361
|
+
function getSupportedNetworks() {
|
|
362
|
+
if (lastFetchedSupportedNetworks !== null) {
|
|
363
|
+
return lastFetchedSupportedNetworks;
|
|
364
|
+
}
|
|
365
|
+
return getSupportedNetworksFallback();
|
|
366
|
+
}
|
|
367
|
+
exports.getSupportedNetworks = getSupportedNetworks;
|
|
368
|
+
/**
|
|
369
|
+
* Generates a fallback supported networks response from the hardcoded SPOT_PRICES_SUPPORT_INFO.
|
|
370
|
+
*
|
|
371
|
+
* @returns A SupportedNetworksResponse derived from hardcoded data.
|
|
372
|
+
*/
|
|
373
|
+
function getSupportedNetworksFallback() {
|
|
374
|
+
const caipChainIds = Object.keys(exports.SPOT_PRICES_SUPPORT_INFO).map((hexChainId) => (0, utils_1.toCaipChainId)(utils_1.KnownCaipNamespace.Eip155, (0, utils_1.hexToNumber)(hexChainId).toString()));
|
|
375
|
+
return {
|
|
376
|
+
fullSupport: caipChainIds.slice(0, 11), // First 11 chains as "full support"
|
|
377
|
+
partialSupport: {
|
|
378
|
+
spotPricesV2: caipChainIds,
|
|
379
|
+
spotPricesV3: caipChainIds,
|
|
380
|
+
},
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Resets the supported networks cache.
|
|
385
|
+
* This is primarily intended for testing purposes.
|
|
386
|
+
*/
|
|
387
|
+
function resetSupportedNetworksCache() {
|
|
388
|
+
lastFetchedSupportedNetworks = null;
|
|
389
|
+
}
|
|
390
|
+
exports.resetSupportedNetworksCache = resetSupportedNetworksCache;
|
|
391
|
+
/**
|
|
392
|
+
* Gets the list of supported chain IDs for spot prices v3 as hex values.
|
|
393
|
+
*
|
|
394
|
+
* @returns Array of hex chain IDs supported by spot prices v3.
|
|
395
|
+
*/
|
|
396
|
+
function getSupportedChainIdsV3AsHex() {
|
|
397
|
+
const supportedNetworks = getSupportedNetworks();
|
|
398
|
+
const allV3Chains = [
|
|
399
|
+
...supportedNetworks.fullSupport,
|
|
400
|
+
...supportedNetworks.partialSupport.spotPricesV3,
|
|
401
|
+
];
|
|
402
|
+
return allV3Chains
|
|
403
|
+
.map(caipChainIdToHex)
|
|
404
|
+
.filter((hexChainId) => hexChainId !== null);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* In-memory store for the last successfully fetched supported currencies.
|
|
408
|
+
*/
|
|
409
|
+
let lastFetchedCurrencies = null;
|
|
410
|
+
/**
|
|
411
|
+
* Fetches the list of supported currencies from the API.
|
|
412
|
+
* Falls back to the hardcoded list if the fetch fails.
|
|
413
|
+
*
|
|
414
|
+
* @returns The list of supported currencies in lowercase.
|
|
415
|
+
*/
|
|
416
|
+
async function fetchSupportedCurrencies() {
|
|
417
|
+
try {
|
|
418
|
+
const url = `${BASE_URL_V1}/supportedVsCurrencies`;
|
|
419
|
+
const response = await (0, controller_utils_1.handleFetch)(url, {
|
|
420
|
+
headers: { 'Cache-Control': 'no-cache' },
|
|
421
|
+
});
|
|
422
|
+
if (Array.isArray(response)) {
|
|
423
|
+
const currencies = response.map((currency) => currency.toLowerCase());
|
|
424
|
+
lastFetchedCurrencies = currencies;
|
|
425
|
+
return currencies;
|
|
426
|
+
}
|
|
427
|
+
// Invalid response format, fall back to hardcoded list
|
|
428
|
+
return [...exports.SUPPORTED_CURRENCIES_FALLBACK];
|
|
429
|
+
}
|
|
430
|
+
catch {
|
|
431
|
+
// On any error, fall back to the hardcoded list
|
|
432
|
+
return [...exports.SUPPORTED_CURRENCIES_FALLBACK];
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
exports.fetchSupportedCurrencies = fetchSupportedCurrencies;
|
|
436
|
+
/**
|
|
437
|
+
* Synchronously gets the list of supported currencies.
|
|
438
|
+
* Returns the last fetched value if available, otherwise returns the fallback list.
|
|
439
|
+
*
|
|
440
|
+
* @returns The list of supported currencies in lowercase.
|
|
441
|
+
*/
|
|
442
|
+
function getSupportedCurrencies() {
|
|
443
|
+
if (lastFetchedCurrencies !== null) {
|
|
444
|
+
return lastFetchedCurrencies;
|
|
445
|
+
}
|
|
446
|
+
return exports.SUPPORTED_CURRENCIES_FALLBACK;
|
|
447
|
+
}
|
|
448
|
+
exports.getSupportedCurrencies = getSupportedCurrencies;
|
|
449
|
+
/**
|
|
450
|
+
* Resets the supported currencies cache.
|
|
451
|
+
* This is primarily intended for testing purposes.
|
|
452
|
+
*/
|
|
453
|
+
function resetSupportedCurrenciesCache() {
|
|
454
|
+
lastFetchedCurrencies = null;
|
|
455
|
+
}
|
|
456
|
+
exports.resetSupportedCurrenciesCache = resetSupportedCurrenciesCache;
|
|
309
457
|
/**
|
|
310
458
|
* This version of the token prices service uses V2 of the Codefi Price API to
|
|
311
459
|
* fetch token prices.
|
|
@@ -313,6 +461,11 @@ const BASE_URL_V3 = 'https://price.api.cx.metamask.io/v3';
|
|
|
313
461
|
class CodefiTokenPricesServiceV2 {
|
|
314
462
|
constructor({ degradedThreshold = controller_utils_1.DEFAULT_DEGRADED_THRESHOLD, retries = controller_utils_1.DEFAULT_MAX_RETRIES, maximumConsecutiveFailures = controller_utils_1.DEFAULT_MAX_CONSECUTIVE_FAILURES, onBreak, onDegraded, circuitBreakDuration = controller_utils_1.DEFAULT_CIRCUIT_BREAK_DURATION, } = {}) {
|
|
315
463
|
_CodefiTokenPricesServiceV2_policy.set(this, void 0);
|
|
464
|
+
/**
|
|
465
|
+
* Map of CAIP-2 chain IDs to their native asset identifiers.
|
|
466
|
+
* Updated via setNativeAssetIdentifiers().
|
|
467
|
+
*/
|
|
468
|
+
_CodefiTokenPricesServiceV2_nativeAssetIdentifiers.set(this, {});
|
|
316
469
|
__classPrivateFieldSet(this, _CodefiTokenPricesServiceV2_policy, (0, controller_utils_1.createServicePolicy)({
|
|
317
470
|
maxRetries: retries,
|
|
318
471
|
maxConsecutiveFailures: maximumConsecutiveFailures,
|
|
@@ -346,6 +499,24 @@ class CodefiTokenPricesServiceV2 {
|
|
|
346
499
|
onDegraded(...args) {
|
|
347
500
|
return __classPrivateFieldGet(this, _CodefiTokenPricesServiceV2_policy, "f").onDegraded(...args);
|
|
348
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Sets the native asset identifiers map for resolving native token CAIP-19 IDs.
|
|
504
|
+
* This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.
|
|
505
|
+
*
|
|
506
|
+
* @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.
|
|
507
|
+
*/
|
|
508
|
+
setNativeAssetIdentifiers(nativeAssetIdentifiers) {
|
|
509
|
+
__classPrivateFieldSet(this, _CodefiTokenPricesServiceV2_nativeAssetIdentifiers, nativeAssetIdentifiers, "f");
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Updates the supported networks cache by fetching from the API.
|
|
513
|
+
* This should be called periodically to keep the supported networks list fresh.
|
|
514
|
+
*
|
|
515
|
+
* @returns The updated supported networks response.
|
|
516
|
+
*/
|
|
517
|
+
async updateSupportedNetworks() {
|
|
518
|
+
return fetchSupportedNetworks();
|
|
519
|
+
}
|
|
349
520
|
/**
|
|
350
521
|
* Retrieves prices in the given currency for the tokens identified by the
|
|
351
522
|
* given addresses which are expected to live on the given chain.
|
|
@@ -356,21 +527,41 @@ class CodefiTokenPricesServiceV2 {
|
|
|
356
527
|
* @returns The prices for the requested tokens.
|
|
357
528
|
*/
|
|
358
529
|
async fetchTokenPrices({ assets, currency, }) {
|
|
530
|
+
// Refresh supported networks in background (non-blocking)
|
|
531
|
+
// This ensures the list stays fresh during normal polling
|
|
532
|
+
// Note: fetchSupportedNetworks handles errors internally and always resolves
|
|
533
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
534
|
+
fetchSupportedNetworks();
|
|
535
|
+
// Get dynamically fetched supported chain IDs for V3
|
|
536
|
+
const supportedChainIdsV3 = getSupportedChainIdsV3AsHex();
|
|
359
537
|
const assetsWithIds = assets
|
|
360
538
|
// Filter out assets that are not supported by V3 of the Price API.
|
|
361
|
-
.filter((asset) =>
|
|
539
|
+
.filter((asset) => supportedChainIdsV3.includes(asset.chainId))
|
|
362
540
|
.map((asset) => {
|
|
363
541
|
const caipChainId = (0, utils_1.toCaipChainId)(utils_1.KnownCaipNamespace.Eip155, (0, utils_1.hexToNumber)(asset.chainId).toString());
|
|
364
542
|
const nativeAddress = (0, exports.getNativeTokenAddress)(asset.chainId);
|
|
543
|
+
const isNativeToken = nativeAddress.toLowerCase() === asset.tokenAddress.toLowerCase();
|
|
544
|
+
let assetId;
|
|
545
|
+
if (isNativeToken) {
|
|
546
|
+
// For native tokens, use nativeAssetIdentifiers from NetworkEnablementController,
|
|
547
|
+
// falling back to hardcoded SPOT_PRICES_SUPPORT_INFO
|
|
548
|
+
assetId =
|
|
549
|
+
__classPrivateFieldGet(this, _CodefiTokenPricesServiceV2_nativeAssetIdentifiers, "f")[caipChainId] ??
|
|
550
|
+
exports.SPOT_PRICES_SUPPORT_INFO[asset.chainId];
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
// For ERC20 tokens, construct the CAIP-19 ID dynamically
|
|
554
|
+
assetId = `${caipChainId}/erc20:${asset.tokenAddress.toLowerCase()}`;
|
|
555
|
+
}
|
|
556
|
+
if (!assetId) {
|
|
557
|
+
return undefined;
|
|
558
|
+
}
|
|
365
559
|
return {
|
|
366
560
|
...asset,
|
|
367
|
-
assetId:
|
|
368
|
-
asset.tokenAddress.toLowerCase()
|
|
369
|
-
? exports.SPOT_PRICES_SUPPORT_INFO[asset.chainId]
|
|
370
|
-
: `${caipChainId}/erc20:${asset.tokenAddress.toLowerCase()}`),
|
|
561
|
+
assetId: assetId,
|
|
371
562
|
};
|
|
372
563
|
})
|
|
373
|
-
.filter((asset) => asset
|
|
564
|
+
.filter((asset) => asset !== undefined);
|
|
374
565
|
if (assetsWithIds.length === 0) {
|
|
375
566
|
return [];
|
|
376
567
|
}
|
|
@@ -403,6 +594,11 @@ class CodefiTokenPricesServiceV2 {
|
|
|
403
594
|
* @returns The exchange rates for the requested base currency.
|
|
404
595
|
*/
|
|
405
596
|
async fetchExchangeRates({ baseCurrency, includeUsdRate, cryptocurrencies, }) {
|
|
597
|
+
// Refresh supported currencies in background (non-blocking)
|
|
598
|
+
// This ensures the list stays fresh during normal polling
|
|
599
|
+
// Note: fetchSupportedCurrencies handles errors internally and always resolves
|
|
600
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
601
|
+
fetchSupportedCurrencies();
|
|
406
602
|
const url = new URL(`${BASE_URL_V1}/exchange-rates`);
|
|
407
603
|
url.searchParams.append('baseCurrency', baseCurrency);
|
|
408
604
|
const urlUsd = new URL(`${BASE_URL_V1}/exchange-rates`);
|
|
@@ -475,8 +671,13 @@ class CodefiTokenPricesServiceV2 {
|
|
|
475
671
|
* @returns True if the API supports the chain ID, false otherwise.
|
|
476
672
|
*/
|
|
477
673
|
validateChainIdSupported(chainId) {
|
|
478
|
-
|
|
479
|
-
|
|
674
|
+
// Use dynamically fetched supported networks
|
|
675
|
+
const supportedChainIds = getSupportedChainIdsV3AsHex();
|
|
676
|
+
// Also include the hardcoded fallback list for backwards compatibility
|
|
677
|
+
const allSupportedChainIds = [
|
|
678
|
+
...new Set([...supportedChainIds, ...exports.SUPPORTED_CHAIN_IDS]),
|
|
679
|
+
];
|
|
680
|
+
return (typeof chainId === 'string' && allSupportedChainIds.includes(chainId));
|
|
480
681
|
}
|
|
481
682
|
/**
|
|
482
683
|
* Type guard for whether the API can return token prices in the given
|
|
@@ -487,11 +688,19 @@ class CodefiTokenPricesServiceV2 {
|
|
|
487
688
|
* @returns True if the API supports the currency, false otherwise.
|
|
488
689
|
*/
|
|
489
690
|
validateCurrencySupported(currency) {
|
|
490
|
-
const supportedCurrencies =
|
|
691
|
+
const supportedCurrencies = getSupportedCurrencies();
|
|
491
692
|
return (typeof currency === 'string' &&
|
|
492
693
|
supportedCurrencies.includes(currency.toLowerCase()));
|
|
493
694
|
}
|
|
695
|
+
/**
|
|
696
|
+
* Fetches the list of supported currencies from the API.
|
|
697
|
+
*
|
|
698
|
+
* @returns The list of supported currencies.
|
|
699
|
+
*/
|
|
700
|
+
async updateSupportedCurrencies() {
|
|
701
|
+
return fetchSupportedCurrencies();
|
|
702
|
+
}
|
|
494
703
|
}
|
|
495
704
|
exports.CodefiTokenPricesServiceV2 = CodefiTokenPricesServiceV2;
|
|
496
|
-
_CodefiTokenPricesServiceV2_policy = new WeakMap();
|
|
705
|
+
_CodefiTokenPricesServiceV2_policy = new WeakMap(), _CodefiTokenPricesServiceV2_nativeAssetIdentifiers = new WeakMap();
|
|
497
706
|
//# sourceMappingURL=codefi-v2.cjs.map
|