Skip to content

Commit

Permalink
feat: add token-transfer for address detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Tien Nam Dao committed Oct 11, 2022
1 parent 39d5a7c commit b56d0cf
Show file tree
Hide file tree
Showing 37 changed files with 2,848 additions and 114 deletions.
9 changes: 7 additions & 2 deletions api/api_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const API_LIST = {
LATEST_BLOCK: 'evm_/api/v1?module=block&action=eth_block_number',
ALL_TOKENS: 'evm_/api/v1?module=token&action=getListTokens', // &page=1&offset=20
ALL_HOLDERS: 'evm_/api/v1?module=account&action=getTopAddressesBalance', // &page=1&offset=20

ALL_TRANSACTIONS: '/transactions',

TRANSACTIONS: '/transactions/',
EVM_TRANSACTION_DETAIL: '/api/v1?module=transaction&action=gettxinfo&txhash=', // call axios
EVM_INTERNAL_TRANSACTION: 'evm_/api/v1?module=account&action=txlistinternal&txhash=', // call axios
Expand All @@ -22,7 +22,12 @@ const API_LIST = {
MARKET_PRICE: 'https://api.tiki.vn/sandseel/api/v2/public/markets/astra/summary',
COMMON_STATS: 'evm_/api/v1/common-stats',
ESTIMATE_COUNTED_INFO: 'evm_/api/v1/estimate-counted-info',
GAS_AVG: 'evm_/api/v1/gas-price-oracle'
GAS_AVG: 'evm_/api/v1/gas-price-oracle',

ADDRESS_COUNTER: 'evm_/api/v1?module=account&action=getaddresscounters', // address=?
ADDRESS_BALANCE: 'evm_/api/v1?module=account&action=balance', // address=?
ADDRESS_TRANSACTION: 'http://128.199.238.171:8080/api/v1/accounts',
ADDRESS_TOKEN_TRANSFER: 'evm_/api/v1?module=account&action=tokentx' // address=?
}

export default API_LIST
33 changes: 33 additions & 0 deletions components/Button/QrButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import clsx from 'clsx'
import { useState } from 'react'

import styles from './style.module.scss'
/***
* @param textCopy text copy into clipboard
* @param textTitle text show on screen
* @param onCopy trigger event copy
* @param iconCopy only copy when user click on icon
*/
interface Props {
classes?: string
textTitle?: string
textClasses?: string
content: string
}

const QrButton = ({ textTitle, textClasses, content, classes }: Props) => {
const [view, setView] = useState(false)

const onShowQr = (e: any) => {
e.preventDefault()
}

return (
<a onClick={onShowQr} className={clsx('link block-hor-center contrast-color-100')}>
{textTitle && <span className={clsx(styles.text, textClasses)}>{textTitle}</span>}
<span className={clsx('padding-left-xs pointer qr-icon contrast-color-100')} />
</a>
)
}

export default QrButton
15 changes: 15 additions & 0 deletions components/Layout.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.layoutContainer {
min-height: 100vh;
.layout {
min-height: 56vh;
}
}

@media (max-width: 960px) {
.layoutContainer {
min-height: 70vh;
.layout {
min-height: 50vh;
}
}
}
6 changes: 4 additions & 2 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import API_LIST from 'api/api_list'
import clsx from 'clsx'
import React, { ReactNode, useEffect } from 'react'
import { setAstraSummary, setValidatorSummary } from 'slices/commonSlice'
import useSWR from 'swr'
import { selectTheme } from '../slices/themeSlice'
import { useAppDispatch, useAppSelector } from '../store/hooks'
import Footer from './Footer'
import styles from './Layout.module.scss'
import Navbar from './Navbar'

type Props = {
Expand Down Expand Up @@ -45,9 +47,9 @@ const Layout: React.FC<Props> = props => {
}, [validatorSummary])

return (
<div className={theme} style={{ minHeight: '100vh' }}>
<div className={clsx(theme, styles.layoutContainer)}>
<Navbar />
<div className="layout">{props.children}</div>
<div className={styles.layout}>{props.children}</div>
<Footer />
</div>
)
Expand Down
11 changes: 7 additions & 4 deletions components/Row/GradientRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import RowType from './RowType'
import styles from './style.module.scss'

interface Props {
children: React.ReactNode
children: React.ReactNode | React.ReactNode[]
type: 'success' | 'error'
classes?: string[]
classes?: string
style?: any
gradient?: 'normal' | 'transparent'
}

const GradientRow = ({ children, type, classes = ['radius-lg'], gradient = 'normal' }: Props) => {
const GradientRow = ({ style, children, type, classes = 'radius-lg', gradient = 'normal' }: Props) => {
// const arrayChildren = React.Children.toArray(children)
return (
<div
className={clsx(styles.row, styles.blockRow, styles.gradientRow, ...classes, {
style={style}
className={clsx(styles.row, styles.blockRow, styles.gradientRow, classes, {
[styles.gradientRowError]: type === 'error' && gradient === 'normal',
[styles.gradientRowSuccess]: type === 'success' && gradient === 'normal',

Expand Down
7 changes: 7 additions & 0 deletions components/Row/style.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.row {
display: flex;
flex-direction: row;
align-items: center;
flex: 1;
}

.blockRow {
box-sizing: border-box;
padding: 12px 28px;
Expand Down
2 changes: 1 addition & 1 deletion components/Tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {

const Tag = ({ text, type, classes }: Props) => {
return (
<span className={clsx(style.tag, style[type], 'money money-xs', 'money-bold', `alert-color-${type}`, classes)}>
<span className={clsx(style.tag, style[type], 'money money-2xs money-bold', `alert-color-${type}`, classes)}>
{text}
</span>
)
Expand Down
6 changes: 3 additions & 3 deletions components/Typography/LinkText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ type LinkFont = 'Titi' | 'Manrope'
interface Props {
fontType?: LinkFont
children: React.ReactNode
className?: string[]
classes?: string
href: string
fontSize?: string
}

export const LinkText = ({ fontType = 'Manrope', children, className = [], href, fontSize }: Props) => {
export const LinkText = ({ fontType = 'Manrope', children, classes, href, fontSize }: Props) => {
return (
<Link href={href}>
<span
className={clsx(
'link',
'alert-color-primary ',
fontSize || (fontType == 'Titi' ? 'money-sm' : 'text-base'),
...className,
classes,
{
'text font-500': fontType === 'Manrope',
'money font-500': fontType === 'Titi'
Expand Down
21 changes: 14 additions & 7 deletions components/Typography/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import clsx from 'clsx'

export default function Tag({ text }: { text: string }) {
interface Props {
text: string
fontType?: 'Titi' | 'Manrope'
hasArrowRight?: boolean
}

export default function Tag({ text, fontType = 'Manrope', hasArrowRight = true }: Props) {
return (
<div
className={clsx(
'arrow-right',
'padding-left-xs padding-right-2xs',
'radius-tl-sm radius-bl-sm',
'contrast-bg-color-10',
'text text-base contrast-color-50',
'margin-left-sm'
'padding-left-xs ',
'contrast-bg-color-10 margin-left-sm',
hasArrowRight
? 'margin-left-sm arrow-right radius-tl-sm radius-bl-sm padding-right-2xs'
: 'radius-sm padding-right-xs',
fontType == 'Manrope' && 'text text-base contrast-color-50',
fontType == 'Titi' && 'money money-2xs contrast-color-50'
)}
>
{text}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"@cosmjs/crypto": "^0.29.0",
"@cosmjs/encoding": "^0.29.0",
"@reduxjs/toolkit": "^1.8.5",
"@types/numeral": "^2.0.2",
"axios": "^0.27.2",
"bignumber.js": "^9.1.0",
"chart.js": "^3.9.1",
"chartjs-adapter-dayjs": "^1.0.0",
"clsx": "^1.2.1",
Expand Down Expand Up @@ -51,6 +51,7 @@
"@svgr/webpack": "^6.3.1",
"@types/lodash": "^4.14.185",
"@types/node": "^18.8.3",
"@types/numeral": "^2.0.2",
"@types/react": "18.0.17",
"@types/react-dom": "18.0.6",
"eslint": "^8.23.1",
Expand Down
8 changes: 7 additions & 1 deletion pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Container from 'components/Container'
import { NextPage } from 'next'
import Head from 'next/head'
import React from 'react'
Expand All @@ -11,7 +12,12 @@ const Home: React.FC<NextPage> = _ => {
<Head>
<title>{process.env.NEXT_PUBLIC_TITLE}</title>
</Head>
<div className="block-center text text-2xl padding-xl">404 | This page could not be found.</div>
<Container>
<div className="text text-2xl padding-xl">
<h1>404</h1> <br />
<h4>This page could not be found.</h4>
</div>
</Container>
</Layout>
)
}
Expand Down
3 changes: 2 additions & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Html, Head, Main, NextScript } from 'next/document'
import { Head, Html, Main, NextScript } from 'next/document'

export default function Document() {
return (
<Html>
<Head>
<link rel="shortcut icon" href="/images/logo/white_logo.svg" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
<body>
<Main />
Expand Down
6 changes: 3 additions & 3 deletions pages/accounts.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PaginationLite } from '@astraprotocol/astra-ui'
import { Breadcumbs, PaginationLite } from '@astraprotocol/astra-ui'
import Container from 'components/Container'
import Row from 'components/Grid/Row'
import RowLoader from 'components/Loader/RowLoader'
import { PageTitle } from 'components/Typography/PageTitle'
import RowTitle from 'components/Typography/RowTitle'
import { NextPage } from 'next'
import Head from 'next/head'
import React, { useState } from 'react'
import { LinkMaker } from 'utils/helper'
import HolderRow from 'views/accounts/HolderRow'
import useAccounts from 'views/accounts/hook/useAccounts'
import Layout from '../components/Layout'
Expand All @@ -25,7 +25,7 @@ const AstraHolderPage: React.FC<NextPage> = _ => {

<Container>
<Row style={{ justifyContent: 'space-between' }}>
<PageTitle>Astra Address</PageTitle>
<Breadcumbs items={[{ label: 'Astra Address', link: LinkMaker.address() }]} />
<PaginationLite currentPage={currentPage} hasNext={hasNextPage} onChange={onPagingChange} />
</Row>
<RowTitle
Expand Down
66 changes: 63 additions & 3 deletions pages/address/[address].tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,71 @@
import { Breadcumbs } from '@astraprotocol/astra-ui'
import Container from 'components/Container'
import Head from 'next/head'
import React from 'react'
import { GetStaticProps } from 'next'
import { ellipseBetweenText, LinkMaker } from 'utils/helper'
import AddressDetailTabs from 'views/accounts/AddressDetailTabs'
import AddressOverview from 'views/accounts/AddressOverview'
import web3 from 'web3'
import Layout from '../../components/Layout'

type Props = {}
type Props = {
address: string
}

const AddressDetailPage: React.FC<Props> = props => {
return <Layout>Implement Here</Layout>
const { address } = props

return (
<Layout>
<Head>
<title>
Address {address} - {process.env.NEXT_PUBLIC_TITLE}
</title>
</Head>
<Container>
<Breadcumbs
items={[{ label: 'Address', link: LinkMaker.address() }, { label: ellipseBetweenText(address) }]}
/>
<AddressOverview address={address} />
<AddressDetailTabs address={address} />
</Container>
</Layout>
)
}

export async function getServerSideProps({ params }) {
const { address } = params
if (web3.utils.isAddress(address))
return {
props: {
address
}
}
// try {
// const blockRes = await cosmosApi.get<BlockDetailResponse>(`${API_LIST.BLOCKS}${blockHeight}`)
// const transactionRes = await cosmosApi.get<TransactionResponse>(
// `${API_LIST.TRANSACTION_OF_BLOCK.replace(':id', blockHeight)}`
// )
// const transactions = transactionRes.data.result
// if (blockRes.status === 200) {
// return { props: { blockDetail: blockRes.data.result, blockHeight, transactions } }
// } else {
// return { props: { data: {} } }
// }
// } catch (e) {
// return {
// redirect: {
// destination: '/404',
// permanent: false
// }
// }
// }
return {
redirect: {
destination: '/404',
permanent: false
}
}
}

export default AddressDetailPage
6 changes: 3 additions & 3 deletions pages/tokens.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PaginationLite } from '@astraprotocol/astra-ui'
import { Breadcumbs, PaginationLite } from '@astraprotocol/astra-ui'
import Container from 'components/Container'
import Row from 'components/Grid/Row'
import RowLoader from 'components/Loader/RowLoader'
import { PageTitle } from 'components/Typography/PageTitle'
import RowTitle from 'components/Typography/RowTitle'
import { NextPage } from 'next'
// import {Pagination} from '@astraprotocol/astra-ui'
import Head from 'next/head'
import React, { useState } from 'react'
import { LinkMaker } from 'utils/helper'
import useTokens from 'views/tokens/hook/useTokens'
import TokenRow from 'views/tokens/TokenRow'
import Layout from '../components/Layout'
Expand All @@ -26,7 +26,7 @@ const AllTokensPage: React.FC<NextPage> = _ => {

<Container>
<Row style={{ justifyContent: 'space-between' }}>
<PageTitle>Tokens</PageTitle>
<Breadcumbs items={[{ label: 'Astra Address', link: LinkMaker.token() }]} />
<PaginationLite currentPage={currentPage} hasNext={hasNextPage} onChange={onPagingChange} />
</Row>
<RowTitle
Expand Down
Loading

0 comments on commit b56d0cf

Please sign in to comment.