@cfxjs/sirius-next-common 0.2.19 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-C3E5EA6J.js → chunk-4LSM4TMM.js} +8 -8
- package/dist/{chunk-C3E5EA6J.js.map → chunk-4LSM4TMM.js.map} +1 -1
- package/dist/{chunk-MUW5KBWU.js → chunk-HF7RD7UD.js} +7 -3
- package/dist/chunk-HF7RD7UD.js.map +1 -0
- package/dist/{chunk-S7M6UTND.js → chunk-J6ZC77OY.js} +3 -3
- package/dist/{chunk-GPQN2P32.js → chunk-LCV3NUFR.js} +2 -2
- package/dist/{chunk-TC4445WV.js → chunk-XUKHHB5L.js} +3 -3
- package/dist/components/AddressContainer/CoreAddressContainer.js +3 -3
- package/dist/components/AddressContainer/EVMAddressContainer.js +3 -3
- package/dist/components/AddressContainer/addressSwitcher.js +2 -2
- package/dist/components/AddressContainer/addressView.js +1 -1
- package/dist/components/TransactionAction/coreTransactionAction.js +3 -3
- package/dist/components/TransactionAction/evmTransactionAction.js +3 -3
- package/dist/utils/hooks/useAddressNameMap.d.ts +7 -2
- package/dist/utils/hooks/useAddressNameMap.js +3 -1
- package/dist/utils/hooks/useEnhanceDataWithNameMap.d.ts +1 -4
- package/dist/utils/hooks/useEnhanceDataWithNameMap.js +2 -5
- package/dist/utils/hooks/useEnhanceDataWithNameMap.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-MUW5KBWU.js.map +0 -1
- /package/dist/{chunk-S7M6UTND.js.map → chunk-J6ZC77OY.js.map} +0 -0
- /package/dist/{chunk-GPQN2P32.js.map → chunk-LCV3NUFR.js.map} +0 -0
- /package/dist/{chunk-TC4445WV.js.map → chunk-XUKHHB5L.js.map} +0 -0
|
@@ -92,22 +92,22 @@ var RenderAddress = ({
|
|
|
92
92
|
const href = convertLink({ link, type, hrefAddress, cfxAddress });
|
|
93
93
|
const Wrapper = href ? "a" : "div";
|
|
94
94
|
const tooltipContent = {
|
|
95
|
-
|
|
96
|
-
label: translations?.
|
|
97
|
-
value:
|
|
95
|
+
addressLabel: {
|
|
96
|
+
label: translations?.profile.address.myNameTag,
|
|
97
|
+
value: addressLabel
|
|
98
98
|
},
|
|
99
99
|
nametag: {
|
|
100
100
|
label: translations?.nametag?.tip,
|
|
101
101
|
value: nametag
|
|
102
102
|
},
|
|
103
|
-
addressLabel: {
|
|
104
|
-
label: translations?.profile.address.myNameTag,
|
|
105
|
-
value: addressLabel
|
|
106
|
-
},
|
|
107
103
|
alias: {
|
|
108
104
|
label: translations?.profile.address.publicNameTag,
|
|
109
105
|
value: tokenName || contractName || verificationName,
|
|
110
106
|
hideLabel: hideAliasPrefixInHover
|
|
107
|
+
},
|
|
108
|
+
ENSLabel: {
|
|
109
|
+
label: translations?.ens?.tip,
|
|
110
|
+
value: ENSLabel
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
const checksumAddress = convertCheckSum(cfxAddress);
|
|
@@ -143,4 +143,4 @@ var RenderAddress = ({
|
|
|
143
143
|
export {
|
|
144
144
|
RenderAddress
|
|
145
145
|
};
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-4LSM4TMM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/AddressContainer/addressView.tsx"],"sourcesContent":["import { Translation } from 'react-i18next';\nimport { Text } from '../Text';\nimport { convertCheckSum } from '../../utils/address';\nimport { getTranslations } from '../../store';\nimport { TooltipContent, RenderAddressProps } from './types';\nimport { shortenAddress } from '@cfx-kit/dapp-utils/dist/address';\n\nconst defaultPCMaxWidth = 138;\n\n// common\nconst renderTooltipContent = (tooltipContent: TooltipContent) => {\n return Object.entries(tooltipContent)\n .map(([key, { label, value, hideLabel }]) => {\n if (value) {\n return (\n <div key={key}>\n {!hideLabel && (\n <span>\n <Translation>{t => t(label)}</Translation>\n </span>\n )}\n {value}\n </div>\n );\n }\n return null;\n })\n .filter(Boolean);\n};\n\n// common\nconst convertLink = ({\n link,\n type,\n hrefAddress,\n cfxAddress,\n}: RenderAddressProps) => {\n if (typeof link === 'string') {\n return link;\n }\n if (link === false) {\n return false;\n }\n\n const address = hrefAddress || cfxAddress;\n\n if (address && typeof address === 'string') {\n const pathname = window.location.pathname.toLowerCase();\n const addressLower = address.toLowerCase();\n if (pathname.includes('/address/' + addressLower)) {\n return false;\n }\n\n if (type === 'pow') {\n return `/address/${address}`;\n }\n\n if (type === 'pos') {\n return `/pos/accounts/${address}`;\n }\n }\n\n return false;\n};\n\n// common\nexport const RenderAddress = ({\n cfxAddress,\n tokenName,\n contractName,\n verificationName,\n hoverValue,\n hrefAddress,\n link = '',\n isFull = false,\n isFullNameTag = false,\n style = {},\n maxWidth,\n prefix = null,\n ENSIcon = null,\n suffix = null,\n type = 'pow',\n addressLabel = '',\n ENSLabel = '',\n nametag = '',\n innerName = '',\n hideAliasPrefixInHover = false,\n}: RenderAddressProps) => {\n const translations = getTranslations();\n\n // Private name tags > Official tag/name > contract token name > contract name tag > contract verification name > CNS/ENS\n const name =\n // Private name tags\n addressLabel ||\n // Official tag/name\n nametag ||\n // contract token name\n tokenName ||\n // contract name tag\n contractName ||\n // contract verification name\n verificationName ||\n // CNS/ENS\n ENSLabel ||\n // inner name is used for some special address, like the zero address\n innerName;\n const isShowEns = !!ENSLabel && name === ENSLabel;\n\n const defaultStyle = {\n maxWidth: `${(name && isFullNameTag) || isFull ? 'unset' : (maxWidth || defaultPCMaxWidth) + 'px'}`,\n };\n\n const href = convertLink({ link, type, hrefAddress, cfxAddress });\n\n const Wrapper = href ? 'a' : 'div';\n\n const tooltipContent: TooltipContent = {\n
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/addressView.tsx"],"sourcesContent":["import { Translation } from 'react-i18next';\nimport { Text } from '../Text';\nimport { convertCheckSum } from '../../utils/address';\nimport { getTranslations } from '../../store';\nimport { TooltipContent, RenderAddressProps } from './types';\nimport { shortenAddress } from '@cfx-kit/dapp-utils/dist/address';\n\nconst defaultPCMaxWidth = 138;\n\n// common\nconst renderTooltipContent = (tooltipContent: TooltipContent) => {\n return Object.entries(tooltipContent)\n .map(([key, { label, value, hideLabel }]) => {\n if (value) {\n return (\n <div key={key}>\n {!hideLabel && (\n <span>\n <Translation>{t => t(label)}</Translation>\n </span>\n )}\n {value}\n </div>\n );\n }\n return null;\n })\n .filter(Boolean);\n};\n\n// common\nconst convertLink = ({\n link,\n type,\n hrefAddress,\n cfxAddress,\n}: RenderAddressProps) => {\n if (typeof link === 'string') {\n return link;\n }\n if (link === false) {\n return false;\n }\n\n const address = hrefAddress || cfxAddress;\n\n if (address && typeof address === 'string') {\n const pathname = window.location.pathname.toLowerCase();\n const addressLower = address.toLowerCase();\n if (pathname.includes('/address/' + addressLower)) {\n return false;\n }\n\n if (type === 'pow') {\n return `/address/${address}`;\n }\n\n if (type === 'pos') {\n return `/pos/accounts/${address}`;\n }\n }\n\n return false;\n};\n\n// common\nexport const RenderAddress = ({\n cfxAddress,\n tokenName,\n contractName,\n verificationName,\n hoverValue,\n hrefAddress,\n link = '',\n isFull = false,\n isFullNameTag = false,\n style = {},\n maxWidth,\n prefix = null,\n ENSIcon = null,\n suffix = null,\n type = 'pow',\n addressLabel = '',\n ENSLabel = '',\n nametag = '',\n innerName = '',\n hideAliasPrefixInHover = false,\n}: RenderAddressProps) => {\n const translations = getTranslations();\n\n // Private name tags > Official tag/name > contract token name > contract name tag > contract verification name > CNS/ENS\n const name =\n // Private name tags\n addressLabel ||\n // Official tag/name\n nametag ||\n // contract token name\n tokenName ||\n // contract name tag\n contractName ||\n // contract verification name\n verificationName ||\n // CNS/ENS\n ENSLabel ||\n // inner name is used for some special address, like the zero address\n innerName;\n const isShowEns = !!ENSLabel && name === ENSLabel;\n\n const defaultStyle = {\n maxWidth: `${(name && isFullNameTag) || isFull ? 'unset' : (maxWidth || defaultPCMaxWidth) + 'px'}`,\n };\n\n const href = convertLink({ link, type, hrefAddress, cfxAddress });\n\n const Wrapper = href ? 'a' : 'div';\n\n const tooltipContent: TooltipContent = {\n addressLabel: {\n label: translations?.profile.address.myNameTag,\n value: addressLabel,\n },\n nametag: {\n label: translations?.nametag?.tip,\n value: nametag,\n },\n alias: {\n label: translations?.profile.address.publicNameTag,\n value: tokenName || contractName || verificationName,\n hideLabel: hideAliasPrefixInHover,\n },\n ENSLabel: {\n label: (translations as any)?.ens?.tip,\n value: ENSLabel,\n },\n };\n\n const checksumAddress = convertCheckSum(cfxAddress);\n\n const cfxAddressLabel =\n typeof checksumAddress === 'string' && !isFull\n ? type === 'pos'\n ? shortenAddress(checksumAddress!, {\n prefixLength: 10,\n suffixLength: 0,\n })\n : shortenAddress(checksumAddress!)\n : checksumAddress;\n\n return (\n <div className=\"inline-flex\">\n {prefix || (isShowEns ? ENSIcon : null)}\n <Text\n tag=\"span\"\n hoverValue={\n <>\n {renderTooltipContent(tooltipContent)}\n <div>{hoverValue || checksumAddress}</div>\n </>\n }\n >\n <Wrapper\n className=\"block relative align-bottom cursor-default truncate\"\n style={{ ...defaultStyle, ...style }}\n {...(href ? { href: String(href) } : {})}\n >\n {name || cfxAddressLabel}\n </Wrapper>\n </Text>\n {suffix}\n </div>\n );\n};\n"],"mappings":"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","names":[]}
|
|
@@ -5,9 +5,12 @@ import {
|
|
|
5
5
|
// src/utils/hooks/useAddressNameMap.ts
|
|
6
6
|
import useSWRImmutable from "swr/immutable";
|
|
7
7
|
import { useMemo } from "react";
|
|
8
|
+
var transformNameMapKeysToLowerCase = (nameMap) => nameMap && Object.fromEntries(
|
|
9
|
+
Object.entries(nameMap).map(([k, v]) => [k.toLowerCase(), v])
|
|
10
|
+
);
|
|
8
11
|
var useAddressNameMap = (addresses, shouldFetch = true) => {
|
|
9
12
|
const key = useMemo(() => {
|
|
10
|
-
return shouldFetch && addresses.length > 0 ? `address-name-map-${
|
|
13
|
+
return shouldFetch && addresses.length > 0 ? `address-name-map-${addresses.map((i) => i.toLowerCase()).sort().join(",")}` : null;
|
|
11
14
|
}, [addresses, shouldFetch]);
|
|
12
15
|
return useSWRImmutable(
|
|
13
16
|
key,
|
|
@@ -15,11 +18,12 @@ var useAddressNameMap = (addresses, shouldFetch = true) => {
|
|
|
15
18
|
withContractInfo: "true",
|
|
16
19
|
withNameTagInfo: "true",
|
|
17
20
|
withENSInfo: "true"
|
|
18
|
-
})
|
|
21
|
+
}).then(transformNameMapKeysToLowerCase)
|
|
19
22
|
);
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export {
|
|
26
|
+
transformNameMapKeysToLowerCase,
|
|
23
27
|
useAddressNameMap
|
|
24
28
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-HF7RD7UD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/hooks/useAddressNameMap.ts"],"sourcesContent":["import useSWRImmutable from 'swr/immutable';\nimport { fetchAddressNameMap } from '../request';\nimport { useMemo } from 'react';\nimport { AddressNameMap } from '../request.types';\n\nexport const transformNameMapKeysToLowerCase = (\n nameMap?: Record<string, AddressNameMap>,\n) =>\n nameMap &&\n Object.fromEntries(\n Object.entries(nameMap).map(([k, v]) => [k.toLowerCase(), v]),\n );\n\nexport const useAddressNameMap = (addresses: string[], shouldFetch = true) => {\n const key = useMemo(() => {\n return shouldFetch && addresses.length > 0\n ? `address-name-map-${addresses\n .map(i => i.toLowerCase())\n .sort()\n .join(',')}`\n : null;\n }, [addresses, shouldFetch]);\n return useSWRImmutable(key, () =>\n fetchAddressNameMap(addresses, {\n withContractInfo: 'true',\n withNameTagInfo: 'true',\n withENSInfo: 'true',\n }).then(transformNameMapKeysToLowerCase),\n );\n};\n"],"mappings":";;;;;AAAA,OAAO,qBAAqB;AAE5B,SAAS,eAAe;AAGjB,IAAM,kCAAkC,CAC7C,YAEA,WACA,OAAO;AAAA,EACL,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC;AAC9D;AAEK,IAAM,oBAAoB,CAAC,WAAqB,cAAc,SAAS;AAC5E,QAAM,MAAM,QAAQ,MAAM;AACxB,WAAO,eAAe,UAAU,SAAS,IACrC,oBAAoB,UACjB,IAAI,OAAK,EAAE,YAAY,CAAC,EACxB,KAAK,EACL,KAAK,GAAG,MACX;AAAA,EACN,GAAG,CAAC,WAAW,WAAW,CAAC;AAC3B,SAAO;AAAA,IAAgB;AAAA,IAAK,MAC1B,oBAAoB,WAAW;AAAA,MAC7B,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,MACjB,aAAa;AAAA,IACf,CAAC,EAAE,KAAK,+BAA+B;AAAA,EACzC;AACF;","names":[]}
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
InvalidAddress,
|
|
12
12
|
MyAddress,
|
|
13
13
|
PosAddress
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LCV3NUFR.js";
|
|
15
15
|
import {
|
|
16
16
|
RenderAddress
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-4LSM4TMM.js";
|
|
18
18
|
import {
|
|
19
19
|
formatAddress,
|
|
20
20
|
isCoreAddress,
|
|
@@ -143,4 +143,4 @@ var CoreAddressContainer = withTranslation()(
|
|
|
143
143
|
export {
|
|
144
144
|
CoreAddressContainer
|
|
145
145
|
};
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-J6ZC77OY.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-MWAD4CIG.js";
|
|
4
4
|
import {
|
|
5
5
|
RenderAddress
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4LSM4TMM.js";
|
|
7
7
|
import {
|
|
8
8
|
formatAddress,
|
|
9
9
|
isInnerContractAddress
|
|
@@ -209,4 +209,4 @@ export {
|
|
|
209
209
|
MyAddress,
|
|
210
210
|
PosAddress
|
|
211
211
|
};
|
|
212
|
-
//# sourceMappingURL=chunk-
|
|
212
|
+
//# sourceMappingURL=chunk-LCV3NUFR.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
ContractCreatedAddress,
|
|
7
7
|
InvalidAddress,
|
|
8
8
|
MyAddress
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LCV3NUFR.js";
|
|
10
10
|
import {
|
|
11
11
|
RenderAddress
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4LSM4TMM.js";
|
|
13
13
|
import {
|
|
14
14
|
convertCheckSum,
|
|
15
15
|
formatAddress,
|
|
@@ -109,4 +109,4 @@ var EVMAddressContainer = withTranslation()(
|
|
|
109
109
|
export {
|
|
110
110
|
EVMAddressContainer
|
|
111
111
|
};
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-XUKHHB5L.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CoreAddressContainer
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-J6ZC77OY.js";
|
|
4
4
|
import "../../chunk-CMOP3BKX.js";
|
|
5
5
|
import "../../chunk-WZIT54AU.js";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-LCV3NUFR.js";
|
|
7
7
|
import "../../chunk-MWAD4CIG.js";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-4LSM4TMM.js";
|
|
9
9
|
import "../../chunk-6L4ZEJQI.js";
|
|
10
10
|
import "../../chunk-C7OIVXE3.js";
|
|
11
11
|
import "../../chunk-TOKKKTFG.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EVMAddressContainer
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-XUKHHB5L.js";
|
|
4
4
|
import "../../chunk-WZIT54AU.js";
|
|
5
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-LCV3NUFR.js";
|
|
6
6
|
import "../../chunk-MWAD4CIG.js";
|
|
7
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-4LSM4TMM.js";
|
|
8
8
|
import "../../chunk-6L4ZEJQI.js";
|
|
9
9
|
import "../../chunk-C7OIVXE3.js";
|
|
10
10
|
import "../../chunk-TOKKKTFG.js";
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
InvalidAddress,
|
|
6
6
|
MyAddress,
|
|
7
7
|
PosAddress
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-LCV3NUFR.js";
|
|
9
9
|
import "../../chunk-MWAD4CIG.js";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-4LSM4TMM.js";
|
|
11
11
|
import "../../chunk-6L4ZEJQI.js";
|
|
12
12
|
import "../../chunk-C7OIVXE3.js";
|
|
13
13
|
import "../../chunk-TOKKKTFG.js";
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
import "../../chunk-TGK5LP2H.js";
|
|
11
11
|
import {
|
|
12
12
|
CoreAddressContainer
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-J6ZC77OY.js";
|
|
14
14
|
import "../../chunk-CMOP3BKX.js";
|
|
15
15
|
import "../../chunk-WZIT54AU.js";
|
|
16
|
-
import "../../chunk-
|
|
16
|
+
import "../../chunk-LCV3NUFR.js";
|
|
17
17
|
import "../../chunk-MWAD4CIG.js";
|
|
18
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-4LSM4TMM.js";
|
|
19
19
|
import "../../chunk-6L4ZEJQI.js";
|
|
20
20
|
import "../../chunk-C7OIVXE3.js";
|
|
21
21
|
import "../../chunk-TOKKKTFG.js";
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
import "../../chunk-TGK5LP2H.js";
|
|
11
11
|
import {
|
|
12
12
|
EVMAddressContainer
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-XUKHHB5L.js";
|
|
14
14
|
import "../../chunk-WZIT54AU.js";
|
|
15
|
-
import "../../chunk-
|
|
15
|
+
import "../../chunk-LCV3NUFR.js";
|
|
16
16
|
import "../../chunk-MWAD4CIG.js";
|
|
17
|
-
import "../../chunk-
|
|
17
|
+
import "../../chunk-4LSM4TMM.js";
|
|
18
18
|
import {
|
|
19
19
|
formatAddress
|
|
20
20
|
} from "../../chunk-6L4ZEJQI.js";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as swr from 'swr';
|
|
2
2
|
import { AddressNameMap } from '../request.types.js';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare const transformNameMapKeysToLowerCase: (nameMap?: Record<string, AddressNameMap>) => {
|
|
5
|
+
[k: string]: AddressNameMap;
|
|
6
|
+
} | undefined;
|
|
7
|
+
declare const useAddressNameMap: (addresses: string[], shouldFetch?: boolean) => swr.SWRResponse<{
|
|
8
|
+
[k: string]: AddressNameMap;
|
|
9
|
+
} | undefined, any, any>;
|
|
5
10
|
|
|
6
|
-
export { useAddressNameMap };
|
|
11
|
+
export { transformNameMapKeysToLowerCase, useAddressNameMap };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
transformNameMapKeysToLowerCase,
|
|
2
3
|
useAddressNameMap
|
|
3
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-HF7RD7UD.js";
|
|
4
5
|
import "../../chunk-VGYNHJFT.js";
|
|
5
6
|
import "../../chunk-J2I22Q2M.js";
|
|
6
7
|
import "../../chunk-YEINMVAR.js";
|
|
7
8
|
import "../../chunk-DQGLZCIG.js";
|
|
8
9
|
import "../../chunk-WQG2LZMB.js";
|
|
9
10
|
export {
|
|
11
|
+
transformNameMapKeysToLowerCase,
|
|
10
12
|
useAddressNameMap
|
|
11
13
|
};
|
|
12
14
|
//# sourceMappingURL=useAddressNameMap.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { AddressNameMap } from '../request.types.js';
|
|
2
2
|
|
|
3
|
-
declare const transformNameMapKeysToLowerCase: (nameMap?: Record<string, AddressNameMap>) => {
|
|
4
|
-
[k: string]: AddressNameMap;
|
|
5
|
-
} | undefined;
|
|
6
3
|
declare const enhanceDataWithNameMap: (list?: Record<string, unknown>[], nameMap?: Record<string, AddressNameMap>) => Record<string, unknown>[] | {
|
|
7
4
|
nameMap: {
|
|
8
5
|
[k: string]: AddressNameMap;
|
|
@@ -27,4 +24,4 @@ declare const useEnhanceDataWithNameMap: (list?: Record<string, unknown>[], { ad
|
|
|
27
24
|
isLoading: boolean;
|
|
28
25
|
};
|
|
29
26
|
|
|
30
|
-
export { enhanceDataWithNameMap, formatListResponseWithNameMap,
|
|
27
|
+
export { enhanceDataWithNameMap, formatListResponseWithNameMap, useEnhanceDataWithNameMap };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
transformNameMapKeysToLowerCase,
|
|
2
3
|
useAddressNameMap
|
|
3
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-HF7RD7UD.js";
|
|
4
5
|
import "../../chunk-VGYNHJFT.js";
|
|
5
6
|
import "../../chunk-J2I22Q2M.js";
|
|
6
7
|
import "../../chunk-YEINMVAR.js";
|
|
@@ -9,9 +10,6 @@ import "../../chunk-WQG2LZMB.js";
|
|
|
9
10
|
|
|
10
11
|
// src/utils/hooks/useEnhanceDataWithNameMap.ts
|
|
11
12
|
import { useMemo } from "react";
|
|
12
|
-
var transformNameMapKeysToLowerCase = (nameMap) => nameMap && Object.fromEntries(
|
|
13
|
-
Object.entries(nameMap).map(([k, v]) => [k.toLowerCase(), v])
|
|
14
|
-
);
|
|
15
13
|
var enhanceDataWithNameMap = (list, nameMap) => {
|
|
16
14
|
if (!nameMap || !list)
|
|
17
15
|
return list;
|
|
@@ -65,7 +63,6 @@ var useEnhanceDataWithNameMap = (list, {
|
|
|
65
63
|
export {
|
|
66
64
|
enhanceDataWithNameMap,
|
|
67
65
|
formatListResponseWithNameMap,
|
|
68
|
-
transformNameMapKeysToLowerCase,
|
|
69
66
|
useEnhanceDataWithNameMap
|
|
70
67
|
};
|
|
71
68
|
//# sourceMappingURL=useEnhanceDataWithNameMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/hooks/useEnhanceDataWithNameMap.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/hooks/useEnhanceDataWithNameMap.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n transformNameMapKeysToLowerCase,\n useAddressNameMap,\n} from './useAddressNameMap';\nimport { AddressNameMap } from '../request.types';\n\nexport const enhanceDataWithNameMap = (\n list?: Record<string, unknown>[],\n nameMap?: Record<string, AddressNameMap>,\n) => {\n if (!nameMap || !list) return list;\n const normalizedNameMap = transformNameMapKeysToLowerCase(nameMap);\n\n return (\n list.map(item => {\n const newItem = {\n ...item,\n nameMap: normalizedNameMap,\n };\n return newItem;\n }) || []\n );\n};\n\nexport const formatListResponseWithNameMap = <\n T extends Record<string, unknown>,\n>(\n res: T,\n) => {\n return {\n ...res,\n list: enhanceDataWithNameMap(\n res.list as Record<string, unknown>[],\n res.nameMap as Record<string, AddressNameMap>,\n ),\n };\n};\n\nexport const useEnhanceDataWithNameMap = (\n list?: Record<string, unknown>[],\n {\n addressKeys,\n nameMap,\n }: {\n addressKeys?: string[];\n nameMap?: Record<string, AddressNameMap>;\n } = {},\n) => {\n const keys = useMemo(() => addressKeys?.join(',') || '', [addressKeys]);\n const addresses = useMemo(() => {\n const set = new Set<string>();\n list?.forEach(item => {\n addressKeys?.forEach(key => {\n const address = item[key];\n if (address && typeof address === 'string') {\n set.add(address);\n }\n });\n });\n return Array.from(set);\n }, [list, keys]);\n const { data: fetchedNameMap, isLoading } = useAddressNameMap(\n addresses,\n !nameMap,\n );\n const finalNameMap = nameMap || fetchedNameMap;\n return useMemo(() => {\n return {\n data: enhanceDataWithNameMap(list, finalNameMap),\n isLoading,\n };\n }, [list, finalNameMap, isLoading]);\n};\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe;AAOjB,IAAM,yBAAyB,CACpC,MACA,YACG;AACH,MAAI,CAAC,WAAW,CAAC;AAAM,WAAO;AAC9B,QAAM,oBAAoB,gCAAgC,OAAO;AAEjE,SACE,KAAK,IAAI,UAAQ;AACf,UAAM,UAAU;AAAA,MACd,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AACA,WAAO;AAAA,EACT,CAAC,KAAK,CAAC;AAEX;AAEO,IAAM,gCAAgC,CAG3C,QACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAAA,EACF;AACF;AAEO,IAAM,4BAA4B,CACvC,MACA;AAAA,EACE;AAAA,EACA;AACF,IAGI,CAAC,MACF;AACH,QAAM,OAAO,QAAQ,MAAM,aAAa,KAAK,GAAG,KAAK,IAAI,CAAC,WAAW,CAAC;AACtE,QAAM,YAAY,QAAQ,MAAM;AAC9B,UAAM,MAAM,oBAAI,IAAY;AAC5B,UAAM,QAAQ,UAAQ;AACpB,mBAAa,QAAQ,SAAO;AAC1B,cAAM,UAAU,KAAK,GAAG;AACxB,YAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,cAAI,IAAI,OAAO;AAAA,QACjB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AACD,WAAO,MAAM,KAAK,GAAG;AAAA,EACvB,GAAG,CAAC,MAAM,IAAI,CAAC;AACf,QAAM,EAAE,MAAM,gBAAgB,UAAU,IAAI;AAAA,IAC1C;AAAA,IACA,CAAC;AAAA,EACH;AACA,QAAM,eAAe,WAAW;AAChC,SAAO,QAAQ,MAAM;AACnB,WAAO;AAAA,MACL,MAAM,uBAAuB,MAAM,YAAY;AAAA,MAC/C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,MAAM,cAAc,SAAS,CAAC;AACpC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/hooks/useAddressNameMap.ts"],"sourcesContent":["import useSWRImmutable from 'swr/immutable';\nimport { fetchAddressNameMap } from '../request';\nimport { useMemo } from 'react';\n\nexport const useAddressNameMap = (addresses: string[], shouldFetch = true) => {\n const key = useMemo(() => {\n return shouldFetch && addresses.length > 0\n ? `address-name-map-${[...addresses].sort().join(',')}`\n : null;\n }, [addresses, shouldFetch]);\n return useSWRImmutable(key, () =>\n fetchAddressNameMap(addresses, {\n withContractInfo: 'true',\n withNameTagInfo: 'true',\n withENSInfo: 'true',\n }),\n );\n};\n"],"mappings":";;;;;AAAA,OAAO,qBAAqB;AAE5B,SAAS,eAAe;AAEjB,IAAM,oBAAoB,CAAC,WAAqB,cAAc,SAAS;AAC5E,QAAM,MAAM,QAAQ,MAAM;AACxB,WAAO,eAAe,UAAU,SAAS,IACrC,oBAAoB,CAAC,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,MAClD;AAAA,EACN,GAAG,CAAC,WAAW,WAAW,CAAC;AAC3B,SAAO;AAAA,IAAgB;AAAA,IAAK,MAC1B,oBAAoB,WAAW;AAAA,MAC7B,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,MACjB,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|