@pancakeswap/token-lists 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +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 +3 -1
- package/dist/index.js +23 -95
- package/dist/index.mjs +2 -13
- package/dist/react.d.ts +1 -1
- package/dist/react.js +52 -643
- package/dist/react.mjs +11 -39
- package/package.json +14 -11
- package/react/lists.ts +1 -2
- package/src/filtering.ts +34 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +2 -0
- package/.turbo/turbo-build.log +0 -23
package/dist/react.mjs
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./chunk-2L3ZO4UM.mjs";
|
|
1
|
+
import { getVersionUpgrade } from './chunk-COROHIJN.mjs';
|
|
2
|
+
import { __spreadProps, __spreadValues, __async } from './chunk-2L3ZO4UM.mjs';
|
|
3
|
+
import { createAction, createReducer, nanoid } from '@reduxjs/toolkit';
|
|
4
|
+
import { atom, useAtom, useAtomValue } from 'jotai';
|
|
5
|
+
import { atomWithStorage } from 'jotai/utils';
|
|
6
|
+
import localForage from 'localforage';
|
|
7
|
+
import { useCallback } from 'react';
|
|
9
8
|
|
|
10
|
-
// react/reducer.ts
|
|
11
|
-
import { createReducer } from "@reduxjs/toolkit";
|
|
12
|
-
|
|
13
|
-
// react/actions.ts
|
|
14
|
-
import { createAction } from "@reduxjs/toolkit";
|
|
15
9
|
var fetchTokenList = {
|
|
16
10
|
pending: createAction("lists/fetchTokenList/pending"),
|
|
17
11
|
fulfilled: createAction("lists/fetchTokenList/fulfilled"),
|
|
@@ -149,11 +143,6 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
|
|
|
149
143
|
}
|
|
150
144
|
})
|
|
151
145
|
);
|
|
152
|
-
|
|
153
|
-
// react/lists.ts
|
|
154
|
-
import { atom, useAtom, useAtomValue } from "jotai";
|
|
155
|
-
import { atomWithStorage } from "jotai/utils";
|
|
156
|
-
import localForage from "localforage";
|
|
157
146
|
function noop() {
|
|
158
147
|
}
|
|
159
148
|
var noopStorage = {
|
|
@@ -185,8 +174,7 @@ var createListsAtom = (storeName, reducer, initialState) => {
|
|
|
185
174
|
return;
|
|
186
175
|
return db.setItem(k, v);
|
|
187
176
|
},
|
|
188
|
-
removeItem: db.removeItem
|
|
189
|
-
delayInit: true
|
|
177
|
+
removeItem: db.removeItem
|
|
190
178
|
};
|
|
191
179
|
}
|
|
192
180
|
return noopStorage;
|
|
@@ -222,10 +210,6 @@ var createListsAtom = (storeName, reducer, initialState) => {
|
|
|
222
210
|
useListState
|
|
223
211
|
};
|
|
224
212
|
};
|
|
225
|
-
|
|
226
|
-
// react/useFetchListCallback.ts
|
|
227
|
-
import { nanoid } from "@reduxjs/toolkit";
|
|
228
|
-
import { useCallback } from "react";
|
|
229
213
|
function useFetchListCallback(dispatch) {
|
|
230
214
|
return useCallback(
|
|
231
215
|
(listUrl, sendDispatch = true) => __async(this, null, function* () {
|
|
@@ -233,7 +217,7 @@ function useFetchListCallback(dispatch) {
|
|
|
233
217
|
if (sendDispatch) {
|
|
234
218
|
dispatch(fetchTokenList.pending({ requestId, url: listUrl }));
|
|
235
219
|
}
|
|
236
|
-
const getTokenList = (yield import(
|
|
220
|
+
const getTokenList = (yield import('./getTokenList-2FAKUE6D.mjs')).default;
|
|
237
221
|
return getTokenList(listUrl).then((tokenList) => {
|
|
238
222
|
if (sendDispatch) {
|
|
239
223
|
dispatch(fetchTokenList.fulfilled({ url: listUrl, tokenList, requestId }));
|
|
@@ -251,17 +235,5 @@ function useFetchListCallback(dispatch) {
|
|
|
251
235
|
);
|
|
252
236
|
}
|
|
253
237
|
var useFetchListCallback_default = useFetchListCallback;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
acceptListUpdate,
|
|
257
|
-
addList,
|
|
258
|
-
createListsAtom,
|
|
259
|
-
createTokenListReducer,
|
|
260
|
-
disableList,
|
|
261
|
-
enableList,
|
|
262
|
-
fetchTokenList,
|
|
263
|
-
rejectVersionUpdate,
|
|
264
|
-
removeList,
|
|
265
|
-
updateListVersion,
|
|
266
|
-
useFetchListCallback_default as useFetchListCallback
|
|
267
|
-
};
|
|
238
|
+
|
|
239
|
+
export { NEW_LIST_STATE, acceptListUpdate, addList, createListsAtom, createTokenListReducer, disableList, enableList, fetchTokenList, rejectVersionUpdate, removeList, updateListVersion, useFetchListCallback_default as useFetchListCallback };
|
package/package.json
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pancakeswap/token-lists",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsup",
|
|
9
|
-
"dev": "tsup --watch",
|
|
10
|
-
"prepublishOnly": "yarn run build",
|
|
11
|
-
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
12
|
-
},
|
|
13
7
|
"dependencies": {
|
|
14
8
|
"ajv": "^6.12.3",
|
|
15
9
|
"lodash": "^4.17.21",
|
|
16
|
-
"@pancakeswap/swap-sdk-core": "
|
|
10
|
+
"@pancakeswap/swap-sdk-core": "1.0.0"
|
|
17
11
|
},
|
|
18
12
|
"peerDependencies": {
|
|
19
13
|
"@reduxjs/toolkit": "^1.9.1",
|
|
20
14
|
"localforage": "^1.10.0",
|
|
21
|
-
"jotai": "^
|
|
15
|
+
"jotai": "^2.0.3",
|
|
22
16
|
"react": "^18.2.0"
|
|
23
17
|
},
|
|
24
18
|
"devDependencies": {
|
|
19
|
+
"@types/react": "^18.0.17",
|
|
20
|
+
"localforage": "^1.10.0",
|
|
21
|
+
"jotai": "^2.0.3",
|
|
25
22
|
"@reduxjs/toolkit": "^1.9.1",
|
|
26
23
|
"react": "^18.2.0",
|
|
27
|
-
"tsup": "^6.
|
|
24
|
+
"tsup": "^6.7.0",
|
|
25
|
+
"@pancakeswap/utils": "1.0.0"
|
|
28
26
|
},
|
|
29
27
|
"exports": {
|
|
30
28
|
".": {
|
|
@@ -51,5 +49,10 @@
|
|
|
51
49
|
"jotai": {
|
|
52
50
|
"optional": true
|
|
53
51
|
}
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup",
|
|
55
|
+
"dev": "tsup --watch",
|
|
56
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
54
57
|
}
|
|
55
|
-
}
|
|
58
|
+
}
|
package/react/lists.ts
CHANGED
|
@@ -42,7 +42,6 @@ export const createListsAtom = (storeName: string, reducer: any, initialState: a
|
|
|
42
42
|
return db.setItem(k, v)
|
|
43
43
|
},
|
|
44
44
|
removeItem: db.removeItem,
|
|
45
|
-
delayInit: true,
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
return noopStorage
|
|
@@ -55,7 +54,7 @@ export const createListsAtom = (storeName: string, reducer: any, initialState: a
|
|
|
55
54
|
IndexedDBStorage('lists'),
|
|
56
55
|
)
|
|
57
56
|
|
|
58
|
-
const defaultStateAtom = atom<ListsState, any>(
|
|
57
|
+
const defaultStateAtom = atom<ListsState, any, void>(
|
|
59
58
|
(get) => {
|
|
60
59
|
const got = get(listsStorageAtom)
|
|
61
60
|
if (got === EMPTY) {
|
package/src/filtering.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Token } from '@pancakeswap/swap-sdk-core'
|
|
2
|
+
import { TokenInfo } from './types'
|
|
3
|
+
|
|
4
|
+
export function createFilterToken<T extends TokenInfo | Token>(
|
|
5
|
+
search: string,
|
|
6
|
+
isAddress: (address: string) => boolean,
|
|
7
|
+
): (token: T) => boolean {
|
|
8
|
+
if (isAddress(search)) {
|
|
9
|
+
const address = search.toLowerCase()
|
|
10
|
+
return (t: T) => 'address' in t && address === t.address.toLowerCase()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const lowerSearchParts = search
|
|
14
|
+
.toLowerCase()
|
|
15
|
+
.split(/\s+/)
|
|
16
|
+
.filter((s) => s.length > 0)
|
|
17
|
+
|
|
18
|
+
if (lowerSearchParts.length === 0) {
|
|
19
|
+
return () => true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const matchesSearch = (s: string): boolean => {
|
|
23
|
+
const sParts = s
|
|
24
|
+
.toLowerCase()
|
|
25
|
+
.split(/\s+/)
|
|
26
|
+
.filter((s_) => s_.length > 0)
|
|
27
|
+
|
|
28
|
+
return lowerSearchParts.every((p) => p.length === 0 || sParts.some((sp) => sp.startsWith(p) || sp.endsWith(p)))
|
|
29
|
+
}
|
|
30
|
+
return (token) => {
|
|
31
|
+
const { symbol, name } = token
|
|
32
|
+
return Boolean((symbol && matchesSearch(symbol)) || (name && matchesSearch(name)))
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/index.ts
CHANGED
package/tsconfig.json
CHANGED
package/tsup.config.ts
CHANGED
package/.turbo/turbo-build.log
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
warning package.json: No license field
|
|
2
|
-
$ tsup
|
|
3
|
-
[34mCLI[39m Building entry: {"index":"./src/index.ts","react":"./react/index.ts"}
|
|
4
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
|
-
[34mCLI[39m tsup v6.6.3
|
|
6
|
-
[34mCLI[39m Using tsup config: /home/runner/work/pancake-frontend/pancake-frontend/packages/token-lists/tsup.config.ts
|
|
7
|
-
[34mCLI[39m Target: es6
|
|
8
|
-
[34mESM[39m Build start
|
|
9
|
-
[34mCJS[39m Build start
|
|
10
|
-
[32mCJS[39m [1mdist/index.js [22m[32m3.11 KB[39m
|
|
11
|
-
[32mCJS[39m [1mdist/react.js [22m[32m28.00 KB[39m
|
|
12
|
-
[32mCJS[39m ⚡️ Build success in 90ms
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m239.00 B[39m
|
|
14
|
-
[32mESM[39m [1mdist/react.mjs [22m[32m8.47 KB[39m
|
|
15
|
-
[32mESM[39m [1mdist/chunk-YBVZDUCZ.mjs [22m[32m1.92 KB[39m
|
|
16
|
-
[32mESM[39m [1mdist/getTokenList-2FAKUE6D.mjs [22m[32m13.43 KB[39m
|
|
17
|
-
[32mESM[39m [1mdist/chunk-2L3ZO4UM.mjs [22m[32m1.42 KB[39m
|
|
18
|
-
[32mESM[39m ⚡️ Build success in 93ms
|
|
19
|
-
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in 17357ms
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.51 KB[39m
|
|
22
|
-
[32mDTS[39m [1mdist/react.d.ts [22m[32m2.50 KB[39m
|
|
23
|
-
[32mDTS[39m [1mdist/types-d752b62d.d.ts [22m[32m1.02 KB[39m
|