Skip to content

Commit

Permalink
Chore/cleanup tokens (#1152)
Browse files Browse the repository at this point in the history
* chore: cleaning up tokens package

* chore: adapt tokens export from sdk to use complete tokenLists

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
towanTG and github-actions[bot] authored Jan 8, 2025
1 parent ebaeb0f commit 912b8fe
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 88 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-ads-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@swapkit/sdk": patch
---

Adapt tokens export in sdk
5 changes: 5 additions & 0 deletions .changeset/wild-swans-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@swapkit/tokens": patch
---

Cleaning up export code. Each list can be imported individually or all at once via tokenLists
2 changes: 1 addition & 1 deletion packages/swapkit/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 3 additions & 7 deletions packages/swapkit/tokens/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -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<string, TokenList> = 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;
Expand Down
4 changes: 2 additions & 2 deletions packages/swapkit/tokens/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./lists";
export * as tokenLists from "./tokenLists";
export * from "./tokenLists";
export * from "./helpers";
export * from "./types";
48 changes: 0 additions & 48 deletions packages/swapkit/tokens/src/lists.ts

This file was deleted.

14 changes: 14 additions & 0 deletions packages/swapkit/tokens/src/tokenLists/index.ts
Original file line number Diff line number Diff line change
@@ -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";
30 changes: 0 additions & 30 deletions packages/swapkit/tokens/src/types.ts

This file was deleted.

0 comments on commit 912b8fe

Please sign in to comment.