@thenamespace/ens-components 1.1.6 → 1.2.1
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 +157 -78
- package/dist/index.js.map +1 -1
- package/dist/types/components/ens-name-registration/registration/CommitmentStep.d.ts +0 -2
- 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(
|
|
@@ -91034,6 +91138,7 @@ const EnsNameRegistrationForm = (props) => {
|
|
|
91034
91138
|
label,
|
|
91035
91139
|
expiryInYears: years,
|
|
91036
91140
|
records: ensRecords,
|
|
91141
|
+
referrer: props.referrer,
|
|
91037
91142
|
onBack: (clearState) => {
|
|
91038
91143
|
if (clearState) {
|
|
91039
91144
|
clearInputState();
|
|
@@ -92481,6 +92586,7 @@ const SubnameMintFormContent = ({
|
|
|
92481
92586
|
}) => {
|
|
92482
92587
|
const { address: connectedAddress, chain: currentChain } = useAccount();
|
|
92483
92588
|
const { switchChain, isPending: isSwitchingChain } = useSwitchChain();
|
|
92589
|
+
const { ethUsdRate } = useEthDollarValue();
|
|
92484
92590
|
const { mintClient } = useMintManager({ isTestnet });
|
|
92485
92591
|
const { mintSubname, estimateTransactionFees } = useMintSubname({ chainId });
|
|
92486
92592
|
const { waitTx } = useWaitTransaction({ chainId });
|
|
@@ -92564,60 +92670,6 @@ const SubnameMintFormContent = ({
|
|
|
92564
92670
|
checkMintDetails(initialLabel, parentName, connectedAddress);
|
|
92565
92671
|
}
|
|
92566
92672
|
}, []);
|
|
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
92673
|
const handleNameChanged = async (value) => {
|
|
92622
92674
|
const _value = value.toLowerCase().trim();
|
|
92623
92675
|
if (_value.includes(".")) {
|
|
@@ -92630,7 +92682,6 @@ const SubnameMintFormContent = ({
|
|
|
92630
92682
|
}
|
|
92631
92683
|
setLabel(_value);
|
|
92632
92684
|
setGasEstimated(false);
|
|
92633
|
-
setTransactionFees((prev) => ({ ...prev, failed: false }));
|
|
92634
92685
|
if (_value.length >= MIN_ENS_LEN$1) {
|
|
92635
92686
|
setAvailability({ isAvailable: false, isChecking: true });
|
|
92636
92687
|
setMintDetails({ ...mintDetails, isChecking: true });
|
|
@@ -92638,6 +92689,8 @@ const SubnameMintFormContent = ({
|
|
|
92638
92689
|
debouncedCheckMintDetails(_value, parentName, connectedAddress);
|
|
92639
92690
|
}
|
|
92640
92691
|
};
|
|
92692
|
+
const [gasEstimated, setGasEstimated] = useState(false);
|
|
92693
|
+
const [transactionFees, setTransactionFees] = useState({ isChecking: false, failed: false, price: { wei: 0n, eth: 0 } });
|
|
92641
92694
|
const formatEthDisplay = (value) => {
|
|
92642
92695
|
if (value === 0) return "0";
|
|
92643
92696
|
if (value < 1e-5) return ">0.00001";
|
|
@@ -92650,17 +92703,10 @@ const SubnameMintFormContent = ({
|
|
|
92650
92703
|
let fees = 0;
|
|
92651
92704
|
let total = price;
|
|
92652
92705
|
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;
|
|
92706
|
+
return { regFees: "N/A", regPrice: isFree2 ? "Free" : formatEthDisplay(price), regTotal: "N/A", isFree: isFree2 };
|
|
92663
92707
|
}
|
|
92708
|
+
fees += transactionFees.price.eth;
|
|
92709
|
+
total += transactionFees.price.eth;
|
|
92664
92710
|
return {
|
|
92665
92711
|
regFees: formatEthDisplay(fees),
|
|
92666
92712
|
regPrice: isFree2 ? "Free" : formatEthDisplay(price),
|
|
@@ -92674,8 +92720,8 @@ const SubnameMintFormContent = ({
|
|
|
92674
92720
|
}
|
|
92675
92721
|
setYears(newYears);
|
|
92676
92722
|
};
|
|
92677
|
-
const totalPriceLoading = transactionFees
|
|
92678
|
-
const transactionFeesLoading = transactionFees
|
|
92723
|
+
const totalPriceLoading = transactionFees.isChecking || mintDetails.isChecking;
|
|
92724
|
+
const transactionFeesLoading = transactionFees.isChecking;
|
|
92679
92725
|
const blockingError = useMemo(() => {
|
|
92680
92726
|
const { canMint, validationErrors } = mintDetails.details;
|
|
92681
92727
|
if (canMint || mintDetails.isChecking) return null;
|
|
@@ -92714,11 +92760,42 @@ const SubnameMintFormContent = ({
|
|
|
92714
92760
|
const isAvailableForMint = useMemo(() => {
|
|
92715
92761
|
return label.length >= 1 && availability.isAvailable && !availability.isChecking && !blockingError && !isSubnameReserved;
|
|
92716
92762
|
}, [label, availability, blockingError, isSubnameReserved]);
|
|
92763
|
+
const fetchGasEstimate = async (labelToEstimate, recordsToEstimate) => {
|
|
92764
|
+
if (!connectedAddress) return;
|
|
92765
|
+
setTransactionFees((prev) => ({ ...prev, isChecking: true, failed: false }));
|
|
92766
|
+
try {
|
|
92767
|
+
const ensMintRecords = {
|
|
92768
|
+
addresses: recordsToEstimate.addresses.map((addr) => ({ chain: addr.coinType, value: addr.value })),
|
|
92769
|
+
texts: recordsToEstimate.texts.map((text) => ({ key: text.key, value: text.value }))
|
|
92770
|
+
};
|
|
92771
|
+
const mintTx = await mintClient.getMintTransactionParameters({
|
|
92772
|
+
records: ensMintRecords,
|
|
92773
|
+
label: labelToEstimate,
|
|
92774
|
+
parentName,
|
|
92775
|
+
owner: connectedAddress,
|
|
92776
|
+
minterAddress: connectedAddress
|
|
92777
|
+
});
|
|
92778
|
+
const result = await estimateTransactionFees({ mintTx, account: connectedAddress });
|
|
92779
|
+
if (result) {
|
|
92780
|
+
setTransactionFees({ isChecking: false, failed: false, price: { wei: result.totalFeeWei, eth: result.totalFeeEth } });
|
|
92781
|
+
setGasEstimated(true);
|
|
92782
|
+
} else {
|
|
92783
|
+
setTransactionFees((prev) => ({ ...prev, isChecking: false, failed: true }));
|
|
92784
|
+
}
|
|
92785
|
+
} catch {
|
|
92786
|
+
setTransactionFees((prev) => ({ ...prev, isChecking: false, failed: true }));
|
|
92787
|
+
}
|
|
92788
|
+
};
|
|
92789
|
+
useEffect(() => {
|
|
92790
|
+
if (connectedAddress) {
|
|
92791
|
+
setGasEstimated(false);
|
|
92792
|
+
}
|
|
92793
|
+
}, [connectedAddress]);
|
|
92717
92794
|
useEffect(() => {
|
|
92718
|
-
if (isAvailableForMint && !gasEstimated && label.length >= MIN_ENS_LEN$1) {
|
|
92795
|
+
if (isAvailableForMint && !gasEstimated && label.length >= MIN_ENS_LEN$1 && connectedAddress) {
|
|
92719
92796
|
fetchGasEstimate(label, ensRecords);
|
|
92720
92797
|
}
|
|
92721
|
-
}, [isAvailableForMint, gasEstimated, label]);
|
|
92798
|
+
}, [isAvailableForMint, gasEstimated, label, connectedAddress]);
|
|
92722
92799
|
const handleSaveRecords = () => {
|
|
92723
92800
|
const newRecords = deepCopy(ensRecordTemplate);
|
|
92724
92801
|
setEnsRecords(newRecords);
|
|
@@ -92737,6 +92814,7 @@ const SubnameMintFormContent = ({
|
|
|
92737
92814
|
setMintStep("minting" /* Minting */);
|
|
92738
92815
|
let tx = null;
|
|
92739
92816
|
let mintPrice = 0n;
|
|
92817
|
+
console.log("Handling mint state", connectedAddress, "Connected address");
|
|
92740
92818
|
try {
|
|
92741
92819
|
setMintState({
|
|
92742
92820
|
isWaitingWallet: true,
|
|
@@ -92945,7 +93023,8 @@ const SubnameMintFormContent = ({
|
|
|
92945
93023
|
expiryPicker: isExpirable ? {
|
|
92946
93024
|
years,
|
|
92947
93025
|
onYearsChange: handleYearsChange
|
|
92948
|
-
} : void 0
|
|
93026
|
+
} : void 0,
|
|
93027
|
+
ethUsdRate
|
|
92949
93028
|
}
|
|
92950
93029
|
),
|
|
92951
93030
|
/* @__PURE__ */ jsx(ProfileSelector, { onSelect: () => setShowProfile(true) })
|
|
@@ -93550,5 +93629,5 @@ const useTheme = () => {
|
|
|
93550
93629
|
return ctx;
|
|
93551
93630
|
};
|
|
93552
93631
|
|
|
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 };
|
|
93632
|
+
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
93633
|
//# sourceMappingURL=index.js.map
|