Skip to content

Commit

Permalink
fix: missing import
Browse files Browse the repository at this point in the history
  • Loading branch information
Tien Nam Dao committed Nov 8, 2022
1 parent 28a3aa3 commit 3dfdecb
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 7 deletions.
36 changes: 36 additions & 0 deletions pages/address/[address]/verify-contract.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useMobileLayout } from '@astraprotocol/astra-ui'
import Container from 'components/Container'
import Layout from 'components/Layout'
import Head from 'next/head'
import React from 'react'

type Props = {
errorMessage?: string
address: string
addressData: Address
}

const ContractVerifyPage: React.FC<Props> = props => {
const { isMobile } = useMobileLayout()
const { address, addressData, errorMessage } = props

return (
<Layout>
<Head>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<title>Verify Contract</title>
</Head>
<Container>
<iframe
src="https://blockscout.astranaut.dev/address/0x23c5d4a327EAcCAfcb6438F96aa3df84aB1486e3/verify-via-flattened-code/new"
height={1000}
width={1200}
/>
</Container>
</Layout>
)
}

// export async function getServerSideProps({ params }) {}

export default ContractVerifyPage
8 changes: 6 additions & 2 deletions views/accounts/AddressDetailTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import AddressInternalTransactionTab from './tabs/AddressInternalTransactionTab'
import AddressTokenTab from './tabs/AddressTokenTab'
import AddressTokenTransferTab from './tabs/AddressTokenTransferTab'
import AddressTransactionTab from './tabs/AddressTransactionTab'
import ContractCodeTab from './tabs/ContractCodeTab'
import ContractTransactionTab from './tabs/ContractTransactionTab'

interface Props {
Expand All @@ -16,6 +17,7 @@ interface Props {

const AddressDetailTab = ({ address, addressData }: Props) => {
const isContract = addressData.type === AddressTypeEnum.Contract
// contract verify?
return (
<BackgroundCard classes="margin-top-lg padding-bottom-lg">
<Tabs
Expand All @@ -25,7 +27,8 @@ const AddressDetailTab = ({ address, addressData }: Props) => {
{ title: 'Token Transfer', id: '2' },
{ title: 'Tokens', id: '3' },
{ title: 'Internal Transactions', id: '4' },
{ title: 'Coin Balance History', id: '5' }
{ title: 'Coin Balance History', id: '5' },
isContract && { title: 'Coin Balance History', id: '6' }
]}
contents={{
'1': isContract ? (
Expand All @@ -36,7 +39,8 @@ const AddressDetailTab = ({ address, addressData }: Props) => {
'2': <AddressTokenTransferTab address={address} />,
'3': <AddressTokenTab address={address} />,
'4': <AddressInternalTransactionTab address={address} />,
'5': <AddressCoinBalanceTab address={address} />
'5': <AddressCoinBalanceTab address={address} />,
'6': <ContractCodeTab address={address} />
}}
></Tabs>
</BackgroundCard>
Expand Down
17 changes: 12 additions & 5 deletions views/accounts/hook/useAddressTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import API_LIST from 'api/api_list'
import { formatEther } from 'ethers/lib/utils'
import { useEffect, useState } from 'react'
import useSWR from 'swr'
import { caculateTxAmount } from 'views/transactions/utils'
import { caculateCosmosTxAmount, caculateEthereumTxAmount } from 'views/transactions/utils'

export default function useAddressTransactions(address: string, page: number) {
const [hookData, setState] = useState<UseAddressTransactionData>({
Expand All @@ -28,14 +28,21 @@ export default function useAddressTransactions(address: string, page: number) {
return rawData.result.map(d => {
let type

const numberOfMsgTypes = d.messageTypes.length
// const numberOfMsgTypes = d.messageTypes.length
const msgTypeSplit = d.messageTypes[0].split('.')
const msgTypeShort = msgTypeSplit[msgTypeSplit.length - 1]
if (numberOfMsgTypes >= 2) type = `${msgTypeShort} (+${numberOfMsgTypes - 1})`
else type = msgTypeShort
// Show in detail
// if (numberOfMsgTypes >= 2) type = `${msgTypeShort} (+${numberOfMsgTypes - 1})`
// else type = msgTypeShort
type = msgTypeShort

return {
value: (d.value ? formatEther(d.value) : caculateTxAmount(d.messages)) || '0',
value:
(d.value
? formatEther(d.value)
: type === 'MsgEthereumTx'
? caculateEthereumTxAmount(d.messages)
: caculateCosmosTxAmount(d.messages)) || '0',
account: d.account,
blockHash: d.blockHash,
blockHeight: d.blockHeight,
Expand Down
18 changes: 18 additions & 0 deletions views/accounts/tabs/ContractCodeTab/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Row from 'components/Grid/Row'

interface Props {
address: string
}

const ContractCodeTab = ({ address }: Props) => {
return (
<div>
<Row style={{ justifyContent: 'space-between' }} classes="padding-xl">
<span className="text text-xl">Contract Code</span>
<></>
</Row>
</div>
)
}

export default ContractCodeTab
Empty file.

0 comments on commit 3dfdecb

Please sign in to comment.