@metamask/assets-controllers 25.0.0 → 27.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.
Files changed (235) hide show
  1. package/CHANGELOG.md +210 -39
  2. package/dist/AccountTrackerController.js +9 -236
  3. package/dist/AccountTrackerController.js.map +1 -1
  4. package/dist/AccountTrackerController.mjs +10 -0
  5. package/dist/AccountTrackerController.mjs.map +1 -0
  6. package/dist/AssetsContractController.js +17 -385
  7. package/dist/AssetsContractController.js.map +1 -1
  8. package/dist/AssetsContractController.mjs +18 -0
  9. package/dist/AssetsContractController.mjs.map +1 -0
  10. package/dist/CurrencyRateController.js +10 -157
  11. package/dist/CurrencyRateController.js.map +1 -1
  12. package/dist/CurrencyRateController.mjs +11 -0
  13. package/dist/CurrencyRateController.mjs.map +1 -0
  14. package/dist/NftController.js +15 -1039
  15. package/dist/NftController.js.map +1 -1
  16. package/dist/NftController.mjs +16 -0
  17. package/dist/NftController.mjs.map +1 -0
  18. package/dist/NftDetectionController.js +12 -215
  19. package/dist/NftDetectionController.js.map +1 -1
  20. package/dist/NftDetectionController.mjs +13 -0
  21. package/dist/NftDetectionController.mjs.map +1 -0
  22. package/dist/Standards/ERC20Standard.js +8 -144
  23. package/dist/Standards/ERC20Standard.js.map +1 -1
  24. package/dist/Standards/ERC20Standard.mjs +9 -0
  25. package/dist/Standards/ERC20Standard.mjs.map +1 -0
  26. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js +8 -217
  27. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js.map +1 -1
  28. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.mjs +9 -0
  29. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.mjs.map +1 -0
  30. package/dist/Standards/NftStandards/ERC721/ERC721Standard.js +8 -175
  31. package/dist/Standards/NftStandards/ERC721/ERC721Standard.js.map +1 -1
  32. package/dist/Standards/NftStandards/ERC721/ERC721Standard.mjs +9 -0
  33. package/dist/Standards/NftStandards/ERC721/ERC721Standard.mjs.map +1 -0
  34. package/dist/TokenBalancesController.js +11 -144
  35. package/dist/TokenBalancesController.js.map +1 -1
  36. package/dist/TokenBalancesController.mjs +12 -0
  37. package/dist/TokenBalancesController.mjs.map +1 -0
  38. package/dist/TokenDetectionController.js +16 -245
  39. package/dist/TokenDetectionController.js.map +1 -1
  40. package/dist/TokenDetectionController.mjs +17 -0
  41. package/dist/TokenDetectionController.mjs.map +1 -0
  42. package/dist/TokenListController.js +13 -250
  43. package/dist/TokenListController.js.map +1 -1
  44. package/dist/TokenListController.mjs +14 -0
  45. package/dist/TokenListController.mjs.map +1 -0
  46. package/dist/TokenRatesController.js +11 -328
  47. package/dist/TokenRatesController.js.map +1 -1
  48. package/dist/TokenRatesController.mjs +12 -0
  49. package/dist/TokenRatesController.mjs.map +1 -0
  50. package/dist/TokensController.js +15 -636
  51. package/dist/TokensController.js.map +1 -1
  52. package/dist/TokensController.mjs +16 -0
  53. package/dist/TokensController.mjs.map +1 -0
  54. package/dist/assetsUtil.js +41 -380
  55. package/dist/assetsUtil.js.map +1 -1
  56. package/dist/assetsUtil.mjs +42 -0
  57. package/dist/assetsUtil.mjs.map +1 -0
  58. package/dist/chunk-23F5W3A2.mjs +157 -0
  59. package/dist/chunk-23F5W3A2.mjs.map +1 -0
  60. package/dist/chunk-27KOXCQK.mjs +1 -0
  61. package/dist/chunk-27KOXCQK.mjs.map +1 -0
  62. package/dist/chunk-3FMWI46J.mjs +361 -0
  63. package/dist/chunk-3FMWI46J.mjs.map +1 -0
  64. package/dist/chunk-3FOTFZIL.mjs +411 -0
  65. package/dist/chunk-3FOTFZIL.mjs.map +1 -0
  66. package/dist/chunk-4LY47RPI.mjs +139 -0
  67. package/dist/chunk-4LY47RPI.mjs.map +1 -0
  68. package/dist/chunk-5C7ZVZNM.mjs +267 -0
  69. package/dist/chunk-5C7ZVZNM.mjs.map +1 -0
  70. package/dist/chunk-64EHFYLM.mjs +245 -0
  71. package/dist/chunk-64EHFYLM.mjs.map +1 -0
  72. package/dist/chunk-6C2ZIK7A.js +245 -0
  73. package/dist/chunk-6C2ZIK7A.js.map +1 -0
  74. package/dist/chunk-6DTCHPBB.mjs +178 -0
  75. package/dist/chunk-6DTCHPBB.mjs.map +1 -0
  76. package/dist/chunk-74IP34EL.js +1177 -0
  77. package/dist/chunk-74IP34EL.js.map +1 -0
  78. package/dist/chunk-BZI7P3TD.js +115 -0
  79. package/dist/chunk-BZI7P3TD.js.map +1 -0
  80. package/dist/chunk-C4PQK53K.js +32 -0
  81. package/dist/chunk-C4PQK53K.js.map +1 -0
  82. package/dist/chunk-CP3HC7AQ.mjs +12 -0
  83. package/dist/chunk-CP3HC7AQ.mjs.map +1 -0
  84. package/dist/chunk-GHZX5DE4.js +215 -0
  85. package/dist/chunk-GHZX5DE4.js.map +1 -0
  86. package/dist/chunk-GMKIOYCB.js +361 -0
  87. package/dist/chunk-GMKIOYCB.js.map +1 -0
  88. package/dist/chunk-H6TOSWUM.js +157 -0
  89. package/dist/chunk-H6TOSWUM.js.map +1 -0
  90. package/dist/chunk-HWFBJFHS.js +284 -0
  91. package/dist/chunk-HWFBJFHS.js.map +1 -0
  92. package/dist/chunk-J2JQQNHN.mjs +115 -0
  93. package/dist/chunk-J2JQQNHN.mjs.map +1 -0
  94. package/dist/chunk-J6HPEQL3.mjs +704 -0
  95. package/dist/chunk-J6HPEQL3.mjs.map +1 -0
  96. package/dist/chunk-JC4WAN2J.mjs +1177 -0
  97. package/dist/chunk-JC4WAN2J.mjs.map +1 -0
  98. package/dist/chunk-LD4GC7OR.js +139 -0
  99. package/dist/chunk-LD4GC7OR.js.map +1 -0
  100. package/dist/chunk-NG2UOKDD.js +178 -0
  101. package/dist/chunk-NG2UOKDD.js.map +1 -0
  102. package/dist/chunk-NGIXA5M5.mjs +418 -0
  103. package/dist/chunk-NGIXA5M5.mjs.map +1 -0
  104. package/dist/chunk-NLNXQHAU.js +704 -0
  105. package/dist/chunk-NLNXQHAU.js.map +1 -0
  106. package/dist/chunk-OBUR4TXH.js +1 -0
  107. package/dist/chunk-OBUR4TXH.js.map +1 -0
  108. package/dist/chunk-PAJTKWEC.mjs +246 -0
  109. package/dist/chunk-PAJTKWEC.mjs.map +1 -0
  110. package/dist/chunk-PRIXT2R6.js +411 -0
  111. package/dist/chunk-PRIXT2R6.js.map +1 -0
  112. package/dist/chunk-PUFSYRJZ.js +74 -0
  113. package/dist/chunk-PUFSYRJZ.js.map +1 -0
  114. package/dist/chunk-QHRPRO5U.mjs +74 -0
  115. package/dist/chunk-QHRPRO5U.mjs.map +1 -0
  116. package/dist/chunk-QR4CX2JT.mjs +284 -0
  117. package/dist/chunk-QR4CX2JT.mjs.map +1 -0
  118. package/dist/chunk-RGHTNZQ6.js +12 -0
  119. package/dist/chunk-RGHTNZQ6.js.map +1 -0
  120. package/dist/chunk-TCO22VIO.mjs +32 -0
  121. package/dist/chunk-TCO22VIO.mjs.map +1 -0
  122. package/dist/chunk-TDKCVCGP.mjs +215 -0
  123. package/dist/chunk-TDKCVCGP.mjs.map +1 -0
  124. package/dist/chunk-UAH5YURZ.js +343 -0
  125. package/dist/chunk-UAH5YURZ.js.map +1 -0
  126. package/dist/chunk-V4ZO3F2S.js +246 -0
  127. package/dist/chunk-V4ZO3F2S.js.map +1 -0
  128. package/dist/chunk-VDJBJAUB.js +418 -0
  129. package/dist/chunk-VDJBJAUB.js.map +1 -0
  130. package/dist/chunk-WRQ7POD7.mjs +343 -0
  131. package/dist/chunk-WRQ7POD7.mjs.map +1 -0
  132. package/dist/chunk-XUI43LEZ.mjs +30 -0
  133. package/dist/chunk-XUI43LEZ.mjs.map +1 -0
  134. package/dist/chunk-YD3NRMFC.js +267 -0
  135. package/dist/chunk-YD3NRMFC.js.map +1 -0
  136. package/dist/chunk-Z4BLTVTB.js +30 -0
  137. package/dist/chunk-Z4BLTVTB.js.map +1 -0
  138. package/dist/constants.js +7 -9
  139. package/dist/constants.js.map +1 -1
  140. package/dist/constants.mjs +8 -0
  141. package/dist/constants.mjs.map +1 -0
  142. package/dist/crypto-compare.js +7 -66
  143. package/dist/crypto-compare.js.map +1 -1
  144. package/dist/crypto-compare.mjs +8 -0
  145. package/dist/crypto-compare.mjs.map +1 -0
  146. package/dist/index.js +72 -36
  147. package/dist/index.js.map +1 -1
  148. package/dist/index.mjs +73 -0
  149. package/dist/index.mjs.map +1 -0
  150. package/dist/token-prices-service/abstract-token-prices-service.js +1 -3
  151. package/dist/token-prices-service/abstract-token-prices-service.js.map +1 -1
  152. package/dist/token-prices-service/abstract-token-prices-service.mjs +1 -0
  153. package/dist/token-prices-service/abstract-token-prices-service.mjs.map +1 -0
  154. package/dist/token-prices-service/codefi-v2.js +11 -353
  155. package/dist/token-prices-service/codefi-v2.js.map +1 -1
  156. package/dist/token-prices-service/codefi-v2.mjs +12 -0
  157. package/dist/token-prices-service/codefi-v2.mjs.map +1 -0
  158. package/dist/token-prices-service/index.js +8 -5
  159. package/dist/token-prices-service/index.js.map +1 -1
  160. package/dist/token-prices-service/index.mjs +9 -0
  161. package/dist/token-prices-service/index.mjs.map +1 -0
  162. package/dist/token-service.js +14 -133
  163. package/dist/token-service.js.map +1 -1
  164. package/dist/token-service.mjs +15 -0
  165. package/dist/token-service.mjs.map +1 -0
  166. package/dist/tsconfig.build.tsbuildinfo +1 -0
  167. package/dist/types/AccountTrackerController.d.ts.map +1 -0
  168. package/dist/{AssetsContractController.d.ts → types/AssetsContractController.d.ts} +5 -6
  169. package/dist/types/AssetsContractController.d.ts.map +1 -0
  170. package/dist/types/CurrencyRateController.d.ts.map +1 -0
  171. package/dist/types/NftController.d.ts.map +1 -0
  172. package/dist/types/NftDetectionController.d.ts.map +1 -0
  173. package/dist/{Standards → types/Standards}/ERC20Standard.d.ts +1 -2
  174. package/dist/types/Standards/ERC20Standard.d.ts.map +1 -0
  175. package/dist/{Standards → types/Standards}/NftStandards/ERC1155/ERC1155Standard.d.ts +1 -2
  176. package/dist/types/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts.map +1 -0
  177. package/dist/types/Standards/NftStandards/ERC721/ERC721Standard.d.ts.map +1 -0
  178. package/dist/{TokenBalancesController.d.ts → types/TokenBalancesController.d.ts} +12 -10
  179. package/dist/types/TokenBalancesController.d.ts.map +1 -0
  180. package/dist/types/TokenDetectionController.d.ts +111 -0
  181. package/dist/types/TokenDetectionController.d.ts.map +1 -0
  182. package/dist/types/TokenListController.d.ts.map +1 -0
  183. package/dist/types/TokenRatesController.d.ts.map +1 -0
  184. package/dist/{TokensController.d.ts → types/TokensController.d.ts} +26 -19
  185. package/dist/types/TokensController.d.ts.map +1 -0
  186. package/dist/{assetsUtil.d.ts → types/assetsUtil.d.ts} +1 -2
  187. package/dist/types/assetsUtil.d.ts.map +1 -0
  188. package/dist/types/constants.d.ts.map +1 -0
  189. package/dist/types/crypto-compare.d.ts.map +1 -0
  190. package/dist/{index.d.ts → types/index.d.ts} +6 -3
  191. package/dist/types/index.d.ts.map +1 -0
  192. package/dist/types/token-prices-service/abstract-token-prices-service.d.ts.map +1 -0
  193. package/dist/types/token-prices-service/codefi-v2.d.ts.map +1 -0
  194. package/dist/types/token-prices-service/index.d.ts.map +1 -0
  195. package/dist/types/token-service.d.ts.map +1 -0
  196. package/package.json +30 -13
  197. package/dist/AccountTrackerController.d.ts.map +0 -1
  198. package/dist/AssetsContractController.d.ts.map +0 -1
  199. package/dist/CurrencyRateController.d.ts.map +0 -1
  200. package/dist/NftController.d.ts.map +0 -1
  201. package/dist/NftDetectionController.d.ts.map +0 -1
  202. package/dist/Standards/ERC20Standard.d.ts.map +0 -1
  203. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts.map +0 -1
  204. package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.ts.map +0 -1
  205. package/dist/Standards/standards-types.d.ts +0 -15
  206. package/dist/Standards/standards-types.d.ts.map +0 -1
  207. package/dist/Standards/standards-types.js +0 -3
  208. package/dist/Standards/standards-types.js.map +0 -1
  209. package/dist/TokenBalancesController.d.ts.map +0 -1
  210. package/dist/TokenDetectionController.d.ts +0 -88
  211. package/dist/TokenDetectionController.d.ts.map +0 -1
  212. package/dist/TokenListController.d.ts.map +0 -1
  213. package/dist/TokenRatesController.d.ts.map +0 -1
  214. package/dist/TokensController.d.ts.map +0 -1
  215. package/dist/assetsUtil.d.ts.map +0 -1
  216. package/dist/constants.d.ts.map +0 -1
  217. package/dist/crypto-compare.d.ts.map +0 -1
  218. package/dist/index.d.ts.map +0 -1
  219. package/dist/token-prices-service/abstract-token-prices-service.d.ts.map +0 -1
  220. package/dist/token-prices-service/codefi-v2.d.ts.map +0 -1
  221. package/dist/token-prices-service/index.d.ts.map +0 -1
  222. package/dist/token-service.d.ts.map +0 -1
  223. /package/dist/{AccountTrackerController.d.ts → types/AccountTrackerController.d.ts} +0 -0
  224. /package/dist/{CurrencyRateController.d.ts → types/CurrencyRateController.d.ts} +0 -0
  225. /package/dist/{NftController.d.ts → types/NftController.d.ts} +0 -0
  226. /package/dist/{NftDetectionController.d.ts → types/NftDetectionController.d.ts} +0 -0
  227. /package/dist/{Standards → types/Standards}/NftStandards/ERC721/ERC721Standard.d.ts +0 -0
  228. /package/dist/{TokenListController.d.ts → types/TokenListController.d.ts} +0 -0
  229. /package/dist/{TokenRatesController.d.ts → types/TokenRatesController.d.ts} +0 -0
  230. /package/dist/{constants.d.ts → types/constants.d.ts} +0 -0
  231. /package/dist/{crypto-compare.d.ts → types/crypto-compare.d.ts} +0 -0
  232. /package/dist/{token-prices-service → types/token-prices-service}/abstract-token-prices-service.d.ts +0 -0
  233. /package/dist/{token-prices-service → types/token-prices-service}/codefi-v2.d.ts +0 -0
  234. /package/dist/{token-prices-service → types/token-prices-service}/index.d.ts +0 -0
  235. /package/dist/{token-service.d.ts → types/token-service.d.ts} +0 -0
@@ -1,637 +1,16 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.TokensController = exports.getDefaultTokensState = void 0;
16
- const contracts_1 = require("@ethersproject/contracts");
17
- const providers_1 = require("@ethersproject/providers");
18
- const base_controller_1 = require("@metamask/base-controller");
19
- const contract_metadata_1 = __importDefault(require("@metamask/contract-metadata"));
20
- const controller_utils_1 = require("@metamask/controller-utils");
21
- const metamask_eth_abis_1 = require("@metamask/metamask-eth-abis");
22
- const rpc_errors_1 = require("@metamask/rpc-errors");
23
- const async_mutex_1 = require("async-mutex");
24
- const events_1 = require("events");
25
- const uuid_1 = require("uuid");
26
- const assetsUtil_1 = require("./assetsUtil");
27
- const ERC20Standard_1 = require("./Standards/ERC20Standard");
28
- const ERC1155Standard_1 = require("./Standards/NftStandards/ERC1155/ERC1155Standard");
29
- const token_service_1 = require("./token-service");
30
- /**
31
- * The name of the {@link TokensController}.
32
- */
33
- const controllerName = 'TokensController';
34
- const getDefaultTokensState = () => {
35
- return {
36
- tokens: [],
37
- ignoredTokens: [],
38
- detectedTokens: [],
39
- allTokens: {},
40
- allIgnoredTokens: {},
41
- allDetectedTokens: {},
42
- };
43
- };
44
- exports.getDefaultTokensState = getDefaultTokensState;
45
- /**
46
- * Controller that stores assets and exposes convenience methods
47
- */
48
- class TokensController extends base_controller_1.BaseControllerV1 {
49
- /**
50
- * Creates a TokensController instance.
51
- *
52
- * @param options - The controller options.
53
- * @param options.chainId - The chain ID of the current network.
54
- * @param options.onPreferencesStateChange - Allows subscribing to preference controller state changes.
55
- * @param options.onNetworkDidChange - Allows subscribing to network controller networkDidChange events.
56
- * @param options.onTokenListStateChange - Allows subscribing to token list controller state changes.
57
- * @param options.getNetworkClientById - Gets the network client with the given id from the NetworkController.
58
- * @param options.config - Initial options used to configure this controller.
59
- * @param options.state - Initial state to set on this controller.
60
- * @param options.messenger - The controller messenger.
61
- */
62
- constructor({ chainId: initialChainId, onPreferencesStateChange, onNetworkDidChange, onTokenListStateChange, getNetworkClientById, config, state, messenger, }) {
63
- super(config, state);
64
- this.mutex = new async_mutex_1.Mutex();
65
- /**
66
- * EventEmitter instance used to listen to specific EIP747 events
67
- */
68
- this.hub = new events_1.EventEmitter();
69
- /**
70
- * Name of this controller used during composition
71
- */
72
- this.name = 'TokensController';
73
- this.defaultConfig = Object.assign({ selectedAddress: '', chainId: initialChainId, provider: undefined }, config);
74
- this.defaultState = Object.assign(Object.assign({}, (0, exports.getDefaultTokensState)()), state);
75
- this.initialize();
76
- this.abortController = new AbortController();
77
- this.getNetworkClientById = getNetworkClientById;
78
- this.messagingSystem = messenger;
79
- onPreferencesStateChange(({ selectedAddress }) => {
80
- var _a, _b, _c;
81
- const { allTokens, allIgnoredTokens, allDetectedTokens } = this.state;
82
- const { chainId } = this.config;
83
- this.configure({ selectedAddress });
84
- this.update({
85
- tokens: ((_a = allTokens[chainId]) === null || _a === void 0 ? void 0 : _a[selectedAddress]) || [],
86
- ignoredTokens: ((_b = allIgnoredTokens[chainId]) === null || _b === void 0 ? void 0 : _b[selectedAddress]) || [],
87
- detectedTokens: ((_c = allDetectedTokens[chainId]) === null || _c === void 0 ? void 0 : _c[selectedAddress]) || [],
88
- });
89
- });
90
- onNetworkDidChange(({ providerConfig }) => {
91
- var _a, _b, _c;
92
- const { allTokens, allIgnoredTokens, allDetectedTokens } = this.state;
93
- const { selectedAddress } = this.config;
94
- const { chainId } = providerConfig;
95
- this.abortController.abort();
96
- this.abortController = new AbortController();
97
- this.configure({ chainId });
98
- this.update({
99
- tokens: ((_a = allTokens[chainId]) === null || _a === void 0 ? void 0 : _a[selectedAddress]) || [],
100
- ignoredTokens: ((_b = allIgnoredTokens[chainId]) === null || _b === void 0 ? void 0 : _b[selectedAddress]) || [],
101
- detectedTokens: ((_c = allDetectedTokens[chainId]) === null || _c === void 0 ? void 0 : _c[selectedAddress]) || [],
102
- });
103
- });
104
- onTokenListStateChange(({ tokenList }) => {
105
- const { tokens } = this.state;
106
- if (tokens.length && !tokens[0].name) {
107
- this.updateTokensAttribute(tokenList, 'name');
108
- }
109
- });
110
- }
111
- /**
112
- * Fetch metadata for a token.
113
- *
114
- * @param tokenAddress - The address of the token.
115
- * @returns The token metadata.
116
- */
117
- fetchTokenMetadata(tokenAddress) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- try {
120
- const token = yield (0, token_service_1.fetchTokenMetadata)(this.config.chainId, tokenAddress, this.abortController.signal);
121
- return token;
122
- }
123
- catch (error) {
124
- if (error instanceof Error &&
125
- error.message.includes(token_service_1.TOKEN_METADATA_NO_SUPPORT_ERROR)) {
126
- return undefined;
127
- }
128
- throw error;
129
- }
130
- });
131
- }
132
- /**
133
- * Adds a token to the stored token list.
134
- *
135
- * @param options - The method argument object.
136
- * @param options.address - Hex address of the token contract.
137
- * @param options.symbol - Symbol of the token.
138
- * @param options.decimals - Number of decimals the token uses.
139
- * @param options.name - Name of the token.
140
- * @param options.image - Image of the token.
141
- * @param options.interactingAddress - The address of the account to add a token to.
142
- * @param options.networkClientId - Network Client ID.
143
- * @returns Current token list.
144
- */
145
- addToken({ address, symbol, decimals, name, image, interactingAddress, networkClientId, }) {
146
- var _a, _b, _c;
147
- return __awaiter(this, void 0, void 0, function* () {
148
- const { chainId, selectedAddress } = this.config;
149
- const releaseLock = yield this.mutex.acquire();
150
- const { allTokens, allIgnoredTokens, allDetectedTokens } = this.state;
151
- let currentChainId = chainId;
152
- if (networkClientId) {
153
- currentChainId =
154
- this.getNetworkClientById(networkClientId).configuration.chainId;
155
- }
156
- const accountAddress = interactingAddress || selectedAddress;
157
- const isInteractingWithWalletAccount = accountAddress === selectedAddress;
158
- try {
159
- address = (0, controller_utils_1.toChecksumHexAddress)(address);
160
- const tokens = ((_a = allTokens[currentChainId]) === null || _a === void 0 ? void 0 : _a[accountAddress]) || [];
161
- const ignoredTokens = ((_b = allIgnoredTokens[currentChainId]) === null || _b === void 0 ? void 0 : _b[accountAddress]) || [];
162
- const detectedTokens = ((_c = allDetectedTokens[currentChainId]) === null || _c === void 0 ? void 0 : _c[accountAddress]) || [];
163
- const newTokens = [...tokens];
164
- const [isERC721, tokenMetadata] = yield Promise.all([
165
- this._detectIsERC721(address, networkClientId),
166
- // TODO parameterize the token metadata fetch by networkClientId
167
- this.fetchTokenMetadata(address),
168
- ]);
169
- // TODO remove this once this method is fully parameterized by networkClientId
170
- if (!networkClientId && currentChainId !== this.config.chainId) {
171
- throw new Error('TokensController Error: Switched networks while adding token');
172
- }
173
- const newEntry = {
174
- address,
175
- symbol,
176
- decimals,
177
- image: image ||
178
- (0, assetsUtil_1.formatIconUrlWithProxy)({
179
- chainId: currentChainId,
180
- tokenAddress: address,
181
- }),
182
- isERC721,
183
- aggregators: (0, assetsUtil_1.formatAggregatorNames)((tokenMetadata === null || tokenMetadata === void 0 ? void 0 : tokenMetadata.aggregators) || []),
184
- name,
185
- };
186
- const previousIndex = newTokens.findIndex((token) => token.address.toLowerCase() === address.toLowerCase());
187
- if (previousIndex !== -1) {
188
- newTokens[previousIndex] = newEntry;
189
- }
190
- else {
191
- newTokens.push(newEntry);
192
- }
193
- const newIgnoredTokens = ignoredTokens.filter((tokenAddress) => tokenAddress.toLowerCase() !== address.toLowerCase());
194
- const newDetectedTokens = detectedTokens.filter((token) => token.address.toLowerCase() !== address.toLowerCase());
195
- const { newAllTokens, newAllIgnoredTokens, newAllDetectedTokens } = this._getNewAllTokensState({
196
- newTokens,
197
- newIgnoredTokens,
198
- newDetectedTokens,
199
- interactingAddress: accountAddress,
200
- interactingChainId: currentChainId,
201
- });
202
- let newState = {
203
- allTokens: newAllTokens,
204
- allIgnoredTokens: newAllIgnoredTokens,
205
- allDetectedTokens: newAllDetectedTokens,
206
- };
207
- // Only update active tokens if user is interacting with their active wallet account.
208
- if (isInteractingWithWalletAccount) {
209
- newState = Object.assign(Object.assign({}, newState), { tokens: newTokens, ignoredTokens: newIgnoredTokens, detectedTokens: newDetectedTokens });
210
- }
211
- this.update(newState);
212
- return newTokens;
213
- }
214
- finally {
215
- releaseLock();
216
- }
217
- });
218
- }
219
- /**
220
- * Add a batch of tokens.
221
- *
222
- * @param tokensToImport - Array of tokens to import.
223
- * @param networkClientId - Optional network client ID used to determine interacting chain ID.
224
- */
225
- addTokens(tokensToImport, networkClientId) {
226
- return __awaiter(this, void 0, void 0, function* () {
227
- const releaseLock = yield this.mutex.acquire();
228
- const { tokens, detectedTokens, ignoredTokens } = this.state;
229
- const importedTokensMap = {};
230
- // Used later to dedupe imported tokens
231
- const newTokensMap = tokens.reduce((output, current) => {
232
- output[current.address] = current;
233
- return output;
234
- }, {});
235
- try {
236
- tokensToImport.forEach((tokenToAdd) => {
237
- const { address, symbol, decimals, image, aggregators, name } = tokenToAdd;
238
- const checksumAddress = (0, controller_utils_1.toChecksumHexAddress)(address);
239
- const formattedToken = {
240
- address: checksumAddress,
241
- symbol,
242
- decimals,
243
- image,
244
- aggregators,
245
- name,
246
- };
247
- newTokensMap[address] = formattedToken;
248
- importedTokensMap[address.toLowerCase()] = true;
249
- return formattedToken;
250
- });
251
- const newTokens = Object.values(newTokensMap);
252
- const newDetectedTokens = detectedTokens.filter((token) => !importedTokensMap[token.address.toLowerCase()]);
253
- const newIgnoredTokens = ignoredTokens.filter((tokenAddress) => !newTokensMap[tokenAddress.toLowerCase()]);
254
- let interactingChainId;
255
- if (networkClientId) {
256
- interactingChainId =
257
- this.getNetworkClientById(networkClientId).configuration.chainId;
258
- }
259
- const { newAllTokens, newAllDetectedTokens, newAllIgnoredTokens } = this._getNewAllTokensState({
260
- newTokens,
261
- newDetectedTokens,
262
- newIgnoredTokens,
263
- interactingChainId,
264
- });
265
- this.update({
266
- tokens: newTokens,
267
- allTokens: newAllTokens,
268
- detectedTokens: newDetectedTokens,
269
- allDetectedTokens: newAllDetectedTokens,
270
- ignoredTokens: newIgnoredTokens,
271
- allIgnoredTokens: newAllIgnoredTokens,
272
- });
273
- }
274
- finally {
275
- releaseLock();
276
- }
277
- });
278
- }
279
- /**
280
- * Ignore a batch of tokens.
281
- *
282
- * @param tokenAddressesToIgnore - Array of token addresses to ignore.
283
- */
284
- ignoreTokens(tokenAddressesToIgnore) {
285
- const { ignoredTokens, detectedTokens, tokens } = this.state;
286
- const ignoredTokensMap = {};
287
- let newIgnoredTokens = [...ignoredTokens];
288
- const checksummedTokenAddresses = tokenAddressesToIgnore.map((address) => {
289
- const checksumAddress = (0, controller_utils_1.toChecksumHexAddress)(address);
290
- ignoredTokensMap[address.toLowerCase()] = true;
291
- return checksumAddress;
292
- });
293
- newIgnoredTokens = [...ignoredTokens, ...checksummedTokenAddresses];
294
- const newDetectedTokens = detectedTokens.filter((token) => !ignoredTokensMap[token.address.toLowerCase()]);
295
- const newTokens = tokens.filter((token) => !ignoredTokensMap[token.address.toLowerCase()]);
296
- const { newAllIgnoredTokens, newAllDetectedTokens, newAllTokens } = this._getNewAllTokensState({
297
- newIgnoredTokens,
298
- newDetectedTokens,
299
- newTokens,
300
- });
301
- this.update({
302
- ignoredTokens: newIgnoredTokens,
303
- tokens: newTokens,
304
- detectedTokens: newDetectedTokens,
305
- allIgnoredTokens: newAllIgnoredTokens,
306
- allDetectedTokens: newAllDetectedTokens,
307
- allTokens: newAllTokens,
308
- });
309
- }
310
- /**
311
- * Adds a batch of detected tokens to the stored token list.
312
- *
313
- * @param incomingDetectedTokens - Array of detected tokens to be added or updated.
314
- * @param detectionDetails - An object containing the chain ID and address of the currently selected network on which the incomingDetectedTokens were detected.
315
- * @param detectionDetails.selectedAddress - the account address on which the incomingDetectedTokens were detected.
316
- * @param detectionDetails.chainId - the chainId on which the incomingDetectedTokens were detected.
317
- */
318
- addDetectedTokens(incomingDetectedTokens, detectionDetails) {
319
- var _a, _b, _c, _d, _e, _f, _g, _h;
320
- return __awaiter(this, void 0, void 0, function* () {
321
- const releaseLock = yield this.mutex.acquire();
322
- // Get existing tokens for the chain + account
323
- const chainId = (_a = detectionDetails === null || detectionDetails === void 0 ? void 0 : detectionDetails.chainId) !== null && _a !== void 0 ? _a : this.config.chainId;
324
- const accountAddress = (_b = detectionDetails === null || detectionDetails === void 0 ? void 0 : detectionDetails.selectedAddress) !== null && _b !== void 0 ? _b : this.config.selectedAddress;
325
- const { allTokens, allDetectedTokens, allIgnoredTokens } = this.state;
326
- let newTokens = [...((_d = (_c = allTokens === null || allTokens === void 0 ? void 0 : allTokens[chainId]) === null || _c === void 0 ? void 0 : _c[accountAddress]) !== null && _d !== void 0 ? _d : [])];
327
- let newDetectedTokens = [
328
- ...((_f = (_e = allDetectedTokens === null || allDetectedTokens === void 0 ? void 0 : allDetectedTokens[chainId]) === null || _e === void 0 ? void 0 : _e[accountAddress]) !== null && _f !== void 0 ? _f : []),
329
- ];
330
- try {
331
- incomingDetectedTokens.forEach((tokenToAdd) => {
332
- var _a, _b, _c;
333
- const { address, symbol, decimals, image, aggregators, isERC721, name, } = tokenToAdd;
334
- const checksumAddress = (0, controller_utils_1.toChecksumHexAddress)(address);
335
- const newEntry = {
336
- address: checksumAddress,
337
- symbol,
338
- decimals,
339
- image,
340
- isERC721,
341
- aggregators,
342
- name,
343
- };
344
- const previousImportedIndex = newTokens.findIndex((token) => token.address.toLowerCase() === checksumAddress.toLowerCase());
345
- if (previousImportedIndex !== -1) {
346
- // Update existing data of imported token
347
- newTokens[previousImportedIndex] = newEntry;
348
- }
349
- else {
350
- const ignoredTokenIndex = (_c = (_b = (_a = allIgnoredTokens === null || allIgnoredTokens === void 0 ? void 0 : allIgnoredTokens[chainId]) === null || _a === void 0 ? void 0 : _a[accountAddress]) === null || _b === void 0 ? void 0 : _b.indexOf(address)) !== null && _c !== void 0 ? _c : -1;
351
- if (ignoredTokenIndex === -1) {
352
- // Add detected token
353
- const previousDetectedIndex = newDetectedTokens.findIndex((token) => token.address.toLowerCase() === checksumAddress.toLowerCase());
354
- if (previousDetectedIndex !== -1) {
355
- newDetectedTokens[previousDetectedIndex] = newEntry;
356
- }
357
- else {
358
- newDetectedTokens.push(newEntry);
359
- }
360
- }
361
- }
362
- });
363
- const { newAllTokens, newAllDetectedTokens } = this._getNewAllTokensState({
364
- newTokens,
365
- newDetectedTokens,
366
- interactingAddress: accountAddress,
367
- interactingChainId: chainId,
368
- });
369
- // We may be detecting tokens on a different chain/account pair than are currently configured.
370
- // Re-point `tokens` and `detectedTokens` to keep them referencing the current chain/account.
371
- const { chainId: currentChain, selectedAddress: currentAddress } = this.config;
372
- newTokens = ((_g = newAllTokens === null || newAllTokens === void 0 ? void 0 : newAllTokens[currentChain]) === null || _g === void 0 ? void 0 : _g[currentAddress]) || [];
373
- newDetectedTokens =
374
- ((_h = newAllDetectedTokens === null || newAllDetectedTokens === void 0 ? void 0 : newAllDetectedTokens[currentChain]) === null || _h === void 0 ? void 0 : _h[currentAddress]) || [];
375
- this.update({
376
- tokens: newTokens,
377
- allTokens: newAllTokens,
378
- detectedTokens: newDetectedTokens,
379
- allDetectedTokens: newAllDetectedTokens,
380
- });
381
- }
382
- finally {
383
- releaseLock();
384
- }
385
- });
386
- }
387
- /**
388
- * Adds isERC721 field to token object. This is called when a user attempts to add tokens that
389
- * were previously added which do not yet had isERC721 field.
390
- *
391
- * @param tokenAddress - The contract address of the token requiring the isERC721 field added.
392
- * @returns The new token object with the added isERC721 field.
393
- */
394
- updateTokenType(tokenAddress) {
395
- return __awaiter(this, void 0, void 0, function* () {
396
- const isERC721 = yield this._detectIsERC721(tokenAddress);
397
- const { tokens } = this.state;
398
- const tokenIndex = tokens.findIndex((token) => {
399
- return token.address.toLowerCase() === tokenAddress.toLowerCase();
400
- });
401
- tokens[tokenIndex].isERC721 = isERC721;
402
- this.update({ tokens });
403
- return tokens[tokenIndex];
404
- });
405
- }
406
- /**
407
- * This is a function that updates the tokens name for the tokens name if it is not defined.
408
- *
409
- * @param tokenList - Represents the fetched token list from service API
410
- * @param tokenAttribute - Represents the token attribute that we want to update on the token list
411
- */
412
- updateTokensAttribute(tokenList, tokenAttribute) {
413
- const { tokens } = this.state;
414
- const newTokens = tokens.map((token) => {
415
- const newToken = tokenList[token.address.toLowerCase()];
416
- return !token[tokenAttribute] && (newToken === null || newToken === void 0 ? void 0 : newToken[tokenAttribute])
417
- ? Object.assign(Object.assign({}, token), { [tokenAttribute]: newToken[tokenAttribute] }) : Object.assign({}, token);
418
- });
419
- this.update({ tokens: newTokens });
420
- }
421
- /**
422
- * Detects whether or not a token is ERC-721 compatible.
423
- *
424
- * @param tokenAddress - The token contract address.
425
- * @param networkClientId - Optional network client ID to fetch contract info with.
426
- * @returns A boolean indicating whether the token address passed in supports the EIP-721
427
- * interface.
428
- */
429
- _detectIsERC721(tokenAddress, networkClientId) {
430
- var _a, _b;
431
- return __awaiter(this, void 0, void 0, function* () {
432
- const checksumAddress = (0, controller_utils_1.toChecksumHexAddress)(tokenAddress);
433
- // if this token is already in our contract metadata map we don't need
434
- // to check against the contract
435
- if (((_a = contract_metadata_1.default[checksumAddress]) === null || _a === void 0 ? void 0 : _a.erc721) === true) {
436
- return Promise.resolve(true);
437
- }
438
- else if (((_b = contract_metadata_1.default[checksumAddress]) === null || _b === void 0 ? void 0 : _b.erc20) === true) {
439
- return Promise.resolve(false);
440
- }
441
- const tokenContract = this._createEthersContract(tokenAddress, metamask_eth_abis_1.abiERC721, networkClientId);
442
- try {
443
- return yield tokenContract.supportsInterface(controller_utils_1.ERC721_INTERFACE_ID);
444
- // TODO: Replace `any` with type
445
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
446
- }
447
- catch (error) {
448
- // currently we see a variety of errors across different networks when
449
- // token contracts are not ERC721 compatible. We need to figure out a better
450
- // way of differentiating token interface types but for now if we get an error
451
- // we have to assume the token is not ERC721 compatible.
452
- return false;
453
- }
454
- });
455
- }
456
- _getProvider(networkClientId) {
457
- var _a;
458
- return new providers_1.Web3Provider(networkClientId
459
- ? this.getNetworkClientById(networkClientId).provider
460
- : (_a = this.config) === null || _a === void 0 ? void 0 : _a.provider);
461
- }
462
- _createEthersContract(tokenAddress, abi, networkClientId) {
463
- const web3provider = this._getProvider(networkClientId);
464
- const tokenContract = new contracts_1.Contract(tokenAddress, abi, web3provider);
465
- return tokenContract;
466
- }
467
- _generateRandomId() {
468
- return (0, uuid_1.v1)();
469
- }
470
- /**
471
- * Adds a new suggestedAsset to the list of watched assets.
472
- * Parameters will be validated according to the asset type being watched.
473
- *
474
- * @param options - The method options.
475
- * @param options.asset - The asset to be watched. For now only ERC20 tokens are accepted.
476
- * @param options.type - The asset type.
477
- * @param options.interactingAddress - The address of the account that is requesting to watch the asset.
478
- * @param options.networkClientId - Network Client ID.
479
- * @returns A promise that resolves if the asset was watched successfully, and rejects otherwise.
480
- */
481
- watchAsset({ asset, type, interactingAddress, networkClientId, }) {
482
- return __awaiter(this, void 0, void 0, function* () {
483
- if (type !== controller_utils_1.ERC20) {
484
- throw new Error(`Asset of type ${type} not supported`);
485
- }
486
- if (!asset.address) {
487
- throw rpc_errors_1.rpcErrors.invalidParams('Address must be specified');
488
- }
489
- if (!(0, controller_utils_1.isValidHexAddress)(asset.address)) {
490
- throw rpc_errors_1.rpcErrors.invalidParams(`Invalid address "${asset.address}"`);
491
- }
492
- // Validate contract
493
- if (yield this._detectIsERC721(asset.address, networkClientId)) {
494
- throw rpc_errors_1.rpcErrors.invalidParams(`Contract ${asset.address} must match type ${type}, but was detected as ${controller_utils_1.ERC721}`);
495
- }
496
- const provider = this._getProvider(networkClientId);
497
- const isErc1155 = yield (0, controller_utils_1.safelyExecute)(() => new ERC1155Standard_1.ERC1155Standard(provider).contractSupportsBase1155Interface(asset.address));
498
- if (isErc1155) {
499
- throw rpc_errors_1.rpcErrors.invalidParams(`Contract ${asset.address} must match type ${type}, but was detected as ${controller_utils_1.ERC1155}`);
500
- }
501
- const erc20 = new ERC20Standard_1.ERC20Standard(provider);
502
- const [contractName, contractSymbol, contractDecimals] = yield Promise.all([
503
- (0, controller_utils_1.safelyExecute)(() => erc20.getTokenName(asset.address)),
504
- (0, controller_utils_1.safelyExecute)(() => erc20.getTokenSymbol(asset.address)),
505
- (0, controller_utils_1.safelyExecute)(() => __awaiter(this, void 0, void 0, function* () { return erc20.getTokenDecimals(asset.address); })),
506
- ]);
507
- asset.name = contractName;
508
- // Validate symbol
509
- if (!asset.symbol && !contractSymbol) {
510
- throw rpc_errors_1.rpcErrors.invalidParams('A symbol is required, but was not found in either the request or contract');
511
- }
512
- if (contractSymbol !== undefined &&
513
- asset.symbol !== undefined &&
514
- asset.symbol.toUpperCase() !== contractSymbol.toUpperCase()) {
515
- throw rpc_errors_1.rpcErrors.invalidParams(`The symbol in the request (${asset.symbol}) does not match the symbol in the contract (${contractSymbol})`);
516
- }
517
- asset.symbol = contractSymbol !== null && contractSymbol !== void 0 ? contractSymbol : asset.symbol;
518
- if (typeof asset.symbol !== 'string') {
519
- throw rpc_errors_1.rpcErrors.invalidParams(`Invalid symbol: not a string`);
520
- }
521
- if (asset.symbol.length > 11) {
522
- throw rpc_errors_1.rpcErrors.invalidParams(`Invalid symbol "${asset.symbol}": longer than 11 characters`);
523
- }
524
- // Validate decimals
525
- if (asset.decimals === undefined && contractDecimals === undefined) {
526
- throw rpc_errors_1.rpcErrors.invalidParams('Decimals are required, but were not found in either the request or contract');
527
- }
528
- if (contractDecimals !== undefined &&
529
- asset.decimals !== undefined &&
530
- String(asset.decimals) !== contractDecimals) {
531
- throw rpc_errors_1.rpcErrors.invalidParams(`The decimals in the request (${asset.decimals}) do not match the decimals in the contract (${contractDecimals})`);
532
- }
533
- const decimalsStr = contractDecimals !== null && contractDecimals !== void 0 ? contractDecimals : asset.decimals;
534
- const decimalsNum = parseInt(decimalsStr, 10);
535
- if (!Number.isInteger(decimalsNum) || decimalsNum > 36 || decimalsNum < 0) {
536
- throw rpc_errors_1.rpcErrors.invalidParams(`Invalid decimals "${decimalsStr}": must be an integer 0 <= 36`);
537
- }
538
- asset.decimals = decimalsNum;
539
- const suggestedAssetMeta = {
540
- asset,
541
- id: this._generateRandomId(),
542
- time: Date.now(),
543
- type,
544
- interactingAddress: interactingAddress || this.config.selectedAddress,
545
- };
546
- yield this._requestApproval(suggestedAssetMeta);
547
- const { address, symbol, decimals, name, image } = asset;
548
- yield this.addToken({
549
- address,
550
- symbol,
551
- decimals,
552
- name,
553
- image,
554
- interactingAddress: suggestedAssetMeta.interactingAddress,
555
- networkClientId,
556
- });
557
- });
558
- }
559
- /**
560
- * Takes a new tokens and ignoredTokens array for the current network/account combination
561
- * and returns new allTokens and allIgnoredTokens state to update to.
562
- *
563
- * @param params - Object that holds token params.
564
- * @param params.newTokens - The new tokens to set for the current network and selected account.
565
- * @param params.newIgnoredTokens - The new ignored tokens to set for the current network and selected account.
566
- * @param params.newDetectedTokens - The new detected tokens to set for the current network and selected account.
567
- * @param params.interactingAddress - The account address to use to store the tokens.
568
- * @param params.interactingChainId - The chainId to use to store the tokens.
569
- * @returns The updated `allTokens` and `allIgnoredTokens` state.
570
- */
571
- _getNewAllTokensState(params) {
572
- const { newTokens, newIgnoredTokens, newDetectedTokens, interactingAddress, interactingChainId, } = params;
573
- const { allTokens, allIgnoredTokens, allDetectedTokens } = this.state;
574
- const { chainId, selectedAddress } = this.config;
575
- const userAddressToAddTokens = interactingAddress !== null && interactingAddress !== void 0 ? interactingAddress : selectedAddress;
576
- const chainIdToAddTokens = interactingChainId !== null && interactingChainId !== void 0 ? interactingChainId : chainId;
577
- let newAllTokens = allTokens;
578
- if ((newTokens === null || newTokens === void 0 ? void 0 : newTokens.length) ||
579
- (newTokens &&
580
- allTokens &&
581
- allTokens[chainIdToAddTokens] &&
582
- allTokens[chainIdToAddTokens][userAddressToAddTokens])) {
583
- const networkTokens = allTokens[chainIdToAddTokens];
584
- const newNetworkTokens = Object.assign(Object.assign({}, networkTokens), { [userAddressToAddTokens]: newTokens });
585
- newAllTokens = Object.assign(Object.assign({}, allTokens), { [chainIdToAddTokens]: newNetworkTokens });
586
- }
587
- let newAllIgnoredTokens = allIgnoredTokens;
588
- if ((newIgnoredTokens === null || newIgnoredTokens === void 0 ? void 0 : newIgnoredTokens.length) ||
589
- (newIgnoredTokens &&
590
- allIgnoredTokens &&
591
- allIgnoredTokens[chainIdToAddTokens] &&
592
- allIgnoredTokens[chainIdToAddTokens][userAddressToAddTokens])) {
593
- const networkIgnoredTokens = allIgnoredTokens[chainIdToAddTokens];
594
- const newIgnoredNetworkTokens = Object.assign(Object.assign({}, networkIgnoredTokens), { [userAddressToAddTokens]: newIgnoredTokens });
595
- newAllIgnoredTokens = Object.assign(Object.assign({}, allIgnoredTokens), { [chainIdToAddTokens]: newIgnoredNetworkTokens });
596
- }
597
- let newAllDetectedTokens = allDetectedTokens;
598
- if ((newDetectedTokens === null || newDetectedTokens === void 0 ? void 0 : newDetectedTokens.length) ||
599
- (newDetectedTokens &&
600
- allDetectedTokens &&
601
- allDetectedTokens[chainIdToAddTokens] &&
602
- allDetectedTokens[chainIdToAddTokens][userAddressToAddTokens])) {
603
- const networkDetectedTokens = allDetectedTokens[chainIdToAddTokens];
604
- const newDetectedNetworkTokens = Object.assign(Object.assign({}, networkDetectedTokens), { [userAddressToAddTokens]: newDetectedTokens });
605
- newAllDetectedTokens = Object.assign(Object.assign({}, allDetectedTokens), { [chainIdToAddTokens]: newDetectedNetworkTokens });
606
- }
607
- return { newAllTokens, newAllIgnoredTokens, newAllDetectedTokens };
608
- }
609
- /**
610
- * Removes all tokens from the ignored list.
611
- */
612
- clearIgnoredTokens() {
613
- this.update({ ignoredTokens: [], allIgnoredTokens: {} });
614
- }
615
- _requestApproval(suggestedAssetMeta) {
616
- return __awaiter(this, void 0, void 0, function* () {
617
- return this.messagingSystem.call('ApprovalController:addRequest', {
618
- id: suggestedAssetMeta.id,
619
- origin: controller_utils_1.ORIGIN_METAMASK,
620
- type: controller_utils_1.ApprovalType.WatchAsset,
621
- requestData: {
622
- id: suggestedAssetMeta.id,
623
- interactingAddress: suggestedAssetMeta.interactingAddress,
624
- asset: {
625
- address: suggestedAssetMeta.asset.address,
626
- decimals: suggestedAssetMeta.asset.decimals,
627
- symbol: suggestedAssetMeta.asset.symbol,
628
- image: suggestedAssetMeta.asset.image || null,
629
- },
630
- },
631
- }, true);
632
- });
633
- }
634
- }
635
- exports.TokensController = TokensController;
636
- exports.default = TokensController;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkNLNXQHAUjs = require('./chunk-NLNXQHAU.js');
6
+ require('./chunk-GHZX5DE4.js');
7
+ require('./chunk-BZI7P3TD.js');
8
+ require('./chunk-PUFSYRJZ.js');
9
+ require('./chunk-YD3NRMFC.js');
10
+ require('./chunk-Z4BLTVTB.js');
11
+
12
+
13
+
14
+
15
+ exports.TokensController = _chunkNLNXQHAUjs.TokensController; exports.default = _chunkNLNXQHAUjs.TokensController_default; exports.getDefaultTokensState = _chunkNLNXQHAUjs.getDefaultTokensState;
637
16
  //# sourceMappingURL=TokensController.js.map