@thenamespace/ens-components 1.1.6 → 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 +156 -78
- 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
|
};
|
|
@@ -62185,6 +62200,65 @@ function requireDist$2 () {
|
|
|
62185
62200
|
|
|
62186
62201
|
var distExports$2 = requireDist$2();
|
|
62187
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
|
+
|
|
62188
62262
|
var dist$1 = {};
|
|
62189
62263
|
|
|
62190
62264
|
var addresses = {};
|
|
@@ -88207,14 +88281,30 @@ var distExports = requireDist();
|
|
|
88207
88281
|
|
|
88208
88282
|
const LIST_MANAGER_API = "https://list-manager.namespace.ninja";
|
|
88209
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
|
+
}
|
|
88210
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 });
|
|
88211
88294
|
const mintClient = useMemo(() => {
|
|
88212
|
-
|
|
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
|
+
}
|
|
88213
88303
|
return distExports.createMintClient({
|
|
88214
|
-
cursomRpcUrls
|
|
88304
|
+
cursomRpcUrls,
|
|
88215
88305
|
isTestnet: isTestnet || false
|
|
88216
88306
|
});
|
|
88217
|
-
}, [isTestnet]);
|
|
88307
|
+
}, [isTestnet, mainnetClient, sepoliaClient, baseClient, baseSepoliaClient, optimismClient]);
|
|
88218
88308
|
const getListingDetails = useCallback(async (name) => {
|
|
88219
88309
|
const listManagerApi = isTestnet ? LIST_MANAGER_TESTNET_API : LIST_MANAGER_API;
|
|
88220
88310
|
const listingNetwork = isTestnet ? ListingNetwork.Sepolia : ListingNetwork.Mainnet;
|
|
@@ -88273,7 +88363,19 @@ const useMintSubname = ({ chainId }) => {
|
|
|
88273
88363
|
account,
|
|
88274
88364
|
value: mintTx.value
|
|
88275
88365
|
});
|
|
88276
|
-
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
|
+
}
|
|
88277
88379
|
const totalFeeWei = gasEstimate * gasPriceWei;
|
|
88278
88380
|
const totalFeeEth = parseFloat(formatEther(totalFeeWei));
|
|
88279
88381
|
return {
|
|
@@ -89245,6 +89347,7 @@ const RegistrationSummary = ({
|
|
|
89245
89347
|
onConnectWallet
|
|
89246
89348
|
}) => {
|
|
89247
89349
|
const { isConnected } = useAccount();
|
|
89350
|
+
const { ethUsdRate } = useEthDollarValue();
|
|
89248
89351
|
const { isEnsAvailable, getRegistrationPrice } = useRegisterENS({
|
|
89249
89352
|
isTestnet
|
|
89250
89353
|
});
|
|
@@ -89401,7 +89504,8 @@ const RegistrationSummary = ({
|
|
|
89401
89504
|
expiryPicker: {
|
|
89402
89505
|
years,
|
|
89403
89506
|
onYearsChange: handleYearsChange
|
|
89404
|
-
}
|
|
89507
|
+
},
|
|
89508
|
+
ethUsdRate
|
|
89405
89509
|
}
|
|
89406
89510
|
),
|
|
89407
89511
|
/* @__PURE__ */ jsx(
|
|
@@ -92481,6 +92585,7 @@ const SubnameMintFormContent = ({
|
|
|
92481
92585
|
}) => {
|
|
92482
92586
|
const { address: connectedAddress, chain: currentChain } = useAccount();
|
|
92483
92587
|
const { switchChain, isPending: isSwitchingChain } = useSwitchChain();
|
|
92588
|
+
const { ethUsdRate } = useEthDollarValue();
|
|
92484
92589
|
const { mintClient } = useMintManager({ isTestnet });
|
|
92485
92590
|
const { mintSubname, estimateTransactionFees } = useMintSubname({ chainId });
|
|
92486
92591
|
const { waitTx } = useWaitTransaction({ chainId });
|
|
@@ -92564,60 +92669,6 @@ const SubnameMintFormContent = ({
|
|
|
92564
92669
|
checkMintDetails(initialLabel, parentName, connectedAddress);
|
|
92565
92670
|
}
|
|
92566
92671
|
}, []);
|
|
92567
|
-
const [transactionFees, setTransactionFees] = useState({
|
|
92568
|
-
isChecking: false,
|
|
92569
|
-
estimatedGas: 0,
|
|
92570
|
-
failed: false,
|
|
92571
|
-
price: {
|
|
92572
|
-
wei: 0n,
|
|
92573
|
-
eth: 0
|
|
92574
|
-
}
|
|
92575
|
-
});
|
|
92576
|
-
const [gasEstimated, setGasEstimated] = useState(false);
|
|
92577
|
-
const fetchGasEstimate = async (labelToEstimate, recordsToEstimate) => {
|
|
92578
|
-
if (!connectedAddress) return;
|
|
92579
|
-
setTransactionFees((prev) => ({ ...prev, isChecking: true, failed: false }));
|
|
92580
|
-
try {
|
|
92581
|
-
const ensMintRecords = {
|
|
92582
|
-
addresses: recordsToEstimate.addresses.map((addr) => ({
|
|
92583
|
-
chain: addr.coinType,
|
|
92584
|
-
value: addr.value
|
|
92585
|
-
})),
|
|
92586
|
-
texts: recordsToEstimate.texts.map((text) => ({
|
|
92587
|
-
key: text.key,
|
|
92588
|
-
value: text.value
|
|
92589
|
-
}))
|
|
92590
|
-
};
|
|
92591
|
-
const mintTx = await mintClient.getMintTransactionParameters({
|
|
92592
|
-
records: ensMintRecords,
|
|
92593
|
-
label: labelToEstimate,
|
|
92594
|
-
parentName,
|
|
92595
|
-
owner: connectedAddress,
|
|
92596
|
-
minterAddress: connectedAddress
|
|
92597
|
-
});
|
|
92598
|
-
const result = await estimateTransactionFees({
|
|
92599
|
-
mintTx,
|
|
92600
|
-
account: connectedAddress
|
|
92601
|
-
});
|
|
92602
|
-
if (result) {
|
|
92603
|
-
setTransactionFees({
|
|
92604
|
-
isChecking: false,
|
|
92605
|
-
estimatedGas: Number(result.gasEstimate),
|
|
92606
|
-
failed: false,
|
|
92607
|
-
price: {
|
|
92608
|
-
wei: result.totalFeeWei,
|
|
92609
|
-
eth: result.totalFeeEth
|
|
92610
|
-
}
|
|
92611
|
-
});
|
|
92612
|
-
setGasEstimated(true);
|
|
92613
|
-
} else {
|
|
92614
|
-
setTransactionFees((prev) => ({ ...prev, isChecking: false, failed: true }));
|
|
92615
|
-
}
|
|
92616
|
-
} catch (err) {
|
|
92617
|
-
console.error("Gas estimation error:", err);
|
|
92618
|
-
setTransactionFees((prev) => ({ ...prev, isChecking: false, failed: true }));
|
|
92619
|
-
}
|
|
92620
|
-
};
|
|
92621
92672
|
const handleNameChanged = async (value) => {
|
|
92622
92673
|
const _value = value.toLowerCase().trim();
|
|
92623
92674
|
if (_value.includes(".")) {
|
|
@@ -92630,7 +92681,6 @@ const SubnameMintFormContent = ({
|
|
|
92630
92681
|
}
|
|
92631
92682
|
setLabel(_value);
|
|
92632
92683
|
setGasEstimated(false);
|
|
92633
|
-
setTransactionFees((prev) => ({ ...prev, failed: false }));
|
|
92634
92684
|
if (_value.length >= MIN_ENS_LEN$1) {
|
|
92635
92685
|
setAvailability({ isAvailable: false, isChecking: true });
|
|
92636
92686
|
setMintDetails({ ...mintDetails, isChecking: true });
|
|
@@ -92638,6 +92688,8 @@ const SubnameMintFormContent = ({
|
|
|
92638
92688
|
debouncedCheckMintDetails(_value, parentName, connectedAddress);
|
|
92639
92689
|
}
|
|
92640
92690
|
};
|
|
92691
|
+
const [gasEstimated, setGasEstimated] = useState(false);
|
|
92692
|
+
const [transactionFees, setTransactionFees] = useState({ isChecking: false, failed: false, price: { wei: 0n, eth: 0 } });
|
|
92641
92693
|
const formatEthDisplay = (value) => {
|
|
92642
92694
|
if (value === 0) return "0";
|
|
92643
92695
|
if (value < 1e-5) return ">0.00001";
|
|
@@ -92650,17 +92702,10 @@ const SubnameMintFormContent = ({
|
|
|
92650
92702
|
let fees = 0;
|
|
92651
92703
|
let total = price;
|
|
92652
92704
|
if (transactionFees.failed) {
|
|
92653
|
-
return {
|
|
92654
|
-
regFees: "N/A",
|
|
92655
|
-
regPrice: isFree2 ? "Free" : formatEthDisplay(price),
|
|
92656
|
-
regTotal: "N/A",
|
|
92657
|
-
isFree: isFree2
|
|
92658
|
-
};
|
|
92659
|
-
}
|
|
92660
|
-
if (transactionFees) {
|
|
92661
|
-
fees += transactionFees.price.eth;
|
|
92662
|
-
total += transactionFees.price.eth;
|
|
92705
|
+
return { regFees: "N/A", regPrice: isFree2 ? "Free" : formatEthDisplay(price), regTotal: "N/A", isFree: isFree2 };
|
|
92663
92706
|
}
|
|
92707
|
+
fees += transactionFees.price.eth;
|
|
92708
|
+
total += transactionFees.price.eth;
|
|
92664
92709
|
return {
|
|
92665
92710
|
regFees: formatEthDisplay(fees),
|
|
92666
92711
|
regPrice: isFree2 ? "Free" : formatEthDisplay(price),
|
|
@@ -92674,8 +92719,8 @@ const SubnameMintFormContent = ({
|
|
|
92674
92719
|
}
|
|
92675
92720
|
setYears(newYears);
|
|
92676
92721
|
};
|
|
92677
|
-
const totalPriceLoading = transactionFees
|
|
92678
|
-
const transactionFeesLoading = transactionFees
|
|
92722
|
+
const totalPriceLoading = transactionFees.isChecking || mintDetails.isChecking;
|
|
92723
|
+
const transactionFeesLoading = transactionFees.isChecking;
|
|
92679
92724
|
const blockingError = useMemo(() => {
|
|
92680
92725
|
const { canMint, validationErrors } = mintDetails.details;
|
|
92681
92726
|
if (canMint || mintDetails.isChecking) return null;
|
|
@@ -92714,11 +92759,42 @@ const SubnameMintFormContent = ({
|
|
|
92714
92759
|
const isAvailableForMint = useMemo(() => {
|
|
92715
92760
|
return label.length >= 1 && availability.isAvailable && !availability.isChecking && !blockingError && !isSubnameReserved;
|
|
92716
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]);
|
|
92717
92793
|
useEffect(() => {
|
|
92718
|
-
if (isAvailableForMint && !gasEstimated && label.length >= MIN_ENS_LEN$1) {
|
|
92794
|
+
if (isAvailableForMint && !gasEstimated && label.length >= MIN_ENS_LEN$1 && connectedAddress) {
|
|
92719
92795
|
fetchGasEstimate(label, ensRecords);
|
|
92720
92796
|
}
|
|
92721
|
-
}, [isAvailableForMint, gasEstimated, label]);
|
|
92797
|
+
}, [isAvailableForMint, gasEstimated, label, connectedAddress]);
|
|
92722
92798
|
const handleSaveRecords = () => {
|
|
92723
92799
|
const newRecords = deepCopy(ensRecordTemplate);
|
|
92724
92800
|
setEnsRecords(newRecords);
|
|
@@ -92737,6 +92813,7 @@ const SubnameMintFormContent = ({
|
|
|
92737
92813
|
setMintStep("minting" /* Minting */);
|
|
92738
92814
|
let tx = null;
|
|
92739
92815
|
let mintPrice = 0n;
|
|
92816
|
+
console.log("Handling mint state", connectedAddress, "Connected address");
|
|
92740
92817
|
try {
|
|
92741
92818
|
setMintState({
|
|
92742
92819
|
isWaitingWallet: true,
|
|
@@ -92945,7 +93022,8 @@ const SubnameMintFormContent = ({
|
|
|
92945
93022
|
expiryPicker: isExpirable ? {
|
|
92946
93023
|
years,
|
|
92947
93024
|
onYearsChange: handleYearsChange
|
|
92948
|
-
} : void 0
|
|
93025
|
+
} : void 0,
|
|
93026
|
+
ethUsdRate
|
|
92949
93027
|
}
|
|
92950
93028
|
),
|
|
92951
93029
|
/* @__PURE__ */ jsx(ProfileSelector, { onSelect: () => setShowProfile(true) })
|
|
@@ -93550,5 +93628,5 @@ const useTheme = () => {
|
|
|
93550
93628
|
return ctx;
|
|
93551
93629
|
};
|
|
93552
93630
|
|
|
93553
|
-
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 };
|
|
93554
93632
|
//# sourceMappingURL=index.js.map
|