diff --git a/.changeset/cool-ads-travel.md b/.changeset/cool-ads-travel.md new file mode 100644 index 000000000..4fef55441 --- /dev/null +++ b/.changeset/cool-ads-travel.md @@ -0,0 +1,5 @@ +--- +"@swapkit/sdk": patch +--- + +Adapt tokens export in sdk diff --git a/.changeset/wild-swans-retire.md b/.changeset/wild-swans-retire.md new file mode 100644 index 000000000..f11181018 --- /dev/null +++ b/.changeset/wild-swans-retire.md @@ -0,0 +1,5 @@ +--- +"@swapkit/tokens": patch +--- + +Cleaning up export code. Each list can be imported individually or all at once via tokenLists diff --git a/packages/swapkit/sdk/src/index.ts b/packages/swapkit/sdk/src/index.ts index da9bb6aff..bb1e02653 100644 --- a/packages/swapkit/sdk/src/index.ts +++ b/packages/swapkit/sdk/src/index.ts @@ -7,7 +7,7 @@ import { MayachainPlugin, ThorchainPlugin } from "@swapkit/plugin-thorchain"; import { wallets as defaultWallets } from "@swapkit/wallets"; export * from "@swapkit/core"; -export * from "@swapkit/tokens"; +export { getTokenIcon, tokenLists } from "@swapkit/tokens"; export const defaultPlugins = { ...ChainflipPlugin, diff --git a/packages/swapkit/tokens/src/helpers.ts b/packages/swapkit/tokens/src/helpers.ts index d32e72ff1..42c71a578 100644 --- a/packages/swapkit/tokens/src/helpers.ts +++ b/packages/swapkit/tokens/src/helpers.ts @@ -1,12 +1,8 @@ -import { tokenLists as defaultTokenLists } from "./lists"; -import type { TokenList } from "./types"; +import * as tokenLists from "./tokenLists"; -export function getTokenIcon( - identifier: string, - lists: Record = defaultTokenLists, -): string | undefined { +export function getTokenIcon(identifier: string): string | undefined { // Search through all lists for a matching token - for (const list of Object.values(lists)) { + for (const list of Object.values(tokenLists)) { const token = list.tokens.find((token) => token.identifier === identifier); if (token?.logoURI) { return token.logoURI; diff --git a/packages/swapkit/tokens/src/index.ts b/packages/swapkit/tokens/src/index.ts index 2b58f4ba4..2cd6d1873 100644 --- a/packages/swapkit/tokens/src/index.ts +++ b/packages/swapkit/tokens/src/index.ts @@ -1,3 +1,3 @@ -export * from "./lists"; +export * as tokenLists from "./tokenLists"; +export * from "./tokenLists"; export * from "./helpers"; -export * from "./types"; diff --git a/packages/swapkit/tokens/src/lists.ts b/packages/swapkit/tokens/src/lists.ts deleted file mode 100644 index bb2677a7f..000000000 --- a/packages/swapkit/tokens/src/lists.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { list as caviarV1 } from "./tokenLists/caviar_v1"; -import { list as chainflip } from "./tokenLists/chainflip"; -import { list as jupiter } from "./tokenLists/jupiter"; -import { list as kado } from "./tokenLists/kado"; -import { list as maya } from "./tokenLists/mayachain"; -import { list as oneInch } from "./tokenLists/oneinch"; -import { list as openOceanV2 } from "./tokenLists/openocean_v2"; -import { list as pancakeswap } from "./tokenLists/pancakeswap"; -import { list as pangolin } from "./tokenLists/pangolin_v1"; -import { list as sushiswap } from "./tokenLists/sushiswap_v2"; -import { list as thorchain } from "./tokenLists/thorchain"; -import { list as traderjoeV2 } from "./tokenLists/traderjoe_v2"; -import { list as uniswapV2 } from "./tokenLists/uniswap_v2"; -import { list as uniswapV3 } from "./tokenLists/uniswap_v3"; - -import type { TokenList } from "./types"; - -export const CaviarV1List = caviarV1; -export const ChainflipList = chainflip; -export const JupiterList = jupiter; -export const KadoList = kado; -export const MayaList = maya; -export const OneInchList = oneInch; -export const OpenOceanV2List = openOceanV2; -export const PancakeswapList = pancakeswap; -export const PangolinList = pangolin; -export const SushiswapList = sushiswap; -export const ThorchainList = thorchain; -export const TraderjoeV2List = traderjoeV2; -export const UniswapV2List = uniswapV2; -export const UniswapV3List = uniswapV3; - -export const tokenLists: Record = { - CaviarV1List, - ChainflipList, - JupiterList, - KadoList, - MayaList, - OneInchList, - OpenOceanV2List, - PancakeswapList, - PangolinList, - SushiswapList, - ThorchainList, - TraderjoeV2List, - UniswapV2List, - UniswapV3List, -}; diff --git a/packages/swapkit/tokens/src/tokenLists/index.ts b/packages/swapkit/tokens/src/tokenLists/index.ts new file mode 100644 index 000000000..a3ca98b31 --- /dev/null +++ b/packages/swapkit/tokens/src/tokenLists/index.ts @@ -0,0 +1,14 @@ +export { list as CaviarV1List } from "./caviar_v1"; +export { list as ChainflipList } from "./chainflip"; +export { list as JupiterList } from "./jupiter"; +export { list as KadoList } from "./kado"; +export { list as MayaList } from "./mayachain"; +export { list as OneInchList } from "./oneinch"; +export { list as OpenOceanV2List } from "./openocean_v2"; +export { list as PancakeswapList } from "./pancakeswap"; +export { list as PangolinList } from "./pangolin_v1"; +export { list as SushiswapList } from "./sushiswap_v2"; +export { list as ThorchainList } from "./thorchain"; +export { list as TraderjoeV2List } from "./traderjoe_v2"; +export { list as UniswapV2List } from "./uniswap_v2"; +export { list as UniswapV3List } from "./uniswap_v3"; diff --git a/packages/swapkit/tokens/src/types.ts b/packages/swapkit/tokens/src/types.ts deleted file mode 100644 index 8453f7f60..000000000 --- a/packages/swapkit/tokens/src/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { list as caviarV1 } from "./tokenLists/caviar_v1"; -import type { list as chainflip } from "./tokenLists/chainflip"; -import type { list as jupiter } from "./tokenLists/jupiter"; -import type { list as kado } from "./tokenLists/kado"; -import type { list as maya } from "./tokenLists/mayachain"; -import type { list as oneInch } from "./tokenLists/oneinch"; -import type { list as openOceanV2 } from "./tokenLists/openocean_v2"; -import type { list as pancakeswap } from "./tokenLists/pancakeswap"; -import type { list as pangolin } from "./tokenLists/pangolin_v1"; -import type { list as sushiswap } from "./tokenLists/sushiswap_v2"; -import type { list as thorchain } from "./tokenLists/thorchain"; -import type { list as traderjoeV2 } from "./tokenLists/traderjoe_v2"; -import type { list as uniswapV2 } from "./tokenLists/uniswap_v2"; -import type { list as uniswapV3 } from "./tokenLists/uniswap_v3"; - -export type TokenList = - | typeof caviarV1 - | typeof chainflip - | typeof jupiter - | typeof kado - | typeof maya - | typeof oneInch - | typeof openOceanV2 - | typeof pancakeswap - | typeof pangolin - | typeof sushiswap - | typeof thorchain - | typeof traderjoeV2 - | typeof uniswapV2 - | typeof uniswapV3;