Skip to content

Commit

Permalink
feat: solana
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Nov 7, 2024
1 parent 3fd094e commit 775df1c
Show file tree
Hide file tree
Showing 2 changed files with 337 additions and 10 deletions.
18 changes: 9 additions & 9 deletions pages/list/[list].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ function TokenListHero({list}: {list: TTokenListItem}): ReactElement {
<ImageWithFallback
unoptimized
src={
list.logoURI?.startsWith('ipfs://')
list.logoURI.startsWith('ipfs://')
? `https://ipfs.io/ipfs/${list.logoURI.replace('ipfs://', '')}`
: list.logoURI
}
altSrc={
list.logoURI?.startsWith('ipfs://')
list.logoURI.startsWith('ipfs://')
? `https://ipfs.io/ipfs/${list.logoURI.replace('ipfs://', '')}`
: list.logoURI
}
Expand Down Expand Up @@ -169,7 +169,7 @@ function TokenListItem({item}: {item: TTokenListItem['tokens'][0]}): ReactElemen
<span>
<a
href={`${
currentNetwork?.blockExplorers?.etherscan?.url || 'https://etherscan.io'
currentNetwork.blockExplorers?.etherscan?.url || 'https://etherscan.io'
}/token/${item.address}`}
target={'_blank'}
rel={'noreferrer'}
Expand Down Expand Up @@ -200,7 +200,7 @@ function TokenListItem({item}: {item: TTokenListItem['tokens'][0]}): ReactElemen
<div className={'col-span-12 flex justify-end text-right md:col-span-2'}>
<div>
<p className={'block text-xxs text-neutral-700 md:text-xs'}>{'Chain'}</p>
<b>{currentNetwork?.name || `Chain ${item.chainId}`}</b>
<b>{currentNetwork.name || `Chain ${item.chainId}`}</b>
</div>
</div>
</div>
Expand All @@ -215,18 +215,18 @@ function TokenListContent({list}: {list: TTokenListItem}): ReactElement {
const [network, set_network] = useState(-1);
useMountEffect((): void => {
const {query} = router;
if (query?.page) {
if (query.page) {
set_currentPage(Number(query.page));
}
if (query?.search) {
if (query.search) {
set_search(String(query.search));
}
});

const availableNetworks = useMemo((): {value: number; label: string}[] => {
const networks: {value: number; label: string}[] = [];
const exists: TNDict<boolean> = {};
([...list.tokens] || []).forEach((item): void => {
list.tokens.forEach((item): void => {
const network = Object.values(chains).find((network): boolean => network.id === item.chainId);
if (network) {
if (exists[network.id]) {
Expand All @@ -243,7 +243,7 @@ function TokenListContent({list}: {list: TTokenListItem}): ReactElement {
}, [list.tokens]);

const searchResult = useMemo((): TTokenListItem['tokens'] => {
return ([...list.tokens] || [])
return list.tokens
.filter((item): boolean => {
if (network === -1) {
return true;
Expand Down Expand Up @@ -518,7 +518,7 @@ export default function Wrapper({pageProps}: {pageProps: {list: TTokenListItem}}
export const getServerSideProps = async (
context: NextPageContext
): Promise<GetServerSidePropsResult<{list: TTokenListItem}>> => {
const listID = context?.query?.list;
const listID = context.query.list;
if (!listID) {
return {
redirect: {
Expand Down
Loading

0 comments on commit 775df1c

Please sign in to comment.