@cfxjs/sirius-next-common 0.2.19 → 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-S7M6UTND.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-C3E5EA6J.js → chunk-734CQOS7.js} +10 -10
- package/dist/{chunk-C3E5EA6J.js.map → chunk-734CQOS7.js.map} +1 -1
- 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-GPQN2P32.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-TC4445WV.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-MUW5KBWU.js → chunk-RWTNG7SM.js} +8 -4
- package/dist/chunk-RWTNG7SM.js.map +1 -0
- 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.d.ts +7 -2
- package/dist/utils/hooks/useAddressNameMap.js +4 -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.d.ts +1 -4
- package/dist/utils/hooks/useEnhanceDataWithNameMap.js +3 -6
- package/dist/utils/hooks/useEnhanceDataWithNameMap.js.map +1 -1
- 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-MUW5KBWU.js.map +0 -1
- 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-S7M6UTND.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-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-GPQN2P32.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-TC4445WV.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-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,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decodeErrorResult
|
|
3
|
+
} from "./chunk-6SXAFSBF.js";
|
|
4
|
+
import {
|
|
5
|
+
useContractDetail
|
|
6
|
+
} from "./chunk-OFAM2QTT.js";
|
|
7
|
+
import {
|
|
8
|
+
CommonError_default
|
|
9
|
+
} from "./chunk-5TGK2EA2.js";
|
|
10
|
+
import {
|
|
11
|
+
CommonPanic_default
|
|
12
|
+
} from "./chunk-ADNS57X5.js";
|
|
13
|
+
import {
|
|
14
|
+
COMMON_ERROR_OUTPUT_PREFIX,
|
|
15
|
+
COMMON_PANIC_OUTPUT_PREFIX
|
|
16
|
+
} from "./chunk-WIB76E7O.js";
|
|
17
|
+
|
|
18
|
+
// src/utils/hooks/useDecodeFunctionError.ts
|
|
19
|
+
import { useMemo } from "react";
|
|
20
|
+
var fields = ["abi"];
|
|
21
|
+
var useDecodeFunctionError = ({
|
|
22
|
+
to,
|
|
23
|
+
implementation: _implementation,
|
|
24
|
+
errorData,
|
|
25
|
+
space
|
|
26
|
+
}) => {
|
|
27
|
+
const standardErrorAbi = useMemo(() => {
|
|
28
|
+
if (!errorData)
|
|
29
|
+
return null;
|
|
30
|
+
if (errorData.startsWith(COMMON_ERROR_OUTPUT_PREFIX))
|
|
31
|
+
return CommonError_default;
|
|
32
|
+
if (errorData.startsWith(COMMON_PANIC_OUTPUT_PREFIX))
|
|
33
|
+
return CommonPanic_default;
|
|
34
|
+
return null;
|
|
35
|
+
}, [errorData]);
|
|
36
|
+
const { data, isLoading: contractLoading } = useContractDetail(
|
|
37
|
+
to,
|
|
38
|
+
fields,
|
|
39
|
+
!standardErrorAbi && !!errorData
|
|
40
|
+
);
|
|
41
|
+
const implementation = _implementation ?? data?.implementation?.address;
|
|
42
|
+
const { data: implementationData, isLoading: implementationLoading } = useContractDetail(implementation, fields, !standardErrorAbi && !!errorData);
|
|
43
|
+
const decodedByStandardError = useMemo(() => {
|
|
44
|
+
if (!standardErrorAbi || !errorData)
|
|
45
|
+
return null;
|
|
46
|
+
try {
|
|
47
|
+
const result = decodeErrorResult({
|
|
48
|
+
abi: standardErrorAbi,
|
|
49
|
+
data: errorData,
|
|
50
|
+
space
|
|
51
|
+
});
|
|
52
|
+
return result;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.log("decode error data with standard error abi failed", error);
|
|
55
|
+
return {
|
|
56
|
+
errorName: "unknown",
|
|
57
|
+
failed: true
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}, [errorData, standardErrorAbi, space]);
|
|
61
|
+
const decoded = useMemo(() => {
|
|
62
|
+
if (!data?.abi || !errorData)
|
|
63
|
+
return null;
|
|
64
|
+
try {
|
|
65
|
+
const result = decodeErrorResult({
|
|
66
|
+
abi: JSON.parse(data.abi),
|
|
67
|
+
data: errorData,
|
|
68
|
+
space
|
|
69
|
+
});
|
|
70
|
+
return result;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.log("decode error data with contract abi failed", error);
|
|
73
|
+
return {
|
|
74
|
+
errorName: "unknown",
|
|
75
|
+
failed: true
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}, [errorData, data, space]);
|
|
79
|
+
const decodedByImplementation = useMemo(() => {
|
|
80
|
+
if (!implementationData?.abi || !errorData)
|
|
81
|
+
return null;
|
|
82
|
+
try {
|
|
83
|
+
const result = decodeErrorResult({
|
|
84
|
+
abi: JSON.parse(implementationData.abi),
|
|
85
|
+
data: errorData,
|
|
86
|
+
space
|
|
87
|
+
});
|
|
88
|
+
return result;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.log("decode error data with implementation abi failed", error);
|
|
91
|
+
return {
|
|
92
|
+
errorName: "unknown",
|
|
93
|
+
failed: true
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}, [errorData, implementationData, space]);
|
|
97
|
+
return useMemo(() => {
|
|
98
|
+
if (!errorData)
|
|
99
|
+
return [null, false];
|
|
100
|
+
if (decodedByStandardError && !decodedByStandardError.failed)
|
|
101
|
+
return [decodedByStandardError, false];
|
|
102
|
+
if (decodedByImplementation && !decodedByImplementation.failed)
|
|
103
|
+
return [decodedByImplementation, implementationLoading];
|
|
104
|
+
if (decoded && !decoded.failed)
|
|
105
|
+
return [decoded, contractLoading];
|
|
106
|
+
if (contractLoading || implementationLoading)
|
|
107
|
+
return [null, true];
|
|
108
|
+
return [
|
|
109
|
+
{
|
|
110
|
+
errorName: "unknown",
|
|
111
|
+
noAbi: !decodedByStandardError && !decodedByImplementation && !decoded,
|
|
112
|
+
failed: decodedByImplementation?.failed || decoded?.failed || decodedByStandardError?.failed
|
|
113
|
+
},
|
|
114
|
+
false
|
|
115
|
+
];
|
|
116
|
+
}, [
|
|
117
|
+
errorData,
|
|
118
|
+
decodedByStandardError,
|
|
119
|
+
decoded,
|
|
120
|
+
decodedByImplementation,
|
|
121
|
+
contractLoading,
|
|
122
|
+
implementationLoading,
|
|
123
|
+
space
|
|
124
|
+
]);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export {
|
|
128
|
+
useDecodeFunctionError
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=chunk-C6GUZVQ2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/hooks/useDecodeFunctionError.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { decodeErrorResult } from 'src/utils/sdk';\nimport type { AbiItem } from 'src/utils/sdk';\nimport { useContractDetail } from './useContractDetail';\nimport {\n COMMON_ERROR_OUTPUT_PREFIX,\n COMMON_PANIC_OUTPUT_PREFIX,\n} from '../constants';\nimport CommonError from 'src/abis/CommonError';\nimport CommonPanic from 'src/abis/CommonPanic';\n\nconst fields = ['abi' as const];\n\ninterface Result {\n abiItem?: AbiItem;\n args?: readonly unknown[];\n errorName: string;\n // no abi for decoded\n noAbi?: boolean;\n // decoded failed\n failed?: boolean;\n}\n\nexport const useDecodeFunctionError = ({\n to,\n implementation: _implementation,\n errorData,\n space,\n}: {\n errorData?: `0x${string}`;\n to?: string;\n implementation?: string;\n space: 'evm' | 'core';\n}): [Result | null, boolean] => {\n const standardErrorAbi = useMemo(() => {\n if (!errorData) return null;\n if (errorData.startsWith(COMMON_ERROR_OUTPUT_PREFIX)) return CommonError;\n if (errorData.startsWith(COMMON_PANIC_OUTPUT_PREFIX)) return CommonPanic;\n return null;\n }, [errorData]);\n const { data, isLoading: contractLoading } = useContractDetail(\n to,\n fields,\n !standardErrorAbi && !!errorData,\n );\n const implementation = _implementation ?? data?.implementation?.address;\n const { data: implementationData, isLoading: implementationLoading } =\n useContractDetail(implementation, fields, !standardErrorAbi && !!errorData);\n const decodedByStandardError = useMemo(() => {\n if (!standardErrorAbi || !errorData) return null;\n try {\n const result = decodeErrorResult({\n abi: standardErrorAbi,\n data: errorData,\n space,\n });\n return result as Result;\n } catch (error) {\n console.log('decode error data with standard error abi failed', error);\n return {\n errorName: 'unknown',\n failed: true,\n };\n }\n }, [errorData, standardErrorAbi, space]);\n const decoded = useMemo(() => {\n if (!data?.abi || !errorData) return null;\n try {\n const result = decodeErrorResult({\n abi: JSON.parse(data.abi as string),\n data: errorData,\n space,\n });\n return result as Result;\n } catch (error) {\n console.log('decode error data with contract abi failed', error);\n return {\n errorName: 'unknown',\n failed: true,\n };\n }\n }, [errorData, data, space]);\n const decodedByImplementation = useMemo(() => {\n if (!implementationData?.abi || !errorData) return null;\n try {\n const result = decodeErrorResult({\n abi: JSON.parse(implementationData.abi as string),\n data: errorData,\n space,\n });\n return result as Result;\n } catch (error) {\n console.log('decode error data with implementation abi failed', error);\n return {\n errorName: 'unknown',\n failed: true,\n };\n }\n }, [errorData, implementationData, space]);\n\n return useMemo(() => {\n if (!errorData) return [null, false];\n if (decodedByStandardError && !decodedByStandardError.failed)\n return [decodedByStandardError, false];\n if (decodedByImplementation && !decodedByImplementation.failed)\n return [decodedByImplementation, implementationLoading];\n if (decoded && !decoded.failed) return [decoded, contractLoading];\n if (contractLoading || implementationLoading) return [null, true];\n return [\n {\n errorName: 'unknown',\n noAbi: !decodedByStandardError && !decodedByImplementation && !decoded,\n failed:\n decodedByImplementation?.failed ||\n decoded?.failed ||\n decodedByStandardError?.failed,\n },\n false,\n ];\n }, [\n errorData,\n decodedByStandardError,\n decoded,\n decodedByImplementation,\n contractLoading,\n implementationLoading,\n space,\n ]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AAWxB,IAAM,SAAS,CAAC,KAAc;AAYvB,IAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AACF,MAKgC;AAC9B,QAAM,mBAAmB,QAAQ,MAAM;AACr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QAAI,CAAC,oBAAoB,OAAO,CAAC;AAAW,aAAO;AACnD,QAAI;AACF,YAAM,SAAS,kBAAkB;AAAA,QAC/B,KAAK,KAAK,MAAM,mBAAmB,GAAa;AAAA,QAChD,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AACD,aAAO;AAAA,IACT,SAAS,OAAP;AACA,cAAQ,IAAI,oDAAoD,KAAK;AACrE,aAAO;AAAA,QACL,WAAW;AAAA,QACX,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,oBAAoB,KAAK,CAAC;AAEzC,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC;AAAW,aAAO,CAAC,MAAM,KAAK;AACnC,QAAI,0BAA0B,CAAC,uBAAuB;AACpD,aAAO,CAAC,wBAAwB,KAAK;AACvC,QAAI,2BAA2B,CAAC,wBAAwB;AACtD,aAAO,CAAC,yBAAyB,qBAAqB;AACxD,QAAI,WAAW,CAAC,QAAQ;AAAQ,aAAO,CAAC,SAAS,eAAe;AAChE,QAAI,mBAAmB;AAAuB,aAAO,CAAC,MAAM,IAAI;AAChE,WAAO;AAAA,MACL;AAAA,QACE,WAAW;AAAA,QACX,OAAO,CAAC,0BAA0B,CAAC,2BAA2B,CAAC;AAAA,QAC/D,QACE,yBAAyB,UACzB,SAAS,UACT,wBAAwB;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -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 R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O,UAAU,eAAe;AAAA,IAClC;AAEA,WAAO,cAAc,eAAe;AAAA,EACtC,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseArgs
|
|
3
|
+
} from "./chunk-XI5WO2NW.js";
|
|
4
|
+
import {
|
|
5
|
+
AceEditor
|
|
6
|
+
} from "./chunk-R62HRSIY.js";
|
|
7
|
+
import {
|
|
8
|
+
formatABI
|
|
9
|
+
} from "./chunk-SNUPCZY7.js";
|
|
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
|