@pancakeswap/token-lists 0.0.6 → 0.0.8
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/.turbo/turbo-build.log +20 -14
- package/CHANGELOG.md +13 -0
- package/LICENSE +674 -0
- package/dist/chunk-2L3ZO4UM.mjs +1 -5
- package/dist/chunk-4TPCCB4K.js +45 -0
- package/dist/{chunk-YBVZDUCZ.mjs → chunk-COROHIJN.mjs} +23 -7
- package/dist/chunk-OGWZ2K32.js +92 -0
- package/dist/getTokenList-2FAKUE6D.mjs +5 -11
- package/dist/getTokenList-YNKBKHZ3.js +472 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +23 -95
- package/dist/index.mjs +2 -13
- package/dist/react.d.ts +1 -1
- package/dist/react.js +54 -644
- package/dist/react.mjs +13 -40
- package/dist/{types-d752b62d.d.ts → types-d6730d17.d.ts} +1 -1
- package/package.json +14 -11
- package/react/lists.ts +2 -2
- package/src/filtering.ts +34 -0
- package/src/index.ts +1 -0
- package/src/types.ts +1 -1
- package/src/wrappedTokenInfo.ts +1 -1
- package/tsconfig.json +1 -1
- package/tsup.config.ts +2 -0
package/dist/react.js
CHANGED
|
@@ -1,608 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __esm = (fn, res) => function __init() {
|
|
26
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
27
|
-
};
|
|
28
|
-
var __export = (target, all) => {
|
|
29
|
-
for (var name in all)
|
|
30
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
31
|
-
};
|
|
32
|
-
var __copyProps = (to, from, except, desc) => {
|
|
33
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
34
|
-
for (let key of __getOwnPropNames(from))
|
|
35
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
36
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
37
|
-
}
|
|
38
|
-
return to;
|
|
39
|
-
};
|
|
40
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
41
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
42
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
43
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
44
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
45
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
46
|
-
mod
|
|
47
|
-
));
|
|
48
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
49
|
-
var __async = (__this, __arguments, generator) => {
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
var fulfilled = (value) => {
|
|
52
|
-
try {
|
|
53
|
-
step(generator.next(value));
|
|
54
|
-
} catch (e) {
|
|
55
|
-
reject(e);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var rejected = (value) => {
|
|
59
|
-
try {
|
|
60
|
-
step(generator.throw(value));
|
|
61
|
-
} catch (e) {
|
|
62
|
-
reject(e);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
66
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// ../utils/uriToHttp.ts
|
|
71
|
-
function uriToHttp(uri) {
|
|
72
|
-
var _a, _b;
|
|
73
|
-
const protocol = uri.split(":")[0].toLowerCase();
|
|
74
|
-
switch (protocol) {
|
|
75
|
-
case "https":
|
|
76
|
-
return [uri];
|
|
77
|
-
case "http":
|
|
78
|
-
return [`https${uri.substring(4)}`, uri];
|
|
79
|
-
case "ipfs":
|
|
80
|
-
const hash = (_a = uri.match(/^ipfs:(\/\/)?(.*)$/i)) == null ? void 0 : _a[2];
|
|
81
|
-
return [`https://cloudflare-ipfs.com/ipfs/${hash}/`, `https://ipfs.io/ipfs/${hash}/`];
|
|
82
|
-
case "ipns":
|
|
83
|
-
const name = (_b = uri.match(/^ipns:(\/\/)?(.*)$/i)) == null ? void 0 : _b[2];
|
|
84
|
-
return [`https://cloudflare-ipfs.com/ipns/${name}/`, `https://ipfs.io/ipns/${name}/`];
|
|
85
|
-
default:
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
var init_uriToHttp = __esm({
|
|
90
|
-
"../utils/uriToHttp.ts"() {
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// schema/pancakeswap.json
|
|
95
|
-
var pancakeswap_default;
|
|
96
|
-
var init_pancakeswap = __esm({
|
|
97
|
-
"schema/pancakeswap.json"() {
|
|
98
|
-
pancakeswap_default = {
|
|
99
|
-
$schema: "http://json-schema.org/draft-07/schema#",
|
|
100
|
-
$id: "pancakeswap",
|
|
101
|
-
title: "PancakeSwap Token List",
|
|
102
|
-
description: "Schema for lists of tokens compatible with the PancakeSwap Interface, including Uniswap standard and PancakeSwap Aptos",
|
|
103
|
-
definitions: {
|
|
104
|
-
Version: {
|
|
105
|
-
type: "object",
|
|
106
|
-
description: "The version of the list, used in change detection",
|
|
107
|
-
examples: [
|
|
108
|
-
{
|
|
109
|
-
major: 1,
|
|
110
|
-
minor: 0,
|
|
111
|
-
patch: 0
|
|
112
|
-
}
|
|
113
|
-
],
|
|
114
|
-
additionalProperties: false,
|
|
115
|
-
properties: {
|
|
116
|
-
major: {
|
|
117
|
-
type: "integer",
|
|
118
|
-
description: "The major version of the list. Must be incremented when tokens are removed from the list or token addresses are changed.",
|
|
119
|
-
minimum: 0,
|
|
120
|
-
examples: [1, 2]
|
|
121
|
-
},
|
|
122
|
-
minor: {
|
|
123
|
-
type: "integer",
|
|
124
|
-
description: "The minor version of the list. Must be incremented when tokens are added to the list.",
|
|
125
|
-
minimum: 0,
|
|
126
|
-
examples: [0, 1]
|
|
127
|
-
},
|
|
128
|
-
patch: {
|
|
129
|
-
type: "integer",
|
|
130
|
-
description: "The patch version of the list. Must be incremented for any changes to the list.",
|
|
131
|
-
minimum: 0,
|
|
132
|
-
examples: [0, 1]
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
required: ["major", "minor", "patch"]
|
|
136
|
-
},
|
|
137
|
-
TagIdentifier: {
|
|
138
|
-
type: "string",
|
|
139
|
-
description: "The unique identifier of a tag",
|
|
140
|
-
minLength: 1,
|
|
141
|
-
maxLength: 10,
|
|
142
|
-
pattern: "^[\\w]+$",
|
|
143
|
-
examples: ["compound", "stablecoin"]
|
|
144
|
-
},
|
|
145
|
-
ExtensionIdentifier: {
|
|
146
|
-
type: "string",
|
|
147
|
-
description: "The name of a token extension property",
|
|
148
|
-
minLength: 1,
|
|
149
|
-
maxLength: 40,
|
|
150
|
-
pattern: "^[\\w]+$",
|
|
151
|
-
examples: ["color", "is_fee_on_transfer", "aliases"]
|
|
152
|
-
},
|
|
153
|
-
ExtensionMap: {
|
|
154
|
-
type: "object",
|
|
155
|
-
description: "An object containing any arbitrary or vendor-specific token metadata",
|
|
156
|
-
maxProperties: 10,
|
|
157
|
-
propertyNames: {
|
|
158
|
-
$ref: "#/definitions/ExtensionIdentifier"
|
|
159
|
-
},
|
|
160
|
-
additionalProperties: {
|
|
161
|
-
$ref: "#/definitions/ExtensionValue"
|
|
162
|
-
},
|
|
163
|
-
examples: [
|
|
164
|
-
{
|
|
165
|
-
color: "#000000",
|
|
166
|
-
is_verified_by_me: true
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
"x-bridged-addresses-by-chain": {
|
|
170
|
-
"1": {
|
|
171
|
-
bridgeAddress: "0x4200000000000000000000000000000000000010",
|
|
172
|
-
tokenAddress: "0x4200000000000000000000000000000000000010"
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
]
|
|
177
|
-
},
|
|
178
|
-
ExtensionPrimitiveValue: {
|
|
179
|
-
anyOf: [
|
|
180
|
-
{
|
|
181
|
-
type: "string",
|
|
182
|
-
minLength: 1,
|
|
183
|
-
maxLength: 42,
|
|
184
|
-
examples: ["#00000"]
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
type: "boolean",
|
|
188
|
-
examples: [true]
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
type: "number",
|
|
192
|
-
examples: [15]
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
type: "null"
|
|
196
|
-
}
|
|
197
|
-
]
|
|
198
|
-
},
|
|
199
|
-
ExtensionValue: {
|
|
200
|
-
anyOf: [
|
|
201
|
-
{
|
|
202
|
-
$ref: "#/definitions/ExtensionPrimitiveValue"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
type: "object",
|
|
206
|
-
maxProperties: 10,
|
|
207
|
-
propertyNames: {
|
|
208
|
-
$ref: "#/definitions/ExtensionIdentifier"
|
|
209
|
-
},
|
|
210
|
-
additionalProperties: {
|
|
211
|
-
$ref: "#/definitions/ExtensionValueInner0"
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
]
|
|
215
|
-
},
|
|
216
|
-
ExtensionValueInner0: {
|
|
217
|
-
anyOf: [
|
|
218
|
-
{
|
|
219
|
-
$ref: "#/definitions/ExtensionPrimitiveValue"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
type: "object",
|
|
223
|
-
maxProperties: 10,
|
|
224
|
-
propertyNames: {
|
|
225
|
-
$ref: "#/definitions/ExtensionIdentifier"
|
|
226
|
-
},
|
|
227
|
-
additionalProperties: {
|
|
228
|
-
$ref: "#/definitions/ExtensionValueInner1"
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
]
|
|
232
|
-
},
|
|
233
|
-
ExtensionValueInner1: {
|
|
234
|
-
anyOf: [
|
|
235
|
-
{
|
|
236
|
-
$ref: "#/definitions/ExtensionPrimitiveValue"
|
|
237
|
-
}
|
|
238
|
-
]
|
|
239
|
-
},
|
|
240
|
-
TagDefinition: {
|
|
241
|
-
type: "object",
|
|
242
|
-
description: "Definition of a tag that can be associated with a token via its identifier",
|
|
243
|
-
additionalProperties: false,
|
|
244
|
-
properties: {
|
|
245
|
-
name: {
|
|
246
|
-
type: "string",
|
|
247
|
-
description: "The name of the tag",
|
|
248
|
-
pattern: "^[ \\w]+$",
|
|
249
|
-
minLength: 1,
|
|
250
|
-
maxLength: 20
|
|
251
|
-
},
|
|
252
|
-
description: {
|
|
253
|
-
type: "string",
|
|
254
|
-
description: "A user-friendly description of the tag",
|
|
255
|
-
pattern: "^[ \\w\\.,:]+$",
|
|
256
|
-
minLength: 1,
|
|
257
|
-
maxLength: 200
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
required: ["name", "description"],
|
|
261
|
-
examples: [
|
|
262
|
-
{
|
|
263
|
-
name: "Stablecoin",
|
|
264
|
-
description: "A token with value pegged to another asset"
|
|
265
|
-
}
|
|
266
|
-
]
|
|
267
|
-
},
|
|
268
|
-
TokenInfo: {
|
|
269
|
-
type: "object",
|
|
270
|
-
description: "Metadata for a single token in a token list",
|
|
271
|
-
additionalProperties: false,
|
|
272
|
-
properties: {
|
|
273
|
-
chainId: {
|
|
274
|
-
type: "integer",
|
|
275
|
-
description: "The chain ID of the Ethereum network where this token is deployed",
|
|
276
|
-
minimum: 1,
|
|
277
|
-
examples: [1, 42]
|
|
278
|
-
},
|
|
279
|
-
address: {
|
|
280
|
-
type: "string",
|
|
281
|
-
description: "The checksummed address of the token on the specified chain ID",
|
|
282
|
-
pattern: "^0x[a-fA-F0-9]{40}$",
|
|
283
|
-
examples: ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]
|
|
284
|
-
},
|
|
285
|
-
decimals: {
|
|
286
|
-
type: "integer",
|
|
287
|
-
description: "The number of decimals for the token balance",
|
|
288
|
-
minimum: 0,
|
|
289
|
-
maximum: 255,
|
|
290
|
-
examples: [18]
|
|
291
|
-
},
|
|
292
|
-
name: {
|
|
293
|
-
type: "string",
|
|
294
|
-
description: "The name of the token",
|
|
295
|
-
minLength: 1,
|
|
296
|
-
maxLength: 40,
|
|
297
|
-
pattern: "^[ \\w.'+\\-%/\xC0-\xD6\xD8-\xF6\xF8-\xFF:&\\[\\]\\(\\)]+$",
|
|
298
|
-
examples: ["USD Coin"]
|
|
299
|
-
},
|
|
300
|
-
symbol: {
|
|
301
|
-
type: "string",
|
|
302
|
-
description: "The symbol for the token; must be alphanumeric",
|
|
303
|
-
pattern: "^[a-zA-Z0-9+\\-%/$.]+$",
|
|
304
|
-
minLength: 1,
|
|
305
|
-
maxLength: 20,
|
|
306
|
-
examples: ["USDC"]
|
|
307
|
-
},
|
|
308
|
-
logoURI: {
|
|
309
|
-
type: "string",
|
|
310
|
-
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",
|
|
311
|
-
format: "uri",
|
|
312
|
-
examples: ["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]
|
|
313
|
-
},
|
|
314
|
-
tags: {
|
|
315
|
-
type: "array",
|
|
316
|
-
description: "An array of tag identifiers associated with the token; tags are defined at the list level",
|
|
317
|
-
items: {
|
|
318
|
-
$ref: "#/definitions/TagIdentifier"
|
|
319
|
-
},
|
|
320
|
-
maxItems: 10,
|
|
321
|
-
examples: ["stablecoin", "compound"]
|
|
322
|
-
},
|
|
323
|
-
extensions: {
|
|
324
|
-
$ref: "#/definitions/ExtensionMap"
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
required: ["chainId", "address", "decimals", "name", "symbol"]
|
|
328
|
-
},
|
|
329
|
-
AptosTokenInfo: {
|
|
330
|
-
type: "object",
|
|
331
|
-
description: "Metadata for a single token in a token list",
|
|
332
|
-
additionalProperties: false,
|
|
333
|
-
properties: {
|
|
334
|
-
chainId: {
|
|
335
|
-
type: "integer",
|
|
336
|
-
description: "The chain ID of the Aptos network where this token is deployed, 0 is devent",
|
|
337
|
-
minimum: 0,
|
|
338
|
-
examples: [1, 42]
|
|
339
|
-
},
|
|
340
|
-
address: {
|
|
341
|
-
type: "string",
|
|
342
|
-
description: "The address of the coin on the specified chain ID",
|
|
343
|
-
examples: ["0x1::aptos_coin::AptosCoin"]
|
|
344
|
-
},
|
|
345
|
-
decimals: {
|
|
346
|
-
type: "integer",
|
|
347
|
-
description: "The number of decimals for the token balance",
|
|
348
|
-
minimum: 0,
|
|
349
|
-
maximum: 255,
|
|
350
|
-
examples: [18]
|
|
351
|
-
},
|
|
352
|
-
name: {
|
|
353
|
-
type: "string",
|
|
354
|
-
description: "The name of the token",
|
|
355
|
-
minLength: 1,
|
|
356
|
-
maxLength: 40,
|
|
357
|
-
pattern: "^[ \\w.'+\\-%/\xC0-\xD6\xD8-\xF6\xF8-\xFF:&\\[\\]\\(\\)]+$",
|
|
358
|
-
examples: ["USD Coin"]
|
|
359
|
-
},
|
|
360
|
-
symbol: {
|
|
361
|
-
type: "string",
|
|
362
|
-
description: "The symbol for the token; must be alphanumeric",
|
|
363
|
-
pattern: "^[a-zA-Z0-9+\\-%/$.]+$",
|
|
364
|
-
minLength: 1,
|
|
365
|
-
maxLength: 20,
|
|
366
|
-
examples: ["USDC"]
|
|
367
|
-
},
|
|
368
|
-
logoURI: {
|
|
369
|
-
type: "string",
|
|
370
|
-
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",
|
|
371
|
-
format: "uri",
|
|
372
|
-
examples: ["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]
|
|
373
|
-
},
|
|
374
|
-
tags: {
|
|
375
|
-
type: "array",
|
|
376
|
-
description: "An array of tag identifiers associated with the token; tags are defined at the list level",
|
|
377
|
-
items: {
|
|
378
|
-
$ref: "#/definitions/TagIdentifier"
|
|
379
|
-
},
|
|
380
|
-
maxItems: 10,
|
|
381
|
-
examples: ["stablecoin", "compound"]
|
|
382
|
-
},
|
|
383
|
-
extensions: {
|
|
384
|
-
$ref: "#/definitions/ExtensionMap"
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
required: ["chainId", "address", "decimals", "name", "symbol"]
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
type: "object",
|
|
391
|
-
additionalProperties: false,
|
|
392
|
-
properties: {
|
|
393
|
-
name: {
|
|
394
|
-
type: "string",
|
|
395
|
-
description: "The name of the token list",
|
|
396
|
-
minLength: 1,
|
|
397
|
-
maxLength: 30,
|
|
398
|
-
pattern: "^[\\w ]+$",
|
|
399
|
-
examples: ["My Token List"]
|
|
400
|
-
},
|
|
401
|
-
timestamp: {
|
|
402
|
-
type: "string",
|
|
403
|
-
format: "date-time",
|
|
404
|
-
description: "The timestamp of this list version; i.e. when this immutable version of the list was created"
|
|
405
|
-
},
|
|
406
|
-
schema: {
|
|
407
|
-
type: "string"
|
|
408
|
-
},
|
|
409
|
-
version: {
|
|
410
|
-
$ref: "#/definitions/Version"
|
|
411
|
-
},
|
|
412
|
-
tokens: {
|
|
413
|
-
type: "array",
|
|
414
|
-
description: "The list of tokens included in the list",
|
|
415
|
-
minItems: 1,
|
|
416
|
-
maxItems: 1e4
|
|
417
|
-
},
|
|
418
|
-
keywords: {
|
|
419
|
-
type: "array",
|
|
420
|
-
description: "Keywords associated with the contents of the list; may be used in list discoverability",
|
|
421
|
-
items: {
|
|
422
|
-
type: "string",
|
|
423
|
-
description: "A keyword to describe the contents of the list",
|
|
424
|
-
minLength: 1,
|
|
425
|
-
maxLength: 20,
|
|
426
|
-
pattern: "^[\\w ]+$",
|
|
427
|
-
examples: ["compound", "lending", "personal tokens"]
|
|
428
|
-
},
|
|
429
|
-
maxItems: 20,
|
|
430
|
-
uniqueItems: true
|
|
431
|
-
},
|
|
432
|
-
tags: {
|
|
433
|
-
type: "object",
|
|
434
|
-
description: "A mapping of tag identifiers to their name and description",
|
|
435
|
-
propertyNames: {
|
|
436
|
-
$ref: "#/definitions/TagIdentifier"
|
|
437
|
-
},
|
|
438
|
-
additionalProperties: {
|
|
439
|
-
$ref: "#/definitions/TagDefinition"
|
|
440
|
-
},
|
|
441
|
-
maxProperties: 20,
|
|
442
|
-
examples: [
|
|
443
|
-
{
|
|
444
|
-
stablecoin: {
|
|
445
|
-
name: "Stablecoin",
|
|
446
|
-
description: "A token with value pegged to another asset"
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
]
|
|
450
|
-
},
|
|
451
|
-
logoURI: {
|
|
452
|
-
type: "string",
|
|
453
|
-
description: "A URI for the logo of the token list; prefer SVG or PNG of size 256x256",
|
|
454
|
-
format: "uri",
|
|
455
|
-
examples: ["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
if: {
|
|
459
|
-
properties: { schema: { const: "aptos" } },
|
|
460
|
-
required: ["name", "timestamp", "version", "tokens", "schema"]
|
|
461
|
-
},
|
|
462
|
-
then: {
|
|
463
|
-
properties: {
|
|
464
|
-
tokens: {
|
|
465
|
-
items: {
|
|
466
|
-
$ref: "#/definitions/AptosTokenInfo"
|
|
467
|
-
},
|
|
468
|
-
type: "array",
|
|
469
|
-
description: "The list of tokens included in the list",
|
|
470
|
-
minItems: 1,
|
|
471
|
-
maxItems: 1e4
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
},
|
|
475
|
-
else: {
|
|
476
|
-
properties: {
|
|
477
|
-
tokens: {
|
|
478
|
-
items: {
|
|
479
|
-
$ref: "#/definitions/TokenInfo"
|
|
480
|
-
},
|
|
481
|
-
type: "array",
|
|
482
|
-
description: "The list of tokens included in the list",
|
|
483
|
-
minItems: 1,
|
|
484
|
-
maxItems: 1e4
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
},
|
|
488
|
-
required: ["name", "timestamp", "version", "tokens"]
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
});
|
|
1
|
+
'use strict';
|
|
492
2
|
|
|
493
|
-
|
|
494
|
-
var
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
return __async(this, null, function* () {
|
|
501
|
-
var _a, _b;
|
|
502
|
-
const urls = uriToHttp(listUrl);
|
|
503
|
-
for (let i = 0; i < urls.length; i++) {
|
|
504
|
-
const url = urls[i];
|
|
505
|
-
const isLast = i === urls.length - 1;
|
|
506
|
-
let response;
|
|
507
|
-
try {
|
|
508
|
-
response = yield fetch(url);
|
|
509
|
-
} catch (error) {
|
|
510
|
-
console.error("Failed to fetch list", listUrl, error);
|
|
511
|
-
if (isLast)
|
|
512
|
-
throw new Error(`Failed to download list ${listUrl}`);
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
if (!response.ok) {
|
|
516
|
-
if (isLast)
|
|
517
|
-
throw new Error(`Failed to download list ${listUrl}`);
|
|
518
|
-
continue;
|
|
519
|
-
}
|
|
520
|
-
const json = yield response.json();
|
|
521
|
-
if (json.tokens) {
|
|
522
|
-
(0, import_remove.default)(json.tokens, (token) => {
|
|
523
|
-
return token.symbol ? token.symbol.length === 0 : true;
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
if (!tokenListValidator(json)) {
|
|
527
|
-
const validationErrors = (_b = (_a = tokenListValidator.errors) == null ? void 0 : _a.reduce((memo, error) => {
|
|
528
|
-
var _a2;
|
|
529
|
-
const add = `${error.dataPath} ${(_a2 = error.message) != null ? _a2 : ""}`;
|
|
530
|
-
return memo.length > 0 ? `${memo}; ${add}` : `${add}`;
|
|
531
|
-
}, "")) != null ? _b : "unknown error";
|
|
532
|
-
throw new Error(`Token list failed validation: ${validationErrors}`);
|
|
533
|
-
}
|
|
534
|
-
return json;
|
|
535
|
-
}
|
|
536
|
-
throw new Error("Unrecognized list URL protocol.");
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
var import_remove, import_ajv, tokenListValidator;
|
|
540
|
-
var init_getTokenList = __esm({
|
|
541
|
-
"react/getTokenList.ts"() {
|
|
542
|
-
"use strict";
|
|
543
|
-
init_uriToHttp();
|
|
544
|
-
import_remove = __toESM(require("lodash/remove"));
|
|
545
|
-
import_ajv = __toESM(require("ajv"));
|
|
546
|
-
init_pancakeswap();
|
|
547
|
-
tokenListValidator = new import_ajv.default({ allErrors: true }).compile(pancakeswap_default);
|
|
548
|
-
}
|
|
549
|
-
});
|
|
3
|
+
var chunkOGWZ2K32_js = require('./chunk-OGWZ2K32.js');
|
|
4
|
+
var chunk4TPCCB4K_js = require('./chunk-4TPCCB4K.js');
|
|
5
|
+
var toolkit = require('@reduxjs/toolkit');
|
|
6
|
+
var jotai = require('jotai');
|
|
7
|
+
var utils = require('jotai/utils');
|
|
8
|
+
var localForage = require('localforage');
|
|
9
|
+
var react = require('react');
|
|
550
10
|
|
|
551
|
-
|
|
552
|
-
var react_exports = {};
|
|
553
|
-
__export(react_exports, {
|
|
554
|
-
NEW_LIST_STATE: () => NEW_LIST_STATE,
|
|
555
|
-
acceptListUpdate: () => acceptListUpdate,
|
|
556
|
-
addList: () => addList,
|
|
557
|
-
createListsAtom: () => createListsAtom,
|
|
558
|
-
createTokenListReducer: () => createTokenListReducer,
|
|
559
|
-
disableList: () => disableList,
|
|
560
|
-
enableList: () => enableList,
|
|
561
|
-
fetchTokenList: () => fetchTokenList,
|
|
562
|
-
rejectVersionUpdate: () => rejectVersionUpdate,
|
|
563
|
-
removeList: () => removeList,
|
|
564
|
-
updateListVersion: () => updateListVersion,
|
|
565
|
-
useFetchListCallback: () => useFetchListCallback_default
|
|
566
|
-
});
|
|
567
|
-
module.exports = __toCommonJS(react_exports);
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
568
12
|
|
|
569
|
-
|
|
570
|
-
var import_toolkit2 = require("@reduxjs/toolkit");
|
|
13
|
+
var localForage__default = /*#__PURE__*/_interopDefault(localForage);
|
|
571
14
|
|
|
572
|
-
// react/actions.ts
|
|
573
|
-
var import_toolkit = require("@reduxjs/toolkit");
|
|
574
15
|
var fetchTokenList = {
|
|
575
|
-
pending:
|
|
576
|
-
fulfilled:
|
|
577
|
-
rejected:
|
|
16
|
+
pending: toolkit.createAction("lists/fetchTokenList/pending"),
|
|
17
|
+
fulfilled: toolkit.createAction("lists/fetchTokenList/fulfilled"),
|
|
18
|
+
rejected: toolkit.createAction("lists/fetchTokenList/rejected")
|
|
578
19
|
};
|
|
579
|
-
var addList =
|
|
580
|
-
var removeList =
|
|
581
|
-
var enableList =
|
|
582
|
-
var disableList =
|
|
583
|
-
var acceptListUpdate =
|
|
584
|
-
var rejectVersionUpdate =
|
|
585
|
-
var updateListVersion =
|
|
586
|
-
|
|
587
|
-
// src/wrappedTokenInfo.ts
|
|
588
|
-
var import_swap_sdk_core = require("@pancakeswap/swap-sdk-core");
|
|
589
|
-
|
|
590
|
-
// src/getVersionUpgrade.ts
|
|
591
|
-
function getVersionUpgrade(base, update) {
|
|
592
|
-
if (update.major > base.major) {
|
|
593
|
-
return 3 /* MAJOR */;
|
|
594
|
-
}
|
|
595
|
-
if (update.major < base.major) {
|
|
596
|
-
return 0 /* NONE */;
|
|
597
|
-
}
|
|
598
|
-
if (update.minor > base.minor) {
|
|
599
|
-
return 2 /* MINOR */;
|
|
600
|
-
}
|
|
601
|
-
if (update.minor < base.minor) {
|
|
602
|
-
return 0 /* NONE */;
|
|
603
|
-
}
|
|
604
|
-
return update.patch > base.patch ? 1 /* PATCH */ : 0 /* NONE */;
|
|
605
|
-
}
|
|
20
|
+
var addList = toolkit.createAction("lists/addList");
|
|
21
|
+
var removeList = toolkit.createAction("lists/removeList");
|
|
22
|
+
var enableList = toolkit.createAction("lists/enableList");
|
|
23
|
+
var disableList = toolkit.createAction("lists/disableList");
|
|
24
|
+
var acceptListUpdate = toolkit.createAction("lists/acceptListUpdate");
|
|
25
|
+
var rejectVersionUpdate = toolkit.createAction("lists/rejectVersionUpdate");
|
|
26
|
+
var updateListVersion = toolkit.createAction("lists/updateListVersion");
|
|
606
27
|
|
|
607
28
|
// react/reducer.ts
|
|
608
29
|
var NEW_LIST_STATE = {
|
|
@@ -611,7 +32,7 @@ var NEW_LIST_STATE = {
|
|
|
611
32
|
loadingRequestId: null,
|
|
612
33
|
pendingUpdate: null
|
|
613
34
|
};
|
|
614
|
-
var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIVE_LIST_URLS) =>
|
|
35
|
+
var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIVE_LIST_URLS) => toolkit.createReducer(
|
|
615
36
|
initialState,
|
|
616
37
|
(builder) => builder.addCase(fetchTokenList.pending, (state, { payload: { requestId, url } }) => {
|
|
617
38
|
var _a, _b, _c, _d;
|
|
@@ -628,11 +49,11 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
|
|
|
628
49
|
const current = (_a = state.byUrl[url]) == null ? void 0 : _a.current;
|
|
629
50
|
const loadingRequestId = (_b = state.byUrl[url]) == null ? void 0 : _b.loadingRequestId;
|
|
630
51
|
if (current) {
|
|
631
|
-
const upgradeType = getVersionUpgrade(current.version, tokenList.version);
|
|
52
|
+
const upgradeType = chunkOGWZ2K32_js.getVersionUpgrade(current.version, tokenList.version);
|
|
632
53
|
if (upgradeType === 0 /* NONE */)
|
|
633
54
|
return;
|
|
634
55
|
if (loadingRequestId === null || loadingRequestId === requestId) {
|
|
635
|
-
state.byUrl[url] = __spreadProps(__spreadValues({}, state.byUrl[url]), {
|
|
56
|
+
state.byUrl[url] = chunk4TPCCB4K_js.__spreadProps(chunk4TPCCB4K_js.__spreadValues({}, state.byUrl[url]), {
|
|
636
57
|
loadingRequestId: null,
|
|
637
58
|
error: null,
|
|
638
59
|
current,
|
|
@@ -643,7 +64,7 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
|
|
|
643
64
|
if (DEFAULT_ACTIVE_LIST_URLS.includes(url) && state.activeListUrls && !state.activeListUrls.includes(url)) {
|
|
644
65
|
state.activeListUrls.push(url);
|
|
645
66
|
}
|
|
646
|
-
state.byUrl[url] = __spreadProps(__spreadValues({}, state.byUrl[url]), {
|
|
67
|
+
state.byUrl[url] = chunk4TPCCB4K_js.__spreadProps(chunk4TPCCB4K_js.__spreadValues({}, state.byUrl[url]), {
|
|
647
68
|
loadingRequestId: null,
|
|
648
69
|
error: null,
|
|
649
70
|
current: tokenList,
|
|
@@ -655,7 +76,7 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
|
|
|
655
76
|
if (((_a = state.byUrl[url]) == null ? void 0 : _a.loadingRequestId) !== requestId) {
|
|
656
77
|
return;
|
|
657
78
|
}
|
|
658
|
-
state.byUrl[url] = __spreadProps(__spreadValues({}, state.byUrl[url]), {
|
|
79
|
+
state.byUrl[url] = chunk4TPCCB4K_js.__spreadProps(chunk4TPCCB4K_js.__spreadValues({}, state.byUrl[url]), {
|
|
659
80
|
loadingRequestId: null,
|
|
660
81
|
error: errorMessage,
|
|
661
82
|
current: null,
|
|
@@ -691,7 +112,7 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
|
|
|
691
112
|
if (!((_a = state.byUrl[url]) == null ? void 0 : _a.pendingUpdate)) {
|
|
692
113
|
throw new Error("accept list update called without pending update");
|
|
693
114
|
}
|
|
694
|
-
state.byUrl[url] = __spreadProps(__spreadValues({}, state.byUrl[url]), {
|
|
115
|
+
state.byUrl[url] = chunk4TPCCB4K_js.__spreadProps(chunk4TPCCB4K_js.__spreadValues({}, state.byUrl[url]), {
|
|
695
116
|
pendingUpdate: null,
|
|
696
117
|
current: state.byUrl[url].pendingUpdate
|
|
697
118
|
});
|
|
@@ -728,11 +149,6 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
|
|
|
728
149
|
}
|
|
729
150
|
})
|
|
730
151
|
);
|
|
731
|
-
|
|
732
|
-
// react/lists.ts
|
|
733
|
-
var import_jotai = require("jotai");
|
|
734
|
-
var import_utils = require("jotai/utils");
|
|
735
|
-
var import_localforage = __toESM(require("localforage"));
|
|
736
152
|
function noop() {
|
|
737
153
|
}
|
|
738
154
|
var noopStorage = {
|
|
@@ -746,13 +162,13 @@ var EMPTY = Symbol();
|
|
|
746
162
|
var createListsAtom = (storeName, reducer, initialState) => {
|
|
747
163
|
function IndexedDBStorage(dbName) {
|
|
748
164
|
if (typeof window !== "undefined") {
|
|
749
|
-
const db =
|
|
165
|
+
const db = localForage__default.default.createInstance({
|
|
750
166
|
name: dbName,
|
|
751
167
|
storeName
|
|
752
168
|
});
|
|
753
169
|
return {
|
|
754
170
|
db,
|
|
755
|
-
getItem: (key) => __async(this, null, function* () {
|
|
171
|
+
getItem: (key) => chunk4TPCCB4K_js.__async(this, null, function* () {
|
|
756
172
|
const value = yield db.getItem(key);
|
|
757
173
|
if (value) {
|
|
758
174
|
return value;
|
|
@@ -769,13 +185,13 @@ var createListsAtom = (storeName, reducer, initialState) => {
|
|
|
769
185
|
}
|
|
770
186
|
return noopStorage;
|
|
771
187
|
}
|
|
772
|
-
const listsStorageAtom =
|
|
188
|
+
const listsStorageAtom = utils.atomWithStorage(
|
|
773
189
|
"lists",
|
|
774
190
|
EMPTY,
|
|
775
191
|
// @ts-ignore
|
|
776
192
|
IndexedDBStorage("lists")
|
|
777
193
|
);
|
|
778
|
-
const defaultStateAtom =
|
|
194
|
+
const defaultStateAtom = jotai.atom(
|
|
779
195
|
(get) => {
|
|
780
196
|
const got = get(listsStorageAtom);
|
|
781
197
|
if (got === EMPTY) {
|
|
@@ -783,16 +199,16 @@ var createListsAtom = (storeName, reducer, initialState) => {
|
|
|
783
199
|
}
|
|
784
200
|
return got;
|
|
785
201
|
},
|
|
786
|
-
(get, set, action) => {
|
|
787
|
-
set(listsStorageAtom, reducer(get(defaultStateAtom), action));
|
|
788
|
-
}
|
|
202
|
+
(get, set, action) => chunk4TPCCB4K_js.__async(void 0, null, function* () {
|
|
203
|
+
set(listsStorageAtom, reducer(yield get(defaultStateAtom), action));
|
|
204
|
+
})
|
|
789
205
|
);
|
|
790
|
-
const isReadyAtom =
|
|
206
|
+
const isReadyAtom = jotai.atom((get) => get(listsStorageAtom) !== EMPTY);
|
|
791
207
|
function useListState() {
|
|
792
|
-
return
|
|
208
|
+
return jotai.useAtom(defaultStateAtom);
|
|
793
209
|
}
|
|
794
210
|
function useListStateReady() {
|
|
795
|
-
return
|
|
211
|
+
return jotai.useAtomValue(isReadyAtom);
|
|
796
212
|
}
|
|
797
213
|
return {
|
|
798
214
|
listsAtom: defaultStateAtom,
|
|
@@ -800,19 +216,15 @@ var createListsAtom = (storeName, reducer, initialState) => {
|
|
|
800
216
|
useListState
|
|
801
217
|
};
|
|
802
218
|
};
|
|
803
|
-
|
|
804
|
-
// react/useFetchListCallback.ts
|
|
805
|
-
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
806
|
-
var import_react = require("react");
|
|
807
219
|
function useFetchListCallback(dispatch) {
|
|
808
|
-
return
|
|
809
|
-
(listUrl, sendDispatch = true) => __async(this, null, function* () {
|
|
810
|
-
const requestId =
|
|
220
|
+
return react.useCallback(
|
|
221
|
+
(listUrl, sendDispatch = true) => chunk4TPCCB4K_js.__async(this, null, function* () {
|
|
222
|
+
const requestId = toolkit.nanoid();
|
|
811
223
|
if (sendDispatch) {
|
|
812
224
|
dispatch(fetchTokenList.pending({ requestId, url: listUrl }));
|
|
813
225
|
}
|
|
814
|
-
const
|
|
815
|
-
return
|
|
226
|
+
const getTokenList = (yield import('./getTokenList-YNKBKHZ3.js')).default;
|
|
227
|
+
return getTokenList(listUrl).then((tokenList) => {
|
|
816
228
|
if (sendDispatch) {
|
|
817
229
|
dispatch(fetchTokenList.fulfilled({ url: listUrl, tokenList, requestId }));
|
|
818
230
|
}
|
|
@@ -829,18 +241,16 @@ function useFetchListCallback(dispatch) {
|
|
|
829
241
|
);
|
|
830
242
|
}
|
|
831
243
|
var useFetchListCallback_default = useFetchListCallback;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
useFetchListCallback
|
|
846
|
-
});
|
|
244
|
+
|
|
245
|
+
exports.NEW_LIST_STATE = NEW_LIST_STATE;
|
|
246
|
+
exports.acceptListUpdate = acceptListUpdate;
|
|
247
|
+
exports.addList = addList;
|
|
248
|
+
exports.createListsAtom = createListsAtom;
|
|
249
|
+
exports.createTokenListReducer = createTokenListReducer;
|
|
250
|
+
exports.disableList = disableList;
|
|
251
|
+
exports.enableList = enableList;
|
|
252
|
+
exports.fetchTokenList = fetchTokenList;
|
|
253
|
+
exports.rejectVersionUpdate = rejectVersionUpdate;
|
|
254
|
+
exports.removeList = removeList;
|
|
255
|
+
exports.updateListVersion = updateListVersion;
|
|
256
|
+
exports.useFetchListCallback = useFetchListCallback_default;
|