@cfxjs/sirius-next-common 0.1.34 → 0.1.35
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-2CYC4UWO.js +108 -0
- package/dist/chunk-2CYC4UWO.js.map +1 -0
- package/dist/chunk-3DYO4SUL.js +63 -0
- package/dist/chunk-3DYO4SUL.js.map +1 -0
- package/dist/chunk-43ZMPNVA.js +3629 -0
- package/dist/chunk-43ZMPNVA.js.map +1 -0
- package/dist/chunk-44PF4ZKF.js +63 -0
- package/dist/chunk-44PF4ZKF.js.map +1 -0
- package/dist/chunk-4AI26PND.js +150 -0
- package/dist/chunk-4AI26PND.js.map +1 -0
- package/dist/chunk-4JCWYUNH.js +275 -0
- package/dist/chunk-4JCWYUNH.js.map +1 -0
- package/dist/chunk-4N3GNHIP.js +108 -0
- package/dist/chunk-4N3GNHIP.js.map +1 -0
- package/dist/chunk-4RBTXO3A.js +108 -0
- package/dist/chunk-4RBTXO3A.js.map +1 -0
- package/dist/chunk-64PFHUWF.js +141 -0
- package/dist/chunk-64PFHUWF.js.map +1 -0
- package/dist/chunk-6CSRI3HH.js +141 -0
- package/dist/chunk-6CSRI3HH.js.map +1 -0
- package/dist/chunk-6RUCML36.js +108 -0
- package/dist/chunk-6RUCML36.js.map +1 -0
- package/dist/chunk-72ZLP3KN.js +3629 -0
- package/dist/chunk-72ZLP3KN.js.map +1 -0
- package/dist/chunk-7GW7YPXK.js +127 -0
- package/dist/chunk-7GW7YPXK.js.map +1 -0
- package/dist/chunk-7M5S36LE.js +2324 -0
- package/dist/chunk-7M5S36LE.js.map +1 -0
- package/dist/chunk-7MUTGZCN.js +63 -0
- package/dist/chunk-7MUTGZCN.js.map +1 -0
- package/dist/chunk-7OSWOC4R.js +3629 -0
- package/dist/chunk-7OSWOC4R.js.map +1 -0
- package/dist/chunk-A474G2N6.js +63 -0
- package/dist/chunk-A474G2N6.js.map +1 -0
- package/dist/chunk-ARALCU4G.js +150 -0
- package/dist/chunk-ARALCU4G.js.map +1 -0
- package/dist/chunk-B2SL7FHW.js +63 -0
- package/dist/chunk-B2SL7FHW.js.map +1 -0
- package/dist/chunk-BEZT4KEG.js +273 -0
- package/dist/chunk-BEZT4KEG.js.map +1 -0
- package/dist/chunk-BHHLS3OI.js +212 -0
- package/dist/chunk-BHHLS3OI.js.map +1 -0
- package/dist/chunk-BR2HJ226.js +150 -0
- package/dist/chunk-BR2HJ226.js.map +1 -0
- package/dist/chunk-BWWA4QW5.js +63 -0
- package/dist/chunk-BWWA4QW5.js.map +1 -0
- package/dist/chunk-BYNC3ECF.js +2324 -0
- package/dist/chunk-BYNC3ECF.js.map +1 -0
- package/dist/chunk-C35VFER4.js +141 -0
- package/dist/chunk-C35VFER4.js.map +1 -0
- package/dist/chunk-CLNWUZHH.js +108 -0
- package/dist/chunk-CLNWUZHH.js.map +1 -0
- package/dist/chunk-CN4VFYDL.js +212 -0
- package/dist/chunk-CN4VFYDL.js.map +1 -0
- package/dist/chunk-CVWVFYZG.js +127 -0
- package/dist/chunk-CVWVFYZG.js.map +1 -0
- package/dist/chunk-DAPOH6OL.js +127 -0
- package/dist/chunk-DAPOH6OL.js.map +1 -0
- package/dist/chunk-DYH3CYMQ.js +63 -0
- package/dist/chunk-DYH3CYMQ.js.map +1 -0
- package/dist/chunk-DZBIZXJT.js +105 -0
- package/dist/chunk-DZBIZXJT.js.map +1 -0
- package/dist/chunk-EN2EIVJL.js +275 -0
- package/dist/chunk-EN2EIVJL.js.map +1 -0
- package/dist/chunk-EXHULFNH.js +212 -0
- package/dist/chunk-EXHULFNH.js.map +1 -0
- package/dist/chunk-EY6XUWRC.js +141 -0
- package/dist/chunk-EY6XUWRC.js.map +1 -0
- package/dist/chunk-FGDJX3JA.js +277 -0
- package/dist/chunk-FGDJX3JA.js.map +1 -0
- package/dist/chunk-FRPZDVFW.js +141 -0
- package/dist/chunk-FRPZDVFW.js.map +1 -0
- package/dist/chunk-FS6ACKGM.js +141 -0
- package/dist/chunk-FS6ACKGM.js.map +1 -0
- package/dist/chunk-G3EGBV5J.js +108 -0
- package/dist/chunk-G3EGBV5J.js.map +1 -0
- package/dist/chunk-G7Z3HMEW.js +108 -0
- package/dist/chunk-G7Z3HMEW.js.map +1 -0
- package/dist/chunk-GMGE4NOB.js +105 -0
- package/dist/chunk-GMGE4NOB.js.map +1 -0
- package/dist/chunk-GMSFDN7D.js +3629 -0
- package/dist/chunk-GMSFDN7D.js.map +1 -0
- package/dist/chunk-HDKF3UAE.js +127 -0
- package/dist/chunk-HDKF3UAE.js.map +1 -0
- package/dist/chunk-HQZOZBRY.js +2324 -0
- package/dist/chunk-HQZOZBRY.js.map +1 -0
- package/dist/chunk-ICC54A7E.js +277 -0
- package/dist/chunk-ICC54A7E.js.map +1 -0
- package/dist/chunk-IM2MIG5M.js +212 -0
- package/dist/chunk-IM2MIG5M.js.map +1 -0
- package/dist/chunk-IMAOZHSC.js +108 -0
- package/dist/chunk-IMAOZHSC.js.map +1 -0
- package/dist/chunk-JCRWKUQ5.js +796 -0
- package/dist/chunk-JCRWKUQ5.js.map +1 -0
- package/dist/chunk-JH4ADQ7I.js +49 -0
- package/dist/chunk-JH4ADQ7I.js.map +1 -0
- package/dist/chunk-JHPVK6CS.js +127 -0
- package/dist/chunk-JHPVK6CS.js.map +1 -0
- package/dist/chunk-JOJQXQLI.js +277 -0
- package/dist/chunk-JOJQXQLI.js.map +1 -0
- package/dist/chunk-KATJWNBU.js +212 -0
- package/dist/chunk-KATJWNBU.js.map +1 -0
- package/dist/chunk-KFSPN5LV.js +271 -0
- package/dist/chunk-KFSPN5LV.js.map +1 -0
- package/dist/chunk-KFUS56FH.js +796 -0
- package/dist/chunk-KFUS56FH.js.map +1 -0
- package/dist/chunk-KOOW3QLT.js +108 -0
- package/dist/chunk-KOOW3QLT.js.map +1 -0
- package/dist/chunk-KU5KDJJQ.js +212 -0
- package/dist/chunk-KU5KDJJQ.js.map +1 -0
- package/dist/chunk-LQPPJMCT.js +141 -0
- package/dist/chunk-LQPPJMCT.js.map +1 -0
- package/dist/chunk-LRWSKPWW.js +108 -0
- package/dist/chunk-LRWSKPWW.js.map +1 -0
- package/dist/chunk-LSPAPAC6.js +275 -0
- package/dist/chunk-LSPAPAC6.js.map +1 -0
- package/dist/chunk-MKRM77ER.js +127 -0
- package/dist/chunk-MKRM77ER.js.map +1 -0
- package/dist/chunk-N2A27HBQ.js +275 -0
- package/dist/chunk-N2A27HBQ.js.map +1 -0
- package/dist/chunk-N3VKT6PD.js +63 -0
- package/dist/chunk-N3VKT6PD.js.map +1 -0
- package/dist/chunk-NR6CZSCD.js +275 -0
- package/dist/chunk-NR6CZSCD.js.map +1 -0
- package/dist/chunk-O7RBLP5X.js +63 -0
- package/dist/chunk-O7RBLP5X.js.map +1 -0
- package/dist/chunk-P6GKWD7Z.js +49 -0
- package/dist/chunk-P6GKWD7Z.js.map +1 -0
- package/dist/chunk-PH3Y26QE.js +275 -0
- package/dist/chunk-PH3Y26QE.js.map +1 -0
- package/dist/chunk-PJ2YHYMS.js +796 -0
- package/dist/chunk-PJ2YHYMS.js.map +1 -0
- package/dist/chunk-PK2FN4VI.js +796 -0
- package/dist/chunk-PK2FN4VI.js.map +1 -0
- package/dist/chunk-PKYF4ATF.js +127 -0
- package/dist/chunk-PKYF4ATF.js.map +1 -0
- package/dist/chunk-Q4DBAKJC.js +127 -0
- package/dist/chunk-Q4DBAKJC.js.map +1 -0
- package/dist/chunk-Q7VF2XEQ.js +141 -0
- package/dist/chunk-Q7VF2XEQ.js.map +1 -0
- package/dist/chunk-QMUTPVWG.js +108 -0
- package/dist/chunk-QMUTPVWG.js.map +1 -0
- package/dist/chunk-QQB223M6.js +49 -0
- package/dist/chunk-QQB223M6.js.map +1 -0
- package/dist/chunk-R6XUP4YU.js +105 -0
- package/dist/chunk-R6XUP4YU.js.map +1 -0
- package/dist/chunk-RCDRPUUW.js +212 -0
- package/dist/chunk-RCDRPUUW.js.map +1 -0
- package/dist/chunk-RFPY65DW.js +127 -0
- package/dist/chunk-RFPY65DW.js.map +1 -0
- package/dist/chunk-RNK6YLW4.js +275 -0
- package/dist/chunk-RNK6YLW4.js.map +1 -0
- package/dist/chunk-RP6FR5KI.js +63 -0
- package/dist/chunk-RP6FR5KI.js.map +1 -0
- package/dist/chunk-RPJ5IR43.js +277 -0
- package/dist/chunk-RPJ5IR43.js.map +1 -0
- package/dist/chunk-RU6VCNTG.js +127 -0
- package/dist/chunk-RU6VCNTG.js.map +1 -0
- package/dist/chunk-RUEFVGLB.js +275 -0
- package/dist/chunk-RUEFVGLB.js.map +1 -0
- package/dist/chunk-S7G36BAF.js +212 -0
- package/dist/chunk-S7G36BAF.js.map +1 -0
- package/dist/chunk-SGTG53XI.js +141 -0
- package/dist/chunk-SGTG53XI.js.map +1 -0
- package/dist/chunk-SJKGGE46.js +63 -0
- package/dist/chunk-SJKGGE46.js.map +1 -0
- package/dist/chunk-SOGN63YT.js +212 -0
- package/dist/chunk-SOGN63YT.js.map +1 -0
- package/dist/chunk-T23IRAHE.js +212 -0
- package/dist/chunk-T23IRAHE.js.map +1 -0
- package/dist/chunk-T6E2JX5B.js +49 -0
- package/dist/chunk-T6E2JX5B.js.map +1 -0
- package/dist/chunk-UCLFGGFU.js +276 -0
- package/dist/chunk-UCLFGGFU.js.map +1 -0
- package/dist/chunk-UD24DKE6.js +105 -0
- package/dist/chunk-UD24DKE6.js.map +1 -0
- package/dist/chunk-UFL43KWY.js +141 -0
- package/dist/chunk-UFL43KWY.js.map +1 -0
- package/dist/chunk-UYXYA627.js +141 -0
- package/dist/chunk-UYXYA627.js.map +1 -0
- package/dist/chunk-VRBN7BUO.js +212 -0
- package/dist/chunk-VRBN7BUO.js.map +1 -0
- package/dist/chunk-VUL3LBEC.js +2324 -0
- package/dist/chunk-VUL3LBEC.js.map +1 -0
- package/dist/chunk-VVQHCLKU.js +212 -0
- package/dist/chunk-VVQHCLKU.js.map +1 -0
- package/dist/chunk-WCOULWN4.js +150 -0
- package/dist/chunk-WCOULWN4.js.map +1 -0
- package/dist/chunk-WJYDNUZB.js +141 -0
- package/dist/chunk-WJYDNUZB.js.map +1 -0
- package/dist/chunk-WRJ773IL.js +127 -0
- package/dist/chunk-WRJ773IL.js.map +1 -0
- package/dist/chunk-WV7E5QWR.js +108 -0
- package/dist/chunk-WV7E5QWR.js.map +1 -0
- package/dist/chunk-YKWBKP5W.js +63 -0
- package/dist/chunk-YKWBKP5W.js.map +1 -0
- package/dist/chunk-Z4PZFJT2.js +127 -0
- package/dist/chunk-Z4PZFJT2.js.map +1 -0
- package/dist/chunk-ZM6PIKKI.js +275 -0
- package/dist/chunk-ZM6PIKKI.js.map +1 -0
- package/dist/components/AddressContainer/CoreAddressContainer.js +10 -10
- package/dist/components/AddressContainer/EVMAddressContainer.js +9 -9
- package/dist/components/AddressContainer/addressSwitcher.js +7 -7
- package/dist/components/AddressContainer/addressView.js +6 -6
- package/dist/components/AddressContainer/label.js +4 -4
- package/dist/components/Age/index.js +4 -4
- 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/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 +3 -3
- package/dist/components/Modal/index.js +3 -3
- package/dist/components/NetworkIcon/index.js +2 -2
- package/dist/components/PhishingAddressContainer/index.js +4 -4
- package/dist/components/Price/index.js +3 -3
- package/dist/components/Radio/index.js +2 -2
- package/dist/components/Select/index.js +3 -3
- package/dist/components/Select/select.js +3 -3
- package/dist/components/Text/index.js +4 -4
- package/dist/components/Tooltip/index.js +3 -3
- package/dist/components/TransactionAction/coreTransactionAction.js +10 -10
- package/dist/components/TransactionAction/evmTransactionAction.js +9 -9
- package/dist/utils/address.d.ts +3 -3
- package/dist/utils/address.js +2 -2
- package/dist/utils/contractManagerTool.js +2 -2
- package/dist/utils/hooks/useENS.js +3 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/request.d.ts +4 -2
- package/dist/utils/request.js +5 -1
- package/dist/utils/request.types.d.ts +6 -1
- package/package.json +3 -3
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContractAddress,
|
|
3
|
+
ContractCreatedAddress,
|
|
4
|
+
InvalidAddress,
|
|
5
|
+
MyAddress
|
|
6
|
+
} from "./chunk-VRBN7BUO.js";
|
|
7
|
+
import {
|
|
8
|
+
RenderAddress
|
|
9
|
+
} from "./chunk-CVWVFYZG.js";
|
|
10
|
+
import {
|
|
11
|
+
convertCheckSum,
|
|
12
|
+
formatAddress,
|
|
13
|
+
isEvmAddress,
|
|
14
|
+
isZeroAddress
|
|
15
|
+
} from "./chunk-RUEFVGLB.js";
|
|
16
|
+
import {
|
|
17
|
+
getLabelInfo
|
|
18
|
+
} from "./chunk-JH4ADQ7I.js";
|
|
19
|
+
import {
|
|
20
|
+
getTranslations,
|
|
21
|
+
useGlobalData
|
|
22
|
+
} from "./chunk-DQGLZCIG.js";
|
|
23
|
+
|
|
24
|
+
// src/components/AddressContainer/EVMAddressContainer.tsx
|
|
25
|
+
import { memo } from "react";
|
|
26
|
+
import { withTranslation } from "react-i18next";
|
|
27
|
+
import _ from "lodash";
|
|
28
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
29
|
+
var parseProps = (props, globalData) => {
|
|
30
|
+
const { alias, t, showAddressLabel, showNametag, nametagInfo } = props;
|
|
31
|
+
const value = props.value || "";
|
|
32
|
+
const cfxAddress = formatAddress(value, "hex");
|
|
33
|
+
const translations = getTranslations();
|
|
34
|
+
let aliasLabel = alias;
|
|
35
|
+
if (!alias && isZeroAddress(cfxAddress)) {
|
|
36
|
+
aliasLabel = t(translations.general.zeroAddress);
|
|
37
|
+
}
|
|
38
|
+
let officalNametag = null;
|
|
39
|
+
let addressLabel = null;
|
|
40
|
+
if (cfxAddress && showAddressLabel) {
|
|
41
|
+
const addressLabels = globalData?.["CONFLUX_SCAN_ADDRESS_LABELS" /* addressLabel */];
|
|
42
|
+
const gAddressLabel = addressLabels?.[convertCheckSum(cfxAddress)] || addressLabels?.[cfxAddress.toLowerCase()];
|
|
43
|
+
if (gAddressLabel) {
|
|
44
|
+
const { label } = getLabelInfo(gAddressLabel, "tag");
|
|
45
|
+
addressLabel = label;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (cfxAddress && showNametag) {
|
|
49
|
+
const nametags = nametagInfo?.[convertCheckSum(cfxAddress)] || nametagInfo?.[cfxAddress.toLowerCase()];
|
|
50
|
+
if (nametags) {
|
|
51
|
+
const nametag = nametags?.nametag ?? "";
|
|
52
|
+
const { label } = getLabelInfo(nametag, "nametag");
|
|
53
|
+
officalNametag = label;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
alias: aliasLabel,
|
|
58
|
+
nametag: officalNametag,
|
|
59
|
+
addressLabel,
|
|
60
|
+
cfxAddress
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var EVMAddressContainer = withTranslation()(
|
|
64
|
+
memo((props) => {
|
|
65
|
+
const { globalData } = useGlobalData();
|
|
66
|
+
if (!props.value && !props.contractCreated) {
|
|
67
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "--" });
|
|
68
|
+
}
|
|
69
|
+
const defaultProps = {
|
|
70
|
+
isFull: false,
|
|
71
|
+
isFullNameTag: false,
|
|
72
|
+
link: true,
|
|
73
|
+
isMe: false,
|
|
74
|
+
showIcon: true,
|
|
75
|
+
verify: false,
|
|
76
|
+
showAddressLabel: true,
|
|
77
|
+
showENSLabel: true,
|
|
78
|
+
showNametag: true
|
|
79
|
+
};
|
|
80
|
+
const mergeDefaultProps = _.assign({}, defaultProps, props);
|
|
81
|
+
const mergeParseProps = _.merge(
|
|
82
|
+
{},
|
|
83
|
+
mergeDefaultProps,
|
|
84
|
+
parseProps(mergeDefaultProps, globalData)
|
|
85
|
+
);
|
|
86
|
+
if (!mergeParseProps.value && mergeParseProps.contractCreated) {
|
|
87
|
+
return ContractCreatedAddress({
|
|
88
|
+
...mergeParseProps,
|
|
89
|
+
outputType: "hex"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (!isEvmAddress(mergeParseProps.value)) {
|
|
93
|
+
return InvalidAddress(mergeParseProps);
|
|
94
|
+
}
|
|
95
|
+
if (mergeParseProps.isContract) {
|
|
96
|
+
return ContractAddress(mergeParseProps);
|
|
97
|
+
}
|
|
98
|
+
if (mergeParseProps.isMe) {
|
|
99
|
+
return MyAddress(mergeParseProps);
|
|
100
|
+
}
|
|
101
|
+
return RenderAddress(mergeParseProps);
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
EVMAddressContainer
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=chunk-2CYC4UWO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/EVMAddressContainer.tsx"],"sourcesContent":["import { memo } from 'react';\nimport { WithTranslation, withTranslation } from 'react-i18next';\nimport _ from 'lodash';\nimport {\n formatAddress,\n isEvmAddress,\n isZeroAddress,\n convertCheckSum,\n} from '../../utils/address';\nimport { useGlobalData, getTranslations } from '../../store';\nimport { LOCALSTORAGE_KEYS_MAP } from '../../utils/constants';\nimport { getLabelInfo } from './label';\n\nimport { RenderAddress } from './addressView';\nimport {\n ContractCreatedAddress,\n InvalidAddress,\n ContractAddress,\n MyAddress,\n} from './addressSwitcher';\nimport { GlobalDataType } from 'src/store/types';\nimport { EVMAddressContainerProps } from './types';\n\nconst parseProps = (\n props: EVMAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const { alias, t, showAddressLabel, showNametag, nametagInfo } = props;\n const value: string = props.value || '';\n const cfxAddress = formatAddress(value, 'hex');\n\n const translations = getTranslations();\n\n let aliasLabel = alias;\n if (!alias && isZeroAddress(cfxAddress)) {\n aliasLabel = t(translations.general.zeroAddress);\n }\n\n // official name tag\n let officalNametag: React.ReactNode = null;\n // private name tag\n let addressLabel: React.ReactNode = null;\n\n if (cfxAddress && showAddressLabel) {\n // global private name tag\n const addressLabels = globalData?.[LOCALSTORAGE_KEYS_MAP.addressLabel];\n const gAddressLabel =\n addressLabels?.[convertCheckSum(cfxAddress)] ||\n addressLabels?.[cfxAddress.toLowerCase()];\n\n if (gAddressLabel) {\n const { label } = getLabelInfo(gAddressLabel, 'tag');\n addressLabel = label;\n }\n }\n\n if (cfxAddress && showNametag) {\n const nametags =\n nametagInfo?.[convertCheckSum(cfxAddress)] ||\n nametagInfo?.[cfxAddress.toLowerCase()];\n\n if (nametags) {\n const nametag = nametags?.nametag ?? '';\n const { label } = getLabelInfo(nametag, 'nametag');\n officalNametag = label;\n }\n }\n\n return {\n alias: aliasLabel,\n nametag: officalNametag,\n addressLabel,\n cfxAddress,\n };\n};\n\nexport const EVMAddressContainer = withTranslation()(\n memo((props: EVMAddressContainerProps & WithTranslation) => {\n const { globalData } = useGlobalData();\n\n // If a txn receipt has no 'to' address or 'contractCreated', show -- for temp\n if (!props.value && !props.contractCreated) {\n return <>--</>;\n }\n\n const defaultProps = {\n isFull: false,\n isFullNameTag: false,\n link: true,\n isMe: false,\n showIcon: true,\n verify: false,\n showAddressLabel: true,\n showENSLabel: true,\n showNametag: true,\n };\n\n const mergeDefaultProps = _.assign({}, defaultProps, props);\n\n const mergeParseProps = _.merge(\n {},\n mergeDefaultProps,\n parseProps(mergeDefaultProps, globalData),\n );\n\n if (!mergeParseProps.value && mergeParseProps.contractCreated) {\n return ContractCreatedAddress({\n ...mergeParseProps,\n outputType: 'hex',\n });\n }\n\n if (!isEvmAddress(mergeParseProps.value)) {\n return InvalidAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isContract) {\n return ContractAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isMe) {\n return MyAddress(mergeParseProps);\n }\n\n return RenderAdd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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,IACf;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,CAAC,gBAAgB,SAAS,gBAAgB,iBAAiB;AAC7D,aAAO,uBAAuB;AAAA,QAC5B,GAAG;AAAA,QACH,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAEA,QAAI,CAAC,aAAa,gBAAgB,KAAK,GAAG;AACxC,aAAO,eAAe,eAAe;AAAA,IACvC;AAEA,QAAI,gBAAgB,YAAY;AAC9B,aAAO,gBAAgB,eAAe;AAAA,IACxC;AAEA,QAAI,gBAAgB,MAAM;AACxB,aAAO,UAAU,eAAe;AAAA,IAClC;AAEA,WAAO,cAAc,eAAe;AAAA,EACtC,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isCoreMainOrTestAddress
|
|
3
|
+
} from "./chunk-N2A27HBQ.js";
|
|
4
|
+
import {
|
|
5
|
+
apiPrefix
|
|
6
|
+
} from "./chunk-7RH7LJYB.js";
|
|
7
|
+
import {
|
|
8
|
+
sendRequestENSInfo
|
|
9
|
+
} from "./chunk-MZAIX5H4.js";
|
|
10
|
+
import {
|
|
11
|
+
useENSStore
|
|
12
|
+
} from "./chunk-DQGLZCIG.js";
|
|
13
|
+
|
|
14
|
+
// src/utils/hooks/useENS.ts
|
|
15
|
+
import { useEffect } from "react";
|
|
16
|
+
import useSWR from "swr";
|
|
17
|
+
var ensUrl = (ens, value) => {
|
|
18
|
+
if (!value)
|
|
19
|
+
return null;
|
|
20
|
+
if (typeof value === "string" && ens[value])
|
|
21
|
+
return null;
|
|
22
|
+
let url = null;
|
|
23
|
+
if (typeof value === "string" && isCoreMainOrTestAddress(value)) {
|
|
24
|
+
url = `${apiPrefix}/ens/reverse/match?address=${value}`;
|
|
25
|
+
} else if (Array.isArray(value) && value.length) {
|
|
26
|
+
const validAddresses = value.filter(
|
|
27
|
+
(v) => typeof v === "string" && isCoreMainOrTestAddress(v) && !ens[v]
|
|
28
|
+
);
|
|
29
|
+
if (validAddresses.length === 0)
|
|
30
|
+
return null;
|
|
31
|
+
const baseUrl = `${apiPrefix}/ens/reverse/match?`;
|
|
32
|
+
const maxQueryLength = 1800 - baseUrl.length;
|
|
33
|
+
const query = validAddresses.reduce((acc, curr, index) => {
|
|
34
|
+
const newPart = `${index === 0 ? "" : "&"}address=${curr}`;
|
|
35
|
+
if (acc.length + newPart.length > maxQueryLength) {
|
|
36
|
+
return acc;
|
|
37
|
+
}
|
|
38
|
+
return acc + newPart;
|
|
39
|
+
}, "");
|
|
40
|
+
if (query) {
|
|
41
|
+
url = baseUrl + query;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return url;
|
|
45
|
+
};
|
|
46
|
+
var useENS = (address) => {
|
|
47
|
+
const { ens, setENS } = useENSStore();
|
|
48
|
+
const url = ensUrl(ens, address);
|
|
49
|
+
const { data } = useSWR(url, () => sendRequestENSInfo(url), {
|
|
50
|
+
revalidateOnFocus: false
|
|
51
|
+
});
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (data) {
|
|
54
|
+
setENS(data);
|
|
55
|
+
}
|
|
56
|
+
}, [data]);
|
|
57
|
+
return { ens };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
useENS
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=chunk-3DYO4SUL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/hooks/useENS.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport useSWR from 'swr';\nimport { sendRequestENSInfo } from 'src/utils/request';\nimport { useENSStore } from '../../store';\nimport { ENSType } from '../../store/types';\nimport { isCoreMainOrTestAddress } from '../address';\nimport { apiPrefix } from '../constants';\n\nconst ensUrl = (ens: ENSType, value: string | null | string[]) => {\n if (!value) return null;\n if (typeof value === 'string' && ens[value]) return null;\n\n let url = null;\n\n if (typeof value === 'string' && isCoreMainOrTestAddress(value)) {\n url = `${apiPrefix}/ens/reverse/match?address=${value}`;\n } else if (Array.isArray(value) && value.length) {\n const validAddresses = value.filter(\n v => typeof v === 'string' && isCoreMainOrTestAddress(v) && !ens[v],\n );\n if (validAddresses.length === 0) return null;\n\n const baseUrl = `${apiPrefix}/ens/reverse/match?`;\n const maxQueryLength = 1800 - baseUrl.length;\n\n const query = validAddresses.reduce((acc, curr, index) => {\n const newPart = `${index === 0 ? '' : '&'}address=${curr}`;\n if (acc.length + newPart.length > maxQueryLength) {\n return acc;\n }\n return acc + newPart;\n }, '');\n\n if (query) {\n url = baseUrl + query;\n }\n }\n\n return url;\n};\n\nexport const useENS = (address: string | null | string[]) => {\n const { ens, setENS } = useENSStore();\n\n const url = ensUrl(ens, address);\n\n const { data } = useSWR(url, () => sendRequestENSInfo(url), {\n revalidateOnFocus: false,\n });\n\n useEffect(() => {\n if (data) {\n setENS(data);\n }\n }, [data]);\n\n return { ens };\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,OAAO,YAAY;AAOnB,IAAM,SAAS,CAAC,KAAc,UAAoC;AAChE,MAAI,CAAC;AAAO,WAAO;AACnB,MAAI,OAAO,UAAU,YAAY,IAAI,KAAK;AAAG,WAAO;AAEpD,MAAI,MAAM;AAEV,MAAI,OAAO,UAAU,YAAY,wBAAwB,KAAK,GAAG;AAC/D,UAAM,GAAG,uCAAuC;AAAA,EAClD,WAAW,MAAM,QAAQ,KAAK,KAAK,MAAM,QAAQ;AAC/C,UAAM,iBAAiB,MAAM;AAAA,MAC3B,OA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