From 2483a05786e259b41c9282950385604dd57332cf Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 24 Feb 2021 12:30:55 -0800 Subject: [PATCH] feat: add solana-token-registry to explorer (#15496) * feat: add solana-token-registry to explorer * feat: bump version for token-registry * fix: ensure tokenName and tokenSymbol exist in incoming json --- explorer/package-lock.json | 8 + explorer/package.json | 1 + explorer/src/components/SearchBar.tsx | 30 +- .../components/account/OwnedTokensCard.tsx | 21 +- .../account/TokenAccountSection.tsx | 12 +- .../components/account/TokenHistoryCard.tsx | 15 +- .../account/TokenLargestAccountsCard.tsx | 7 +- .../components/account/UnknownAccountCard.tsx | 4 +- explorer/src/components/common/Address.tsx | 11 +- .../instruction/token/TokenDetailsCard.tsx | 11 +- .../transaction/TokenBalancesCard.tsx | 7 +- explorer/src/pages/AccountDetailsPage.tsx | 12 +- explorer/src/providers/mints/index.tsx | 7 +- .../src/providers/mints/token-registry.tsx | 49 +++ explorer/src/tokenRegistry.ts | 296 ------------------ explorer/src/utils/tx.ts | 15 +- 16 files changed, 148 insertions(+), 358 deletions(-) create mode 100644 explorer/src/providers/mints/token-registry.tsx delete mode 100644 explorer/src/tokenRegistry.ts diff --git a/explorer/package-lock.json b/explorer/package-lock.json index 2650dd42b7..0a9b573296 100644 --- a/explorer/package-lock.json +++ b/explorer/package-lock.json @@ -2598,6 +2598,14 @@ "@sinonjs/commons": "^1.7.0" } }, + "@solana/spl-token-registry": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@solana/spl-token-registry/-/spl-token-registry-0.1.4.tgz", + "integrity": "sha512-gJ7dW8G3sYy/kgrYykjt5+01Tpl3jGxOg+5cmLAcgrFIt9zbD22gXdINxznObIaviahiFCfpLPiTfqHmW9fvEA==", + "requires": { + "cross-fetch": "^3.0.6" + } + }, "@solana/web3.js": { "version": "0.92.2", "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-0.92.2.tgz", diff --git a/explorer/package.json b/explorer/package.json index 9001f44c07..650d70f136 100644 --- a/explorer/package.json +++ b/explorer/package.json @@ -6,6 +6,7 @@ "@project-serum/serum": "^0.13.23", "@react-hook/debounce": "^3.0.0", "@sentry/react": "^6.2.0", + "@solana/spl-token-registry": "^0.1.4", "@solana/web3.js": "^0.92.2", "@testing-library/jest-dom": "^5.11.9", "@testing-library/react": "^11.2.5", diff --git a/explorer/src/components/SearchBar.tsx b/explorer/src/components/SearchBar.tsx index 292c11fedd..c357130472 100644 --- a/explorer/src/components/SearchBar.tsx +++ b/explorer/src/components/SearchBar.tsx @@ -10,14 +10,16 @@ import { LoaderName, SEARCHABLE_PROGRAMS, } from "utils/tx"; -import { TokenRegistry } from "tokenRegistry"; import { Cluster, useCluster } from "providers/cluster"; +import { useTokenRegistry } from "providers/mints/token-registry"; +import { KnownTokenMap } from "@solana/spl-token-registry"; export function SearchBar() { const [search, setSearch] = React.useState(""); const selectRef = React.useRef | null>(null); const history = useHistory(); const location = useLocation(); + const { tokenRegistry } = useTokenRegistry(); const { cluster } = useCluster(); const onChange = ( @@ -41,7 +43,7 @@ export function SearchBar() {