zcashname-sdk 0.6.1 → 0.7.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 +19 -5
- package/dist/zns.cjs +23 -17
- package/dist/zns.d.cts +11 -10
- package/dist/zns.d.ts +11 -10
- package/dist/zns.js +23 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,26 +67,40 @@ console.log("Memo:", memo);
|
|
|
67
67
|
| `prepareUpdate(name, newAddress, nonce, registryAddress)` | Change address |
|
|
68
68
|
| `prepareBuy(name, buyerAddress, registryAddress)` | Buy a listed name |
|
|
69
69
|
| `prepareRelease(name, nonce, registryAddress)` | Release name (burn) |
|
|
70
|
-
| `prepareSetPrice(prices, nonce, registryAddress)` | Admin: set pricing tiers |
|
|
71
70
|
|
|
72
71
|
## Reading Data
|
|
73
72
|
|
|
74
73
|
```ts
|
|
75
|
-
// Resolve name → address
|
|
74
|
+
// Resolve name → address (single lookup)
|
|
76
75
|
const reg = await zns.resolveName("alice");
|
|
77
76
|
|
|
78
|
-
// Resolve address → names (reverse lookup)
|
|
77
|
+
// Resolve address → names (reverse lookup) - supports pagination
|
|
79
78
|
const names = await zns.resolveAddress("u1qqlzrf9...");
|
|
80
79
|
|
|
80
|
+
// Paginated address lookup (get next 50 names starting from position 50)
|
|
81
|
+
const namesPage2 = await zns.resolveAddress("u1qqlzrf9...", 50, 50);
|
|
82
|
+
|
|
83
|
+
// List all registered names (paginated) - useful for explorers
|
|
84
|
+
const allNames = await zns.listAllRegistrations();
|
|
85
|
+
|
|
86
|
+
// Paginated list (first 100 registrations)
|
|
87
|
+
const first100 = await zns.listAllRegistrations(100, 0);
|
|
88
|
+
|
|
81
89
|
// Check availability
|
|
82
90
|
const available = await zns.isAvailable("bob");
|
|
83
91
|
|
|
84
|
-
// Get
|
|
92
|
+
// Get marketplace listings - supports pagination
|
|
85
93
|
const listings = await zns.listings();
|
|
86
94
|
|
|
87
|
-
//
|
|
95
|
+
// Paginated listings (get 50 listings starting from position 100)
|
|
96
|
+
const listingsPage3 = await zns.listings(50, 100);
|
|
97
|
+
|
|
98
|
+
// Query events with pagination
|
|
88
99
|
const { events, total } = await zns.events({ action: "CLAIM", limit: 10 });
|
|
89
100
|
|
|
101
|
+
// Next page of events
|
|
102
|
+
const nextPage = await zns.events({ action: "CLAIM", limit: 10, offset: 10 });
|
|
103
|
+
|
|
90
104
|
// Get current pricing from status
|
|
91
105
|
const status = await zns.status();
|
|
92
106
|
const cost = zns.claimCost(5, status.pricing); // cost for 5-char name
|
package/dist/zns.cjs
CHANGED
|
@@ -93,9 +93,23 @@ var ZNS = class {
|
|
|
93
93
|
async resolveName(name) {
|
|
94
94
|
return this.rpc("resolve", { query: name });
|
|
95
95
|
}
|
|
96
|
-
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
97
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
98
|
+
async resolveAddress(address, limit, offset) {
|
|
99
|
+
return this.rpc("resolve", {
|
|
100
|
+
query: address,
|
|
101
|
+
limit,
|
|
102
|
+
offset
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** List all registered names. Useful for explorers or browsers.
|
|
106
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
107
|
+
async listAllRegistrations(limit, offset) {
|
|
108
|
+
return this.rpc("resolve", {
|
|
109
|
+
query: "",
|
|
110
|
+
limit,
|
|
111
|
+
offset
|
|
112
|
+
});
|
|
99
113
|
}
|
|
100
114
|
/** Check if a name is available for registration.
|
|
101
115
|
* Returns false immediately for invalid names without hitting the server. */
|
|
@@ -119,9 +133,12 @@ var ZNS = class {
|
|
|
119
133
|
return false;
|
|
120
134
|
}
|
|
121
135
|
}
|
|
122
|
-
async listings() {
|
|
123
|
-
const result = await this.rpc("
|
|
124
|
-
|
|
136
|
+
async listings(limit, offset) {
|
|
137
|
+
const result = await this.rpc("listings", {
|
|
138
|
+
limit,
|
|
139
|
+
offset
|
|
140
|
+
});
|
|
141
|
+
return result;
|
|
125
142
|
}
|
|
126
143
|
async events(filter) {
|
|
127
144
|
return this.rpc(
|
|
@@ -272,17 +289,6 @@ var ZNS = class {
|
|
|
272
289
|
}
|
|
273
290
|
};
|
|
274
291
|
}
|
|
275
|
-
prepareSetPrice(prices, nonce) {
|
|
276
|
-
return {
|
|
277
|
-
prices,
|
|
278
|
-
nonce,
|
|
279
|
-
payload: `SETPRICE:${prices.length}:${prices.join(":")}:${nonce}`,
|
|
280
|
-
complete: (signature) => {
|
|
281
|
-
const memo = `ZNS:SETPRICE:${prices.length}:${prices.join(":")}:${nonce}:${signature}`;
|
|
282
|
-
return { memo, uri: this.buildZcashUri(this.registryAddress, void 0, memo) };
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
292
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
287
293
|
registrationPayload(reg) {
|
|
288
294
|
switch (reg.last_action) {
|
package/dist/zns.d.cts
CHANGED
|
@@ -112,11 +112,6 @@ interface PreparedRelease extends PreparedAction {
|
|
|
112
112
|
readonly name: string;
|
|
113
113
|
readonly nonce: number;
|
|
114
114
|
}
|
|
115
|
-
/** Prepared SETPRICE action (admin only) */
|
|
116
|
-
interface PreparedSetPrice extends PreparedAction {
|
|
117
|
-
readonly prices: readonly Zats[];
|
|
118
|
-
readonly nonce: number;
|
|
119
|
-
}
|
|
120
115
|
|
|
121
116
|
declare const DEFAULT_URL = "https://light.zcash.me/zns-testnet";
|
|
122
117
|
declare const TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta00cx4068wnlzcv7tx9n3t3gfhsy83pe4y6jrhxtzaq0hj6xtg5zrk2dn7zen3vns2a5pgs4fxdjlletmqrhfa42";
|
|
@@ -150,8 +145,12 @@ declare class ZNS {
|
|
|
150
145
|
status(): Promise<Status>;
|
|
151
146
|
/** Resolve a ZNS name to its registration. Returns null if not registered. */
|
|
152
147
|
resolveName(name: string): Promise<Registration | null>;
|
|
153
|
-
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
154
|
-
|
|
148
|
+
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
149
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
150
|
+
resolveAddress(address: string, limit?: number, offset?: number): Promise<Registration[]>;
|
|
151
|
+
/** List all registered names. Useful for explorers or browsers.
|
|
152
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
153
|
+
listAllRegistrations(limit?: number, offset?: number): Promise<Registration[]>;
|
|
155
154
|
/** Check if a name is available for registration.
|
|
156
155
|
* Returns false immediately for invalid names without hitting the server. */
|
|
157
156
|
isAvailable(name: string): Promise<boolean>;
|
|
@@ -160,7 +159,10 @@ declare class ZNS {
|
|
|
160
159
|
* Performs basic format validation but NOT full bech32m checksum verification.
|
|
161
160
|
* Returns true if the address looks like a unified address, false otherwise. */
|
|
162
161
|
isValidUnifiedAddress(address: string): boolean;
|
|
163
|
-
listings(): Promise<
|
|
162
|
+
listings(limit?: number, offset?: number): Promise<{
|
|
163
|
+
listings: Listing[];
|
|
164
|
+
total: number;
|
|
165
|
+
}>;
|
|
164
166
|
events(filter?: EventsFilter): Promise<EventsResult>;
|
|
165
167
|
/**
|
|
166
168
|
* Verify a listing's signature.
|
|
@@ -205,7 +207,6 @@ declare class ZNS {
|
|
|
205
207
|
prepareUpdate(name: string, newAddress: string, nonce: number): PreparedUpdate;
|
|
206
208
|
prepareBuy(name: string, buyerAddress: string): PreparedBuy;
|
|
207
209
|
prepareRelease(name: string, nonce: number): PreparedRelease;
|
|
208
|
-
prepareSetPrice(prices: Zats[], nonce: number): PreparedSetPrice;
|
|
209
210
|
private registrationPayload;
|
|
210
211
|
private verifyEd25519;
|
|
211
212
|
private requireValidName;
|
|
@@ -217,4 +218,4 @@ declare class ZNS {
|
|
|
217
218
|
private rpc;
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
export { type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, type LastAction, type Listing, MAINNET_UIVK, type Network, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type
|
|
221
|
+
export { type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, type LastAction, type Listing, MAINNET_UIVK, type Network, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, type Zats };
|
package/dist/zns.d.ts
CHANGED
|
@@ -112,11 +112,6 @@ interface PreparedRelease extends PreparedAction {
|
|
|
112
112
|
readonly name: string;
|
|
113
113
|
readonly nonce: number;
|
|
114
114
|
}
|
|
115
|
-
/** Prepared SETPRICE action (admin only) */
|
|
116
|
-
interface PreparedSetPrice extends PreparedAction {
|
|
117
|
-
readonly prices: readonly Zats[];
|
|
118
|
-
readonly nonce: number;
|
|
119
|
-
}
|
|
120
115
|
|
|
121
116
|
declare const DEFAULT_URL = "https://light.zcash.me/zns-testnet";
|
|
122
117
|
declare const TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta00cx4068wnlzcv7tx9n3t3gfhsy83pe4y6jrhxtzaq0hj6xtg5zrk2dn7zen3vns2a5pgs4fxdjlletmqrhfa42";
|
|
@@ -150,8 +145,12 @@ declare class ZNS {
|
|
|
150
145
|
status(): Promise<Status>;
|
|
151
146
|
/** Resolve a ZNS name to its registration. Returns null if not registered. */
|
|
152
147
|
resolveName(name: string): Promise<Registration | null>;
|
|
153
|
-
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
154
|
-
|
|
148
|
+
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
149
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
150
|
+
resolveAddress(address: string, limit?: number, offset?: number): Promise<Registration[]>;
|
|
151
|
+
/** List all registered names. Useful for explorers or browsers.
|
|
152
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
153
|
+
listAllRegistrations(limit?: number, offset?: number): Promise<Registration[]>;
|
|
155
154
|
/** Check if a name is available for registration.
|
|
156
155
|
* Returns false immediately for invalid names without hitting the server. */
|
|
157
156
|
isAvailable(name: string): Promise<boolean>;
|
|
@@ -160,7 +159,10 @@ declare class ZNS {
|
|
|
160
159
|
* Performs basic format validation but NOT full bech32m checksum verification.
|
|
161
160
|
* Returns true if the address looks like a unified address, false otherwise. */
|
|
162
161
|
isValidUnifiedAddress(address: string): boolean;
|
|
163
|
-
listings(): Promise<
|
|
162
|
+
listings(limit?: number, offset?: number): Promise<{
|
|
163
|
+
listings: Listing[];
|
|
164
|
+
total: number;
|
|
165
|
+
}>;
|
|
164
166
|
events(filter?: EventsFilter): Promise<EventsResult>;
|
|
165
167
|
/**
|
|
166
168
|
* Verify a listing's signature.
|
|
@@ -205,7 +207,6 @@ declare class ZNS {
|
|
|
205
207
|
prepareUpdate(name: string, newAddress: string, nonce: number): PreparedUpdate;
|
|
206
208
|
prepareBuy(name: string, buyerAddress: string): PreparedBuy;
|
|
207
209
|
prepareRelease(name: string, nonce: number): PreparedRelease;
|
|
208
|
-
prepareSetPrice(prices: Zats[], nonce: number): PreparedSetPrice;
|
|
209
210
|
private registrationPayload;
|
|
210
211
|
private verifyEd25519;
|
|
211
212
|
private requireValidName;
|
|
@@ -217,4 +218,4 @@ declare class ZNS {
|
|
|
217
218
|
private rpc;
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
export { type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, type LastAction, type Listing, MAINNET_UIVK, type Network, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type
|
|
221
|
+
export { type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, type LastAction, type Listing, MAINNET_UIVK, type Network, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, type Zats };
|
package/dist/zns.js
CHANGED
|
@@ -56,9 +56,23 @@ var ZNS = class {
|
|
|
56
56
|
async resolveName(name) {
|
|
57
57
|
return this.rpc("resolve", { query: name });
|
|
58
58
|
}
|
|
59
|
-
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
60
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
61
|
+
async resolveAddress(address, limit, offset) {
|
|
62
|
+
return this.rpc("resolve", {
|
|
63
|
+
query: address,
|
|
64
|
+
limit,
|
|
65
|
+
offset
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** List all registered names. Useful for explorers or browsers.
|
|
69
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
70
|
+
async listAllRegistrations(limit, offset) {
|
|
71
|
+
return this.rpc("resolve", {
|
|
72
|
+
query: "",
|
|
73
|
+
limit,
|
|
74
|
+
offset
|
|
75
|
+
});
|
|
62
76
|
}
|
|
63
77
|
/** Check if a name is available for registration.
|
|
64
78
|
* Returns false immediately for invalid names without hitting the server. */
|
|
@@ -82,9 +96,12 @@ var ZNS = class {
|
|
|
82
96
|
return false;
|
|
83
97
|
}
|
|
84
98
|
}
|
|
85
|
-
async listings() {
|
|
86
|
-
const result = await this.rpc("
|
|
87
|
-
|
|
99
|
+
async listings(limit, offset) {
|
|
100
|
+
const result = await this.rpc("listings", {
|
|
101
|
+
limit,
|
|
102
|
+
offset
|
|
103
|
+
});
|
|
104
|
+
return result;
|
|
88
105
|
}
|
|
89
106
|
async events(filter) {
|
|
90
107
|
return this.rpc(
|
|
@@ -235,17 +252,6 @@ var ZNS = class {
|
|
|
235
252
|
}
|
|
236
253
|
};
|
|
237
254
|
}
|
|
238
|
-
prepareSetPrice(prices, nonce) {
|
|
239
|
-
return {
|
|
240
|
-
prices,
|
|
241
|
-
nonce,
|
|
242
|
-
payload: `SETPRICE:${prices.length}:${prices.join(":")}:${nonce}`,
|
|
243
|
-
complete: (signature) => {
|
|
244
|
-
const memo = `ZNS:SETPRICE:${prices.length}:${prices.join(":")}:${nonce}:${signature}`;
|
|
245
|
-
return { memo, uri: this.buildZcashUri(this.registryAddress, void 0, memo) };
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
255
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
250
256
|
registrationPayload(reg) {
|
|
251
257
|
switch (reg.last_action) {
|