@pancakeswap/token-lists 0.0.7 → 0.0.9

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.
@@ -0,0 +1,29 @@
1
+
2
+ > @pancakeswap/token-lists@0.0.9 build /home/runner/work/pancake-frontend/pancake-frontend/packages/token-lists
3
+ > tsup
4
+
5
+ CLI Building entry: {"index":"./src/index.ts","react":"./react/index.ts"}
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v6.7.0
8
+ CLI Using tsup config: /home/runner/work/pancake-frontend/pancake-frontend/packages/token-lists/tsup.config.ts
9
+ CLI Target: es6
10
+ ESM Build start
11
+ CJS Build start
12
+ Entry module "dist/getTokenList-YNKBKHZ3.js" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
13
+ CJS dist/chunk-4TPCCB4K.js 1.49 KB
14
+ CJS dist/index.js 815.00 B
15
+ CJS dist/chunk-OGWZ2K32.js 2.83 KB
16
+ CJS dist/getTokenList-YNKBKHZ3.js 13.76 KB
17
+ CJS dist/react.js 9.13 KB
18
+ CJS ⚡️ Build success in 1438ms
19
+ ESM dist/chunk-2L3ZO4UM.mjs 1.42 KB
20
+ ESM dist/index.mjs 160.00 B
21
+ ESM dist/chunk-COROHIJN.mjs 2.67 KB
22
+ ESM dist/getTokenList-2FAKUE6D.mjs 13.40 KB
23
+ ESM dist/react.mjs 8.43 KB
24
+ ESM ⚡️ Build success in 1447ms
25
+ DTS Build start
26
+ DTS ⚡️ Build success in 11919ms
27
+ DTS dist/index.d.ts 1.68 KB
28
+ DTS dist/react.d.ts 2.52 KB
29
+ DTS dist/types-d6730d17.d.ts 1.03 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pancakeswap/token-lists
2
2
 
3
+ ## 0.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - d994c3335: chore: Bump up jotai
8
+
9
+ ## 0.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - e31475e6b: chore: Bump up jotai
14
+
3
15
  ## 0.0.7
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { SerializedToken, Token } from '@pancakeswap/swap-sdk-core';
2
- import { T as TokenInfo, a as TokenList, V as Version } from './types-d752b62d.js';
3
- export { b as Tags } from './types-d752b62d.js';
2
+ import { T as TokenInfo, a as TokenList, V as Version } from './types-d6730d17.js';
3
+ export { b as Tags } from './types-d6730d17.js';
4
4
 
5
5
  interface SerializedWrappedToken extends SerializedToken {
6
6
  chainId: number;
7
- address: string;
7
+ address: `0x${string}`;
8
8
  decimals: number;
9
9
  symbol: string;
10
10
  name?: string;
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _reduxjs_toolkit_dist_createReducer from '@reduxjs/toolkit/dist/createReducer';
2
- import { a as TokenList, V as Version } from './types-d752b62d.js';
2
+ import { a as TokenList, V as Version } from './types-d6730d17.js';
3
3
  import * as _reduxjs_toolkit from '@reduxjs/toolkit';
4
4
  import { ActionCreatorWithPayload } from '@reduxjs/toolkit';
5
5
  import * as jotai from 'jotai';
@@ -52,4 +52,4 @@ declare const createListsAtom: (storeName: string, reducer: any, initialState: a
52
52
 
53
53
  declare function useFetchListCallback(dispatch: (action?: unknown) => void): (listUrl: string, sendDispatch?: boolean) => Promise<TokenList>;
54
54
 
55
- export { ListsState, NEW_LIST_STATE, acceptListUpdate, addList, createListsAtom, createTokenListReducer, disableList, enableList, fetchTokenList, rejectVersionUpdate, removeList, updateListVersion, useFetchListCallback };
55
+ export { ListByUrlState, ListsState, NEW_LIST_STATE, acceptListUpdate, addList, createListsAtom, createTokenListReducer, disableList, enableList, fetchTokenList, rejectVersionUpdate, removeList, updateListVersion, useFetchListCallback };
package/dist/react.js CHANGED
@@ -152,11 +152,9 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
152
152
  function noop() {
153
153
  }
154
154
  var noopStorage = {
155
- getItem: noop,
156
- setItem: noop,
157
- removeItem: noop,
158
- keys: [],
159
- getAllKeys: noop
155
+ getItem: () => Promise.resolve(noop()),
156
+ setItem: () => Promise.resolve(noop()),
157
+ removeItem: () => Promise.resolve(noop())
160
158
  };
161
159
  var EMPTY = Symbol();
162
160
  var createListsAtom = (storeName, reducer, initialState) => {
@@ -167,7 +165,6 @@ var createListsAtom = (storeName, reducer, initialState) => {
167
165
  storeName
168
166
  });
169
167
  return {
170
- db,
171
168
  getItem: (key) => chunk4TPCCB4K_js.__async(this, null, function* () {
172
169
  const value = yield db.getItem(key);
173
170
  if (value) {
@@ -175,40 +172,36 @@ var createListsAtom = (storeName, reducer, initialState) => {
175
172
  }
176
173
  return initialState;
177
174
  }),
178
- setItem: (k, v) => {
175
+ setItem: (k, v) => chunk4TPCCB4K_js.__async(this, null, function* () {
179
176
  if (v === EMPTY)
180
177
  return;
181
- return db.setItem(k, v);
182
- },
178
+ yield db.setItem(k, v);
179
+ }),
183
180
  removeItem: db.removeItem
184
181
  };
185
182
  }
186
183
  return noopStorage;
187
184
  }
188
- const listsStorageAtom = utils.atomWithStorage(
189
- "lists",
190
- EMPTY,
191
- // @ts-ignore
192
- IndexedDBStorage("lists")
193
- );
185
+ const listsStorageAtom = utils.atomWithStorage("lists", EMPTY, IndexedDBStorage("lists"));
194
186
  const defaultStateAtom = jotai.atom(
195
187
  (get) => {
196
- const got = get(listsStorageAtom);
197
- if (got === EMPTY) {
198
- return initialState;
188
+ const value = get(utils.loadable(listsStorageAtom));
189
+ if (value.state === "hasData" && value.data !== EMPTY) {
190
+ return value.data;
199
191
  }
200
- return got;
192
+ return initialState;
201
193
  },
202
- (get, set, action) => {
203
- set(listsStorageAtom, reducer(get(defaultStateAtom), action));
204
- }
194
+ (get, set, action) => chunk4TPCCB4K_js.__async(void 0, null, function* () {
195
+ set(listsStorageAtom, reducer(yield get(defaultStateAtom), action));
196
+ })
205
197
  );
206
- const isReadyAtom = jotai.atom((get) => get(listsStorageAtom) !== EMPTY);
198
+ const isReadyAtom = utils.loadable(listsStorageAtom);
207
199
  function useListState() {
208
200
  return jotai.useAtom(defaultStateAtom);
209
201
  }
210
202
  function useListStateReady() {
211
- return jotai.useAtomValue(isReadyAtom);
203
+ const value = jotai.useAtomValue(isReadyAtom);
204
+ return value.state === "hasData" && value.data !== EMPTY;
212
205
  }
213
206
  return {
214
207
  listsAtom: defaultStateAtom,
package/dist/react.mjs CHANGED
@@ -2,7 +2,7 @@ import { getVersionUpgrade } from './chunk-COROHIJN.mjs';
2
2
  import { __spreadProps, __spreadValues, __async } from './chunk-2L3ZO4UM.mjs';
3
3
  import { createAction, createReducer, nanoid } from '@reduxjs/toolkit';
4
4
  import { atom, useAtom, useAtomValue } from 'jotai';
5
- import { atomWithStorage } from 'jotai/utils';
5
+ import { atomWithStorage, loadable } from 'jotai/utils';
6
6
  import localForage from 'localforage';
7
7
  import { useCallback } from 'react';
8
8
 
@@ -146,11 +146,9 @@ var createTokenListReducer = (initialState, DEFAULT_LIST_OF_LISTS, DEFAULT_ACTIV
146
146
  function noop() {
147
147
  }
148
148
  var noopStorage = {
149
- getItem: noop,
150
- setItem: noop,
151
- removeItem: noop,
152
- keys: [],
153
- getAllKeys: noop
149
+ getItem: () => Promise.resolve(noop()),
150
+ setItem: () => Promise.resolve(noop()),
151
+ removeItem: () => Promise.resolve(noop())
154
152
  };
155
153
  var EMPTY = Symbol();
156
154
  var createListsAtom = (storeName, reducer, initialState) => {
@@ -161,7 +159,6 @@ var createListsAtom = (storeName, reducer, initialState) => {
161
159
  storeName
162
160
  });
163
161
  return {
164
- db,
165
162
  getItem: (key) => __async(this, null, function* () {
166
163
  const value = yield db.getItem(key);
167
164
  if (value) {
@@ -169,40 +166,36 @@ var createListsAtom = (storeName, reducer, initialState) => {
169
166
  }
170
167
  return initialState;
171
168
  }),
172
- setItem: (k, v) => {
169
+ setItem: (k, v) => __async(this, null, function* () {
173
170
  if (v === EMPTY)
174
171
  return;
175
- return db.setItem(k, v);
176
- },
172
+ yield db.setItem(k, v);
173
+ }),
177
174
  removeItem: db.removeItem
178
175
  };
179
176
  }
180
177
  return noopStorage;
181
178
  }
182
- const listsStorageAtom = atomWithStorage(
183
- "lists",
184
- EMPTY,
185
- // @ts-ignore
186
- IndexedDBStorage("lists")
187
- );
179
+ const listsStorageAtom = atomWithStorage("lists", EMPTY, IndexedDBStorage("lists"));
188
180
  const defaultStateAtom = atom(
189
181
  (get) => {
190
- const got = get(listsStorageAtom);
191
- if (got === EMPTY) {
192
- return initialState;
182
+ const value = get(loadable(listsStorageAtom));
183
+ if (value.state === "hasData" && value.data !== EMPTY) {
184
+ return value.data;
193
185
  }
194
- return got;
186
+ return initialState;
195
187
  },
196
- (get, set, action) => {
197
- set(listsStorageAtom, reducer(get(defaultStateAtom), action));
198
- }
188
+ (get, set, action) => __async(void 0, null, function* () {
189
+ set(listsStorageAtom, reducer(yield get(defaultStateAtom), action));
190
+ })
199
191
  );
200
- const isReadyAtom = atom((get) => get(listsStorageAtom) !== EMPTY);
192
+ const isReadyAtom = loadable(listsStorageAtom);
201
193
  function useListState() {
202
194
  return useAtom(defaultStateAtom);
203
195
  }
204
196
  function useListStateReady() {
205
- return useAtomValue(isReadyAtom);
197
+ const value = useAtomValue(isReadyAtom);
198
+ return value.state === "hasData" && value.data !== EMPTY;
206
199
  }
207
200
  return {
208
201
  listsAtom: defaultStateAtom,
@@ -1,7 +1,7 @@
1
1
  type ExtensionValue = string | number | boolean | null | undefined;
2
2
  interface TokenInfo {
3
3
  readonly chainId: number;
4
- readonly address: string;
4
+ readonly address: `0x${string}`;
5
5
  readonly name: string;
6
6
  readonly decimals: number;
7
7
  readonly symbol: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pancakeswap/token-lists",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -11,18 +11,19 @@
11
11
  },
12
12
  "peerDependencies": {
13
13
  "@reduxjs/toolkit": "^1.9.1",
14
+ "jotai": "^2.4.3",
14
15
  "localforage": "^1.10.0",
15
- "jotai": "^2.0.3",
16
16
  "react": "^18.2.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@types/react": "^18.0.17",
20
- "localforage": "^1.10.0",
21
- "jotai": "^2.0.3",
22
19
  "@reduxjs/toolkit": "^1.9.1",
20
+ "@types/react": "^18.2.21",
21
+ "jotai": "^2.4.3",
22
+ "localforage": "^1.10.0",
23
23
  "react": "^18.2.0",
24
24
  "tsup": "^6.7.0",
25
- "@pancakeswap/utils": "1.0.0"
25
+ "vitest": "^0.34.4",
26
+ "@pancakeswap/utils": "5.0.6"
26
27
  },
27
28
  "exports": {
28
29
  ".": {
@@ -53,6 +54,7 @@
53
54
  "scripts": {
54
55
  "build": "tsup",
55
56
  "dev": "tsup --watch",
57
+ "test": "vitest --run",
56
58
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
57
59
  }
58
60
  }
@@ -0,0 +1,21 @@
1
+ import { expect, test } from 'vitest'
2
+ import * as exports from './index'
3
+
4
+ test('exports', () => {
5
+ expect(Object.keys(exports)).toMatchInlineSnapshot(`
6
+ [
7
+ "NEW_LIST_STATE",
8
+ "createTokenListReducer",
9
+ "fetchTokenList",
10
+ "addList",
11
+ "removeList",
12
+ "enableList",
13
+ "disableList",
14
+ "acceptListUpdate",
15
+ "rejectVersionUpdate",
16
+ "updateListVersion",
17
+ "createListsAtom",
18
+ "useFetchListCallback",
19
+ ]
20
+ `)
21
+ })
package/react/lists.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { atom, useAtom, useAtomValue } from 'jotai'
2
- import { atomWithStorage } from 'jotai/utils'
2
+ import { atomWithStorage, loadable } from 'jotai/utils'
3
+ import { type AsyncStorage } from 'jotai/vanilla/utils/atomWithStorage'
3
4
  import localForage from 'localforage'
4
5
  import { ListsState } from './reducer'
5
6
 
6
7
  // eslint-disable-next-line @typescript-eslint/no-empty-function
7
8
  function noop() {}
8
- const noopStorage = {
9
- getItem: noop,
10
- setItem: noop,
11
- removeItem: noop,
12
- keys: [],
13
- getAllKeys: noop,
9
+
10
+ const noopStorage: AsyncStorage<any> = {
11
+ getItem: () => Promise.resolve(noop()),
12
+ setItem: () => Promise.resolve(noop()),
13
+ removeItem: () => Promise.resolve(noop()),
14
14
  }
15
15
 
16
16
  // eslint-disable-next-line symbol-description
@@ -21,14 +21,13 @@ export const createListsAtom = (storeName: string, reducer: any, initialState: a
21
21
  * Persist you redux state using IndexedDB
22
22
  * @param {string} dbName - IndexedDB database name
23
23
  */
24
- function IndexedDBStorage(dbName: string) {
24
+ function IndexedDBStorage<Value>(dbName: string): AsyncStorage<Value> {
25
25
  if (typeof window !== 'undefined') {
26
26
  const db = localForage.createInstance({
27
27
  name: dbName,
28
28
  storeName,
29
29
  })
30
30
  return {
31
- db,
32
31
  getItem: async (key: string) => {
33
32
  const value = await db.getItem(key)
34
33
  if (value) {
@@ -36,10 +35,9 @@ export const createListsAtom = (storeName: string, reducer: any, initialState: a
36
35
  }
37
36
  return initialState
38
37
  },
39
- setItem: (k: string, v: any) => {
38
+ setItem: async (k: string, v: any) => {
40
39
  if (v === EMPTY) return
41
- // eslint-disable-next-line consistent-return
42
- return db.setItem(k, v)
40
+ await db.setItem(k, v)
43
41
  },
44
42
  removeItem: db.removeItem,
45
43
  }
@@ -47,34 +45,30 @@ export const createListsAtom = (storeName: string, reducer: any, initialState: a
47
45
  return noopStorage
48
46
  }
49
47
 
50
- const listsStorageAtom = atomWithStorage<ListsState | typeof EMPTY>(
51
- 'lists',
52
- EMPTY,
53
- // @ts-ignore
54
- IndexedDBStorage('lists'),
55
- )
48
+ const listsStorageAtom = atomWithStorage<ListsState | typeof EMPTY>('lists', EMPTY, IndexedDBStorage('lists'))
56
49
 
57
50
  const defaultStateAtom = atom<ListsState, any, void>(
58
51
  (get) => {
59
- const got = get(listsStorageAtom)
60
- if (got === EMPTY) {
61
- return initialState
52
+ const value = get(loadable(listsStorageAtom))
53
+ if (value.state === 'hasData' && value.data !== EMPTY) {
54
+ return value.data
62
55
  }
63
- return got
56
+ return initialState
64
57
  },
65
- (get, set, action) => {
66
- set(listsStorageAtom, reducer(get(defaultStateAtom), action))
58
+ async (get, set, action) => {
59
+ set(listsStorageAtom, reducer(await get(defaultStateAtom), action))
67
60
  },
68
61
  )
69
62
 
70
- const isReadyAtom = atom((get) => get(listsStorageAtom) !== EMPTY)
63
+ const isReadyAtom = loadable(listsStorageAtom)
71
64
 
72
65
  function useListState() {
73
66
  return useAtom(defaultStateAtom)
74
67
  }
75
68
 
76
69
  function useListStateReady() {
77
- return useAtomValue(isReadyAtom)
70
+ const value = useAtomValue(isReadyAtom)
71
+ return value.state === 'hasData' && value.data !== EMPTY
78
72
  }
79
73
 
80
74
  return {
@@ -1,11 +1,10 @@
1
1
  import { describe, it, expect, beforeEach } from 'vitest'
2
- import { Store } from 'redux'
3
- import { configureStore } from '@reduxjs/toolkit'
2
+ import { configureStore, type EnhancedStore } from '@reduxjs/toolkit'
4
3
 
5
4
  import { fetchTokenList, acceptListUpdate, addList, removeList, enableList, updateListVersion } from './actions'
6
- import { ListsState, createTokenListReducer, NEW_LIST_STATE } from './reducer'
5
+ import { ListsState, createTokenListReducer, NEW_LIST_STATE, type ListByUrlState } from './reducer'
7
6
 
8
- const DEFAULT_ACTIVE_LIST_URLS = []
7
+ const DEFAULT_ACTIVE_LIST_URLS: string[] = []
9
8
  const DEFAULT_LIST_OF_LISTS = ['https://tokens.pancakeswap.finance/pancakeswap-extended.json']
10
9
  const STUB_TOKEN_LIST = {
11
10
  name: '',
@@ -14,7 +13,7 @@ const STUB_TOKEN_LIST = {
14
13
  tokens: [],
15
14
  }
16
15
 
17
- const UNSUPPORTED_LIST_URLS = []
16
+ const UNSUPPORTED_LIST_URLS: string[] = []
18
17
 
19
18
  const reducer = createTokenListReducer(
20
19
  {
@@ -23,7 +22,7 @@ const reducer = createTokenListReducer(
23
22
  ...DEFAULT_LIST_OF_LISTS.concat(...UNSUPPORTED_LIST_URLS).reduce((memo, listUrl) => {
24
23
  memo[listUrl] = NEW_LIST_STATE
25
24
  return memo
26
- }, {}),
25
+ }, {} as Record<string, ListByUrlState>),
27
26
  },
28
27
  activeListUrls: DEFAULT_ACTIVE_LIST_URLS,
29
28
  },
@@ -44,12 +43,24 @@ const MAJOR_UPDATED_STUB_LIST = {
44
43
  version: { ...STUB_TOKEN_LIST.version, major: STUB_TOKEN_LIST.version.major + 1 },
45
44
  }
46
45
 
47
- describe.skip('list reducer', () => {
48
- let store: Store<ListsState>
46
+ const resetStore = (preloadedState?: ListsState) => {
47
+ return configureStore({ reducer, preloadedState })
48
+ }
49
+
50
+ describe('list reducer', () => {
51
+ let store: EnhancedStore<ListsState> = resetStore()
49
52
 
50
53
  beforeEach(() => {
51
- store = configureStore({
52
- reducer,
54
+ store = resetStore({
55
+ byUrl: {
56
+ 'fake-url': {
57
+ error: null,
58
+ current: STUB_TOKEN_LIST,
59
+ pendingUpdate: null,
60
+ loadingRequestId: null,
61
+ },
62
+ },
63
+ activeListUrls: undefined,
53
64
  })
54
65
  })
55
66
 
@@ -62,7 +73,7 @@ describe.skip('list reducer', () => {
62
73
  'fake-url': {
63
74
  error: null,
64
75
  loadingRequestId: 'request-id',
65
- current: null,
76
+ current: STUB_TOKEN_LIST,
66
77
  pendingUpdate: null,
67
78
  },
68
79
  },
@@ -71,7 +82,7 @@ describe.skip('list reducer', () => {
71
82
  })
72
83
 
73
84
  it('does not clear current list', () => {
74
- store = createStore(reducer, {
85
+ store = resetStore({
75
86
  byUrl: {
76
87
  'fake-url': {
77
88
  error: null,
@@ -200,6 +211,7 @@ describe.skip('list reducer', () => {
200
211
 
201
212
  describe('rejected', () => {
202
213
  it('no-op if not loading', () => {
214
+ store = resetStore({ byUrl: {}, activeListUrls: undefined })
203
215
  store.dispatch(fetchTokenList.rejected({ requestId: 'request-id', errorMessage: 'abcd', url: 'fake-url' }))
204
216
  expect(store.getState()).toEqual({
205
217
  byUrl: {},
@@ -208,7 +220,7 @@ describe.skip('list reducer', () => {
208
220
  })
209
221
 
210
222
  it('sets the error if loading', () => {
211
- store = createStore(reducer, {
223
+ store = resetStore({
212
224
  byUrl: {
213
225
  'fake-url': {
214
226
  error: null,
@@ -237,9 +249,26 @@ describe.skip('list reducer', () => {
237
249
 
238
250
  describe('addList', () => {
239
251
  it('adds the list key to byUrl', () => {
252
+ store = resetStore({
253
+ byUrl: {
254
+ 'fake-url': {
255
+ error: null,
256
+ current: STUB_TOKEN_LIST,
257
+ loadingRequestId: null,
258
+ pendingUpdate: null,
259
+ },
260
+ },
261
+ activeListUrls: undefined,
262
+ })
240
263
  store.dispatch(addList('list-id'))
241
264
  expect(store.getState()).toEqual({
242
265
  byUrl: {
266
+ 'fake-url': {
267
+ error: null,
268
+ current: STUB_TOKEN_LIST,
269
+ loadingRequestId: null,
270
+ pendingUpdate: null,
271
+ },
243
272
  'list-id': {
244
273
  error: null,
245
274
  current: null,
@@ -251,7 +280,7 @@ describe.skip('list reducer', () => {
251
280
  })
252
281
  })
253
282
  it('no op for existing list', () => {
254
- store = createStore(reducer, {
283
+ store = resetStore({
255
284
  byUrl: {
256
285
  'fake-url': {
257
286
  error: null,
@@ -279,7 +308,7 @@ describe.skip('list reducer', () => {
279
308
 
280
309
  describe('acceptListUpdate', () => {
281
310
  it('swaps pending update into current', () => {
282
- store = createStore(reducer, {
311
+ store = resetStore({
283
312
  byUrl: {
284
313
  'fake-url': {
285
314
  error: null,
@@ -307,7 +336,7 @@ describe.skip('list reducer', () => {
307
336
 
308
337
  describe('removeList', () => {
309
338
  it('deletes the list key', () => {
310
- store = createStore(reducer, {
339
+ store = resetStore({
311
340
  byUrl: {
312
341
  'fake-url': {
313
342
  error: null,
@@ -325,7 +354,7 @@ describe.skip('list reducer', () => {
325
354
  })
326
355
  })
327
356
  it('Removes from active lists if active list is removed', () => {
328
- store = createStore(reducer, {
357
+ store = resetStore({
329
358
  byUrl: {
330
359
  'fake-url': {
331
360
  error: null,
@@ -346,7 +375,7 @@ describe.skip('list reducer', () => {
346
375
 
347
376
  describe('enableList', () => {
348
377
  it('enables a list url', () => {
349
- store = createStore(reducer, {
378
+ store = resetStore({
350
379
  byUrl: {
351
380
  'fake-url': {
352
381
  error: null,
@@ -371,7 +400,7 @@ describe.skip('list reducer', () => {
371
400
  })
372
401
  })
373
402
  it('adds to url keys if not present already on enable', () => {
374
- store = createStore(reducer, {
403
+ store = resetStore({
375
404
  byUrl: {
376
405
  'fake-url': {
377
406
  error: null,
@@ -402,7 +431,7 @@ describe.skip('list reducer', () => {
402
431
  })
403
432
  })
404
433
  it('enable works if list already added', () => {
405
- store = createStore(reducer, {
434
+ store = resetStore({
406
435
  byUrl: {
407
436
  'fake-url': {
408
437
  error: null,
@@ -431,7 +460,7 @@ describe.skip('list reducer', () => {
431
460
  describe('updateVersion', () => {
432
461
  describe('never initialized', () => {
433
462
  beforeEach(() => {
434
- store = createStore(reducer, {
463
+ store = resetStore({
435
464
  byUrl: {
436
465
  'https://unpkg.com/@uniswap/default-token-list@latest/uniswap-default.tokenlist.json': {
437
466
  error: null,
@@ -481,7 +510,7 @@ describe.skip('list reducer', () => {
481
510
  })
482
511
  describe('initialized with a different set of lists', () => {
483
512
  beforeEach(() => {
484
- store = createStore(reducer, {
513
+ store = resetStore({
485
514
  byUrl: {
486
515
  'https://unpkg.com/@uniswap/default-token-list@latest/uniswap-default.tokenlist.json': {
487
516
  error: null,
package/react/reducer.ts CHANGED
@@ -27,7 +27,7 @@ export interface ListsState {
27
27
  readonly activeListUrls: string[] | undefined
28
28
  }
29
29
 
30
- type ListByUrlState = ListsState['byUrl'][string]
30
+ export type ListByUrlState = ListsState['byUrl'][string]
31
31
 
32
32
  export const NEW_LIST_STATE: ListByUrlState = {
33
33
  error: null,
@@ -0,0 +1,14 @@
1
+ import { expect, test } from 'vitest'
2
+ import * as exports from './index'
3
+
4
+ test('exports', () => {
5
+ expect(Object.keys(exports)).toMatchInlineSnapshot(`
6
+ [
7
+ "WrappedTokenInfo",
8
+ "deserializeToken",
9
+ "VersionUpgrade",
10
+ "getVersionUpgrade",
11
+ "createFilterToken",
12
+ ]
13
+ `)
14
+ })
package/src/types.ts CHANGED
@@ -2,7 +2,7 @@ type ExtensionValue = string | number | boolean | null | undefined
2
2
 
3
3
  export interface TokenInfo {
4
4
  readonly chainId: number
5
- readonly address: string
5
+ readonly address: `0x${string}`
6
6
  readonly name: string
7
7
  readonly decimals: number
8
8
  readonly symbol: string
@@ -3,7 +3,7 @@ import { TokenInfo, TokenList } from './types'
3
3
 
4
4
  export interface SerializedWrappedToken extends SerializedToken {
5
5
  chainId: number
6
- address: string
6
+ address: `0x${string}`
7
7
  decimals: number
8
8
  symbol: string
9
9
  name?: string