@thenamespace/ens-components 0.25.0 → 0.26.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
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Address, ContractFunctionExecutionError, Hash, TransactionReceipt } from 'viem';
2
+ import { Address, Hash, ContractFunctionExecutionError, TransactionReceipt } from 'viem';
3
3
  import * as React$1 from 'react';
4
4
  import React__default, { ReactNode, PropsWithChildren } from 'react';
5
5
 
@@ -62,6 +62,54 @@ interface RegistrationSuccessData {
62
62
  }
63
63
  declare const EnsNameRegistrationForm: (props: EnsNameRegistrationFormProps) => react_jsx_runtime.JSX.Element;
64
64
 
65
+ declare const capitalize: (value: string) => string;
66
+ declare const equalsIgnoreCase: (a: string, b: string) => boolean;
67
+ declare const deepCopy: (a: any) => any;
68
+ declare const debounce: <T extends (...args: any[]) => any>(func: T, wait: number) => ((...args: Parameters<T>) => void);
69
+
70
+ declare function convertEVMChainIdToCoinType(chainId: number): number;
71
+
72
+ interface EnsRecordsDiff {
73
+ textsAdded: EnsTextRecord[];
74
+ textsModified: EnsTextRecord[];
75
+ textsRemoved: EnsTextRecord[];
76
+ addressesAdded: EnsAddressRecord[];
77
+ addressesRemoved: EnsAddressRecord[];
78
+ addressesModified: EnsAddressRecord[];
79
+ contenthashAdded?: EnsContenthashRecord;
80
+ contenthashRemoved: boolean;
81
+ contenthashModified?: EnsContenthashRecord;
82
+ isDifferent: boolean;
83
+ }
84
+ declare const getEnsRecordsDiff: (oldRecords: EnsRecords, newRecords: EnsRecords) => EnsRecordsDiff;
85
+ interface RecordValidationError {
86
+ type: "address" | "text" | "contenthash";
87
+ reason: string;
88
+ }
89
+ declare const validateEnsRecords: (ensRecords: EnsRecords) => {
90
+ validationFailed: boolean;
91
+ errors: RecordValidationError[];
92
+ };
93
+ declare const diffToEnsRecords: (diff: EnsRecordsDiff) => EnsRecords;
94
+
95
+ declare const ensureFloatInput: (value: string) => string;
96
+ declare const formatFloat: (value: string | number, decimals?: number) => number;
97
+
98
+ declare const convertToResolverData: (name: string, records: EnsRecords) => `0x${string}`[];
99
+ declare const convertToMulticallResolverData: (name: string, recordsDiff: EnsRecordsDiff) => `0x${string}`[];
100
+
101
+ declare const createEnsReferer: (address: Address) => Hash;
102
+
103
+ interface BlockExplorerConfig {
104
+ name: string;
105
+ url: string;
106
+ }
107
+ declare const getBlockExplorer: (chainId: number) => BlockExplorerConfig;
108
+ declare const getBlockExplorerTransactionUrl: (chainId: number, hash: string) => string;
109
+ declare const getBlockExplorerAddressUrl: (chainId: number, address: string) => string;
110
+ declare const getBlockExplorerName: (chainId: number) => string;
111
+ declare const getEnsAppUrl: (ensName: string, isTestnet?: boolean) => string;
112
+
65
113
  interface EnsRecordsFormProps {
66
114
  resolverChainId?: number;
67
115
  resolverAddress?: Address;
@@ -70,8 +118,12 @@ interface EnsRecordsFormProps {
70
118
  existingRecords: EnsRecords;
71
119
  noBorder?: boolean;
72
120
  className?: string;
121
+ onCancel?: () => void;
122
+ onRecordsUpdated?: (newRecords: EnsRecordsDiff) => void;
123
+ onGreat?: () => void;
124
+ onTransactionSent?: (hash: Hash) => void;
73
125
  }
74
- declare const EnsRecordsForm: ({ name, existingRecords, resolverChainId, isTestnet, resolverAddress, noBorder, className, }: EnsRecordsFormProps) => react_jsx_runtime.JSX.Element;
126
+ declare const EnsRecordsForm: ({ name, existingRecords, resolverChainId, isTestnet, resolverAddress, noBorder, className, onCancel, onGreat, onRecordsUpdated, onTransactionSent }: EnsRecordsFormProps) => react_jsx_runtime.JSX.Element;
75
127
 
76
128
  type ButtonVariant = "solid" | "outline" | "ghost" | "destructive";
77
129
  type ButtonSize = "sm" | "md" | "lg";
@@ -318,53 +370,6 @@ interface SupportedTextRecord {
318
370
  declare const supportedTexts: SupportedTextRecord[];
319
371
  declare const getSupportedText: (key: string) => SupportedTextRecord | undefined;
320
372
 
321
- declare const capitalize: (value: string) => string;
322
- declare const equalsIgnoreCase: (a: string, b: string) => boolean;
323
- declare const deepCopy: (a: any) => any;
324
- declare const debounce: <T extends (...args: any[]) => any>(func: T, wait: number) => ((...args: Parameters<T>) => void);
325
-
326
- declare function convertEVMChainIdToCoinType(chainId: number): number;
327
-
328
- interface EnsRecordsDiff {
329
- textsAdded: EnsTextRecord[];
330
- textsModified: EnsTextRecord[];
331
- textsRemoved: EnsTextRecord[];
332
- addressesAdded: EnsAddressRecord[];
333
- addressesRemoved: EnsAddressRecord[];
334
- addressesModified: EnsAddressRecord[];
335
- contenthashAdded?: EnsContenthashRecord;
336
- contenthashRemoved: boolean;
337
- contenthashModified?: EnsContenthashRecord;
338
- isDifferent: boolean;
339
- }
340
- declare const getEnsRecordsDiff: (oldRecords: EnsRecords, newRecords: EnsRecords) => EnsRecordsDiff;
341
- interface RecordValidationError {
342
- type: "address" | "text" | "contenthash";
343
- reason: string;
344
- }
345
- declare const validateEnsRecords: (ensRecords: EnsRecords) => {
346
- validationFailed: boolean;
347
- errors: RecordValidationError[];
348
- };
349
-
350
- declare const ensureFloatInput: (value: string) => string;
351
- declare const formatFloat: (value: string | number, decimals?: number) => number;
352
-
353
- declare const convertToResolverData: (name: string, records: EnsRecords) => `0x${string}`[];
354
- declare const convertToMulticallResolverData: (name: string, recordsDiff: EnsRecordsDiff) => `0x${string}`[];
355
-
356
- declare const createEnsReferer: (address: Address) => Hash;
357
-
358
- interface BlockExplorerConfig {
359
- name: string;
360
- url: string;
361
- }
362
- declare const getBlockExplorer: (chainId: number) => BlockExplorerConfig;
363
- declare const getBlockExplorerTransactionUrl: (chainId: number, hash: string) => string;
364
- declare const getBlockExplorerAddressUrl: (chainId: number, address: string) => string;
365
- declare const getBlockExplorerName: (chainId: number) => string;
366
- declare const getEnsAppUrl: (ensName: string, isTestnet?: boolean) => string;
367
-
368
373
  declare const SET_TEXT_FUNC = "function setText(bytes32 node, string key, string value)";
369
374
  declare const SET_ADDRESS_FUNC = "function setAddr(bytes32 node, uint256 coin, bytes value)";
370
375
  declare const SET_CONTENTHASH_FUNC = "function setContenthash(bytes32 node, bytes value)";
@@ -489,5 +494,5 @@ declare const useENSResolver: ({ resolverChainId, isTestnet, }: {
489
494
  setUpdateRecordsTx: (update: UpdateRecordsRequest) => Promise<`0x${string}`>;
490
495
  };
491
496
 
492
- 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, 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 };
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 };
493
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 };
package/dist/index.js CHANGED
@@ -1666,6 +1666,18 @@ const validateEnsRecords = (ensRecords) => {
1666
1666
  errors: validationErrs
1667
1667
  };
1668
1668
  };
1669
+ const diffToEnsRecords = (diff) => {
1670
+ const records = {
1671
+ addresses: [],
1672
+ texts: []
1673
+ };
1674
+ records.addresses = [...diff.addressesAdded, ...diff.addressesModified];
1675
+ records.texts = [...diff.textsAdded, ...diff.textsModified];
1676
+ if (diff.contenthashAdded || diff.contenthashModified) {
1677
+ records.contenthash = diff.contenthashAdded || diff.contenthashModified;
1678
+ }
1679
+ return records;
1680
+ };
1669
1681
 
1670
1682
  const ensureFloatInput = (value) => {
1671
1683
  if (value.length === 0) {
@@ -28602,19 +28614,26 @@ const EnsUpdateRecordsForm = ({
28602
28614
  resolverAddress,
28603
28615
  isTestnet,
28604
28616
  onGreat,
28605
- onRecordsUpdated
28617
+ onRecordsUpdated,
28618
+ onCancel,
28619
+ onTransactionSent
28606
28620
  }) => {
28607
28621
  const [recordsTemplate, setRecordsTemplate] = useState(
28608
28622
  deepCopy(existingRecords)
28609
28623
  );
28610
28624
  const { setUpdateRecordsTx } = useENSResolver({ resolverChainId, isTestnet });
28611
- const { waitTx } = useWaitTransaction({ isTestnet, chainId: resolverChainId });
28625
+ const { waitTx } = useWaitTransaction({
28626
+ isTestnet,
28627
+ chainId: resolverChainId
28628
+ });
28612
28629
  const [step, setStep] = useState(0 /* SetRecords */);
28613
28630
  const [updateTx, setUpdateTx] = useState({
28614
28631
  hash: "0x0",
28615
28632
  status: TxProgress.Pending
28616
28633
  });
28617
- const [error, setError] = useState(null);
28634
+ const [error, setError] = useState(
28635
+ null
28636
+ );
28618
28637
  const [isUpdating, setIsUpdating] = useState({
28619
28638
  waitingWallet: false,
28620
28639
  waitingTx: false
@@ -28668,6 +28687,7 @@ const EnsUpdateRecordsForm = ({
28668
28687
  return;
28669
28688
  }
28670
28689
  try {
28690
+ onTransactionSent?.(tx);
28671
28691
  await waitTx({ hash: tx });
28672
28692
  setUpdateTx({ hash: tx, status: TxProgress.Success });
28673
28693
  setIsUpdating({ waitingWallet: false, waitingTx: false });
@@ -28685,9 +28705,17 @@ const EnsUpdateRecordsForm = ({
28685
28705
  records: recordsTemplate,
28686
28706
  onRecordsUpdated: (records) => setRecordsTemplate(records),
28687
28707
  actionButtons: /* @__PURE__ */ jsxs("div", { style: { padding: 10, paddingTop: 0 }, children: [
28688
- validationError && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Alert, { variant: "error", children: validationError }) }),
28708
+ validationError && /* @__PURE__ */ jsx("div", { style: { marginTop: -12 }, children: /* @__PURE__ */ jsx(Alert, { variant: "error", children: validationError }) }),
28689
28709
  /* @__PURE__ */ jsxs("div", { className: "ens-update-records-form-actions", children: [
28690
- /* @__PURE__ */ jsx(Button, { variant: "outline", size: "lg", children: "Cancel" }),
28710
+ /* @__PURE__ */ jsx(
28711
+ Button,
28712
+ {
28713
+ onClick: () => onCancel?.(),
28714
+ variant: "outline",
28715
+ size: "lg",
28716
+ children: "Cancel"
28717
+ }
28718
+ ),
28691
28719
  /* @__PURE__ */ jsx(
28692
28720
  Button,
28693
28721
  {
@@ -28738,7 +28766,11 @@ const EnsRecordsForm = ({
28738
28766
  isTestnet,
28739
28767
  resolverAddress,
28740
28768
  noBorder,
28741
- className
28769
+ className,
28770
+ onCancel,
28771
+ onGreat,
28772
+ onRecordsUpdated,
28773
+ onTransactionSent
28742
28774
  }) => {
28743
28775
  const mainnetChainId = isTestnet ? sepolia$1.id : mainnet$1.id;
28744
28776
  const resolverChain = resolverChainId ? resolverChainId : mainnetChainId;
@@ -28826,9 +28858,12 @@ const EnsRecordsForm = ({
28826
28858
  isTestnet,
28827
28859
  resolverAddress: resolverState.address,
28828
28860
  resolverChainId: resolverChain,
28829
- onRecordsUpdated: (recordsDiff) => {
28830
- console.log("records updated");
28831
- }
28861
+ onRecordsUpdated: (records) => {
28862
+ onRecordsUpdated?.(records);
28863
+ },
28864
+ onGreat,
28865
+ onCancel,
28866
+ onTransactionSent
28832
28867
  }
28833
28868
  )
28834
28869
  ]
@@ -36590,5 +36625,5 @@ var walletConnectWalletYHWKVTDY = /*#__PURE__*/Object.freeze({
36590
36625
  default: walletConnectWallet_default
36591
36626
  });
36592
36627
 
36593
- 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$1 as Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TxProgress, WalletConnectProvider, capitalize, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce$1 as debounce, deepCopy, 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 };
36628
+ 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$1 as Text, TextRecordCategory, Textarea, ThemeProvider, Tooltip, TxProgress, WalletConnectProvider, capitalize, convertEVMChainIdToCoinType, convertToMulticallResolverData, convertToResolverData, createEnsReferer, debounce$1 as 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 };
36594
36629
  //# sourceMappingURL=index.js.map