@cfxjs/sirius-next-common 0.1.32 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2P6RNTXI.js +141 -0
- package/dist/chunk-2P6RNTXI.js.map +1 -0
- package/dist/chunk-5PYSDWGQ.js +127 -0
- package/dist/chunk-5PYSDWGQ.js.map +1 -0
- package/dist/chunk-5Z5K44KU.js +108 -0
- package/dist/chunk-5Z5K44KU.js.map +1 -0
- package/dist/chunk-CL6X23Y3.js +108 -0
- package/dist/chunk-CL6X23Y3.js.map +1 -0
- package/dist/chunk-E7KZNWOF.js +150 -0
- package/dist/chunk-E7KZNWOF.js.map +1 -0
- package/dist/chunk-EF2N45TZ.js +49 -0
- package/dist/chunk-EF2N45TZ.js.map +1 -0
- package/dist/chunk-GJCBWNU5.js +127 -0
- package/dist/chunk-GJCBWNU5.js.map +1 -0
- package/dist/chunk-GL4KHAZB.js +105 -0
- package/dist/chunk-GL4KHAZB.js.map +1 -0
- package/dist/chunk-GYK27Y5X.js +796 -0
- package/dist/chunk-GYK27Y5X.js.map +1 -0
- package/dist/chunk-H63H7IRY.js +141 -0
- package/dist/chunk-H63H7IRY.js.map +1 -0
- package/dist/chunk-HMP3NSJX.js +3629 -0
- package/dist/chunk-HMP3NSJX.js.map +1 -0
- package/dist/chunk-JMM6NFUN.js +212 -0
- package/dist/chunk-JMM6NFUN.js.map +1 -0
- package/dist/chunk-LC3NZF3B.js +3629 -0
- package/dist/chunk-LC3NZF3B.js.map +1 -0
- package/dist/chunk-LSIWDRKV.js +105 -0
- package/dist/chunk-LSIWDRKV.js.map +1 -0
- package/dist/chunk-MN3Y4WII.js +2324 -0
- package/dist/chunk-MN3Y4WII.js.map +1 -0
- package/dist/chunk-OBYGZKWE.js +796 -0
- package/dist/chunk-OBYGZKWE.js.map +1 -0
- package/dist/chunk-PH7BGJ6R.js +150 -0
- package/dist/chunk-PH7BGJ6R.js.map +1 -0
- package/dist/chunk-PKSF74ZF.js +49 -0
- package/dist/chunk-PKSF74ZF.js.map +1 -0
- package/dist/chunk-QSLCIDOR.js +212 -0
- package/dist/chunk-QSLCIDOR.js.map +1 -0
- package/dist/chunk-XEK7EJTM.js +2324 -0
- package/dist/chunk-XEK7EJTM.js.map +1 -0
- package/dist/components/AddressContainer/CoreAddressContainer.js +10 -10
- package/dist/components/AddressContainer/EVMAddressContainer.js +9 -9
- package/dist/components/AddressContainer/addressSwitcher.js +7 -7
- package/dist/components/AddressContainer/addressView.js +6 -6
- package/dist/components/AddressContainer/label.js +3 -3
- package/dist/components/Age/index.js +3 -3
- package/dist/components/CopyButton/index.js +2 -2
- package/dist/components/DownloadCSV/index.js +3 -3
- package/dist/components/GasPriceDropdown/index.js +1 -1
- package/dist/components/IncreasePercent/index.js +1 -1
- package/dist/components/InfoIconWithTooltip/index.js +2 -2
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/NetworkIcon/index.js +1 -1
- package/dist/components/PhishingAddressContainer/index.js +4 -4
- package/dist/components/Price/index.js +2 -2
- package/dist/components/Radio/index.js +1 -1
- package/dist/components/Select/index.js +2 -2
- package/dist/components/Select/select.js +2 -2
- package/dist/components/Text/index.js +3 -3
- package/dist/components/Tooltip/index.js +2 -2
- package/dist/components/TransactionAction/coreTransactionAction.js +10 -10
- package/dist/components/TransactionAction/evmTransactionAction.js +9 -9
- package/dist/utils/address.js +2 -2
- package/dist/utils/contractManagerTool.js +1 -1
- package/dist/utils/hooks/useENS.js +3 -3
- package/dist/utils/index.d.ts +15 -1
- package/dist/utils/index.js +7 -3
- package/dist/utils/rpcRequest.d.ts +1 -1
- package/dist/utils/rpcRequest.js +1 -1
- package/package.json +10 -6
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useENS
|
|
3
|
+
} from "./chunk-3UXPRBHP.js";
|
|
4
|
+
import {
|
|
5
|
+
ContractAddress,
|
|
6
|
+
ContractCreatedAddress,
|
|
7
|
+
CoreHexAddress,
|
|
8
|
+
InvalidAddress,
|
|
9
|
+
MyAddress,
|
|
10
|
+
PosAddress
|
|
11
|
+
} from "./chunk-JMM6NFUN.js";
|
|
12
|
+
import {
|
|
13
|
+
RenderAddress
|
|
14
|
+
} from "./chunk-GJCBWNU5.js";
|
|
15
|
+
import {
|
|
16
|
+
formatAddress,
|
|
17
|
+
isCoreAddress,
|
|
18
|
+
isCoreContractAddress,
|
|
19
|
+
isZeroAddress
|
|
20
|
+
} from "./chunk-OJQKHBLY.js";
|
|
21
|
+
import {
|
|
22
|
+
getLabelInfo
|
|
23
|
+
} from "./chunk-PKSF74ZF.js";
|
|
24
|
+
import {
|
|
25
|
+
getTranslations,
|
|
26
|
+
useGlobalData
|
|
27
|
+
} from "./chunk-DQGLZCIG.js";
|
|
28
|
+
|
|
29
|
+
// src/components/AddressContainer/CoreAddressContainer.tsx
|
|
30
|
+
import { memo } from "react";
|
|
31
|
+
import { withTranslation } from "react-i18next";
|
|
32
|
+
import _ from "lodash";
|
|
33
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
34
|
+
var parseProps = (props, globalData) => {
|
|
35
|
+
const {
|
|
36
|
+
alias,
|
|
37
|
+
ensInfo,
|
|
38
|
+
t,
|
|
39
|
+
showAddressLabel,
|
|
40
|
+
showNametag,
|
|
41
|
+
nametagInfo,
|
|
42
|
+
showENSLabel
|
|
43
|
+
} = props;
|
|
44
|
+
const value = props.value || "";
|
|
45
|
+
const cfxAddress = formatAddress(value, "base32");
|
|
46
|
+
let ENSMap = ensInfo || {};
|
|
47
|
+
const translations = getTranslations();
|
|
48
|
+
let aliasLabel = alias;
|
|
49
|
+
if (!alias && isZeroAddress(cfxAddress)) {
|
|
50
|
+
aliasLabel = t(translations.general.zeroAddress);
|
|
51
|
+
}
|
|
52
|
+
let prefixIcon = null;
|
|
53
|
+
let officalNametag = null;
|
|
54
|
+
let addressLabel = null;
|
|
55
|
+
let ENSLabel = null;
|
|
56
|
+
const gENSLabel = cfxAddress && ENSMap[cfxAddress]?.name;
|
|
57
|
+
if (cfxAddress && showAddressLabel) {
|
|
58
|
+
const addressLabels = globalData?.["CONFLUX_SCAN_ADDRESS_LABELS" /* addressLabel */];
|
|
59
|
+
const gAddressLabel = addressLabels?.[cfxAddress];
|
|
60
|
+
if (gAddressLabel) {
|
|
61
|
+
const { label } = getLabelInfo(gAddressLabel, "tag");
|
|
62
|
+
addressLabel = label;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (cfxAddress && showNametag) {
|
|
66
|
+
const nametags = nametagInfo?.[cfxAddress];
|
|
67
|
+
if (nametags) {
|
|
68
|
+
const nametag = nametags?.nametag ?? "";
|
|
69
|
+
const { label } = getLabelInfo(nametag, "nametag");
|
|
70
|
+
officalNametag = label;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (showENSLabel && gENSLabel) {
|
|
74
|
+
const { label, icon } = getLabelInfo(gENSLabel, "ens");
|
|
75
|
+
ENSLabel = label;
|
|
76
|
+
prefixIcon = icon;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
alias: aliasLabel,
|
|
80
|
+
prefix: prefixIcon,
|
|
81
|
+
nametag: officalNametag,
|
|
82
|
+
addressLabel,
|
|
83
|
+
ENSLabel,
|
|
84
|
+
cfxAddress
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
var CoreAddressContainer = withTranslation()(
|
|
88
|
+
memo((props) => {
|
|
89
|
+
const { globalData } = useGlobalData();
|
|
90
|
+
const unnecessaryEns = props.ensInfo || props.showENSLabel === false;
|
|
91
|
+
const { ens } = useENS(unnecessaryEns ? null : props.value);
|
|
92
|
+
if (!props.value && !props.contractCreated) {
|
|
93
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "--" });
|
|
94
|
+
}
|
|
95
|
+
const defaultProps = {
|
|
96
|
+
isFull: false,
|
|
97
|
+
isFullNameTag: false,
|
|
98
|
+
link: true,
|
|
99
|
+
isMe: false,
|
|
100
|
+
showIcon: true,
|
|
101
|
+
verify: false,
|
|
102
|
+
showAddressLabel: true,
|
|
103
|
+
showENSLabel: true,
|
|
104
|
+
showNametag: true,
|
|
105
|
+
ensInfo: ens
|
|
106
|
+
};
|
|
107
|
+
const mergeDefaultProps = _.assign({}, defaultProps, props);
|
|
108
|
+
const mergeParseProps = _.merge(
|
|
109
|
+
{},
|
|
110
|
+
mergeDefaultProps,
|
|
111
|
+
parseProps(mergeDefaultProps, globalData)
|
|
112
|
+
);
|
|
113
|
+
if (mergeParseProps.isPosAddress) {
|
|
114
|
+
return PosAddress(mergeParseProps);
|
|
115
|
+
}
|
|
116
|
+
if (!mergeParseProps.value && mergeParseProps.contractCreated) {
|
|
117
|
+
return ContractCreatedAddress({
|
|
118
|
+
...mergeParseProps,
|
|
119
|
+
outputType: "base32"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (mergeParseProps.isEspaceAddress) {
|
|
123
|
+
return CoreHexAddress(mergeParseProps);
|
|
124
|
+
}
|
|
125
|
+
if (!isCoreAddress(mergeParseProps.value)) {
|
|
126
|
+
return InvalidAddress(mergeParseProps);
|
|
127
|
+
}
|
|
128
|
+
if (isCoreContractAddress(mergeParseProps.cfxAddress)) {
|
|
129
|
+
return ContractAddress(mergeParseProps);
|
|
130
|
+
}
|
|
131
|
+
if (mergeParseProps.isMe) {
|
|
132
|
+
return MyAddress(mergeParseProps);
|
|
133
|
+
}
|
|
134
|
+
return RenderAddress(mergeParseProps);
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
export {
|
|
139
|
+
CoreAddressContainer
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=chunk-2P6RNTXI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/CoreAddressContainer.tsx"],"sourcesContent":["import { memo } from 'react';\nimport { WithTranslation, withTranslation } from 'react-i18next';\nimport _ from 'lodash';\nimport {\n formatAddress,\n isCoreAddress,\n isCoreContractAddress,\n isZeroAddress,\n convertCheckSum,\n} from '../../utils/address';\nimport { useGlobalData, getTranslations } from '../../store';\nimport { LOCALSTORAGE_KEYS_MAP } from '../../utils/constants';\nimport { getLabelInfo } from './label';\nimport { useENS } from '../../utils/hooks/useENS';\n\nimport { RenderAddress } from './addressView';\nimport {\n ContractCreatedAddress,\n CoreHexAddress,\n InvalidAddress,\n ContractAddress,\n MyAddress,\n PosAddress,\n} from './addressSwitcher';\nimport { GlobalDataType } from 'src/store/types';\nimport { CoreAddressContainerProps } from './types';\n\nconst parseProps = (\n props: CoreAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const {\n alias,\n ensInfo,\n t,\n showAddressLabel,\n showNametag,\n nametagInfo,\n showENSLabel,\n } = props;\n const value: string = props.value || '';\n const cfxAddress = formatAddress(value, 'base32');\n\n let ENSMap = ensInfo || {};\n\n const translations = getTranslations();\n\n let aliasLabel = alias;\n if (!alias && isZeroAddress(cfxAddress)) {\n aliasLabel = t(translations.general.zeroAddress);\n }\n\n let prefixIcon: React.ReactNode = null;\n // official name tag\n let officalNametag: React.ReactNode = null;\n // private name tag\n let addressLabel: React.ReactNode = null;\n // ens name tag\n let ENSLabel: React.ReactNode = null;\n // global ens name tag\n const gENSLabel = cfxAddress && ENSMap[cfxAddress]?.name;\n\n if (cfxAddress && showAddressLabel) {\n // global private name tag\n const addressLabels = globalData?.[LOCALSTORAGE_KEYS_MAP.addressLabel];\n const gAddressLabel = addressLabels?.[cfxAddress];\n\n if (gAddressLabel) {\n const { label } = getLabelInfo(gAddressLabel, 'tag');\n addressLabel = label;\n }\n }\n\n if (cfxAddress && showNametag) {\n const nametags = nametagInfo?.[cfxAddress];\n\n if (nametags) {\n const nametag = nametags?.nametag ?? '';\n const { label } = getLabelInfo(nametag, 'nametag');\n officalNametag = label;\n }\n }\n\n if (showENSLabel && gENSLabel) {\n const { label, icon } = getLabelInfo(gENSLabel, 'ens');\n ENSLabel = label;\n prefixIcon = icon;\n }\n\n return {\n alias: aliasLabel,\n prefix: prefixIcon,\n nametag: officalNametag,\n addressLabel,\n ENSLabel,\n cfxAddress,\n };\n};\n\nexport const CoreAddressContainer = withTranslation()(\n memo((props: CoreAddressContainerProps & WithTranslation) => {\n const { globalData } = useGlobalData();\n\n // If the interface returns Ens content, there is no need to obtain it separately, or disable the display of Ens content (in most cases on the list page).\n const unnecessaryEns = props.ensInfo || props.showENSLabel === false;\n const { ens } = useENS(unnecessaryEns ? null : props.value);\n\n // If a txn receipt has no 'to' address or 'contractCreated', show -- for temp\n if (!props.value && !props.contractCreated) {\n return <>--</>;\n }\n\n const defaultProps = {\n isFull: false,\n isFullNameTag: false,\n link: true,\n isMe: false,\n showIcon: true,\n verify: false,\n showAddressLabel: true,\n showENSLabel: true,\n showNametag: true,\n ensInfo: ens,\n };\n\n const mergeDefaultProps = _.assign({}, defaultProps, props);\n\n const mergeParseProps = _.merge(\n {},\n mergeDefaultProps,\n parseProps(mergeDefaultProps, globalData),\n );\n\n if (mergeParseProps.isPosAddress) {\n return PosAddress(mergeParseProps);\n }\n\n if (!mergeParseProps.value && mergeParseProps.contractCreated) {\n return ContractCreatedAddress({\n ...mergeParseProps,\n outputType: 'base32',\n });\n }\n\n if (mergeParseProps.isEspaceAddress) {\n return CoreHexAddress(mergeParseProps);\n }\n\n if (!isCoreAddress(mergeParseProps.value)) {\n return InvalidAddress(mergeParseProps);\n }\n\n if (isCoreContractAddress(mergeParseProps.cfxAddress)) {\n return ContractAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isMe) {\n return MyAddress(mergeParseProps);\n }\n\n return RenderAddress(mergeParseProps);\n }),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,SAA0B,uBAAuB;AACjD,OAAO,OAAO;AA2GD;AAlFb,IAAM,aAAa,CACjB,OACA,eACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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,CAAC,MAAM,SAAS,CAAC,MAAM,iBAAiB;AAC1C,aAAO,gCAAE,gBAAE;AAAA,IACb;AAEA,UAAM,eAAe;AAAA,MACnB,QAAQ;AAAA,MACR,eAAe;AAAA,MACf,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,kBAAkB;AAAA,MAClB,cAAc;AAAA,MACd,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAEA,UAAM,oBAAoB,EAAE,OAAO,CAAC,GAAG,cAAc,KAAK;AAE1D,UAAM,kBAAkB,EAAE;AAAA,MACxB,CAAC;AAAA,MACD;AAAA,MACA,WAAW,mBAAmB,UAAU;AAAA,IAC1C;AAEA,QAAI,gBAAgB,cAAc;AAChC,aAAO,WAAW,eAAe;AAAA,IACnC;AAEA,QAAI,CAAC,gBAAgB,SAAS,gBAAgB,iBAAiB;AAC7D,aAAO,uBAAuB;AAAA,QAC5B,GAAG;AAAA,QACH,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAEA,QAAI,gBAAgB,iBAAiB;AACnC,aAAO,eAAe,eAAe;AAAA,IACvC;AAEA,QAAI,CAAC,cAAc,gBAAgB,KAAK,GAAG;AACzC,aAAO,eAAe,eAAe;AAAA,IACvC;AAEA,QAAI,sBAAsB,gBAAgB,UAAU,GAAG;AACrD,aAAO,gBAAgB,eAAe;AAAA,IACxC;AAEA,QAAI,gBAAgB,MAAM;AACxB,aAAO,UAAU,eAAe;AAAA,IAClC;AAEA,WAAO,cAAc,eAAe;AAAA,EACtC,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertCheckSum
|
|
3
|
+
} from "./chunk-OJQKHBLY.js";
|
|
4
|
+
import {
|
|
5
|
+
Text
|
|
6
|
+
} from "./chunk-GL4KHAZB.js";
|
|
7
|
+
import {
|
|
8
|
+
getTranslations
|
|
9
|
+
} from "./chunk-DQGLZCIG.js";
|
|
10
|
+
|
|
11
|
+
// src/components/AddressContainer/addressView.tsx
|
|
12
|
+
import { Translation } from "react-i18next";
|
|
13
|
+
import { shortenAddress } from "@cfx-kit/dapp-utils/dist/address";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var defaultPCMaxWidth = 138;
|
|
16
|
+
var renderTooltipContent = (tooltipContent) => {
|
|
17
|
+
return Object.entries(tooltipContent).map(([key, { label, value, hideLabel }]) => {
|
|
18
|
+
if (value) {
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
20
|
+
!hideLabel && /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Translation, { children: (t) => t(label) }) }),
|
|
21
|
+
value
|
|
22
|
+
] }, key);
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}).filter(Boolean);
|
|
26
|
+
};
|
|
27
|
+
var convertLink = ({
|
|
28
|
+
link,
|
|
29
|
+
type,
|
|
30
|
+
hrefAddress,
|
|
31
|
+
cfxAddress
|
|
32
|
+
}) => {
|
|
33
|
+
if (typeof link === "string") {
|
|
34
|
+
return link;
|
|
35
|
+
}
|
|
36
|
+
const address = hrefAddress || cfxAddress;
|
|
37
|
+
if (address && typeof address === "string") {
|
|
38
|
+
const pathname = window.location.pathname.toLowerCase();
|
|
39
|
+
const addressLower = address.toLowerCase();
|
|
40
|
+
if (pathname.includes("/address/" + addressLower)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (type === "pow") {
|
|
44
|
+
return `/address/${address}`;
|
|
45
|
+
}
|
|
46
|
+
if (type === "pos") {
|
|
47
|
+
return `/pos/accounts/${address}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
};
|
|
52
|
+
var RenderAddress = ({
|
|
53
|
+
cfxAddress,
|
|
54
|
+
alias,
|
|
55
|
+
hoverValue,
|
|
56
|
+
hrefAddress,
|
|
57
|
+
content,
|
|
58
|
+
link = "",
|
|
59
|
+
isFull = false,
|
|
60
|
+
isFullNameTag = false,
|
|
61
|
+
style = {},
|
|
62
|
+
maxWidth,
|
|
63
|
+
prefix = null,
|
|
64
|
+
suffix = null,
|
|
65
|
+
type = "pow",
|
|
66
|
+
addressLabel = "",
|
|
67
|
+
ENSLabel = "",
|
|
68
|
+
nametag = "",
|
|
69
|
+
hideAliasPrefixInHover = false
|
|
70
|
+
}) => {
|
|
71
|
+
const translations = getTranslations();
|
|
72
|
+
const name = content || ENSLabel || nametag || addressLabel || alias;
|
|
73
|
+
const defaultStyle = {
|
|
74
|
+
maxWidth: `${name && isFullNameTag || isFull ? "auto" : (maxWidth || defaultPCMaxWidth) + "px"}`
|
|
75
|
+
};
|
|
76
|
+
const href = convertLink({ link, type, hrefAddress, cfxAddress });
|
|
77
|
+
const Wrapper = href ? "a" : "div";
|
|
78
|
+
const tooltipContent = {
|
|
79
|
+
ENSLabel: {
|
|
80
|
+
label: translations?.ens?.tip,
|
|
81
|
+
value: ENSLabel
|
|
82
|
+
},
|
|
83
|
+
nametag: {
|
|
84
|
+
label: translations?.nametag?.tip,
|
|
85
|
+
value: nametag
|
|
86
|
+
},
|
|
87
|
+
addressLabel: {
|
|
88
|
+
label: translations?.profile.address.myNameTag,
|
|
89
|
+
value: addressLabel
|
|
90
|
+
},
|
|
91
|
+
alias: {
|
|
92
|
+
label: translations?.profile.address.publicNameTag,
|
|
93
|
+
value: alias,
|
|
94
|
+
hideLabel: hideAliasPrefixInHover
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const checksumAddress = convertCheckSum(cfxAddress);
|
|
98
|
+
const cfxAddressLabel = typeof cfxAddress === "string" && !isFull ? shortenAddress(checksumAddress) : checksumAddress;
|
|
99
|
+
return /* @__PURE__ */ jsxs("div", { className: "inline-flex", children: [
|
|
100
|
+
prefix,
|
|
101
|
+
/* @__PURE__ */ jsx(
|
|
102
|
+
Text,
|
|
103
|
+
{
|
|
104
|
+
tag: "span",
|
|
105
|
+
hoverValue: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
106
|
+
renderTooltipContent(tooltipContent),
|
|
107
|
+
/* @__PURE__ */ jsx("div", { children: hoverValue || checksumAddress })
|
|
108
|
+
] }),
|
|
109
|
+
children: /* @__PURE__ */ jsx(
|
|
110
|
+
Wrapper,
|
|
111
|
+
{
|
|
112
|
+
className: "block relative align-bottom cursor-default truncate",
|
|
113
|
+
style: { ...defaultStyle, ...style },
|
|
114
|
+
...href ? { href: String(href) } : {},
|
|
115
|
+
children: name || cfxAddressLabel
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
suffix
|
|
121
|
+
] });
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
RenderAddress
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=chunk-5PYSDWGQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/addressView.tsx"],"sourcesContent":["import { Translation } from 'react-i18next';\nimport { Text } from '../Text';\nimport { convertCheckSum } from '../../utils/address';\nimport { getTranslations } from '../../store';\nimport { TooltipContent, RenderAddressProps } from './types';\nimport { shortenAddress } from '@cfx-kit/dapp-utils/dist/address';\n\nconst defaultPCMaxWidth = 138;\n\n// common\nconst renderTooltipContent = (tooltipContent: TooltipContent) => {\n return Object.entries(tooltipContent)\n .map(([key, { label, value, hideLabel }]) => {\n if (value) {\n return (\n <div key={key}>\n {!hideLabel && (\n <span>\n <Translation>{t => t(label)}</Translation>\n </span>\n )}\n {value}\n </div>\n );\n }\n return null;\n })\n .filter(Boolean);\n};\n\n// common\nconst convertLink = ({\n link,\n type,\n hrefAddress,\n cfxAddress,\n}: RenderAddressProps) => {\n if (typeof link === 'string') {\n return link;\n }\n\n const address = hrefAddress || cfxAddress;\n\n if (address && typeof address === 'string') {\n const pathname = window.location.pathname.toLowerCase();\n const addressLower = address.toLowerCase();\n if (pathname.includes('/address/' + addressLower)) {\n return false;\n }\n\n if (type === 'pow') {\n return `/address/${address}`;\n }\n\n if (type === 'pos') {\n return `/pos/accounts/${address}`;\n }\n }\n\n return false;\n};\n\n// common\nexport const RenderAddress = ({\n cfxAddress,\n alias,\n hoverValue,\n hrefAddress,\n content,\n link = '',\n isFull = false,\n isFullNameTag = false,\n style = {},\n maxWidth,\n prefix = null,\n suffix = null,\n type = 'pow',\n addressLabel = '',\n ENSLabel = '',\n nametag = '',\n hideAliasPrefixInHover = false,\n}: RenderAddressProps) => {\n const translations = getTranslations();\n\n const name = content || ENSLabel || nametag || addressLabel || alias;\n\n const defaultStyle = {\n maxWidth: `${(name && isFullNameTag) || isFull ? 'auto' : (maxWidth || defaultPCMaxWidth) + 'px'}`,\n };\n\n const href = convertLink({ link, type, hrefAddress, cfxAddress });\n\n const Wrapper = href ? 'a' : 'div';\n\n const tooltipContent: TooltipContent = {\n ENSLabel: {\n label: (translations as any)?.ens?.tip,\n value: ENSLabel,\n },\n nametag: {\n label: translations?.nametag?.tip,\n value: nametag,\n },\n addressLabel: {\n label: translations?.profile.address.myNameTag,\n value: addressLabel,\n },\n alias: {\n label: translations?.profile.address.publicNameTag,\n value: alias,\n hideLabel: hideAliasPrefixInHover,\n },\n };\n\n const checksumAddress = convertCheckSum(cfxAddress);\n\n const cfxAddressLabel =\n typeof cfxAddress === 'string' && !isFull\n ? shortenAddress(checksumAddress!)\n : checksumAddress;\n\n return (\n <div className=\"inline-flex\">\n {prefix}\n <Text\n tag=\"span\"\n hoverValue={\n <>\n {renderTooltipContent(tooltipContent)}\n <div>{hoverValue || checksumAddress}</div>\n </>\n }\n >\n <Wrapper\n className=\"block relative align-bottom cursor-default truncate\"\n style={{ ...defaultStyle, ...style }}\n {...(href ? { href: String(href) } : {})}\n >\n {name || cfxAddressLabel}\n </Wrapper>\n </Text>\n {suffix}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,mBAAmB;AAK5B,SAAS,sBAAsB;AA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+
MyAddress
|
|
6
|
+
} from "./chunk-JMM6NFUN.js";
|
|
7
|
+
import {
|
|
8
|
+
RenderAddress
|
|
9
|
+
} from "./chunk-GJCBWNU5.js";
|
|
10
|
+
import {
|
|
11
|
+
convertCheckSum,
|
|
12
|
+
formatAddress,
|
|
13
|
+
isEvmAddress,
|
|
14
|
+
isZeroAddress
|
|
15
|
+
} from "./chunk-OJQKHBLY.js";
|
|
16
|
+
import {
|
|
17
|
+
getLabelInfo
|
|
18
|
+
} from "./chunk-PKSF74ZF.js";
|
|
19
|
+
import {
|
|
20
|
+
getTranslations,
|
|
21
|
+
useGlobalData
|
|
22
|
+
} from "./chunk-DQGLZCIG.js";
|
|
23
|
+
|
|
24
|
+
// src/components/AddressContainer/EVMAddressContainer.tsx
|
|
25
|
+
import { memo } from "react";
|
|
26
|
+
import { withTranslation } from "react-i18next";
|
|
27
|
+
import _ from "lodash";
|
|
28
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
29
|
+
var parseProps = (props, globalData) => {
|
|
30
|
+
const { alias, t, showAddressLabel, showNametag, nametagInfo } = props;
|
|
31
|
+
const value = props.value || "";
|
|
32
|
+
const cfxAddress = formatAddress(value, "hex");
|
|
33
|
+
const translations = getTranslations();
|
|
34
|
+
let aliasLabel = alias;
|
|
35
|
+
if (!alias && isZeroAddress(cfxAddress)) {
|
|
36
|
+
aliasLabel = t(translations.general.zeroAddress);
|
|
37
|
+
}
|
|
38
|
+
let officalNametag = null;
|
|
39
|
+
let addressLabel = null;
|
|
40
|
+
if (cfxAddress && showAddressLabel) {
|
|
41
|
+
const addressLabels = globalData?.["CONFLUX_SCAN_ADDRESS_LABELS" /* addressLabel */];
|
|
42
|
+
const gAddressLabel = addressLabels?.[convertCheckSum(cfxAddress)] || addressLabels?.[cfxAddress.toLowerCase()];
|
|
43
|
+
if (gAddressLabel) {
|
|
44
|
+
const { label } = getLabelInfo(gAddressLabel, "tag");
|
|
45
|
+
addressLabel = label;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (cfxAddress && showNametag) {
|
|
49
|
+
const nametags = nametagInfo?.[convertCheckSum(cfxAddress)] || nametagInfo?.[cfxAddress.toLowerCase()];
|
|
50
|
+
if (nametags) {
|
|
51
|
+
const nametag = nametags?.nametag ?? "";
|
|
52
|
+
const { label } = getLabelInfo(nametag, "nametag");
|
|
53
|
+
officalNametag = label;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
alias: aliasLabel,
|
|
58
|
+
nametag: officalNametag,
|
|
59
|
+
addressLabel,
|
|
60
|
+
cfxAddress
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var EVMAddressContainer = withTranslation()(
|
|
64
|
+
memo((props) => {
|
|
65
|
+
const { globalData } = useGlobalData();
|
|
66
|
+
if (!props.value && !props.contractCreated) {
|
|
67
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "--" });
|
|
68
|
+
}
|
|
69
|
+
const defaultProps = {
|
|
70
|
+
isFull: false,
|
|
71
|
+
isFullNameTag: false,
|
|
72
|
+
link: true,
|
|
73
|
+
isMe: false,
|
|
74
|
+
showIcon: true,
|
|
75
|
+
verify: false,
|
|
76
|
+
showAddressLabel: true,
|
|
77
|
+
showENSLabel: true,
|
|
78
|
+
showNametag: true
|
|
79
|
+
};
|
|
80
|
+
const mergeDefaultProps = _.assign({}, defaultProps, props);
|
|
81
|
+
const mergeParseProps = _.merge(
|
|
82
|
+
{},
|
|
83
|
+
mergeDefaultProps,
|
|
84
|
+
parseProps(mergeDefaultProps, globalData)
|
|
85
|
+
);
|
|
86
|
+
if (!mergeParseProps.value && mergeParseProps.contractCreated) {
|
|
87
|
+
return ContractCreatedAddress({
|
|
88
|
+
...mergeParseProps,
|
|
89
|
+
outputType: "hex"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (!isEvmAddress(mergeParseProps.value)) {
|
|
93
|
+
return InvalidAddress(mergeParseProps);
|
|
94
|
+
}
|
|
95
|
+
if (mergeParseProps.isContract) {
|
|
96
|
+
return ContractAddress(mergeParseProps);
|
|
97
|
+
}
|
|
98
|
+
if (mergeParseProps.isMe) {
|
|
99
|
+
return MyAddress(mergeParseProps);
|
|
100
|
+
}
|
|
101
|
+
return RenderAddress(mergeParseProps);
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
EVMAddressContainer
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=chunk-5Z5K44KU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/EVMAddressContainer.tsx"],"sourcesContent":["import { memo } from 'react';\nimport { WithTranslation, withTranslation } from 'react-i18next';\nimport _ from 'lodash';\nimport {\n formatAddress,\n isEvmAddress,\n isZeroAddress,\n convertCheckSum,\n} from '../../utils/address';\nimport { useGlobalData, getTranslations } from '../../store';\nimport { LOCALSTORAGE_KEYS_MAP } from '../../utils/constants';\nimport { getLabelInfo } from './label';\n\nimport { RenderAddress } from './addressView';\nimport {\n ContractCreatedAddress,\n InvalidAddress,\n ContractAddress,\n MyAddress,\n} from './addressSwitcher';\nimport { GlobalDataType } from 'src/store/types';\nimport { EVMAddressContainerProps } from './types';\n\nconst parseProps = (\n props: EVMAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const { alias, t, showAddressLabel, showNametag, nametagInfo } = props;\n const value: string = props.value || '';\n const cfxAddress = formatAddress(value, 'hex');\n\n const translations = getTranslations();\n\n let aliasLabel = alias;\n if (!alias && isZeroAddress(cfxAddress)) {\n aliasLabel = t(translations.general.zeroAddress);\n }\n\n // official name tag\n let officalNametag: React.ReactNode = null;\n // private name tag\n let addressLabel: React.ReactNode = null;\n\n if (cfxAddress && showAddressLabel) {\n // global private name tag\n const addressLabels = globalData?.[LOCALSTORAGE_KEYS_MAP.addressLabel];\n const gAddressLabel =\n addressLabels?.[convertCheckSum(cfxAddress)] ||\n addressLabels?.[cfxAddress.toLowerCase()];\n\n if (gAddressLabel) {\n const { label } = getLabelInfo(gAddressLabel, 'tag');\n addressLabel = label;\n }\n }\n\n if (cfxAddress && showNametag) {\n const nametags =\n nametagInfo?.[convertCheckSum(cfxAddress)] ||\n nametagInfo?.[cfxAddress.toLowerCase()];\n\n if (nametags) {\n const nametag = nametags?.nametag ?? '';\n const { label } = getLabelInfo(nametag, 'nametag');\n officalNametag = label;\n }\n }\n\n return {\n alias: aliasLabel,\n nametag: officalNametag,\n addressLabel,\n cfxAddress,\n };\n};\n\nexport const EVMAddressContainer = withTranslation()(\n memo((props: EVMAddressContainerProps & WithTranslation) => {\n const { globalData } = useGlobalData();\n\n // If a txn receipt has no 'to' address or 'contractCreated', show -- for temp\n if (!props.value && !props.contractCreated) {\n return <>--</>;\n }\n\n const defaultProps = {\n isFull: false,\n isFullNameTag: false,\n link: true,\n isMe: false,\n showIcon: true,\n verify: false,\n showAddressLabel: true,\n showENSLabel: true,\n showNametag: true,\n };\n\n const mergeDefaultProps = _.assign({}, defaultProps, props);\n\n const mergeParseProps = _.merge(\n {},\n mergeDefaultProps,\n parseProps(mergeDefaultProps, globalData),\n );\n\n if (!mergeParseProps.value && mergeParseProps.contractCreated) {\n return ContractCreatedAddress({\n ...mergeParseProps,\n outputType: 'hex',\n });\n }\n\n if (!isEvmAddress(mergeParseProps.value)) {\n return InvalidAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isContract) {\n return ContractAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isMe) {\n return MyAddress(mergeParseProps);\n }\n\n return RenderAddress(mergeParseProps);\n }),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,SAA0B,uBAAuB;AACjD,OAAO,OAAO;AAgFD;AA3Db,IAAM,aAAa,CACjB,OACA,eACG;AACH,QAAM,EAAE,OAAO,GAAG,kBAAkB,aAAa,YAAY,IAAI;AACjE,QAAM,QAAgB,MAAM,SAAS;AACrC,QAAM,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,CAAC;AAAA,MACD;AAAA,MACA,WAAW,mBAAmB,UAAU;AAAA,IAC1C;AAEA,QAAI,CAAC,gBAAgB,SAAS,gBAAgB,iBAAiB;AAC7D,aAAO,uBAAuB;AAAA,QAC5B,GAAG;AAAA,QACH,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAEA,QAAI,CAAC,aAAa,gBAAgB,KAAK,GAAG;AACxC,aAAO,eAAe,eAAe;AAAA,IACvC;AAEA,QAAI,gBAAgB,YAAY;AAC9B,aAAO,gBAAgB,eAAe;AAAA,IACxC;AAEA,QAAI,gBAAgB,MAAM;AACxB,aAAO,UAAU,eAAe;AAAA,IAClC;AAEA,WAAO,cAAc,eAAe;AAAA,EACtC,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContractAddress,
|
|
3
|
+
ContractCreatedAddress,
|
|
4
|
+
InvalidAddress,
|
|
5
|
+
MyAddress
|
|
6
|
+
} from "./chunk-QSLCIDOR.js";
|
|
7
|
+
import {
|
|
8
|
+
RenderAddress
|
|
9
|
+
} from "./chunk-5PYSDWGQ.js";
|
|
10
|
+
import {
|
|
11
|
+
convertCheckSum,
|
|
12
|
+
formatAddress,
|
|
13
|
+
isEvmAddress,
|
|
14
|
+
isZeroAddress
|
|
15
|
+
} from "./chunk-OJQKHBLY.js";
|
|
16
|
+
import {
|
|
17
|
+
getLabelInfo
|
|
18
|
+
} from "./chunk-EF2N45TZ.js";
|
|
19
|
+
import {
|
|
20
|
+
getTranslations,
|
|
21
|
+
useGlobalData
|
|
22
|
+
} from "./chunk-DQGLZCIG.js";
|
|
23
|
+
|
|
24
|
+
// src/components/AddressContainer/EVMAddressContainer.tsx
|
|
25
|
+
import { memo } from "react";
|
|
26
|
+
import { withTranslation } from "react-i18next";
|
|
27
|
+
import _ from "lodash";
|
|
28
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
29
|
+
var parseProps = (props, globalData) => {
|
|
30
|
+
const { alias, t, showAddressLabel, showNametag, nametagInfo } = props;
|
|
31
|
+
const value = props.value || "";
|
|
32
|
+
const cfxAddress = formatAddress(value, "hex");
|
|
33
|
+
const translations = getTranslations();
|
|
34
|
+
let aliasLabel = alias;
|
|
35
|
+
if (!alias && isZeroAddress(cfxAddress)) {
|
|
36
|
+
aliasLabel = t(translations.general.zeroAddress);
|
|
37
|
+
}
|
|
38
|
+
let officalNametag = null;
|
|
39
|
+
let addressLabel = null;
|
|
40
|
+
if (cfxAddress && showAddressLabel) {
|
|
41
|
+
const addressLabels = globalData?.["CONFLUX_SCAN_ADDRESS_LABELS" /* addressLabel */];
|
|
42
|
+
const gAddressLabel = addressLabels?.[convertCheckSum(cfxAddress)] || addressLabels?.[cfxAddress.toLowerCase()];
|
|
43
|
+
if (gAddressLabel) {
|
|
44
|
+
const { label } = getLabelInfo(gAddressLabel, "tag");
|
|
45
|
+
addressLabel = label;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (cfxAddress && showNametag) {
|
|
49
|
+
const nametags = nametagInfo?.[convertCheckSum(cfxAddress)] || nametagInfo?.[cfxAddress.toLowerCase()];
|
|
50
|
+
if (nametags) {
|
|
51
|
+
const nametag = nametags?.nametag ?? "";
|
|
52
|
+
const { label } = getLabelInfo(nametag, "nametag");
|
|
53
|
+
officalNametag = label;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
alias: aliasLabel,
|
|
58
|
+
nametag: officalNametag,
|
|
59
|
+
addressLabel,
|
|
60
|
+
cfxAddress
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var EVMAddressContainer = withTranslation()(
|
|
64
|
+
memo((props) => {
|
|
65
|
+
const { globalData } = useGlobalData();
|
|
66
|
+
if (!props.value && !props.contractCreated) {
|
|
67
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "--" });
|
|
68
|
+
}
|
|
69
|
+
const defaultProps = {
|
|
70
|
+
isFull: false,
|
|
71
|
+
isFullNameTag: false,
|
|
72
|
+
link: true,
|
|
73
|
+
isMe: false,
|
|
74
|
+
showIcon: true,
|
|
75
|
+
verify: false,
|
|
76
|
+
showAddressLabel: true,
|
|
77
|
+
showENSLabel: true,
|
|
78
|
+
showNametag: true
|
|
79
|
+
};
|
|
80
|
+
const mergeDefaultProps = _.assign({}, defaultProps, props);
|
|
81
|
+
const mergeParseProps = _.merge(
|
|
82
|
+
{},
|
|
83
|
+
mergeDefaultProps,
|
|
84
|
+
parseProps(mergeDefaultProps, globalData)
|
|
85
|
+
);
|
|
86
|
+
if (!mergeParseProps.value && mergeParseProps.contractCreated) {
|
|
87
|
+
return ContractCreatedAddress({
|
|
88
|
+
...mergeParseProps,
|
|
89
|
+
outputType: "hex"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (!isEvmAddress(mergeParseProps.value)) {
|
|
93
|
+
return InvalidAddress(mergeParseProps);
|
|
94
|
+
}
|
|
95
|
+
if (mergeParseProps.isContract) {
|
|
96
|
+
return ContractAddress(mergeParseProps);
|
|
97
|
+
}
|
|
98
|
+
if (mergeParseProps.isMe) {
|
|
99
|
+
return MyAddress(mergeParseProps);
|
|
100
|
+
}
|
|
101
|
+
return RenderAddress(mergeParseProps);
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
EVMAddressContainer
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=chunk-CL6X23Y3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/EVMAddressContainer.tsx"],"sourcesContent":["import { memo } from 'react';\nimport { WithTranslation, withTranslation } from 'react-i18next';\nimport _ from 'lodash';\nimport {\n formatAddress,\n isEvmAddress,\n isZeroAddress,\n convertCheckSum,\n} from '../../utils/address';\nimport { useGlobalData, getTranslations } from '../../store';\nimport { LOCALSTORAGE_KEYS_MAP } from '../../utils/constants';\nimport { getLabelInfo } from './label';\n\nimport { RenderAddress } from './addressView';\nimport {\n ContractCreatedAddress,\n InvalidAddress,\n ContractAddress,\n MyAddress,\n} from './addressSwitcher';\nimport { GlobalDataType } from 'src/store/types';\nimport { EVMAddressContainerProps } from './types';\n\nconst parseProps = (\n props: EVMAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const { alias, t, showAddressLabel, showNametag, nametagInfo } = props;\n const value: string = props.value || '';\n const cfxAddress = formatAddress(value, 'hex');\n\n const translations = getTranslations();\n\n let aliasLabel = alias;\n if (!alias && isZeroAddress(cfxAddress)) {\n aliasLabel = t(translations.general.zeroAddress);\n }\n\n // official name tag\n let officalNametag: React.ReactNode = null;\n // private name tag\n let addressLabel: React.ReactNode = null;\n\n if (cfxAddress && showAddressLabel) {\n // global private name tag\n const addressLabels = globalData?.[LOCALSTORAGE_KEYS_MAP.addressLabel];\n const gAddressLabel =\n addressLabels?.[convertCheckSum(cfxAddress)] ||\n addressLabels?.[cfxAddress.toLowerCase()];\n\n if (gAddressLabel) {\n const { label } = getLabelInfo(gAddressLabel, 'tag');\n addressLabel = label;\n }\n }\n\n if (cfxAddress && showNametag) {\n const nametags =\n nametagInfo?.[convertCheckSum(cfxAddress)] ||\n nametagInfo?.[cfxAddress.toLowerCase()];\n\n if (nametags) {\n const nametag = nametags?.nametag ?? '';\n const { label } = getLabelInfo(nametag, 'nametag');\n officalNametag = label;\n }\n }\n\n return {\n alias: aliasLabel,\n nametag: officalNametag,\n addressLabel,\n cfxAddress,\n };\n};\n\nexport const EVMAddressContainer = withTranslation()(\n memo((props: EVMAddressContainerProps & WithTranslation) => {\n const { globalData } = useGlobalData();\n\n // If a txn receipt has no 'to' address or 'contractCreated', show -- for temp\n if (!props.value && !props.contractCreated) {\n return <>--</>;\n }\n\n const defaultProps = {\n isFull: false,\n isFullNameTag: false,\n link: true,\n isMe: false,\n showIcon: true,\n verify: false,\n showAddressLabel: true,\n showENSLabel: true,\n showNametag: true,\n };\n\n const mergeDefaultProps = _.assign({}, defaultProps, props);\n\n const mergeParseProps = _.merge(\n {},\n mergeDefaultProps,\n parseProps(mergeDefaultProps, globalData),\n );\n\n if (!mergeParseProps.value && mergeParseProps.contractCreated) {\n return ContractCreatedAddress({\n ...mergeParseProps,\n outputType: 'hex',\n });\n }\n\n if (!isEvmAddress(mergeParseProps.value)) {\n return InvalidAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isContract) {\n return ContractAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isMe) {\n return MyAddress(mergeParseProps);\n }\n\n return RenderAddress(mergeParseProps);\n }),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,SAA0B,uBAAuB;AACjD,OAAO,OAAO;AAgFD;AA3Db,IAAM,aAAa,CACjB,OACA,eACG;AACH,QAAM,EAAE,OAAO,GAAG,kBAAkB,aAAa,YAAY,IAAI;AACjE,QAAM,QAAgB,MAAM,SAAS;AACrC,QAAM,aAAa,cAAc,OAAO,KAAK;AAE7C,QAAM,eAAe,gBAAgB;AAErC,MAAI,aAAa;AACjB,MAAI,CAAC,SAAS,cAAc,UAAU,GAAG;AACvC,iBAAa,EAAE,aAAa,QAAQ,WAAW;AAAA,EACjD;AAGA,MAAI,iBAAkC;AAEtC,MAAI,eAAgC;AAEpC,MAAI,cAAc,kBAAkB;AAElC,UAAM,gBAAgB,6DAA+C;AACrE,UAAM,gBACJ,gBAAgB,gBAAgB,UAAU,CAAC,KAC3C,gBAAgB,WAAW,YAAY,CAAC;AAE1C,QAAI,eAAe;AACjB,YAAM,EAAE,MAAM,IAAI,aAAa,eAAe,KAAK;AACnD,qBAAe;AAAA,IACjB;AAAA,EACF;AAEA,MAAI,cAAc,aAAa;AAC7B,UAAM,WACJ,cAAc,gBAAgB,UAAU,CAAC,KACzC,cAAc,WAAW,YAAY,CAAC;AAExC,QAAI,UAAU;AACZ,YAAM,UAAU,UAAU,WAAW;AACrC,YAAM,EAAE,MAAM,IAAI,aAAa,SAAS,SAAS;AACjD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