@thenamespace/ens-components 0.26.0 → 0.28.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/dist/index.d.ts CHANGED
@@ -3,16 +3,16 @@ import { Address, Hash, ContractFunctionExecutionError, TransactionReceipt } fro
3
3
  import * as React$1 from 'react';
4
4
  import React__default, { ReactNode, PropsWithChildren } from 'react';
5
5
 
6
- interface EnsRecords {
7
- addresses: EnsAddressRecord[];
8
- texts: EnsTextRecord[];
6
+ interface EnsRecords$1 {
7
+ addresses: EnsAddressRecord$1[];
8
+ texts: EnsTextRecord$1[];
9
9
  contenthash?: EnsContenthashRecord;
10
10
  }
11
- interface EnsTextRecord {
11
+ interface EnsTextRecord$1 {
12
12
  key: string;
13
13
  value: string;
14
14
  }
15
- interface EnsAddressRecord {
15
+ interface EnsAddressRecord$1 {
16
16
  coinType: number;
17
17
  value: string;
18
18
  }
@@ -28,7 +28,7 @@ declare enum ContenthashProtocol {
28
28
  Swarm = "swarm"
29
29
  }
30
30
 
31
- type ChainName = "eth" | "arb" | "base" | "bitcoin" | "matic" | "op" | "sol" | "zora" | "celo";
31
+ type ChainName$1 = "eth" | "arb" | "base" | "bitcoin" | "matic" | "op" | "sol" | "zora" | "celo";
32
32
 
33
33
  declare enum TxProgress {
34
34
  Pending = 0,
@@ -36,9 +36,34 @@ declare enum TxProgress {
36
36
  Failed = 2
37
37
  }
38
38
 
39
+ interface NameListing {
40
+ type: ListingType;
41
+ name: string;
42
+ isVerified: boolean;
43
+ l2Metadata?: {
44
+ isBurnable: boolean;
45
+ isExpirable: boolean;
46
+ registryAddress: Address;
47
+ registryNetwork: ListingNetwork;
48
+ };
49
+ nameNetwork: ListingNetwork;
50
+ }
51
+ declare enum ListingType {
52
+ L1 = "L1",
53
+ L2 = "L2"
54
+ }
55
+ declare enum ListingNetwork {
56
+ Base = "BASE",
57
+ Optimism = "OPTIMISM",
58
+ Mainnet = "MAINNET",
59
+ Sepolia = "SEPOLIA",
60
+ BaseSepolia = "BASE_SEPOLIA"
61
+ }
62
+ declare const getChainIdForListingNetwork: (network: ListingNetwork) => number;
63
+
39
64
  interface SelectRecordsFormProps {
40
- records: EnsRecords;
41
- onRecordsUpdated: (records: EnsRecords) => void;
65
+ records: EnsRecords$1;
66
+ onRecordsUpdated: (records: EnsRecords$1) => void;
42
67
  actionButtons?: React.ReactNode;
43
68
  }
44
69
  declare const SelectRecordsForm: ({ records, onRecordsUpdated, actionButtons, }: SelectRecordsFormProps) => react_jsx_runtime.JSX.Element;
@@ -70,32 +95,32 @@ declare const debounce: <T extends (...args: any[]) => any>(func: T, wait: numbe
70
95
  declare function convertEVMChainIdToCoinType(chainId: number): number;
71
96
 
72
97
  interface EnsRecordsDiff {
73
- textsAdded: EnsTextRecord[];
74
- textsModified: EnsTextRecord[];
75
- textsRemoved: EnsTextRecord[];
76
- addressesAdded: EnsAddressRecord[];
77
- addressesRemoved: EnsAddressRecord[];
78
- addressesModified: EnsAddressRecord[];
98
+ textsAdded: EnsTextRecord$1[];
99
+ textsModified: EnsTextRecord$1[];
100
+ textsRemoved: EnsTextRecord$1[];
101
+ addressesAdded: EnsAddressRecord$1[];
102
+ addressesRemoved: EnsAddressRecord$1[];
103
+ addressesModified: EnsAddressRecord$1[];
79
104
  contenthashAdded?: EnsContenthashRecord;
80
105
  contenthashRemoved: boolean;
81
106
  contenthashModified?: EnsContenthashRecord;
82
107
  isDifferent: boolean;
83
108
  }
84
- declare const getEnsRecordsDiff: (oldRecords: EnsRecords, newRecords: EnsRecords) => EnsRecordsDiff;
109
+ declare const getEnsRecordsDiff: (oldRecords: EnsRecords$1, newRecords: EnsRecords$1) => EnsRecordsDiff;
85
110
  interface RecordValidationError {
86
111
  type: "address" | "text" | "contenthash";
87
112
  reason: string;
88
113
  }
89
- declare const validateEnsRecords: (ensRecords: EnsRecords) => {
114
+ declare const validateEnsRecords: (ensRecords: EnsRecords$1) => {
90
115
  validationFailed: boolean;
91
116
  errors: RecordValidationError[];
92
117
  };
93
- declare const diffToEnsRecords: (diff: EnsRecordsDiff) => EnsRecords;
118
+ declare const diffToEnsRecords: (diff: EnsRecordsDiff) => EnsRecords$1;
94
119
 
95
120
  declare const ensureFloatInput: (value: string) => string;
96
121
  declare const formatFloat: (value: string | number, decimals?: number) => number;
97
122
 
98
- declare const convertToResolverData: (name: string, records: EnsRecords) => `0x${string}`[];
123
+ declare const convertToResolverData: (name: string, records: EnsRecords$1) => `0x${string}`[];
99
124
  declare const convertToMulticallResolverData: (name: string, recordsDiff: EnsRecordsDiff) => `0x${string}`[];
100
125
 
101
126
  declare const createEnsReferer: (address: Address) => Hash;
@@ -115,7 +140,7 @@ interface EnsRecordsFormProps {
115
140
  resolverAddress?: Address;
116
141
  isTestnet?: boolean;
117
142
  name: string;
118
- existingRecords: EnsRecords;
143
+ existingRecords: EnsRecords$1;
119
144
  noBorder?: boolean;
120
145
  className?: string;
121
146
  onCancel?: () => void;
@@ -125,6 +150,36 @@ interface EnsRecordsFormProps {
125
150
  }
126
151
  declare const EnsRecordsForm: ({ name, existingRecords, resolverChainId, isTestnet, resolverAddress, noBorder, className, onCancel, onGreat, onRecordsUpdated, onTransactionSent }: EnsRecordsFormProps) => react_jsx_runtime.JSX.Element;
127
152
 
153
+ interface MintSuccessData {
154
+ fullName: string;
155
+ label: string;
156
+ parentName: string;
157
+ txHash: string;
158
+ price: string;
159
+ transactionFees: string;
160
+ records: EnsRecords$1;
161
+ }
162
+ interface SubnameMintedData {
163
+ label: string;
164
+ parentName: string;
165
+ fullSubname: string;
166
+ records: EnsRecords$1;
167
+ price: string;
168
+ transactionFees: string;
169
+ ownerAddress: string;
170
+ txHash: string;
171
+ chainId: number;
172
+ }
173
+ interface SubnameMintFormProps {
174
+ parentName: string;
175
+ label?: string;
176
+ isTestnet?: boolean;
177
+ onCancel?: () => void;
178
+ onSuccess?: (data: MintSuccessData) => void;
179
+ onSubnameMinted?: (data: SubnameMintedData) => void;
180
+ }
181
+ declare const SubnameMintForm: ({ parentName, label, isTestnet, onCancel, onSuccess, onSubnameMinted, }: SubnameMintFormProps) => react_jsx_runtime.JSX.Element;
182
+
128
183
  type ButtonVariant = "solid" | "outline" | "ghost" | "destructive";
129
184
  type ButtonSize = "sm" | "md" | "lg";
130
185
  interface ButtonProps extends Omit<React__default.ButtonHTMLAttributes<HTMLButtonElement>, "prefix"> {
@@ -185,7 +240,7 @@ interface IconProps {
185
240
  declare const Icon: React__default.FC<IconProps>;
186
241
 
187
242
  interface ChainIconProps extends React__default.SVGProps<SVGSVGElement> {
188
- chain: ChainName;
243
+ chain: ChainName$1;
189
244
  size?: number;
190
245
  }
191
246
  declare const ChainIcon: React__default.FC<ChainIconProps>;
@@ -234,8 +289,10 @@ interface ContenthashIconProps extends React.SVGProps<SVGSVGElement> {
234
289
  declare const ContenthashIcon: (props: ContenthashIconProps) => react_jsx_runtime.JSX.Element | null;
235
290
 
236
291
  type AlertVariant = "error" | "warning" | "info" | "success";
292
+ type AlertPosition = "vertical" | "horizontal";
237
293
  interface AlertProps {
238
294
  variant?: AlertVariant;
295
+ position?: AlertPosition;
239
296
  children: React__default.ReactNode;
240
297
  className?: string;
241
298
  onClose?: () => void;
@@ -320,19 +377,41 @@ interface ProgressBarProps {
320
377
  }
321
378
  declare function ProgressBar({ progress }: ProgressBarProps): react_jsx_runtime.JSX.Element;
322
379
 
380
+ interface PricingDisplayProps {
381
+ primaryFee: {
382
+ label: string;
383
+ amount: number | string;
384
+ isChecking: boolean;
385
+ };
386
+ networkFees?: {
387
+ amount: number | string;
388
+ isChecking: boolean;
389
+ };
390
+ total: {
391
+ amount: number | string;
392
+ isChecking: boolean;
393
+ };
394
+ expiryPicker?: {
395
+ years: number;
396
+ onYearsChange: (years: number) => void;
397
+ };
398
+ className?: string;
399
+ }
400
+ declare const PricingDisplay: React__default.FC<PricingDisplayProps>;
401
+
323
402
  interface SupportedEnsAddress {
324
403
  validateFunc?: (value: string) => boolean;
325
404
  isEMV?: boolean;
326
405
  label: string;
327
406
  coinType: number;
328
407
  chainId?: number;
329
- chainName: ChainName;
408
+ chainName: ChainName$1;
330
409
  placeholder?: string;
331
410
  }
332
411
  declare const supportedAddresses: SupportedEnsAddress[];
333
412
  declare const getSupportedAddressMap: () => Record<number, SupportedEnsAddress>;
334
413
  declare const getSupportedAddressByCoin: (coin: number) => SupportedEnsAddress | undefined;
335
- declare const getSupportedAddressByName: (name: ChainName) => SupportedEnsAddress | undefined;
414
+ declare const getSupportedAddressByName: (name: ChainName$1) => SupportedEnsAddress | undefined;
336
415
  declare const getSupportedAddressByChainId: (chainId: number) => SupportedEnsAddress | undefined;
337
416
  type TextCategory = "profile" | "social";
338
417
  interface SupportedText {
@@ -452,7 +531,7 @@ interface RegistrationRequest {
452
531
  owner: Address;
453
532
  expiryInYears: number;
454
533
  secret: string;
455
- records: EnsRecords;
534
+ records: EnsRecords$1;
456
535
  referrer?: Address;
457
536
  }
458
537
  declare const useRegisterENS: ({ isTestnet }: {
@@ -494,5 +573,170 @@ declare const useENSResolver: ({ resolverChainId, isTestnet, }: {
494
573
  setUpdateRecordsTx: (update: UpdateRecordsRequest) => Promise<`0x${string}`>;
495
574
  };
496
575
 
497
- export { Accordion, Alert, Button, Card, ChainIcon, ConnectAndSetChain, ContenthashIcon, ContenthashProtocol, ContractErrorLabel, Dropdown, ENS_RESOLVER_ABI, EnsNameRegistrationForm, EnsRecordsForm, Icon, Input, MULTICALL, Modal, ProfileHeader, ProgressBar, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, ShurikenSpinner, Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TxProgress, WalletConnectProvider, capitalize, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce, deepCopy, diffToEnsRecords, ensureFloatInput, equalsIgnoreCase, formatFloat, getBlockExplorer, getBlockExplorerAddressUrl, getBlockExplorerName, getBlockExplorerTransactionUrl, getEnsAppUrl, getEnsRecordsDiff, getSupportedAddressByChainId, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isCommitmentToNewErr, isContenthashValid, isUserDeniedError, supportedAddresses, supportedContenthashRecords, supportedTexts, useENSResolver, useRegisterENS, useTheme, useWaitTransaction, validateEnsRecords };
498
- export type { AccordionProps, AlertProps, AlertVariant, ButtonProps, ButtonSize, ButtonVariant, ChainName, ConnectAndSetChainProps, ContractErrorLabelProps, DropdownProps, EnsAddressRecord, EnsContenthashRecord, EnsRecords, EnsRecordsDiff, EnsTextRecord, IconName, IconProps, InputProps, InputSize, InputType, ModalProps, ModalSize, ProfileHeaderProps, RecordValidationError, RegistrationRequest, ShurikenSpinnerProps, SupportedContenthashRecord, SupportedEnsAddress, SupportedText, SupportedTextRecord, TextCategory, TextColor, TextProps, TextSize, TextWeight, TextareaProps, TextareaSize, ThemeContextValue, ThemeName, ThemeProviderProps, TooltipPosition, TooltipProps };
576
+ declare enum ChainName {
577
+ Ethereum = "eth",
578
+ Default = "default",
579
+ Solana = "sol",
580
+ Arbitrum = "arb",
581
+ Optimism = "op",
582
+ Base = "base",
583
+ Polygon = "polygon",
584
+ Bsc = "bsc",
585
+ Avalanche = "avax",
586
+ Gnosis = "gnosis",
587
+ Zksync = "zksync",
588
+ Cosmos = "cosmos",
589
+ Near = "near",
590
+ Linea = "linea",
591
+ Scroll = "scroll",
592
+ Bitcoin = "btc",
593
+ Starknet = "starknet"
594
+ }
595
+
596
+ declare enum ContenthashType {
597
+ Ipfs = "ipfs",
598
+ Onion = "onion3",
599
+ Swarm = "swarm",
600
+ Arweave = "arweave",
601
+ Skynet = "syknet"
602
+ }
603
+
604
+ /** Parameters for estimating mint details and price. */
605
+ interface MintDetailsRequest {
606
+ parentName: string;
607
+ label: string;
608
+ minterAddress: string;
609
+ expiryInYears?: number;
610
+ isTestnet?: boolean;
611
+ }
612
+ /** Estimated details and validations for a mint request. */
613
+ interface MintDetailsResponse {
614
+ /**
615
+ * Flag indicating if subname can be minted based on passed parameters.
616
+ */
617
+ canMint: boolean;
618
+ /**
619
+ * Estimated price of minting in ETH
620
+ */
621
+ estimatedPriceEth: number;
622
+ /**
623
+ * Estimated fee for minting in ETH
624
+ */
625
+ estimatedFeeEth: number;
626
+ /**
627
+ * Flag indicating if standard fee is a fixed fee which is not subtracted from the minting price.
628
+ */
629
+ isStandardFee: boolean;
630
+ /**
631
+ * List of validation errors if there were any. Populated if {@link canMint} is false.
632
+ */
633
+ validationErrors: MintingValidationErrorType[];
634
+ }
635
+ /**
636
+ * Describes all possible error codes that could be thrown while attempting to mint the subname.
637
+ */
638
+ /** Error codes describing why a mint cannot proceed. */
639
+ type MintingValidationErrorType = "SUBNAME_TAKEN" | "MINTER_NOT_TOKEN_OWNER" | "MINTER_NOT_WHITELISTED" | "LISTING_EXPIRED" | "SUBNAME_RESERVED" | "VERIFIED_MINTER_ADDRESS_REQUIRED";
640
+ /** Prepared transaction data for calling the mint function on-chain. */
641
+ interface MintTransactionResponse {
642
+ contractAddress: Address;
643
+ args: any[];
644
+ account: string;
645
+ abi: any;
646
+ functionName: string;
647
+ value: bigint;
648
+ }
649
+ /** Parameters for preparing a mint transaction. */
650
+ interface MintTransactionRequest {
651
+ parentName: string;
652
+ label: string;
653
+ owner?: string;
654
+ minterAddress: Address;
655
+ expiryInYears?: number;
656
+ records?: EnsRecords;
657
+ }
658
+ /** Single ENS text record to set for the subname. */
659
+ interface EnsTextRecord {
660
+ key: string;
661
+ value: string;
662
+ }
663
+ /** Address record for a specific chain (by coin type or ChainName). */
664
+ interface EnsAddressRecord {
665
+ chain: ChainName | number;
666
+ value: string;
667
+ }
668
+ /** Contenthash record (ipfs, ipns, swarm, etc.). */
669
+ interface ContenthashRecord {
670
+ type: ContenthashType;
671
+ value: string;
672
+ }
673
+ /** Optional records to be applied at mint time. */
674
+ interface EnsRecords {
675
+ texts?: EnsTextRecord[];
676
+ addresses?: EnsAddressRecord[];
677
+ contenthash?: ContenthashRecord;
678
+ }
679
+
680
+ /**
681
+ * Main client interface for preparing mint transactions and checking
682
+ * subname availability across L1 and supported L2 networks.
683
+ *
684
+ * @example
685
+ * ```typescript
686
+ * import { createMintClient } from '@thenamespace/mint-manager';
687
+ *
688
+ * // Zero-config (mainnet)
689
+ * const client = createMintClient();
690
+ *
691
+ * // Testnet
692
+ * const testnet = createMintClient({
693
+ * isTestnet: true,
694
+ * customRpcUrls: { [baseSepolia.id]: ALCHEMY_BASE_SEPOLIA_RPC }
695
+ * });
696
+ * ```
697
+ */
698
+ interface MintClient {
699
+ /** Fetches estimated minting parameters and price quote. */
700
+ getMintDetails(request: MintDetailsRequest): Promise<MintDetailsResponse>;
701
+ /**
702
+ * Returns ABI, args and value for submitting the mint transaction.
703
+ * Includes resolver data if records are provided.
704
+ */
705
+ getMintTransactionParameters(request: MintTransactionRequest): Promise<MintTransactionResponse>;
706
+ /** Checks availability of an L1 subname using ENS Registry. */
707
+ isL1SubnameAvailable(subname: string): Promise<boolean>;
708
+ /** Checks availability of an L2 subname on a specific chain. */
709
+ isL2SubnameAvailable(subname: string, chainId: number): Promise<boolean>;
710
+ }
711
+
712
+ interface UseMintManagerParams {
713
+ isTestnet?: boolean;
714
+ }
715
+ declare const useMintManager: ({ isTestnet }: UseMintManagerParams) => {
716
+ mintClient: MintClient;
717
+ getListingDetails: (name: string) => Promise<NameListing>;
718
+ };
719
+
720
+ interface MintSubnameResult {
721
+ txHash: Hash;
722
+ price: bigint;
723
+ }
724
+ interface EstimatedFees {
725
+ gasEstimate: bigint;
726
+ gasPrice: bigint;
727
+ totalFeeWei: bigint;
728
+ totalFeeEth: number;
729
+ }
730
+ interface EstimateFeesParams {
731
+ mintTx: MintTransactionResponse;
732
+ account: Address;
733
+ }
734
+ declare const useMintSubname: ({ chainId }: {
735
+ chainId: number;
736
+ }) => {
737
+ mintSubname: (mintTx: MintTransactionResponse) => Promise<MintSubnameResult>;
738
+ estimateTransactionFees: (params: EstimateFeesParams) => Promise<EstimatedFees | null>;
739
+ };
740
+
741
+ export { Accordion, Alert, Button, Card, ChainIcon, ConnectAndSetChain, ContenthashIcon, ContenthashProtocol, ContractErrorLabel, Dropdown, ENS_RESOLVER_ABI, EnsNameRegistrationForm, EnsRecordsForm, Icon, Input, ListingNetwork, ListingType, MULTICALL, Modal, PricingDisplay, ProfileHeader, ProgressBar, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, ShurikenSpinner, SubnameMintForm, Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TxProgress, WalletConnectProvider, capitalize, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce, deepCopy, diffToEnsRecords, ensureFloatInput, equalsIgnoreCase, formatFloat, getBlockExplorer, getBlockExplorerAddressUrl, getBlockExplorerName, getBlockExplorerTransactionUrl, getChainIdForListingNetwork, getEnsAppUrl, getEnsRecordsDiff, getSupportedAddressByChainId, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isCommitmentToNewErr, isContenthashValid, isUserDeniedError, supportedAddresses, supportedContenthashRecords, supportedTexts, useENSResolver, useMintManager, useMintSubname, useRegisterENS, useTheme, useWaitTransaction, validateEnsRecords };
742
+ 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, ModalProps, ModalSize, NameListing, PricingDisplayProps, ProfileHeaderProps, RecordValidationError, RegistrationRequest, ShurikenSpinnerProps, SupportedContenthashRecord, SupportedEnsAddress, SupportedText, SupportedTextRecord, TextCategory, TextColor, TextProps, TextSize, TextWeight, TextareaProps, TextareaSize, ThemeContextValue, ThemeName, ThemeProviderProps, TooltipPosition, TooltipProps };