@cfxjs/sirius-next-common 0.1.31 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2P6RNTXI.js +141 -0
- package/dist/chunk-2P6RNTXI.js.map +1 -0
- package/dist/chunk-3MZJYUNS.js +212 -0
- package/dist/chunk-3MZJYUNS.js.map +1 -0
- package/dist/chunk-4WJIMFI5.js +141 -0
- package/dist/chunk-4WJIMFI5.js.map +1 -0
- package/dist/chunk-5PYSDWGQ.js +127 -0
- package/dist/chunk-5PYSDWGQ.js.map +1 -0
- package/dist/chunk-5Z5K44KU.js +108 -0
- package/dist/chunk-5Z5K44KU.js.map +1 -0
- package/dist/chunk-6CR7KJMU.js +141 -0
- package/dist/chunk-6CR7KJMU.js.map +1 -0
- package/dist/chunk-6Q2ML33K.js +141 -0
- package/dist/chunk-6Q2ML33K.js.map +1 -0
- package/dist/chunk-7TTJMYA4.js +108 -0
- package/dist/chunk-7TTJMYA4.js.map +1 -0
- package/dist/chunk-CL6X23Y3.js +108 -0
- package/dist/chunk-CL6X23Y3.js.map +1 -0
- package/dist/chunk-E7KZNWOF.js +150 -0
- package/dist/chunk-E7KZNWOF.js.map +1 -0
- package/dist/chunk-EF2N45TZ.js +49 -0
- package/dist/chunk-EF2N45TZ.js.map +1 -0
- package/dist/chunk-FRW235T3.js +213 -0
- package/dist/chunk-FRW235T3.js.map +1 -0
- package/dist/chunk-GJCBWNU5.js +127 -0
- package/dist/chunk-GJCBWNU5.js.map +1 -0
- package/dist/chunk-GL4KHAZB.js +105 -0
- package/dist/chunk-GL4KHAZB.js.map +1 -0
- package/dist/chunk-GYK27Y5X.js +796 -0
- package/dist/chunk-GYK27Y5X.js.map +1 -0
- package/dist/chunk-H63H7IRY.js +141 -0
- package/dist/chunk-H63H7IRY.js.map +1 -0
- package/dist/chunk-HMP3NSJX.js +3629 -0
- package/dist/chunk-HMP3NSJX.js.map +1 -0
- package/dist/chunk-JEBXQSTA.js +108 -0
- package/dist/chunk-JEBXQSTA.js.map +1 -0
- package/dist/chunk-JMM6NFUN.js +212 -0
- package/dist/chunk-JMM6NFUN.js.map +1 -0
- package/dist/chunk-LC3NZF3B.js +3629 -0
- package/dist/chunk-LC3NZF3B.js.map +1 -0
- package/dist/chunk-LSIWDRKV.js +105 -0
- package/dist/chunk-LSIWDRKV.js.map +1 -0
- package/dist/chunk-LXPKK77D.js +213 -0
- package/dist/chunk-LXPKK77D.js.map +1 -0
- package/dist/chunk-MN3Y4WII.js +2324 -0
- package/dist/chunk-MN3Y4WII.js.map +1 -0
- package/dist/chunk-OBYGZKWE.js +796 -0
- package/dist/chunk-OBYGZKWE.js.map +1 -0
- package/dist/chunk-PH7BGJ6R.js +150 -0
- package/dist/chunk-PH7BGJ6R.js.map +1 -0
- package/dist/chunk-PKSF74ZF.js +49 -0
- package/dist/chunk-PKSF74ZF.js.map +1 -0
- package/dist/chunk-QSLCIDOR.js +212 -0
- package/dist/chunk-QSLCIDOR.js.map +1 -0
- package/dist/chunk-XAIU7RPV.js +108 -0
- package/dist/chunk-XAIU7RPV.js.map +1 -0
- package/dist/chunk-XEK7EJTM.js +2324 -0
- package/dist/chunk-XEK7EJTM.js.map +1 -0
- package/dist/components/AddressContainer/CoreAddressContainer.js +10 -10
- package/dist/components/AddressContainer/EVMAddressContainer.js +9 -9
- package/dist/components/AddressContainer/addressSwitcher.js +7 -7
- package/dist/components/AddressContainer/addressView.js +6 -6
- package/dist/components/AddressContainer/label.js +3 -3
- package/dist/components/Age/index.js +3 -3
- package/dist/components/CopyButton/index.js +2 -2
- package/dist/components/DownloadCSV/index.js +3 -3
- package/dist/components/GasPriceDropdown/index.js +1 -1
- package/dist/components/IncreasePercent/index.js +1 -1
- package/dist/components/InfoIconWithTooltip/index.js +2 -2
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/NetworkIcon/index.js +1 -1
- package/dist/components/PhishingAddressContainer/index.js +4 -4
- package/dist/components/Price/index.js +2 -2
- package/dist/components/Radio/index.js +1 -1
- package/dist/components/Select/index.js +2 -2
- package/dist/components/Select/select.js +2 -2
- package/dist/components/Text/index.js +3 -3
- package/dist/components/Tooltip/index.js +2 -2
- package/dist/components/TransactionAction/coreTransactionAction.js +10 -10
- package/dist/components/TransactionAction/evmTransactionAction.js +9 -9
- package/dist/utils/address.js +2 -2
- package/dist/utils/contractManagerTool.js +1 -1
- package/dist/utils/hooks/useENS.js +3 -3
- package/dist/utils/index.d.ts +15 -1
- package/dist/utils/index.js +7 -3
- package/dist/utils/rpcRequest.d.ts +1 -1
- package/dist/utils/rpcRequest.js +1 -1
- package/dist/utils/tx.d.ts +2 -0
- package/dist/utils/tx.js +95 -0
- package/dist/utils/tx.js.map +1 -0
- package/package.json +8 -4
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useBreakpoint
|
|
3
|
+
} from "./chunk-TOKKKTFG.js";
|
|
4
|
+
import {
|
|
5
|
+
Tooltip
|
|
6
|
+
} from "./chunk-MN3Y4WII.js";
|
|
7
|
+
import {
|
|
8
|
+
selectText
|
|
9
|
+
} from "./chunk-GYK27Y5X.js";
|
|
10
|
+
|
|
11
|
+
// src/components/Text/index.tsx
|
|
12
|
+
import React from "react";
|
|
13
|
+
import clsx from "clsx";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
var getTypeColor = (type) => {
|
|
16
|
+
const colors = {
|
|
17
|
+
default: "inherit",
|
|
18
|
+
primary: "#7cd77b",
|
|
19
|
+
secondary: "#666",
|
|
20
|
+
success: "#7cd77b",
|
|
21
|
+
warning: "#ffc438",
|
|
22
|
+
error: "#e15c56"
|
|
23
|
+
};
|
|
24
|
+
return colors[type] || colors.default;
|
|
25
|
+
};
|
|
26
|
+
var Text = React.memo(
|
|
27
|
+
({
|
|
28
|
+
className,
|
|
29
|
+
children,
|
|
30
|
+
maxWidth: _maxWidth,
|
|
31
|
+
mobileMaxWidth = _maxWidth,
|
|
32
|
+
maxCount: _maxCount,
|
|
33
|
+
mobileMaxCount = _maxCount,
|
|
34
|
+
hoverValue,
|
|
35
|
+
hoverValueMaxCount: outerHoverValueMaxCount,
|
|
36
|
+
tag = "p",
|
|
37
|
+
type = "default",
|
|
38
|
+
hideTooltip = false,
|
|
39
|
+
...props
|
|
40
|
+
}) => {
|
|
41
|
+
const Component = tag;
|
|
42
|
+
const bp = useBreakpoint();
|
|
43
|
+
let child = children;
|
|
44
|
+
const maxCount = bp === "s" ? mobileMaxCount : _maxCount;
|
|
45
|
+
const maxWidth = bp === "s" ? mobileMaxWidth : _maxWidth;
|
|
46
|
+
if (maxWidth === void 0 && maxCount && typeof children === "string" && children.length > maxCount) {
|
|
47
|
+
child = String.prototype.substr.call(children, 0, maxCount) + "...";
|
|
48
|
+
}
|
|
49
|
+
let textContent = hoverValue || children;
|
|
50
|
+
if (bp === "s" && typeof textContent === "string") {
|
|
51
|
+
const hoverValueMaxCount = outerHoverValueMaxCount || 34;
|
|
52
|
+
let textContentCopy = textContent;
|
|
53
|
+
let newTextContent = [];
|
|
54
|
+
let count = 0;
|
|
55
|
+
while (textContentCopy.length > hoverValueMaxCount) {
|
|
56
|
+
newTextContent.push(
|
|
57
|
+
/* @__PURE__ */ jsx("span", { children: textContentCopy.substr(0, hoverValueMaxCount) }, count)
|
|
58
|
+
);
|
|
59
|
+
newTextContent.push(/* @__PURE__ */ jsx("br", {}, `br${count}`));
|
|
60
|
+
textContentCopy = textContentCopy.substr(hoverValueMaxCount);
|
|
61
|
+
if (count > 3) {
|
|
62
|
+
textContentCopy = textContentCopy.substr(0, hoverValueMaxCount - 3) + "...";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
newTextContent.push(/* @__PURE__ */ jsx("span", { children: textContentCopy }, ++count));
|
|
66
|
+
textContent = newTextContent;
|
|
67
|
+
}
|
|
68
|
+
const tooltipText = !hideTooltip && React.createElement(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
onClick: (e) => {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
e.stopPropagation();
|
|
74
|
+
selectText(e.currentTarget);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
textContent
|
|
78
|
+
);
|
|
79
|
+
const p = { title: tooltipText };
|
|
80
|
+
return React.createElement(Tooltip, p, [
|
|
81
|
+
/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
82
|
+
Component,
|
|
83
|
+
{
|
|
84
|
+
className: clsx(
|
|
85
|
+
"sirius-text truncate vertical-bottom",
|
|
86
|
+
"all-[a]:truncate all-[a]:vertical-bottom all-[a]:cursor-pointer all-[a:hover]:text-#0626ae",
|
|
87
|
+
className
|
|
88
|
+
),
|
|
89
|
+
style: {
|
|
90
|
+
maxWidth,
|
|
91
|
+
display: maxWidth === void 0 ? "inherit" : "inline-block",
|
|
92
|
+
color: getTypeColor(type)
|
|
93
|
+
},
|
|
94
|
+
...props,
|
|
95
|
+
children: child
|
|
96
|
+
}
|
|
97
|
+
) }, "text")
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
Text
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=chunk-LSIWDRKV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Text/index.tsx"],"sourcesContent":["import React from 'react';\nimport clsx from 'clsx';\nimport { Tooltip } from '../Tooltip';\nimport { selectText } from '../../utils';\nimport { useBreakpoint } from '../../utils/media';\n\ntype NormalTypes =\n | 'default'\n | 'secondary'\n | 'success'\n | 'warning'\n | 'error'\n | 'primary';\n\ntype TextProps = {\n children?: React.ReactNode;\n maxWidth?: string;\n mobileMaxWidth?: string;\n maxCount?: number;\n mobileMaxCount?: number;\n hoverValue?: React.ReactNode;\n hoverValueMaxCount?: number;\n tag?: 'p' | 'span';\n type?: NormalTypes;\n hideTooltip?: boolean;\n};\ntype NativeAttrs = Omit<React.HTMLAttributes<any>, keyof TextProps>;\n\nconst getTypeColor = (type: NormalTypes) => {\n const colors: { [key in NormalTypes]: string } = {\n default: 'inherit',\n primary: '#7cd77b',\n secondary: '#666',\n success: '#7cd77b',\n warning: '#ffc438',\n error: '#e15c56',\n };\n\n return colors[type] || colors.default;\n};\n\n// note:\n// 1. maxWidth priority is higher than maxCount\n// 2. maxCount only apply to string\n// 3. if hoverValue is provided, use hoverValue as Tooltip text, otherwise use children\n// if text of prop tooltip is provided, use as Tooltip text\nexport const Text = React.memo(\n ({\n className,\n children,\n maxWidth: _maxWidth,\n mobileMaxWidth = _maxWidth,\n maxCount: _maxCount,\n mobileMaxCount = _maxCount,\n hoverValue,\n hoverValueMaxCount: outerHoverValueMaxCount,\n tag = 'p',\n type = 'default',\n hideTooltip = false,\n ...props\n }: NativeAttrs & TextProps) => {\n const Component = tag;\n const bp = useBreakpoint();\n let child: React.ReactNode = children;\n const maxCount = bp === 's' ? mobileMaxCount : _maxCount;\n const maxWidth = bp === 's' ? mobileMaxWidth : _maxWidth;\n if (\n maxWidth === undefined &&\n maxCount &&\n typeof children === 'string' &&\n children.length > maxCount\n ) {\n child = String.prototype.substr.call(children, 0, maxCount) + '...';\n }\n\n let textContent = hoverValue || children;\n // 控制移动端字符串类型 tooltip 的长度\n // 这里有个问题,就是截断的位置可能是一个完整的单词,暂时没有办法处理,如果为了避免这种情况,需要由外面传入前对内容进行处理,比如设置固定宽度小于 24rem\n // @todo 后续可以试下读取文本长度,动态设置容器宽度值的方式,可以避免截断位置的问题\n if (bp === 's' && typeof textContent === 'string') {\n const hoverValueMaxCount = outerHoverValueMaxCount || 34; // default text count is 36\n let textContentCopy: string = textContent;\n let newTextContent: Array<React.ReactNode> = [];\n let count = 0;\n while (textContentCopy.length > hoverValueMaxCount) {\n newTextContent.push(\n <span key={count}>\n {textContentCopy.substr(0, hoverValueMaxCount)}\n </span>,\n );\n newTextContent.push(<br key={`br${count}`} />);\n textContentCopy = textContentCopy.substr(hoverValueMaxCount);\n // 防止文本过长的情况\n if (count > 3) {\n textContentCopy =\n textContentCopy.substr(0, hoverValueMaxCount - 3) + '...';\n }\n }\n newTextContent.push(<span key={++count}>{textContentCopy}</span>);\n textContent = newTextContent;\n }\n const tooltipText =\n !hideTooltip &&\n React.createElement(\n 'div',\n {\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n selectText(e.currentTarget);\n },\n },\n textContent,\n );\n\n const p = { title: tooltipText };\n return React.createElement(Tooltip, p, [\n <span key=\"text\">\n <Component\n className={clsx(\n 'sirius-text truncate vertical-bottom',\n 'all-[a]:truncate all-[a]:vertical-bottom all-[a]:cursor-pointer all-[a:hover]:text-#0626ae',\n className,\n )}\n style={{\n maxWidth,\n display: maxWidth === undefined ? 'inherit' : 'inline-block',\n color: getTypeColor(type),\n }}\n {...props}\n >\n {child}\n </Component>\n </span>,\n ]);\n },\n);\n"],"mappings":";;;;;;;;;;;AAAA,OAAO,WAAW;AAClB,OAAO,UAAU;AAqFP;AA1DV,IAAM,eAAe,CAAC,SAAsB;AAC1C,QAAM,SAA2C;AAAA,IAC/C,SAAS;AAAA,IACT,SAAS;AAAA,IACT,WAAW;AAAA,IACX,SAAS;AAAA,IACT,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAEA,SAAO,OAAO,IAAI,KAAK,OAAO;AAChC;AAOO,IAAM,OAAO,MAAM;AAAA,EACxB,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB;AAAA,IACA,oBAAoB;AAAA,IACpB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,cAAc;AAAA,IACd,GAAG;AAAA,EACL,MAA+B;AAC7B,UAAM,YAAY;AAClB,UAAM,KAAK,cAAc;AACzB,QAAI,QAAyB;AAC7B,UAAM,WAAW,OAAO,MAAM,iBAAiB;AAC/C,UAAM,WAAW,OAAO,MAAM,iBAAiB;AAC/C,QACE,aA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AC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RenderAddress
|
|
3
|
+
} from "./chunk-XHNBO2OJ.js";
|
|
4
|
+
import {
|
|
5
|
+
formatAddress,
|
|
6
|
+
isInnerContractAddress
|
|
7
|
+
} from "./chunk-BVWWK2EL.js";
|
|
8
|
+
import {
|
|
9
|
+
Tooltip
|
|
10
|
+
} from "./chunk-U6VIVFW5.js";
|
|
11
|
+
import {
|
|
12
|
+
coreCorrespondsToEspace,
|
|
13
|
+
formatString,
|
|
14
|
+
getNetwork
|
|
15
|
+
} from "./chunk-RZWV4WHX.js";
|
|
16
|
+
import {
|
|
17
|
+
getEnvConfig,
|
|
18
|
+
getTranslations,
|
|
19
|
+
useGlobalData
|
|
20
|
+
} from "./chunk-DQGLZCIG.js";
|
|
21
|
+
|
|
22
|
+
// src/components/AddressContainer/addressSwitcher.tsx
|
|
23
|
+
import { AlertTriangle, File } from "@zeit-ui/react-icons";
|
|
24
|
+
import InternalContractIcon from "./internal-contract-icon-ZH2RG3CU.png";
|
|
25
|
+
import ContractIcon from "./contract-icon-P3W2HUAA.png";
|
|
26
|
+
import VerifiedIcon from "./verified-VJRHZNN7.png";
|
|
27
|
+
import isMeIcon from "./me-SIV36SR7.png";
|
|
28
|
+
import { isPosAddress } from "@cfx-kit/dapp-utils/dist/address";
|
|
29
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
30
|
+
var ContractCreatedAddress = (props) => {
|
|
31
|
+
const { contractCreated = "", outputType, t, isFull } = props;
|
|
32
|
+
const translations = getTranslations();
|
|
33
|
+
const contractAddress = formatAddress(contractCreated, outputType);
|
|
34
|
+
const customProps = {
|
|
35
|
+
content: t(translations.transaction.contractCreation),
|
|
36
|
+
alias: t(translations.transaction.contractCreation),
|
|
37
|
+
hrefAddress: contractAddress,
|
|
38
|
+
cfxAddress: contractAddress,
|
|
39
|
+
maxWidth: 160
|
|
40
|
+
};
|
|
41
|
+
const mergedProps = { ...props, ...customProps };
|
|
42
|
+
return RenderAddress({
|
|
43
|
+
...mergedProps,
|
|
44
|
+
prefix: /* @__PURE__ */ jsx("div", { className: `mr-[2px] flex-shrink-0 ${isFull ? "icon" : ""}`, children: /* @__PURE__ */ jsx(Tooltip, { title: mergedProps.content, children: /* @__PURE__ */ jsx("div", { className: "relative w-[16px] h-[16px]", children: /* @__PURE__ */ jsx(
|
|
45
|
+
"img",
|
|
46
|
+
{
|
|
47
|
+
className: "w-[16px] h-[16px] align-bottom mb-[3px]",
|
|
48
|
+
src: ContractIcon,
|
|
49
|
+
alt: mergedProps.content
|
|
50
|
+
}
|
|
51
|
+
) }) }) })
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
var CoreHexAddress = (props) => {
|
|
55
|
+
const { value, t, isFull, maxWidth } = props;
|
|
56
|
+
const { globalData } = useGlobalData();
|
|
57
|
+
const ENV_CONFIG = getEnvConfig();
|
|
58
|
+
const translations = getTranslations();
|
|
59
|
+
const hexAddress = formatAddress(value, "hex");
|
|
60
|
+
const network = getNetwork(
|
|
61
|
+
globalData?.networks,
|
|
62
|
+
coreCorrespondsToEspace(ENV_CONFIG.ENV_NETWORK_ID)
|
|
63
|
+
);
|
|
64
|
+
const url = `${network.url}/address/${hexAddress}`;
|
|
65
|
+
console.log("url", url);
|
|
66
|
+
return RenderAddress({
|
|
67
|
+
cfxAddress: hexAddress,
|
|
68
|
+
hoverValue: hexAddress,
|
|
69
|
+
link: url,
|
|
70
|
+
isFull,
|
|
71
|
+
maxWidth,
|
|
72
|
+
suffixSize: 0,
|
|
73
|
+
prefix: /* @__PURE__ */ jsx("div", { className: "mr-[2px] flex-shrink-0", children: /* @__PURE__ */ jsx(Tooltip, { title: t(translations.general.eSpaceAddress), children: /* @__PURE__ */ jsx(File, { size: 16, color: "#17B38A" }) }) })
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
var InvalidAddress = (props) => {
|
|
77
|
+
const {
|
|
78
|
+
value,
|
|
79
|
+
alias,
|
|
80
|
+
t,
|
|
81
|
+
isFull,
|
|
82
|
+
maxWidth,
|
|
83
|
+
isFullNameTag,
|
|
84
|
+
hideAliasPrefixInHover
|
|
85
|
+
} = props;
|
|
86
|
+
const translations = getTranslations();
|
|
87
|
+
const tip = t(translations.general.invalidAddress);
|
|
88
|
+
return RenderAddress({
|
|
89
|
+
cfxAddress: value,
|
|
90
|
+
alias,
|
|
91
|
+
hoverValue: `${tip}: ${value}`,
|
|
92
|
+
content: alias ? formatString(alias, "tag") : value,
|
|
93
|
+
link: false,
|
|
94
|
+
isFull,
|
|
95
|
+
isFullNameTag,
|
|
96
|
+
maxWidth,
|
|
97
|
+
style: { color: "#e00909" },
|
|
98
|
+
prefix: /* @__PURE__ */ jsx("div", { className: "mr-[2px] flex-shrink-0", children: /* @__PURE__ */ jsx(Tooltip, { title: tip, children: /* @__PURE__ */ jsx(AlertTriangle, { size: 16, color: "#e00909" }) }) }),
|
|
99
|
+
hideAliasPrefixInHover
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
var ContractAddress = (props) => {
|
|
103
|
+
const { showIcon, verify, t, cfxAddress, isFull } = props;
|
|
104
|
+
const translations = getTranslations();
|
|
105
|
+
const isInnerContract = cfxAddress && isInnerContractAddress(cfxAddress);
|
|
106
|
+
const typeText = t(
|
|
107
|
+
isInnerContract ? translations.general.internalContract : verify ? translations.general.verifiedContract : translations.general.unverifiedContract
|
|
108
|
+
);
|
|
109
|
+
return RenderAddress({
|
|
110
|
+
...props,
|
|
111
|
+
prefix: showIcon ? /* @__PURE__ */ jsx("div", { className: `mr-[2px] flex-shrink-0 ${isFull ? "icon" : ""}`, children: /* @__PURE__ */ jsx(Tooltip, { title: typeText, children: /* @__PURE__ */ jsx("div", { className: "relative w-[16px] h-[16px]", children: isInnerContract ? /* @__PURE__ */ jsx(
|
|
112
|
+
"img",
|
|
113
|
+
{
|
|
114
|
+
className: "w-[16px] h-[16px] align-bottom mb-[5px]",
|
|
115
|
+
src: InternalContractIcon,
|
|
116
|
+
alt: typeText
|
|
117
|
+
}
|
|
118
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
120
|
+
"img",
|
|
121
|
+
{
|
|
122
|
+
className: "w-[16px] h-[16px] align-bottom mb-[5px]",
|
|
123
|
+
src: ContractIcon,
|
|
124
|
+
alt: typeText
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
verify ? /* @__PURE__ */ jsx(
|
|
128
|
+
"img",
|
|
129
|
+
{
|
|
130
|
+
className: "w-[8px] h-[8px] absolute bottom-[-1px] right-[1px]",
|
|
131
|
+
src: VerifiedIcon,
|
|
132
|
+
alt: ""
|
|
133
|
+
}
|
|
134
|
+
) : /* @__PURE__ */ jsx(Fragment, {})
|
|
135
|
+
] }) }) }) }) : /* @__PURE__ */ jsx(Fragment, {})
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
var MyAddress = (props) => {
|
|
139
|
+
const { isFull } = props;
|
|
140
|
+
return RenderAddress({
|
|
141
|
+
...props,
|
|
142
|
+
suffix: /* @__PURE__ */ jsx("div", { className: "mr-[2px] flex-shrink-0", children: /* @__PURE__ */ jsx(
|
|
143
|
+
"img",
|
|
144
|
+
{
|
|
145
|
+
className: "w-[38.5px] h-[16px] ml-[3px] align-bottom",
|
|
146
|
+
src: isMeIcon,
|
|
147
|
+
alt: "is me",
|
|
148
|
+
style: {
|
|
149
|
+
marginBottom: isFull ? "6px" : "4px"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
) })
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
var PosAddress = (props) => {
|
|
156
|
+
const {
|
|
157
|
+
alias,
|
|
158
|
+
isFull,
|
|
159
|
+
isFullNameTag,
|
|
160
|
+
maxWidth,
|
|
161
|
+
t,
|
|
162
|
+
link,
|
|
163
|
+
isMe,
|
|
164
|
+
hideAliasPrefixInHover
|
|
165
|
+
} = props;
|
|
166
|
+
const value = props.value;
|
|
167
|
+
if (!value) {
|
|
168
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "--" });
|
|
169
|
+
}
|
|
170
|
+
if (isMe) {
|
|
171
|
+
return MyAddress(props);
|
|
172
|
+
}
|
|
173
|
+
const translations = getTranslations();
|
|
174
|
+
const content = alias ? formatString(alias, "tag") : formatString(value, "posAddress");
|
|
175
|
+
if (!isPosAddress(value)) {
|
|
176
|
+
const tip = t(translations.general.invalidPosAddress);
|
|
177
|
+
return RenderAddress({
|
|
178
|
+
cfxAddress: value,
|
|
179
|
+
alias,
|
|
180
|
+
hoverValue: `${tip}: ${value}`,
|
|
181
|
+
content,
|
|
182
|
+
link: false,
|
|
183
|
+
isFull,
|
|
184
|
+
isFullNameTag,
|
|
185
|
+
maxWidth,
|
|
186
|
+
style: { color: "#e00909" },
|
|
187
|
+
prefix: /* @__PURE__ */ jsx("div", { className: "mr-[2px] flex-shrink-0", children: /* @__PURE__ */ jsx(Tooltip, { title: tip, children: /* @__PURE__ */ jsx(AlertTriangle, { size: 16, color: "#e00909" }) }) }),
|
|
188
|
+
type: "pos",
|
|
189
|
+
hideAliasPrefixInHover
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return RenderAddress({
|
|
193
|
+
cfxAddress: value,
|
|
194
|
+
alias,
|
|
195
|
+
link,
|
|
196
|
+
isFull,
|
|
197
|
+
isFullNameTag,
|
|
198
|
+
maxWidth,
|
|
199
|
+
type: "pos",
|
|
200
|
+
content,
|
|
201
|
+
hideAliasPrefixInHover
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export {
|
|
206
|
+
ContractCreatedAddress,
|
|
207
|
+
CoreHexAddress,
|
|
208
|
+
InvalidAddress,
|
|
209
|
+
ContractAddress,
|
|
210
|
+
MyAddress,
|
|
211
|
+
PosAddress
|
|
212
|
+
};
|
|
213
|
+
//# sourceMappingURL=chunk-LXPKK77D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/addressSwitcher.tsx"],"sourcesContent":["import { WithTranslation } from 'react-i18next';\nimport { AlertTriangle, File } from '@zeit-ui/react-icons';\nimport InternalContractIcon from '../../images/internal-contract-icon.png';\nimport ContractIcon from '../../images/contract-icon.png';\nimport VerifiedIcon from '../../images/verified.png';\nimport isMeIcon from '../../images/me.png';\nimport { Tooltip } from '../Tooltip';\nimport { isPosAddress } from '@cfx-kit/dapp-utils/dist/address';\nimport { formatAddress, isInnerContractAddress } from '../../utils/address';\nimport { getTranslations, getEnvConfig, useGlobalData } from '../../store';\nimport { getNetwork, formatString, coreCorrespondsToEspace } from 'src/utils';\nimport { Props } from './types';\nimport { RenderAddress } from './addressView';\n\n// common\nexport const ContractCreatedAddress = (\n props: Props & WithTranslation & { outputType: 'hex' | 'base32' },\n) => {\n const { contractCreated = '', outputType, t, isFull } = props;\n\n const translations = getTranslations();\n\n const contractAddress = formatAddress(contractCreated, outputType);\n\n const customProps = {\n content: t(translations.transaction.contractCreation),\n alias: t(translations.transaction.contractCreation),\n hrefAddress: contractAddress,\n cfxAddress: contractAddress,\n maxWidth: 160,\n };\n\n const mergedProps = { ...props, ...customProps };\n return RenderAddress({\n ...mergedProps,\n prefix: (\n <div className={`mr-[2px] flex-shrink-0 ${isFull ? 'icon' : ''}`}>\n <Tooltip title={mergedProps.content}>\n <div className=\"relative w-[16px] h-[16px]\">\n <img\n className=\"w-[16px] h-[16px] align-bottom mb-[3px]\"\n src={ContractIcon}\n alt={mergedProps.content}\n />\n </div>\n </Tooltip>\n </div>\n ),\n });\n};\n\n// core\nexport const CoreHexAddress = (props: Props & WithTranslation) => {\n const { value, t, isFull, maxWidth } = props;\n const { globalData } = useGlobalData();\n\n const ENV_CONFIG = getEnvConfig();\n const translations = getTranslations();\n const hexAddress = formatAddress(value, 'hex');\n const network = getNetwork(\n globalData?.networks,\n coreCorrespondsToEspace(ENV_CONFIG.ENV_NETWORK_ID),\n );\n const url = `${network.url}/address/${hexAddress}`;\n console.log('url', url);\n\n return RenderAddress({\n cfxAddress: hexAddress,\n hoverValue: hexAddress,\n link: url,\n isFull,\n maxWidth,\n suffixSize: 0,\n prefix: (\n <div className=\"mr-[2px] flex-shrink-0\">\n <Tooltip title={t((translations as any).general.eSpaceAddress)}>\n <File size={16} color=\"#17B38A\" />\n </Tooltip>\n </div>\n ),\n });\n};\n\n// common\nexport const InvalidAddress = (props: Props & WithTranslation) => {\n const {\n value,\n alias,\n t,\n isFull,\n maxWidth,\n isFullNameTag,\n hideAliasPrefixInHover,\n } = props;\n\n const translations = getTranslations();\n\n const tip = t(translations.general.invalidAddress);\n\n return RenderAddress({\n cfxAddress: value,\n alias,\n hoverValue: `${tip}: ${value}`,\n content: alias ? formatString(alias, 'tag') : value,\n link: false,\n isFull,\n isFullNameTag,\n maxWidth,\n style: { color: '#e00909' },\n prefix: (\n <div className=\"mr-[2px] flex-shrink-0\">\n <Tooltip title={tip}>\n <AlertTriangle size={16} color=\"#e00909\" />\n </Tooltip>\n </div>\n ),\n hideAliasPrefixInHover,\n });\n};\n\n// common\nexport const ContractAddress = (props: Props & WithTranslation) => {\n const { showIcon, verify, t, cfxAddress, isFull } = props;\n\n const translations = getTranslations();\n\n const isInnerContract = cfxAddress && isInnerContractAddress(cfxAddress);\n\n const typeText = t(\n isInnerContract\n ? translations.general.internalContract\n : verify\n ? translations.general.verifiedContract\n : translations.general.unverifiedContract,\n );\n\n return RenderAddress({\n ...props,\n prefix: showIcon ? (\n <div className={`mr-[2px] flex-shrink-0 ${isFull ? 'icon' : ''}`}>\n <Tooltip title={typeText}>\n <div className=\"relative w-[16px] h-[16px]\">\n {isInnerContract ? (\n <img\n className=\"w-[16px] h-[16px] align-bottom mb-[5px]\"\n src={InternalContractIcon}\n alt={typeText}\n />\n ) : (\n <>\n <img\n className=\"w-[16px] h-[16px] align-bottom mb-[5px]\"\n src={ContractIcon}\n alt={typeText}\n />\n {verify ? (\n <img\n className=\"w-[8px] h-[8px] absolute bottom-[-1px] right-[1px]\"\n src={VerifiedIcon}\n alt={''}\n />\n ) : (\n <></>\n )}\n </>\n )}\n </div>\n </Tooltip>\n </div>\n ) : (\n <></>\n ),\n });\n};\n\n// common\nexport const MyAddress = (props: Props & WithTranslation) => {\n const { isFull } = props;\n return RenderAddress({\n ...props,\n suffix: (\n <div className=\"mr-[2px] flex-shrink-0\">\n <img\n className=\"w-[38.5px] h-[16px] ml-[3px] align-bottom\"\n src={isMeIcon}\n alt=\"is me\"\n style={{\n marginBottom: isFull ? '6px' : '4px',\n }}\n />\n </div>\n ),\n });\n};\n\n// core\nexport const PosAddress = (props: Props & WithTranslation) => {\n const {\n alias,\n isFull,\n isFullNameTag,\n maxWidth,\n t,\n link,\n isMe,\n hideAliasPrefixInHover,\n } = props;\n const value = props.value;\n if (!value) {\n return <>--</>;\n }\n if (isMe) {\n return MyAddress(props);\n }\n const translations = getTranslations();\n const content = alias\n ? formatString(alias, 'tag')\n : formatString(value, 'posAddress');\n if (!isPosAddress(value)) {\n const tip = t(translations.general.invalidPosAddress);\n return RenderAddress({\n cfxAddress: value,\n alias,\n hoverValue: `${tip}: ${value}`,\n content,\n link: false,\n isFull,\n isFullNameTag,\n maxWidth,\n style: { color: '#e00909' },\n prefix: (\n <div className=\"mr-[2px] flex-shrink-0\">\n <Tooltip title={tip}>\n <AlertTriangle size={16} color=\"#e00909\" />\n </Tooltip>\n </div>\n ),\n type: 'pos',\n hideAliasPrefixInHover,\n });\n }\n\n return RenderAddress({\n cfxAddress: value,\n alias,\n link,\n isFull,\n isFullNameTag,\n maxWidth,\n type: 'pos',\n content,\n hideAliasPrefixInHover,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,eAAe,YAAY;AACpC,OAAO,0BAA0B;AACjC,OAAO,kBAAkB;AACzB,OAAO,kBAAkB;AACzB,OAAO,cAAc;AAErB,SAAS,oBAAoB;AAgCjB,SA2HM,UA3HN,KA8GE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