Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch mantle price fix #29789

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .yarn/patches/@metamask-assets-controllers-patch-d114308c1b.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
diff --git a/dist/assetsUtil.cjs b/dist/assetsUtil.cjs
index 61246f51500c8cab48f18296a73629fb73454caa..34396ba143e3ebcb04fa2c80f7a35d1abd06710e 100644
--- a/dist/assetsUtil.cjs
+++ b/dist/assetsUtil.cjs
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
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; } }
-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;
+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;
const controller_utils_1 = require("@metamask/controller-utils");
const utils_1 = require("@metamask/utils");
const bn_js_1 = __importDefault(require("bn.js"));
@@ -368,4 +368,19 @@ async function fetchTokenContractExchangeRates({ tokenPricesService, nativeCurre
}, {});
}
exports.fetchTokenContractExchangeRates = fetchTokenContractExchangeRates;
+/**
+ * Function to search for a specific value in a given map and return the key
+ * @param map - map input to search value
+ * @param value - the value to search for
+ * @returns returns key that corresponds to the value
+ */
+function getKeyByValue(map, value) {
+ for (const [key, val] of map.entries()) {
+ if (val === value) {
+ return key;
+ }
+ }
+ return null; // Return null if no match is found
+}
+exports.getKeyByValue = getKeyByValue;
//# sourceMappingURL=assetsUtil.cjs.map
\ No newline at end of file
diff --git a/dist/assetsUtil.mjs b/dist/assetsUtil.mjs
index 1e14797c8e1cd48e75287b37c29eb6065daac5e6..c288b56227bd7779982083be4cae9674d01ae1dd 100644
--- a/dist/assetsUtil.mjs
+++ b/dist/assetsUtil.mjs
@@ -354,4 +354,18 @@ export async function fetchTokenContractExchangeRates({ tokenPricesService, nati
};
}, {});
}
+/**
+ * Function to search for a specific value in a given map and return the key
+ * @param map - map input to search value
+ * @param value - the value to search for
+ * @returns returns key that corresponds to the value
+ */
+export function getKeyByValue(map, value) {
+ for (const [key, val] of map.entries()) {
+ if (val === value) {
+ return key;
+ }
+ }
+ return null; // Return null if no match is found
+}
//# sourceMappingURL=assetsUtil.mjs.map
\ No newline at end of file
diff --git a/dist/crypto-compare-service/crypto-compare.cjs b/dist/crypto-compare-service/crypto-compare.cjs
index 4cdf9c15053fb4acbc8aa7cade912e87c7aaf224..4d778fceaae35936ce90370ffd62346c8863ffdd 100644
--- a/dist/crypto-compare-service/crypto-compare.cjs
+++ b/dist/crypto-compare-service/crypto-compare.cjs
@@ -105,12 +105,14 @@ exports.fetchExchangeRate = fetchExchangeRate;
* @returns Promise resolving to exchange rates for given currencies.
*/
async function fetchMultiExchangeRate(fiatCurrency, cryptocurrencies, includeUSDRate) {
- const url = getMultiPricingURL(cryptocurrencies, [fiatCurrency], includeUSDRate);
+ const fsyms = cryptocurrencies.map((nativeCurrency) => nativeSymbolOverrides.get(nativeCurrency) ?? nativeCurrency);
+ const url = getMultiPricingURL(fsyms, [fiatCurrency], includeUSDRate);
const response = await (0, controller_utils_1.handleFetch)(url);
handleErrorResponse(response);
const rates = {};
for (const [cryptocurrency, values] of Object.entries(response)) {
- rates[cryptocurrency.toLowerCase()] = {
+ const key = (0, assetsUtil_1.getKeyByValue)(nativeSymbolOverrides, cryptocurrency);
+ rates[key?.toLowerCase() ?? cryptocurrency.toLowerCase()] = {
[fiatCurrency.toLowerCase()]: values[fiatCurrency.toUpperCase()],
...(includeUSDRate && { usd: values.USD }),
};
diff --git a/dist/crypto-compare-service/crypto-compare.mjs b/dist/crypto-compare-service/crypto-compare.mjs
index 58db2280159669c1b48fb94a9164b8e0be2850a7..231c099452cd7faf8838690c19f2c4be51fa4cd2 100644
--- a/dist/crypto-compare-service/crypto-compare.mjs
+++ b/dist/crypto-compare-service/crypto-compare.mjs
@@ -1,4 +1,5 @@
import { handleFetch } from "@metamask/controller-utils";
+import { getKeyByValue } from "../assetsUtil.mjs";
/**
* A map from native currency symbol to CryptoCompare identifier.
* This is only needed when the values don't match.
@@ -101,12 +102,14 @@ export async function fetchExchangeRate(currency, nativeCurrency, includeUSDRate
* @returns Promise resolving to exchange rates for given currencies.
*/
export async function fetchMultiExchangeRate(fiatCurrency, cryptocurrencies, includeUSDRate) {
- const url = getMultiPricingURL(cryptocurrencies, [fiatCurrency], includeUSDRate);
+ const fsyms = cryptocurrencies.map((nativeCurrency) => nativeSymbolOverrides.get(nativeCurrency) ?? nativeCurrency);
+ const url = getMultiPricingURL(fsyms, [fiatCurrency], includeUSDRate);
const response = await handleFetch(url);
handleErrorResponse(response);
const rates = {};
for (const [cryptocurrency, values] of Object.entries(response)) {
- rates[cryptocurrency.toLowerCase()] = {
+ const key = getKeyByValue(nativeSymbolOverrides, cryptocurrency);
+ rates[key?.toLowerCase() ?? cryptocurrency.toLowerCase()] = {
[fiatCurrency.toLowerCase()]: values[fiatCurrency.toUpperCase()],
...(includeUSDRate && { usd: values.USD }),
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
"@metamask/address-book-controller": "^6.0.0",
"@metamask/announcement-controller": "^7.0.0",
"@metamask/approval-controller": "^7.0.0",
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A45.1.0%23~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%3A%3Aversion=45.1.0&hash=cfcadc#~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch",
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@patch%253A@metamask/assets-controllers@npm%25253A45.1.0%2523~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%253A%253Aversion=45.1.0&hash=cfcadc%23~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch%3A%3Aversion=45.1.0&hash=4e79dd#~/.yarn/patches/@metamask-assets-controllers-patch-d114308c1b.patch",
"@metamask/base-controller": "^7.0.0",
"@metamask/bitcoin-wallet-snap": "^0.8.2",
"@metamask/browser-passworder": "^4.3.0",
Expand Down
43 changes: 41 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5032,7 +5032,7 @@ __metadata:
languageName: node
linkType: hard

"@metamask/assets-controllers@patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A45.1.0%23~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%3A%3Aversion=45.1.0&hash=cfcadc#~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch":
"@metamask/assets-controllers@patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A45.1.0%23~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%3A%3Aversion=45.1.0&hash=cfcadc#~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch::version=45.1.0&hash=4e79dd":
version: 45.1.0
resolution: "@metamask/assets-controllers@patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A45.1.0%23~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%3A%3Aversion=45.1.0&hash=cfcadc#~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch::version=45.1.0&hash=4e79dd"
dependencies:
Expand Down Expand Up @@ -5071,6 +5071,45 @@ __metadata:
languageName: node
linkType: hard

"@metamask/assets-controllers@patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@patch%253A@metamask/assets-controllers@npm%25253A45.1.0%2523~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%253A%253Aversion=45.1.0&hash=cfcadc%23~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch%3A%3Aversion=45.1.0&hash=4e79dd#~/.yarn/patches/@metamask-assets-controllers-patch-d114308c1b.patch":
version: 45.1.0
resolution: "@metamask/assets-controllers@patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@patch%253A@metamask/assets-controllers@npm%25253A45.1.0%2523~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%253A%253Aversion=45.1.0&hash=cfcadc%23~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch%3A%3Aversion=45.1.0&hash=4e79dd#~/.yarn/patches/@metamask-assets-controllers-patch-d114308c1b.patch::version=45.1.0&hash=d31b84"
dependencies:
"@ethereumjs/util": "npm:^8.1.0"
"@ethersproject/abi": "npm:^5.7.0"
"@ethersproject/address": "npm:^5.7.0"
"@ethersproject/bignumber": "npm:^5.7.0"
"@ethersproject/contracts": "npm:^5.7.0"
"@ethersproject/providers": "npm:^5.7.0"
"@metamask/abi-utils": "npm:^2.0.3"
"@metamask/base-controller": "npm:^7.0.2"
"@metamask/contract-metadata": "npm:^2.4.0"
"@metamask/controller-utils": "npm:^11.4.3"
"@metamask/eth-query": "npm:^4.0.0"
"@metamask/metamask-eth-abis": "npm:^3.1.1"
"@metamask/polling-controller": "npm:^12.0.1"
"@metamask/rpc-errors": "npm:^7.0.1"
"@metamask/utils": "npm:^10.0.0"
"@types/bn.js": "npm:^5.1.5"
"@types/uuid": "npm:^8.3.0"
async-mutex: "npm:^0.5.0"
bn.js: "npm:^5.2.1"
cockatiel: "npm:^3.1.2"
immer: "npm:^9.0.6"
lodash: "npm:^4.17.21"
multiformats: "npm:^13.1.0"
single-call-balance-checker-abi: "npm:^1.0.0"
uuid: "npm:^8.3.2"
peerDependencies:
"@metamask/accounts-controller": ^20.0.0
"@metamask/approval-controller": ^7.0.0
"@metamask/keyring-controller": ^19.0.0
"@metamask/network-controller": ^22.0.0
"@metamask/preferences-controller": ^15.0.0
checksum: 10/01019ce997fa4654e410ea4d469c16d5711a5103b71e063151f916eb1cdba88391c3726104e5bf77e65f45821fa86c318ab08c1347f9cf8c95caa388ca24ab34
languageName: node
linkType: hard

"@metamask/auto-changelog@npm:^2.1.0":
version: 2.6.1
resolution: "@metamask/auto-changelog@npm:2.6.1"
Expand Down Expand Up @@ -26623,7 +26662,7 @@ __metadata:
"@metamask/announcement-controller": "npm:^7.0.0"
"@metamask/api-specs": "npm:^0.9.3"
"@metamask/approval-controller": "npm:^7.0.0"
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@npm%253A45.1.0%23~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%3A%3Aversion=45.1.0&hash=cfcadc#~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch"
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@patch%253A@metamask/assets-controllers@npm%25253A45.1.0%2523~/.yarn/patches/@metamask-assets-controllers-npm-45.1.0-d914c453f0.patch%253A%253Aversion=45.1.0&hash=cfcadc%23~/.yarn/patches/@metamask-assets-controllers-patch-d6ed5f8213.patch%3A%3Aversion=45.1.0&hash=4e79dd#~/.yarn/patches/@metamask-assets-controllers-patch-d114308c1b.patch"
"@metamask/auto-changelog": "npm:^2.1.0"
"@metamask/base-controller": "npm:^7.0.0"
"@metamask/bitcoin-wallet-snap": "npm:^0.8.2"
Expand Down
Loading