Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First steps towards displaying contract info #544

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion src/app/components/SubPageCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Skeleton from '@mui/material/Skeleton'
type StyledComponentProps = {
featured?: boolean
isLoadingTitle?: boolean
title?: string
title?: ReactNode
csillag marked this conversation as resolved.
Show resolved Hide resolved
subheader?: string
action?: ReactNode
noPadding?: boolean
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