zcashname-sdk 0.6.0 → 0.7.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/README.md +19 -4
- package/dist/zns.cjs +25 -8
- package/dist/zns.d.cts +10 -3
- package/dist/zns.d.ts +10 -3
- package/dist/zns.js +25 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -72,21 +72,36 @@ console.log("Memo:", memo);
|
|
|
72
72
|
## Reading Data
|
|
73
73
|
|
|
74
74
|
```ts
|
|
75
|
-
// Resolve name → address
|
|
75
|
+
// Resolve name → address (single lookup)
|
|
76
76
|
const reg = await zns.resolveName("alice");
|
|
77
77
|
|
|
78
|
-
// Resolve address → names (reverse lookup)
|
|
78
|
+
// Resolve address → names (reverse lookup) - supports pagination
|
|
79
79
|
const names = await zns.resolveAddress("u1qqlzrf9...");
|
|
80
80
|
|
|
81
|
+
// Paginated address lookup (get next 50 names starting from position 50)
|
|
82
|
+
const namesPage2 = await zns.resolveAddress("u1qqlzrf9...", 50, 50);
|
|
83
|
+
|
|
84
|
+
// List all registered names (paginated) - useful for explorers
|
|
85
|
+
const allNames = await zns.listAllRegistrations();
|
|
86
|
+
|
|
87
|
+
// Paginated list (first 100 registrations)
|
|
88
|
+
const first100 = await zns.listAllRegistrations(100, 0);
|
|
89
|
+
|
|
81
90
|
// Check availability
|
|
82
91
|
const available = await zns.isAvailable("bob");
|
|
83
92
|
|
|
84
|
-
// Get
|
|
93
|
+
// Get marketplace listings - supports pagination
|
|
85
94
|
const listings = await zns.listings();
|
|
86
95
|
|
|
87
|
-
//
|
|
96
|
+
// Paginated listings (get 50 listings starting from position 100)
|
|
97
|
+
const listingsPage3 = await zns.listings(50, 100);
|
|
98
|
+
|
|
99
|
+
// Query events with pagination
|
|
88
100
|
const { events, total } = await zns.events({ action: "CLAIM", limit: 10 });
|
|
89
101
|
|
|
102
|
+
// Next page of events
|
|
103
|
+
const nextPage = await zns.events({ action: "CLAIM", limit: 10, offset: 10 });
|
|
104
|
+
|
|
90
105
|
// Get current pricing from status
|
|
91
106
|
const status = await zns.status();
|
|
92
107
|
const cost = zns.claimCost(5, status.pricing); // cost for 5-char name
|
package/dist/zns.cjs
CHANGED
|
@@ -43,8 +43,8 @@ var TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta
|
|
|
43
43
|
var MAINNET_UIVK = "uivk1gl26qy0xjja7lqhyg3pf0x4j4j66kqwewrjkdcg28eqq4wgtzjmujpee7x9cs2ec9xhnlgrm8ptlw8z80j2aryw8nqtssser2ys778a0s00uvgkdjnfr58sndhfvc3f4zqjs6ywva6";
|
|
44
44
|
var KNOWN_UIVKS = [TESTNET_UIVK, MAINNET_UIVK];
|
|
45
45
|
var REGISTRY_ADDRESSES = {
|
|
46
|
-
testnet: "
|
|
47
|
-
mainnet: "
|
|
46
|
+
testnet: "utest1f32kn6c4zvn54xr8wfsnxmj9hzpu2mwgtxzpzwcw34906tdccdvzs0z2dx38lly7tpan77x6udt8pjczqm22ymsdhlz9j0tk5yq664nl",
|
|
47
|
+
mainnet: "u1k0evt0ahj5qdt6y9ftsxndl8lrkm4ff6rp00u04cjpmqj6hxl9t8hfsxftmn3ht34e03lljh89czn2h8qn67rwrs8x0hm3lsxsucp9q9"
|
|
48
48
|
};
|
|
49
49
|
var NAME_RE = /^[a-z0-9]{1,62}$/;
|
|
50
50
|
var ZNS = class {
|
|
@@ -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(
|
package/dist/zns.d.cts
CHANGED
|
@@ -150,8 +150,12 @@ declare class ZNS {
|
|
|
150
150
|
status(): Promise<Status>;
|
|
151
151
|
/** Resolve a ZNS name to its registration. Returns null if not registered. */
|
|
152
152
|
resolveName(name: string): Promise<Registration | null>;
|
|
153
|
-
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
154
|
-
|
|
153
|
+
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
154
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
155
|
+
resolveAddress(address: string, limit?: number, offset?: number): Promise<Registration[]>;
|
|
156
|
+
/** List all registered names. Useful for explorers or browsers.
|
|
157
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
158
|
+
listAllRegistrations(limit?: number, offset?: number): Promise<Registration[]>;
|
|
155
159
|
/** Check if a name is available for registration.
|
|
156
160
|
* Returns false immediately for invalid names without hitting the server. */
|
|
157
161
|
isAvailable(name: string): Promise<boolean>;
|
|
@@ -160,7 +164,10 @@ declare class ZNS {
|
|
|
160
164
|
* Performs basic format validation but NOT full bech32m checksum verification.
|
|
161
165
|
* Returns true if the address looks like a unified address, false otherwise. */
|
|
162
166
|
isValidUnifiedAddress(address: string): boolean;
|
|
163
|
-
listings(): Promise<
|
|
167
|
+
listings(limit?: number, offset?: number): Promise<{
|
|
168
|
+
listings: Listing[];
|
|
169
|
+
total: number;
|
|
170
|
+
}>;
|
|
164
171
|
events(filter?: EventsFilter): Promise<EventsResult>;
|
|
165
172
|
/**
|
|
166
173
|
* Verify a listing's signature.
|
package/dist/zns.d.ts
CHANGED
|
@@ -150,8 +150,12 @@ declare class ZNS {
|
|
|
150
150
|
status(): Promise<Status>;
|
|
151
151
|
/** Resolve a ZNS name to its registration. Returns null if not registered. */
|
|
152
152
|
resolveName(name: string): Promise<Registration | null>;
|
|
153
|
-
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
154
|
-
|
|
153
|
+
/** Resolve a Zcash Unified Address to all names pointing to it. Returns empty array if none.
|
|
154
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
155
|
+
resolveAddress(address: string, limit?: number, offset?: number): Promise<Registration[]>;
|
|
156
|
+
/** List all registered names. Useful for explorers or browsers.
|
|
157
|
+
* Supports pagination with limit (default 50, max 500) and offset (default 0). */
|
|
158
|
+
listAllRegistrations(limit?: number, offset?: number): Promise<Registration[]>;
|
|
155
159
|
/** Check if a name is available for registration.
|
|
156
160
|
* Returns false immediately for invalid names without hitting the server. */
|
|
157
161
|
isAvailable(name: string): Promise<boolean>;
|
|
@@ -160,7 +164,10 @@ declare class ZNS {
|
|
|
160
164
|
* Performs basic format validation but NOT full bech32m checksum verification.
|
|
161
165
|
* Returns true if the address looks like a unified address, false otherwise. */
|
|
162
166
|
isValidUnifiedAddress(address: string): boolean;
|
|
163
|
-
listings(): Promise<
|
|
167
|
+
listings(limit?: number, offset?: number): Promise<{
|
|
168
|
+
listings: Listing[];
|
|
169
|
+
total: number;
|
|
170
|
+
}>;
|
|
164
171
|
events(filter?: EventsFilter): Promise<EventsResult>;
|
|
165
172
|
/**
|
|
166
173
|
* Verify a listing's signature.
|
package/dist/zns.js
CHANGED
|
@@ -6,8 +6,8 @@ var TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta
|
|
|
6
6
|
var MAINNET_UIVK = "uivk1gl26qy0xjja7lqhyg3pf0x4j4j66kqwewrjkdcg28eqq4wgtzjmujpee7x9cs2ec9xhnlgrm8ptlw8z80j2aryw8nqtssser2ys778a0s00uvgkdjnfr58sndhfvc3f4zqjs6ywva6";
|
|
7
7
|
var KNOWN_UIVKS = [TESTNET_UIVK, MAINNET_UIVK];
|
|
8
8
|
var REGISTRY_ADDRESSES = {
|
|
9
|
-
testnet: "
|
|
10
|
-
mainnet: "
|
|
9
|
+
testnet: "utest1f32kn6c4zvn54xr8wfsnxmj9hzpu2mwgtxzpzwcw34906tdccdvzs0z2dx38lly7tpan77x6udt8pjczqm22ymsdhlz9j0tk5yq664nl",
|
|
10
|
+
mainnet: "u1k0evt0ahj5qdt6y9ftsxndl8lrkm4ff6rp00u04cjpmqj6hxl9t8hfsxftmn3ht34e03lljh89czn2h8qn67rwrs8x0hm3lsxsucp9q9"
|
|
11
11
|
};
|
|
12
12
|
var NAME_RE = /^[a-z0-9]{1,62}$/;
|
|
13
13
|
var ZNS = class {
|
|
@@ -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(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcashname-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TypeScript SDK for the Zcash Name System (ZNS)",
|
|
6
6
|
"main": "dist/zns.cjs",
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"typescript": "^5.4.0",
|
|
38
38
|
"vitest": "^2.0.0"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|