@thenamespace/ens-components 0.38.0-alpha → 1.1.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 +200 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +86 -65
- package/dist/index.js.map +1 -1
- package/dist/types/components/ens-name-registration/ENSNameRegistrationForm.d.ts +2 -0
- package/dist/types/components/ens-name-registration/RegistrationSummary.d.ts +1 -0
- package/dist/types/components/ens-name-registration/SetNameRecords.d.ts +2 -0
- package/dist/types/components/subname-mint-form/MintFormActions.d.ts +3 -1
- package/dist/types/components/subname-mint-form/SubnameMintForm.d.ts +3 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# `@thenamespace/ens-components`
|
|
2
|
+
|
|
3
|
+
Production-ready React components for ENS name registration, record editing, and subname issuance.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@thenamespace/ens-components)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @thenamespace/ens-components
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @thenamespace/ens-components
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Peer dependencies (you likely already have these):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install react react-dom wagmi viem
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
### 1. Wrap your app with Web3 providers
|
|
24
|
+
|
|
25
|
+
The library reads wallet state from wagmi. Use your own wagmi setup or RainbowKit:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { getDefaultConfig, RainbowKitProvider } from "@rainbow-me/rainbowkit";
|
|
29
|
+
import { WagmiProvider } from "wagmi";
|
|
30
|
+
import { mainnet, sepolia } from "wagmi/chains";
|
|
31
|
+
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
|
|
32
|
+
import "@rainbow-me/rainbowkit/styles.css";
|
|
33
|
+
|
|
34
|
+
const config = getDefaultConfig({
|
|
35
|
+
appName: "My App",
|
|
36
|
+
projectId: "YOUR_WALLETCONNECT_PROJECT_ID",
|
|
37
|
+
chains: [mainnet, sepolia],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export function Providers({ children }: { children: React.ReactNode }) {
|
|
41
|
+
return (
|
|
42
|
+
<WagmiProvider config={config}>
|
|
43
|
+
<QueryClientProvider client={new QueryClient()}>
|
|
44
|
+
<RainbowKitProvider>{children}</RainbowKitProvider>
|
|
45
|
+
</QueryClientProvider>
|
|
46
|
+
</WagmiProvider>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Import styles
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import "@thenamespace/ens-components/styles";
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 3. Drop in a component
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { EnsNameRegistrationForm } from "@thenamespace/ens-components";
|
|
61
|
+
|
|
62
|
+
export default function App() {
|
|
63
|
+
return <EnsNameRegistrationForm isTestnet={false} />;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Components
|
|
70
|
+
|
|
71
|
+
### `EnsNameRegistrationForm`
|
|
72
|
+
|
|
73
|
+
Full `.eth` name registration flow: search → commit → wait → register.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<EnsNameRegistrationForm
|
|
77
|
+
isTestnet={false}
|
|
78
|
+
onNameRegistered={(name) => console.log("Registered:", name)}
|
|
79
|
+
/>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| Prop | Type | Description |
|
|
83
|
+
|------|------|-------------|
|
|
84
|
+
| `isTestnet` | `boolean` | Use Sepolia testnet contracts |
|
|
85
|
+
| `onNameRegistered` | `(name: string) => void` | Callback after successful registration |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### `EnsRecordsForm`
|
|
90
|
+
|
|
91
|
+
Edit all resolver records for an ENS name — addresses, text records, contenthash, avatar, and header image.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<EnsRecordsForm
|
|
95
|
+
name="alice.eth"
|
|
96
|
+
existingRecords={{ texts: [], addresses: [] }}
|
|
97
|
+
isTestnet={false}
|
|
98
|
+
onRecordsSaved={(records) => console.log(records)}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
| Prop | Type | Description |
|
|
103
|
+
|------|------|-------------|
|
|
104
|
+
| `name` | `string` | The ENS name to edit |
|
|
105
|
+
| `existingRecords` | `EnsRecords` | Current on-chain records to pre-populate |
|
|
106
|
+
| `isTestnet` | `boolean` | Use Sepolia testnet contracts |
|
|
107
|
+
| `onRecordsSaved` | `(records: EnsRecords) => void` | Callback after records are saved |
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### `SubnameMintForm`
|
|
112
|
+
|
|
113
|
+
Mint an onchain subname from a Namespace listing.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
<SubnameMintForm
|
|
117
|
+
parentName="alice.eth"
|
|
118
|
+
isTestnet={false}
|
|
119
|
+
onSubnameMinted={(subname) => console.log("Minted:", subname)}
|
|
120
|
+
/>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
| Prop | Type | Description |
|
|
124
|
+
|------|------|-------------|
|
|
125
|
+
| `parentName` | `string` | Parent ENS name with an active listing |
|
|
126
|
+
| `isTestnet` | `boolean` | Use Sepolia testnet contracts |
|
|
127
|
+
| `onSubnameMinted` | `(subname: string) => void` | Callback after mint |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### `OffchainSubnameForm`
|
|
132
|
+
|
|
133
|
+
Create or update an offchain subname through the Namespace API.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<OffchainSubnameForm
|
|
137
|
+
name="alice.eth"
|
|
138
|
+
apiKeyOrToken="YOUR_NAMESPACE_API_KEY"
|
|
139
|
+
isTestnet={false}
|
|
140
|
+
onSubnameSaved={(subname) => console.log("Saved:", subname)}
|
|
141
|
+
/>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
| Prop | Type | Description |
|
|
145
|
+
|------|------|-------------|
|
|
146
|
+
| `name` | `string` | Parent ENS name |
|
|
147
|
+
| `apiKeyOrToken` | `string` | Namespace API key or SIWE token |
|
|
148
|
+
| `isTestnet` | `boolean` | Use Sepolia testnet contracts |
|
|
149
|
+
| `onSubnameSaved` | `(subname: string) => void` | Callback after save |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Hooks
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import {
|
|
157
|
+
useRegisterENS,
|
|
158
|
+
useENSResolver,
|
|
159
|
+
useMintSubname,
|
|
160
|
+
useOffchainManager,
|
|
161
|
+
useWaitTransaction,
|
|
162
|
+
useAvatarClient,
|
|
163
|
+
} from "@thenamespace/ens-components";
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Types
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import type {
|
|
170
|
+
EnsRecords,
|
|
171
|
+
EnsTextRecord,
|
|
172
|
+
EnsAddressRecord,
|
|
173
|
+
EnsContenthashRecord,
|
|
174
|
+
} from "@thenamespace/ens-components";
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Theming
|
|
180
|
+
|
|
181
|
+
Components use CSS variables that can be overridden:
|
|
182
|
+
|
|
183
|
+
```css
|
|
184
|
+
:root {
|
|
185
|
+
--ns-color-primary: #5A4BFF;
|
|
186
|
+
--ns-color-bg: #ffffff;
|
|
187
|
+
--ns-color-fg: #111111;
|
|
188
|
+
--ns-radius-md: 12px;
|
|
189
|
+
--ns-font-family: "DM Sans", sans-serif;
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Links
|
|
196
|
+
|
|
197
|
+
- [Namespace](https://namespace.ninja) — subname issuance platform
|
|
198
|
+
- [ENS](https://ens.domains) — Ethereum Name Service
|
|
199
|
+
- [Source](https://github.com/thenamespace/ui-components)
|
|
200
|
+
- [npm](https://www.npmjs.com/package/@thenamespace/ens-components)
|