-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: multichain token autodetection
- Loading branch information
Showing
20 changed files
with
541 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.yarn/patches/@metamask-assets-controllers-npm-44.1.0-012aa448d8.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
diff --git a/dist/assetsUtil.cjs b/dist/assetsUtil.cjs | ||
index 48571b8c1b78e94d88e1837e986b5f8735ac651b..61246f51500c8cab48f18296a73629fb73454caa 100644 | ||
--- a/dist/assetsUtil.cjs | ||
+++ b/dist/assetsUtil.cjs | ||
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": 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; | ||
const controller_utils_1 = require("@metamask/controller-utils"); | ||
const utils_1 = require("@metamask/utils"); | ||
@@ -233,7 +234,7 @@ async function getIpfsCIDv1AndPath(ipfsUrl) { | ||
const index = url.indexOf('/'); | ||
const cid = index !== -1 ? url.substring(0, index) : url; | ||
const path = index !== -1 ? url.substring(index) : undefined; | ||
- const { CID } = await import("multiformats"); | ||
+ const { CID } = _interopRequireWildcard(require("multiformats")); | ||
// We want to ensure that the CID is v1 (https://docs.ipfs.io/concepts/content-addressing/#identifier-formats) | ||
// because most cid v0s appear to be incompatible with IPFS subdomains | ||
return { | ||
diff --git a/dist/token-prices-service/codefi-v2.mjs b/dist/token-prices-service/codefi-v2.mjs | ||
index e7eaad2cfa8b233c4fd42a51f745233a1cc5c387..bf8ec7819f678c2f185d6a85d7e3ea81f055a309 100644 | ||
--- a/dist/token-prices-service/codefi-v2.mjs | ||
+++ b/dist/token-prices-service/codefi-v2.mjs | ||
@@ -12,8 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function ( | ||
var _CodefiTokenPricesServiceV2_tokenPricePolicy; | ||
import { handleFetch } from "@metamask/controller-utils"; | ||
import { hexToNumber } from "@metamask/utils"; | ||
-import $cockatiel from "cockatiel"; | ||
-const { circuitBreaker, ConsecutiveBreaker, ExponentialBackoff, handleAll, retry, wrap, CircuitState } = $cockatiel; | ||
+import { circuitBreaker, ConsecutiveBreaker, ExponentialBackoff, handleAll, retry, wrap, CircuitState } from "cockatiel" | ||
/** | ||
* The list of currencies that can be supplied as the `vsCurrency` parameter to | ||
* the `/spot-prices` endpoint, in lowercase form. | ||
diff --git a/dist/TokenDetectionController.cjs b/dist/TokenDetectionController.cjs | ||
index 8fd5efde7a3c24080f8a43f79d10300e8c271245..a3c334ac7dd2e5698e6b54a73491b7145c2a9010 100644 | ||
--- a/dist/TokenDetectionController.cjs | ||
+++ b/dist/TokenDetectionController.cjs | ||
@@ -250,17 +250,20 @@ _TokenDetectionController_intervalId = new WeakMap(), _TokenDetectionController_ | ||
} | ||
}); | ||
this.messagingSystem.subscribe('AccountsController:selectedEvmAccountChange', | ||
- // TODO: Either fix this lint violation or explain why it's necessary to ignore. | ||
- // eslint-disable-next-line @typescript-eslint/no-misused-promises | ||
- async (selectedAccount) => { | ||
- const isSelectedAccountIdChanged = __classPrivateFieldGet(this, _TokenDetectionController_selectedAccountId, "f") !== selectedAccount.id; | ||
- if (isSelectedAccountIdChanged) { | ||
- __classPrivateFieldSet(this, _TokenDetectionController_selectedAccountId, selectedAccount.id, "f"); | ||
- await __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_restartTokenDetection).call(this, { | ||
- selectedAddress: selectedAccount.address, | ||
- }); | ||
- } | ||
- }); | ||
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore. | ||
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises | ||
+ async (selectedAccount) => { | ||
+ const { networkConfigurationsByChainId } = this.messagingSystem.call('NetworkController:getState'); | ||
+ const chainIds = Object.keys(networkConfigurationsByChainId); | ||
+ const isSelectedAccountIdChanged = __classPrivateFieldGet(this, _TokenDetectionController_selectedAccountId, "f") !== selectedAccount.id; | ||
+ if (isSelectedAccountIdChanged) { | ||
+ __classPrivateFieldSet(this, _TokenDetectionController_selectedAccountId, selectedAccount.id, "f"); | ||
+ await __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_restartTokenDetection).call(this, { | ||
+ selectedAddress: selectedAccount.address, | ||
+ chainIds, | ||
+ }); | ||
+ } | ||
+ }); | ||
}, _TokenDetectionController_stopPolling = function _TokenDetectionController_stopPolling() { | ||
if (__classPrivateFieldGet(this, _TokenDetectionController_intervalId, "f")) { | ||
clearInterval(__classPrivateFieldGet(this, _TokenDetectionController_intervalId, "f")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.