Skip to content

Commit b383cb5

Browse files
authored
Merge pull request #1888 from oasisprotocol/kaja/partially-verified-contracts-tag
Differentiate partially verified contracts
2 parents 0bc047c + 9412607 commit b383cb5

File tree

12 files changed

+43
-25
lines changed

12 files changed

+43
-25
lines changed

.changelog/1888.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Differentiate partially and fully verified contracts

src/app/components/Account/RuntimeAccountDetailsView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const RuntimeAccountDetailsView: FC<RuntimeAccountDetailsViewProps> = ({
105105
<VerificationIcon
106106
address_eth={account.address_eth!}
107107
scope={account}
108-
verified={!!account.evm_contract?.verification}
108+
verificationLevel={account.evm_contract?.verification?.verification_level}
109109
/>
110110
</dd>
111111
</>

src/app/components/ContractVerificationIcon/index.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,28 @@ import { StatusBadge } from '../common/StatusBadge'
1313
export const verificationIconBoxHeight = 28
1414

1515
type ContractStatusProps = {
16-
verified: boolean
16+
verificationLevel?: 'full' | 'partial'
1717
}
18-
19-
export const ContractStatus = ({ verified }: ContractStatusProps) => {
18+
export const ContractStatus = ({ verificationLevel }: ContractStatusProps) => {
2019
const { t } = useTranslation()
21-
const statusLabel = verified
22-
? t('contract.verification.isVerified')
23-
: t('contract.verification.isNotVerified')
24-
const statusVariant = verified ? 'success' : 'danger'
20+
const statusLabel =
21+
verificationLevel === 'full'
22+
? t('contract.verification.isVerified')
23+
: verificationLevel === 'partial'
24+
? t('contract.verification.isPartiallyVerified')
25+
: t('contract.verification.isNotVerified')
26+
const statusVariant =
27+
verificationLevel === 'full' ? 'success' : verificationLevel === 'partial' ? 'partialsuccess' : 'danger'
2528

2629
return <StatusBadge label={statusLabel} variant={statusVariant} />
2730
}
2831

2932
export const VerificationIcon: FC<{
3033
address_eth: string
3134
scope: SearchScope
32-
verified: boolean
35+
verificationLevel?: 'full' | 'partial'
3336
noLink?: boolean
34-
}> = ({ address_eth, scope, verified, noLink = false }) => {
37+
}> = ({ address_eth, scope, verificationLevel, noLink = false }) => {
3538
const { t } = useTranslation()
3639
const [explainDelay, setExplainDelay] = useState(false)
3740
if (isLocalnet(scope.network)) {
@@ -42,19 +45,19 @@ export const VerificationIcon: FC<{
4245
rel: 'noopener noreferrer',
4346
target: '_blank',
4447
sx: { fontWeight: 400, color: 'inherit', textDecoration: 'underline' },
45-
onClick: verified ? undefined : () => setExplainDelay(true),
48+
onClick: verificationLevel ? undefined : () => setExplainDelay(true),
4649
}
4750
const Component = noLink ? Box : (Link as React.ElementType)
4851
const componentProps = noLink ? {} : sourcifyLinkProps
4952

5053
return (
5154
<>
5255
<Component {...componentProps}>
53-
<ContractStatus verified={verified} />
56+
<ContractStatus verificationLevel={verificationLevel} />
5457
</Component>
5558
&nbsp; &nbsp;
5659
{!noLink &&
57-
(verified ? (
60+
(verificationLevel ? (
5861
<Typography component="span" sx={{ fontSize: '12px', color: COLORS.brandExtraDark }}>
5962
<Trans
6063
t={t}

src/app/components/StatusIcon/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,28 @@ import Tooltip from '@mui/material/Tooltip'
1111
import { useTxErrorMessage } from '../../hooks/useTxErrorMessage'
1212
import { TFunction } from 'i18next'
1313

14-
type TxStatus = 'unknown' | 'success' | 'failure' | 'pending'
14+
type TxStatus = 'unknown' | 'success' | 'partialsuccess' | 'failure' | 'pending'
1515

1616
const statusBgColor: Record<TxStatus, string> = {
1717
unknown: COLORS.grayMediumLight,
18-
success: COLORS.honeydew,
18+
success: COLORS.eucalyptus,
19+
partialsuccess: COLORS.honeydew,
1920
failure: COLORS.linen,
2021
pending: COLORS.warningLight,
2122
}
2223

2324
const statusFgColor: Record<TxStatus, string> = {
2425
unknown: COLORS.grayMedium,
25-
success: COLORS.eucalyptus,
26+
success: COLORS.honeydew,
27+
partialsuccess: COLORS.eucalyptus,
2628
failure: COLORS.errorIndicatorBackground,
2729
pending: COLORS.warningColor,
2830
}
2931

3032
export const statusIcon: Record<TxStatus, ReactNode> = {
3133
unknown: <HelpIcon color="inherit" fontSize="inherit" />,
32-
success: <CheckCircleIcon color="success" fontSize="inherit" />,
34+
success: <CheckCircleIcon color="inherit" fontSize="inherit" />,
35+
partialsuccess: <CheckCircleIcon color="success" fontSize="inherit" />,
3336
failure: <CancelIcon color="error" fontSize="inherit" />,
3437
pending: <HelpIcon color="inherit" fontSize="inherit" />,
3538
}
@@ -119,6 +122,7 @@ export const StatusIcon: FC<StatusIconProps> = ({ success, error, withText, meth
119122
const statusLabel: Record<TxStatus, string> = {
120123
unknown: t('common.unknown'),
121124
success: t('common.success'),
125+
partialsuccess: t('common.partial_success'),
122126
failure: t('common.failed'),
123127
pending: getPendingLabel(t, method, withText),
124128
}

src/app/components/Tokens/TokenDetails.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ export const TokenDetails: FC<{
6969
</dd>
7070
<dt>{t('contract.verification.title')}</dt>
7171
<dd>
72-
<VerificationIcon address_eth={token.eth_contract_addr} scope={token} verified={token.is_verified} />
72+
<VerificationIcon
73+
address_eth={token.eth_contract_addr}
74+
scope={token}
75+
verificationLevel={token.verification_level}
76+
/>
7377
</dd>
7478

7579
<dt>{t(isMobile ? 'tokens.holders' : 'tokens.holdersCount')}</dt>

src/app/components/Tokens/TokenList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export const TokenList = (props: TokensProps) => {
131131
<VerificationIcon
132132
address_eth={token.eth_contract_addr}
133133
scope={token}
134-
verified={token.is_verified}
134+
verificationLevel={token.verification_level}
135135
noLink
136136
/>
137137
</Box>

src/app/components/common/StatusBadge.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import CancelIcon from '@mui/icons-material/Cancel'
77
import InfoIcon from '@mui/icons-material/Info'
88
import ErrorIcon from '@mui/icons-material/Error'
99

10-
export type StatusVariant = 'success' | 'warning' | 'danger' | 'info'
10+
export type StatusVariant = 'success' | 'partialsuccess' | 'warning' | 'danger' | 'info'
1111

1212
const variantStyles: Record<StatusVariant, { bgColor: string }> = {
1313
success: {
14+
bgColor: COLORS.eucalyptus,
15+
},
16+
partialsuccess: {
1417
bgColor: COLORS.honeydew,
1518
},
1619
warning: {
@@ -25,7 +28,8 @@ const variantStyles: Record<StatusVariant, { bgColor: string }> = {
2528
}
2629

2730
const variantIcon: Record<StatusVariant, ReactNode> = {
28-
success: <CheckCircleIcon color="success" fontSize="small" />,
31+
success: <CheckCircleIcon sx={{ color: COLORS.honeydew }} fontSize="small" />,
32+
partialsuccess: <CheckCircleIcon color="success" fontSize="small" />,
2933
warning: <ErrorIcon color="warning" fontSize="small" />,
3034
danger: <CancelIcon color="error" fontSize="small" />,
3135
info: <InfoIcon color="info" fontSize="small" />,

src/app/pages/NFTInstanceDashboardPage/InstanceDetailsCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const InstanceDetailsCard: FC<InstanceDetailsCardProps> = ({
9797
<VerificationIcon
9898
address_eth={token?.eth_contract_addr!}
9999
scope={token!}
100-
verified={!!token?.is_verified}
100+
verificationLevel={token?.verification_level}
101101
/>
102102
</dd>
103103
</StyledDescriptionList>

src/app/pages/NFTInstanceDashboardPage/InstanceTitleCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const InstanceTitleCard: FC<InstanceTitleCardProps> = ({ isFetched, isLoa
6868
<VerificationIcon
6969
address_eth={token.eth_contract_addr}
7070
scope={token}
71-
verified={token.is_verified}
71+
verificationLevel={token.verification_level}
7272
noLink
7373
/>
7474
<AccountLink scope={scope} address={displayAddress!} alwaysTrim />

src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const TokenDetailsCard: FC<{ scope: SearchScope; address: string; searchT
6464
<VerificationIcon
6565
address_eth={token.eth_contract_addr}
6666
scope={token}
67-
verified={token.is_verified}
67+
verificationLevel={token.verification_level}
6868
/>
6969
</dd>
7070

0 commit comments

Comments
 (0)