Skip to content

Commit dc9f5ae

Browse files
authored
Merge pull request #794 from Conflux-Chain/s40
fix: SCAN-4181, SCAN-4182
2 parents 75d5421 + 8d7b06b commit dc9f5ae

File tree

6 files changed

+47
-1
lines changed

6 files changed

+47
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import { useGlobalData } from 'utils/hooks/useGlobal';
3+
import { LOCALSTORAGE_KEYS_MAP } from 'utils/constants';
4+
import { Bookmark } from '@zeit-ui/react-icons';
5+
import { useTranslation } from 'react-i18next';
6+
import { translations } from 'locales/i18n';
7+
import { Text } from '../Text/Loadable';
8+
9+
export const AddressLabel = ({ address }) => {
10+
const [globalData = {}] = useGlobalData();
11+
const { t } = useTranslation();
12+
13+
const addressLabel = globalData[LOCALSTORAGE_KEYS_MAP.addressLabel][address];
14+
const addressLabelIcon = (
15+
<Text span hoverValue={t(translations.profile.tip.label)}>
16+
<Bookmark color="var(--theme-color-gray2)" size={16} />
17+
</Text>
18+
);
19+
20+
if (addressLabel) {
21+
return (
22+
<span>
23+
{' '}
24+
({addressLabelIcon}
25+
{addressLabel})
26+
</span>
27+
);
28+
}
29+
30+
return null;
31+
};

src/app/components/TxnComponents/InputData/OptimizationDecode.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Text } from 'app/components/Text/Loadable';
1010
import { Event } from '../Event';
1111
// import Info from '@zeit-ui/react-icons/info';
1212
import { media } from 'styles/media';
13+
import { AddressLabel } from '../AddressLabel';
1314

1415
export const OptimizationDecode = ({
1516
data = '',
@@ -75,6 +76,7 @@ export const OptimizationDecode = ({
7576
{a.formattedValue}{' '}
7677
</Link>
7778
<ContractDetail info={contractInfo} />
79+
<AddressLabel address={a.formattedValue} />
7880
</>
7981
);
8082
}

src/app/containers/Transaction/EventLogs/Address.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import React from 'react';
22
import { Link } from 'app/components/Link/Loadable';
33
import { formatAddress } from 'utils';
44
import { ContractDetail } from 'app/components/TxnComponents/ContractDetail';
5+
import { AddressLabel } from 'app/components/TxnComponents/AddressLabel';
56

67
export const Address = ({ address, contract }) => {
78
return (
89
<>
910
<Link href={`/address/${address}`}>{formatAddress(address)}</Link>
1011
<ContractDetail info={contract} />
12+
<AddressLabel address={formatAddress(address)} />
1113
</>
1214
);
1315
};

src/app/containers/Transaction/EventLogs/Data.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { media } from '../../../../styles/media';
1010
import { ContractDetail } from 'app/components/TxnComponents/ContractDetail';
1111
import { formatAddress } from 'utils';
1212
import { DecodedParams } from 'app/components/TxnComponents/util';
13+
import { AddressLabel } from 'app/components/TxnComponents/AddressLabel';
1314

1415
const isPossibleAddress = data => {
1516
try {
@@ -78,7 +79,12 @@ const decodeData = (value, type) => {
7879
switch (type) {
7980
case 'address':
8081
const address = SDK.format.address(`0x${value.substr(24)}`, NETWORK_ID);
81-
result = <Link href={`/address/${address}`}>{address}</Link>;
82+
result = (
83+
<>
84+
<Link href={`/address/${address}`}>{address}</Link>
85+
<AddressLabel address={address} />
86+
</>
87+
);
8288
break;
8389
case 'number':
8490
result = SDK.format.bigInt(v).toString();
@@ -168,6 +174,7 @@ export const Data = ({
168174
<>
169175
<Link href={`/address/${d.value}`}>{d.value} </Link>
170176
<ContractDetail info={contractInfo}></ContractDetail>
177+
<AddressLabel address={d.value} />
171178
</>
172179
);
173180
}

src/app/containers/Transaction/EventLogs/Topics.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Link } from 'app/components/Link';
77
import { ContractDetail } from 'app/components/TxnComponents/ContractDetail';
88
import { media } from 'styles/media';
99
import { formatAddress } from 'utils';
10+
import { AddressLabel } from 'app/components/TxnComponents/AddressLabel';
1011

1112
export const Topics = ({ data, signature, contractAndTokenInfo }) => {
1213
const { t } = useTranslation();
@@ -81,6 +82,7 @@ export const Topics = ({ data, signature, contractAndTokenInfo }) => {
8182
<>
8283
<Link href={`/address/${value}`}>{value} </Link>
8384
<ContractDetail info={contractInfo}></ContractDetail>
85+
<AddressLabel address={value} />
8486
</>
8587
);
8688
}

src/app/containers/Transaction/EventLogs/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Data } from './Data';
2222
import { Event } from 'app/components/TxnComponents/Event';
2323
import { disassembleEvent } from 'app/components/TxnComponents/util';
2424
import { media } from 'styles/media';
25+
import { AddressLabel } from 'app/components/TxnComponents/AddressLabel';
2526

2627
interface Props {
2728
hash: string;
@@ -193,6 +194,7 @@ const EventLog = ({ log }) => {
193194
address={address}
194195
contract={contractAndTokenInfo[formatAddress(address)]}
195196
></Address>
197+
<AddressLabel address={address} />
196198
</Description>
197199
{fnName ? (
198200
<Description

0 commit comments

Comments
 (0)