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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 13 deletions

View File

@ -2419,6 +2419,14 @@
"buffer-layout": "^1.2.0"
},
"dependencies": {
"@babel/runtime": {
"version": "7.13.10",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.13.10.tgz",
"integrity": "sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==",
"requires": {
"regenerator-runtime": "^0.13.4"
}
},
"@solana/web3.js": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.0.0.tgz",
@ -2446,6 +2454,15 @@
}
}
},
"buffer": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.1.tgz",
"integrity": "sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ==",
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"superstruct": {
"version": "0.14.2",
"resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz",
@ -4937,15 +4954,6 @@
"node-int64": "^0.4.0"
}
},
"buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",

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) => {