@inversealtruism/cairnx-core 0.1.24 → 0.1.25

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/index.cjs CHANGED
@@ -39,12 +39,14 @@ __export(index_exports, {
39
39
  EPOCH_LEN: () => import_csd_codec4.EPOCH_LEN,
40
40
  FEE_BPS: () => FEE_BPS,
41
41
  FEE_BPS_V16: () => FEE_BPS_V16,
42
+ FINALIZE_TIP_MARGIN: () => FINALIZE_TIP_MARGIN,
42
43
  HALVING_INTERVAL: () => import_csd_codec4.HALVING_INTERVAL,
43
44
  HASH_RE: () => HASH_RE,
44
45
  INITIAL_REWARD: () => import_csd_codec4.INITIAL_REWARD,
45
46
  MAX_ACTIVE_CLAIMS: () => MAX_ACTIVE_CLAIMS,
46
47
  MAX_AMOUNT: () => MAX_AMOUNT,
47
48
  MAX_OFFER_EPOCHS: () => MAX_OFFER_EPOCHS,
49
+ MAX_PENDING_REG: () => MAX_PENDING_REG,
48
50
  MAX_RECORD_BYTES: () => MAX_RECORD_BYTES,
49
51
  MINT_KEYS: () => MINT_KEYS,
50
52
  MIN_FEE_ATTEST: () => import_csd_codec4.MIN_FEE_ATTEST,
@@ -61,6 +63,7 @@ __export(index_exports, {
61
63
  NAME_PREMIUM_START: () => NAME_PREMIUM_START,
62
64
  NAME_RE: () => NAME_RE,
63
65
  NAME_TERM_EPOCHS: () => NAME_TERM_EPOCHS,
66
+ NFINALIZE_KEYS: () => NFINALIZE_KEYS,
64
67
  NPROFILE_KEYS: () => NPROFILE_KEYS,
65
68
  OFFER_KEYS: () => OFFER_KEYS,
66
69
  PKEY: () => PKEY,
@@ -68,6 +71,8 @@ __export(index_exports, {
68
71
  PROFILE_MAX_VALUE_BYTES: () => PROFILE_MAX_VALUE_BYTES,
69
72
  REBATE_BPS: () => REBATE_BPS,
70
73
  REBATE_FLAT: () => REBATE_FLAT,
74
+ REG_COMMIT_MAX_BLOCKS: () => REG_COMMIT_MAX_BLOCKS,
75
+ REG_FINALIZE_GRACE_BLOCKS: () => REG_FINALIZE_GRACE_BLOCKS,
71
76
  RESERVED_NAMES: () => RESERVED_NAMES,
72
77
  SALT_RE: () => SALT_RE,
73
78
  SCORE_CANCEL: () => SCORE_CANCEL,
@@ -90,6 +95,7 @@ __export(index_exports, {
90
95
  V22_HEIGHT: () => V22_HEIGHT,
91
96
  V23_HEIGHT: () => V23_HEIGHT,
92
97
  V24_HEIGHT: () => V24_HEIGHT,
98
+ V25_HEIGHT: () => V25_HEIGHT,
93
99
  ZERO_ADDR: () => ZERO_ADDR,
94
100
  bid: () => bid,
95
101
  blockReward: () => import_csd_codec4.blockReward,
@@ -110,6 +116,7 @@ __export(index_exports, {
110
116
  nameClaim: () => nameClaim,
111
117
  nameCommit: () => nameCommit,
112
118
  nameCommitRecord: () => nameCommitRecord,
119
+ nameFinalize: () => nameFinalize,
113
120
  nameProfile: () => nameProfile,
114
121
  nameRegFee: () => nameRegFee,
115
122
  nameRenew: () => nameRenew,
@@ -212,6 +219,11 @@ var HASH_RE = /^0x[0-9a-f]{64}$/;
212
219
  var SALT_RE = /^[0-9a-fA-F]{16,128}$/;
213
220
  var RESERVED_NAMES = /* @__PURE__ */ new Set(["csd", "treasury", "admin", "official", "root", "www", "support"]);
214
221
  var COMMIT_MAX_BLOCKS = 8 * import_csd_codec.EPOCH_LEN;
222
+ var V25_HEIGHT = 1e7;
223
+ var REG_COMMIT_MAX_BLOCKS = 8;
224
+ var REG_FINALIZE_GRACE_BLOCKS = 12;
225
+ var MAX_PENDING_REG = 3;
226
+ var FINALIZE_TIP_MARGIN = 2;
215
227
  var epochOf = (height) => Math.floor(height / import_csd_codec.EPOCH_LEN);
216
228
  var claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
217
229
  var claimWindowOf = (claimUntilHeight) => claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
@@ -274,6 +286,7 @@ var TRANSFER_KEYS = /* @__PURE__ */ new Set(["v", "t", "ticker", "to", "amount",
274
286
  var OFFER_KEYS = /* @__PURE__ */ new Set(["v", "t", "give", "want", "min", "bid", "taker", "memo", "ts"]);
275
287
  var BID_KEYS = /* @__PURE__ */ new Set(["v", "t", "want", "give", "memo", "ts"]);
276
288
  var NAME_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "salt"]);
289
+ var NFINALIZE_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "salt"]);
277
290
  var NPROFILE_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "p"]);
278
291
  function parseRecord(uri, payloadHashHex) {
279
292
  if (new TextEncoder().encode(uri).length > MAX_RECORD_BYTES) return null;
@@ -385,6 +398,12 @@ function parseRecord(uri, payloadHashHex) {
385
398
  if (r.salt !== void 0 && (typeof r.salt !== "string" || !SALT_RE.test(r.salt))) return null;
386
399
  return r;
387
400
  }
401
+ case "nfinalize": {
402
+ if (!onlyKeys(r, NFINALIZE_KEYS)) return null;
403
+ if (!isName(r.name)) return null;
404
+ if (typeof r.salt !== "string" || !SALT_RE.test(r.salt)) return null;
405
+ return r;
406
+ }
388
407
  case "nxfer": {
389
408
  if (!isName(r.name) || !isAddr(r.to)) return null;
390
409
  if (Object.keys(r).length !== 4) return null;
@@ -441,6 +460,7 @@ var bid = (r) => buildRecord({ v: 1, t: "bid", ...r });
441
460
  var offerCancelAll = (r = {}) => buildRecord({ v: 1, t: "ocancel", ...r });
442
461
  var nameCommitRecord = (r) => buildRecord({ v: 1, t: "ncommit", ...r });
443
462
  var nameClaim = (r) => buildRecord({ v: 1, t: "name", ...r });
463
+ var nameFinalize = (r) => buildRecord({ v: 1, t: "nfinalize", ...r });
444
464
  var nameXfer = (r) => buildRecord({ v: 1, t: "nxfer", ...r });
445
465
  var nameSet = (r) => buildRecord({ v: 1, t: "nset", ...r });
446
466
  var nameRenew = (r) => buildRecord({ v: 1, t: "nrenew", ...r });
@@ -511,6 +531,10 @@ function resolve(events, tipHeight) {
511
531
  for (const b of bids.values()) {
512
532
  if (b.status === "open" && ep > effExpiry(b, height)) b.status = "expired";
513
533
  }
534
+ for (const nm of [...names.keys()]) {
535
+ const n = names.get(nm);
536
+ if (n.pending && n.finalizeBy !== void 0 && height > n.finalizeBy) names.delete(nm);
537
+ }
514
538
  };
515
539
  const V15_EPOCH = epochOf(V15_HEIGHT);
516
540
  const paidThrough = (n) => n.paidThroughEpoch ?? V15_EPOCH + NAME_TERM_EPOCHS;
@@ -561,6 +585,7 @@ function resolve(events, tipHeight) {
561
585
  const v16 = ev.height >= V16_HEIGHT;
562
586
  const v19 = ev.height >= V19_HEIGHT;
563
587
  const v23 = ev.height >= V23_HEIGHT;
588
+ const v25 = ev.height >= V25_HEIGHT;
564
589
  const feeToTreasury = ev.kind === "propose" ? ptAmt((ev.paidTo ?? {})[TREASURY_ADDR]) : 0n;
565
590
  if (ev.kind === "propose") {
566
591
  const rec = parseRecord(ev.uri, ev.payloadHash);
@@ -646,11 +671,12 @@ function resolve(events, tipHeight) {
646
671
  note(ev, ev.id, "name", false, "before v1.1 activation");
647
672
  continue;
648
673
  }
674
+ const regWindow = v25 ? REG_COMMIT_MAX_BLOCKS : COMMIT_MAX_BLOCKS;
649
675
  let effHeight = ev.height;
650
676
  if (rec.salt !== void 0) {
651
677
  const ch = nameCommit(rec.name, rec.salt, who);
652
678
  const cH = commits.get(ch);
653
- if (cH === void 0 || cH >= ev.height || ev.height - cH > COMMIT_MAX_BLOCKS) {
679
+ if (cH === void 0 || cH >= ev.height || ev.height - cH > regWindow) {
654
680
  note(ev, ev.id, "name", false, "no valid in-window commit for this reveal");
655
681
  continue;
656
682
  }
@@ -658,8 +684,9 @@ function resolve(events, tipHeight) {
658
684
  }
659
685
  const cur = names.get(rec.name);
660
686
  const epClaim = epochOf(ev.height);
661
- if (cur && v15 && lapsed(cur, epClaim)) {
662
- const fee = expiredClaimFee(rec.name, epClaim - (paidThrough(cur) + NAME_GRACE_EPOCHS), ev.height);
687
+ const curActive = cur && cur.pending && cur.finalizeBy !== void 0 && ev.height > cur.finalizeBy ? void 0 : cur;
688
+ if (curActive && !curActive.pending && v15 && lapsed(curActive, epClaim)) {
689
+ const fee = expiredClaimFee(rec.name, epClaim - (paidThrough(curActive) + NAME_GRACE_EPOCHS), ev.height);
663
690
  if (feeToTreasury < fee) {
664
691
  note(ev, ev.id, "name", false, "lapsed-name claim fee unpaid (decaying premium)");
665
692
  continue;
@@ -673,6 +700,32 @@ function resolve(events, tipHeight) {
673
700
  note(ev, ev.id, "name", true, "lapsed lease re-claimed (premium)");
674
701
  continue;
675
702
  }
703
+ if (v25) {
704
+ if (rec.salt === void 0) {
705
+ note(ev, ev.id, "name", false, "v2.5: registration requires a commit-reveal (salt)");
706
+ continue;
707
+ }
708
+ const better2 = !curActive || !curActive.viaFill && (effHeight < curActive.effHeight || effHeight === curActive.effHeight && (ev.pos < curActive.pos || ev.pos === curActive.pos && ev.id < curActive.id));
709
+ if (!better2) {
710
+ note(ev, ev.id, "name", false, curActive?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
711
+ continue;
712
+ }
713
+ let myPending = 0;
714
+ for (const [nm, n] of names) if (n.pending && n.owner === who && nm !== rec.name && n.finalizeBy !== void 0 && ev.height <= n.finalizeBy) myPending++;
715
+ if (myPending >= MAX_PENDING_REG) {
716
+ note(ev, ev.id, "name", false, "too many pending reservations (max reached)");
717
+ continue;
718
+ }
719
+ if (curActive) {
720
+ for (const o of offers.values()) if (o.status === "open" && isNameGive(o.give) && o.give.name === rec.name) {
721
+ releaseGive(o);
722
+ o.status = "cancelled";
723
+ }
724
+ }
725
+ names.set(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, pending: true, finalizeBy: effHeight + REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS });
726
+ note(ev, ev.id, "name", true, curActive ? "reserved (displaced prior reservation)" : "reserved (pending finalize)");
727
+ continue;
728
+ }
676
729
  if (feeToTreasury < nameRegFee(rec.name, ev.height)) {
677
730
  note(ev, ev.id, "name", false, "name registration fee unpaid");
678
731
  continue;
@@ -686,12 +739,12 @@ function resolve(events, tipHeight) {
686
739
  locked: false,
687
740
  ...v15 ? { paidThroughEpoch: epClaim + NAME_TERM_EPOCHS } : {}
688
741
  };
689
- const better = !cur || !cur.viaFill && (effHeight < cur.effHeight || effHeight === cur.effHeight && (ev.pos < cur.pos || ev.pos === cur.pos && ev.id < cur.id));
742
+ const better = !curActive || !curActive.viaFill && (effHeight < curActive.effHeight || effHeight === curActive.effHeight && (ev.pos < curActive.pos || ev.pos === curActive.pos && ev.id < curActive.id));
690
743
  if (!better) {
691
- note(ev, ev.id, "name", false, cur?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
744
+ note(ev, ev.id, "name", false, curActive?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
692
745
  continue;
693
746
  }
694
- if (cur) {
747
+ if (curActive) {
695
748
  for (const o of offers.values()) if (o.status === "open" && isNameGive(o.give) && o.give.name === rec.name) {
696
749
  releaseGive(o);
697
750
  o.status = "cancelled";
@@ -699,13 +752,49 @@ function resolve(events, tipHeight) {
699
752
  }
700
753
  names.set(rec.name, cand);
701
754
  feesPaid += nameRegFee(rec.name, ev.height);
702
- note(ev, ev.id, "name", true, cur ? "displaced prior holder" : void 0);
755
+ note(ev, ev.id, "name", true, curActive ? "displaced prior holder" : void 0);
756
+ } else if (rec.t === "nfinalize") {
757
+ if (!v25) {
758
+ note(ev, ev.id, "nfinalize", false, "before v2.5 activation");
759
+ continue;
760
+ }
761
+ const n = names.get(rec.name);
762
+ if (!n || !n.pending || n.owner !== who) {
763
+ note(ev, ev.id, "nfinalize", false, "no matching pending reservation you own");
764
+ continue;
765
+ }
766
+ const cH = commits.get(nameCommit(rec.name, rec.salt, who));
767
+ if (cH === void 0 || cH !== n.effHeight) {
768
+ note(ev, ev.id, "nfinalize", false, "salt does not match the reservation commit");
769
+ continue;
770
+ }
771
+ if (!(ev.height > n.effHeight + REG_COMMIT_MAX_BLOCKS)) {
772
+ note(ev, ev.id, "nfinalize", false, "too early \u2014 displacement contest not yet frozen");
773
+ continue;
774
+ }
775
+ if (n.finalizeBy !== void 0 && ev.height > n.finalizeBy) {
776
+ note(ev, ev.id, "nfinalize", false, "reservation expired");
777
+ continue;
778
+ }
779
+ if (feeToTreasury < nameRegFee(rec.name, ev.height)) {
780
+ note(ev, ev.id, "nfinalize", false, "name registration fee unpaid");
781
+ continue;
782
+ }
783
+ n.pending = void 0;
784
+ n.finalizeBy = void 0;
785
+ n.paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS;
786
+ feesPaid += nameRegFee(rec.name, ev.height);
787
+ note(ev, ev.id, "nfinalize", true);
703
788
  } else if (rec.t === "nxfer") {
704
789
  const n = names.get(rec.name);
705
790
  if (!n || n.owner !== who) {
706
791
  note(ev, ev.id, "nxfer", false, "not the name owner");
707
792
  continue;
708
793
  }
794
+ if (n.pending) {
795
+ note(ev, ev.id, "nxfer", false, "name reservation not yet finalized");
796
+ continue;
797
+ }
709
798
  if (v15 && lapsed(n, epochOf(ev.height))) {
710
799
  note(ev, ev.id, "nxfer", false, "lease lapsed \u2014 claim it instead");
711
800
  continue;
@@ -724,6 +813,10 @@ function resolve(events, tipHeight) {
724
813
  note(ev, ev.id, "nset", false, "not the name owner");
725
814
  continue;
726
815
  }
816
+ if (n.pending) {
817
+ note(ev, ev.id, "nset", false, "name reservation not yet finalized");
818
+ continue;
819
+ }
727
820
  if (v15 && lapsed(n, epochOf(ev.height))) {
728
821
  note(ev, ev.id, "nset", false, "lease lapsed \u2014 claim it instead");
729
822
  continue;
@@ -741,6 +834,10 @@ function resolve(events, tipHeight) {
741
834
  note(ev, ev.id, "nprofile", false, "not the name owner");
742
835
  continue;
743
836
  }
837
+ if (n.pending) {
838
+ note(ev, ev.id, "nprofile", false, "name reservation not yet finalized");
839
+ continue;
840
+ }
744
841
  if (v15 && lapsed(n, epochOf(ev.height))) {
745
842
  note(ev, ev.id, "nprofile", false, "lease lapsed \u2014 claim it instead");
746
843
  continue;
@@ -785,6 +882,10 @@ function resolve(events, tipHeight) {
785
882
  note(ev, ev.id, "offer", false, "you don't own this name");
786
883
  continue;
787
884
  }
885
+ if (n.pending) {
886
+ note(ev, ev.id, "offer", false, "name reservation not yet finalized");
887
+ continue;
888
+ }
788
889
  if (n.locked) {
789
890
  note(ev, ev.id, "offer", false, "name already locked by another offer");
790
891
  continue;
@@ -894,6 +995,10 @@ function resolve(events, tipHeight) {
894
995
  }
895
996
  const n = names.get(rec.name);
896
997
  const ep = epochOf(ev.height);
998
+ if (n && n.pending) {
999
+ note(ev, ev.id, "nrenew", false, "name reservation not yet finalized");
1000
+ continue;
1001
+ }
897
1002
  if (!n || lapsed(n, ep)) {
898
1003
  note(ev, ev.id, "nrenew", false, "no live lease (lapsed names are claimed, not renewed)");
899
1004
  continue;
@@ -1173,8 +1278,13 @@ function resolve(events, tipHeight) {
1173
1278
  const namesOut = {};
1174
1279
  const tipV15 = tipHeight >= V15_HEIGHT;
1175
1280
  const tipV19 = tipHeight >= V19_HEIGHT;
1281
+ const tipV25 = tipHeight >= V25_HEIGHT;
1176
1282
  const tipEpoch = epochOf(tipHeight);
1177
1283
  for (const [nm, n] of [...names.entries()].sort(([a], [b]) => ord(a, b))) {
1284
+ if (tipV25 && n.pending) {
1285
+ namesOut[nm] = { name: nm, owner: n.owner, claimId: n.id, height: n.height, effectiveHeight: n.effHeight, locked: n.locked, pending: true, finalizeBy: n.finalizeBy };
1286
+ continue;
1287
+ }
1178
1288
  namesOut[nm] = {
1179
1289
  name: nm,
1180
1290
  owner: n.owner,
@@ -1248,12 +1358,14 @@ var import_csd_codec4 = require("@inversealtruism/csd-codec");
1248
1358
  EPOCH_LEN,
1249
1359
  FEE_BPS,
1250
1360
  FEE_BPS_V16,
1361
+ FINALIZE_TIP_MARGIN,
1251
1362
  HALVING_INTERVAL,
1252
1363
  HASH_RE,
1253
1364
  INITIAL_REWARD,
1254
1365
  MAX_ACTIVE_CLAIMS,
1255
1366
  MAX_AMOUNT,
1256
1367
  MAX_OFFER_EPOCHS,
1368
+ MAX_PENDING_REG,
1257
1369
  MAX_RECORD_BYTES,
1258
1370
  MINT_KEYS,
1259
1371
  MIN_FEE_ATTEST,
@@ -1270,6 +1382,7 @@ var import_csd_codec4 = require("@inversealtruism/csd-codec");
1270
1382
  NAME_PREMIUM_START,
1271
1383
  NAME_RE,
1272
1384
  NAME_TERM_EPOCHS,
1385
+ NFINALIZE_KEYS,
1273
1386
  NPROFILE_KEYS,
1274
1387
  OFFER_KEYS,
1275
1388
  PKEY,
@@ -1277,6 +1390,8 @@ var import_csd_codec4 = require("@inversealtruism/csd-codec");
1277
1390
  PROFILE_MAX_VALUE_BYTES,
1278
1391
  REBATE_BPS,
1279
1392
  REBATE_FLAT,
1393
+ REG_COMMIT_MAX_BLOCKS,
1394
+ REG_FINALIZE_GRACE_BLOCKS,
1280
1395
  RESERVED_NAMES,
1281
1396
  SALT_RE,
1282
1397
  SCORE_CANCEL,
@@ -1299,6 +1414,7 @@ var import_csd_codec4 = require("@inversealtruism/csd-codec");
1299
1414
  V22_HEIGHT,
1300
1415
  V23_HEIGHT,
1301
1416
  V24_HEIGHT,
1417
+ V25_HEIGHT,
1302
1418
  ZERO_ADDR,
1303
1419
  bid,
1304
1420
  blockReward,
@@ -1319,6 +1435,7 @@ var import_csd_codec4 = require("@inversealtruism/csd-codec");
1319
1435
  nameClaim,
1320
1436
  nameCommit,
1321
1437
  nameCommitRecord,
1438
+ nameFinalize,
1322
1439
  nameProfile,
1323
1440
  nameRegFee,
1324
1441
  nameRenew,
package/dist/index.d.cts CHANGED
@@ -63,6 +63,11 @@ declare const HASH_RE: RegExp;
63
63
  declare const SALT_RE: RegExp;
64
64
  declare const RESERVED_NAMES: Set<string>;
65
65
  declare const COMMIT_MAX_BLOCKS: number;
66
+ declare const V25_HEIGHT = 10000000;
67
+ declare const REG_COMMIT_MAX_BLOCKS = 8;
68
+ declare const REG_FINALIZE_GRACE_BLOCKS = 12;
69
+ declare const MAX_PENDING_REG = 3;
70
+ declare const FINALIZE_TIP_MARGIN = 2;
66
71
  declare const epochOf: (height: number) => number;
67
72
  declare const claimWindowAt: (height: number) => number;
68
73
  declare const claimWindowOf: (claimUntilHeight: number) => number;
@@ -152,6 +157,12 @@ interface NameRecord {
152
157
  name: string;
153
158
  salt?: string;
154
159
  }
160
+ interface NameFinalizeRecord {
161
+ v: 1;
162
+ t: "nfinalize";
163
+ name: string;
164
+ salt: string;
165
+ }
155
166
  interface NameXferRecord {
156
167
  v: 1;
157
168
  t: "nxfer";
@@ -181,7 +192,7 @@ interface NameProfileRecord {
181
192
  name: string;
182
193
  p: Record<string, string>;
183
194
  }
184
- type CairnXRecord = DeployRecord | MintRecord | TransferRecord | OfferRecord | BidRecord | OfferCancelAllRecord | NameCommitRecord | NameRecord | NameXferRecord | NameSetRecord | NameRenewRecord | TokenMetaRecord | NameProfileRecord;
195
+ type CairnXRecord = DeployRecord | MintRecord | TransferRecord | OfferRecord | BidRecord | OfferCancelAllRecord | NameCommitRecord | NameRecord | NameFinalizeRecord | NameXferRecord | NameSetRecord | NameRenewRecord | TokenMetaRecord | NameProfileRecord;
185
196
  interface ProposeEvent {
186
197
  kind: "propose";
187
198
  id: string;
@@ -237,6 +248,11 @@ interface NameState {
237
248
  paidThroughEpoch?: number;
238
249
  /** v1.5: true once the lease + grace lapsed (record kept for history; name is claimable) */
239
250
  expired?: true;
251
+ /** v2.5: a payment-free registration reservation awaiting nfinalize. NOT resolvable (confers no address)
252
+ * and not actionable by the owner until finalized; auto-expires at finalizeBy. Materialized at v2.5+ tips
253
+ * only, so every pre-v2.5 canonical hash stays byte-identical. */
254
+ pending?: true;
255
+ finalizeBy?: number;
240
256
  /** v1.9: ENS-class identity — a charset-locked string→string map (doc 36). INERT cosmetic metadata
241
257
  * (NOT a send target; the verified address is `addr`). Materialized at v1.9+ tips only, cleared on
242
258
  * every ownership change, absent when empty. */
@@ -347,6 +363,7 @@ declare const TRANSFER_KEYS: Set<string>;
347
363
  declare const OFFER_KEYS: Set<string>;
348
364
  declare const BID_KEYS: Set<string>;
349
365
  declare const NAME_KEYS: Set<string>;
366
+ declare const NFINALIZE_KEYS: Set<string>;
350
367
  declare const NPROFILE_KEYS: Set<string>;
351
368
  /**
352
369
  * Parse + validate a record from an anchored `uri`. Returns null for anything invalid —
@@ -365,6 +382,7 @@ declare const bid: (r: Omit<BidRecord, "v" | "t">) => BuiltRecord;
365
382
  declare const offerCancelAll: (r?: Omit<OfferCancelAllRecord, "v" | "t">) => BuiltRecord;
366
383
  declare const nameCommitRecord: (r: Omit<NameCommitRecord, "v" | "t">) => BuiltRecord;
367
384
  declare const nameClaim: (r: Omit<NameRecord, "v" | "t">) => BuiltRecord;
385
+ declare const nameFinalize: (r: Omit<NameFinalizeRecord, "v" | "t">) => BuiltRecord;
368
386
  declare const nameXfer: (r: Omit<NameXferRecord, "v" | "t">) => BuiltRecord;
369
387
  declare const nameSet: (r: Omit<NameSetRecord, "v" | "t">) => BuiltRecord;
370
388
  declare const nameRenew: (r: Omit<NameRenewRecord, "v" | "t">) => BuiltRecord;
@@ -402,4 +420,4 @@ declare function requiredClaimDepth(valueSats: number | bigint, height: number):
402
420
  capped: boolean;
403
421
  };
404
422
 
405
- export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_RECORD_BYTES, MINT_KEYS, type MintRecord, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NPROFILE_KEYS, type NameCommitRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SALT_RE, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, type Want, ZERO_ADDR, bid, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, parseAmount, parseRecord, requiredClaimDepth, resolve, tokenMeta, tradeFee, transfer };
423
+ export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FEE_BPS, FEE_BPS_V16, FINALIZE_TIP_MARGIN, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MINT_KEYS, type MintRecord, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, type Want, ZERO_ADDR, bid, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, parseAmount, parseRecord, requiredClaimDepth, resolve, tokenMeta, tradeFee, transfer };
package/dist/index.d.ts CHANGED
@@ -63,6 +63,11 @@ declare const HASH_RE: RegExp;
63
63
  declare const SALT_RE: RegExp;
64
64
  declare const RESERVED_NAMES: Set<string>;
65
65
  declare const COMMIT_MAX_BLOCKS: number;
66
+ declare const V25_HEIGHT = 10000000;
67
+ declare const REG_COMMIT_MAX_BLOCKS = 8;
68
+ declare const REG_FINALIZE_GRACE_BLOCKS = 12;
69
+ declare const MAX_PENDING_REG = 3;
70
+ declare const FINALIZE_TIP_MARGIN = 2;
66
71
  declare const epochOf: (height: number) => number;
67
72
  declare const claimWindowAt: (height: number) => number;
68
73
  declare const claimWindowOf: (claimUntilHeight: number) => number;
@@ -152,6 +157,12 @@ interface NameRecord {
152
157
  name: string;
153
158
  salt?: string;
154
159
  }
160
+ interface NameFinalizeRecord {
161
+ v: 1;
162
+ t: "nfinalize";
163
+ name: string;
164
+ salt: string;
165
+ }
155
166
  interface NameXferRecord {
156
167
  v: 1;
157
168
  t: "nxfer";
@@ -181,7 +192,7 @@ interface NameProfileRecord {
181
192
  name: string;
182
193
  p: Record<string, string>;
183
194
  }
184
- type CairnXRecord = DeployRecord | MintRecord | TransferRecord | OfferRecord | BidRecord | OfferCancelAllRecord | NameCommitRecord | NameRecord | NameXferRecord | NameSetRecord | NameRenewRecord | TokenMetaRecord | NameProfileRecord;
195
+ type CairnXRecord = DeployRecord | MintRecord | TransferRecord | OfferRecord | BidRecord | OfferCancelAllRecord | NameCommitRecord | NameRecord | NameFinalizeRecord | NameXferRecord | NameSetRecord | NameRenewRecord | TokenMetaRecord | NameProfileRecord;
185
196
  interface ProposeEvent {
186
197
  kind: "propose";
187
198
  id: string;
@@ -237,6 +248,11 @@ interface NameState {
237
248
  paidThroughEpoch?: number;
238
249
  /** v1.5: true once the lease + grace lapsed (record kept for history; name is claimable) */
239
250
  expired?: true;
251
+ /** v2.5: a payment-free registration reservation awaiting nfinalize. NOT resolvable (confers no address)
252
+ * and not actionable by the owner until finalized; auto-expires at finalizeBy. Materialized at v2.5+ tips
253
+ * only, so every pre-v2.5 canonical hash stays byte-identical. */
254
+ pending?: true;
255
+ finalizeBy?: number;
240
256
  /** v1.9: ENS-class identity — a charset-locked string→string map (doc 36). INERT cosmetic metadata
241
257
  * (NOT a send target; the verified address is `addr`). Materialized at v1.9+ tips only, cleared on
242
258
  * every ownership change, absent when empty. */
@@ -347,6 +363,7 @@ declare const TRANSFER_KEYS: Set<string>;
347
363
  declare const OFFER_KEYS: Set<string>;
348
364
  declare const BID_KEYS: Set<string>;
349
365
  declare const NAME_KEYS: Set<string>;
366
+ declare const NFINALIZE_KEYS: Set<string>;
350
367
  declare const NPROFILE_KEYS: Set<string>;
351
368
  /**
352
369
  * Parse + validate a record from an anchored `uri`. Returns null for anything invalid —
@@ -365,6 +382,7 @@ declare const bid: (r: Omit<BidRecord, "v" | "t">) => BuiltRecord;
365
382
  declare const offerCancelAll: (r?: Omit<OfferCancelAllRecord, "v" | "t">) => BuiltRecord;
366
383
  declare const nameCommitRecord: (r: Omit<NameCommitRecord, "v" | "t">) => BuiltRecord;
367
384
  declare const nameClaim: (r: Omit<NameRecord, "v" | "t">) => BuiltRecord;
385
+ declare const nameFinalize: (r: Omit<NameFinalizeRecord, "v" | "t">) => BuiltRecord;
368
386
  declare const nameXfer: (r: Omit<NameXferRecord, "v" | "t">) => BuiltRecord;
369
387
  declare const nameSet: (r: Omit<NameSetRecord, "v" | "t">) => BuiltRecord;
370
388
  declare const nameRenew: (r: Omit<NameRenewRecord, "v" | "t">) => BuiltRecord;
@@ -402,4 +420,4 @@ declare function requiredClaimDepth(valueSats: number | bigint, height: number):
402
420
  capped: boolean;
403
421
  };
404
422
 
405
- export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_RECORD_BYTES, MINT_KEYS, type MintRecord, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NPROFILE_KEYS, type NameCommitRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SALT_RE, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, type Want, ZERO_ADDR, bid, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, parseAmount, parseRecord, requiredClaimDepth, resolve, tokenMeta, tradeFee, transfer };
423
+ export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FEE_BPS, FEE_BPS_V16, FINALIZE_TIP_MARGIN, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MINT_KEYS, type MintRecord, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, type Want, ZERO_ADDR, bid, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, parseAmount, parseRecord, requiredClaimDepth, resolve, tokenMeta, tradeFee, transfer };
package/dist/index.js CHANGED
@@ -81,6 +81,11 @@ var HASH_RE = /^0x[0-9a-f]{64}$/;
81
81
  var SALT_RE = /^[0-9a-fA-F]{16,128}$/;
82
82
  var RESERVED_NAMES = /* @__PURE__ */ new Set(["csd", "treasury", "admin", "official", "root", "www", "support"]);
83
83
  var COMMIT_MAX_BLOCKS = 8 * EPOCH_LEN;
84
+ var V25_HEIGHT = 1e7;
85
+ var REG_COMMIT_MAX_BLOCKS = 8;
86
+ var REG_FINALIZE_GRACE_BLOCKS = 12;
87
+ var MAX_PENDING_REG = 3;
88
+ var FINALIZE_TIP_MARGIN = 2;
84
89
  var epochOf = (height) => Math.floor(height / EPOCH_LEN);
85
90
  var claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
86
91
  var claimWindowOf = (claimUntilHeight) => claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
@@ -143,6 +148,7 @@ var TRANSFER_KEYS = /* @__PURE__ */ new Set(["v", "t", "ticker", "to", "amount",
143
148
  var OFFER_KEYS = /* @__PURE__ */ new Set(["v", "t", "give", "want", "min", "bid", "taker", "memo", "ts"]);
144
149
  var BID_KEYS = /* @__PURE__ */ new Set(["v", "t", "want", "give", "memo", "ts"]);
145
150
  var NAME_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "salt"]);
151
+ var NFINALIZE_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "salt"]);
146
152
  var NPROFILE_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "p"]);
147
153
  function parseRecord(uri, payloadHashHex) {
148
154
  if (new TextEncoder().encode(uri).length > MAX_RECORD_BYTES) return null;
@@ -254,6 +260,12 @@ function parseRecord(uri, payloadHashHex) {
254
260
  if (r.salt !== void 0 && (typeof r.salt !== "string" || !SALT_RE.test(r.salt))) return null;
255
261
  return r;
256
262
  }
263
+ case "nfinalize": {
264
+ if (!onlyKeys(r, NFINALIZE_KEYS)) return null;
265
+ if (!isName(r.name)) return null;
266
+ if (typeof r.salt !== "string" || !SALT_RE.test(r.salt)) return null;
267
+ return r;
268
+ }
257
269
  case "nxfer": {
258
270
  if (!isName(r.name) || !isAddr(r.to)) return null;
259
271
  if (Object.keys(r).length !== 4) return null;
@@ -310,6 +322,7 @@ var bid = (r) => buildRecord({ v: 1, t: "bid", ...r });
310
322
  var offerCancelAll = (r = {}) => buildRecord({ v: 1, t: "ocancel", ...r });
311
323
  var nameCommitRecord = (r) => buildRecord({ v: 1, t: "ncommit", ...r });
312
324
  var nameClaim = (r) => buildRecord({ v: 1, t: "name", ...r });
325
+ var nameFinalize = (r) => buildRecord({ v: 1, t: "nfinalize", ...r });
313
326
  var nameXfer = (r) => buildRecord({ v: 1, t: "nxfer", ...r });
314
327
  var nameSet = (r) => buildRecord({ v: 1, t: "nset", ...r });
315
328
  var nameRenew = (r) => buildRecord({ v: 1, t: "nrenew", ...r });
@@ -380,6 +393,10 @@ function resolve(events, tipHeight) {
380
393
  for (const b of bids.values()) {
381
394
  if (b.status === "open" && ep > effExpiry(b, height)) b.status = "expired";
382
395
  }
396
+ for (const nm of [...names.keys()]) {
397
+ const n = names.get(nm);
398
+ if (n.pending && n.finalizeBy !== void 0 && height > n.finalizeBy) names.delete(nm);
399
+ }
383
400
  };
384
401
  const V15_EPOCH = epochOf(V15_HEIGHT);
385
402
  const paidThrough = (n) => n.paidThroughEpoch ?? V15_EPOCH + NAME_TERM_EPOCHS;
@@ -430,6 +447,7 @@ function resolve(events, tipHeight) {
430
447
  const v16 = ev.height >= V16_HEIGHT;
431
448
  const v19 = ev.height >= V19_HEIGHT;
432
449
  const v23 = ev.height >= V23_HEIGHT;
450
+ const v25 = ev.height >= V25_HEIGHT;
433
451
  const feeToTreasury = ev.kind === "propose" ? ptAmt((ev.paidTo ?? {})[TREASURY_ADDR]) : 0n;
434
452
  if (ev.kind === "propose") {
435
453
  const rec = parseRecord(ev.uri, ev.payloadHash);
@@ -515,11 +533,12 @@ function resolve(events, tipHeight) {
515
533
  note(ev, ev.id, "name", false, "before v1.1 activation");
516
534
  continue;
517
535
  }
536
+ const regWindow = v25 ? REG_COMMIT_MAX_BLOCKS : COMMIT_MAX_BLOCKS;
518
537
  let effHeight = ev.height;
519
538
  if (rec.salt !== void 0) {
520
539
  const ch = nameCommit(rec.name, rec.salt, who);
521
540
  const cH = commits.get(ch);
522
- if (cH === void 0 || cH >= ev.height || ev.height - cH > COMMIT_MAX_BLOCKS) {
541
+ if (cH === void 0 || cH >= ev.height || ev.height - cH > regWindow) {
523
542
  note(ev, ev.id, "name", false, "no valid in-window commit for this reveal");
524
543
  continue;
525
544
  }
@@ -527,8 +546,9 @@ function resolve(events, tipHeight) {
527
546
  }
528
547
  const cur = names.get(rec.name);
529
548
  const epClaim = epochOf(ev.height);
530
- if (cur && v15 && lapsed(cur, epClaim)) {
531
- const fee = expiredClaimFee(rec.name, epClaim - (paidThrough(cur) + NAME_GRACE_EPOCHS), ev.height);
549
+ const curActive = cur && cur.pending && cur.finalizeBy !== void 0 && ev.height > cur.finalizeBy ? void 0 : cur;
550
+ if (curActive && !curActive.pending && v15 && lapsed(curActive, epClaim)) {
551
+ const fee = expiredClaimFee(rec.name, epClaim - (paidThrough(curActive) + NAME_GRACE_EPOCHS), ev.height);
532
552
  if (feeToTreasury < fee) {
533
553
  note(ev, ev.id, "name", false, "lapsed-name claim fee unpaid (decaying premium)");
534
554
  continue;
@@ -542,6 +562,32 @@ function resolve(events, tipHeight) {
542
562
  note(ev, ev.id, "name", true, "lapsed lease re-claimed (premium)");
543
563
  continue;
544
564
  }
565
+ if (v25) {
566
+ if (rec.salt === void 0) {
567
+ note(ev, ev.id, "name", false, "v2.5: registration requires a commit-reveal (salt)");
568
+ continue;
569
+ }
570
+ const better2 = !curActive || !curActive.viaFill && (effHeight < curActive.effHeight || effHeight === curActive.effHeight && (ev.pos < curActive.pos || ev.pos === curActive.pos && ev.id < curActive.id));
571
+ if (!better2) {
572
+ note(ev, ev.id, "name", false, curActive?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
573
+ continue;
574
+ }
575
+ let myPending = 0;
576
+ for (const [nm, n] of names) if (n.pending && n.owner === who && nm !== rec.name && n.finalizeBy !== void 0 && ev.height <= n.finalizeBy) myPending++;
577
+ if (myPending >= MAX_PENDING_REG) {
578
+ note(ev, ev.id, "name", false, "too many pending reservations (max reached)");
579
+ continue;
580
+ }
581
+ if (curActive) {
582
+ for (const o of offers.values()) if (o.status === "open" && isNameGive(o.give) && o.give.name === rec.name) {
583
+ releaseGive(o);
584
+ o.status = "cancelled";
585
+ }
586
+ }
587
+ names.set(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, pending: true, finalizeBy: effHeight + REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS });
588
+ note(ev, ev.id, "name", true, curActive ? "reserved (displaced prior reservation)" : "reserved (pending finalize)");
589
+ continue;
590
+ }
545
591
  if (feeToTreasury < nameRegFee(rec.name, ev.height)) {
546
592
  note(ev, ev.id, "name", false, "name registration fee unpaid");
547
593
  continue;
@@ -555,12 +601,12 @@ function resolve(events, tipHeight) {
555
601
  locked: false,
556
602
  ...v15 ? { paidThroughEpoch: epClaim + NAME_TERM_EPOCHS } : {}
557
603
  };
558
- const better = !cur || !cur.viaFill && (effHeight < cur.effHeight || effHeight === cur.effHeight && (ev.pos < cur.pos || ev.pos === cur.pos && ev.id < cur.id));
604
+ const better = !curActive || !curActive.viaFill && (effHeight < curActive.effHeight || effHeight === curActive.effHeight && (ev.pos < curActive.pos || ev.pos === curActive.pos && ev.id < curActive.id));
559
605
  if (!better) {
560
- note(ev, ev.id, "name", false, cur?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
606
+ note(ev, ev.id, "name", false, curActive?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
561
607
  continue;
562
608
  }
563
- if (cur) {
609
+ if (curActive) {
564
610
  for (const o of offers.values()) if (o.status === "open" && isNameGive(o.give) && o.give.name === rec.name) {
565
611
  releaseGive(o);
566
612
  o.status = "cancelled";
@@ -568,13 +614,49 @@ function resolve(events, tipHeight) {
568
614
  }
569
615
  names.set(rec.name, cand);
570
616
  feesPaid += nameRegFee(rec.name, ev.height);
571
- note(ev, ev.id, "name", true, cur ? "displaced prior holder" : void 0);
617
+ note(ev, ev.id, "name", true, curActive ? "displaced prior holder" : void 0);
618
+ } else if (rec.t === "nfinalize") {
619
+ if (!v25) {
620
+ note(ev, ev.id, "nfinalize", false, "before v2.5 activation");
621
+ continue;
622
+ }
623
+ const n = names.get(rec.name);
624
+ if (!n || !n.pending || n.owner !== who) {
625
+ note(ev, ev.id, "nfinalize", false, "no matching pending reservation you own");
626
+ continue;
627
+ }
628
+ const cH = commits.get(nameCommit(rec.name, rec.salt, who));
629
+ if (cH === void 0 || cH !== n.effHeight) {
630
+ note(ev, ev.id, "nfinalize", false, "salt does not match the reservation commit");
631
+ continue;
632
+ }
633
+ if (!(ev.height > n.effHeight + REG_COMMIT_MAX_BLOCKS)) {
634
+ note(ev, ev.id, "nfinalize", false, "too early \u2014 displacement contest not yet frozen");
635
+ continue;
636
+ }
637
+ if (n.finalizeBy !== void 0 && ev.height > n.finalizeBy) {
638
+ note(ev, ev.id, "nfinalize", false, "reservation expired");
639
+ continue;
640
+ }
641
+ if (feeToTreasury < nameRegFee(rec.name, ev.height)) {
642
+ note(ev, ev.id, "nfinalize", false, "name registration fee unpaid");
643
+ continue;
644
+ }
645
+ n.pending = void 0;
646
+ n.finalizeBy = void 0;
647
+ n.paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS;
648
+ feesPaid += nameRegFee(rec.name, ev.height);
649
+ note(ev, ev.id, "nfinalize", true);
572
650
  } else if (rec.t === "nxfer") {
573
651
  const n = names.get(rec.name);
574
652
  if (!n || n.owner !== who) {
575
653
  note(ev, ev.id, "nxfer", false, "not the name owner");
576
654
  continue;
577
655
  }
656
+ if (n.pending) {
657
+ note(ev, ev.id, "nxfer", false, "name reservation not yet finalized");
658
+ continue;
659
+ }
578
660
  if (v15 && lapsed(n, epochOf(ev.height))) {
579
661
  note(ev, ev.id, "nxfer", false, "lease lapsed \u2014 claim it instead");
580
662
  continue;
@@ -593,6 +675,10 @@ function resolve(events, tipHeight) {
593
675
  note(ev, ev.id, "nset", false, "not the name owner");
594
676
  continue;
595
677
  }
678
+ if (n.pending) {
679
+ note(ev, ev.id, "nset", false, "name reservation not yet finalized");
680
+ continue;
681
+ }
596
682
  if (v15 && lapsed(n, epochOf(ev.height))) {
597
683
  note(ev, ev.id, "nset", false, "lease lapsed \u2014 claim it instead");
598
684
  continue;
@@ -610,6 +696,10 @@ function resolve(events, tipHeight) {
610
696
  note(ev, ev.id, "nprofile", false, "not the name owner");
611
697
  continue;
612
698
  }
699
+ if (n.pending) {
700
+ note(ev, ev.id, "nprofile", false, "name reservation not yet finalized");
701
+ continue;
702
+ }
613
703
  if (v15 && lapsed(n, epochOf(ev.height))) {
614
704
  note(ev, ev.id, "nprofile", false, "lease lapsed \u2014 claim it instead");
615
705
  continue;
@@ -654,6 +744,10 @@ function resolve(events, tipHeight) {
654
744
  note(ev, ev.id, "offer", false, "you don't own this name");
655
745
  continue;
656
746
  }
747
+ if (n.pending) {
748
+ note(ev, ev.id, "offer", false, "name reservation not yet finalized");
749
+ continue;
750
+ }
657
751
  if (n.locked) {
658
752
  note(ev, ev.id, "offer", false, "name already locked by another offer");
659
753
  continue;
@@ -763,6 +857,10 @@ function resolve(events, tipHeight) {
763
857
  }
764
858
  const n = names.get(rec.name);
765
859
  const ep = epochOf(ev.height);
860
+ if (n && n.pending) {
861
+ note(ev, ev.id, "nrenew", false, "name reservation not yet finalized");
862
+ continue;
863
+ }
766
864
  if (!n || lapsed(n, ep)) {
767
865
  note(ev, ev.id, "nrenew", false, "no live lease (lapsed names are claimed, not renewed)");
768
866
  continue;
@@ -1042,8 +1140,13 @@ function resolve(events, tipHeight) {
1042
1140
  const namesOut = {};
1043
1141
  const tipV15 = tipHeight >= V15_HEIGHT;
1044
1142
  const tipV19 = tipHeight >= V19_HEIGHT;
1143
+ const tipV25 = tipHeight >= V25_HEIGHT;
1045
1144
  const tipEpoch = epochOf(tipHeight);
1046
1145
  for (const [nm, n] of [...names.entries()].sort(([a], [b]) => ord(a, b))) {
1146
+ if (tipV25 && n.pending) {
1147
+ namesOut[nm] = { name: nm, owner: n.owner, claimId: n.id, height: n.height, effectiveHeight: n.effHeight, locked: n.locked, pending: true, finalizeBy: n.finalizeBy };
1148
+ continue;
1149
+ }
1047
1150
  namesOut[nm] = {
1048
1151
  name: nm,
1049
1152
  owner: n.owner,
@@ -1125,12 +1228,14 @@ export {
1125
1228
  EPOCH_LEN2 as EPOCH_LEN,
1126
1229
  FEE_BPS,
1127
1230
  FEE_BPS_V16,
1231
+ FINALIZE_TIP_MARGIN,
1128
1232
  HALVING_INTERVAL,
1129
1233
  HASH_RE,
1130
1234
  INITIAL_REWARD2 as INITIAL_REWARD,
1131
1235
  MAX_ACTIVE_CLAIMS,
1132
1236
  MAX_AMOUNT,
1133
1237
  MAX_OFFER_EPOCHS,
1238
+ MAX_PENDING_REG,
1134
1239
  MAX_RECORD_BYTES,
1135
1240
  MINT_KEYS,
1136
1241
  MIN_FEE_ATTEST,
@@ -1147,6 +1252,7 @@ export {
1147
1252
  NAME_PREMIUM_START,
1148
1253
  NAME_RE,
1149
1254
  NAME_TERM_EPOCHS,
1255
+ NFINALIZE_KEYS,
1150
1256
  NPROFILE_KEYS,
1151
1257
  OFFER_KEYS,
1152
1258
  PKEY,
@@ -1154,6 +1260,8 @@ export {
1154
1260
  PROFILE_MAX_VALUE_BYTES,
1155
1261
  REBATE_BPS,
1156
1262
  REBATE_FLAT,
1263
+ REG_COMMIT_MAX_BLOCKS,
1264
+ REG_FINALIZE_GRACE_BLOCKS,
1157
1265
  RESERVED_NAMES,
1158
1266
  SALT_RE,
1159
1267
  SCORE_CANCEL,
@@ -1176,6 +1284,7 @@ export {
1176
1284
  V22_HEIGHT,
1177
1285
  V23_HEIGHT,
1178
1286
  V24_HEIGHT,
1287
+ V25_HEIGHT,
1179
1288
  ZERO_ADDR,
1180
1289
  bid,
1181
1290
  blockReward2 as blockReward,
@@ -1196,6 +1305,7 @@ export {
1196
1305
  nameClaim,
1197
1306
  nameCommit,
1198
1307
  nameCommitRecord,
1308
+ nameFinalize,
1199
1309
  nameProfile,
1200
1310
  nameRegFee,
1201
1311
  nameRenew,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inversealtruism/cairnx-core",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "CairnX — tokens, atomic DvP trades and leased .csd names on Compute Substrate, as a pure deterministic convention library (Ordinals/Runes class). Ships the normative CONVENTION.md and the conformance vectors.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",