@pancakeswap/token-lists 0.0.14 → 0.0.16

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/dist/react.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkOGWZ2K32_js = require('./chunk-OGWZ2K32.js');
4
- var chunk4TPCCB4K_js = require('./chunk-4TPCCB4K.js');
3
+ var chunkYOAEDKQH_js = require('./chunk-YOAEDKQH.js');
5
4
  var toolkit = require('@reduxjs/toolkit');
6
5
  var jotai = require('jotai');
7
6
  var utils = require('jotai/utils');
@@ -25,7 +24,560 @@ var acceptListUpdate = toolkit.createAction("lists/acceptListUpdate");
25
24
  var rejectVersionUpdate = toolkit.createAction("lists/rejectVersionUpdate");
26
25
  var updateListVersion = toolkit.createAction("lists/updateListVersion");
27
26
 
28
- // react/reducer.ts
27
+ // ../utils/uriToHttp.ts
28
+ function uriToHttp(uri) {
29
+ var _a, _b;
30
+ const protocol = uri.split(":")[0].toLowerCase();
31
+ switch (protocol) {
32
+ case "https":
33
+ return [uri];
34
+ case "http":
35
+ return [`https${uri.substring(4)}`, uri];
36
+ case "ipfs":
37
+ const hash = (_a = uri.match(/^ipfs:(\/\/)?(.*)$/i)) == null ? void 0 : _a[2];
38
+ return [`https://cloudflare-ipfs.com/ipfs/${hash}/`, `https://ipfs.io/ipfs/${hash}/`];
39
+ case "ipns":
40
+ const name = (_b = uri.match(/^ipns:(\/\/)?(.*)$/i)) == null ? void 0 : _b[2];
41
+ return [`https://cloudflare-ipfs.com/ipns/${name}/`, `https://ipfs.io/ipns/${name}/`];
42
+ default:
43
+ return [];
44
+ }
45
+ }
46
+
47
+ // schema/pancakeswap.json
48
+ var pancakeswap_default = {
49
+ $schema: "http://json-schema.org/draft-07/schema#",
50
+ $id: "pancakeswap",
51
+ title: "PancakeSwap Token List",
52
+ description: "Schema for lists of tokens compatible with the PancakeSwap Interface, including Uniswap standard and PancakeSwap Aptos",
53
+ definitions: {
54
+ Version: {
55
+ type: "object",
56
+ description: "The version of the list, used in change detection",
57
+ examples: [
58
+ {
59
+ major: 1,
60
+ minor: 0,
61
+ patch: 0
62
+ }
63
+ ],
64
+ additionalProperties: false,
65
+ properties: {
66
+ major: {
67
+ type: "integer",
68
+ description: "The major version of the list. Must be incremented when tokens are removed from the list or token addresses are changed.",
69
+ minimum: 0,
70
+ examples: [1, 2]
71
+ },
72
+ minor: {
73
+ type: "integer",
74
+ description: "The minor version of the list. Must be incremented when tokens are added to the list.",
75
+ minimum: 0,
76
+ examples: [0, 1]
77
+ },
78
+ patch: {
79
+ type: "integer",
80
+ description: "The patch version of the list. Must be incremented for any changes to the list.",
81
+ minimum: 0,
82
+ examples: [0, 1]
83
+ }
84
+ },
85
+ required: ["major", "minor", "patch"]
86
+ },
87
+ TagIdentifier: {
88
+ type: "string",
89
+ description: "The unique identifier of a tag",
90
+ minLength: 1,
91
+ maxLength: 10,
92
+ pattern: "^[\\w]+$",
93
+ examples: ["compound", "stablecoin"]
94
+ },
95
+ ExtensionIdentifier: {
96
+ type: "string",
97
+ description: "The name of a token extension property",
98
+ minLength: 1,
99
+ maxLength: 40,
100
+ pattern: "^[\\w]+$",
101
+ examples: ["color", "is_fee_on_transfer", "aliases"]
102
+ },
103
+ ExtensionMap: {
104
+ type: "object",
105
+ description: "An object containing any arbitrary or vendor-specific token metadata",
106
+ maxProperties: 10,
107
+ propertyNames: {
108
+ $ref: "#/definitions/ExtensionIdentifier"
109
+ },
110
+ additionalProperties: {
111
+ $ref: "#/definitions/ExtensionValue"
112
+ },
113
+ examples: [
114
+ {
115
+ color: "#000000",
116
+ is_verified_by_me: true
117
+ },
118
+ {
119
+ "x-bridged-addresses-by-chain": {
120
+ "1": {
121
+ bridgeAddress: "0x4200000000000000000000000000000000000010",
122
+ tokenAddress: "0x4200000000000000000000000000000000000010"
123
+ }
124
+ }
125
+ }
126
+ ]
127
+ },
128
+ ExtensionPrimitiveValue: {
129
+ anyOf: [
130
+ {
131
+ type: "string",
132
+ minLength: 1,
133
+ maxLength: 42,
134
+ examples: ["#00000"]
135
+ },
136
+ {
137
+ type: "boolean",
138
+ examples: [true]
139
+ },
140
+ {
141
+ type: "number",
142
+ examples: [15]
143
+ },
144
+ {
145
+ type: "null"
146
+ }
147
+ ]
148
+ },
149
+ ExtensionValue: {
150
+ anyOf: [
151
+ {
152
+ $ref: "#/definitions/ExtensionPrimitiveValue"
153
+ },
154
+ {
155
+ type: "object",
156
+ maxProperties: 10,
157
+ propertyNames: {
158
+ $ref: "#/definitions/ExtensionIdentifier"
159
+ },
160
+ additionalProperties: {
161
+ $ref: "#/definitions/ExtensionValueInner0"
162
+ }
163
+ }
164
+ ]
165
+ },
166
+ ExtensionValueInner0: {
167
+ anyOf: [
168
+ {
169
+ $ref: "#/definitions/ExtensionPrimitiveValue"
170
+ },
171
+ {
172
+ type: "object",
173
+ maxProperties: 10,
174
+ propertyNames: {
175
+ $ref: "#/definitions/ExtensionIdentifier"
176
+ },
177
+ additionalProperties: {
178
+ $ref: "#/definitions/ExtensionValueInner1"
179
+ }
180
+ }
181
+ ]
182
+ },
183
+ ExtensionValueInner1: {
184
+ anyOf: [
185
+ {
186
+ $ref: "#/definitions/ExtensionPrimitiveValue"
187
+ }
188
+ ]
189
+ },
190
+ TagDefinition: {
191
+ type: "object",
192
+ description: "Definition of a tag that can be associated with a token via its identifier",
193
+ additionalProperties: false,
194
+ properties: {
195
+ name: {
196
+ type: "string",
197
+ description: "The name of the tag",
198
+ pattern: "^[ \\w]+$",
199
+ minLength: 1,
200
+ maxLength: 20
201
+ },
202
+ description: {
203
+ type: "string",
204
+ description: "A user-friendly description of the tag",
205
+ pattern: "^[ \\w\\.,:]+$",
206
+ minLength: 1,
207
+ maxLength: 200
208
+ }
209
+ },
210
+ required: ["name", "description"],
211
+ examples: [
212
+ {
213
+ name: "Stablecoin",
214
+ description: "A token with value pegged to another asset"
215
+ }
216
+ ]
217
+ },
218
+ TokenInfo: {
219
+ type: "object",
220
+ description: "Metadata for a single token in a token list",
221
+ additionalProperties: false,
222
+ properties: {
223
+ chainId: {
224
+ type: "integer",
225
+ description: "The chain ID of the Ethereum network where this token is deployed",
226
+ minimum: 1,
227
+ examples: [1, 42]
228
+ },
229
+ address: {
230
+ type: "string",
231
+ description: "The checksummed address of the token on the specified chain ID",
232
+ pattern: "^0x[a-fA-F0-9]{40}$",
233
+ examples: ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]
234
+ },
235
+ decimals: {
236
+ type: "integer",
237
+ description: "The number of decimals for the token balance",
238
+ minimum: 0,
239
+ maximum: 255,
240
+ examples: [18]
241
+ },
242
+ name: {
243
+ type: "string",
244
+ description: "The name of the token",
245
+ minLength: 1,
246
+ maxLength: 40,
247
+ pattern: "^[ \\w.'+\\-%/\xC0-\xD6\xD8-\xF6\xF8-\xFF:&\\[\\]\\(\\)]+$",
248
+ examples: ["USD Coin"]
249
+ },
250
+ symbol: {
251
+ type: "string",
252
+ description: "The symbol for the token; must be alphanumeric",
253
+ pattern: "^[a-zA-Z0-9+\\-%/$.\\s]+$",
254
+ minLength: 1,
255
+ maxLength: 20,
256
+ examples: ["USDC"]
257
+ },
258
+ logoURI: {
259
+ type: "string",
260
+ description: "A URI to the token logo asset; if not set, interface will attempt to find a logo based on the token address; suggest SVG or PNG of size 64x64",
261
+ format: "uri",
262
+ examples: ["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]
263
+ },
264
+ tags: {
265
+ type: "array",
266
+ description: "An array of tag identifiers associated with the token; tags are defined at the list level",
267
+ items: {
268
+ $ref: "#/definitions/TagIdentifier"
269
+ },
270
+ maxItems: 10,
271
+ examples: ["stablecoin", "compound"]
272
+ },
273
+ extensions: {
274
+ $ref: "#/definitions/ExtensionMap"
275
+ }
276
+ },
277
+ required: ["chainId", "address", "decimals", "name", "symbol"]
278
+ },
279
+ AptosTokenInfo: {
280
+ type: "object",
281
+ description: "Metadata for a single token in a token list",
282
+ additionalProperties: false,
283
+ properties: {
284
+ chainId: {
285
+ type: "integer",
286
+ description: "The chain ID of the Aptos network where this token is deployed, 0 is devent",
287
+ minimum: 0,
288
+ examples: [1, 42]
289
+ },
290
+ address: {
291
+ type: "string",
292
+ description: "The address of the coin on the specified chain ID",
293
+ examples: ["0x1::aptos_coin::AptosCoin"]
294
+ },
295
+ decimals: {
296
+ type: "integer",
297
+ description: "The number of decimals for the token balance",
298
+ minimum: 0,
299
+ maximum: 255,
300
+ examples: [18]
301
+ },
302
+ name: {
303
+ type: "string",
304
+ description: "The name of the token",
305
+ minLength: 1,
306
+ maxLength: 40,
307
+ pattern: "^[ \\w.'+\\-%/\xC0-\xD6\xD8-\xF6\xF8-\xFF:&\\[\\]\\(\\)]+$",
308
+ examples: ["USD Coin"]
309
+ },
310
+ symbol: {
311
+ type: "string",
312
+ description: "The symbol for the token; must be alphanumeric",
313
+ pattern: "^[a-zA-Z0-9+\\-%/$.]+$",
314
+ minLength: 1,
315
+ maxLength: 20,
316
+ examples: ["USDC"]
317
+ },
318
+ logoURI: {
319
+ type: "string",
320
+ description: "A URI to the token logo asset; if not set, interface will attempt to find a logo based on the token address; suggest SVG or PNG of size 64x64",
321
+ format: "uri",
322
+ examples: ["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]
323
+ },
324
+ tags: {
325
+ type: "array",
326
+ description: "An array of tag identifiers associated with the token; tags are defined at the list level",
327
+ items: {
328
+ $ref: "#/definitions/TagIdentifier"
329
+ },
330
+ maxItems: 10,
331
+ examples: ["stablecoin", "compound"]
332
+ },
333
+ extensions: {
334
+ $ref: "#/definitions/ExtensionMap"
335
+ }
336
+ },
337
+ required: ["chainId", "address", "decimals", "name", "symbol"]
338
+ }
339
+ },
340
+ type: "object",
341
+ additionalProperties: false,
342
+ properties: {
343
+ name: {
344
+ type: "string",
345
+ description: "The name of the token list",
346
+ minLength: 1,
347
+ maxLength: 30,
348
+ pattern: "^[\\w ]+$",
349
+ examples: ["My Token List"]
350
+ },
351
+ timestamp: {
352
+ type: "string",
353
+ format: "date-time",
354
+ description: "The timestamp of this list version; i.e. when this immutable version of the list was created"
355
+ },
356
+ schema: {
357
+ type: "string"
358
+ },
359
+ version: {
360
+ $ref: "#/definitions/Version"
361
+ },
362
+ tokens: {
363
+ type: "array",
364
+ description: "The list of tokens included in the list",
365
+ minItems: 1,
366
+ maxItems: 1e4
367
+ },
368
+ keywords: {
369
+ type: "array",
370
+ description: "Keywords associated with the contents of the list; may be used in list discoverability",
371
+ items: {
372
+ type: "string",
373
+ description: "A keyword to describe the contents of the list",
374
+ minLength: 1,
375
+ maxLength: 20,
376
+ pattern: "^[\\w ]+$",
377
+ examples: ["compound", "lending", "personal tokens"]
378
+ },
379
+ maxItems: 20,
380
+ uniqueItems: true
381
+ },
382
+ tags: {
383
+ type: "object",
384
+ description: "A mapping of tag identifiers to their name and description",
385
+ propertyNames: {
386
+ $ref: "#/definitions/TagIdentifier"
387
+ },
388
+ additionalProperties: {
389
+ $ref: "#/definitions/TagDefinition"
390
+ },
391
+ maxProperties: 20,
392
+ examples: [
393
+ {
394
+ stablecoin: {
395
+ name: "Stablecoin",
396
+ description: "A token with value pegged to another asset"
397
+ }
398
+ }
399
+ ]
400
+ },
401
+ logoURI: {
402
+ type: "string",
403
+ description: "A URI for the logo of the token list; prefer SVG or PNG of size 256x256",
404
+ format: "uri",
405
+ examples: ["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]
406
+ }
407
+ },
408
+ if: {
409
+ properties: { schema: { const: "aptos" } },
410
+ required: ["name", "timestamp", "version", "tokens", "schema"]
411
+ },
412
+ then: {
413
+ properties: {
414
+ tokens: {
415
+ items: {
416
+ $ref: "#/definitions/AptosTokenInfo"
417
+ },
418
+ type: "array",
419
+ description: "The list of tokens included in the list",
420
+ minItems: 1,
421
+ maxItems: 1e4
422
+ }
423
+ }
424
+ },
425
+ else: {
426
+ properties: {
427
+ tokens: {
428
+ items: {
429
+ $ref: "#/definitions/TokenInfo"
430
+ },
431
+ type: "array",
432
+ description: "The list of tokens included in the list",
433
+ minItems: 1,
434
+ maxItems: 1e4
435
+ }
436
+ }
437
+ },
438
+ required: ["name", "timestamp", "version", "tokens"]
439
+ };
440
+
441
+ // react/getTokenList.ts
442
+ function getTokenList(listUrl) {
443
+ return chunkYOAEDKQH_js.__async(this, null, function* () {
444
+ const urls = uriToHttp(listUrl);
445
+ const { default: Ajv } = yield import('ajv');
446
+ const validator = new Ajv({ allErrors: true }).compile(pancakeswap_default);
447
+ for (const [i, url] of urls.entries()) {
448
+ try {
449
+ const json = yield fetchJson(url);
450
+ if (!validator(json)) {
451
+ const preFilterErrors = validator.errors;
452
+ json.tokens = json.tokens.filter((token) => validator(chunkYOAEDKQH_js.__spreadProps(chunkYOAEDKQH_js.__spreadValues({}, json), { tokens: [token] })));
453
+ if (!validator(json)) {
454
+ const errors = validator.errors;
455
+ throw new Error(`Validation failed after filtering: ${JSON.stringify(errors)}`);
456
+ }
457
+ console.warn(`Pre-filter validation errors: ${JSON.stringify(preFilterErrors)}`);
458
+ }
459
+ return json;
460
+ } catch (error) {
461
+ return void 0;
462
+ }
463
+ }
464
+ throw new Error("Unrecognized list URL protocol.");
465
+ });
466
+ }
467
+ function fetchJson(url) {
468
+ return chunkYOAEDKQH_js.__async(this, null, function* () {
469
+ const res = yield fetch(url);
470
+ if (!res.ok)
471
+ throw new Error(`Failed to fetch: ${url}`);
472
+ return res.json();
473
+ });
474
+ }
475
+ function noop() {
476
+ }
477
+ var noopStorage = {
478
+ getItem: () => Promise.resolve(noop()),
479
+ setItem: () => Promise.resolve(noop()),
480
+ removeItem: () => Promise.resolve(noop())
481
+ };
482
+ var EMPTY = Symbol();
483
+ function findTokenByAddress(state, chainId, address) {
484
+ var _a, _b;
485
+ const urls = (_a = state.activeListUrls) != null ? _a : Object.keys(state.byUrl);
486
+ for (const url of urls) {
487
+ const list = (_b = state.byUrl[url]) == null ? void 0 : _b.current;
488
+ const token = list == null ? void 0 : list.tokens.find((t) => t.chainId === chainId && t.address.toLowerCase() === address.toLowerCase());
489
+ if (token)
490
+ return token;
491
+ }
492
+ return void 0;
493
+ }
494
+ function findTokenBySymbol(state, chainId, symbol) {
495
+ var _a, _b;
496
+ const urls = (_a = state.activeListUrls) != null ? _a : Object.keys(state.byUrl);
497
+ for (const url of urls) {
498
+ const list = (_b = state.byUrl[url]) == null ? void 0 : _b.current;
499
+ const token = list == null ? void 0 : list.tokens.find((t) => t.chainId === chainId && t.symbol.toLowerCase() === symbol.toLowerCase());
500
+ if (token)
501
+ return token;
502
+ }
503
+ return void 0;
504
+ }
505
+ var createListsAtom = (storeName, reducer, initialState) => {
506
+ function IndexedDBStorage(dbName) {
507
+ if (typeof window !== "undefined") {
508
+ const db = localForage__default.default.createInstance({
509
+ name: dbName,
510
+ storeName
511
+ });
512
+ return {
513
+ getItem: (key) => chunkYOAEDKQH_js.__async(this, null, function* () {
514
+ const value = yield db.getItem(key);
515
+ if (value) {
516
+ return value;
517
+ }
518
+ return initialState;
519
+ }),
520
+ setItem: (k, v) => chunkYOAEDKQH_js.__async(this, null, function* () {
521
+ if (v === EMPTY)
522
+ return;
523
+ yield db.setItem(k, v);
524
+ }),
525
+ removeItem: db.removeItem
526
+ };
527
+ }
528
+ return noopStorage;
529
+ }
530
+ const listsStorageAtom = utils.atomWithStorage("lists", EMPTY, IndexedDBStorage("lists"));
531
+ const defaultStateAtom = jotai.atom(
532
+ (get) => {
533
+ const value = get(utils.loadable(listsStorageAtom));
534
+ if (value.state === "hasData" && value.data !== EMPTY) {
535
+ return value.data;
536
+ }
537
+ return initialState;
538
+ },
539
+ (get, set, action) => chunkYOAEDKQH_js.__async(void 0, null, function* () {
540
+ set(listsStorageAtom, reducer(yield get(defaultStateAtom), action));
541
+ })
542
+ );
543
+ const isReadyAtom = utils.loadable(listsStorageAtom);
544
+ const tokenAtom = utils.atomFamily(
545
+ (key) => jotai.atom((get) => findTokenByAddress(get(defaultStateAtom), key.chainId, key.address))
546
+ );
547
+ const tokenBySymbolAtom = utils.atomFamily(
548
+ (key) => jotai.atom((get) => findTokenBySymbol(get(defaultStateAtom), key.chainId, key.symbol))
549
+ );
550
+ const fetchListAtom = jotai.atom(null, (get, set, url) => chunkYOAEDKQH_js.__async(void 0, null, function* () {
551
+ const state = get(defaultStateAtom);
552
+ const listState = state.byUrl[url];
553
+ if ((listState == null ? void 0 : listState.current) || (listState == null ? void 0 : listState.loadingRequestId)) {
554
+ return;
555
+ }
556
+ const requestId = toolkit.nanoid();
557
+ set(defaultStateAtom, fetchTokenList.pending({ url, requestId }));
558
+ try {
559
+ const tokenList = yield getTokenList(url);
560
+ set(defaultStateAtom, fetchTokenList.fulfilled({ url, tokenList, requestId }));
561
+ } catch (error) {
562
+ set(defaultStateAtom, fetchTokenList.rejected({ url, requestId, errorMessage: error.message }));
563
+ }
564
+ }));
565
+ function useListState() {
566
+ return jotai.useAtom(defaultStateAtom);
567
+ }
568
+ function useListStateReady() {
569
+ const value = jotai.useAtomValue(isReadyAtom);
570
+ return value.state === "hasData" && value.data !== EMPTY;
571
+ }
572
+ return {
573
+ listsAtom: defaultStateAtom,
574
+ tokenAtom,
575
+ tokenBySymbolAtom,
576
+ fetchListAtom,
577
+ useListStateReady,
578
+ useListState
579
+ };
580
+ };
29
581
  var NEW_LIST_STATE = {
30
582
  error: null,
31
583
  current: null,
@@ -49,11 +601,11 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
49
601
  const current = (_a = state.byUrl[url]) == null ? void 0 : _a.current;
50
602
  const loadingRequestId = (_b = state.byUrl[url]) == null ? void 0 : _b.loadingRequestId;
51
603
  if (current) {
52
- const upgradeType = chunkOGWZ2K32_js.getVersionUpgrade(current.version, tokenList.version);
604
+ const upgradeType = chunkYOAEDKQH_js.getVersionUpgrade(current.version, tokenList.version);
53
605
  if (upgradeType === 0 /* NONE */)
54
606
  return;
55
607
  if (loadingRequestId === null || loadingRequestId === requestId) {
56
- state.byUrl[url] = chunk4TPCCB4K_js.__spreadProps(chunk4TPCCB4K_js.__spreadValues({}, state.byUrl[url]), {
608
+ state.byUrl[url] = chunkYOAEDKQH_js.__spreadProps(chunkYOAEDKQH_js.__spreadValues({}, state.byUrl[url]), {
57
609
  loadingRequestId: null,
58
610
  error: null,
59
611
  current,
@@ -64,7 +616,7 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
64
616
  if (DEFAULT_ACTIVE_LIST_URLS.includes(url) && state.activeListUrls && !state.activeListUrls.includes(url)) {
65
617
  state.activeListUrls.push(url);
66
618
  }
67
- state.byUrl[url] = chunk4TPCCB4K_js.__spreadProps(chunk4TPCCB4K_js.__spreadValues({}, state.byUrl[url]), {
619
+ state.byUrl[url] = chunkYOAEDKQH_js.__spreadProps(chunkYOAEDKQH_js.__spreadValues({}, state.byUrl[url]), {
68
620
  loadingRequestId: null,
69
621
  error: null,
70
622
  current: tokenList,
@@ -76,7 +628,7 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
76
628
  if (((_a = state.byUrl[url]) == null ? void 0 : _a.loadingRequestId) !== requestId) {
77
629
  return;
78
630
  }
79
- state.byUrl[url] = chunk4TPCCB4K_js.__spreadProps(chunk4TPCCB4K_js.__spreadValues({}, state.byUrl[url]), {
631
+ state.byUrl[url] = chunkYOAEDKQH_js.__spreadProps(chunkYOAEDKQH_js.__spreadValues({}, state.byUrl[url]), {
80
632
  loadingRequestId: null,
81
633
  error: errorMessage,
82
634
  current: null,
@@ -112,7 +664,7 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
112
664
  if (!((_a = state.byUrl[url]) == null ? void 0 : _a.pendingUpdate)) {
113
665
  throw new Error("accept list update called without pending update");
114
666
  }
115
- state.byUrl[url] = chunk4TPCCB4K_js.__spreadProps(chunk4TPCCB4K_js.__spreadValues({}, state.byUrl[url]), {
667
+ state.byUrl[url] = chunkYOAEDKQH_js.__spreadProps(chunkYOAEDKQH_js.__spreadValues({}, state.byUrl[url]), {
116
668
  pendingUpdate: null,
117
669
  current: state.byUrl[url].pendingUpdate
118
670
  });
@@ -149,75 +701,17 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
149
701
  }
150
702
  })
151
703
  );
152
- function noop() {
153
- }
154
- var noopStorage = {
155
- getItem: () => Promise.resolve(noop()),
156
- setItem: () => Promise.resolve(noop()),
157
- removeItem: () => Promise.resolve(noop())
158
- };
159
- var EMPTY = Symbol();
160
- var createListsAtom = (storeName, reducer, initialState) => {
161
- function IndexedDBStorage(dbName) {
162
- if (typeof window !== "undefined") {
163
- const db = localForage__default.default.createInstance({
164
- name: dbName,
165
- storeName
166
- });
167
- return {
168
- getItem: (key) => chunk4TPCCB4K_js.__async(this, null, function* () {
169
- const value = yield db.getItem(key);
170
- if (value) {
171
- return value;
172
- }
173
- return initialState;
174
- }),
175
- setItem: (k, v) => chunk4TPCCB4K_js.__async(this, null, function* () {
176
- if (v === EMPTY)
177
- return;
178
- yield db.setItem(k, v);
179
- }),
180
- removeItem: db.removeItem
181
- };
182
- }
183
- return noopStorage;
184
- }
185
- const listsStorageAtom = utils.atomWithStorage("lists", EMPTY, IndexedDBStorage("lists"));
186
- const defaultStateAtom = jotai.atom(
187
- (get) => {
188
- const value = get(utils.loadable(listsStorageAtom));
189
- if (value.state === "hasData" && value.data !== EMPTY) {
190
- return value.data;
191
- }
192
- return initialState;
193
- },
194
- (get, set, action) => chunk4TPCCB4K_js.__async(void 0, null, function* () {
195
- set(listsStorageAtom, reducer(yield get(defaultStateAtom), action));
196
- })
197
- );
198
- const isReadyAtom = utils.loadable(listsStorageAtom);
199
- function useListState() {
200
- return jotai.useAtom(defaultStateAtom);
201
- }
202
- function useListStateReady() {
203
- const value = jotai.useAtomValue(isReadyAtom);
204
- return value.state === "hasData" && value.data !== EMPTY;
205
- }
206
- return {
207
- listsAtom: defaultStateAtom,
208
- useListStateReady,
209
- useListState
210
- };
211
- };
212
704
  function useFetchListCallback(dispatch) {
213
705
  return react.useCallback(
214
- (listUrl, sendDispatch = true) => chunk4TPCCB4K_js.__async(this, null, function* () {
706
+ (listUrl, sendDispatch = true) => chunkYOAEDKQH_js.__async(this, null, function* () {
215
707
  const requestId = toolkit.nanoid();
216
708
  if (sendDispatch) {
217
709
  dispatch(fetchTokenList.pending({ requestId, url: listUrl }));
218
710
  }
219
- const getTokenList = (yield import('./getTokenList-A3DXVBCD.js')).default;
220
711
  return getTokenList(listUrl).then((tokenList) => {
712
+ if (!tokenList) {
713
+ throw new Error("Token list not found");
714
+ }
221
715
  if (sendDispatch) {
222
716
  dispatch(fetchTokenList.fulfilled({ url: listUrl, tokenList, requestId }));
223
717
  }
@@ -243,6 +737,9 @@ exports.createTokenListReducer = createTokenListReducer;
243
737
  exports.disableList = disableList;
244
738
  exports.enableList = enableList;
245
739
  exports.fetchTokenList = fetchTokenList;
740
+ exports.findTokenByAddress = findTokenByAddress;
741
+ exports.findTokenBySymbol = findTokenBySymbol;
742
+ exports.getTokenList = getTokenList;
246
743
  exports.rejectVersionUpdate = rejectVersionUpdate;
247
744
  exports.removeList = removeList;
248
745
  exports.updateListVersion = updateListVersion;