@swapkit/tokens 2.1.0 → 2.2.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.
package/package.json CHANGED
@@ -24,5 +24,5 @@
24
24
  },
25
25
  "type": "module",
26
26
  "types": "./src/index.ts",
27
- "version": "2.1.0"
27
+ "version": "2.2.0"
28
28
  }
package/src/helpers.ts CHANGED
@@ -1,9 +1,13 @@
1
- import { tokenLists } from "./index";
1
+ import { tokenLists as defaultTokenLists } from "./lists";
2
+ import type { TokenList } from "./types";
2
3
 
3
- export function getTokenIcon(identifier: string): string | undefined {
4
+ export function getTokenIcon(
5
+ identifier: string,
6
+ lists: Record<string, TokenList> = defaultTokenLists,
7
+ ): string | undefined {
4
8
  // Search through all lists for a matching token
5
- for (const list of Object.values(tokenLists)) {
6
- const token = list.tokens.find((t) => t.identifier === identifier);
9
+ for (const list of Object.values(lists)) {
10
+ const token = list.tokens.find((token) => token.identifier === identifier);
7
11
  if (token?.logoURI) {
8
12
  return token.logoURI;
9
13
  }
package/src/index.ts CHANGED
@@ -1,51 +1,3 @@
1
- import { list as CaviarV1List } from "./tokenLists/caviar_v1";
2
- import { list as ChainflipList } from "./tokenLists/chainflip";
3
- import { list as JupiterList } from "./tokenLists/jupiter";
4
- import { list as KadoList } from "./tokenLists/kado";
5
- import { list as MayaList } from "./tokenLists/mayachain";
6
- // export { list as OciswapV1List } from "./tokenLists/ociswap_v1";
7
- import { list as OneInchList } from "./tokenLists/oneinch";
8
- import { list as OpenOceanV2List } from "./tokenLists/openocean_v2";
9
- import { list as PancakeswapList } from "./tokenLists/pancakeswap";
10
- import { list as PangolinList } from "./tokenLists/pangolin_v1";
11
- import { list as SushiswapList } from "./tokenLists/sushiswap_v2";
12
- import { list as ThorchainList } from "./tokenLists/thorchain";
13
- import { list as TraderjoeV2List } from "./tokenLists/traderjoe_v2";
14
- import { list as UniswapV2List } from "./tokenLists/uniswap_v2";
15
- import { list as UniswapV3List } from "./tokenLists/uniswap_v3";
16
-
17
- export const tokenLists: {
18
- CaviarV1List: typeof CaviarV1List;
19
- ChainflipList: typeof ChainflipList;
20
- JupiterList: typeof JupiterList;
21
- KadoList: typeof KadoList;
22
- MayaList: typeof MayaList;
23
- // OciswapV1List: typeof OciswapV1List
24
- OneInchList: typeof OneInchList;
25
- OpenOceanV2List: typeof OpenOceanV2List;
26
- PancakeswapList: typeof PancakeswapList;
27
- PangolinList: typeof PangolinList;
28
- SushiswapList: typeof SushiswapList;
29
- ThorchainList: typeof ThorchainList;
30
- TraderjoeV2List: typeof TraderjoeV2List;
31
- UniswapV2List: typeof UniswapV2List;
32
- UniswapV3List: typeof UniswapV3List;
33
- } = {
34
- CaviarV1List,
35
- ChainflipList,
36
- JupiterList,
37
- KadoList,
38
- MayaList,
39
- // OciswapV1List,
40
- OneInchList,
41
- OpenOceanV2List,
42
- PancakeswapList,
43
- PangolinList,
44
- SushiswapList,
45
- ThorchainList,
46
- TraderjoeV2List,
47
- UniswapV2List,
48
- UniswapV3List,
49
- };
50
-
1
+ export * from "./lists";
51
2
  export * from "./helpers";
3
+ export * from "./types";
package/src/lists.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { list as caviarV1 } from "./tokenLists/caviar_v1";
2
+ import { list as chainflip } from "./tokenLists/chainflip";
3
+ import { list as jupiter } from "./tokenLists/jupiter";
4
+ import { list as kado } from "./tokenLists/kado";
5
+ import { list as maya } from "./tokenLists/mayachain";
6
+ import { list as oneInch } from "./tokenLists/oneinch";
7
+ import { list as openOceanV2 } from "./tokenLists/openocean_v2";
8
+ import { list as pancakeswap } from "./tokenLists/pancakeswap";
9
+ import { list as pangolin } from "./tokenLists/pangolin_v1";
10
+ import { list as sushiswap } from "./tokenLists/sushiswap_v2";
11
+ import { list as thorchain } from "./tokenLists/thorchain";
12
+ import { list as traderjoeV2 } from "./tokenLists/traderjoe_v2";
13
+ import { list as uniswapV2 } from "./tokenLists/uniswap_v2";
14
+ import { list as uniswapV3 } from "./tokenLists/uniswap_v3";
15
+
16
+ import type { TokenList } from "./types";
17
+
18
+ export const CaviarV1List = caviarV1;
19
+ export const ChainflipList = chainflip;
20
+ export const JupiterList = jupiter;
21
+ export const KadoList = kado;
22
+ export const MayaList = maya;
23
+ export const OneInchList = oneInch;
24
+ export const OpenOceanV2List = openOceanV2;
25
+ export const PancakeswapList = pancakeswap;
26
+ export const PangolinList = pangolin;
27
+ export const SushiswapList = sushiswap;
28
+ export const ThorchainList = thorchain;
29
+ export const TraderjoeV2List = traderjoeV2;
30
+ export const UniswapV2List = uniswapV2;
31
+ export const UniswapV3List = uniswapV3;
32
+
33
+ export const tokenLists: Record<string, TokenList> = {
34
+ CaviarV1List,
35
+ ChainflipList,
36
+ JupiterList,
37
+ KadoList,
38
+ MayaList,
39
+ OneInchList,
40
+ OpenOceanV2List,
41
+ PancakeswapList,
42
+ PangolinList,
43
+ SushiswapList,
44
+ ThorchainList,
45
+ TraderjoeV2List,
46
+ UniswapV2List,
47
+ UniswapV3List,
48
+ };
package/src/types.ts ADDED
@@ -0,0 +1,30 @@
1
+ import type { list as caviarV1 } from "./tokenLists/caviar_v1";
2
+ import type { list as chainflip } from "./tokenLists/chainflip";
3
+ import type { list as jupiter } from "./tokenLists/jupiter";
4
+ import type { list as kado } from "./tokenLists/kado";
5
+ import type { list as maya } from "./tokenLists/mayachain";
6
+ import type { list as oneInch } from "./tokenLists/oneinch";
7
+ import type { list as openOceanV2 } from "./tokenLists/openocean_v2";
8
+ import type { list as pancakeswap } from "./tokenLists/pancakeswap";
9
+ import type { list as pangolin } from "./tokenLists/pangolin_v1";
10
+ import type { list as sushiswap } from "./tokenLists/sushiswap_v2";
11
+ import type { list as thorchain } from "./tokenLists/thorchain";
12
+ import type { list as traderjoeV2 } from "./tokenLists/traderjoe_v2";
13
+ import type { list as uniswapV2 } from "./tokenLists/uniswap_v2";
14
+ import type { list as uniswapV3 } from "./tokenLists/uniswap_v3";
15
+
16
+ export type TokenList =
17
+ | typeof caviarV1
18
+ | typeof chainflip
19
+ | typeof jupiter
20
+ | typeof kado
21
+ | typeof maya
22
+ | typeof oneInch
23
+ | typeof openOceanV2
24
+ | typeof pancakeswap
25
+ | typeof pangolin
26
+ | typeof sushiswap
27
+ | typeof thorchain
28
+ | typeof traderjoeV2
29
+ | typeof uniswapV2
30
+ | typeof uniswapV3;