zcashname-sdk 0.8.2 → 0.8.3
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/zns.cjs +6 -20
- package/dist/zns.d.cts +4 -1
- package/dist/zns.d.ts +4 -1
- package/dist/zns.js +4 -19
- package/package.json +1 -1
package/dist/zns.cjs
CHANGED
|
@@ -35,7 +35,8 @@ __export(zns_exports, {
|
|
|
35
35
|
LIST_COMMISSION: () => LIST_COMMISSION,
|
|
36
36
|
MAINNET_UIVK: () => MAINNET_UIVK,
|
|
37
37
|
TESTNET_UIVK: () => TESTNET_UIVK,
|
|
38
|
-
ZNS: () => ZNS
|
|
38
|
+
ZNS: () => ZNS,
|
|
39
|
+
ZNS_ACTIONS: () => ZNS_ACTIONS
|
|
39
40
|
});
|
|
40
41
|
module.exports = __toCommonJS(zns_exports);
|
|
41
42
|
var ed25519 = __toESM(require("@noble/ed25519"), 1);
|
|
@@ -54,6 +55,7 @@ var REGISTRY_ADDRESSES = {
|
|
|
54
55
|
testnet: "utest1f32kn6c4zvn54xr8wfsnxmj9hzpu2mwgtxzpzwcw34906tdccdvzs0z2dx38lly7tpan77x6udt8pjczqm22ymsdhlz9j0tk5yq664nl",
|
|
55
56
|
mainnet: "u1k0evt0ahj5qdt6y9ftsxndl8lrkm4ff6rp00u04cjpmqj6hxl9t8hfsxftmn3ht34e03lljh89czn2h8qn67rwrs8x0hm3lsxsucp9q9"
|
|
56
57
|
};
|
|
58
|
+
var ZNS_ACTIONS = ["CLAIM", "BUY", "UPDATE", "LIST", "DELIST", "RELEASE"];
|
|
57
59
|
var NAME_RE = /^[a-z0-9]{1,62}$/;
|
|
58
60
|
function isWholeNumber(value) {
|
|
59
61
|
return /^\d+$/.test(value) && !value.startsWith("0") || value === "0";
|
|
@@ -292,29 +294,12 @@ var ZNS = class {
|
|
|
292
294
|
return mk("invalid", actionUpper, "release", `Nonce must be a whole number.`);
|
|
293
295
|
return mk("valid", actionUpper, "release", "Valid RELEASE payload.");
|
|
294
296
|
}
|
|
295
|
-
case "setprice": {
|
|
296
|
-
if (parts.length < 3)
|
|
297
|
-
return mk("invalid", actionUpper, "setprice", `Expected SETPRICE:<count>:<tier1>:...:<nonce>.`);
|
|
298
|
-
const count = Number(parts[0]);
|
|
299
|
-
if (!isWholeNumber(parts[0]) || isNaN(count) || count <= 0)
|
|
300
|
-
return mk("invalid", actionUpper, "setprice", `Count must be a positive whole number.`);
|
|
301
|
-
const priceCount = parts.length - 2;
|
|
302
|
-
if (priceCount !== count)
|
|
303
|
-
return mk("invalid", actionUpper, "setprice", `SETPRICE count mismatch: header is ${count} but found ${priceCount} price tiers.`);
|
|
304
|
-
if (!isWholeNumber(parts[parts.length - 1]))
|
|
305
|
-
return mk("invalid", actionUpper, "setprice", `Nonce must be a whole number.`);
|
|
306
|
-
for (let i = 1; i < parts.length - 1; i++) {
|
|
307
|
-
if (!isWholeNumber(parts[i]) || Number(parts[i]) <= 0)
|
|
308
|
-
return mk("invalid", actionUpper, "setprice", `Tier ${i} must be a positive whole number in zats.`);
|
|
309
|
-
}
|
|
310
|
-
return mk("valid", actionUpper, "setprice", "Valid SETPRICE payload.");
|
|
311
|
-
}
|
|
312
297
|
default:
|
|
313
298
|
return {
|
|
314
299
|
valid: false,
|
|
315
300
|
action: actionUpper,
|
|
316
301
|
canonicalAction: null,
|
|
317
|
-
message: `Unrecognized action "${actionUpper}". Valid actions:
|
|
302
|
+
message: `Unrecognized action "${actionUpper}". Valid actions: ${ZNS_ACTIONS.join(", ")}.`,
|
|
318
303
|
level: "unrecognized"
|
|
319
304
|
};
|
|
320
305
|
}
|
|
@@ -553,5 +538,6 @@ var ZNS = class {
|
|
|
553
538
|
LIST_COMMISSION,
|
|
554
539
|
MAINNET_UIVK,
|
|
555
540
|
TESTNET_UIVK,
|
|
556
|
-
ZNS
|
|
541
|
+
ZNS,
|
|
542
|
+
ZNS_ACTIONS
|
|
557
543
|
});
|
package/dist/zns.d.cts
CHANGED
|
@@ -153,6 +153,9 @@ interface PayloadValidationResult {
|
|
|
153
153
|
declare const DEFAULT_URL = "https://light.zcash.me/zns-testnet";
|
|
154
154
|
declare const TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta00cx4068wnlzcv7tx9n3t3gfhsy83pe4y6jrhxtzaq0hj6xtg5zrk2dn7zen3vns2a5pgs4fxdjlletmqrhfa42";
|
|
155
155
|
declare const MAINNET_UIVK = "uivk1gl26qy0xjja7lqhyg3pf0x4j4j66kqwewrjkdcg28eqq4wgtzjmujpee7x9cs2ec9xhnlgrm8ptlw8z80j2aryw8nqtssser2ys778a0s00uvgkdjnfr58sndhfvc3f4zqjs6ywva6";
|
|
156
|
+
/** Actions accepted by {@link validatePayload}. Exposed for consumers who need
|
|
157
|
+
* to build action selectors or dynamic validation. */
|
|
158
|
+
declare const ZNS_ACTIONS: readonly ["CLAIM", "BUY", "UPDATE", "LIST", "DELIST", "RELEASE"];
|
|
156
159
|
type Network = "testnet" | "mainnet";
|
|
157
160
|
declare class ZNS {
|
|
158
161
|
private url;
|
|
@@ -283,4 +286,4 @@ declare class ZNS {
|
|
|
283
286
|
private rpc;
|
|
284
287
|
}
|
|
285
288
|
|
|
286
|
-
export { BUY_COMMISSION, type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, LIST_COMMISSION, type LastAction, type Listing, MAINNET_UIVK, type Network, type PayloadValidationLevel, type PayloadValidationResult, type PendingBuy, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedSetPrice, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, type Zats };
|
|
289
|
+
export { BUY_COMMISSION, type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, LIST_COMMISSION, type LastAction, type Listing, MAINNET_UIVK, type Network, type PayloadValidationLevel, type PayloadValidationResult, type PendingBuy, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedSetPrice, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, ZNS_ACTIONS, type Zats };
|
package/dist/zns.d.ts
CHANGED
|
@@ -153,6 +153,9 @@ interface PayloadValidationResult {
|
|
|
153
153
|
declare const DEFAULT_URL = "https://light.zcash.me/zns-testnet";
|
|
154
154
|
declare const TESTNET_UIVK = "uivktest1hzw7wyadutvzfgpna80yftsk5l7jeyu2p5me5quvp28tytxueta00cx4068wnlzcv7tx9n3t3gfhsy83pe4y6jrhxtzaq0hj6xtg5zrk2dn7zen3vns2a5pgs4fxdjlletmqrhfa42";
|
|
155
155
|
declare const MAINNET_UIVK = "uivk1gl26qy0xjja7lqhyg3pf0x4j4j66kqwewrjkdcg28eqq4wgtzjmujpee7x9cs2ec9xhnlgrm8ptlw8z80j2aryw8nqtssser2ys778a0s00uvgkdjnfr58sndhfvc3f4zqjs6ywva6";
|
|
156
|
+
/** Actions accepted by {@link validatePayload}. Exposed for consumers who need
|
|
157
|
+
* to build action selectors or dynamic validation. */
|
|
158
|
+
declare const ZNS_ACTIONS: readonly ["CLAIM", "BUY", "UPDATE", "LIST", "DELIST", "RELEASE"];
|
|
156
159
|
type Network = "testnet" | "mainnet";
|
|
157
160
|
declare class ZNS {
|
|
158
161
|
private url;
|
|
@@ -283,4 +286,4 @@ declare class ZNS {
|
|
|
283
286
|
private rpc;
|
|
284
287
|
}
|
|
285
288
|
|
|
286
|
-
export { BUY_COMMISSION, type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, LIST_COMMISSION, type LastAction, type Listing, MAINNET_UIVK, type Network, type PayloadValidationLevel, type PayloadValidationResult, type PendingBuy, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedSetPrice, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, type Zats };
|
|
289
|
+
export { BUY_COMMISSION, type CompletedAction, DEFAULT_URL, type Event, type EventAction, type EventsFilter, type EventsResult, LIST_COMMISSION, type LastAction, type Listing, MAINNET_UIVK, type Network, type PayloadValidationLevel, type PayloadValidationResult, type PendingBuy, type PreparedBuy, type PreparedClaim, type PreparedDelist, type PreparedList, type PreparedRelease, type PreparedSetPrice, type PreparedUpdate, type Pricing, type Registration, type Status, TESTNET_UIVK, ZNS, ZNS_ACTIONS, type Zats };
|
package/dist/zns.js
CHANGED
|
@@ -15,6 +15,7 @@ var REGISTRY_ADDRESSES = {
|
|
|
15
15
|
testnet: "utest1f32kn6c4zvn54xr8wfsnxmj9hzpu2mwgtxzpzwcw34906tdccdvzs0z2dx38lly7tpan77x6udt8pjczqm22ymsdhlz9j0tk5yq664nl",
|
|
16
16
|
mainnet: "u1k0evt0ahj5qdt6y9ftsxndl8lrkm4ff6rp00u04cjpmqj6hxl9t8hfsxftmn3ht34e03lljh89czn2h8qn67rwrs8x0hm3lsxsucp9q9"
|
|
17
17
|
};
|
|
18
|
+
var ZNS_ACTIONS = ["CLAIM", "BUY", "UPDATE", "LIST", "DELIST", "RELEASE"];
|
|
18
19
|
var NAME_RE = /^[a-z0-9]{1,62}$/;
|
|
19
20
|
function isWholeNumber(value) {
|
|
20
21
|
return /^\d+$/.test(value) && !value.startsWith("0") || value === "0";
|
|
@@ -253,29 +254,12 @@ var ZNS = class {
|
|
|
253
254
|
return mk("invalid", actionUpper, "release", `Nonce must be a whole number.`);
|
|
254
255
|
return mk("valid", actionUpper, "release", "Valid RELEASE payload.");
|
|
255
256
|
}
|
|
256
|
-
case "setprice": {
|
|
257
|
-
if (parts.length < 3)
|
|
258
|
-
return mk("invalid", actionUpper, "setprice", `Expected SETPRICE:<count>:<tier1>:...:<nonce>.`);
|
|
259
|
-
const count = Number(parts[0]);
|
|
260
|
-
if (!isWholeNumber(parts[0]) || isNaN(count) || count <= 0)
|
|
261
|
-
return mk("invalid", actionUpper, "setprice", `Count must be a positive whole number.`);
|
|
262
|
-
const priceCount = parts.length - 2;
|
|
263
|
-
if (priceCount !== count)
|
|
264
|
-
return mk("invalid", actionUpper, "setprice", `SETPRICE count mismatch: header is ${count} but found ${priceCount} price tiers.`);
|
|
265
|
-
if (!isWholeNumber(parts[parts.length - 1]))
|
|
266
|
-
return mk("invalid", actionUpper, "setprice", `Nonce must be a whole number.`);
|
|
267
|
-
for (let i = 1; i < parts.length - 1; i++) {
|
|
268
|
-
if (!isWholeNumber(parts[i]) || Number(parts[i]) <= 0)
|
|
269
|
-
return mk("invalid", actionUpper, "setprice", `Tier ${i} must be a positive whole number in zats.`);
|
|
270
|
-
}
|
|
271
|
-
return mk("valid", actionUpper, "setprice", "Valid SETPRICE payload.");
|
|
272
|
-
}
|
|
273
257
|
default:
|
|
274
258
|
return {
|
|
275
259
|
valid: false,
|
|
276
260
|
action: actionUpper,
|
|
277
261
|
canonicalAction: null,
|
|
278
|
-
message: `Unrecognized action "${actionUpper}". Valid actions:
|
|
262
|
+
message: `Unrecognized action "${actionUpper}". Valid actions: ${ZNS_ACTIONS.join(", ")}.`,
|
|
279
263
|
level: "unrecognized"
|
|
280
264
|
};
|
|
281
265
|
}
|
|
@@ -513,5 +497,6 @@ export {
|
|
|
513
497
|
LIST_COMMISSION,
|
|
514
498
|
MAINNET_UIVK,
|
|
515
499
|
TESTNET_UIVK,
|
|
516
|
-
ZNS
|
|
500
|
+
ZNS,
|
|
501
|
+
ZNS_ACTIONS
|
|
517
502
|
};
|