@thenamespace/ens-components 1.1.5 → 1.2.0
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/README.md +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +176 -81
- package/dist/index.js.map +1 -1
- package/dist/types/components/molecules/pricing-display/PricingDisplay.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useEthDollarValue.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,5 +196,5 @@ Components use CSS variables that can be overridden:
|
|
|
196
196
|
|
|
197
197
|
- [Namespace](https://namespace.ninja) — subname issuance platform
|
|
198
198
|
- [ENS](https://ens.domains) — Ethereum Name Service
|
|
199
|
-
- [Source](https://github.com/thenamespace/
|
|
199
|
+
- [Source](https://github.com/thenamespace/ens-components)
|
|
200
200
|
- [npm](https://www.npmjs.com/package/@thenamespace/ens-components)
|
package/dist/index.d.ts
CHANGED
|
@@ -457,6 +457,7 @@ interface PricingDisplayProps {
|
|
|
457
457
|
years: number;
|
|
458
458
|
onYearsChange: (years: number) => void;
|
|
459
459
|
};
|
|
460
|
+
ethUsdRate?: number | null;
|
|
460
461
|
className?: string;
|
|
461
462
|
}
|
|
462
463
|
declare const PricingDisplay: React__default.FC<PricingDisplayProps>;
|
|
@@ -591,6 +592,10 @@ interface ThemeProviderProps {
|
|
|
591
592
|
declare const ThemeProvider: React__default.FC<ThemeProviderProps>;
|
|
592
593
|
declare const useTheme: () => ThemeContextValue;
|
|
593
594
|
|
|
595
|
+
declare function useEthDollarValue(): {
|
|
596
|
+
ethUsdRate: number | null;
|
|
597
|
+
};
|
|
598
|
+
|
|
594
599
|
interface RentPriceResponse {
|
|
595
600
|
wei: bigint;
|
|
596
601
|
eth: number;
|
|
@@ -846,5 +851,5 @@ declare const useAvatarClient: ({ isTestnet, domain }: UseAvatarClientParams) =>
|
|
|
846
851
|
getErrorMessage: (err: unknown, imageType?: UploadImageType) => string;
|
|
847
852
|
};
|
|
848
853
|
|
|
849
|
-
export { Accordion, Alert, Button, Card, ChainIcon, ConnectAndSetChain, ContenthashIcon, ContenthashProtocol, ContractErrorLabel, Dropdown, ENS_RESOLVER_ABI, EnsNameRegistrationForm, EnsRecordsForm, Icon, Input, ListingNetwork, ListingType, MULTICALL, Modal, OffchainSubnameForm, PricingDisplay, ProfileHeader, ProgressBar, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, ShurikenSpinner, SubnameMintForm, Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TransactionPendingScreen, TxProgress, capitalize, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce, deepCopy, diffToEnsRecords, ensureFloatInput, equalsIgnoreCase, formatFloat, getAvatarUploadErrorMessage, getBlockExplorer, getBlockExplorerAddressUrl, getBlockExplorerName, getBlockExplorerTransactionUrl, getChainIdForListingNetwork, getEnsAppUrl, getEnsRecordsDiff, getImageUploadErrorMessage, getSupportedAddressByChainId, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isCommitmentToNewErr, isContenthashValid, isUserDeniedError, supportedAddresses, supportedContenthashRecords, supportedTexts, useAvatarClient, useENSResolver, useMintManager, useMintSubname, useOffchainManager, useRegisterENS, useTheme, useWaitTransaction, validateEnsRecords, wait };
|
|
854
|
+
export { Accordion, Alert, Button, Card, ChainIcon, ConnectAndSetChain, ContenthashIcon, ContenthashProtocol, ContractErrorLabel, Dropdown, ENS_RESOLVER_ABI, EnsNameRegistrationForm, EnsRecordsForm, Icon, Input, ListingNetwork, ListingType, MULTICALL, Modal, OffchainSubnameForm, PricingDisplay, ProfileHeader, ProgressBar, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, ShurikenSpinner, SubnameMintForm, Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TransactionPendingScreen, TxProgress, capitalize, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce, deepCopy, diffToEnsRecords, ensureFloatInput, equalsIgnoreCase, formatFloat, getAvatarUploadErrorMessage, getBlockExplorer, getBlockExplorerAddressUrl, getBlockExplorerName, getBlockExplorerTransactionUrl, getChainIdForListingNetwork, getEnsAppUrl, getEnsRecordsDiff, getImageUploadErrorMessage, getSupportedAddressByChainId, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isCommitmentToNewErr, isContenthashValid, isUserDeniedError, supportedAddresses, supportedContenthashRecords, supportedTexts, useAvatarClient, useENSResolver, useEthDollarValue, useMintManager, useMintSubname, useOffchainManager, useRegisterENS, useTheme, useWaitTransaction, validateEnsRecords, wait };
|
|
850
855
|
export type { AccordionProps, AlertPosition, AlertProps, AlertVariant, ButtonProps, ButtonSize, ButtonVariant, ChainName$1 as ChainName, ConnectAndSetChainProps, ContractErrorLabelProps, DropdownProps, EnsAddressRecord$1 as EnsAddressRecord, EnsContenthashRecord, EnsRecords$1 as EnsRecords, EnsRecordsDiff, EnsTextRecord$1 as EnsTextRecord, EstimatedFees, IconName, IconProps, InputProps, InputSize, InputType, ModalPresentation, ModalProps, ModalResponsivePresentation, ModalSize, NameListing, OffchainSubnameCreatedData, PricingDisplayProps, ProfileHeaderProps, RecordValidationError, RegistrationRequest, ShurikenSpinnerProps, SupportedContenthashRecord, SupportedEnsAddress, SupportedText, SupportedTextRecord, TextCategory, TextColor, TextProps, TextSize, TextWeight, TextareaProps, TextareaSize, ThemeContextValue, ThemeName, ThemeProviderProps, TooltipPosition, TooltipProps, UploadAvatarParams, UploadImageType };
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { baseSepolia, sepolia, mainnet, optimism, base as base$3, zoraSepolia, z
|
|
|
10
10
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
11
11
|
import * as React from 'react';
|
|
12
12
|
import React__default, { forwardRef, createElement, useState, useRef, useEffect, useCallback, useLayoutEffect, useMemo, createContext, useContext } from 'react';
|
|
13
|
-
import { useAccount, useSwitchChain, usePublicClient, useWalletClient } from 'wagmi';
|
|
13
|
+
import { useAccount, useSwitchChain, useReadContract, usePublicClient, useWalletClient } from 'wagmi';
|
|
14
14
|
import { createOffchainClient, ChainName, getCoinType } from '@thenamespace/offchain-manager';
|
|
15
15
|
import { normalize } from 'viem/ens';
|
|
16
16
|
|
|
@@ -11860,9 +11860,18 @@ const PricingDisplay = ({
|
|
|
11860
11860
|
networkFees,
|
|
11861
11861
|
total,
|
|
11862
11862
|
expiryPicker,
|
|
11863
|
+
ethUsdRate,
|
|
11863
11864
|
className = ""
|
|
11864
11865
|
}) => {
|
|
11865
11866
|
const totalLoading = total.isChecking || primaryFee.isChecking || networkFees?.isChecking;
|
|
11867
|
+
const totalUsd = React__default.useMemo(() => {
|
|
11868
|
+
if (!ethUsdRate || totalLoading || total.amount === "Free" || total.amount === "N/A") {
|
|
11869
|
+
return null;
|
|
11870
|
+
}
|
|
11871
|
+
const eth = parseFloat(String(total.amount));
|
|
11872
|
+
if (isNaN(eth) || eth <= 0) return null;
|
|
11873
|
+
return (eth * ethUsdRate).toFixed(2);
|
|
11874
|
+
}, [ethUsdRate, total.amount, totalLoading]);
|
|
11866
11875
|
return /* @__PURE__ */ jsxs("div", { className: `ens-registration-pricing ${className}`, children: [
|
|
11867
11876
|
expiryPicker && /* @__PURE__ */ jsxs("div", { className: "ens-expiry-picker d-flex justify-content-between mb-2", children: [
|
|
11868
11877
|
/* @__PURE__ */ jsx(
|
|
@@ -11893,7 +11902,13 @@ const PricingDisplay = ({
|
|
|
11893
11902
|
] }),
|
|
11894
11903
|
/* @__PURE__ */ jsxs("div", { className: "d-flex justify-content-between align-items-center mt-2 total-fee", children: [
|
|
11895
11904
|
/* @__PURE__ */ jsx(Text, { size: "lg", weight: "bold", children: "Total" }),
|
|
11896
|
-
totalLoading ? /* @__PURE__ */ jsx(ShurikenSpinner, { size: 20 }) : /* @__PURE__ */
|
|
11905
|
+
totalLoading ? /* @__PURE__ */ jsx(ShurikenSpinner, { size: 20 }) : /* @__PURE__ */ jsxs("div", { style: { textAlign: "right" }, children: [
|
|
11906
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", weight: "bold", children: total.amount === "Free" ? "Free" : `${total.amount} ETH` }),
|
|
11907
|
+
totalUsd && /* @__PURE__ */ jsxs(Text, { size: "xs", color: "grey", children: [
|
|
11908
|
+
"\u2248 $",
|
|
11909
|
+
totalUsd
|
|
11910
|
+
] })
|
|
11911
|
+
] })
|
|
11897
11912
|
] })
|
|
11898
11913
|
] });
|
|
11899
11914
|
};
|
|
@@ -11918,6 +11933,7 @@ const TextRecords = ({
|
|
|
11918
11933
|
}, [texts]);
|
|
11919
11934
|
const [lastAddedKey, setLastAddedKey] = useState(null);
|
|
11920
11935
|
const [customDrafts, setCustomDrafts] = useState([]);
|
|
11936
|
+
const [lastAddedDraftId, setLastAddedDraftId] = useState(null);
|
|
11921
11937
|
const inputRefs = useRef({});
|
|
11922
11938
|
const draftKeys = useMemo(
|
|
11923
11939
|
() => new Set(customDrafts.map((d) => d.key).filter(Boolean)),
|
|
@@ -11935,8 +11951,18 @@ const TextRecords = ({
|
|
|
11935
11951
|
return true;
|
|
11936
11952
|
};
|
|
11937
11953
|
const handleAddCustomDraft = () => {
|
|
11938
|
-
|
|
11954
|
+
const id = genDraftId();
|
|
11955
|
+
setCustomDrafts((prev) => [...prev, { id, key: "", value: "" }]);
|
|
11956
|
+
setLastAddedDraftId(id);
|
|
11939
11957
|
};
|
|
11958
|
+
useEffect(() => {
|
|
11959
|
+
if (!lastAddedDraftId) return;
|
|
11960
|
+
const el = inputRefs.current[lastAddedDraftId];
|
|
11961
|
+
if (!el) return;
|
|
11962
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
11963
|
+
el.focus();
|
|
11964
|
+
setLastAddedDraftId(null);
|
|
11965
|
+
}, [customDrafts, lastAddedDraftId]);
|
|
11940
11966
|
const handleCustomDraftKeyChange = (draftId, newKey) => {
|
|
11941
11967
|
const draft = customDrafts.find((d) => d.id === draftId);
|
|
11942
11968
|
const oldKey = draft.key;
|
|
@@ -12148,6 +12174,9 @@ const TextRecords = ({
|
|
|
12148
12174
|
/* @__PURE__ */ jsx(
|
|
12149
12175
|
Input,
|
|
12150
12176
|
{
|
|
12177
|
+
ref: (el) => {
|
|
12178
|
+
inputRefs.current[draft.id] = el;
|
|
12179
|
+
},
|
|
12151
12180
|
style: { flex: 1 },
|
|
12152
12181
|
value: draft.key,
|
|
12153
12182
|
onChange: (e) => handleCustomDraftKeyChange(draft.id, e.target.value),
|
|
@@ -62171,6 +62200,65 @@ function requireDist$2 () {
|
|
|
62171
62200
|
|
|
62172
62201
|
var distExports$2 = requireDist$2();
|
|
62173
62202
|
|
|
62203
|
+
const CHAINLINK_ETH_USD = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419";
|
|
62204
|
+
const CACHE_KEY = "ns_eth_usd_price";
|
|
62205
|
+
const TTL_MS = 3.5 * 60 * 60 * 1e3;
|
|
62206
|
+
const AGGREGATOR_ABI = [
|
|
62207
|
+
{
|
|
62208
|
+
inputs: [],
|
|
62209
|
+
name: "latestRoundData",
|
|
62210
|
+
outputs: [
|
|
62211
|
+
{ name: "roundId", type: "uint80" },
|
|
62212
|
+
{ name: "answer", type: "int256" },
|
|
62213
|
+
{ name: "startedAt", type: "uint256" },
|
|
62214
|
+
{ name: "updatedAt", type: "uint256" },
|
|
62215
|
+
{ name: "answeredInRound", type: "uint80" }
|
|
62216
|
+
],
|
|
62217
|
+
stateMutability: "view",
|
|
62218
|
+
type: "function"
|
|
62219
|
+
}
|
|
62220
|
+
];
|
|
62221
|
+
function readCache() {
|
|
62222
|
+
try {
|
|
62223
|
+
const raw = localStorage.getItem(CACHE_KEY);
|
|
62224
|
+
if (!raw) return null;
|
|
62225
|
+
const { rate, fetchedAt } = JSON.parse(raw);
|
|
62226
|
+
if (Date.now() - fetchedAt < TTL_MS) return rate;
|
|
62227
|
+
} catch {
|
|
62228
|
+
}
|
|
62229
|
+
return null;
|
|
62230
|
+
}
|
|
62231
|
+
function writeCache(rate) {
|
|
62232
|
+
try {
|
|
62233
|
+
localStorage.setItem(CACHE_KEY, JSON.stringify({ rate, fetchedAt: Date.now() }));
|
|
62234
|
+
} catch {
|
|
62235
|
+
}
|
|
62236
|
+
}
|
|
62237
|
+
function useEthDollarValue() {
|
|
62238
|
+
const [ethUsdRate, setEthUsdRate] = useState(() => readCache());
|
|
62239
|
+
const cacheHit = ethUsdRate !== null;
|
|
62240
|
+
const { data } = useReadContract({
|
|
62241
|
+
address: CHAINLINK_ETH_USD,
|
|
62242
|
+
abi: AGGREGATOR_ABI,
|
|
62243
|
+
functionName: "latestRoundData",
|
|
62244
|
+
chainId: mainnet.id,
|
|
62245
|
+
query: {
|
|
62246
|
+
enabled: !cacheHit,
|
|
62247
|
+
staleTime: TTL_MS,
|
|
62248
|
+
gcTime: TTL_MS + 30 * 60 * 1e3
|
|
62249
|
+
}
|
|
62250
|
+
});
|
|
62251
|
+
useEffect(() => {
|
|
62252
|
+
if (!data) return;
|
|
62253
|
+
const rate = Number(data[1]) / 1e8;
|
|
62254
|
+
if (rate > 0) {
|
|
62255
|
+
writeCache(rate);
|
|
62256
|
+
setEthUsdRate(rate);
|
|
62257
|
+
}
|
|
62258
|
+
}, [data]);
|
|
62259
|
+
return { ethUsdRate };
|
|
62260
|
+
}
|
|
62261
|
+
|
|
62174
62262
|
var dist$1 = {};
|
|
62175
62263
|
|
|
62176
62264
|
var addresses = {};
|
|
@@ -63903,15 +63991,18 @@ const useRegisterENS = ({ isTestnet }) => {
|
|
|
63903
63991
|
const publicClient = usePublicClient({
|
|
63904
63992
|
chainId: isTestnet ? sepolia.id : mainnet.id
|
|
63905
63993
|
});
|
|
63994
|
+
const { address } = useAccount();
|
|
63906
63995
|
const { data: walletClient } = useWalletClient({
|
|
63907
63996
|
chainId: isTestnet ? sepolia.id : mainnet.id
|
|
63908
63997
|
});
|
|
63909
63998
|
const getRegistrationPrice = async (label, expiryInYears = 1) => {
|
|
63999
|
+
const ethController = getEthController();
|
|
63910
64000
|
const price = await publicClient.readContract({
|
|
63911
64001
|
abi: ABIS.ETH_REGISTRAR_CONTOLLER,
|
|
63912
64002
|
functionName: "rentPrice",
|
|
63913
|
-
args: [label, expiryInYears * SECONDS_IN_YEAR],
|
|
63914
|
-
address:
|
|
64003
|
+
args: [label, BigInt(expiryInYears * SECONDS_IN_YEAR)],
|
|
64004
|
+
address: ethController,
|
|
64005
|
+
account: address
|
|
63915
64006
|
});
|
|
63916
64007
|
const totalPrice = price.base + price.premium;
|
|
63917
64008
|
return {
|
|
@@ -88190,14 +88281,30 @@ var distExports = requireDist();
|
|
|
88190
88281
|
|
|
88191
88282
|
const LIST_MANAGER_API = "https://list-manager.namespace.ninja";
|
|
88192
88283
|
const LIST_MANAGER_TESTNET_API = "https://staging.list-manager.namespace.ninja";
|
|
88284
|
+
function getTransportUrl(client) {
|
|
88285
|
+
const transport = client?.transport;
|
|
88286
|
+
return transport?.type === "http" ? transport.url : void 0;
|
|
88287
|
+
}
|
|
88193
88288
|
const useMintManager = ({ isTestnet }) => {
|
|
88289
|
+
const mainnetClient = usePublicClient({ chainId: mainnet.id });
|
|
88290
|
+
const sepoliaClient = usePublicClient({ chainId: sepolia.id });
|
|
88291
|
+
const baseClient = usePublicClient({ chainId: base$3.id });
|
|
88292
|
+
const baseSepoliaClient = usePublicClient({ chainId: baseSepolia.id });
|
|
88293
|
+
const optimismClient = usePublicClient({ chainId: optimism.id });
|
|
88194
88294
|
const mintClient = useMemo(() => {
|
|
88195
|
-
|
|
88295
|
+
const cursomRpcUrls = {};
|
|
88296
|
+
const clients = [mainnetClient, sepoliaClient, baseClient, baseSepoliaClient, optimismClient];
|
|
88297
|
+
for (const client of clients) {
|
|
88298
|
+
const url = getTransportUrl(client);
|
|
88299
|
+
if (client && url) {
|
|
88300
|
+
cursomRpcUrls[String(client.chain.id)] = url;
|
|
88301
|
+
}
|
|
88302
|
+
}
|
|
88196
88303
|
return distExports.createMintClient({
|
|
88197
|
-
cursomRpcUrls
|
|
88304
|
+
cursomRpcUrls,
|
|
88198
88305
|
isTestnet: isTestnet || false
|
|
88199
88306
|
});
|
|
88200
|
-
}, [isTestnet]);
|
|
88307
|
+
}, [isTestnet, mainnetClient, sepoliaClient, baseClient, baseSepoliaClient, optimismClient]);
|
|
88201
88308
|
const getListingDetails = useCallback(async (name) => {
|
|
88202
88309
|
const listManagerApi = isTestnet ? LIST_MANAGER_TESTNET_API : LIST_MANAGER_API;
|
|
88203
88310
|
const listingNetwork = isTestnet ? ListingNetwork.Sepolia : ListingNetwork.Mainnet;
|
|
@@ -88256,7 +88363,19 @@ const useMintSubname = ({ chainId }) => {
|
|
|
88256
88363
|
account,
|
|
88257
88364
|
value: mintTx.value
|
|
88258
88365
|
});
|
|
88259
|
-
let gasPriceWei
|
|
88366
|
+
let gasPriceWei;
|
|
88367
|
+
try {
|
|
88368
|
+
const [block, priorityFee] = await Promise.all([
|
|
88369
|
+
publicClient.getBlock({ blockTag: "latest" }),
|
|
88370
|
+
publicClient.estimateMaxPriorityFeePerGas().catch(() => 0n)
|
|
88371
|
+
]);
|
|
88372
|
+
const baseFee = block.baseFeePerGas ?? await publicClient.getGasPrice();
|
|
88373
|
+
const minPriorityFee = 1500000000n;
|
|
88374
|
+
const effectivePriorityFee = priorityFee > minPriorityFee ? priorityFee : minPriorityFee;
|
|
88375
|
+
gasPriceWei = baseFee * 2n + effectivePriorityFee;
|
|
88376
|
+
} catch {
|
|
88377
|
+
gasPriceWei = await publicClient.getGasPrice();
|
|
88378
|
+
}
|
|
88260
88379
|
const totalFeeWei = gasEstimate * gasPriceWei;
|
|
88261
88380
|
const totalFeeEth = parseFloat(formatEther(totalFeeWei));
|
|
88262
88381
|
return {
|
|
@@ -89228,6 +89347,7 @@ const RegistrationSummary = ({
|
|
|
89228
89347
|
onConnectWallet
|
|
89229
89348
|
}) => {
|
|
89230
89349
|
const { isConnected } = useAccount();
|
|
89350
|
+
const { ethUsdRate } = useEthDollarValue();
|
|
89231
89351
|
const { isEnsAvailable, getRegistrationPrice } = useRegisterENS({
|
|
89232
89352
|
isTestnet
|
|
89233
89353
|
});
|
|
@@ -89384,7 +89504,8 @@ const RegistrationSummary = ({
|
|
|
89384
89504
|
expiryPicker: {
|
|
89385
89505
|
years,
|
|
89386
89506
|
onYearsChange: handleYearsChange
|
|
89387
|
-
}
|
|
89507
|
+
},
|
|
89508
|
+
ethUsdRate
|
|
89388
89509
|
}
|
|
89389
89510
|
),
|
|
89390
89511
|
/* @__PURE__ */ jsx(
|
|
@@ -92464,6 +92585,7 @@ const SubnameMintFormContent = ({
|
|
|
92464
92585
|
}) => {
|
|
92465
92586
|
const { address: connectedAddress, chain: currentChain } = useAccount();
|
|
92466
92587
|
const { switchChain, isPending: isSwitchingChain } = useSwitchChain();
|
|
92588
|
+
const { ethUsdRate } = useEthDollarValue();
|
|
92467
92589
|
const { mintClient } = useMintManager({ isTestnet });
|
|
92468
92590
|
const { mintSubname, estimateTransactionFees } = useMintSubname({ chainId });
|
|
92469
92591
|
const { waitTx } = useWaitTransaction({ chainId });
|
|
@@ -92547,60 +92669,6 @@ const SubnameMintFormContent = ({
|
|
|
92547
92669
|
checkMintDetails(initialLabel, parentName, connectedAddress);
|
|
92548
92670
|
}
|
|
92549
92671
|
}, []);
|
|
92550
|
-
const [transactionFees, setTransactionFees] = useState({
|
|
92551
|
-
isChecking: false,
|
|
92552
|
-
estimatedGas: 0,
|
|
92553
|
-
failed: false,
|
|
92554
|
-
price: {
|
|
92555
|
-
wei: 0n,
|
|
92556
|
-
eth: 0
|
|
92557
|
-
}
|
|
92558
|
-
});
|
|
92559
|
-
const [gasEstimated, setGasEstimated] = useState(false);
|
|
92560
|
-
const fetchGasEstimate = async (labelToEstimate, recordsToEstimate) => {
|
|
92561
|
-
if (!connectedAddress) return;
|
|
92562
|
-
setTransactionFees((prev) => ({ ...prev, isChecking: true, failed: false }));
|
|
92563
|
-
try {
|
|
92564
|
-
const ensMintRecords = {
|
|
92565
|
-
addresses: recordsToEstimate.addresses.map((addr) => ({
|
|
92566
|
-
chain: addr.coinType,
|
|
92567
|
-
value: addr.value
|
|
92568
|
-
})),
|
|
92569
|
-
texts: recordsToEstimate.texts.map((text) => ({
|
|
92570
|
-
key: text.key,
|
|
92571
|
-
value: text.value
|
|
92572
|
-
}))
|
|
92573
|
-
};
|
|
92574
|
-
const mintTx = await mintClient.getMintTransactionParameters({
|
|
92575
|
-
records: ensMintRecords,
|
|
92576
|
-
label: labelToEstimate,
|
|
92577
|
-
parentName,
|
|
92578
|
-
owner: connectedAddress,
|
|
92579
|
-
minterAddress: connectedAddress
|
|
92580
|
-
});
|
|
92581
|
-
const result = await estimateTransactionFees({
|
|
92582
|
-
mintTx,
|
|
92583
|
-
account: connectedAddress
|
|
92584
|
-
});
|
|
92585
|
-
if (result) {
|
|
92586
|
-
setTransactionFees({
|
|
92587
|
-
isChecking: false,
|
|
92588
|
-
estimatedGas: Number(result.gasEstimate),
|
|
92589
|
-
failed: false,
|
|
92590
|
-
price: {
|
|
92591
|
-
wei: result.totalFeeWei,
|
|
92592
|
-
eth: result.totalFeeEth
|
|
92593
|
-
}
|
|
92594
|
-
});
|
|
92595
|
-
setGasEstimated(true);
|
|
92596
|
-
} else {
|
|
92597
|
-
setTransactionFees((prev) => ({ ...prev, isChecking: false, failed: true }));
|
|
92598
|
-
}
|
|
92599
|
-
} catch (err) {
|
|
92600
|
-
console.error("Gas estimation error:", err);
|
|
92601
|
-
setTransactionFees((prev) => ({ ...prev, isChecking: false, failed: true }));
|
|
92602
|
-
}
|
|
92603
|
-
};
|
|
92604
92672
|
const handleNameChanged = async (value) => {
|
|
92605
92673
|
const _value = value.toLowerCase().trim();
|
|
92606
92674
|
if (_value.includes(".")) {
|
|
@@ -92613,7 +92681,6 @@ const SubnameMintFormContent = ({
|
|
|
92613
92681
|
}
|
|
92614
92682
|
setLabel(_value);
|
|
92615
92683
|
setGasEstimated(false);
|
|
92616
|
-
setTransactionFees((prev) => ({ ...prev, failed: false }));
|
|
92617
92684
|
if (_value.length >= MIN_ENS_LEN$1) {
|
|
92618
92685
|
setAvailability({ isAvailable: false, isChecking: true });
|
|
92619
92686
|
setMintDetails({ ...mintDetails, isChecking: true });
|
|
@@ -92621,6 +92688,8 @@ const SubnameMintFormContent = ({
|
|
|
92621
92688
|
debouncedCheckMintDetails(_value, parentName, connectedAddress);
|
|
92622
92689
|
}
|
|
92623
92690
|
};
|
|
92691
|
+
const [gasEstimated, setGasEstimated] = useState(false);
|
|
92692
|
+
const [transactionFees, setTransactionFees] = useState({ isChecking: false, failed: false, price: { wei: 0n, eth: 0 } });
|
|
92624
92693
|
const formatEthDisplay = (value) => {
|
|
92625
92694
|
if (value === 0) return "0";
|
|
92626
92695
|
if (value < 1e-5) return ">0.00001";
|
|
@@ -92633,17 +92702,10 @@ const SubnameMintFormContent = ({
|
|
|
92633
92702
|
let fees = 0;
|
|
92634
92703
|
let total = price;
|
|
92635
92704
|
if (transactionFees.failed) {
|
|
92636
|
-
return {
|
|
92637
|
-
regFees: "N/A",
|
|
92638
|
-
regPrice: isFree2 ? "Free" : formatEthDisplay(price),
|
|
92639
|
-
regTotal: "N/A",
|
|
92640
|
-
isFree: isFree2
|
|
92641
|
-
};
|
|
92642
|
-
}
|
|
92643
|
-
if (transactionFees) {
|
|
92644
|
-
fees += transactionFees.price.eth;
|
|
92645
|
-
total += transactionFees.price.eth;
|
|
92705
|
+
return { regFees: "N/A", regPrice: isFree2 ? "Free" : formatEthDisplay(price), regTotal: "N/A", isFree: isFree2 };
|
|
92646
92706
|
}
|
|
92707
|
+
fees += transactionFees.price.eth;
|
|
92708
|
+
total += transactionFees.price.eth;
|
|
92647
92709
|
return {
|
|
92648
92710
|
regFees: formatEthDisplay(fees),
|
|
92649
92711
|
regPrice: isFree2 ? "Free" : formatEthDisplay(price),
|
|
@@ -92657,8 +92719,8 @@ const SubnameMintFormContent = ({
|
|
|
92657
92719
|
}
|
|
92658
92720
|
setYears(newYears);
|
|
92659
92721
|
};
|
|
92660
|
-
const totalPriceLoading = transactionFees
|
|
92661
|
-
const transactionFeesLoading = transactionFees
|
|
92722
|
+
const totalPriceLoading = transactionFees.isChecking || mintDetails.isChecking;
|
|
92723
|
+
const transactionFeesLoading = transactionFees.isChecking;
|
|
92662
92724
|
const blockingError = useMemo(() => {
|
|
92663
92725
|
const { canMint, validationErrors } = mintDetails.details;
|
|
92664
92726
|
if (canMint || mintDetails.isChecking) return null;
|
|
@@ -92697,11 +92759,42 @@ const SubnameMintFormContent = ({
|
|
|
92697
92759
|
const isAvailableForMint = useMemo(() => {
|
|
92698
92760
|
return label.length >= 1 && availability.isAvailable && !availability.isChecking && !blockingError && !isSubnameReserved;
|
|
92699
92761
|
}, [label, availability, blockingError, isSubnameReserved]);
|
|
92762
|
+
const fetchGasEstimate = async (labelToEstimate, recordsToEstimate) => {
|
|
92763
|
+
if (!connectedAddress) return;
|
|
92764
|
+
setTransactionFees((prev) => ({ ...prev, isChecking: true, failed: false }));
|
|
92765
|
+
try {
|
|
92766
|
+
const ensMintRecords = {
|
|
92767
|
+
addresses: recordsToEstimate.addresses.map((addr) => ({ chain: addr.coinType, value: addr.value })),
|
|
92768
|
+
texts: recordsToEstimate.texts.map((text) => ({ key: text.key, value: text.value }))
|
|
92769
|
+
};
|
|
92770
|
+
const mintTx = await mintClient.getMintTransactionParameters({
|
|
92771
|
+
records: ensMintRecords,
|
|
92772
|
+
label: labelToEstimate,
|
|
92773
|
+
parentName,
|
|
92774
|
+
owner: connectedAddress,
|
|
92775
|
+
minterAddress: connectedAddress
|
|
92776
|
+
});
|
|
92777
|
+
const result = await estimateTransactionFees({ mintTx, account: connectedAddress });
|
|
92778
|
+
if (result) {
|
|
92779
|
+
setTransactionFees({ isChecking: false, failed: false, price: { wei: result.totalFeeWei, eth: result.totalFeeEth } });
|
|
92780
|
+
setGasEstimated(true);
|
|
92781
|
+
} else {
|
|
92782
|
+
setTransactionFees((prev) => ({ ...prev, isChecking: false, failed: true }));
|
|
92783
|
+
}
|
|
92784
|
+
} catch {
|
|
92785
|
+
setTransactionFees((prev) => ({ ...prev, isChecking: false, failed: true }));
|
|
92786
|
+
}
|
|
92787
|
+
};
|
|
92788
|
+
useEffect(() => {
|
|
92789
|
+
if (connectedAddress) {
|
|
92790
|
+
setGasEstimated(false);
|
|
92791
|
+
}
|
|
92792
|
+
}, [connectedAddress]);
|
|
92700
92793
|
useEffect(() => {
|
|
92701
|
-
if (isAvailableForMint && !gasEstimated && label.length >= MIN_ENS_LEN$1) {
|
|
92794
|
+
if (isAvailableForMint && !gasEstimated && label.length >= MIN_ENS_LEN$1 && connectedAddress) {
|
|
92702
92795
|
fetchGasEstimate(label, ensRecords);
|
|
92703
92796
|
}
|
|
92704
|
-
}, [isAvailableForMint, gasEstimated, label]);
|
|
92797
|
+
}, [isAvailableForMint, gasEstimated, label, connectedAddress]);
|
|
92705
92798
|
const handleSaveRecords = () => {
|
|
92706
92799
|
const newRecords = deepCopy(ensRecordTemplate);
|
|
92707
92800
|
setEnsRecords(newRecords);
|
|
@@ -92720,6 +92813,7 @@ const SubnameMintFormContent = ({
|
|
|
92720
92813
|
setMintStep("minting" /* Minting */);
|
|
92721
92814
|
let tx = null;
|
|
92722
92815
|
let mintPrice = 0n;
|
|
92816
|
+
console.log("Handling mint state", connectedAddress, "Connected address");
|
|
92723
92817
|
try {
|
|
92724
92818
|
setMintState({
|
|
92725
92819
|
isWaitingWallet: true,
|
|
@@ -92928,7 +93022,8 @@ const SubnameMintFormContent = ({
|
|
|
92928
93022
|
expiryPicker: isExpirable ? {
|
|
92929
93023
|
years,
|
|
92930
93024
|
onYearsChange: handleYearsChange
|
|
92931
|
-
} : void 0
|
|
93025
|
+
} : void 0,
|
|
93026
|
+
ethUsdRate
|
|
92932
93027
|
}
|
|
92933
93028
|
),
|
|
92934
93029
|
/* @__PURE__ */ jsx(ProfileSelector, { onSelect: () => setShowProfile(true) })
|
|
@@ -93533,5 +93628,5 @@ const useTheme = () => {
|
|
|
93533
93628
|
return ctx;
|
|
93534
93629
|
};
|
|
93535
93630
|
|
|
93536
|
-
export { Accordion, Alert, Button, Card, ChainIcon, ConnectAndSetChain, ContenthashIcon, ContenthashProtocol, ContractErrorLabel, Dropdown, ENS_RESOLVER_ABI, EnsNameRegistrationForm, EnsRecordsForm, Icon, Input, ListingNetwork, ListingType, MULTICALL, Modal, OffchainSubnameForm, PricingDisplay, ProfileHeader, ProgressBar, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, ShurikenSpinner, SubnameMintForm, Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TransactionPendingScreen, TxProgress, capitalize, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce, deepCopy, diffToEnsRecords, ensureFloatInput, equalsIgnoreCase, formatFloat, getAvatarUploadErrorMessage, getBlockExplorer, getBlockExplorerAddressUrl, getBlockExplorerName, getBlockExplorerTransactionUrl, getChainIdForListingNetwork, getEnsAppUrl, getEnsRecordsDiff, getImageUploadErrorMessage, getSupportedAddressByChainId, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isCommitmentToNewErr, isContenthashValid, isUserDeniedError, supportedAddresses, supportedContenthashRecords, supportedTexts, useAvatarClient, useENSResolver, useMintManager, useMintSubname, useOffchainManager, useRegisterENS, useTheme, useWaitTransaction, validateEnsRecords, wait };
|
|
93631
|
+
export { Accordion, Alert, Button, Card, ChainIcon, ConnectAndSetChain, ContenthashIcon, ContenthashProtocol, ContractErrorLabel, Dropdown, ENS_RESOLVER_ABI, EnsNameRegistrationForm, EnsRecordsForm, Icon, Input, ListingNetwork, ListingType, MULTICALL, Modal, OffchainSubnameForm, PricingDisplay, ProfileHeader, ProgressBar, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, ShurikenSpinner, SubnameMintForm, Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TransactionPendingScreen, TxProgress, capitalize, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce, deepCopy, diffToEnsRecords, ensureFloatInput, equalsIgnoreCase, formatFloat, getAvatarUploadErrorMessage, getBlockExplorer, getBlockExplorerAddressUrl, getBlockExplorerName, getBlockExplorerTransactionUrl, getChainIdForListingNetwork, getEnsAppUrl, getEnsRecordsDiff, getImageUploadErrorMessage, getSupportedAddressByChainId, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isCommitmentToNewErr, isContenthashValid, isUserDeniedError, supportedAddresses, supportedContenthashRecords, supportedTexts, useAvatarClient, useENSResolver, useEthDollarValue, useMintManager, useMintSubname, useOffchainManager, useRegisterENS, useTheme, useWaitTransaction, validateEnsRecords, wait };
|
|
93537
93632
|
//# sourceMappingURL=index.js.map
|