@cfxjs/sirius-next-common 0.2.20 → 0.2.21-fix-error-publish
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-CMOP3BKX.js → chunk-225VMTCA.js} +3 -3
- package/dist/{chunk-LCIBOT5P.js → chunk-3JIAKQ23.js} +2 -2
- package/dist/{chunk-C7OIVXE3.js → chunk-4B7BV62E.js} +3 -3
- package/dist/chunk-4BS66NNM.js +29 -0
- package/dist/chunk-4BS66NNM.js.map +1 -0
- package/dist/{chunk-J6ZC77OY.js → chunk-4M53GHPD.js} +6 -6
- package/dist/{chunk-GHHUAWSG.js → chunk-524EB4WC.js} +3 -3
- package/dist/chunk-5AM5HM3B.js +10 -0
- package/dist/chunk-5AM5HM3B.js.map +1 -0
- package/dist/{chunk-XZL5CZFT.js → chunk-5MJZWIYI.js} +4 -4
- package/dist/chunk-6C5NQACS.js +202 -0
- package/dist/chunk-6C5NQACS.js.map +1 -0
- package/dist/{chunk-H5ZJBRIK.js → chunk-6PKWA444.js} +4 -4
- package/dist/{chunk-4LSM4TMM.js → chunk-734CQOS7.js} +3 -3
- package/dist/chunk-7RLNWQIR.js +192 -0
- package/dist/chunk-7RLNWQIR.js.map +1 -0
- package/dist/{chunk-RUU22F7R.js → chunk-7VFOHX3W.js} +2 -2
- package/dist/{chunk-BEI5TWJL.js → chunk-7WDLTRBN.js} +2 -2
- package/dist/{chunk-AYCHKB2Y.js → chunk-A3IT7RYO.js} +2 -2
- package/dist/{chunk-UF5BN4QN.js → chunk-A3VPSWVX.js} +2 -2
- package/dist/chunk-A46LVI25.js +82 -0
- package/dist/chunk-A46LVI25.js.map +1 -0
- package/dist/chunk-A6B5V6XY.js +140 -0
- package/dist/chunk-A6B5V6XY.js.map +1 -0
- package/dist/{chunk-ELF2EOGF.js → chunk-AQFNXW4W.js} +2 -2
- package/dist/chunk-ASS6TOFE.js +72 -0
- package/dist/chunk-ASS6TOFE.js.map +1 -0
- package/dist/{chunk-NM3BMITL.js → chunk-B5JCHBO3.js} +2 -2
- package/dist/{chunk-DCQANK66.js → chunk-BGNBKP5R.js} +2 -2
- package/dist/{chunk-6L4ZEJQI.js → chunk-BN3ATGHU.js} +2 -2
- package/dist/chunk-C6GUZVQ2.js +130 -0
- package/dist/chunk-C6GUZVQ2.js.map +1 -0
- package/dist/chunk-CNXGYDZG.js +146 -0
- package/dist/chunk-CNXGYDZG.js.map +1 -0
- package/dist/chunk-DASMAZXS.js +71 -0
- package/dist/{chunk-LCV3NUFR.js → chunk-DO6PJAZB.js} +5 -5
- package/dist/chunk-E7FB4S3X.js +276 -0
- package/dist/chunk-E7FB4S3X.js.map +1 -0
- package/dist/{chunk-BHAXBHVC.js → chunk-EHRGH3HS.js} +4 -4
- package/dist/chunk-EOSVUB2G.js +51 -0
- package/dist/chunk-EOSVUB2G.js.map +1 -0
- package/dist/chunk-FGPRA3A4.js +80 -0
- package/dist/chunk-FGPRA3A4.js.map +1 -0
- package/dist/{chunk-UZALXR3J.js → chunk-FJMV3UA7.js} +4 -4
- package/dist/{chunk-YVV32ON3.js → chunk-FSYB23NA.js} +2 -2
- package/dist/{chunk-XUKHHB5L.js → chunk-FTAFV6RE.js} +5 -5
- package/dist/chunk-FW5ON36S.js +212 -0
- package/dist/chunk-FW5ON36S.js.map +1 -0
- package/dist/chunk-HCEXWKMZ.js +90 -0
- package/dist/chunk-HCEXWKMZ.js.map +1 -0
- package/dist/chunk-HW5VD7EO.js +17 -0
- package/dist/chunk-HW5VD7EO.js.map +1 -0
- package/dist/{chunk-GQRCW7WX.js → chunk-J536GL5G.js} +2 -2
- package/dist/{chunk-DYNSSHD5.js → chunk-J7UQ2R3H.js} +7 -7
- package/dist/{chunk-YEAWH772.js → chunk-JBCKAHH7.js} +2 -2
- package/dist/{chunk-7VQL3G7K.js → chunk-JKFT4JUY.js} +4 -4
- package/dist/chunk-L7RD6ZPE.js +534 -0
- package/dist/chunk-L7RD6ZPE.js.map +1 -0
- package/dist/{chunk-W64AF7LA.js → chunk-MFCMTOYM.js} +5 -5
- package/dist/chunk-MQY7EQPG.js +284 -0
- package/dist/chunk-MQY7EQPG.js.map +1 -0
- package/dist/chunk-MWSXXVVL.js +157 -0
- package/dist/chunk-MWSXXVVL.js.map +1 -0
- package/dist/chunk-O6BP54O6.js +63 -0
- package/dist/chunk-O6BP54O6.js.map +1 -0
- package/dist/chunk-OFAM2QTT.js +17 -0
- package/dist/chunk-OFAM2QTT.js.map +1 -0
- package/dist/{chunk-2WEBXRNL.js → chunk-OSPPP5W5.js} +2 -2
- package/dist/chunk-OT252GGM.js +66 -0
- package/dist/chunk-OT252GGM.js.map +1 -0
- package/dist/{chunk-WZIT54AU.js → chunk-OTSNM4CR.js} +2 -2
- package/dist/chunk-OTSNM4CR.js.map +1 -0
- package/dist/chunk-QX7AGYA5.js +2149 -0
- package/dist/chunk-QX7AGYA5.js.map +1 -0
- package/dist/chunk-R62HRSIY.js +145 -0
- package/dist/chunk-R62HRSIY.js.map +1 -0
- package/dist/{chunk-OT7NZ4PK.js → chunk-RLA5XZT2.js} +3 -3
- package/dist/chunk-RLA5XZT2.js.map +1 -0
- package/dist/{chunk-HF7RD7UD.js → chunk-RWTNG7SM.js} +2 -2
- package/dist/chunk-SIZYE6WH.js +3616 -0
- package/dist/chunk-SIZYE6WH.js.map +1 -0
- package/dist/chunk-SNUPCZY7.js +812 -0
- package/dist/chunk-SNUPCZY7.js.map +1 -0
- package/dist/{chunk-VGYNHJFT.js → chunk-SYWQ2T57.js} +8 -7
- package/dist/chunk-SYWQ2T57.js.map +1 -0
- package/dist/chunk-TGWQSVFC.js +26 -0
- package/dist/chunk-TGWQSVFC.js.map +1 -0
- package/dist/chunk-UVRMLFMC.js +21 -0
- package/dist/chunk-UVRMLFMC.js.map +1 -0
- package/dist/chunk-UX6IRX2M.js +146 -0
- package/dist/chunk-UX6IRX2M.js.map +1 -0
- package/dist/chunk-VD73ULXJ.js +107 -0
- package/dist/chunk-VD73ULXJ.js.map +1 -0
- package/dist/chunk-VEK5DLFI.js +23 -0
- package/dist/chunk-VEK5DLFI.js.map +1 -0
- package/dist/chunk-VTHVXZOP.js +112 -0
- package/dist/chunk-VTHVXZOP.js.map +1 -0
- package/dist/chunk-WY3RJ3A6.js +51 -0
- package/dist/chunk-XI5WO2NW.js +37 -0
- package/dist/chunk-XI5WO2NW.js.map +1 -0
- package/dist/{chunk-C6CGZ6KN.js → chunk-YOCMEOLX.js} +2 -2
- package/dist/chunk-YOVNVFY2.js +105 -0
- package/dist/chunk-YOVNVFY2.js.map +1 -0
- package/dist/{chunk-7AVQOIDM.js → chunk-Z64Z5HLJ.js} +2 -2
- package/dist/components/AAFailedReason/index.d.ts +11 -0
- package/dist/components/AAFailedReason/index.js +41 -0
- package/dist/components/AAFailedReason/index.js.map +1 -0
- package/dist/components/AceEditor/index.js +4 -4
- 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/AddressContainer/utils.js +3 -3
- package/dist/components/Age/index.js +4 -4
- package/dist/components/AutoComplete/index.js +3 -3
- package/dist/components/Charts/PreviewChartTemplate.js +1 -1
- package/dist/components/Charts/StockChartTemplate.js +1 -1
- package/dist/components/CopyButton/index.js +3 -3
- package/dist/components/DecimalsSelect/index.js +3 -3
- package/dist/components/DownloadCSV/index.js +4 -4
- package/dist/components/GasPriceDropdown/index.js +2 -2
- package/dist/components/IncreasePercent/index.js +2 -2
- package/dist/components/InfoIconWithTooltip/index.js +4 -4
- package/dist/components/InputData/AddressLabel.js +8 -8
- package/dist/components/InputData/ContractDetail.js +3 -3
- package/dist/components/InputData/JsonDecode.js +5 -5
- package/dist/components/InputData/OptimizationDecode.js +10 -10
- package/dist/components/InputData/UTF8.js +3 -3
- package/dist/components/InputData/index.js +14 -14
- package/dist/components/Modal/index.js +3 -3
- package/dist/components/NetworkIcon/index.js +2 -2
- package/dist/components/OutputData/ErrorDecode.js +13 -13
- package/dist/components/OutputData/index.js +15 -15
- package/dist/components/PhishingAddressContainer/index.js +4 -4
- package/dist/components/Popover/index.js +3 -3
- package/dist/components/Price/index.js +3 -3
- package/dist/components/ProxyContractAddress/index.js +6 -6
- package/dist/components/Radio/index.js +2 -2
- package/dist/components/SearchInput/index.js +4 -4
- package/dist/components/Select/index.js +4 -4
- package/dist/components/Select/select.js +3 -3
- package/dist/components/SmartAccountAddress/index.d.ts +11 -0
- package/dist/components/SmartAccountAddress/index.js +94 -0
- package/dist/components/SmartAccountAddress/index.js.map +1 -0
- package/dist/components/Text/index.js +4 -4
- package/dist/components/Tooltip/index.js +3 -3
- package/dist/components/TransactionAction/coreTransactionAction.js +23 -18
- package/dist/components/TransactionAction/coreTransactionAction.js.map +1 -1
- package/dist/components/TransactionAction/evmTransactionAction.js +22 -17
- package/dist/components/TransactionAction/evmTransactionAction.js.map +1 -1
- package/dist/components/TransactionTrace/TraceDetail.js +23 -23
- package/dist/components/TransactionTrace/TreeTraceTable.js +24 -24
- package/dist/components/TransactionTrace/index.js +24 -24
- package/dist/utils/address.js +2 -2
- package/dist/utils/contractManagerTool.js +2 -2
- package/dist/utils/hooks/useAddressLabel.js +3 -3
- package/dist/utils/hooks/useAddressNameMap.js +2 -2
- package/dist/utils/hooks/useAutoSetHolderFilterParams.js +2 -2
- package/dist/utils/hooks/useContractDetail.js +2 -2
- package/dist/utils/hooks/useDecodeFunctionData.js +5 -5
- package/dist/utils/hooks/useDecodeFunctionError.js +3 -3
- package/dist/utils/hooks/useENS.js +3 -3
- package/dist/utils/hooks/useEnhanceDataWithNameMap.js +2 -2
- package/dist/utils/hooks/useMethodAbi.js +2 -2
- package/dist/utils/hooks/useTableData.js +1 -1
- package/dist/utils/hooks/useTxTrace.js +3 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/request.d.ts +1 -0
- package/dist/utils/request.js +1 -1
- package/package.json +17 -17
- package/dist/chunk-VGYNHJFT.js.map +0 -1
- /package/dist/{chunk-CMOP3BKX.js.map → chunk-225VMTCA.js.map} +0 -0
- /package/dist/{chunk-LCIBOT5P.js.map → chunk-3JIAKQ23.js.map} +0 -0
- /package/dist/{chunk-C7OIVXE3.js.map → chunk-4B7BV62E.js.map} +0 -0
- /package/dist/{chunk-J6ZC77OY.js.map → chunk-4M53GHPD.js.map} +0 -0
- /package/dist/{chunk-GHHUAWSG.js.map → chunk-524EB4WC.js.map} +0 -0
- /package/dist/{chunk-XZL5CZFT.js.map → chunk-5MJZWIYI.js.map} +0 -0
- /package/dist/{chunk-H5ZJBRIK.js.map → chunk-6PKWA444.js.map} +0 -0
- /package/dist/{chunk-4LSM4TMM.js.map → chunk-734CQOS7.js.map} +0 -0
- /package/dist/{chunk-RUU22F7R.js.map → chunk-7VFOHX3W.js.map} +0 -0
- /package/dist/{chunk-BEI5TWJL.js.map → chunk-7WDLTRBN.js.map} +0 -0
- /package/dist/{chunk-AYCHKB2Y.js.map → chunk-A3IT7RYO.js.map} +0 -0
- /package/dist/{chunk-UF5BN4QN.js.map → chunk-A3VPSWVX.js.map} +0 -0
- /package/dist/{chunk-ELF2EOGF.js.map → chunk-AQFNXW4W.js.map} +0 -0
- /package/dist/{chunk-NM3BMITL.js.map → chunk-B5JCHBO3.js.map} +0 -0
- /package/dist/{chunk-DCQANK66.js.map → chunk-BGNBKP5R.js.map} +0 -0
- /package/dist/{chunk-6L4ZEJQI.js.map → chunk-BN3ATGHU.js.map} +0 -0
- /package/dist/{chunk-OT7NZ4PK.js.map → chunk-DASMAZXS.js.map} +0 -0
- /package/dist/{chunk-LCV3NUFR.js.map → chunk-DO6PJAZB.js.map} +0 -0
- /package/dist/{chunk-BHAXBHVC.js.map → chunk-EHRGH3HS.js.map} +0 -0
- /package/dist/{chunk-UZALXR3J.js.map → chunk-FJMV3UA7.js.map} +0 -0
- /package/dist/{chunk-YVV32ON3.js.map → chunk-FSYB23NA.js.map} +0 -0
- /package/dist/{chunk-XUKHHB5L.js.map → chunk-FTAFV6RE.js.map} +0 -0
- /package/dist/{chunk-GQRCW7WX.js.map → chunk-J536GL5G.js.map} +0 -0
- /package/dist/{chunk-DYNSSHD5.js.map → chunk-J7UQ2R3H.js.map} +0 -0
- /package/dist/{chunk-YEAWH772.js.map → chunk-JBCKAHH7.js.map} +0 -0
- /package/dist/{chunk-7VQL3G7K.js.map → chunk-JKFT4JUY.js.map} +0 -0
- /package/dist/{chunk-W64AF7LA.js.map → chunk-MFCMTOYM.js.map} +0 -0
- /package/dist/{chunk-2WEBXRNL.js.map → chunk-OSPPP5W5.js.map} +0 -0
- /package/dist/{chunk-HF7RD7UD.js.map → chunk-RWTNG7SM.js.map} +0 -0
- /package/dist/{chunk-WZIT54AU.js.map → chunk-WY3RJ3A6.js.map} +0 -0
- /package/dist/{chunk-C6CGZ6KN.js.map → chunk-YOCMEOLX.js.map} +0 -0
- /package/dist/{chunk-7AVQOIDM.js.map → chunk-Z64Z5HLJ.js.map} +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useENS
|
|
3
|
+
} from "./chunk-O6BP54O6.js";
|
|
4
|
+
import {
|
|
5
|
+
getAddressNameInfo
|
|
6
|
+
} from "./chunk-OTSNM4CR.js";
|
|
7
|
+
import {
|
|
8
|
+
ContractAddress,
|
|
9
|
+
ContractCreatedAddress,
|
|
10
|
+
CoreHexAddress,
|
|
11
|
+
InvalidAddress,
|
|
12
|
+
MyAddress,
|
|
13
|
+
PosAddress
|
|
14
|
+
} from "./chunk-FW5ON36S.js";
|
|
15
|
+
import {
|
|
16
|
+
RenderAddress
|
|
17
|
+
} from "./chunk-UX6IRX2M.js";
|
|
18
|
+
import {
|
|
19
|
+
formatAddress,
|
|
20
|
+
isCoreAddress,
|
|
21
|
+
isCoreContractAddress,
|
|
22
|
+
isZeroAddress
|
|
23
|
+
} from "./chunk-MQY7EQPG.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 ICON_ENS from "./logo-cns-7CXISC6I.svg";
|
|
34
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
35
|
+
var parseProps = (props, globalData) => {
|
|
36
|
+
const {
|
|
37
|
+
t,
|
|
38
|
+
showAddressLabel,
|
|
39
|
+
showNametag,
|
|
40
|
+
nametag,
|
|
41
|
+
showENSLabel,
|
|
42
|
+
ensName,
|
|
43
|
+
nameMap,
|
|
44
|
+
cfxAddress,
|
|
45
|
+
showVerificationName
|
|
46
|
+
} = props;
|
|
47
|
+
const translations = getTranslations();
|
|
48
|
+
const nameInfo = getAddressNameInfo(cfxAddress, nameMap);
|
|
49
|
+
let innerName = props.innerName;
|
|
50
|
+
if (!innerName && isZeroAddress(cfxAddress)) {
|
|
51
|
+
innerName = t(translations.general.zeroAddress);
|
|
52
|
+
}
|
|
53
|
+
let addressLabel = null;
|
|
54
|
+
let officalNametag = null;
|
|
55
|
+
let ENSLabel = null;
|
|
56
|
+
let ENSIcon = null;
|
|
57
|
+
if (cfxAddress && showAddressLabel) {
|
|
58
|
+
const addressLabels = globalData?.["CONFLUX_SCAN_ADDRESS_LABELS" /* addressLabel */];
|
|
59
|
+
addressLabel = addressLabels?.[cfxAddress];
|
|
60
|
+
}
|
|
61
|
+
if (cfxAddress && showNametag) {
|
|
62
|
+
officalNametag = nametag || nameInfo?.nametag;
|
|
63
|
+
}
|
|
64
|
+
if (showENSLabel && ensName) {
|
|
65
|
+
ENSLabel = ensName;
|
|
66
|
+
ENSIcon = /* @__PURE__ */ jsx(
|
|
67
|
+
"img",
|
|
68
|
+
{
|
|
69
|
+
src: ICON_ENS,
|
|
70
|
+
className: "w-[16px] h-[16px] mb-[3px] mr-[2px]",
|
|
71
|
+
alt: ""
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
innerName,
|
|
77
|
+
nametag: officalNametag,
|
|
78
|
+
addressLabel,
|
|
79
|
+
ENSLabel,
|
|
80
|
+
ENSIcon,
|
|
81
|
+
cfxAddress,
|
|
82
|
+
tokenName: props.tokenName || nameInfo?.tokenName,
|
|
83
|
+
contractName: props.contractName || nameInfo?.contractName,
|
|
84
|
+
verificationName: showVerificationName ? props.verificationName || nameInfo?.verificationName : void 0,
|
|
85
|
+
verify: props.verify || nameInfo?.verify,
|
|
86
|
+
ensName: props.ensName || nameInfo?.ensName,
|
|
87
|
+
isEspaceAddress: props.isEspaceAddress || nameInfo?.isEspaceAddress
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var CoreAddressContainer = withTranslation()(
|
|
91
|
+
memo((props) => {
|
|
92
|
+
const { globalData } = useGlobalData();
|
|
93
|
+
const unnecessaryEns = !!props.ensName || props.showENSLabel === false;
|
|
94
|
+
const { ens } = useENS(unnecessaryEns ? null : props.value);
|
|
95
|
+
if (!props.value && !props.contractCreated) {
|
|
96
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "--" });
|
|
97
|
+
}
|
|
98
|
+
const cfxAddress = formatAddress(props.value, "base32");
|
|
99
|
+
const defaultProps = {
|
|
100
|
+
isFull: false,
|
|
101
|
+
isFullNameTag: false,
|
|
102
|
+
link: true,
|
|
103
|
+
isMe: false,
|
|
104
|
+
showIcon: true,
|
|
105
|
+
verify: false,
|
|
106
|
+
showAddressLabel: true,
|
|
107
|
+
showENSLabel: true,
|
|
108
|
+
showNametag: true,
|
|
109
|
+
cfxAddress,
|
|
110
|
+
ensName: ens ? ens[cfxAddress]?.name : void 0
|
|
111
|
+
};
|
|
112
|
+
const mergeDefaultProps = _.assign({}, defaultProps, props);
|
|
113
|
+
const mergeParseProps = _.merge(
|
|
114
|
+
{},
|
|
115
|
+
mergeDefaultProps,
|
|
116
|
+
parseProps(mergeDefaultProps, globalData)
|
|
117
|
+
);
|
|
118
|
+
if (mergeParseProps.isPosAddress) {
|
|
119
|
+
return PosAddress(mergeParseProps);
|
|
120
|
+
}
|
|
121
|
+
if (!mergeParseProps.value && mergeParseProps.contractCreated) {
|
|
122
|
+
return ContractCreatedAddress({
|
|
123
|
+
...mergeParseProps,
|
|
124
|
+
outputType: "base32"
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (mergeParseProps.isEspaceAddress) {
|
|
128
|
+
return CoreHexAddress(mergeParseProps);
|
|
129
|
+
}
|
|
130
|
+
if (!isCoreAddress(mergeParseProps.value)) {
|
|
131
|
+
return InvalidAddress(mergeParseProps);
|
|
132
|
+
}
|
|
133
|
+
if (isCoreContractAddress(mergeParseProps.cfxAddress)) {
|
|
134
|
+
return ContractAddress(mergeParseProps);
|
|
135
|
+
}
|
|
136
|
+
if (mergeParseProps.isMe) {
|
|
137
|
+
return MyAddress(mergeParseProps);
|
|
138
|
+
}
|
|
139
|
+
return RenderAddress(mergeParseProps);
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
CoreAddressContainer
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=chunk-CNXGYDZG.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,IACA;AAAA,E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
|
10
|
+
|
|
11
|
+
// src/components/InputData/JsonDecode.tsx
|
|
12
|
+
import { useId, useMemo } from "react";
|
|
13
|
+
import "ace-builds/src-noconflict/mode-json";
|
|
14
|
+
import "ace-builds/src-noconflict/theme-tomorrow";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
var AceEditorStyle = {
|
|
17
|
+
width: "initial",
|
|
18
|
+
opacity: 0.62,
|
|
19
|
+
margin: "0.3571rem 0"
|
|
20
|
+
};
|
|
21
|
+
var JsonDecode = ({
|
|
22
|
+
decodedParams,
|
|
23
|
+
decodedResults,
|
|
24
|
+
abiItem,
|
|
25
|
+
input,
|
|
26
|
+
success,
|
|
27
|
+
name
|
|
28
|
+
}) => {
|
|
29
|
+
const id = useId();
|
|
30
|
+
const json = useMemo(() => {
|
|
31
|
+
try {
|
|
32
|
+
const signature = input.slice(0, 10);
|
|
33
|
+
const fullName = formatABI([abiItem])[0];
|
|
34
|
+
const minimalName = formatABI([abiItem], { minimal: true })[0];
|
|
35
|
+
const params = decodedParams.args && parseArgs(decodedParams.args, abiItem.inputs);
|
|
36
|
+
const returns = success ? decodedResults && parseArgs(decodedResults, abiItem.outputs ?? []) : decodedResults?.[0];
|
|
37
|
+
const json2 = {
|
|
38
|
+
name: abiItem.name,
|
|
39
|
+
fullName,
|
|
40
|
+
type: minimalName,
|
|
41
|
+
signature,
|
|
42
|
+
params,
|
|
43
|
+
returns
|
|
44
|
+
};
|
|
45
|
+
return JSON.stringify(json2, null, 4);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
}, [input, decodedParams, decodedResults, abiItem, success]);
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
|
+
AceEditor,
|
|
52
|
+
{
|
|
53
|
+
style: AceEditorStyle,
|
|
54
|
+
mode: "json",
|
|
55
|
+
theme: "tomorrow",
|
|
56
|
+
fontSize: "1rem",
|
|
57
|
+
showGutter: false,
|
|
58
|
+
showPrintMargin: false,
|
|
59
|
+
value: json,
|
|
60
|
+
readOnly: true,
|
|
61
|
+
height: "11.1429rem",
|
|
62
|
+
wrapEnabled: true,
|
|
63
|
+
name: name || id
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
JsonDecode
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=chunk-DASMAZXS.js.map
|
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
} from "./chunk-MWAD4CIG.js";
|
|
4
4
|
import {
|
|
5
5
|
RenderAddress
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-734CQOS7.js";
|
|
7
7
|
import {
|
|
8
8
|
formatAddress,
|
|
9
9
|
isInnerContractAddress
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BN3ATGHU.js";
|
|
11
11
|
import {
|
|
12
12
|
Tooltip
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-L7RD6ZPE.js";
|
|
14
14
|
import {
|
|
15
15
|
coreCorrespondsToEspace,
|
|
16
16
|
getNetwork
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-B5JCHBO3.js";
|
|
18
18
|
import {
|
|
19
19
|
getEnvConfig,
|
|
20
20
|
getTranslations,
|
|
@@ -209,4 +209,4 @@ export {
|
|
|
209
209
|
MyAddress,
|
|
210
210
|
PosAddress
|
|
211
211
|
};
|
|
212
|
-
//# sourceMappingURL=chunk-
|
|
212
|
+
//# sourceMappingURL=chunk-DO6PJAZB.js.map
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import {
|
|
2
|
+
publishRequestError
|
|
3
|
+
} from "./chunk-J2I22Q2M.js";
|
|
4
|
+
import {
|
|
5
|
+
fetchWithCache
|
|
6
|
+
} from "./chunk-YEINMVAR.js";
|
|
7
|
+
import {
|
|
8
|
+
getEnvConfig
|
|
9
|
+
} from "./chunk-DQGLZCIG.js";
|
|
10
|
+
|
|
11
|
+
// src/utils/request.ts
|
|
12
|
+
import qs from "query-string";
|
|
13
|
+
var TIMEOUT_TIMESTAMP = 6e4;
|
|
14
|
+
var checkStatus = (response) => {
|
|
15
|
+
if (response.status >= 200 && response.status < 300 || response.status === 600) {
|
|
16
|
+
return response;
|
|
17
|
+
} else {
|
|
18
|
+
const error = new Error(response.statusText);
|
|
19
|
+
error.name = "HttpError";
|
|
20
|
+
error.status = response.status;
|
|
21
|
+
error.response = response;
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var parseJSON = async (response) => {
|
|
26
|
+
const contentType = response.headers.get("content-type");
|
|
27
|
+
try {
|
|
28
|
+
if (contentType?.includes("application/json")) {
|
|
29
|
+
return { data: await response.json(), response };
|
|
30
|
+
} else if (contentType?.includes("text/html")) {
|
|
31
|
+
return { data: await response.text(), response };
|
|
32
|
+
} else {
|
|
33
|
+
return { data: response, response };
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error.name === "AbortError") {
|
|
37
|
+
return { data: response, response };
|
|
38
|
+
}
|
|
39
|
+
error.response = response;
|
|
40
|
+
error.status = 20001;
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var checkResponse = function(url, {
|
|
45
|
+
data,
|
|
46
|
+
response
|
|
47
|
+
}, opts) {
|
|
48
|
+
if (response.status === 200 && (data.status === "1" || data.code === 0)) {
|
|
49
|
+
return data.result || data.data;
|
|
50
|
+
} else if (/HEAD/i.test(opts?.method || "")) {
|
|
51
|
+
return response;
|
|
52
|
+
} else {
|
|
53
|
+
const code = Number(data.status ?? data.code);
|
|
54
|
+
const error = new Error(data.message);
|
|
55
|
+
error.response = data;
|
|
56
|
+
error.status = code;
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var fetchWithAbort = (url, options = {}) => {
|
|
61
|
+
const controller = new AbortController();
|
|
62
|
+
const opts = { ...options, signal: controller.signal };
|
|
63
|
+
const showErrorMessage = options.showErrorMessage ?? true;
|
|
64
|
+
const timeout = options.timeout || TIMEOUT_TIMESTAMP;
|
|
65
|
+
let timeoutId;
|
|
66
|
+
const promise = new Promise((resolve, reject) => {
|
|
67
|
+
timeoutId = setTimeout(() => {
|
|
68
|
+
controller.abort();
|
|
69
|
+
showErrorMessage && publishRequestError(
|
|
70
|
+
{ url, code: 20002, message: "Request timeout" },
|
|
71
|
+
"http"
|
|
72
|
+
);
|
|
73
|
+
reject(new Error("Request timeout"));
|
|
74
|
+
}, timeout);
|
|
75
|
+
window.fetch(url, opts).then(checkStatus).then(parseJSON).then((...args) => checkResponse(url, ...args, opts)).then((data) => resolve(data)).catch((error) => {
|
|
76
|
+
if (/HEAD/i.test(opts?.method || "")) {
|
|
77
|
+
return resolve({});
|
|
78
|
+
}
|
|
79
|
+
if (error.name === "TypeError") {
|
|
80
|
+
showErrorMessage && publishRequestError({ url, code: 20004 }, "http");
|
|
81
|
+
reject(new Error("Network error"));
|
|
82
|
+
} else if (error.name === "AbortError") {
|
|
83
|
+
showErrorMessage && publishRequestError(
|
|
84
|
+
{ url, code: 20003, message: "Fetch aborted" },
|
|
85
|
+
"http"
|
|
86
|
+
);
|
|
87
|
+
reject(new Error("Fetch aborted"));
|
|
88
|
+
} else {
|
|
89
|
+
showErrorMessage && publishRequestError(
|
|
90
|
+
{ url, code: error.status, message: error.message },
|
|
91
|
+
"http"
|
|
92
|
+
);
|
|
93
|
+
reject(error);
|
|
94
|
+
}
|
|
95
|
+
}).finally(() => clearTimeout(timeoutId));
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
promise,
|
|
99
|
+
abort: () => {
|
|
100
|
+
clearTimeout(timeoutId);
|
|
101
|
+
controller.abort();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
var fetch = (url, options = {}) => {
|
|
106
|
+
const { promise } = fetchWithAbort(url, options);
|
|
107
|
+
return promise;
|
|
108
|
+
};
|
|
109
|
+
var appendApiPrefix = (url) => {
|
|
110
|
+
if (url.startsWith("/stat/")) {
|
|
111
|
+
return url;
|
|
112
|
+
}
|
|
113
|
+
if (url.startsWith("http")) {
|
|
114
|
+
return url;
|
|
115
|
+
}
|
|
116
|
+
return `/v1${url.startsWith("/") ? url : "/" + url}`;
|
|
117
|
+
};
|
|
118
|
+
var fetchWithPrefix = (url, opts) => {
|
|
119
|
+
return fetch(appendApiPrefix(url), opts);
|
|
120
|
+
};
|
|
121
|
+
var fetchWithOpenApi = (url, opts) => {
|
|
122
|
+
const ENV_CONFIG = getEnvConfig();
|
|
123
|
+
if (!ENV_CONFIG.ENV_OPEN_API_HOST) {
|
|
124
|
+
throw new Error("ENV_OPEN_API_HOST is not set");
|
|
125
|
+
}
|
|
126
|
+
return fetch(
|
|
127
|
+
`${ENV_CONFIG.ENV_OPEN_API_HOST}${url.startsWith("/") ? url : "/" + url}`,
|
|
128
|
+
opts
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
var simpleGetFetcher = async (args) => {
|
|
132
|
+
let [url, query] = args;
|
|
133
|
+
if (query) {
|
|
134
|
+
url = qs.stringifyUrl({ url, query });
|
|
135
|
+
}
|
|
136
|
+
return await fetchWithPrefix(url, {
|
|
137
|
+
method: "get"
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
var queryAddress = (address) => {
|
|
141
|
+
return address.reduce((prev, curr, index) => {
|
|
142
|
+
return !index ? `address=${curr}` : `${prev}&address=${curr}`;
|
|
143
|
+
}, "");
|
|
144
|
+
};
|
|
145
|
+
var sendRequestChart = async (config) => {
|
|
146
|
+
try {
|
|
147
|
+
const res = await fetch(
|
|
148
|
+
qs.stringifyUrl({ url: config.url, query: config.query }),
|
|
149
|
+
{
|
|
150
|
+
method: config.type || "GET",
|
|
151
|
+
body: config.body,
|
|
152
|
+
headers: config.headers,
|
|
153
|
+
signal: config.signal
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
const data = res;
|
|
157
|
+
data.list = [...data.list || []].reverse();
|
|
158
|
+
return data;
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.error("Request failed", error);
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
var sendRequestENSInfo = async (url) => {
|
|
165
|
+
if (!url)
|
|
166
|
+
return {};
|
|
167
|
+
try {
|
|
168
|
+
const res = await fetch(url, {
|
|
169
|
+
method: "GET"
|
|
170
|
+
});
|
|
171
|
+
return res?.map;
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.error("Request failed", error);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
var sendRequestGasPrice = async () => {
|
|
178
|
+
try {
|
|
179
|
+
const res = await fetch(`/stat/gasprice/tracker`, {
|
|
180
|
+
method: "GET"
|
|
181
|
+
});
|
|
182
|
+
return res;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error("Request failed", error);
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var reqNametag = async (address) => {
|
|
189
|
+
const query = queryAddress(address);
|
|
190
|
+
const res = await fetch(`/v1/nametag?${query}`, {
|
|
191
|
+
method: "GET"
|
|
192
|
+
});
|
|
193
|
+
return res?.map;
|
|
194
|
+
};
|
|
195
|
+
var reqContractAndToken = fetchWithCache(
|
|
196
|
+
async (address) => {
|
|
197
|
+
const query = queryAddress(address);
|
|
198
|
+
const res = await fetch(`/v1/contract-and-token?${query}`, {
|
|
199
|
+
method: "GET"
|
|
200
|
+
});
|
|
201
|
+
return res;
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
key: "contract-and-token",
|
|
205
|
+
maxAge: 1e3 * 60 * 60
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
var getContractDetail = fetchWithCache(
|
|
209
|
+
(contractAddress, fields = []) => {
|
|
210
|
+
const url = qs.stringifyUrl({
|
|
211
|
+
url: `/v1/contract/${contractAddress}`,
|
|
212
|
+
query: { fields }
|
|
213
|
+
});
|
|
214
|
+
return fetch(url, {
|
|
215
|
+
method: "GET"
|
|
216
|
+
});
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
key: "contract-detail",
|
|
220
|
+
maxAge: 1e3 * 60 * 60
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
var detectAccountType = fetchWithCache(
|
|
224
|
+
(address) => {
|
|
225
|
+
return fetchWithOpenApi(
|
|
226
|
+
`/util/detectAccountType?hex=${address}`,
|
|
227
|
+
{
|
|
228
|
+
method: "GET"
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
// 10 seconds
|
|
234
|
+
maxAge: 1e3 * 10
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
var reqAbiByMethodId = (methodId) => {
|
|
238
|
+
return fetchWithPrefix(
|
|
239
|
+
qs.stringifyUrl({
|
|
240
|
+
url: "/stat/list-abi-method",
|
|
241
|
+
query: {
|
|
242
|
+
id: methodId
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
var fetchAddressNameMap = (addresses, params = {}) => {
|
|
248
|
+
const url = qs.stringifyUrl({
|
|
249
|
+
url: "/account/infos",
|
|
250
|
+
query: {
|
|
251
|
+
accounts: addresses.join(","),
|
|
252
|
+
...params
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return fetchWithOpenApi(url, {
|
|
256
|
+
method: "GET"
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export {
|
|
261
|
+
fetch,
|
|
262
|
+
appendApiPrefix,
|
|
263
|
+
fetchWithPrefix,
|
|
264
|
+
fetchWithOpenApi,
|
|
265
|
+
simpleGetFetcher,
|
|
266
|
+
sendRequestChart,
|
|
267
|
+
sendRequestENSInfo,
|
|
268
|
+
sendRequestGasPrice,
|
|
269
|
+
reqNametag,
|
|
270
|
+
reqContractAndToken,
|
|
271
|
+
getContractDetail,
|
|
272
|
+
detectAccountType,
|
|
273
|
+
reqAbiByMethodId,
|
|
274
|
+
fetchAddressNameMap
|
|
275
|
+
};
|
|
276
|
+
//# sourceMappingURL=chunk-E7FB4S3X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/request.ts"],"sourcesContent":["import qs from 'query-string';\nimport { publishRequestError } from './pubsub';\nimport {\n AddressNameMap,\n BaseContractInfo,\n DetectAccountTypeResponse,\n MethodAbiItemResponse,\n} from './request.types';\nimport { getEnvConfig } from '../store';\nimport { fetchWithCache } from './cache';\ninterface FetchWithAbortType<T> {\n promise: Promise<T>;\n abort: () => void;\n}\n\ninterface FetchOptions extends RequestInit {\n timeout?: number;\n showErrorMessage?: boolean;\n}\n\nconst TIMEOUT_TIMESTAMP = 60000;\n\nconst checkStatus = (response: Response) => {\n if (\n (response.status >= 200 && response.status < 300) ||\n response.status === 600\n ) {\n return response;\n } else {\n const error = new Error(response.statusText);\n error.name = 'HttpError';\n (error as any).status = response.status;\n (error as any).response = response;\n throw error;\n }\n};\n\n// 格式化 response data\nconst parseJSON = async (response: Response) => {\n const contentType = response.headers.get('content-type');\n try {\n if (contentType?.includes('application/json')) {\n return { data: await response.json(), response };\n } else if (contentType?.includes('text/html')) {\n return { data: await response.text(), response };\n } else {\n // contentType 还有其他类型,目前项目中用不到\n // 不能简单的报错,比如 image/x-icon 是 favicon 请求\n // 此处直接返回 response,由业务代码处理其他类型的数据\n return { data: response, response };\n }\n } catch (error) {\n if ((error as any).name === 'AbortError') {\n return { data: response, response };\n }\n (error as any).response = response;\n (error as any).status = 20001;\n throw error;\n }\n};\n\n// 检查返回值中是否包含错误\nconst checkResponse = function (\n url: string,\n {\n data,\n response,\n }: {\n data: any;\n response: Response;\n },\n opts: FetchOptions,\n) {\n // 兼容 data.code 和 data.data, 是关于 core space 的数据结构\n if (response.status === 200 && (data.status === '1' || data.code === 0)) {\n return data.result || data.data;\n } else if (/HEAD/i.test(opts?.method || '')) {\n // handle of HEAD method\n return response;\n } else {\n const code = Number(data.status ?? data.code);\n const error: Partial<ErrorEvent> & {\n response?: ResponseType;\n status?: number;\n } = new Error(data.message);\n error.response = data;\n error.status = code;\n throw error;\n }\n};\n\nconst fetchWithAbort = <T>(\n url: string,\n options: FetchOptions = {},\n): FetchWithAbortType<T> => {\n const controller = new AbortController();\n const opts: FetchOptions = { ...options, signal: controller.signal };\n const showErrorMessage = options.showErrorMessage ?? true;\n const timeout = options.timeout || TIMEOUT_TIMESTAMP;\n\n let timeoutId: ReturnType<typeof setTimeout>;\n const promise: Promise<T> = new Promise((resolve, reject) => {\n timeoutId = setTimeout(() => {\n controller.abort();\n showErrorMessage &&\n publishRequestError(\n { url, code: 20002, message: 'Request timeout' },\n 'http',\n );\n reject(new Error('Request timeout'));\n }, timeout);\n\n window\n .fetch(url, opts)\n .then(checkStatus)\n .then(parseJSON)\n .then((...args) => checkResponse(url, ...args, opts))\n .then(data => resolve(data as T))\n .catch(error => {\n if (/HEAD/i.test(opts?.method || '')) {\n return resolve({} as T);\n }\n\n // A fetch() promise will reject with a TypeError when a network error is encountered or CORS is misconfigured on the server-side,\n // although this usually means permission issues or similar — a 404 does not constitute a network error, for example.\n // For detail: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch\n if (error.name === 'TypeError') {\n showErrorMessage && publishRequestError({ url, code: 20004 }, 'http');\n reject(new Error('Network error'));\n } else if (error.name === 'AbortError') {\n showErrorMessage &&\n publishRequestError(\n { url, code: 20003, message: 'Fetch aborted' },\n 'http',\n );\n reject(new Error('Fetch aborted'));\n } else {\n showErrorMessage &&\n publishRequestError(\n { url, code: (error as any).status, message: error.message },\n 'http',\n );\n reject(error);\n }\n })\n .finally(() => clearTimeout(timeoutId));\n });\n\n return {\n promise,\n abort: () => {\n clearTimeout(timeoutId);\n controller.abort();\n },\n };\n};\n\nexport const fetch = <T>(\n url: string,\n options: FetchOptions = {},\n): Promise<T> => {\n const { promise } = fetchWithAbort<T>(url, options);\n return promise;\n};\n\nexport const appendApiPrefix = (url: string) => {\n // for cfx top N\n if (url.startsWith('/stat/')) {\n return url;\n }\n if (url.startsWith('http')) {\n return url;\n }\n return `/v1${url.startsWith('/') ? url : '/' + url}`;\n};\n\nexport const fetchWithPrefix = <T>(url: string, opts?: FetchOptions) => {\n return fetch<T>(appendApiPrefix(url), opts);\n};\n\nexport const fetchWithOpenApi = <T>(url: string, opts?: FetchOptions) => {\n const ENV_CONFIG = getEnvConfig();\n if (!ENV_CONFIG.ENV_OPEN_API_HOST) {\n throw new Error('ENV_OPEN_API_HOST is not set');\n }\n return fetch<T>(\n `${ENV_CONFIG.ENV_OPEN_API_HOST}${url.startsWith('/') ? url : '/' + url}`,\n opts,\n );\n};\n\nexport const simpleGetFetcher = async <T>(args: any[]) => {\n let [url, query] = args;\n if (query) {\n url = qs.stringifyUrl({ url, query });\n }\n return await fetchWithPrefix<T>(url, {\n method: 'get',\n });\n};\n\ntype RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';\ninterface QueryParams {\n [key: string]: string | undefined;\n}\ninterface Config {\n url: string;\n query: QueryParams;\n type?: RequestMethod;\n body?: any;\n headers?: Headers;\n signal?: AbortSignal;\n}\n\nconst queryAddress = (address: string[]) => {\n return address.reduce((prev, curr, index) => {\n return !index ? `address=${curr}` : `${prev}&address=${curr}`;\n }, '');\n};\n\nexport const sendRequestChart = async (config: Config) => {\n try {\n const res: any = await fetch(\n qs.stringifyUrl({ url: config.url, query: config.query }),\n {\n method: config.type || 'GET',\n body: config.body,\n headers: config.headers,\n signal: config.signal,\n },\n );\n const data = res;\n data.list = [...(data.list || [])].reverse();\n return data;\n } catch (error) {\n console.error('Request failed', error);\n throw error;\n }\n};\n\nexport const sendRequestENSInfo = async (url?: string | null) => {\n if (!url) return {};\n try {\n const res: any = await fetch(url, {\n method: 'GET',\n });\n\n return res?.map;\n } catch (error) {\n console.error('Request failed', error);\n throw error;\n }\n};\n\nexport const sendRequestGasPrice = async () => {\n try {\n const res: any = await fetch(`/stat/gasprice/tracker`, {\n method: 'GET',\n });\n return res;\n } catch (error) {\n console.error('Request failed', error);\n throw error;\n }\n};\n\nexport const reqNametag = async (address: string[]) => {\n const query = queryAddress(address);\n\n const res: any = await fetch(`/v1/nametag?${query}`, {\n method: 'GET',\n });\n return res?.map;\n};\n\nexport const reqContractAndToken = fetchWithCache(\n async (address: string[]) => {\n const query = queryAddress(address);\n\n const res: any = await fetch(`/v1/contract-and-token?${query}`, {\n method: 'GET',\n });\n return res;\n },\n {\n key: 'contract-and-token',\n maxAge: 1000 * 60 * 60,\n },\n);\n\nexport const getContractDetail = fetchWithCache(\n <T extends string>(contractAddress?: string, fields: T[] = []) => {\n const url = qs.stringifyUrl({\n url: `/v1/contract/${contractAddress}`,\n query: { fields },\n });\n\n return fetch<BaseContractInfo & Record<T, unknown>>(url, {\n method: 'GET',\n });\n },\n {\n key: 'contract-detail',\n maxAge: 1000 * 60 * 60,\n },\n);\n\nexport const detectAccountType = fetchWithCache(\n (address: string) => {\n return fetchWithOpenApi<DetectAccountTypeResponse>(\n `/util/detectAccountType?hex=${address}`,\n {\n method: 'GET',\n },\n );\n },\n {\n // 10 seconds\n maxAge: 1000 * 10,\n },\n);\n\nexport const reqAbiByMethodId = (methodId: string) => {\n return fetchWithPrefix<{\n list: MethodAbiItemResponse[];\n }>(\n qs.stringifyUrl({\n url: '/stat/list-abi-method',\n query: {\n id: methodId,\n },\n }),\n );\n};\n\nexport const fetchAddressNameMap = (\n addresses: string[],\n params: {\n withContractInfo?: 'true' | 'false';\n withNameTagInfo?: 'true' | 'false';\n withENSInfo?: 'true' | 'false';\n } = {},\n) => {\n const url = qs.stringifyUrl({\n url: '/account/infos',\n query: {\n accounts: addresses.join(','),\n ...params,\n },\n });\n return fetchWithOpenApi<Record<string, AddressNameMap>>(url, {\n method: 'GET',\n });\n};\n"],"mappings":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,KAAK;AAAA,IACL,QAAQ,MAAO,KAAK;AAAA,EACtB;AACF;AAEO,IAAM,oBAAoB;AAAA,EAC/B,CAAmB,iBAA0B,SAAc,CAAC,MAAM;AAChE,UAAM,MAAM,GAAG,aAAa;AAAA,MAC1B,KAAK,gBAAgB;AAAA,MACrB,OAAO,EAAE,OAAO;AAAA,IAClB,CAAC;AAED,WAAO,MAA6C,KAAK;AAAA,MACvD,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,QAAQ,MAAO,KAAK;AAAA,EACtB;AACF;AAEO,IAAM,oBAAoB;AAAA,EAC/B,CAAC,YAAoB;AACnB,WAAO;AAAA,MACL,+BAA+B;AAAA,MAC/B;AAAA,QACE,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA;AAAA,IAEE,QAAQ,MAAO;AAAA,EACjB;AACF;AAEO,IAAM,mBAAmB,CAAC,aAAqB;AACpD,SAAO;AAAA,IAGL,GAAG,aAAa;AAAA,MACd,KAAK;AAAA,MACL,OAAO;AAAA,QACL,IAAI;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,sBAAsB,CACjC,WACA,SAII,CAAC,MACF;AACH,QAAM,MAAM,GAAG,aAAa;AAAA,IAC1B,KAAK;AAAA,IACL,OAAO;AAAA,MACL,UAAU,UAAU,KAAK,GAAG;AAAA,MAC5B,GAAG;AAAA,IACL;AAAA,EACF,CAAC;AACD,SAAO,iBAAiD,KAAK;AAAA,IAC3D,QAAQ;AAAA,EACV,CAAC;AACH;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAddressLabel
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VEK5DLFI.js";
|
|
4
4
|
import {
|
|
5
5
|
useENS
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-O6BP54O6.js";
|
|
7
7
|
import {
|
|
8
8
|
Text
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4B7BV62E.js";
|
|
10
10
|
import {
|
|
11
11
|
getTranslations
|
|
12
12
|
} from "./chunk-DQGLZCIG.js";
|
|
@@ -48,4 +48,4 @@ var AddressLabel = ({
|
|
|
48
48
|
export {
|
|
49
49
|
AddressLabel
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-EHRGH3HS.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useAddressLabel
|
|
3
|
+
} from "./chunk-BGNBKP5R.js";
|
|
4
|
+
import {
|
|
5
|
+
useENS
|
|
6
|
+
} from "./chunk-225VMTCA.js";
|
|
7
|
+
import {
|
|
8
|
+
Text
|
|
9
|
+
} from "./chunk-YOVNVFY2.js";
|
|
10
|
+
import {
|
|
11
|
+
getTranslations
|
|
12
|
+
} from "./chunk-DQGLZCIG.js";
|
|
13
|
+
|
|
14
|
+
// src/components/InputData/AddressLabel.tsx
|
|
15
|
+
import { Bookmark } from "@zeit-ui/react-icons";
|
|
16
|
+
import { useTranslation } from "react-i18next";
|
|
17
|
+
import ICON_ENS from "./logo-cns-7CXISC6I.svg";
|
|
18
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
var ENSIcon = () => /* @__PURE__ */ jsx("img", { src: ICON_ENS, className: "w-[16px] h-[16px] mb-[3px] mr-[2px]", alt: "" });
|
|
20
|
+
var AddressLabel = ({
|
|
21
|
+
address,
|
|
22
|
+
space
|
|
23
|
+
}) => {
|
|
24
|
+
const translations = getTranslations();
|
|
25
|
+
const { ens } = useENS(space === "core" ? address : null);
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
const addressLabel = useAddressLabel(address);
|
|
28
|
+
const label = ens[address]?.name ?? "";
|
|
29
|
+
const addressLabelIcon = /* @__PURE__ */ jsx(Text, { tag: "span", hoverValue: t(translations.profile.tip.label), children: /* @__PURE__ */ jsx(Bookmark, { color: "var(--theme-color-gray2)", size: 16 }) });
|
|
30
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
label && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
32
|
+
" ",
|
|
33
|
+
"(",
|
|
34
|
+
/* @__PURE__ */ jsx(ENSIcon, {}),
|
|
35
|
+
label,
|
|
36
|
+
")"
|
|
37
|
+
] }),
|
|
38
|
+
addressLabel && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
+
" ",
|
|
40
|
+
"(",
|
|
41
|
+
addressLabelIcon,
|
|
42
|
+
addressLabel,
|
|
43
|
+
")"
|
|
44
|
+
] })
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
AddressLabel
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=chunk-EOSVUB2G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/InputData/AddressLabel.tsx"],"sourcesContent":["import { Bookmark } from '@zeit-ui/react-icons';\nimport { useTranslation } from 'react-i18next';\nimport { Text } from '../Text';\nimport { getTranslations } from 'src/store';\nimport { useENS } from 'src/utils/hooks/useENS';\nimport { useAddressLabel } from 'src/utils/hooks/useAddressLabel';\nimport ICON_ENS from '../../images/logo-cns.svg';\n\nconst ENSIcon = () => (\n <img src={ICON_ENS} className=\"w-[16px] h-[16px] mb-[3px] mr-[2px]\" alt=\"\" />\n);\n\nexport const AddressLabel = ({\n address,\n space,\n}: {\n address: string;\n space: 'evm' | 'core';\n}) => {\n const translations = getTranslations();\n // ENS is only for core space, and we don't want to request ENS info for evm space to avoid unnecessary requests\n const { ens } = useENS(space === 'core' ? address : null);\n const { t } = useTranslation();\n\n const addressLabel = useAddressLabel(address);\n\n const label = ens[address]?.name ?? '';\n\n const addressLabelIcon = (\n <Text tag=\"span\" hoverValue={t(translations.profile.tip.label)}>\n <Bookmark color=\"var(--theme-color-gray2)\" size={16} />\n </Text>\n );\n\n return (\n <>\n {label && (\n <>\n {' '}\n (<ENSIcon />\n {label})\n </>\n )}\n {addressLabel && (\n <>\n {' '}\n ({addressLabelIcon}\n {addressLabel})\n </>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAK/B,OAAO,cAAc;AAGnB,SA4BM,UA5BN,KA4BM,YA5BN;AADF,IAAM,UAAU,MACd,oBAAC,SAAI,KAAK,UAAU,WAAU,uCAAsC,KAAI,IAAG;AAGtE,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AACF,MAGM;AACJ,QAAM,eAAe,gBAAgB;AAErC,QAAM,EAAE,IAAI,IAAI,OAAO,UAAU,SAAS,UAAU,IAAI;AACxD,QAAM,EAAE,EAAE,IAAI,eAAe;AAE7B,QAAM,eAAe,gBAAgB,OAAO;AAE5C,QAAM,QAAQ,IAAI,OAAO,GAAG,QAAQ;AAEpC,QAAM,mBACJ,oBAAC,QAAK,KAAI,QAAO,YAAY,EAAE,aAAa,QAAQ,IAAI,KAAK,GAC3D,8BAAC,YAAS,OAAM,4BAA2B,MAAM,IAAI,GACvD;AAGF,SACE,iCACG;AAAA,aACC,iCACG;AAAA;AAAA,MAAI;AAAA,MACJ,oBAAC,WAAQ;AAAA,MACT;AAAA,MAAM;AAAA,OACT;AAAA,IAED,gBACC,iCACG;AAAA;AAAA,MAAI;AAAA,MACH;AAAA,MACD;AAAA,MAAa;AAAA,OAChB;AAAA,KAEJ;AAEJ;","names":[]}
|