@metamask-previews/assets-controllers 20.0.0-preview.3fbb6b41 → 23.1.0-preview.353ee83b
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 +103 -10
- package/dist/AccountTrackerController.d.ts +28 -7
- package/dist/AccountTrackerController.d.ts.map +1 -1
- package/dist/AccountTrackerController.js +104 -30
- package/dist/AccountTrackerController.js.map +1 -1
- package/dist/AssetsContractController.d.ts.map +1 -1
- package/dist/AssetsContractController.js +4 -0
- package/dist/AssetsContractController.js.map +1 -1
- package/dist/CurrencyRateController.d.ts +2 -2
- package/dist/CurrencyRateController.d.ts.map +1 -1
- package/dist/CurrencyRateController.js +1 -1
- package/dist/CurrencyRateController.js.map +1 -1
- package/dist/NftController.d.ts +75 -1
- package/dist/NftController.d.ts.map +1 -1
- package/dist/NftController.js +35 -14
- package/dist/NftController.js.map +1 -1
- package/dist/NftDetectionController.d.ts +7 -4
- package/dist/NftDetectionController.d.ts.map +1 -1
- package/dist/NftDetectionController.js +26 -14
- package/dist/NftDetectionController.js.map +1 -1
- package/dist/Standards/ERC20Standard.d.ts.map +1 -1
- package/dist/Standards/ERC20Standard.js +4 -0
- package/dist/Standards/ERC20Standard.js.map +1 -1
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts +11 -10
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts.map +1 -1
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js +106 -85
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js.map +1 -1
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.ts.map +1 -1
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.js +2 -0
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.js.map +1 -1
- package/dist/Standards/standards-types.d.ts.map +1 -1
- package/dist/Standards/standards-types.js.map +1 -1
- package/dist/TokenDetectionController.d.ts +43 -56
- package/dist/TokenDetectionController.d.ts.map +1 -1
- package/dist/TokenDetectionController.js +132 -96
- package/dist/TokenDetectionController.js.map +1 -1
- package/dist/TokenListController.d.ts +6 -4
- package/dist/TokenListController.d.ts.map +1 -1
- package/dist/TokenListController.js +11 -10
- package/dist/TokenListController.js.map +1 -1
- package/dist/TokenRatesController.d.ts +6 -38
- package/dist/TokenRatesController.d.ts.map +1 -1
- package/dist/TokenRatesController.js +125 -93
- package/dist/TokenRatesController.js.map +1 -1
- package/dist/TokensController.d.ts +5 -6
- package/dist/TokensController.d.ts.map +1 -1
- package/dist/TokensController.js +81 -21
- package/dist/TokensController.js.map +1 -1
- package/dist/assetsUtil.d.ts +80 -9
- package/dist/assetsUtil.d.ts.map +1 -1
- package/dist/assetsUtil.js +177 -27
- package/dist/assetsUtil.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/token-prices-service/abstract-token-prices-service.d.ts +15 -16
- package/dist/token-prices-service/abstract-token-prices-service.d.ts.map +1 -1
- package/dist/token-prices-service/abstract-token-prices-service.js.map +1 -1
- package/dist/token-prices-service/codefi-v2.d.ts +61 -3
- package/dist/token-prices-service/codefi-v2.d.ts.map +1 -1
- package/dist/token-prices-service/codefi-v2.js +86 -20
- package/dist/token-prices-service/codefi-v2.js.map +1 -1
- package/dist/token-prices-service/index.d.ts +1 -1
- package/dist/token-prices-service/index.js +2 -2
- package/dist/token-prices-service/index.js.map +1 -1
- package/package.json +15 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ERC721Standard.js","sourceRoot":"","sources":["../../../../src/Standards/NftStandards/ERC721/ERC721Standard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAoD;AAEpD,iEAOoC;AACpC,mEAAwD;AAExD,oDAA0D;AAE1D,MAAa,cAAc;IAGzB,YAAY,QAAsB;QAIlC;;;;;WAKG;QACH,sCAAiC,GAAG,CAClC,OAAe,EACG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AAC,CAAC;YACjE,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;KAAA;CAqFF;AAzMD,wCAyMC","sourcesContent":["import { Contract } from '@ethersproject/contracts';\nimport type { Web3Provider } from '@ethersproject/providers';\nimport {\n timeoutFetch,\n ERC721_INTERFACE_ID,\n ERC721_METADATA_INTERFACE_ID,\n ERC721_ENUMERABLE_INTERFACE_ID,\n ERC721,\n safelyExecute,\n} from '@metamask/controller-utils';\nimport { abiERC721 } from '@metamask/metamask-eth-abis';\n\nimport { getFormattedIpfsUrl } from '../../../assetsUtil';\n\nexport class ERC721Standard {\n private readonly provider: Web3Provider;\n\n constructor(provider: Web3Provider) {\n this.provider = provider;\n }\n\n /**\n * Query if contract implements ERC721Metadata interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721Metadata interface.\n */\n contractSupportsMetadataInterface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(\n address,\n ERC721_METADATA_INTERFACE_ID,\n );\n };\n\n /**\n * Query if contract implements ERC721Enumerable interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721Enumerable interface.\n */\n contractSupportsEnumerableInterface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(\n address,\n ERC721_ENUMERABLE_INTERFACE_ID,\n );\n };\n\n /**\n * Query if contract implements ERC721 interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721 interface.\n */\n contractSupportsBase721Interface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(address, ERC721_INTERFACE_ID);\n };\n\n /**\n * Enumerate assets assigned to an owner.\n *\n * @param address - ERC721 asset contract address.\n * @param selectedAddress - Current account public address.\n * @param index - An NFT counter less than `balanceOf(selectedAddress)`.\n * @returns Promise resolving to token identifier for the 'index'th asset assigned to 'selectedAddress'.\n */\n getNftTokenId = async (\n address: string,\n selectedAddress: string,\n index: number,\n ): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.tokenOfOwnerByIndex(selectedAddress, index);\n };\n\n /**\n * Query for tokenURI for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @param tokenId - ERC721 asset identifier.\n * @returns Promise resolving to the 'tokenURI'.\n */\n getTokenURI = async (address: string, tokenId: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n const supportsMetadata = await this.contractSupportsMetadataInterface(\n address,\n );\n if (!supportsMetadata) {\n throw new Error('Contract does not support ERC721 metadata interface.');\n }\n return contract.tokenURI(tokenId);\n };\n\n /**\n * Query for name for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to the 'name'.\n */\n getAssetName = async (address: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.name();\n };\n\n /**\n * Query for symbol for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to the 'symbol'.\n */\n getAssetSymbol = async (address: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.symbol();\n };\n\n /**\n * Query for owner for a given ERC721 asset.\n *\n * @param address - ERC721 asset contract address.\n * @param tokenId - ERC721 asset identifier.\n * @returns Promise resolving to the owner address.\n */\n async getOwnerOf(address: string, tokenId: string): Promise<string> {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.ownerOf(tokenId);\n }\n\n /**\n * Query if a contract implements an interface.\n *\n * @param address - Asset contract address.\n * @param interfaceId - Interface identifier.\n * @returns Promise resolving to whether the contract implements `interfaceID`.\n */\n private readonly contractSupportsInterface = async (\n address: string,\n interfaceId: string,\n ): Promise<boolean> => {\n const contract = new Contract(address, abiERC721, this.provider);\n try {\n return await contract.supportsInterface(interfaceId);\n } catch (err: any) {\n // Mirror previous implementation\n if (err.message.includes('call revert exception')) {\n return false;\n }\n throw err;\n }\n };\n\n /**\n * Query if a contract implements an interface.\n *\n * @param address - Asset contract address.\n * @param ipfsGateway - The user's preferred IPFS gateway.\n * @param tokenId - tokenId of a given token in the contract.\n * @returns Promise resolving an object containing the standard, tokenURI, symbol and name of the given contract/tokenId pair.\n */\n getDetails = async (\n address: string,\n ipfsGateway: string,\n tokenId?: string,\n ): Promise<{\n standard: string;\n tokenURI: string | undefined;\n symbol: string | undefined;\n name: string | undefined;\n image: string | undefined;\n }> => {\n const isERC721 = await this.contractSupportsBase721Interface(address);\n if (!isERC721) {\n throw new Error(\"This isn't a valid ERC721 contract\");\n }\n\n const [symbol, name, tokenURI] = await Promise.all([\n safelyExecute(() => this.getAssetSymbol(address)),\n safelyExecute(() => this.getAssetName(address)),\n tokenId\n ? safelyExecute(() =>\n this.getTokenURI(address, tokenId).then((uri) =>\n uri.startsWith('ipfs://')\n ? getFormattedIpfsUrl(ipfsGateway, uri, true)\n : uri,\n ),\n )\n : undefined,\n ]);\n\n let image;\n if (tokenURI) {\n try {\n const response = await timeoutFetch(tokenURI);\n const object = await response.json();\n image = object?.image;\n if (image?.startsWith('ipfs://')) {\n image = getFormattedIpfsUrl(ipfsGateway, image, true);\n }\n } catch {\n // ignore\n }\n }\n\n return {\n standard: ERC721,\n tokenURI,\n symbol,\n name,\n image,\n };\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ERC721Standard.js","sourceRoot":"","sources":["../../../../src/Standards/NftStandards/ERC721/ERC721Standard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAoD;AAEpD,iEAOoC;AACpC,mEAAwD;AAExD,oDAA0D;AAE1D,MAAa,cAAc;IAGzB,YAAY,QAAsB;QAIlC;;;;;WAKG;QACH,sCAAiC,GAAG,CAClC,OAAe,EACG,EAAE;YACpB,OAAO,IAAI,CAAC,yBAAyB,CACnC,OAAO,EACP,+CAA4B,CAC7B,CAAC;QACJ,CAAC,CAAA,CAAC;QAEF;;;;;WAKG;QACH,wCAAmC,GAAG,CACpC,OAAe,EACG,EAAE;YACpB,OAAO,IAAI,CAAC,yBAAyB,CACnC,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providers';\nimport {\n timeoutFetch,\n ERC721_INTERFACE_ID,\n ERC721_METADATA_INTERFACE_ID,\n ERC721_ENUMERABLE_INTERFACE_ID,\n ERC721,\n safelyExecute,\n} from '@metamask/controller-utils';\nimport { abiERC721 } from '@metamask/metamask-eth-abis';\n\nimport { getFormattedIpfsUrl } from '../../../assetsUtil';\n\nexport class ERC721Standard {\n private readonly provider: Web3Provider;\n\n constructor(provider: Web3Provider) {\n this.provider = provider;\n }\n\n /**\n * Query if contract implements ERC721Metadata interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721Metadata interface.\n */\n contractSupportsMetadataInterface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(\n address,\n ERC721_METADATA_INTERFACE_ID,\n );\n };\n\n /**\n * Query if contract implements ERC721Enumerable interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721Enumerable interface.\n */\n contractSupportsEnumerableInterface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(\n address,\n ERC721_ENUMERABLE_INTERFACE_ID,\n );\n };\n\n /**\n * Query if contract implements ERC721 interface.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to whether the contract implements ERC721 interface.\n */\n contractSupportsBase721Interface = async (\n address: string,\n ): Promise<boolean> => {\n return this.contractSupportsInterface(address, ERC721_INTERFACE_ID);\n };\n\n /**\n * Enumerate assets assigned to an owner.\n *\n * @param address - ERC721 asset contract address.\n * @param selectedAddress - Current account public address.\n * @param index - An NFT counter less than `balanceOf(selectedAddress)`.\n * @returns Promise resolving to token identifier for the 'index'th asset assigned to 'selectedAddress'.\n */\n getNftTokenId = async (\n address: string,\n selectedAddress: string,\n index: number,\n ): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.tokenOfOwnerByIndex(selectedAddress, index);\n };\n\n /**\n * Query for tokenURI for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @param tokenId - ERC721 asset identifier.\n * @returns Promise resolving to the 'tokenURI'.\n */\n getTokenURI = async (address: string, tokenId: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n const supportsMetadata = await this.contractSupportsMetadataInterface(\n address,\n );\n if (!supportsMetadata) {\n throw new Error('Contract does not support ERC721 metadata interface.');\n }\n return contract.tokenURI(tokenId);\n };\n\n /**\n * Query for name for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to the 'name'.\n */\n getAssetName = async (address: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.name();\n };\n\n /**\n * Query for symbol for a given asset.\n *\n * @param address - ERC721 asset contract address.\n * @returns Promise resolving to the 'symbol'.\n */\n getAssetSymbol = async (address: string): Promise<string> => {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.symbol();\n };\n\n /**\n * Query for owner for a given ERC721 asset.\n *\n * @param address - ERC721 asset contract address.\n * @param tokenId - ERC721 asset identifier.\n * @returns Promise resolving to the owner address.\n */\n async getOwnerOf(address: string, tokenId: string): Promise<string> {\n const contract = new Contract(address, abiERC721, this.provider);\n return contract.ownerOf(tokenId);\n }\n\n /**\n * Query if a contract implements an interface.\n *\n * @param address - Asset contract address.\n * @param interfaceId - Interface identifier.\n * @returns Promise resolving to whether the contract implements `interfaceID`.\n */\n private readonly contractSupportsInterface = async (\n address: string,\n interfaceId: string,\n ): Promise<boolean> => {\n const contract = new Contract(address, abiERC721, this.provider);\n try {\n return await contract.supportsInterface(interfaceId);\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (err: any) {\n // Mirror previous implementation\n if (err.message.includes('call revert exception')) {\n return false;\n }\n throw err;\n }\n };\n\n /**\n * Query if a contract implements an interface.\n *\n * @param address - Asset contract address.\n * @param ipfsGateway - The user's preferred IPFS gateway.\n * @param tokenId - tokenId of a given token in the contract.\n * @returns Promise resolving an object containing the standard, tokenURI, symbol and name of the given contract/tokenId pair.\n */\n getDetails = async (\n address: string,\n ipfsGateway: string,\n tokenId?: string,\n ): Promise<{\n standard: string;\n tokenURI: string | undefined;\n symbol: string | undefined;\n name: string | undefined;\n image: string | undefined;\n }> => {\n const isERC721 = await this.contractSupportsBase721Interface(address);\n if (!isERC721) {\n throw new Error(\"This isn't a valid ERC721 contract\");\n }\n\n const [symbol, name, tokenURI] = await Promise.all([\n safelyExecute(() => this.getAssetSymbol(address)),\n safelyExecute(() => this.getAssetName(address)),\n tokenId\n ? safelyExecute(() =>\n this.getTokenURI(address, tokenId).then((uri) =>\n uri.startsWith('ipfs://')\n ? getFormattedIpfsUrl(ipfsGateway, uri, true)\n : uri,\n ),\n )\n : undefined,\n ]);\n\n let image;\n if (tokenURI) {\n try {\n const response = await timeoutFetch(tokenURI);\n const object = await response.json();\n image = object?.image;\n if (image?.startsWith('ipfs://')) {\n image = getFormattedIpfsUrl(ipfsGateway, image, true);\n }\n } catch {\n // ignore\n }\n }\n\n return {\n standard: ERC721,\n tokenURI,\n symbol,\n name,\n image,\n };\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-types.d.ts","sourceRoot":"","sources":["../../src/Standards/standards-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EACV,MAAM,6BAA6B,CAAC;AAErC,aAAK,QAAQ,GAAG;
|
|
1
|
+
{"version":3,"file":"standards-types.d.ts","sourceRoot":"","sources":["../../src/Standards/standards-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EACV,MAAM,6BAA6B,CAAC;AAErC,aAAK,QAAQ,GAAG;IAGd,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;CAC1B,CAAC;AAEF,oBAAY,IAAI,GAAG;IACjB,GAAG,EAAE;QACH,IAAI,CACF,OAAO,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EACrC,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAC/C,IAAI,CAAC;QACR,QAAQ,CACN,GAAG,EAAE,OAAO,QAAQ,GAAG,OAAO,SAAS,GAAG,OAAO,UAAU,GAC1D,QAAQ,CAAC;KACb,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-types.js","sourceRoot":"","sources":["../../src/Standards/standards-types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n abiERC20,\n abiERC1155,\n abiERC721,\n} from '@metamask/metamask-eth-abis';\n\ntype Contract = {\n at(address: string): any;\n};\n\nexport type Web3 = {\n eth: {\n call(\n payload: { to: string; data: string },\n block: undefined,\n callback: (error: Error, result: string) => void,\n ): void;\n contract(\n abi: typeof abiERC20 | typeof abiERC721 | typeof abiERC1155,\n ): Contract;\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"standards-types.js","sourceRoot":"","sources":["../../src/Standards/standards-types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n abiERC20,\n abiERC1155,\n abiERC721,\n} from '@metamask/metamask-eth-abis';\n\ntype Contract = {\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n at(address: string): any;\n};\n\nexport type Web3 = {\n eth: {\n call(\n payload: { to: string; data: string },\n block: undefined,\n callback: (error: Error, result: string) => void,\n ): void;\n contract(\n abi: typeof abiERC20 | typeof abiERC721 | typeof abiERC1155,\n ): Contract;\n };\n};\n"]}
|
|
@@ -1,71 +1,66 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NetworkClientId,
|
|
3
|
-
import {
|
|
1
|
+
import type { RestrictedControllerMessenger, ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
|
|
2
|
+
import type { NetworkClientId, NetworkControllerNetworkDidChangeEvent, NetworkControllerStateChangeEvent, NetworkControllerGetNetworkConfigurationByNetworkClientId } from '@metamask/network-controller';
|
|
3
|
+
import { StaticIntervalPollingController } from '@metamask/polling-controller';
|
|
4
4
|
import type { PreferencesState } from '@metamask/preferences-controller';
|
|
5
|
-
import type { Hex } from '@metamask/utils';
|
|
6
5
|
import type { AssetsContractController } from './AssetsContractController';
|
|
7
|
-
import type {
|
|
6
|
+
import type { GetTokenListState, TokenListStateChange } from './TokenListController';
|
|
8
7
|
import type { TokensController, TokensState } from './TokensController';
|
|
8
|
+
export declare const controllerName = "TokenDetectionController";
|
|
9
|
+
export declare type TokenDetectionState = Record<never, never>;
|
|
10
|
+
export declare type TokenDetectionControllerGetStateAction = ControllerGetStateAction<typeof controllerName, TokenDetectionState>;
|
|
11
|
+
export declare type TokenDetectionControllerActions = TokenDetectionControllerGetStateAction;
|
|
12
|
+
export declare type AllowedActions = NetworkControllerGetNetworkConfigurationByNetworkClientId | GetTokenListState;
|
|
13
|
+
export declare type TokenDetectionControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, TokenDetectionState>;
|
|
14
|
+
export declare type TokenDetectionControllerEvents = TokenDetectionControllerStateChangeEvent;
|
|
15
|
+
export declare type AllowedEvents = NetworkControllerStateChangeEvent | NetworkControllerNetworkDidChangeEvent | TokenListStateChange;
|
|
16
|
+
export declare type TokenDetectionControllerMessenger = RestrictedControllerMessenger<typeof controllerName, TokenDetectionControllerActions | AllowedActions, TokenDetectionControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
9
17
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* TokenDetection configuration
|
|
13
|
-
* @property interval - Polling interval used to fetch new token rates
|
|
14
|
-
* @property selectedAddress - Vault selected address
|
|
18
|
+
* Controller that passively polls on a set interval for Tokens auto detection
|
|
19
|
+
* @property intervalId - Polling interval used to fetch new token rates
|
|
15
20
|
* @property chainId - The chain ID of the current network
|
|
21
|
+
* @property selectedAddress - Vault selected address
|
|
22
|
+
* @property networkClientId - The network client ID of the current selected network
|
|
23
|
+
* @property disabled - Boolean to track if network requests are blocked
|
|
16
24
|
* @property isDetectionEnabledFromPreferences - Boolean to track if detection is enabled from PreferencesController
|
|
17
25
|
* @property isDetectionEnabledForNetwork - Boolean to track if detected is enabled for current network
|
|
18
26
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
selectedAddress: string;
|
|
22
|
-
chainId: Hex;
|
|
23
|
-
isDetectionEnabledFromPreferences: boolean;
|
|
24
|
-
isDetectionEnabledForNetwork: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Controller that passively polls on a set interval for Tokens auto detection
|
|
28
|
-
*/
|
|
29
|
-
export declare class TokenDetectionController extends PollingControllerV1<TokenDetectionConfig, BaseState> {
|
|
30
|
-
private intervalId?;
|
|
31
|
-
/**
|
|
32
|
-
* Name of this controller used during composition
|
|
33
|
-
*/
|
|
34
|
-
name: string;
|
|
35
|
-
private readonly getBalancesInSingleCall;
|
|
36
|
-
private readonly addDetectedTokens;
|
|
37
|
-
private readonly getTokensState;
|
|
38
|
-
private readonly getTokenListState;
|
|
39
|
-
private readonly getNetworkClientById;
|
|
27
|
+
export declare class TokenDetectionController extends StaticIntervalPollingController<typeof controllerName, TokenDetectionState, TokenDetectionControllerMessenger> {
|
|
28
|
+
#private;
|
|
40
29
|
/**
|
|
41
30
|
* Creates a TokenDetectionController instance.
|
|
42
31
|
*
|
|
43
32
|
* @param options - The controller options.
|
|
33
|
+
* @param options.messenger - The controller messaging system.
|
|
34
|
+
* @param options.disabled - If set to true, all network requests are blocked.
|
|
35
|
+
* @param options.interval - Polling interval used to fetch new token rates
|
|
36
|
+
* @param options.networkClientId - The selected network client ID of the current network
|
|
37
|
+
* @param options.selectedAddress - Vault selected address
|
|
44
38
|
* @param options.onPreferencesStateChange - Allows subscribing to preferences controller state changes.
|
|
45
|
-
* @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
|
|
46
|
-
* @param options.onTokenListStateChange - Allows subscribing to token list controller state changes.
|
|
47
|
-
* @param options.getBalancesInSingleCall - Gets the balances of a list of tokens for the given address.
|
|
48
39
|
* @param options.addDetectedTokens - Add a list of detected tokens.
|
|
49
|
-
* @param options.
|
|
40
|
+
* @param options.getBalancesInSingleCall - Gets the balances of a list of tokens for the given address.
|
|
50
41
|
* @param options.getTokensState - Gets the current state of the Tokens controller.
|
|
51
|
-
* @param options.getNetworkState - Gets the state of the network controller.
|
|
52
42
|
* @param options.getPreferencesState - Gets the state of the preferences controller.
|
|
53
|
-
* @param options.getNetworkClientById - Gets the network client by ID.
|
|
54
|
-
* @param config - Initial options used to configure this controller.
|
|
55
|
-
* @param state - Initial state to set on this controller.
|
|
56
43
|
*/
|
|
57
|
-
constructor({
|
|
44
|
+
constructor({ networkClientId, selectedAddress, interval, disabled, onPreferencesStateChange, getBalancesInSingleCall, addDetectedTokens, getPreferencesState, getTokensState, messenger, }: {
|
|
45
|
+
networkClientId: NetworkClientId;
|
|
46
|
+
selectedAddress?: string;
|
|
47
|
+
interval?: number;
|
|
48
|
+
disabled?: boolean;
|
|
58
49
|
onPreferencesStateChange: (listener: (preferencesState: PreferencesState) => void) => void;
|
|
59
|
-
onNetworkStateChange: (listener: (networkState: NetworkState) => void) => void;
|
|
60
|
-
onTokenListStateChange: (listener: (tokenListState: TokenListState) => void) => void;
|
|
61
|
-
getBalancesInSingleCall: AssetsContractController['getBalancesInSingleCall'];
|
|
62
50
|
addDetectedTokens: TokensController['addDetectedTokens'];
|
|
63
|
-
|
|
51
|
+
getBalancesInSingleCall: AssetsContractController['getBalancesInSingleCall'];
|
|
64
52
|
getTokensState: () => TokensState;
|
|
65
|
-
getNetworkState: () => NetworkState;
|
|
66
53
|
getPreferencesState: () => PreferencesState;
|
|
67
|
-
|
|
68
|
-
}
|
|
54
|
+
messenger: TokenDetectionControllerMessenger;
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Allows controller to make active and passive polling requests
|
|
58
|
+
*/
|
|
59
|
+
enable(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Blocks controller from making network calls
|
|
62
|
+
*/
|
|
63
|
+
disable(): void;
|
|
69
64
|
/**
|
|
70
65
|
* Start polling for detected tokens.
|
|
71
66
|
*/
|
|
@@ -74,14 +69,6 @@ export declare class TokenDetectionController extends PollingControllerV1<TokenD
|
|
|
74
69
|
* Stop polling for detected tokens.
|
|
75
70
|
*/
|
|
76
71
|
stop(): void;
|
|
77
|
-
private stopPolling;
|
|
78
|
-
/**
|
|
79
|
-
* Starts a new polling interval.
|
|
80
|
-
*
|
|
81
|
-
* @param interval - An interval on which to poll.
|
|
82
|
-
*/
|
|
83
|
-
private startPolling;
|
|
84
|
-
private getCorrectChainId;
|
|
85
72
|
_executePoll(networkClientId: string, options: {
|
|
86
73
|
address: string;
|
|
87
74
|
}): Promise<void>;
|
|
@@ -92,7 +79,7 @@ export declare class TokenDetectionController extends PollingControllerV1<TokenD
|
|
|
92
79
|
* @param options.networkClientId - The ID of the network client to use.
|
|
93
80
|
* @param options.accountAddress - The account address to use.
|
|
94
81
|
*/
|
|
95
|
-
detectTokens(
|
|
82
|
+
detectTokens({ networkClientId, accountAddress, }?: {
|
|
96
83
|
networkClientId?: NetworkClientId;
|
|
97
84
|
accountAddress?: string;
|
|
98
85
|
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenDetectionController.d.ts","sourceRoot":"","sources":["../src/TokenDetectionController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"TokenDetectionController.d.ts","sourceRoot":"","sources":["../src/TokenDetectionController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AAKnC,OAAO,KAAK,EACV,eAAe,EACf,sCAAsC,EACtC,iCAAiC,EACjC,yDAAyD,EAC1D,MAAM,8BAA8B,CA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jB,mBAAmB,EACnB,cAAc,EACd,SAAS,GACV,EAAE;QACD,eAAe,EAAE,eAAe,CAAC;QACjC,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,wBAAwB,EAAE,CACxB,QAAQ,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,KACnD,IAAI,CAAC;QACV,iBAAiB,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QACzD,uBAAuB,EAAE,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;QAC7E,cAAc,EAAE,MAAM,WAAW,CAAC;QAClC,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;QAC5C,SAAS,EAAE,iCAAiC,CAAC;KAC9C;IA2ED;;OAEG;IACH,MAAM;IAIN;;OAEG;IACH,OAAO;IAIP;;OAEG;IACG,KAAK;IAKX;;OAEG;IACH,IAAI;IAkCE,YAAY,CAChB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC;IAUhB;;;;;;OAMG;IACG,YAAY,CAAC,EACjB,eAAe,EACf,cAAc,GACf,GAAE;QACD,eAAe,CAAC,EAAE,eAAe,CAAC;QAClC,cAAc,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,IAAI,CAAC;CAsFvB;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -8,127 +8,144 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _TokenDetectionController_instances, _TokenDetectionController_intervalId, _TokenDetectionController_chainId, _TokenDetectionController_selectedAddress, _TokenDetectionController_networkClientId, _TokenDetectionController_disabled, _TokenDetectionController_isDetectionEnabledFromPreferences, _TokenDetectionController_isDetectionEnabledForNetwork, _TokenDetectionController_addDetectedTokens, _TokenDetectionController_getBalancesInSingleCall, _TokenDetectionController_getTokensState, _TokenDetectionController_stopPolling, _TokenDetectionController_startPolling, _TokenDetectionController_getCorrectChainId;
|
|
11
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TokenDetectionController = void 0;
|
|
24
|
+
exports.TokenDetectionController = exports.controllerName = void 0;
|
|
13
25
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
14
26
|
const polling_controller_1 = require("@metamask/polling-controller");
|
|
15
27
|
const assetsUtil_1 = require("./assetsUtil");
|
|
16
28
|
const DEFAULT_INTERVAL = 180000;
|
|
29
|
+
exports.controllerName = 'TokenDetectionController';
|
|
17
30
|
/**
|
|
18
31
|
* Controller that passively polls on a set interval for Tokens auto detection
|
|
32
|
+
* @property intervalId - Polling interval used to fetch new token rates
|
|
33
|
+
* @property chainId - The chain ID of the current network
|
|
34
|
+
* @property selectedAddress - Vault selected address
|
|
35
|
+
* @property networkClientId - The network client ID of the current selected network
|
|
36
|
+
* @property disabled - Boolean to track if network requests are blocked
|
|
37
|
+
* @property isDetectionEnabledFromPreferences - Boolean to track if detection is enabled from PreferencesController
|
|
38
|
+
* @property isDetectionEnabledForNetwork - Boolean to track if detected is enabled for current network
|
|
19
39
|
*/
|
|
20
|
-
class TokenDetectionController extends polling_controller_1.
|
|
40
|
+
class TokenDetectionController extends polling_controller_1.StaticIntervalPollingController {
|
|
21
41
|
/**
|
|
22
42
|
* Creates a TokenDetectionController instance.
|
|
23
43
|
*
|
|
24
44
|
* @param options - The controller options.
|
|
45
|
+
* @param options.messenger - The controller messaging system.
|
|
46
|
+
* @param options.disabled - If set to true, all network requests are blocked.
|
|
47
|
+
* @param options.interval - Polling interval used to fetch new token rates
|
|
48
|
+
* @param options.networkClientId - The selected network client ID of the current network
|
|
49
|
+
* @param options.selectedAddress - Vault selected address
|
|
25
50
|
* @param options.onPreferencesStateChange - Allows subscribing to preferences controller state changes.
|
|
26
|
-
* @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
|
|
27
|
-
* @param options.onTokenListStateChange - Allows subscribing to token list controller state changes.
|
|
28
|
-
* @param options.getBalancesInSingleCall - Gets the balances of a list of tokens for the given address.
|
|
29
51
|
* @param options.addDetectedTokens - Add a list of detected tokens.
|
|
30
|
-
* @param options.
|
|
52
|
+
* @param options.getBalancesInSingleCall - Gets the balances of a list of tokens for the given address.
|
|
31
53
|
* @param options.getTokensState - Gets the current state of the Tokens controller.
|
|
32
|
-
* @param options.getNetworkState - Gets the state of the network controller.
|
|
33
54
|
* @param options.getPreferencesState - Gets the state of the preferences controller.
|
|
34
|
-
* @param options.getNetworkClientById - Gets the network client by ID.
|
|
35
|
-
* @param config - Initial options used to configure this controller.
|
|
36
|
-
* @param state - Initial state to set on this controller.
|
|
37
55
|
*/
|
|
38
|
-
constructor({
|
|
39
|
-
const { providerConfig: { chainId: defaultChainId }, } = getNetworkState();
|
|
56
|
+
constructor({ networkClientId, selectedAddress = '', interval = DEFAULT_INTERVAL, disabled = true, onPreferencesStateChange, getBalancesInSingleCall, addDetectedTokens, getPreferencesState, getTokensState, messenger, }) {
|
|
40
57
|
const { useTokenDetection: defaultUseTokenDetection } = getPreferencesState();
|
|
41
|
-
super(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this
|
|
50
|
-
this
|
|
51
|
-
this
|
|
52
|
-
this
|
|
53
|
-
this
|
|
54
|
-
|
|
58
|
+
super({
|
|
59
|
+
name: exports.controllerName,
|
|
60
|
+
messenger,
|
|
61
|
+
state: {},
|
|
62
|
+
metadata: {},
|
|
63
|
+
});
|
|
64
|
+
_TokenDetectionController_instances.add(this);
|
|
65
|
+
_TokenDetectionController_intervalId.set(this, void 0);
|
|
66
|
+
_TokenDetectionController_chainId.set(this, void 0);
|
|
67
|
+
_TokenDetectionController_selectedAddress.set(this, void 0);
|
|
68
|
+
_TokenDetectionController_networkClientId.set(this, void 0);
|
|
69
|
+
_TokenDetectionController_disabled.set(this, void 0);
|
|
70
|
+
_TokenDetectionController_isDetectionEnabledFromPreferences.set(this, void 0);
|
|
71
|
+
_TokenDetectionController_isDetectionEnabledForNetwork.set(this, void 0);
|
|
72
|
+
_TokenDetectionController_addDetectedTokens.set(this, void 0);
|
|
73
|
+
_TokenDetectionController_getBalancesInSingleCall.set(this, void 0);
|
|
74
|
+
_TokenDetectionController_getTokensState.set(this, void 0);
|
|
75
|
+
__classPrivateFieldSet(this, _TokenDetectionController_disabled, disabled, "f");
|
|
76
|
+
this.setIntervalLength(interval);
|
|
77
|
+
__classPrivateFieldSet(this, _TokenDetectionController_networkClientId, networkClientId, "f");
|
|
78
|
+
__classPrivateFieldSet(this, _TokenDetectionController_selectedAddress, selectedAddress, "f");
|
|
79
|
+
__classPrivateFieldSet(this, _TokenDetectionController_chainId, __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_getCorrectChainId).call(this, networkClientId), "f");
|
|
80
|
+
__classPrivateFieldSet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, defaultUseTokenDetection, "f");
|
|
81
|
+
__classPrivateFieldSet(this, _TokenDetectionController_isDetectionEnabledForNetwork, (0, assetsUtil_1.isTokenDetectionSupportedForNetwork)(__classPrivateFieldGet(this, _TokenDetectionController_chainId, "f")), "f");
|
|
82
|
+
__classPrivateFieldSet(this, _TokenDetectionController_addDetectedTokens, addDetectedTokens, "f");
|
|
83
|
+
__classPrivateFieldSet(this, _TokenDetectionController_getBalancesInSingleCall, getBalancesInSingleCall, "f");
|
|
84
|
+
__classPrivateFieldSet(this, _TokenDetectionController_getTokensState, getTokensState, "f");
|
|
85
|
+
this.messagingSystem.subscribe('TokenListController:stateChange', ({ tokenList }) => __awaiter(this, void 0, void 0, function* () {
|
|
55
86
|
const hasTokens = Object.keys(tokenList).length;
|
|
56
87
|
if (hasTokens) {
|
|
57
|
-
this.detectTokens();
|
|
88
|
+
yield this.detectTokens();
|
|
58
89
|
}
|
|
59
|
-
});
|
|
60
|
-
onPreferencesStateChange(({ selectedAddress, useTokenDetection }) => {
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
this
|
|
65
|
-
isDetectionEnabledFromPreferences: useTokenDetection,
|
|
66
|
-
selectedAddress,
|
|
67
|
-
});
|
|
90
|
+
}));
|
|
91
|
+
onPreferencesStateChange(({ selectedAddress: newSelectedAddress, useTokenDetection }) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const isSelectedAddressChanged = __classPrivateFieldGet(this, _TokenDetectionController_selectedAddress, "f") !== newSelectedAddress;
|
|
93
|
+
const isDetectionChangedFromPreferences = __classPrivateFieldGet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, "f") !== useTokenDetection;
|
|
94
|
+
__classPrivateFieldSet(this, _TokenDetectionController_selectedAddress, newSelectedAddress, "f");
|
|
95
|
+
__classPrivateFieldSet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, useTokenDetection, "f");
|
|
68
96
|
if (useTokenDetection &&
|
|
69
97
|
(isSelectedAddressChanged || isDetectionChangedFromPreferences)) {
|
|
70
|
-
this.detectTokens();
|
|
98
|
+
yield this.detectTokens();
|
|
71
99
|
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
const isChainIdChanged =
|
|
77
|
-
this
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (isDetectionEnabledForNetwork && isChainIdChanged) {
|
|
82
|
-
this.detectTokens();
|
|
100
|
+
}));
|
|
101
|
+
this.messagingSystem.subscribe('NetworkController:networkDidChange', ({ selectedNetworkClientId }) => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
__classPrivateFieldSet(this, _TokenDetectionController_networkClientId, selectedNetworkClientId, "f");
|
|
103
|
+
const newChainId = __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_getCorrectChainId).call(this, selectedNetworkClientId);
|
|
104
|
+
const isChainIdChanged = __classPrivateFieldGet(this, _TokenDetectionController_chainId, "f") !== newChainId;
|
|
105
|
+
__classPrivateFieldSet(this, _TokenDetectionController_chainId, newChainId, "f");
|
|
106
|
+
__classPrivateFieldSet(this, _TokenDetectionController_isDetectionEnabledForNetwork, (0, assetsUtil_1.isTokenDetectionSupportedForNetwork)(newChainId), "f");
|
|
107
|
+
if (__classPrivateFieldGet(this, _TokenDetectionController_isDetectionEnabledForNetwork, "f") && isChainIdChanged) {
|
|
108
|
+
yield this.detectTokens();
|
|
83
109
|
}
|
|
84
|
-
});
|
|
110
|
+
}));
|
|
85
111
|
}
|
|
86
112
|
/**
|
|
87
|
-
*
|
|
113
|
+
* Allows controller to make active and passive polling requests
|
|
88
114
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.configure({ disabled: false });
|
|
92
|
-
yield this.startPolling();
|
|
93
|
-
});
|
|
115
|
+
enable() {
|
|
116
|
+
__classPrivateFieldSet(this, _TokenDetectionController_disabled, false, "f");
|
|
94
117
|
}
|
|
95
118
|
/**
|
|
96
|
-
*
|
|
119
|
+
* Blocks controller from making network calls
|
|
97
120
|
*/
|
|
98
|
-
|
|
99
|
-
this
|
|
100
|
-
this.stopPolling();
|
|
101
|
-
}
|
|
102
|
-
stopPolling() {
|
|
103
|
-
if (this.intervalId) {
|
|
104
|
-
clearInterval(this.intervalId);
|
|
105
|
-
}
|
|
121
|
+
disable() {
|
|
122
|
+
__classPrivateFieldSet(this, _TokenDetectionController_disabled, true, "f");
|
|
106
123
|
}
|
|
107
124
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @param interval - An interval on which to poll.
|
|
125
|
+
* Start polling for detected tokens.
|
|
111
126
|
*/
|
|
112
|
-
|
|
127
|
+
start() {
|
|
113
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
yield this.detectTokens();
|
|
117
|
-
this.intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
yield this.detectTokens();
|
|
119
|
-
}), this.config.interval);
|
|
129
|
+
this.enable();
|
|
130
|
+
yield __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_startPolling).call(this);
|
|
120
131
|
});
|
|
121
132
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Stop polling for detected tokens.
|
|
135
|
+
*/
|
|
136
|
+
stop() {
|
|
137
|
+
this.disable();
|
|
138
|
+
__classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_stopPolling).call(this);
|
|
127
139
|
}
|
|
128
140
|
_executePoll(networkClientId, options) {
|
|
129
|
-
return this
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
if (__classPrivateFieldGet(this, _TokenDetectionController_disabled, "f")) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
yield this.detectTokens({
|
|
146
|
+
networkClientId,
|
|
147
|
+
accountAddress: options.address,
|
|
148
|
+
});
|
|
132
149
|
});
|
|
133
150
|
}
|
|
134
151
|
/**
|
|
@@ -138,21 +155,19 @@ class TokenDetectionController extends polling_controller_1.PollingControllerV1
|
|
|
138
155
|
* @param options.networkClientId - The ID of the network client to use.
|
|
139
156
|
* @param options.accountAddress - The account address to use.
|
|
140
157
|
*/
|
|
141
|
-
detectTokens(
|
|
158
|
+
detectTokens({ networkClientId, accountAddress, } = {}) {
|
|
142
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
!isDetectionEnabledForNetwork ||
|
|
147
|
-
!isDetectionEnabledFromPreferences) {
|
|
160
|
+
if (__classPrivateFieldGet(this, _TokenDetectionController_disabled, "f") ||
|
|
161
|
+
!__classPrivateFieldGet(this, _TokenDetectionController_isDetectionEnabledForNetwork, "f") ||
|
|
162
|
+
!__classPrivateFieldGet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, "f")) {
|
|
148
163
|
return;
|
|
149
164
|
}
|
|
150
|
-
const { tokens } = this.
|
|
151
|
-
const selectedAddress = accountAddress || this
|
|
152
|
-
const chainId = this.
|
|
165
|
+
const { tokens } = __classPrivateFieldGet(this, _TokenDetectionController_getTokensState, "f").call(this);
|
|
166
|
+
const selectedAddress = accountAddress || __classPrivateFieldGet(this, _TokenDetectionController_selectedAddress, "f");
|
|
167
|
+
const chainId = __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_getCorrectChainId).call(this, networkClientId);
|
|
153
168
|
const tokensAddresses = tokens.map(
|
|
154
169
|
/* istanbul ignore next*/ (token) => token.address.toLowerCase());
|
|
155
|
-
const { tokenList } = this.
|
|
170
|
+
const { tokenList } = this.messagingSystem.call('TokenListController:getState');
|
|
156
171
|
const tokensToDetect = [];
|
|
157
172
|
for (const address of Object.keys(tokenList)) {
|
|
158
173
|
if (!tokensAddresses.includes(address)) {
|
|
@@ -171,16 +186,17 @@ class TokenDetectionController extends polling_controller_1.PollingControllerV1
|
|
|
171
186
|
break;
|
|
172
187
|
}
|
|
173
188
|
yield (0, controller_utils_1.safelyExecute)(() => __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
|
|
189
|
+
var _a;
|
|
190
|
+
const balances = yield __classPrivateFieldGet(this, _TokenDetectionController_getBalancesInSingleCall, "f").call(this, selectedAddress, tokensSlice);
|
|
175
191
|
const tokensToAdd = [];
|
|
176
192
|
for (const tokenAddress of Object.keys(balances)) {
|
|
177
193
|
let ignored;
|
|
178
194
|
/* istanbul ignore else */
|
|
179
|
-
const { ignoredTokens } = this.
|
|
195
|
+
const { ignoredTokens } = __classPrivateFieldGet(this, _TokenDetectionController_getTokensState, "f").call(this);
|
|
180
196
|
if (ignoredTokens.length) {
|
|
181
197
|
ignored = ignoredTokens.find((ignoredTokenAddress) => ignoredTokenAddress === (0, controller_utils_1.toChecksumHexAddress)(tokenAddress));
|
|
182
198
|
}
|
|
183
|
-
const caseInsensitiveTokenKey = Object.keys(tokenList).find((i) => i.toLowerCase() === tokenAddress.toLowerCase())
|
|
199
|
+
const caseInsensitiveTokenKey = (_a = Object.keys(tokenList).find((i) => i.toLowerCase() === tokenAddress.toLowerCase())) !== null && _a !== void 0 ? _a : '';
|
|
184
200
|
if (ignored === undefined) {
|
|
185
201
|
const { decimals, symbol, aggregators, iconUrl, name } = tokenList[caseInsensitiveTokenKey];
|
|
186
202
|
tokensToAdd.push({
|
|
@@ -195,7 +211,7 @@ class TokenDetectionController extends polling_controller_1.PollingControllerV1
|
|
|
195
211
|
}
|
|
196
212
|
}
|
|
197
213
|
if (tokensToAdd.length) {
|
|
198
|
-
yield this.
|
|
214
|
+
yield __classPrivateFieldGet(this, _TokenDetectionController_addDetectedTokens, "f").call(this, tokensToAdd, {
|
|
199
215
|
selectedAddress,
|
|
200
216
|
chainId,
|
|
201
217
|
});
|
|
@@ -206,5 +222,25 @@ class TokenDetectionController extends polling_controller_1.PollingControllerV1
|
|
|
206
222
|
}
|
|
207
223
|
}
|
|
208
224
|
exports.TokenDetectionController = TokenDetectionController;
|
|
225
|
+
_TokenDetectionController_intervalId = new WeakMap(), _TokenDetectionController_chainId = new WeakMap(), _TokenDetectionController_selectedAddress = new WeakMap(), _TokenDetectionController_networkClientId = new WeakMap(), _TokenDetectionController_disabled = new WeakMap(), _TokenDetectionController_isDetectionEnabledFromPreferences = new WeakMap(), _TokenDetectionController_isDetectionEnabledForNetwork = new WeakMap(), _TokenDetectionController_addDetectedTokens = new WeakMap(), _TokenDetectionController_getBalancesInSingleCall = new WeakMap(), _TokenDetectionController_getTokensState = new WeakMap(), _TokenDetectionController_instances = new WeakSet(), _TokenDetectionController_stopPolling = function _TokenDetectionController_stopPolling() {
|
|
226
|
+
if (__classPrivateFieldGet(this, _TokenDetectionController_intervalId, "f")) {
|
|
227
|
+
clearInterval(__classPrivateFieldGet(this, _TokenDetectionController_intervalId, "f"));
|
|
228
|
+
}
|
|
229
|
+
}, _TokenDetectionController_startPolling = function _TokenDetectionController_startPolling() {
|
|
230
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
+
if (__classPrivateFieldGet(this, _TokenDetectionController_disabled, "f")) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
__classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_stopPolling).call(this);
|
|
235
|
+
yield this.detectTokens();
|
|
236
|
+
__classPrivateFieldSet(this, _TokenDetectionController_intervalId, setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
yield this.detectTokens();
|
|
238
|
+
}), this.getIntervalLength()), "f");
|
|
239
|
+
});
|
|
240
|
+
}, _TokenDetectionController_getCorrectChainId = function _TokenDetectionController_getCorrectChainId(networkClientId) {
|
|
241
|
+
var _a;
|
|
242
|
+
const { chainId } = (_a = this.messagingSystem.call('NetworkController:getNetworkConfigurationByNetworkClientId', networkClientId !== null && networkClientId !== void 0 ? networkClientId : __classPrivateFieldGet(this, _TokenDetectionController_networkClientId, "f"))) !== null && _a !== void 0 ? _a : {};
|
|
243
|
+
return chainId !== null && chainId !== void 0 ? chainId : __classPrivateFieldGet(this, _TokenDetectionController_chainId, "f");
|
|
244
|
+
};
|
|
209
245
|
exports.default = TokenDetectionController;
|
|
210
246
|
//# sourceMappingURL=TokenDetectionController.js.map
|