Skip to content

Commit 0536336

Browse files
committed
chore: update api host
1 parent 0842846 commit 0536336

File tree

28 files changed

+335
-182
lines changed

28 files changed

+335
-182
lines changed

src/components/account/accountTable.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,69 @@ import { PAGE_SIZE } from '@/utils/const'
88
import { useData } from '@/context'
99
import BigNumber from 'bignumber.js'
1010
import { Link } from '../link'
11+
import { env } from 'next-runtime-env'
1112

1213
interface Props extends BareProps {
1314
args?: getExtrinsicListParams
1415
}
1516

1617
const Component: React.FC<Props> = ({ children, className, args }) => {
17-
const { metadata, token, isLoading } = useData();
18+
const { metadata, token, isLoading } = useData()
1819
const [page, setPage] = React.useState(1)
1920
const rowsPerPage = PAGE_SIZE
20-
const { data } = useAccounts({
21+
const NEXT_PUBLIC_API_HOST = env('NEXT_PUBLIC_API_HOST') || ''
22+
const { data } = useAccounts(NEXT_PUBLIC_API_HOST, {
2123
...args,
2224
page: page - 1,
2325
row: rowsPerPage,
2426
})
2527
const extrinsicsData = unwrap(data)
2628
const total = extrinsicsData?.count || 0
2729
const items = extrinsicsData?.list
28-
const pages = useMemo(() => {
29-
return extrinsicsData?.count ? Math.ceil(extrinsicsData?.count / rowsPerPage) : 0;
30-
}, [extrinsicsData?.count, rowsPerPage]);
30+
const pages = useMemo(() => {
31+
return extrinsicsData?.count ? Math.ceil(extrinsicsData?.count / rowsPerPage) : 0
32+
}, [extrinsicsData?.count, rowsPerPage])
3133
return (
3234
<Table
3335
aria-label="Table"
3436
bottomContent={
3537
<div className="flex w-full justify-center">
3638
{pages > 0 && (
37-
<Pagination color={getThemeColor(true)} isCompact showControls showShadow initialPage={1} page={page} total={pages} onChange={(page) => setPage(page)} />
39+
<Pagination
40+
color={getThemeColor(true)}
41+
isCompact
42+
showControls
43+
showShadow
44+
initialPage={1}
45+
page={page}
46+
total={pages}
47+
onChange={(page) => setPage(page)}
48+
/>
3849
)}
3950
</div>
4051
}
4152
classNames={{
4253
wrapper: 'min-h-[222px]',
43-
td: 'h-[50px]'
54+
td: 'h-[50px]',
4455
}}>
4556
<TableHeader>
4657
<TableColumn key="address">Account</TableColumn>
4758
<TableColumn key="balance">{`Balance (${token?.symbol})`}</TableColumn>
4859
</TableHeader>
49-
<TableBody items={items || []} emptyContent={"No data"}>
60+
<TableBody items={items || []} emptyContent={'No data'}>
5061
{(item) => (
5162
<TableRow key={item.address}>
5263
{(columnKey) => {
5364
if (columnKey === 'balance') {
5465
return <TableCell>{getBalanceAmount(new BigNumber(item.balance), token?.decimals).toFormat()}</TableCell>
5566
} else if (columnKey === 'address') {
56-
return <TableCell><Link color={getThemeColor(true)} href={`/sub/account/${item.address}`}>{item.address}</Link></TableCell>
67+
return (
68+
<TableCell>
69+
<Link color={getThemeColor(true)} href={`/sub/account/${item.address}`}>
70+
{item.address}
71+
</Link>
72+
</TableCell>
73+
)
5774
}
5875
return <TableCell>{getKeyValue(item, columnKey)}</TableCell>
5976
}}

src/components/block/blockTable.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ import { unwrap, useBlocks } from '@/utils/api'
66
import { getThemeColor, timeAgo } from '@/utils/text'
77
import { PAGE_SIZE } from '@/utils/const'
88
import { Link } from '../link'
9+
import { env } from 'next-runtime-env'
910

1011
interface Props extends BareProps {
1112
args?: string
1213
}
1314

1415
const Component: React.FC<Props> = ({ children, className }) => {
1516
const [page, setPage] = React.useState(1)
17+
const NEXT_PUBLIC_API_HOST = env('NEXT_PUBLIC_API_HOST') || ''
1618
const rowsPerPage = PAGE_SIZE
17-
const { data } = useBlocks({
19+
const { data } = useBlocks(NEXT_PUBLIC_API_HOST, {
1820
page: page - 1,
1921
row: rowsPerPage,
2022
})
@@ -31,12 +33,23 @@ const Component: React.FC<Props> = ({ children, className }) => {
3133
aria-label="Table"
3234
bottomContent={
3335
<div className="flex w-full justify-center">
34-
{pages > 0 && <Pagination color={getThemeColor(true)} isCompact showControls showShadow initialPage={1} page={page} total={pages} onChange={(page) => setPage(page)} />}
36+
{pages > 0 && (
37+
<Pagination
38+
color={getThemeColor(true)}
39+
isCompact
40+
showControls
41+
showShadow
42+
initialPage={1}
43+
page={page}
44+
total={pages}
45+
onChange={(page) => setPage(page)}
46+
/>
47+
)}
3548
</div>
3649
}
3750
classNames={{
3851
wrapper: 'min-h-[222px]',
39-
td: 'h-[50px]'
52+
td: 'h-[50px]',
4053
}}>
4154
<TableHeader>
4255
<TableColumn key="block_num">Block</TableColumn>
@@ -45,20 +58,24 @@ const Component: React.FC<Props> = ({ children, className }) => {
4558
<TableColumn key="event_count">Event</TableColumn>
4659
<TableColumn key="block_timestamp">Time</TableColumn>
4760
</TableHeader>
48-
<TableBody items={items || []} emptyContent={"No data"}>
61+
<TableBody items={items || []} emptyContent={'No data'}>
4962
{(item) => (
5063
<TableRow key={item.block_num}>
5164
{(columnKey) => {
5265
if (columnKey === 'block_num') {
5366
return (
5467
<TableCell>
55-
<Link color={getThemeColor(true)} href={`/sub/block/${item.block_num}`}>{item.block_num}</Link>
68+
<Link color={getThemeColor(true)} href={`/sub/block/${item.block_num}`}>
69+
{item.block_num}
70+
</Link>
5671
</TableCell>
5772
)
5873
} else if (columnKey === 'hash') {
5974
return (
6075
<TableCell>
61-
<Link color={getThemeColor(true)} href={`/sub/block/${item.block_num}`}>{item.hash}</Link>
76+
<Link color={getThemeColor(true)} href={`/sub/block/${item.block_num}`}>
77+
{item.hash}
78+
</Link>
6279
</TableCell>
6380
)
6481
} else if (columnKey === 'block_timestamp') {

src/components/contract/contractTable.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,57 @@ import { Table, Pagination, TableHeader, TableColumn, TableBody, TableRow, Table
55
import { getPVMContractListParams, unwrap, usePVMContracts } from '@/utils/api'
66
import { PAGE_SIZE } from '@/utils/const'
77
import { useData } from '@/context'
8-
import BigNumber from 'bignumber.js'
98
import { Link } from '../link'
9+
import { env } from 'next-runtime-env'
1010

1111
interface Props extends BareProps {
1212
args?: getPVMContractListParams
1313
}
1414

1515
const Component: React.FC<Props> = ({ children, className, args }) => {
16-
const { metadata, token, isLoading } = useData();
16+
const { metadata, token, isLoading } = useData()
1717
const [page, setPage] = React.useState(1)
1818
const rowsPerPage = PAGE_SIZE
19-
const { data } = usePVMContracts({
19+
const NEXT_PUBLIC_API_HOST = env('NEXT_PUBLIC_API_HOST') || ''
20+
const { data } = usePVMContracts(NEXT_PUBLIC_API_HOST, {
2021
...args,
2122
page: page - 1,
2223
row: rowsPerPage,
2324
})
2425
const contractsData = unwrap(data)
2526
const total = contractsData?.count || 0
2627
const items = contractsData?.list
27-
const pages = useMemo(() => {
28-
return contractsData?.count ? Math.ceil(contractsData?.count / rowsPerPage) : 0;
29-
}, [contractsData?.count, rowsPerPage]);
28+
const pages = useMemo(() => {
29+
return contractsData?.count ? Math.ceil(contractsData?.count / rowsPerPage) : 0
30+
}, [contractsData?.count, rowsPerPage])
3031
return (
3132
<Table
3233
aria-label="Table"
3334
bottomContent={
3435
<div className="flex w-full justify-center">
35-
{pages > 0 && (
36-
<Pagination isCompact showControls showShadow initialPage={1} page={page} total={pages} onChange={(page) => setPage(page)} />
37-
)}
36+
{pages > 0 && <Pagination isCompact showControls showShadow initialPage={1} page={page} total={pages} onChange={(page) => setPage(page)} />}
3837
</div>
3938
}
4039
classNames={{
4140
wrapper: 'min-h-[222px]',
42-
td: 'h-[50px]'
41+
td: 'h-[50px]',
4342
}}>
4443
<TableHeader>
4544
<TableColumn key="address">Contract</TableColumn>
4645
<TableColumn key="contract_name">Name</TableColumn>
4746
<TableColumn key="transaction_count">Transaction</TableColumn>
4847
<TableColumn key="verify_status">Status</TableColumn>
4948
</TableHeader>
50-
<TableBody items={items || []} emptyContent={"No data"}>
49+
<TableBody items={items || []} emptyContent={'No data'}>
5150
{(item) => (
5251
<TableRow key={item.address}>
5352
{(columnKey) => {
5453
if (columnKey === 'address') {
55-
return <TableCell><Link href={`/contract/${item.address}`}>{item.address}</Link></TableCell>
54+
return (
55+
<TableCell>
56+
<Link href={`/contract/${item.address}`}>{item.address}</Link>
57+
</TableCell>
58+
)
5659
} else if (columnKey === 'verify_status') {
5760
return <TableCell>{item.verify_status === 'verified' ? 'Verified' : 'Unverified'}</TableCell>
5861
}

src/components/contract/verify.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ import { getThemeColor, parseFileText } from '@/utils/text'
1616
import { FileUpload } from '../file'
1717
import _ from 'lodash'
1818
import axios from 'axios'
19-
import { API_HOST } from '@/utils/const'
2019
import qs from 'qs'
2120
import { Link } from '../link'
21+
import { env } from 'next-runtime-env'
2222

2323
interface Props extends BareProps {
2424
address: string
2525
}
2626

2727
const Component: React.FC<Props> = ({ children, className, address }) => {
28+
const NEXT_PUBLIC_API_HOST = env('NEXT_PUBLIC_API_HOST') || ''
2829
const [isLoading, setIsLoading] = useState<boolean>(false)
2930
const [nightly, setNightly] = useState<string>('false')
3031
const [compilerType, setCompilerType] = useState<string>('json')
@@ -59,7 +60,7 @@ const Component: React.FC<Props> = ({ children, className, address }) => {
5960
})
6061
return options
6162
}, [])
62-
const { data, error } = usePVMSolcs({
63+
const { data, error } = usePVMSolcs(NEXT_PUBLIC_API_HOST, {
6364
releases: nightly !== 'true',
6465
})
6566
const compilerData = unwrap(data)
@@ -75,7 +76,7 @@ const Component: React.FC<Props> = ({ children, className, address }) => {
7576
})
7677
return options
7778
}, [compilerData])
78-
const { data: pvmData } = usePVMResolcs({})
79+
const { data: pvmData } = usePVMResolcs(NEXT_PUBLIC_API_HOST, {})
7980
const resolcData = unwrap(pvmData)
8081
const resolcOptions = useMemo(() => {
8182
let options: any[] = []
@@ -158,7 +159,7 @@ const Component: React.FC<Props> = ({ children, className, address }) => {
158159
axios({
159160
url: verifyApi.path,
160161
method: 'POST',
161-
baseURL: `${API_HOST}`,
162+
baseURL: `${NEXT_PUBLIC_API_HOST}`,
162163
headers: {
163164
'Content-Type': 'application/x-www-form-urlencoded',
164165
},

src/components/erc20Token/erc20TokenTable.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getPVMTokenListParams, unwrap, usePVMTokens } from '@/utils/api'
66
import { timeAgo } from '@/utils/text'
77
import { PAGE_SIZE } from '@/utils/const'
88
import { Link } from '../link'
9+
import { env } from 'next-runtime-env'
910

1011
interface Props extends BareProps {
1112
args?: getPVMTokenListParams
@@ -14,7 +15,8 @@ interface Props extends BareProps {
1415
const Component: React.FC<Props> = ({ args, children, className }) => {
1516
const [page, setPage] = React.useState(1)
1617
const rowsPerPage = PAGE_SIZE
17-
const { data } = usePVMTokens({
18+
const NEXT_PUBLIC_API_HOST = env('NEXT_PUBLIC_API_HOST') || ''
19+
const { data } = usePVMTokens(NEXT_PUBLIC_API_HOST, {
1820
...args,
1921
page: page - 1,
2022
row: rowsPerPage,
@@ -37,7 +39,7 @@ const Component: React.FC<Props> = ({ args, children, className }) => {
3739
}
3840
classNames={{
3941
wrapper: 'min-h-[222px]',
40-
td: 'h-[50px]'
42+
td: 'h-[50px]',
4143
}}>
4244
<TableHeader>
4345
<TableColumn key="symbol">Symbol</TableColumn>

src/components/erc20Token/tokenHolderTable.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PAGE_SIZE } from '@/utils/const'
77
import BigNumber from 'bignumber.js'
88
import { getBalanceAmount } from '@/utils/text'
99
import { Link } from '../link'
10+
import { env } from 'next-runtime-env'
1011

1112
interface Props extends BareProps {
1213
args?: getPVMTokenHolderListParams
@@ -16,7 +17,8 @@ interface Props extends BareProps {
1617
const Component: React.FC<Props> = ({ args, token, children, className }) => {
1718
const [page, setPage] = React.useState(1)
1819
const rowsPerPage = PAGE_SIZE
19-
const { data } = usePVMTokenHolders({
20+
const NEXT_PUBLIC_API_HOST = env('NEXT_PUBLIC_API_HOST') || ''
21+
const { data } = usePVMTokenHolders(NEXT_PUBLIC_API_HOST, {
2022
...args,
2123
page: page - 1,
2224
row: rowsPerPage,
@@ -39,7 +41,7 @@ const Component: React.FC<Props> = ({ args, token, children, className }) => {
3941
}
4042
classNames={{
4143
wrapper: 'min-h-[222px]',
42-
td: 'h-[50px]'
44+
td: 'h-[50px]',
4345
}}>
4446
<TableHeader>
4547
<TableColumn key="holder">Account</TableColumn>

src/components/erc20Token/tokenTransferTable.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import React, { useMemo } from 'react'
22

33
import { BareProps } from '@/types/page'
44
import { Table, Pagination, TableHeader, TableColumn, TableBody, TableRow, TableCell, getKeyValue } from '@heroui/react'
5-
import { getPVMTokenHolderListParams, getPVMTokenTransferListParams, pvmTokenType, unwrap, usePVMTokenHolders, usePVMTokenTransfers } from '@/utils/api'
5+
import {
6+
getPVMTokenTransferListParams,
7+
pvmTokenType,
8+
unwrap,
9+
usePVMTokenTransfers,
10+
} from '@/utils/api'
611
import { PAGE_SIZE } from '@/utils/const'
712
import BigNumber from 'bignumber.js'
813
import { formatHash, getBalanceAmount, timeAgo } from '@/utils/text'
914
import { Link } from '../link'
15+
import { env } from 'next-runtime-env'
1016

1117
interface Props extends BareProps {
1218
args?: getPVMTokenTransferListParams
@@ -16,7 +22,8 @@ interface Props extends BareProps {
1622
const Component: React.FC<Props> = ({ args, token, children, className }) => {
1723
const [page, setPage] = React.useState(1)
1824
const rowsPerPage = PAGE_SIZE
19-
const { data } = usePVMTokenTransfers({
25+
const NEXT_PUBLIC_API_HOST = env('NEXT_PUBLIC_API_HOST') || ''
26+
const { data } = usePVMTokenTransfers(NEXT_PUBLIC_API_HOST, {
2027
...args,
2128
page: page - 1,
2229
row: rowsPerPage,
@@ -39,7 +46,7 @@ const Component: React.FC<Props> = ({ args, token, children, className }) => {
3946
}
4047
classNames={{
4148
wrapper: 'min-h-[222px]',
42-
td: 'h-[50px]'
49+
td: 'h-[50px]',
4350
}}>
4451
<TableHeader>
4552
<TableColumn key="hash">Transaction Hash</TableColumn>
@@ -60,9 +67,17 @@ const Component: React.FC<Props> = ({ args, token, children, className }) => {
6067
</TableCell>
6168
)
6269
} else if (columnKey === 'hash') {
63-
return <TableCell><Link href={`/tx/${item.hash}`}>{formatHash(item.hash)}</Link></TableCell>
70+
return (
71+
<TableCell>
72+
<Link href={`/tx/${item.hash}`}>{formatHash(item.hash)}</Link>
73+
</TableCell>
74+
)
6475
} else if (columnKey === 'value') {
65-
return <TableCell>{getBalanceAmount(new BigNumber(item.value), item.decimals).toFormat()} {item.symbol}</TableCell>
76+
return (
77+
<TableCell>
78+
{getBalanceAmount(new BigNumber(item.value), item.decimals).toFormat()} {item.symbol}
79+
</TableCell>
80+
)
6681
} else if (columnKey === 'create_at') {
6782
return <TableCell>{timeAgo(item.create_at)}</TableCell>
6883
}

0 commit comments

Comments
 (0)