|
| 1 | +diff --git a/dist/assetsUtil.cjs b/dist/assetsUtil.cjs |
| 2 | +index 61246f51500c8cab48f18296a73629fb73454caa..34396ba143e3ebcb04fa2c80f7a35d1abd06710e 100644 |
| 3 | +--- a/dist/assetsUtil.cjs |
| 4 | ++++ b/dist/assetsUtil.cjs |
| 5 | +@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { |
| 6 | + }; |
| 7 | + Object.defineProperty(exports, "__esModule", { value: true }); |
| 8 | + function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } |
| 9 | +-exports.fetchTokenContractExchangeRates = exports.reduceInBatchesSerially = exports.divideIntoBatches = exports.ethersBigNumberToBN = exports.addUrlProtocolPrefix = exports.getFormattedIpfsUrl = exports.getIpfsCIDv1AndPath = exports.removeIpfsProtocolPrefix = exports.isTokenListSupportedForNetwork = exports.isTokenDetectionSupportedForNetwork = exports.SupportedStakedBalanceNetworks = exports.SupportedTokenDetectionNetworks = exports.formatIconUrlWithProxy = exports.formatAggregatorNames = exports.hasNewCollectionFields = exports.compareNftMetadata = exports.TOKEN_PRICES_BATCH_SIZE = void 0; |
| 10 | ++exports.getKeyByValue = exports.fetchTokenContractExchangeRates = exports.reduceInBatchesSerially = exports.divideIntoBatches = exports.ethersBigNumberToBN = exports.addUrlProtocolPrefix = exports.getFormattedIpfsUrl = exports.getIpfsCIDv1AndPath = exports.removeIpfsProtocolPrefix = exports.isTokenListSupportedForNetwork = exports.isTokenDetectionSupportedForNetwork = exports.SupportedStakedBalanceNetworks = exports.SupportedTokenDetectionNetworks = exports.formatIconUrlWithProxy = exports.formatAggregatorNames = exports.hasNewCollectionFields = exports.compareNftMetadata = exports.TOKEN_PRICES_BATCH_SIZE = void 0; |
| 11 | + const controller_utils_1 = require("@metamask/controller-utils"); |
| 12 | + const utils_1 = require("@metamask/utils"); |
| 13 | + const bn_js_1 = __importDefault(require("bn.js")); |
| 14 | +@@ -368,4 +368,19 @@ async function fetchTokenContractExchangeRates({ tokenPricesService, nativeCurre |
| 15 | + }, {}); |
| 16 | + } |
| 17 | + exports.fetchTokenContractExchangeRates = fetchTokenContractExchangeRates; |
| 18 | ++/** |
| 19 | ++ * Function to search for a specific value in a given map and return the key |
| 20 | ++ * @param map - map input to search value |
| 21 | ++ * @param value - the value to search for |
| 22 | ++ * @returns returns key that corresponds to the value |
| 23 | ++ */ |
| 24 | ++function getKeyByValue(map, value) { |
| 25 | ++ for (const [key, val] of map.entries()) { |
| 26 | ++ if (val === value) { |
| 27 | ++ return key; |
| 28 | ++ } |
| 29 | ++ } |
| 30 | ++ return null; // Return null if no match is found |
| 31 | ++} |
| 32 | ++exports.getKeyByValue = getKeyByValue; |
| 33 | + //# sourceMappingURL=assetsUtil.cjs.map |
| 34 | +\ No newline at end of file |
| 35 | +diff --git a/dist/assetsUtil.mjs b/dist/assetsUtil.mjs |
| 36 | +index 1e14797c8e1cd48e75287b37c29eb6065daac5e6..c288b56227bd7779982083be4cae9674d01ae1dd 100644 |
| 37 | +--- a/dist/assetsUtil.mjs |
| 38 | ++++ b/dist/assetsUtil.mjs |
| 39 | +@@ -354,4 +354,18 @@ export async function fetchTokenContractExchangeRates({ tokenPricesService, nati |
| 40 | + }; |
| 41 | + }, {}); |
| 42 | + } |
| 43 | ++/** |
| 44 | ++ * Function to search for a specific value in a given map and return the key |
| 45 | ++ * @param map - map input to search value |
| 46 | ++ * @param value - the value to search for |
| 47 | ++ * @returns returns key that corresponds to the value |
| 48 | ++ */ |
| 49 | ++export function getKeyByValue(map, value) { |
| 50 | ++ for (const [key, val] of map.entries()) { |
| 51 | ++ if (val === value) { |
| 52 | ++ return key; |
| 53 | ++ } |
| 54 | ++ } |
| 55 | ++ return null; // Return null if no match is found |
| 56 | ++} |
| 57 | + //# sourceMappingURL=assetsUtil.mjs.map |
| 58 | +\ No newline at end of file |
| 59 | +diff --git a/dist/crypto-compare-service/crypto-compare.cjs b/dist/crypto-compare-service/crypto-compare.cjs |
| 60 | +index 4cdf9c15053fb4acbc8aa7cade912e87c7aaf224..7bddcf4322f7825affdf34116778ba08b7676951 100644 |
| 61 | +--- a/dist/crypto-compare-service/crypto-compare.cjs |
| 62 | ++++ b/dist/crypto-compare-service/crypto-compare.cjs |
| 63 | +@@ -2,6 +2,7 @@ |
| 64 | + Object.defineProperty(exports, "__esModule", { value: true }); |
| 65 | + exports.fetchMultiExchangeRate = exports.fetchExchangeRate = void 0; |
| 66 | + const controller_utils_1 = require("@metamask/controller-utils"); |
| 67 | ++const assetsUtil_1 = require("../assetsUtil.cjs"); |
| 68 | + /** |
| 69 | + * A map from native currency symbol to CryptoCompare identifier. |
| 70 | + * This is only needed when the values don't match. |
| 71 | +@@ -105,12 +106,14 @@ exports.fetchExchangeRate = fetchExchangeRate; |
| 72 | + * @returns Promise resolving to exchange rates for given currencies. |
| 73 | + */ |
| 74 | + async function fetchMultiExchangeRate(fiatCurrency, cryptocurrencies, includeUSDRate) { |
| 75 | +- const url = getMultiPricingURL(cryptocurrencies, [fiatCurrency], includeUSDRate); |
| 76 | ++ const fsyms = cryptocurrencies.map((nativeCurrency) => nativeSymbolOverrides.get(nativeCurrency) ?? nativeCurrency); |
| 77 | ++ const url = getMultiPricingURL(fsyms, [fiatCurrency], includeUSDRate); |
| 78 | + const response = await (0, controller_utils_1.handleFetch)(url); |
| 79 | + handleErrorResponse(response); |
| 80 | + const rates = {}; |
| 81 | + for (const [cryptocurrency, values] of Object.entries(response)) { |
| 82 | +- rates[cryptocurrency.toLowerCase()] = { |
| 83 | ++ const key = (0, assetsUtil_1.getKeyByValue)(nativeSymbolOverrides, cryptocurrency); |
| 84 | ++ rates[key?.toLowerCase() ?? cryptocurrency.toLowerCase()] = { |
| 85 | + [fiatCurrency.toLowerCase()]: values[fiatCurrency.toUpperCase()], |
| 86 | + ...(includeUSDRate && { usd: values.USD }), |
| 87 | + }; |
| 88 | +diff --git a/dist/crypto-compare-service/crypto-compare.mjs b/dist/crypto-compare-service/crypto-compare.mjs |
| 89 | +index 58db2280159669c1b48fb94a9164b8e0be2850a7..74e0560718d42202e9183ff7ff1bfdac1424506e 100644 |
| 90 | +--- a/dist/crypto-compare-service/crypto-compare.mjs |
| 91 | ++++ b/dist/crypto-compare-service/crypto-compare.mjs |
| 92 | +@@ -101,12 +101,14 @@ export async function fetchExchangeRate(currency, nativeCurrency, includeUSDRate |
| 93 | + * @returns Promise resolving to exchange rates for given currencies. |
| 94 | + */ |
| 95 | + export async function fetchMultiExchangeRate(fiatCurrency, cryptocurrencies, includeUSDRate) { |
| 96 | +- const url = getMultiPricingURL(cryptocurrencies, [fiatCurrency], includeUSDRate); |
| 97 | ++ const fsyms = cryptocurrencies.map((nativeCurrency) => nativeSymbolOverrides.get(nativeCurrency) ?? nativeCurrency); |
| 98 | ++ const url = getMultiPricingURL(fsyms, [fiatCurrency], includeUSDRate); |
| 99 | + const response = await handleFetch(url); |
| 100 | + handleErrorResponse(response); |
| 101 | + const rates = {}; |
| 102 | + for (const [cryptocurrency, values] of Object.entries(response)) { |
| 103 | +- rates[cryptocurrency.toLowerCase()] = { |
| 104 | ++ const key = getKeyByValue(nativeSymbolOverrides, cryptocurrency); |
| 105 | ++ rates[key?.toLowerCase() ?? cryptocurrency.toLowerCase()] = { |
| 106 | + [fiatCurrency.toLowerCase()]: values[fiatCurrency.toUpperCase()], |
| 107 | + ...(includeUSDRate && { usd: values.USD }), |
| 108 | + }; |
0 commit comments