Skip to content

Commit

Permalink
First steps towards displaying contract info
Browse files Browse the repository at this point in the history
- When displaying a contract, say so in the title
- Show link to TX that created the contract
  • Loading branch information
csillag committed Jun 20, 2023
1 parent ca63904 commit 17305eb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/544.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
At address page, recognize contracts, and use appropriate title
11 changes: 11 additions & 0 deletions src/app/components/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Link from '@mui/material/Link'
import { DashboardLink } from '../../pages/DashboardPage/DashboardLink'
import { getNameForTicker, Ticker } from '../../../types/ticker'
import { TokenPriceInfo } from '../../../coin-gecko/api'
import { TransactionLink } from '../Transactions/TransactionLink'

export const StyledAvatarContainer = styled('dt')(({ theme }) => ({
'&&': {
Expand Down Expand Up @@ -58,6 +59,7 @@ export const Account: FC<AccountProps> = ({ account, isLoading, tokenPriceInfo,
const { isMobile } = useScreenSize()
const balance = account?.balances[0]?.balance ?? '0'
const address = account ? account.address_eth ?? account.address : undefined
const creationTxHash = account?.evm_contract?.creation_tx // TODO: use evm_hash if available

const transactionsLabel = account ? account.stats.num_txns.toLocaleString() : ''
const transactionsAnchor = account
Expand Down Expand Up @@ -97,6 +99,15 @@ export const Account: FC<AccountProps> = ({ account, isLoading, tokenPriceInfo,
<CopyToClipboard value={address!} />
</dd>

{creationTxHash && (
<>
<dt>{t('common.createdAt')}</dt>
<dd>
<TransactionLink scope={account} hash={creationTxHash} />
</dd>
</>
)}

<dt>{t('common.balance')}</dt>
<dd>{t('common.valueInToken', { value: balance, ticker: tickerName })}</dd>

Expand Down
7 changes: 6 additions & 1 deletion src/app/pages/AccountDetailsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const AccountDetailsPage: FC = () => {
const { account, isLoading, isError } = useAccount(scope, address)

const tokenPriceInfo = useTokenPrice(account?.ticker || Ticker.ROSE)
const isContract = !!account?.evm_contract

const showErc20 = showEmptyAccountDetails || !!account?.tokenBalances[EvmTokenType.ERC20].length
const erc20Link = useHref(`tokens/erc-20#${accountTokenContainerId}`)
Expand All @@ -33,7 +34,11 @@ export const AccountDetailsPage: FC = () => {

return (
<PageLayout>
<SubPageCard featured title={t('account.title')}>
<SubPageCard
featured
isLoadingTitle={isLoading}
title={isContract ? t('contract.title') : t('account.title')}
>
<AccountDetailsView
isLoading={isLoading}
isError={isError}
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"block": "Block",
"bytes": "{{value, number}}",
"cancel": "Cancel",
"createdAt": "Created at",
"data": "Data",
"emerald": "Emerald",
"cipher": "Cipher",
Expand Down Expand Up @@ -90,6 +91,9 @@
"testnet": "Testnet",
"valuePair": "{{value, number}}"
},
"contract": {
"title": "Contract"
},
"nodes": {
"title": "Active nodes",
"unknown": "Consensus layer indexer is not caught up with the latest blocks. The number of active nodes is unknown.",
Expand Down

0 comments on commit 17305eb

Please sign in to comment.