-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tien Nam Dao
committed
Nov 7, 2022
1 parent
eee0389
commit b2ded4e
Showing
12 changed files
with
162 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Breadcumbs, useMobileLayout } from '@astraprotocol/astra-ui' | ||
import { evmApi } from 'api' | ||
import API_LIST from 'api/api_list' | ||
import { AxiosError } from 'axios' | ||
import Container from 'components/Container' | ||
import Head from 'next/head' | ||
import React from 'react' | ||
import { ellipseBetweenText, LinkMaker } from 'utils/helper' | ||
import Web3 from 'web3' | ||
import Layout from '../../../components/Layout' | ||
|
||
type Props = { | ||
token: string | ||
tokenData: Token | ||
errorMessage?: string | ||
} | ||
|
||
const TokenInstanceDetailPage: React.FC<Props> = props => { | ||
const { isMobile } = useMobileLayout() | ||
const { token, tokenData, errorMessage } = props | ||
|
||
const title = tokenData ? `${tokenData.name} (${tokenData.symbol}) - ${process.env.NEXT_PUBLIC_TITLE}` : token | ||
return ( | ||
<Layout> | ||
<Head> | ||
<meta name="viewport" content="initial-scale=1.0, width=device-width" /> | ||
<title>{title}</title> | ||
</Head> | ||
<Container> | ||
<Breadcumbs | ||
items={[ | ||
{ label: 'Address', link: LinkMaker.token() }, | ||
{ label: isMobile ? ellipseBetweenText(token) : token } | ||
]} | ||
/> | ||
|
||
<h1 className="text contrast-color-70 margin-top-sm">{'In Development'}</h1> | ||
</Container> | ||
</Layout> | ||
) | ||
} | ||
|
||
export async function getServerSideProps({ params }) { | ||
const { token } = params | ||
if (Web3.utils.isAddress(token, 11115)) { | ||
try { | ||
const tokenData = await evmApi.get<TokenDetailResponse>(`${API_LIST.TOKEN_DETAIL}${token}`) | ||
if (tokenData.data.result) { | ||
return { | ||
props: { | ||
errorMessage: '404 Not Found', | ||
token, | ||
tokenData: tokenData.data.result | ||
} | ||
} | ||
} | ||
return { | ||
props: { | ||
errorMessage: tokenData.data.message, | ||
token, | ||
tokenData: null | ||
} | ||
} | ||
} catch (err) { | ||
let errorMessage = err.message | ||
if (err instanceof AxiosError) { | ||
console.log('error api', err.message, err.code, err?.config?.baseURL, err?.config?.url) | ||
if (err.code !== '200') errorMessage = '404 Not Found' | ||
} | ||
return { | ||
props: { | ||
errorMessage: err.message, | ||
token, | ||
tokenData: null | ||
} | ||
} | ||
} | ||
} | ||
return { | ||
props: { | ||
message: 'Token address invalid', | ||
token, | ||
tokenData: null | ||
} | ||
} | ||
} | ||
|
||
export default TokenInstanceDetailPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters