@cfxjs/sirius-next-common 0.2.18 → 0.2.20
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-NFPBS22O.js → chunk-4LSM4TMM.js} +9 -10
- package/dist/chunk-4LSM4TMM.js.map +1 -0
- package/dist/{chunk-MUW5KBWU.js → chunk-HF7RD7UD.js} +7 -3
- package/dist/chunk-HF7RD7UD.js.map +1 -0
- package/dist/{chunk-GG7ROFBQ.js → chunk-J6ZC77OY.js} +6 -5
- package/dist/chunk-J6ZC77OY.js.map +1 -0
- package/dist/{chunk-K4SBN5ZT.js → chunk-LCV3NUFR.js} +2 -2
- package/dist/{chunk-YKHDBNJD.js → chunk-XUKHHB5L.js} +12 -5
- package/dist/chunk-XUKHHB5L.js.map +1 -0
- package/dist/components/AddressContainer/CoreAddressContainer.js +3 -3
- package/dist/components/AddressContainer/EVMAddressContainer.js +3 -3
- package/dist/components/AddressContainer/addressSwitcher.js +2 -2
- package/dist/components/AddressContainer/addressView.d.ts +1 -1
- package/dist/components/AddressContainer/addressView.js +1 -1
- package/dist/components/AddressContainer/types.d.ts +0 -1
- package/dist/components/TransactionAction/coreTransactionAction.js +3 -3
- package/dist/components/TransactionAction/evmTransactionAction.js +3 -3
- package/dist/utils/hooks/useAddressNameMap.d.ts +7 -2
- package/dist/utils/hooks/useAddressNameMap.js +3 -1
- package/dist/utils/hooks/useEnhanceDataWithNameMap.d.ts +1 -4
- package/dist/utils/hooks/useEnhanceDataWithNameMap.js +2 -5
- package/dist/utils/hooks/useEnhanceDataWithNameMap.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-GG7ROFBQ.js.map +0 -1
- package/dist/chunk-MUW5KBWU.js.map +0 -1
- package/dist/chunk-NFPBS22O.js.map +0 -1
- package/dist/chunk-YKHDBNJD.js.map +0 -1
- /package/dist/{chunk-K4SBN5ZT.js.map → chunk-LCV3NUFR.js.map} +0 -0
|
@@ -56,7 +56,6 @@ var RenderAddress = ({
|
|
|
56
56
|
cfxAddress,
|
|
57
57
|
tokenName,
|
|
58
58
|
contractName,
|
|
59
|
-
showVerificationName = false,
|
|
60
59
|
verificationName,
|
|
61
60
|
hoverValue,
|
|
62
61
|
hrefAddress,
|
|
@@ -82,7 +81,7 @@ var RenderAddress = ({
|
|
|
82
81
|
nametag || // contract token name
|
|
83
82
|
tokenName || // contract name tag
|
|
84
83
|
contractName || // contract verification name
|
|
85
|
-
|
|
84
|
+
verificationName || // CNS/ENS
|
|
86
85
|
ENSLabel || // inner name is used for some special address, like the zero address
|
|
87
86
|
innerName
|
|
88
87
|
);
|
|
@@ -93,22 +92,22 @@ var RenderAddress = ({
|
|
|
93
92
|
const href = convertLink({ link, type, hrefAddress, cfxAddress });
|
|
94
93
|
const Wrapper = href ? "a" : "div";
|
|
95
94
|
const tooltipContent = {
|
|
96
|
-
|
|
97
|
-
label: translations?.
|
|
98
|
-
value:
|
|
95
|
+
addressLabel: {
|
|
96
|
+
label: translations?.profile.address.myNameTag,
|
|
97
|
+
value: addressLabel
|
|
99
98
|
},
|
|
100
99
|
nametag: {
|
|
101
100
|
label: translations?.nametag?.tip,
|
|
102
101
|
value: nametag
|
|
103
102
|
},
|
|
104
|
-
addressLabel: {
|
|
105
|
-
label: translations?.profile.address.myNameTag,
|
|
106
|
-
value: addressLabel
|
|
107
|
-
},
|
|
108
103
|
alias: {
|
|
109
104
|
label: translations?.profile.address.publicNameTag,
|
|
110
105
|
value: tokenName || contractName || verificationName,
|
|
111
106
|
hideLabel: hideAliasPrefixInHover
|
|
107
|
+
},
|
|
108
|
+
ENSLabel: {
|
|
109
|
+
label: translations?.ens?.tip,
|
|
110
|
+
value: ENSLabel
|
|
112
111
|
}
|
|
113
112
|
};
|
|
114
113
|
const checksumAddress = convertCheckSum(cfxAddress);
|
|
@@ -144,4 +143,4 @@ var RenderAddress = ({
|
|
|
144
143
|
export {
|
|
145
144
|
RenderAddress
|
|
146
145
|
};
|
|
147
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-4LSM4TMM.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 if (link === false) {\n return false;\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 tokenName,\n contractName,\n verificationName,\n hoverValue,\n hrefAddress,\n link = '',\n isFull = false,\n isFullNameTag = false,\n style = {},\n maxWidth,\n prefix = null,\n ENSIcon = null,\n suffix = null,\n type = 'pow',\n addressLabel = '',\n ENSLabel = '',\n nametag = '',\n innerName = '',\n hideAliasPrefixInHover = false,\n}: RenderAddressProps) => {\n const translations = getTranslations();\n\n // Private name tags > Official tag/name > contract token name > contract name tag > contract verification name > CNS/ENS\n const name =\n // Private name tags\n addressLabel ||\n // Official tag/name\n nametag ||\n // contract token name\n tokenName ||\n // contract name tag\n contractName ||\n // contract verification name\n verificationName ||\n // CNS/ENS\n ENSLabel ||\n // inner name is used for some special address, like the zero address\n innerName;\n const isShowEns = !!ENSLabel && name === ENSLabel;\n\n const defaultStyle = {\n maxWidth: `${(name && isFullNameTag) || isFull ? 'unset' : (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 addressLabel: {\n label: translations?.profile.address.myNameTag,\n value: addressLabel,\n },\n nametag: {\n label: translations?.nametag?.tip,\n value: nametag,\n },\n alias: {\n label: translations?.profile.address.publicNameTag,\n value: tokenName || contractName || verificationName,\n hideLabel: hideAliasPrefixInHover,\n },\n ENSLabel: {\n label: (translations as any)?.ens?.tip,\n value: ENSLabel,\n },\n };\n\n const checksumAddress = convertCheckSum(cfxAddress);\n\n const cfxAddressLabel =\n typeof checksumAddress === 'string' && !isFull\n ? type === 'pos'\n ? shortenAddress(checksumAddress!, {\n prefixLength: 10,\n suffixLength: 0,\n })\n : shortenAddress(checksumAddress!)\n : checksumAddress;\n\n return (\n <div className=\"inline-flex\">\n {prefix || (isShowEns ? ENSIcon : null)}\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;AAUrB,SA2IA,UAxIM,KAHN;AARV,IAAM,oBAAoB;AAG1B,IAAM,uBAAuB,CAAC,mBAAmC;AAC/D,SAAO,OAAO,QAAQ,cAAc,EACjC,IAAI,CA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A;AAAA,QACX;AAAA;AAAA,IACF;AAAA,IACC;AAAA,KACH;AAEJ;","names":[]}
|
|
@@ -5,9 +5,12 @@ import {
|
|
|
5
5
|
// src/utils/hooks/useAddressNameMap.ts
|
|
6
6
|
import useSWRImmutable from "swr/immutable";
|
|
7
7
|
import { useMemo } from "react";
|
|
8
|
+
var transformNameMapKeysToLowerCase = (nameMap) => nameMap && Object.fromEntries(
|
|
9
|
+
Object.entries(nameMap).map(([k, v]) => [k.toLowerCase(), v])
|
|
10
|
+
);
|
|
8
11
|
var useAddressNameMap = (addresses, shouldFetch = true) => {
|
|
9
12
|
const key = useMemo(() => {
|
|
10
|
-
return shouldFetch && addresses.length > 0 ? `address-name-map-${
|
|
13
|
+
return shouldFetch && addresses.length > 0 ? `address-name-map-${addresses.map((i) => i.toLowerCase()).sort().join(",")}` : null;
|
|
11
14
|
}, [addresses, shouldFetch]);
|
|
12
15
|
return useSWRImmutable(
|
|
13
16
|
key,
|
|
@@ -15,11 +18,12 @@ var useAddressNameMap = (addresses, shouldFetch = true) => {
|
|
|
15
18
|
withContractInfo: "true",
|
|
16
19
|
withNameTagInfo: "true",
|
|
17
20
|
withENSInfo: "true"
|
|
18
|
-
})
|
|
21
|
+
}).then(transformNameMapKeysToLowerCase)
|
|
19
22
|
);
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export {
|
|
26
|
+
transformNameMapKeysToLowerCase,
|
|
23
27
|
useAddressNameMap
|
|
24
28
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-HF7RD7UD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/hooks/useAddressNameMap.ts"],"sourcesContent":["import useSWRImmutable from 'swr/immutable';\nimport { fetchAddressNameMap } from '../request';\nimport { useMemo } from 'react';\nimport { AddressNameMap } from '../request.types';\n\nexport const transformNameMapKeysToLowerCase = (\n nameMap?: Record<string, AddressNameMap>,\n) =>\n nameMap &&\n Object.fromEntries(\n Object.entries(nameMap).map(([k, v]) => [k.toLowerCase(), v]),\n );\n\nexport const useAddressNameMap = (addresses: string[], shouldFetch = true) => {\n const key = useMemo(() => {\n return shouldFetch && addresses.length > 0\n ? `address-name-map-${addresses\n .map(i => i.toLowerCase())\n .sort()\n .join(',')}`\n : null;\n }, [addresses, shouldFetch]);\n return useSWRImmutable(key, () =>\n fetchAddressNameMap(addresses, {\n withContractInfo: 'true',\n withNameTagInfo: 'true',\n withENSInfo: 'true',\n }).then(transformNameMapKeysToLowerCase),\n );\n};\n"],"mappings":";;;;;AAAA,OAAO,qBAAqB;AAE5B,SAAS,eAAe;AAGjB,IAAM,kCAAkC,CAC7C,YAEA,WACA,OAAO;AAAA,EACL,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC;AAC9D;AAEK,IAAM,oBAAoB,CAAC,WAAqB,cAAc,SAAS;AAC5E,QAAM,MAAM,QAAQ,MAAM;AACxB,WAAO,eAAe,UAAU,SAAS,IACrC,oBAAoB,UACjB,IAAI,OAAK,EAAE,YAAY,CAAC,EACxB,KAAK,EACL,KAAK,GAAG,MACX;AAAA,EACN,GAAG,CAAC,WAAW,WAAW,CAAC;AAC3B,SAAO;AAAA,IAAgB;AAAA,IAAK,MAC1B,oBAAoB,WAAW;AAAA,MAC7B,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,MACjB,aAAa;AAAA,IACf,CAAC,EAAE,KAAK,+BAA+B;AAAA,EACzC;AACF;","names":[]}
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
InvalidAddress,
|
|
12
12
|
MyAddress,
|
|
13
13
|
PosAddress
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LCV3NUFR.js";
|
|
15
15
|
import {
|
|
16
16
|
RenderAddress
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-4LSM4TMM.js";
|
|
18
18
|
import {
|
|
19
19
|
formatAddress,
|
|
20
20
|
isCoreAddress,
|
|
@@ -41,7 +41,8 @@ var parseProps = (props, globalData) => {
|
|
|
41
41
|
showENSLabel,
|
|
42
42
|
ensName,
|
|
43
43
|
nameMap,
|
|
44
|
-
cfxAddress
|
|
44
|
+
cfxAddress,
|
|
45
|
+
showVerificationName
|
|
45
46
|
} = props;
|
|
46
47
|
const translations = getTranslations();
|
|
47
48
|
const nameInfo = getAddressNameInfo(cfxAddress, nameMap);
|
|
@@ -80,7 +81,7 @@ var parseProps = (props, globalData) => {
|
|
|
80
81
|
cfxAddress,
|
|
81
82
|
tokenName: props.tokenName || nameInfo?.tokenName,
|
|
82
83
|
contractName: props.contractName || nameInfo?.contractName,
|
|
83
|
-
verificationName: props.verificationName || nameInfo?.verificationName,
|
|
84
|
+
verificationName: showVerificationName ? props.verificationName || nameInfo?.verificationName : void 0,
|
|
84
85
|
verify: props.verify || nameInfo?.verify,
|
|
85
86
|
ensName: props.ensName || nameInfo?.ensName,
|
|
86
87
|
isEspaceAddress: props.isEspaceAddress || nameInfo?.isEspaceAddress
|
|
@@ -142,4 +143,4 @@ var CoreAddressContainer = withTranslation()(
|
|
|
142
143
|
export {
|
|
143
144
|
CoreAddressContainer
|
|
144
145
|
};
|
|
145
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-J6ZC77OY.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} from '../../utils/address';\nimport { useGlobalData, getTranslations } from '../../store';\nimport { LOCALSTORAGE_KEYS_MAP } from '../../utils/constants';\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';\nimport ICON_ENS from '../../images/logo-cns.svg';\nimport { getAddressNameInfo } from './utils';\n\nconst parseProps = (\n props: CoreAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const {\n t,\n showAddressLabel,\n showNametag,\n nametag,\n showENSLabel,\n ensName,\n nameMap,\n cfxAddress,\n showVerificationName,\n } = props;\n\n const translations = getTranslations();\n\n const nameInfo = getAddressNameInfo(cfxAddress, nameMap);\n\n let innerName = props.innerName;\n if (!innerName && isZeroAddress(cfxAddress)) {\n innerName = t(translations.general.zeroAddress);\n }\n\n // private name tag\n let addressLabel: React.ReactNode = null;\n // official name tag\n let officalNametag: React.ReactNode = null;\n // ens name tag\n let ENSLabel: React.ReactNode = null;\n let ENSIcon: React.ReactNode = null;\n\n if (cfxAddress && showAddressLabel) {\n // global private name tag\n const addressLabels = globalData?.[LOCALSTORAGE_KEYS_MAP.addressLabel];\n addressLabel = addressLabels?.[cfxAddress];\n }\n\n if (cfxAddress && showNametag) {\n officalNametag = nametag || nameInfo?.nametag;\n }\n\n if (showENSLabel && ensName) {\n ENSLabel = ensName;\n ENSIcon = (\n <img\n src={ICON_ENS}\n className=\"w-[16px] h-[16px] mb-[3px] mr-[2px]\"\n alt=\"\"\n />\n );\n }\n\n return {\n innerName,\n nametag: officalNametag,\n addressLabel,\n ENSLabel,\n ENSIcon: ENSIcon,\n cfxAddress,\n tokenName: props.tokenName || nameInfo?.tokenName,\n contractName: props.contractName || nameInfo?.contractName,\n verificationName: showVerificationName\n ? props.verificationName || nameInfo?.verificationName\n : undefined,\n verify: props.verify || nameInfo?.verify,\n ensName: props.ensName || nameInfo?.ensName,\n isEspaceAddress: props.isEspaceAddress || nameInfo?.isEspaceAddress,\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.ensName || 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 const cfxAddress = formatAddress(props.value, 'base32');\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 cfxAddress,\n ensName: ens ? ens[cfxAddress]?.name : undefined,\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;AAsBd,OAAO,cAAc;AAiDf,SAoCO,UApCP;AA9CN,IAAM,aAAa,CACjB,OACA,eACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA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,gBAAE;AAAA,IACb;AACA,UAAM,aAAa,cAAc,MAAM,OAAO,QAAQ;AAEtD,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;AAAA,MACA,SAAS,MAAM,IAAI,UAAU,GAAG,OAAO;AAAA,IACzC;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":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-MWAD4CIG.js";
|
|
4
4
|
import {
|
|
5
5
|
RenderAddress
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4LSM4TMM.js";
|
|
7
7
|
import {
|
|
8
8
|
formatAddress,
|
|
9
9
|
isInnerContractAddress
|
|
@@ -209,4 +209,4 @@ export {
|
|
|
209
209
|
MyAddress,
|
|
210
210
|
PosAddress
|
|
211
211
|
};
|
|
212
|
-
//# sourceMappingURL=chunk-
|
|
212
|
+
//# sourceMappingURL=chunk-LCV3NUFR.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
ContractCreatedAddress,
|
|
7
7
|
InvalidAddress,
|
|
8
8
|
MyAddress
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LCV3NUFR.js";
|
|
10
10
|
import {
|
|
11
11
|
RenderAddress
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4LSM4TMM.js";
|
|
13
13
|
import {
|
|
14
14
|
convertCheckSum,
|
|
15
15
|
formatAddress,
|
|
@@ -27,7 +27,14 @@ import { withTranslation } from "react-i18next";
|
|
|
27
27
|
import _ from "lodash";
|
|
28
28
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
29
29
|
var parseProps = (props, globalData) => {
|
|
30
|
-
const {
|
|
30
|
+
const {
|
|
31
|
+
t,
|
|
32
|
+
showAddressLabel,
|
|
33
|
+
showNametag,
|
|
34
|
+
nametag,
|
|
35
|
+
nameMap,
|
|
36
|
+
showVerificationName
|
|
37
|
+
} = props;
|
|
31
38
|
const value = props.value || "";
|
|
32
39
|
const cfxAddress = formatAddress(value, "hex");
|
|
33
40
|
const nameInfo = getAddressNameInfo(cfxAddress, nameMap);
|
|
@@ -52,7 +59,7 @@ var parseProps = (props, globalData) => {
|
|
|
52
59
|
cfxAddress,
|
|
53
60
|
tokenName: props.tokenName || nameInfo?.tokenName,
|
|
54
61
|
contractName: props.contractName || nameInfo?.contractName,
|
|
55
|
-
verificationName: props.verificationName || nameInfo?.verificationName,
|
|
62
|
+
verificationName: showVerificationName ? props.verificationName || nameInfo?.verificationName : void 0,
|
|
56
63
|
verify: props.verify || nameInfo?.verify,
|
|
57
64
|
isContract: props.isContract || nameInfo?.isContract
|
|
58
65
|
};
|
|
@@ -102,4 +109,4 @@ var EVMAddressContainer = withTranslation()(
|
|
|
102
109
|
export {
|
|
103
110
|
EVMAddressContainer
|
|
104
111
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-XUKHHB5L.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';\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';\nimport { getAddressNameInfo } from './utils';\n\nconst parseProps = (\n props: EVMAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const {\n t,\n showAddressLabel,\n showNametag,\n nametag,\n nameMap,\n showVerificationName,\n } = props;\n const value: string = props.value || '';\n const cfxAddress = formatAddress(value, 'hex');\n\n const nameInfo = getAddressNameInfo(cfxAddress, nameMap);\n\n const translations = getTranslations();\n\n let innerName = props.innerName;\n if (!innerName && isZeroAddress(cfxAddress)) {\n innerName = 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 addressLabel =\n addressLabels?.[convertCheckSum(cfxAddress)] ||\n addressLabels?.[cfxAddress.toLowerCase()];\n }\n\n if (cfxAddress && showNametag) {\n officalNametag = nametag || nameInfo?.nametag;\n }\n\n return {\n innerName,\n nametag: officalNametag,\n addressLabel,\n cfxAddress,\n tokenName: props.tokenName || nameInfo?.tokenName,\n contractName: props.contractName || nameInfo?.contractName,\n verificationName: showVerificationName\n ? props.verificationName || nameInfo?.verificationName\n : undefined,\n verify: props.verify || nameInfo?.verify,\n isContract: props.isContract || nameInfo?.isContract,\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;AAmFD;AA9Db,IAAM,aAAa,CACjB,OACA,eACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,QAAgB,MAAM,SAAS;AACrC,QAAM,aAAa,cAAc,OAAO,KAAK;AAE7C,QAAM,WAAW,mBAAmB,YAAY,OAAO;AAEvD,QAAM,eAAe,gBAAgB;AAEr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D,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":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CoreAddressContainer
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-J6ZC77OY.js";
|
|
4
4
|
import "../../chunk-CMOP3BKX.js";
|
|
5
5
|
import "../../chunk-WZIT54AU.js";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-LCV3NUFR.js";
|
|
7
7
|
import "../../chunk-MWAD4CIG.js";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-4LSM4TMM.js";
|
|
9
9
|
import "../../chunk-6L4ZEJQI.js";
|
|
10
10
|
import "../../chunk-C7OIVXE3.js";
|
|
11
11
|
import "../../chunk-TOKKKTFG.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EVMAddressContainer
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-XUKHHB5L.js";
|
|
4
4
|
import "../../chunk-WZIT54AU.js";
|
|
5
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-LCV3NUFR.js";
|
|
6
6
|
import "../../chunk-MWAD4CIG.js";
|
|
7
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-4LSM4TMM.js";
|
|
8
8
|
import "../../chunk-6L4ZEJQI.js";
|
|
9
9
|
import "../../chunk-C7OIVXE3.js";
|
|
10
10
|
import "../../chunk-TOKKKTFG.js";
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
InvalidAddress,
|
|
6
6
|
MyAddress,
|
|
7
7
|
PosAddress
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-LCV3NUFR.js";
|
|
9
9
|
import "../../chunk-MWAD4CIG.js";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-4LSM4TMM.js";
|
|
11
11
|
import "../../chunk-6L4ZEJQI.js";
|
|
12
12
|
import "../../chunk-C7OIVXE3.js";
|
|
13
13
|
import "../../chunk-TOKKKTFG.js";
|
|
@@ -2,6 +2,6 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import { RenderAddressProps } from './types.js';
|
|
3
3
|
import '../../utils/request.types.js';
|
|
4
4
|
|
|
5
|
-
declare const RenderAddress: ({ cfxAddress, tokenName, contractName,
|
|
5
|
+
declare const RenderAddress: ({ cfxAddress, tokenName, contractName, verificationName, hoverValue, hrefAddress, link, isFull, isFullNameTag, style, maxWidth, prefix, ENSIcon, suffix, type, addressLabel, ENSLabel, nametag, innerName, hideAliasPrefixInHover, }: RenderAddressProps) => react_jsx_runtime.JSX.Element;
|
|
6
6
|
|
|
7
7
|
export { RenderAddress };
|
|
@@ -68,7 +68,6 @@ interface RenderAddressProps {
|
|
|
68
68
|
type?: 'pow' | 'pos';
|
|
69
69
|
tokenName?: string | null;
|
|
70
70
|
contractName?: string | null;
|
|
71
|
-
showVerificationName?: boolean;
|
|
72
71
|
verificationName?: string | null;
|
|
73
72
|
innerName?: string | null;
|
|
74
73
|
addressLabel?: string | Iterable<React.ReactNode> | null;
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
import "../../chunk-TGK5LP2H.js";
|
|
11
11
|
import {
|
|
12
12
|
CoreAddressContainer
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-J6ZC77OY.js";
|
|
14
14
|
import "../../chunk-CMOP3BKX.js";
|
|
15
15
|
import "../../chunk-WZIT54AU.js";
|
|
16
|
-
import "../../chunk-
|
|
16
|
+
import "../../chunk-LCV3NUFR.js";
|
|
17
17
|
import "../../chunk-MWAD4CIG.js";
|
|
18
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-4LSM4TMM.js";
|
|
19
19
|
import "../../chunk-6L4ZEJQI.js";
|
|
20
20
|
import "../../chunk-C7OIVXE3.js";
|
|
21
21
|
import "../../chunk-TOKKKTFG.js";
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
import "../../chunk-TGK5LP2H.js";
|
|
11
11
|
import {
|
|
12
12
|
EVMAddressContainer
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-XUKHHB5L.js";
|
|
14
14
|
import "../../chunk-WZIT54AU.js";
|
|
15
|
-
import "../../chunk-
|
|
15
|
+
import "../../chunk-LCV3NUFR.js";
|
|
16
16
|
import "../../chunk-MWAD4CIG.js";
|
|
17
|
-
import "../../chunk-
|
|
17
|
+
import "../../chunk-4LSM4TMM.js";
|
|
18
18
|
import {
|
|
19
19
|
formatAddress
|
|
20
20
|
} from "../../chunk-6L4ZEJQI.js";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as swr from 'swr';
|
|
2
2
|
import { AddressNameMap } from '../request.types.js';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare const transformNameMapKeysToLowerCase: (nameMap?: Record<string, AddressNameMap>) => {
|
|
5
|
+
[k: string]: AddressNameMap;
|
|
6
|
+
} | undefined;
|
|
7
|
+
declare const useAddressNameMap: (addresses: string[], shouldFetch?: boolean) => swr.SWRResponse<{
|
|
8
|
+
[k: string]: AddressNameMap;
|
|
9
|
+
} | undefined, any, any>;
|
|
5
10
|
|
|
6
|
-
export { useAddressNameMap };
|
|
11
|
+
export { transformNameMapKeysToLowerCase, useAddressNameMap };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
transformNameMapKeysToLowerCase,
|
|
2
3
|
useAddressNameMap
|
|
3
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-HF7RD7UD.js";
|
|
4
5
|
import "../../chunk-VGYNHJFT.js";
|
|
5
6
|
import "../../chunk-J2I22Q2M.js";
|
|
6
7
|
import "../../chunk-YEINMVAR.js";
|
|
7
8
|
import "../../chunk-DQGLZCIG.js";
|
|
8
9
|
import "../../chunk-WQG2LZMB.js";
|
|
9
10
|
export {
|
|
11
|
+
transformNameMapKeysToLowerCase,
|
|
10
12
|
useAddressNameMap
|
|
11
13
|
};
|
|
12
14
|
//# sourceMappingURL=useAddressNameMap.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { AddressNameMap } from '../request.types.js';
|
|
2
2
|
|
|
3
|
-
declare const transformNameMapKeysToLowerCase: (nameMap?: Record<string, AddressNameMap>) => {
|
|
4
|
-
[k: string]: AddressNameMap;
|
|
5
|
-
} | undefined;
|
|
6
3
|
declare const enhanceDataWithNameMap: (list?: Record<string, unknown>[], nameMap?: Record<string, AddressNameMap>) => Record<string, unknown>[] | {
|
|
7
4
|
nameMap: {
|
|
8
5
|
[k: string]: AddressNameMap;
|
|
@@ -27,4 +24,4 @@ declare const useEnhanceDataWithNameMap: (list?: Record<string, unknown>[], { ad
|
|
|
27
24
|
isLoading: boolean;
|
|
28
25
|
};
|
|
29
26
|
|
|
30
|
-
export { enhanceDataWithNameMap, formatListResponseWithNameMap,
|
|
27
|
+
export { enhanceDataWithNameMap, formatListResponseWithNameMap, useEnhanceDataWithNameMap };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
transformNameMapKeysToLowerCase,
|
|
2
3
|
useAddressNameMap
|
|
3
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-HF7RD7UD.js";
|
|
4
5
|
import "../../chunk-VGYNHJFT.js";
|
|
5
6
|
import "../../chunk-J2I22Q2M.js";
|
|
6
7
|
import "../../chunk-YEINMVAR.js";
|
|
@@ -9,9 +10,6 @@ import "../../chunk-WQG2LZMB.js";
|
|
|
9
10
|
|
|
10
11
|
// src/utils/hooks/useEnhanceDataWithNameMap.ts
|
|
11
12
|
import { useMemo } from "react";
|
|
12
|
-
var transformNameMapKeysToLowerCase = (nameMap) => nameMap && Object.fromEntries(
|
|
13
|
-
Object.entries(nameMap).map(([k, v]) => [k.toLowerCase(), v])
|
|
14
|
-
);
|
|
15
13
|
var enhanceDataWithNameMap = (list, nameMap) => {
|
|
16
14
|
if (!nameMap || !list)
|
|
17
15
|
return list;
|
|
@@ -65,7 +63,6 @@ var useEnhanceDataWithNameMap = (list, {
|
|
|
65
63
|
export {
|
|
66
64
|
enhanceDataWithNameMap,
|
|
67
65
|
formatListResponseWithNameMap,
|
|
68
|
-
transformNameMapKeysToLowerCase,
|
|
69
66
|
useEnhanceDataWithNameMap
|
|
70
67
|
};
|
|
71
68
|
//# sourceMappingURL=useEnhanceDataWithNameMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/hooks/useEnhanceDataWithNameMap.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/hooks/useEnhanceDataWithNameMap.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n transformNameMapKeysToLowerCase,\n useAddressNameMap,\n} from './useAddressNameMap';\nimport { AddressNameMap } from '../request.types';\n\nexport const enhanceDataWithNameMap = (\n list?: Record<string, unknown>[],\n nameMap?: Record<string, AddressNameMap>,\n) => {\n if (!nameMap || !list) return list;\n const normalizedNameMap = transformNameMapKeysToLowerCase(nameMap);\n\n return (\n list.map(item => {\n const newItem = {\n ...item,\n nameMap: normalizedNameMap,\n };\n return newItem;\n }) || []\n );\n};\n\nexport const formatListResponseWithNameMap = <\n T extends Record<string, unknown>,\n>(\n res: T,\n) => {\n return {\n ...res,\n list: enhanceDataWithNameMap(\n res.list as Record<string, unknown>[],\n res.nameMap as Record<string, AddressNameMap>,\n ),\n };\n};\n\nexport const useEnhanceDataWithNameMap = (\n list?: Record<string, unknown>[],\n {\n addressKeys,\n nameMap,\n }: {\n addressKeys?: string[];\n nameMap?: Record<string, AddressNameMap>;\n } = {},\n) => {\n const keys = useMemo(() => addressKeys?.join(',') || '', [addressKeys]);\n const addresses = useMemo(() => {\n const set = new Set<string>();\n list?.forEach(item => {\n addressKeys?.forEach(key => {\n const address = item[key];\n if (address && typeof address === 'string') {\n set.add(address);\n }\n });\n });\n return Array.from(set);\n }, [list, keys]);\n const { data: fetchedNameMap, isLoading } = useAddressNameMap(\n addresses,\n !nameMap,\n );\n const finalNameMap = nameMap || fetchedNameMap;\n return useMemo(() => {\n return {\n data: enhanceDataWithNameMap(list, finalNameMap),\n isLoading,\n };\n }, [list, finalNameMap, isLoading]);\n};\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe;AAOjB,IAAM,yBAAyB,CACpC,MACA,YACG;AACH,MAAI,CAAC,WAAW,CAAC;AAAM,WAAO;AAC9B,QAAM,oBAAoB,gCAAgC,OAAO;AAEjE,SACE,KAAK,IAAI,UAAQ;AACf,UAAM,UAAU;AAAA,MACd,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AACA,WAAO;AAAA,EACT,CAAC,KAAK,CAAC;AAEX;AAEO,IAAM,gCAAgC,CAG3C,QACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAAA,EACF;AACF;AAEO,IAAM,4BAA4B,CACvC,MACA;AAAA,EACE;AAAA,EACA;AACF,IAGI,CAAC,MACF;AACH,QAAM,OAAO,QAAQ,MAAM,aAAa,KAAK,GAAG,KAAK,IAAI,CAAC,WAAW,CAAC;AACtE,QAAM,YAAY,QAAQ,MAAM;AAC9B,UAAM,MAAM,oBAAI,IAAY;AAC5B,UAAM,QAAQ,UAAQ;AACpB,mBAAa,QAAQ,SAAO;AAC1B,cAAM,UAAU,KAAK,GAAG;AACxB,YAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,cAAI,IAAI,OAAO;AAAA,QACjB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AACD,WAAO,MAAM,KAAK,GAAG;AAAA,EACvB,GAAG,CAAC,MAAM,IAAI,CAAC;AACf,QAAM,EAAE,MAAM,gBAAgB,UAAU,IAAI;AAAA,IAC1C;AAAA,IACA,CAAC;AAAA,EACH;AACA,QAAM,eAAe,WAAW;AAChC,SAAO,QAAQ,MAAM;AACnB,WAAO;AAAA,MACL,MAAM,uBAAuB,MAAM,YAAY;AAAA,MAC/C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,MAAM,cAAc,SAAS,CAAC;AACpC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
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} from '../../utils/address';\nimport { useGlobalData, getTranslations } from '../../store';\nimport { LOCALSTORAGE_KEYS_MAP } from '../../utils/constants';\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';\nimport ICON_ENS from '../../images/logo-cns.svg';\nimport { getAddressNameInfo } from './utils';\n\nconst parseProps = (\n props: CoreAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const {\n t,\n showAddressLabel,\n showNametag,\n nametag,\n showENSLabel,\n ensName,\n nameMap,\n cfxAddress,\n } = props;\n\n const translations = getTranslations();\n\n const nameInfo = getAddressNameInfo(cfxAddress, nameMap);\n\n let innerName = props.innerName;\n if (!innerName && isZeroAddress(cfxAddress)) {\n innerName = t(translations.general.zeroAddress);\n }\n\n // private name tag\n let addressLabel: React.ReactNode = null;\n // official name tag\n let officalNametag: React.ReactNode = null;\n // ens name tag\n let ENSLabel: React.ReactNode = null;\n let ENSIcon: React.ReactNode = null;\n\n if (cfxAddress && showAddressLabel) {\n // global private name tag\n const addressLabels = globalData?.[LOCALSTORAGE_KEYS_MAP.addressLabel];\n addressLabel = addressLabels?.[cfxAddress];\n }\n\n if (cfxAddress && showNametag) {\n officalNametag = nametag || nameInfo?.nametag;\n }\n\n if (showENSLabel && ensName) {\n ENSLabel = ensName;\n ENSIcon = (\n <img\n src={ICON_ENS}\n className=\"w-[16px] h-[16px] mb-[3px] mr-[2px]\"\n alt=\"\"\n />\n );\n }\n\n return {\n innerName,\n nametag: officalNametag,\n addressLabel,\n ENSLabel,\n ENSIcon: ENSIcon,\n cfxAddress,\n tokenName: props.tokenName || nameInfo?.tokenName,\n contractName: props.contractName || nameInfo?.contractName,\n verificationName: props.verificationName || nameInfo?.verificationName,\n verify: props.verify || nameInfo?.verify,\n ensName: props.ensName || nameInfo?.ensName,\n isEspaceAddress: props.isEspaceAddress || nameInfo?.isEspaceAddress,\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.ensName || 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 const cfxAddress = formatAddress(props.value, 'base32');\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 cfxAddress,\n ensName: ens ? ens[cfxAddress]?.name : undefined,\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;AAsBd,OAAO,cAAc;AAgDf,SAkCO,UAlCP;AA7CN,IAAM,aAAa,CACjB,OACA,eACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,eAAe,gBAAgB;AAErC,QAAM,WAAW,mBAAmB,YAAY,OAAO;AAEvD,MAAI,YAAY,MAAM;AACtB,MAAI,CAAC,aAAa,cAAc,UAAU,GAAG;AAC3C,gBAAY,EAAE,aAAa,QAAQ,WAAW;AAAA,EAChD;AAGA,MAAI,eAAgC;AAEpC,MAAI,iBAAkC;AAEtC,MAAI,WAA4B;AAChC,MAAI,UAA2B;AAE/B,MAAI,cAAc,kBAAkB;AAElC,UAAM,gBAAgB,6DAA+C;AACrE,mBAAe,gBAAgB,UAAU;AAAA,EAC3C;AAEA,MAAI,cAAc,aAAa;AAC7B,qBAAiB,WAAW,UAAU;AAAA,EACxC;AAEA,MAAI,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AI,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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/hooks/useAddressNameMap.ts"],"sourcesContent":["import useSWRImmutable from 'swr/immutable';\nimport { fetchAddressNameMap } from '../request';\nimport { useMemo } from 'react';\n\nexport const useAddressNameMap = (addresses: string[], shouldFetch = true) => {\n const key = useMemo(() => {\n return shouldFetch && addresses.length > 0\n ? `address-name-map-${[...addresses].sort().join(',')}`\n : null;\n }, [addresses, shouldFetch]);\n return useSWRImmutable(key, () =>\n fetchAddressNameMap(addresses, {\n withContractInfo: 'true',\n withNameTagInfo: 'true',\n withENSInfo: 'true',\n }),\n );\n};\n"],"mappings":";;;;;AAAA,OAAO,qBAAqB;AAE5B,SAAS,eAAe;AAEjB,IAAM,oBAAoB,CAAC,WAAqB,cAAc,SAAS;AAC5E,QAAM,MAAM,QAAQ,MAAM;AACxB,WAAO,eAAe,UAAU,SAAS,IACrC,oBAAoB,CAAC,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,MAClD;AAAA,EACN,GAAG,CAAC,WAAW,WAAW,CAAC;AAC3B,SAAO;AAAA,IAAgB;AAAA,IAAK,MAC1B,oBAAoB,WAAW;AAAA,MAC7B,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,MACjB,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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 if (link === false) {\n return false;\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 tokenName,\n contractName,\n showVerificationName = false,\n verificationName,\n hoverValue,\n hrefAddress,\n link = '',\n isFull = false,\n isFullNameTag = false,\n style = {},\n maxWidth,\n prefix = null,\n ENSIcon = null,\n suffix = null,\n type = 'pow',\n addressLabel = '',\n ENSLabel = '',\n nametag = '',\n innerName = '',\n hideAliasPrefixInHover = false,\n}: RenderAddressProps) => {\n const translations = getTranslations();\n\n // Private name tags > Official tag/name > contract token name > contract name tag > contract verification name > CNS/ENS\n const name =\n // Private name tags\n addressLabel ||\n // Official tag/name\n nametag ||\n // contract token name\n tokenName ||\n // contract name tag\n contractName ||\n // contract verification name\n (showVerificationName && verificationName) ||\n // CNS/ENS\n ENSLabel ||\n // inner name is used for some special address, like the zero address\n innerName;\n const isShowEns = !!ENSLabel && name === ENSLabel;\n\n const defaultStyle = {\n maxWidth: `${(name && isFullNameTag) || isFull ? 'unset' : (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: tokenName || contractName || verificationName,\n hideLabel: hideAliasPrefixInHover,\n },\n };\n\n const checksumAddress = convertCheckSum(cfxAddress);\n\n const cfxAddressLabel =\n typeof checksumAddress === 'string' && !isFull\n ? type === 'pos'\n ? shortenAddress(checksumAddress!, {\n prefixLength: 10,\n suffixLength: 0,\n })\n : shortenAddress(checksumAddress!)\n : checksumAddress;\n\n return (\n <div className=\"inline-flex\">\n {prefix || (isShowEns ? ENSIcon : null)}\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;AAUrB,SA4IA,UAzIM,KAHN;AARV,IAA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AO,EAAE,GAAG,cAAc,GAAG,MAAM;AAAA,YAClC,GAAI,OAAO,EAAE,MAAM,OAAO,IAAI,EAAE,IAAI,CAAC;AAAA,YAErC,kBAAQ;AAAA;AAAA,QACX;AAAA;AAAA,IACF;AAAA,IACC;AAAA,KACH;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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';\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';\nimport { getAddressNameInfo } from './utils';\n\nconst parseProps = (\n props: EVMAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const { t, showAddressLabel, showNametag, nametag, nameMap } = props;\n const value: string = props.value || '';\n const cfxAddress = formatAddress(value, 'hex');\n\n const nameInfo = getAddressNameInfo(cfxAddress, nameMap);\n\n const translations = getTranslations();\n\n let innerName = props.innerName;\n if (!innerName && isZeroAddress(cfxAddress)) {\n innerName = 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 addressLabel =\n addressLabels?.[convertCheckSum(cfxAddress)] ||\n addressLabels?.[cfxAddress.toLowerCase()];\n }\n\n if (cfxAddress && showNametag) {\n officalNametag = nametag || nameInfo?.nametag;\n }\n\n return {\n innerName,\n nametag: officalNametag,\n addressLabel,\n cfxAddress,\n tokenName: props.tokenName || nameInfo?.tokenName,\n contractName: props.contractName || nameInfo?.contractName,\n verificationName: props.verificationName || nameInfo?.verificationName,\n verify: props.verify || nameInfo?.verify,\n isContract: props.isContract || nameInfo?.isContract,\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;AA0ED;AArDb,IAAM,aAAa,CACjB,OACA,eACG;AACH,QAAM,EAAE,GAAG,kBAAkB,aAAa,SAAS,QAAQ,IAAI;AAC/D,QAAM,QAAgB,MAAM,SAAS;AACrC,QAAM,aAAa,cAAc,OAAO,KAAK;AAE7C,QAAM,WAAW,mBAAmB,YAAY,OAAO;AAEvD,QAAM,eAAe,gBAAgB;AAErC,MAAI,YAAY,MAAM;AACtB,MAAI,CAAC,aAAa,cAAc,UAAU,GAA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