@thenamespace/ens-components 1.3.1 → 1.5.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
@@ -4,6 +4,7 @@ import * as _thenamespace_offchain_manager from '@thenamespace/offchain-manager'
4
4
  import { ChainName as ChainName$2, OffchainClient } from '@thenamespace/offchain-manager';
5
5
  import * as React$1 from 'react';
6
6
  import React__default, { ReactNode } from 'react';
7
+ import { UploadResult } from '@thenamespace/avatar';
7
8
 
8
9
  interface EnsRecords$1 {
9
10
  addresses: EnsAddressRecord$1[];
@@ -172,6 +173,45 @@ declare const yearsFromSeconds: (seconds: number) => number;
172
173
  */
173
174
  declare const formatDurationSummary: (durationSeconds: number) => string;
174
175
 
176
+ /**
177
+ * Pure helpers for formatting ETH/USD pricing in the registration UI.
178
+ *
179
+ * Display rules:
180
+ * - ETH is rendered at a fixed 4 decimals.
181
+ * - Non-zero values smaller than 0.0001 ETH render as the literal "<0.0001"
182
+ * so cheap-gas rows stay informative without claiming a misleading exact
183
+ * figure. The USD subtitle is derived from wei (when available) so it
184
+ * stays numerically honest even when the ETH cell is rounded.
185
+ * - "Free" and "N/A" are sentinel strings — they bypass formatting and
186
+ * suppress the USD subtitle.
187
+ */
188
+ declare const ETH_SENTINELS: readonly ["Free", "N/A"];
189
+ type EthSentinel = (typeof ETH_SENTINELS)[number];
190
+ declare const isSentinel: (amount: number | string) => amount is EthSentinel;
191
+ /**
192
+ * Format an ETH amount for display at a fixed 4 decimals.
193
+ *
194
+ * Any positive value below the 4-decimal threshold renders as the literal
195
+ * "<0.0001" — honest about the rounding direction, and (crucially) avoids
196
+ * the misleading 1:1 read against the wei-derived USD subtitle when the
197
+ * true amount is much smaller than 0.0001 ETH.
198
+ */
199
+ declare const formatEth: (eth: number) => string;
200
+ /**
201
+ * Convert wei → USD. Note the `Number(bigint)` cast loses exactness above
202
+ * 2^53 wei (~0.009 ETH); the resulting error is < 1e-7 relative, which is
203
+ * invisible after `.toFixed(2)` for any realistic ENS registration total.
204
+ */
205
+ declare const usdFromWei: (wei: bigint, rate: number) => number;
206
+ /**
207
+ * Compute the `≈ $X.XX` subtitle for a fee row.
208
+ *
209
+ * Prefers `weiAmount` (precise) over the displayed string (which may have
210
+ * been rounded by `formatEth`). Returns `null` when the row is loading,
211
+ * unpriced, a sentinel ("Free"/"N/A"), or otherwise unparseable.
212
+ */
213
+ declare const computeUsd: (amount: number | string, weiAmount: bigint | undefined, ethUsdRate: number | null | undefined, isChecking: boolean) => string | null;
214
+
175
215
  interface EnsRecordsFormProps {
176
216
  resolverChainId?: number;
177
217
  resolverAddress?: Address;
@@ -459,20 +499,20 @@ interface ProgressBarProps {
459
499
  }
460
500
  declare function ProgressBar({ progress }: ProgressBarProps): react_jsx_runtime.JSX.Element;
461
501
 
502
+ interface FeeRow {
503
+ amount: number | string;
504
+ isChecking: boolean;
505
+ /** Optional precise wei value. When provided, USD is computed from wei
506
+ * rather than from the (possibly rounded) display string. See
507
+ * `usdFromWei` for the precision bound. */
508
+ weiAmount?: bigint;
509
+ }
462
510
  interface PricingDisplayProps {
463
- primaryFee: {
511
+ primaryFee: FeeRow & {
464
512
  label: string;
465
- amount: number | string;
466
- isChecking: boolean;
467
- };
468
- networkFees?: {
469
- amount: number | string;
470
- isChecking: boolean;
471
- };
472
- total: {
473
- amount: number | string;
474
- isChecking: boolean;
475
513
  };
514
+ networkFees?: FeeRow;
515
+ total: FeeRow;
476
516
  expiryPicker?: {
477
517
  durationSeconds: number;
478
518
  onDurationChange: (seconds: number) => void;
@@ -853,24 +893,6 @@ declare const useMintSubname: ({ chainId }: {
853
893
 
854
894
  declare const useOffchainManager: (name: string, apiKeyOrToken: string, isTestnet?: boolean) => _thenamespace_offchain_manager.OffchainClient;
855
895
 
856
- /**
857
- * Upload result
858
- */
859
- interface UploadResult {
860
- /** URL of the uploaded image */
861
- url: string;
862
- /** Upload timestamp */
863
- uploadedAt: string;
864
- /** File size in bytes */
865
- fileSize: number;
866
- /** Whether this was an update to existing image */
867
- isUpdate: boolean;
868
- /** Whether the upload is pending (for unregistered names) */
869
- pending?: boolean;
870
- /** Optional message from the server */
871
- message?: string;
872
- }
873
-
874
896
  interface UseAvatarClientParams {
875
897
  isTestnet?: boolean;
876
898
  domain?: string;
@@ -889,5 +911,5 @@ declare const useAvatarClient: ({ isTestnet, domain }: UseAvatarClientParams) =>
889
911
  getErrorMessage: (err: unknown, imageType?: UploadImageType) => string;
890
912
  };
891
913
 
892
- export { Accordion, Alert, Button, Card, ChainIcon, ConnectAndSetChain, ContenthashIcon, ContenthashProtocol, ContractErrorLabel, Dropdown, DurationPicker, ENS_RESOLVER_ABI, EnsNameRegistrationForm, EnsRecordsForm, Icon, Input, ListingNetwork, ListingType, MIN_REGISTRATION_SECONDS, MULTICALL, Modal, ONE_DAY, ONE_YEAR, 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, formatDurationSummary, formatFloat, getAvatarUploadErrorMessage, getBlockExplorer, getBlockExplorerAddressUrl, getBlockExplorerName, getBlockExplorerTransactionUrl, getChainIdForListingNetwork, getEnsAppUrl, getEnsRecordsDiff, getImageUploadErrorMessage, getSupportedAddressByChainId, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isCommitmentToNewErr, isContenthashValid, isUserDeniedError, roundDurationWithDay, secondsFromYears, secondsToDateInput, supportedAddresses, supportedContenthashRecords, supportedTexts, useAvatarClient, useENSResolver, useEthDollarValue, useMintManager, useMintSubname, useOffchainManager, useRegisterENS, useTheme, useWaitTransaction, validateEnsRecords, wait, yearsFromSeconds };
893
- export type { AccordionProps, AlertPosition, AlertProps, AlertVariant, ButtonProps, ButtonSize, ButtonVariant, ChainName$1 as ChainName, ConnectAndSetChainProps, ContractErrorLabelProps, DropdownProps, DurationPickerProps, 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, RegistrationFeeEstimate, RegistrationRequest, ShurikenSpinnerProps, SupportedContenthashRecord, SupportedEnsAddress, SupportedText, SupportedTextRecord, TextCategory, TextColor, TextProps, TextSize, TextWeight, TextareaProps, TextareaSize, ThemeContextValue, ThemeName, ThemeProviderProps, TooltipPosition, TooltipProps, UploadAvatarParams, UploadImageType };
914
+ export { Accordion, Alert, Button, Card, ChainIcon, ConnectAndSetChain, ContenthashIcon, ContenthashProtocol, ContractErrorLabel, Dropdown, DurationPicker, ENS_RESOLVER_ABI, ETH_SENTINELS, EnsNameRegistrationForm, EnsRecordsForm, Icon, Input, ListingNetwork, ListingType, MIN_REGISTRATION_SECONDS, MULTICALL, Modal, ONE_DAY, ONE_YEAR, OffchainSubnameForm, PricingDisplay, ProfileHeader, ProgressBar, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, ShurikenSpinner, SubnameMintForm, Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TransactionPendingScreen, TxProgress, capitalize, computeUsd, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce, deepCopy, diffToEnsRecords, ensureFloatInput, equalsIgnoreCase, formatDurationSummary, formatEth, formatFloat, getAvatarUploadErrorMessage, getBlockExplorer, getBlockExplorerAddressUrl, getBlockExplorerName, getBlockExplorerTransactionUrl, getChainIdForListingNetwork, getEnsAppUrl, getEnsRecordsDiff, getImageUploadErrorMessage, getSupportedAddressByChainId, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isCommitmentToNewErr, isContenthashValid, isSentinel, isUserDeniedError, roundDurationWithDay, secondsFromYears, secondsToDateInput, supportedAddresses, supportedContenthashRecords, supportedTexts, usdFromWei, useAvatarClient, useENSResolver, useEthDollarValue, useMintManager, useMintSubname, useOffchainManager, useRegisterENS, useTheme, useWaitTransaction, validateEnsRecords, wait, yearsFromSeconds };
915
+ export type { AccordionProps, AlertPosition, AlertProps, AlertVariant, ButtonProps, ButtonSize, ButtonVariant, ChainName$1 as ChainName, ConnectAndSetChainProps, ContractErrorLabelProps, DropdownProps, DurationPickerProps, EnsAddressRecord$1 as EnsAddressRecord, EnsContenthashRecord, EnsRecords$1 as EnsRecords, EnsRecordsDiff, EnsTextRecord$1 as EnsTextRecord, EstimatedFees, EthSentinel, IconName, IconProps, InputProps, InputSize, InputType, ModalPresentation, ModalProps, ModalResponsivePresentation, ModalSize, NameListing, OffchainSubnameCreatedData, PricingDisplayProps, ProfileHeaderProps, RecordValidationError, RegistrationFeeEstimate, RegistrationRequest, ShurikenSpinnerProps, SupportedContenthashRecord, SupportedEnsAddress, SupportedText, SupportedTextRecord, TextCategory, TextColor, TextProps, TextSize, TextWeight, TextareaProps, TextareaSize, ThemeContextValue, ThemeName, ThemeProviderProps, TooltipPosition, TooltipProps, UploadAvatarParams, UploadImageType };