@thenamespace/ens-components 0.19.0 → 0.21.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.
Files changed (137) hide show
  1. package/README.md +1 -510
  2. package/dist/index.css +1 -4890
  3. package/dist/index.css.map +1 -1
  4. package/dist/index.d.ts +211 -26716
  5. package/dist/index.js +28632 -132585
  6. package/dist/index.js.map +1 -1
  7. package/dist/styles.js +3 -3
  8. package/dist/types/components/atoms/icon/Icon.d.ts +1 -1
  9. package/dist/types/components/atoms/index.d.ts +1 -0
  10. package/dist/types/components/atoms/input/Input.d.ts +1 -0
  11. package/dist/types/components/atoms/spinner/ShurikenSpinner.d.ts +8 -0
  12. package/dist/types/components/ens-name-registration/ENSNameRegistrationForm.d.ts +11 -0
  13. package/dist/types/components/ens-name-registration/RegistrationProcess.d.ts +22 -0
  14. package/dist/types/components/ens-name-registration/RegistrationSummary.d.ts +40 -0
  15. package/dist/types/components/ens-name-registration/SetNameRecords.d.ts +10 -0
  16. package/dist/types/components/ens-name-registration/registration/CommitmentStep.d.ts +11 -0
  17. package/dist/types/components/{ens-names-registrar-component/sub-components → ens-name-registration/registration}/ProgressBar.d.ts +1 -0
  18. package/dist/types/components/ens-name-registration/registration/RegistrationStep.d.ts +17 -0
  19. package/dist/types/components/ens-name-registration/registration/SuccessScreen.d.ts +16 -0
  20. package/dist/types/components/{ens-names-registrar-component/sub-components → ens-name-registration/registration}/Timer.d.ts +1 -0
  21. package/dist/types/components/ens-name-registration/registration/TimerStep.d.ts +8 -0
  22. package/dist/types/components/ens-name-registration/registration/TransactionPendingScreen.d.ts +10 -0
  23. package/dist/types/components/ens-name-registration/registration/index.d.ts +7 -0
  24. package/dist/types/components/ens-name-registration/registration/types.d.ts +30 -0
  25. package/dist/types/components/index.d.ts +1 -6
  26. package/dist/types/components/molecules/accordion/Accordion.d.ts +16 -0
  27. package/dist/types/components/molecules/accordion/index.d.ts +1 -0
  28. package/dist/types/components/molecules/contract-error-label/ContractErrorLabel.d.ts +16 -0
  29. package/dist/types/components/molecules/contract-error-label/index.d.ts +1 -0
  30. package/dist/types/components/molecules/index.d.ts +2 -0
  31. package/dist/types/components/select-records-form/SelectRecordsForm.d.ts +2 -1
  32. package/dist/types/constants/records/addressConstants.d.ts +0 -1
  33. package/dist/types/hooks/abis/index.d.ts +92 -0
  34. package/dist/types/hooks/index.d.ts +2 -25
  35. package/dist/types/hooks/useRegisterENS.d.ts +26 -0
  36. package/dist/types/hooks/useWaitTransaction.d.ts +13 -0
  37. package/dist/types/index.d.ts +1 -2
  38. package/dist/types/types/index.d.ts +0 -10
  39. package/dist/types/utils/ens.d.ts +2 -3
  40. package/dist/types/utils/index.d.ts +2 -0
  41. package/dist/types/utils/models.d.ts +1 -2
  42. package/dist/types/utils/records.d.ts +9 -0
  43. package/dist/types/utils/strings.d.ts +1 -0
  44. package/dist/types/web3/index.d.ts +0 -4
  45. package/package.json +21 -17
  46. package/dist/types/backend/index.d.ts +0 -1
  47. package/dist/types/backend/list-manager/index.d.ts +0 -57
  48. package/dist/types/components/ens-names-card/EnsNameCard.d.ts +0 -14
  49. package/dist/types/components/ens-names-registrar-component/ENSNamesRegistrarComponent.d.ts +0 -17
  50. package/dist/types/components/ens-names-registrar-component/sub-components/CostSummary.d.ts +0 -12
  51. package/dist/types/components/ens-names-registrar-component/sub-components/Header.d.ts +0 -8
  52. package/dist/types/components/ens-names-registrar-component/sub-components/NameSearch.d.ts +0 -12
  53. package/dist/types/components/ens-names-registrar-component/sub-components/RegistrationForm.d.ts +0 -24
  54. package/dist/types/components/ens-names-registrar-component/sub-components/RegistrationProcess.d.ts +0 -10
  55. package/dist/types/components/ens-names-registrar-component/sub-components/StepItem.d.ts +0 -11
  56. package/dist/types/components/ens-names-registrar-component/sub-components/SuccessScreen.d.ts +0 -13
  57. package/dist/types/components/ens-navbar-profile-card/NavbarProfileCard.d.ts +0 -14
  58. package/dist/types/components/ens-profile-card/ProfileCard.d.ts +0 -24
  59. package/dist/types/components/subname-offchain-registrar-modal/SubnameOffChainRegistrarModal.d.ts +0 -18
  60. package/dist/types/components/subname-offchain-registrar-modal/sub-components/InitialStep.d.ts +0 -9
  61. package/dist/types/components/subname-offchain-registrar-modal/sub-components/OffchainRegistrationProcess.d.ts +0 -18
  62. package/dist/types/components/subname-offchain-registrar-modal/sub-components/OffchainSuccessScreen.d.ts +0 -8
  63. package/dist/types/components/subname-onchain-registrar-modal/SubnameOnChainRegistrarModal.d.ts +0 -31
  64. package/dist/types/components/subname-onchain-registrar-modal/sub-components/ConfirmationStep.d.ts +0 -18
  65. package/dist/types/components/subname-onchain-registrar-modal/sub-components/InitialStep.d.ts +0 -11
  66. package/dist/types/components/subname-onchain-registrar-modal/sub-components/OnchainSuccessScreen.d.ts +0 -6
  67. package/dist/types/components/subname-onchain-registrar-modal/sub-components/RegistrationStep.d.ts +0 -28
  68. package/dist/types/context/account-context.d.ts +0 -44
  69. package/dist/types/context/account-filter-context.d.ts +0 -32
  70. package/dist/types/context/auth-context.d.ts +0 -22
  71. package/dist/types/context/crop-image-context.d.ts +0 -27
  72. package/dist/types/context/current-user-context.d.ts +0 -19
  73. package/dist/types/context/edit-profile-context.d.ts +0 -13
  74. package/dist/types/context/ens-profile-context.d.ts +0 -54
  75. package/dist/types/context/index.d.ts +0 -6
  76. package/dist/types/context/listing-form-context.d.ts +0 -55
  77. package/dist/types/context/listing-status-context.d.ts +0 -19
  78. package/dist/types/context/mint-subname-context.d.ts +0 -12
  79. package/dist/types/context/profile-filter.context.d.ts +0 -19
  80. package/dist/types/environment/index.d.ts +0 -9
  81. package/dist/types/hooks/efp/use-efp.d.ts +0 -11
  82. package/dist/types/hooks/ens/ens-local-cache.d.ts +0 -18
  83. package/dist/types/hooks/ens/use-ens-client.d.ts +0 -763
  84. package/dist/types/hooks/ens/use-ens-contract-address.d.ts +0 -1
  85. package/dist/types/hooks/ens/use-ens-name-profile.d.ts +0 -15
  86. package/dist/types/hooks/ens/use-ens.d.ts +0 -21
  87. package/dist/types/hooks/ens/use-eth-registrar-controller.d.ts +0 -21
  88. package/dist/types/hooks/ens/use-name-wrapper.d.ts +0 -6
  89. package/dist/types/hooks/ens/use-owned-ens-names.d.ts +0 -9
  90. package/dist/types/hooks/namespace/use-burn-l2-subname.d.ts +0 -4
  91. package/dist/types/hooks/namespace/use-hybrid-resolver.d.ts +0 -10
  92. package/dist/types/hooks/namespace/use-l2-controller.d.ts +0 -8
  93. package/dist/types/hooks/namespace/use-listing-manager.d.ts +0 -2
  94. package/dist/types/hooks/namespace/use-mint-client.d.ts +0 -2
  95. package/dist/types/hooks/namespace/use-mintable-listings.d.ts +0 -7
  96. package/dist/types/hooks/namespace/use-name-listings.d.ts +0 -1
  97. package/dist/types/hooks/namespace/use-namespace-account.d.ts +0 -25
  98. package/dist/types/hooks/namespace/use-namespace-indexer.d.ts +0 -7
  99. package/dist/types/hooks/namespace/use-re-render-image.d.ts +0 -1
  100. package/dist/types/hooks/namespace/use-trading-stats.d.ts +0 -1
  101. package/dist/types/hooks/upload-image/use-upload-image.d.ts +0 -8
  102. package/dist/types/hooks/use-error-modal.d.ts +0 -4
  103. package/dist/types/hooks/use-screen-size.d.ts +0 -5
  104. package/dist/types/hooks/useWaitForTransaction.d.ts +0 -3
  105. package/dist/types/hooks/useWeb3Clients.d.ts +0 -8041
  106. package/dist/types/hooks/web3/alchemy-sdk-no-ssr.d.ts +0 -0
  107. package/dist/types/hooks/web3/use-alchemy-sdk.d.ts +0 -4
  108. package/dist/types/hooks/web3/use-block-explorer.d.ts +0 -2
  109. package/dist/types/hooks/web3/use-blockexplorer-url.d.ts +0 -2
  110. package/dist/types/hooks/web3/use-contract-addresses.d.ts +0 -1
  111. package/dist/types/hooks/web3/use-l1-name-minter.d.ts +0 -5
  112. package/dist/types/hooks/web3/use-main-chain.d.ts +0 -10
  113. package/dist/types/hooks/web3/use-main-public-client.d.ts +0 -3624
  114. package/dist/types/hooks/web3/use-name-resolver.d.ts +0 -24
  115. package/dist/types/hooks/web3/use-name-wrapper.d.ts +0 -3
  116. package/dist/types/hooks/web3/use-wait-for-transaction.d.ts +0 -8
  117. package/dist/types/hooks/web3/use-web3-clients.d.ts +0 -8042
  118. package/dist/types/types/auth.d.ts +0 -8
  119. package/dist/types/types/ens.d.ts +0 -61
  120. package/dist/types/types/errors.d.ts +0 -2
  121. package/dist/types/types/hybrid-resolver.d.ts +0 -4
  122. package/dist/types/types/indexer.d.ts +0 -27
  123. package/dist/types/types/l2.d.ts +0 -34
  124. package/dist/types/types/list-manager.d.ts +0 -179
  125. package/dist/types/types/listing.d.ts +0 -136
  126. package/dist/types/types/minting.d.ts +0 -75
  127. package/dist/types/types/name-listing/enums.d.ts +0 -20
  128. package/dist/types/types/name-listing/index.d.ts +0 -3
  129. package/dist/types/types/name-listing/l2-name-registry.d.ts +0 -13
  130. package/dist/types/types/name-listing/listing.d.ts +0 -73
  131. package/dist/types/types/networks.d.ts +0 -16
  132. package/dist/types/utils/image-event-emitter.d.ts +0 -8
  133. package/dist/types/web3/abis/index.d.ts +0 -300
  134. package/dist/types/web3/chains.d.ts +0 -12
  135. package/dist/types/web3/contracts/addresses.d.ts +0 -4
  136. package/dist/types/web3/efp-provider.d.ts +0 -2
  137. package/dist/types/web3/providers.d.ts +0 -3
package/README.md CHANGED
@@ -1,510 +1 @@
1
- # @thenamespace/ens-components
2
-
3
- React components for ENS (Ethereum Name Service) name registration and subname minting.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @thenamespace/ens-components
9
- ```
10
-
11
- ## Peer Dependencies
12
-
13
- This package requires the following peer dependencies:
14
-
15
- ```bash
16
- npm install wagmi @rainbow-me/rainbowkit @tanstack/react-query viem react react-dom
17
- ```
18
-
19
- ## Quick Start
20
-
21
- ### 1. Setup Required Providers
22
-
23
- Wrap your application with the required providers:
24
-
25
- ```tsx
26
- import React from "react";
27
- import { WagmiProvider } from "wagmi";
28
- import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
29
- import { RainbowKitProvider, getDefaultConfig } from "@rainbow-me/rainbowkit";
30
- import { mainnet, sepolia } from "wagmi/chains";
31
- import { http } from "wagmi";
32
-
33
- // Import styles
34
- import "@thenamespace/ens-components/index.css";
35
- import "@rainbow-me/rainbowkit/styles.css";
36
-
37
- const wagmiConfig = getDefaultConfig({
38
- appName: "My ENS App",
39
- projectId: "YOUR_WALLETCONNECT_PROJECT_ID", // Get from https://cloud.walletconnect.com
40
- chains: [mainnet, sepolia],
41
- transports: {
42
- [mainnet.id]: http(),
43
- [sepolia.id]: http(),
44
- },
45
- });
46
-
47
- const queryClient = new QueryClient();
48
-
49
- function AppProviders({ children }: { children: React.ReactNode }) {
50
- return (
51
- <WagmiProvider config={wagmiConfig}>
52
- <QueryClientProvider client={queryClient}>
53
- <RainbowKitProvider>
54
- {children}
55
- </RainbowKitProvider>
56
- </QueryClientProvider>
57
- </WagmiProvider>
58
- );
59
- }
60
- ```
61
-
62
- ### 2. Use the Components
63
-
64
- ```tsx
65
- import { ENSNamesRegistrarComponent, SubnameOnChainRegistrarModal } from "@thenamespace/ens-components";
66
-
67
- function MyApp() {
68
- return (
69
- <AppProviders>
70
- {/* Your components here */}
71
- </AppProviders>
72
- );
73
- }
74
- ```
75
-
76
- ## Components
77
-
78
- ### ENSNamesRegistrarComponent
79
-
80
- Component for registering top-level ENS names (e.g., `myname.eth`).
81
-
82
- #### Basic Usage
83
-
84
- ```tsx
85
- import { useState } from "react";
86
- import { ENSNamesRegistrarComponent } from "@thenamespace/ens-components";
87
-
88
- function RegisterENSName() {
89
- const [name, setName] = useState("");
90
- const [duration, setDuration] = useState(1);
91
-
92
- return (
93
- <ENSNamesRegistrarComponent
94
- name={name}
95
- duration={duration}
96
- onNameChange={setName}
97
- onDurationChange={setDuration}
98
- onCompleteRegistration={() => {
99
- console.log("Registration complete!");
100
- }}
101
- />
102
- );
103
- }
104
- ```
105
-
106
- #### Component Flow
107
-
108
- The component has 4 main steps:
109
-
110
- 1. **NameSearch** - User searches for an available ENS name
111
- 2. **RegistrationForm** - User reviews details and sets registration duration
112
- 3. **RegistrationProcess** - Transaction processing with multiple steps
113
- 4. **SuccessScreen** - Registration completion confirmation
114
-
115
- #### Props
116
-
117
- | Prop | Type | Required | Default | Description |
118
- |------|------|----------|---------|-------------|
119
- | `name` | `string` | No | `"brightwave"` | Initial ENS name (without .eth suffix) |
120
- | `duration` | `number` | No | `1` | Registration duration in years |
121
- | `onNameChange` | `(name: string) => void` | No | - | Callback when name changes |
122
- | `onDurationChange` | `(duration: number) => void` | No | - | Callback when duration changes |
123
- | `onBack` | `() => void` | No | - | Callback when back button is clicked |
124
- | `onClose` | `() => void` | No | - | Callback when close button is clicked |
125
- | `onNext` | `() => void` | No | - | Callback when next button is clicked |
126
- | `onCompleteProfile` | `() => void` | No | - | Callback when "Complete Profile" is clicked |
127
- | `onOpenWallet` | `() => void` | No | - | Callback when wallet needs to be opened |
128
- | `onCompleteRegistration` | `() => void` | No | - | Callback when registration completes |
129
- | `onRegisterAnother` | `() => void` | No | - | Callback when "Register Another" is clicked |
130
- | `onViewName` | `() => void` | No | - | Callback when "View Name" is clicked |
131
-
132
- #### Complete Example
133
-
134
- ```tsx
135
- import { useState } from "react";
136
- import { ENSNamesRegistrarComponent } from "@thenamespace/ens-components";
137
-
138
- function ENSRegistrationExample() {
139
- const [name, setName] = useState("");
140
- const [duration, setDuration] = useState(1);
141
- const [registeredNames, setRegisteredNames] = useState<string[]>([]);
142
-
143
- const handleCompleteRegistration = () => {
144
- if (name) {
145
- setRegisteredNames([...registeredNames, name]);
146
- alert(`Successfully registered ${name}.eth!`);
147
- }
148
- };
149
-
150
- return (
151
- <div>
152
- <ENSNamesRegistrarComponent
153
- name={name}
154
- duration={duration}
155
- onNameChange={setName}
156
- onDurationChange={setDuration}
157
- onBack={() => console.log("Back clicked")}
158
- onClose={() => console.log("Close clicked")}
159
- onNext={() => console.log("Next clicked")}
160
- onCompleteProfile={() => {
161
- console.log("Complete profile clicked");
162
- // Navigate to profile completion page
163
- }}
164
- onOpenWallet={() => console.log("Open wallet clicked")}
165
- onCompleteRegistration={handleCompleteRegistration}
166
- onRegisterAnother={() => {
167
- setName("");
168
- setDuration(1);
169
- }}
170
- onViewName={() => {
171
- if (name) {
172
- window.open(`https://app.ens.domains/${name}`, "_blank");
173
- }
174
- }}
175
- />
176
-
177
- {registeredNames.length > 0 && (
178
- <div>
179
- <h3>Registered Names:</h3>
180
- <ul>
181
- {registeredNames.map((n) => (
182
- <li key={n}>{n}.eth</li>
183
- ))}
184
- </ul>
185
- </div>
186
- )}
187
- </div>
188
- );
189
- }
190
- ```
191
-
192
- ---
193
-
194
- ### SubnameOnChainRegistrarModal
195
-
196
- Component for registering on-chain subnames (e.g., `mysubname.mydomain.eth`).
197
-
198
- #### Basic Usage
199
-
200
- ```tsx
201
- import { useState } from "react";
202
- import { SubnameOnChainRegistrarModal } from "@thenamespace/ens-components";
203
-
204
- function RegisterSubname() {
205
- const [step, setStep] = useState(0);
206
- const [name, setName] = useState("");
207
- const [parentName] = useState("mydomain.eth");
208
- const [profileComplete, setProfileComplete] = useState(false);
209
- const [owner, setOwner] = useState("");
210
- const [duration, setDuration] = useState(1);
211
- const [useAsPrimary, setUseAsPrimary] = useState(false);
212
-
213
- return (
214
- <SubnameOnChainRegistrarModal
215
- step={step}
216
- name={name}
217
- parentName={parentName}
218
- profileComplete={profileComplete}
219
- owner={owner}
220
- duration={duration}
221
- useAsPrimary={useAsPrimary}
222
- onStepChange={setStep}
223
- onNameChange={setName}
224
- onProfileCompleteChange={setProfileComplete}
225
- onOwnerChange={setOwner}
226
- onDurationChange={setDuration}
227
- onUseAsPrimaryChange={setUseAsPrimary}
228
- onCompleteRegistration={() => {
229
- setStep(2); // Move to success screen
230
- }}
231
- />
232
- );
233
- }
234
- ```
235
-
236
- #### Component Flow
237
-
238
- The component has 3 main steps:
239
-
240
- 1. **InitialStep** (step 0) - User enters subname label
241
- 2. **RegistrationStep** (step 1) - User reviews details and registers
242
- 3. **SuccessScreen** (step 2) - Registration completion confirmation
243
-
244
- #### Props
245
-
246
- | Prop | Type | Required | Default | Description |
247
- |------|------|----------|---------|-------------|
248
- | `step` | `number` | No | `0` | Current step (0: Initial, 1: Registration, 2: Success) |
249
- | `name` | `string` | No | `""` | Subname label (without parent domain) |
250
- | `parentName` | `string` | No | `"celotest.eth"` | Parent domain name |
251
- | `profileComplete` | `boolean` | No | `false` | Whether profile is complete |
252
- | `domainSuffix` | `string` | No | `"eth"` | Domain suffix |
253
- | `owner` | `string` | No | `"0x035eB...24117D3"` | Owner address for the subname |
254
- | `duration` | `number` | No | `1` | Registration duration in years |
255
- | `registrationFee` | `string` | No | - | Registration fee (optional) |
256
- | `networkFee` | `string` | No | - | Network fee (optional) |
257
- | `totalCost` | `string` | No | - | Total cost (optional) |
258
- | `useAsPrimary` | `boolean` | No | `false` | Whether to use as primary name |
259
- | `profileImageUrl` | `string` | No | - | Profile image URL (optional) |
260
- | `onStepChange` | `(step: number) => void` | No | - | Callback when step changes |
261
- | `onNameChange` | `(name: string) => void` | No | - | Callback when name changes |
262
- | `onProfileCompleteChange` | `(complete: boolean) => void` | No | - | Callback when profile complete status changes |
263
- | `onOwnerChange` | `(owner: string) => void` | No | - | Callback when owner changes |
264
- | `onDurationChange` | `(duration: number) => void` | No | - | Callback when duration changes |
265
- | `onUseAsPrimaryChange` | `(useAsPrimary: boolean) => void` | No | - | Callback when useAsPrimary changes |
266
- | `onRegister` | `() => void` | No | - | Callback when register button is clicked |
267
- | `onCancel` | `() => void` | No | - | Callback when cancel button is clicked |
268
- | `onClose` | `() => void` | No | - | Callback when close button is clicked |
269
- | `onCompleteProfile` | `() => void` | No | - | Callback when "Complete Profile" is clicked |
270
- | `onOpenWallet` | `() => void` | No | - | Callback when wallet needs to be opened |
271
- | `onCompleteRegistration` | `() => void` | No | - | Callback when registration completes |
272
- | `onRegisterAnother` | `() => void` | No | - | Callback when "Register Another" is clicked |
273
- | `onViewName` | `() => void` | No | - | Callback when "View Name" is clicked |
274
- | `onFinish` | `() => void` | No | - | Callback when finish button is clicked (success screen) |
275
-
276
- #### Complete Example
277
-
278
- ```tsx
279
- import { useState } from "react";
280
- import { SubnameOnChainRegistrarModal } from "@thenamespace/ens-components";
281
-
282
- function SubnameRegistrationExample() {
283
- const [isOpen, setIsOpen] = useState(false);
284
- const [step, setStep] = useState(0);
285
- const [name, setName] = useState("");
286
- const [parentName] = useState("mydomain.eth");
287
- const [profileComplete, setProfileComplete] = useState(false);
288
- const [owner, setOwner] = useState("");
289
- const [duration, setDuration] = useState(1);
290
- const [useAsPrimary, setUseAsPrimary] = useState(false);
291
- const [registeredSubnames, setRegisteredSubnames] = useState<string[]>([]);
292
-
293
- const handleCompleteRegistration = () => {
294
- const fullName = name ? `${name}.${parentName}` : "";
295
- if (fullName) {
296
- setRegisteredSubnames([...registeredSubnames, fullName]);
297
- setStep(2); // Move to success screen
298
- alert(`Successfully registered ${fullName}!`);
299
- }
300
- };
301
-
302
- const handleFinish = () => {
303
- setIsOpen(false);
304
- setStep(0);
305
- setName("");
306
- setProfileComplete(false);
307
- setDuration(1);
308
- setUseAsPrimary(false);
309
- };
310
-
311
- if (!isOpen) {
312
- return (
313
- <div>
314
- <button onClick={() => setIsOpen(true)}>
315
- Register Subname
316
- </button>
317
- {registeredSubnames.length > 0 && (
318
- <div>
319
- <h3>Registered Subnames:</h3>
320
- <ul>
321
- {registeredSubnames.map((n) => (
322
- <li key={n}>{n}</li>
323
- ))}
324
- </ul>
325
- </div>
326
- )}
327
- </div>
328
- );
329
- }
330
-
331
- return (
332
- <div style={{ position: "fixed", inset: 0, backgroundColor: "rgba(0, 0, 0, 0.5)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 1000 }}>
333
- <div style={{ backgroundColor: "white", borderRadius: "8px", padding: "20px", maxWidth: "600px", width: "90%", maxHeight: "90vh", overflow: "auto" }}>
334
- <SubnameOnChainRegistrarModal
335
- step={step}
336
- name={name}
337
- parentName={parentName}
338
- profileComplete={profileComplete}
339
- owner={owner}
340
- duration={duration}
341
- useAsPrimary={useAsPrimary}
342
- onStepChange={setStep}
343
- onNameChange={setName}
344
- onProfileCompleteChange={setProfileComplete}
345
- onOwnerChange={setOwner}
346
- onDurationChange={setDuration}
347
- onUseAsPrimaryChange={setUseAsPrimary}
348
- onRegister={() => console.log("Register clicked")}
349
- onCancel={() => {
350
- console.log("Cancel clicked");
351
- setStep(0);
352
- }}
353
- onClose={handleFinish}
354
- onCompleteProfile={() => {
355
- console.log("Complete profile clicked");
356
- setProfileComplete(true);
357
- }}
358
- onCompleteRegistration={handleCompleteRegistration}
359
- onFinish={handleFinish}
360
- />
361
- </div>
362
- </div>
363
- );
364
- }
365
- ```
366
-
367
- ## Full Example with Both Components
368
-
369
- ```tsx
370
- import React, { useState } from "react";
371
- import { WagmiProvider } from "wagmi";
372
- import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
373
- import { RainbowKitProvider, getDefaultConfig } from "@rainbow-me/rainbowkit";
374
- import { mainnet, sepolia } from "wagmi/chains";
375
- import { http } from "wagmi";
376
- import { ENSNamesRegistrarComponent, SubnameOnChainRegistrarModal } from "@thenamespace/ens-components";
377
- import "@thenamespace/ens-components/index.css";
378
- import "@rainbow-me/rainbowkit/styles.css";
379
-
380
- const wagmiConfig = getDefaultConfig({
381
- appName: "My ENS App",
382
- projectId: "YOUR_WALLETCONNECT_PROJECT_ID",
383
- chains: [mainnet, sepolia],
384
- transports: {
385
- [mainnet.id]: http(),
386
- [sepolia.id]: http(),
387
- },
388
- });
389
-
390
- const queryClient = new QueryClient();
391
-
392
- function AppProviders({ children }: { children: React.ReactNode }) {
393
- return (
394
- <WagmiProvider config={wagmiConfig}>
395
- <QueryClientProvider client={queryClient}>
396
- <RainbowKitProvider>
397
- {children}
398
- </RainbowKitProvider>
399
- </QueryClientProvider>
400
- </WagmiProvider>
401
- );
402
- }
403
-
404
- function App() {
405
- const [activeTab, setActiveTab] = useState<"ens" | "subname">("ens");
406
-
407
- // ENS Name Registration State
408
- const [ensName, setEnsName] = useState("");
409
- const [ensDuration, setEnsDuration] = useState(1);
410
-
411
- // Subname Registration State
412
- const [subnameStep, setSubnameStep] = useState(0);
413
- const [subname, setSubname] = useState("");
414
- const [parentName] = useState("mydomain.eth");
415
- const [profileComplete, setProfileComplete] = useState(false);
416
- const [owner, setOwner] = useState("");
417
- const [duration, setDuration] = useState(1);
418
- const [useAsPrimary, setUseAsPrimary] = useState(false);
419
-
420
- return (
421
- <AppProviders>
422
- <div style={{ padding: "20px" }}>
423
- <div style={{ marginBottom: "20px" }}>
424
- <button
425
- onClick={() => setActiveTab("ens")}
426
- style={{ marginRight: "10px", padding: "10px", backgroundColor: activeTab === "ens" ? "#007bff" : "#ccc", color: "white", border: "none", borderRadius: "4px", cursor: "pointer" }}
427
- >
428
- Register ENS Name
429
- </button>
430
- <button
431
- onClick={() => setActiveTab("subname")}
432
- style={{ padding: "10px", backgroundColor: activeTab === "subname" ? "#007bff" : "#ccc", color: "white", border: "none", borderRadius: "4px", cursor: "pointer" }}
433
- >
434
- Register Subname
435
- </button>
436
- </div>
437
-
438
- {activeTab === "ens" && (
439
- <div>
440
- <h2>Register ENS Name</h2>
441
- <ENSNamesRegistrarComponent
442
- name={ensName}
443
- duration={ensDuration}
444
- onNameChange={setEnsName}
445
- onDurationChange={setEnsDuration}
446
- onCompleteRegistration={() => {
447
- alert(`Successfully registered ${ensName}.eth!`);
448
- }}
449
- />
450
- </div>
451
- )}
452
-
453
- {activeTab === "subname" && (
454
- <div>
455
- <h2>Register On-Chain Subname</h2>
456
- <SubnameOnChainRegistrarModal
457
- step={subnameStep}
458
- name={subname}
459
- parentName={parentName}
460
- profileComplete={profileComplete}
461
- owner={owner}
462
- duration={duration}
463
- useAsPrimary={useAsPrimary}
464
- onStepChange={setSubnameStep}
465
- onNameChange={setSubname}
466
- onProfileCompleteChange={setProfileComplete}
467
- onOwnerChange={setOwner}
468
- onDurationChange={setDuration}
469
- onUseAsPrimaryChange={setUseAsPrimary}
470
- onCompleteRegistration={() => {
471
- setSubnameStep(2);
472
- alert(`Successfully registered ${subname}.${parentName}!`);
473
- }}
474
- onFinish={() => {
475
- setSubnameStep(0);
476
- setSubname("");
477
- }}
478
- />
479
- </div>
480
- )}
481
- </div>
482
- </AppProviders>
483
- );
484
- }
485
-
486
- export default App;
487
- ```
488
-
489
- ## Styling
490
-
491
- The components come with their own CSS. Make sure to import the styles:
492
-
493
- ```tsx
494
- import "@thenamespace/ens-components/index.css";
495
- import "@rainbow-me/rainbowkit/styles.css";
496
- ```
497
-
498
- ## Requirements
499
-
500
- - React 18+
501
- - Node.js 16+
502
- - A WalletConnect Project ID (get one at https://cloud.walletconnect.com)
503
-
504
- ## License
505
-
506
- ISC
507
-
508
- ## Support
509
-
510
- For issues and questions, please visit the package repository.
1
+ // TODO