Skip to content

Commit

Permalink
use fetch function for token list (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparkallas authored Sep 18, 2024
1 parent d94a15f commit 2d667ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@superfluid-finance/metadata": "^1.5.0",
"@superfluid-finance/sdk-core": "^0.8.0",
"@superfluid-finance/sdk-redux": "^0.6.1",
"@superfluid-finance/tokenlist": "^5.6.1",
"@superfluid-finance/tokenlist": "^5.7.0",
"@tanstack/react-query": "^5.53.3",
"clsx": "^2.1.1",
"decimal.js": "^10.3.1",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/hooks/useTokenQuery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { memoize } from "lodash";
import { sfSubgraph } from "../redux/store";
import { extendedSuperTokenList } from "@superfluid-finance/tokenlist";
import { extendedSuperTokenList as extendedSuperTokenList_, fetchLatestExtendedSuperTokenList } from "@superfluid-finance/tokenlist";
import { UseQueryResult } from "../redux/UseQueryResult";
import { Token } from "@superfluid-finance/sdk-core";

Expand Down Expand Up @@ -44,8 +44,11 @@ export function useTokenQuery(arg: Arg, options?: Omit<Options, "selectFromResul
return tokenQuery;
}

export let extendedSuperTokenList = extendedSuperTokenList_;
fetchLatestExtendedSuperTokenList().then(fetchedTokenList => extendedSuperTokenList = fetchedTokenList);

export const findTokenFromTokenList = memoize((input: { chainId: number, address: string }) => {
const tokenAddressLowerCased = input.address.toLowerCase();
const tokenListToken = extendedSuperTokenList.tokens.find(x => x.chainId === input.chainId && x.address === tokenAddressLowerCased);
return tokenListToken;
}, ({ chainId, address }) => `${chainId}-${address.toLowerCase()}`);
}, ({ chainId, address }) => `${chainId}-${address.toLowerCase()}-${extendedSuperTokenList.version}`);

0 comments on commit 2d667ec

Please sign in to comment.