fix: token registry avoids custom slug (#16093)

This commit is contained in:
Josh
2021-03-24 09:08:47 -07:00
committed by GitHub
parent 570fd3f810
commit 7aa65831bc
2 changed files with 22 additions and 13 deletions

View File

@@ -5,7 +5,7 @@ import {
TokenInfo,
TokenListContainer,
} from "@solana/spl-token-registry";
import { clusterSlug, useCluster } from "providers/cluster";
import { Cluster, clusterSlug, useCluster } from "providers/cluster";
const TokenRegistryContext = React.createContext<TokenInfoMap>(new Map());
@@ -19,9 +19,10 @@ export function TokenRegistryProvider({ children }: ProviderProps) {
React.useEffect(() => {
new TokenListProvider().resolve().then((tokens: TokenListContainer) => {
const tokenList = tokens
.filterByClusterSlug(clusterSlug(cluster))
.getList();
const tokenList =
cluster === Cluster.Custom
? []
: tokens.filterByClusterSlug(clusterSlug(cluster)).getList();
setTokenRegistry(
tokenList.reduce((map: TokenInfoMap, item: TokenInfo) => {