@inversealtruism/cairnx-core 0.1.9 → 0.1.12
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 +73 -8
- package/dist/index.d.cts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +65 -8
- package/package.json +8 -8
- package/test/vectors/cases.json +248 -0
package/dist/index.cjs
CHANGED
|
@@ -36,11 +36,16 @@ __export(index_exports, {
|
|
|
36
36
|
MAX_ACTIVE_CLAIMS: () => MAX_ACTIVE_CLAIMS,
|
|
37
37
|
MAX_AMOUNT: () => MAX_AMOUNT,
|
|
38
38
|
MAX_RECORD_BYTES: () => MAX_RECORD_BYTES,
|
|
39
|
+
NAME_FEE_SHORT_V18: () => NAME_FEE_SHORT_V18,
|
|
40
|
+
NAME_FEE_V18: () => NAME_FEE_V18,
|
|
39
41
|
NAME_GRACE_EPOCHS: () => NAME_GRACE_EPOCHS,
|
|
40
42
|
NAME_PREMIUM_DECAY_EPOCHS: () => NAME_PREMIUM_DECAY_EPOCHS,
|
|
41
43
|
NAME_PREMIUM_START: () => NAME_PREMIUM_START,
|
|
42
44
|
NAME_RE: () => NAME_RE,
|
|
43
45
|
NAME_TERM_EPOCHS: () => NAME_TERM_EPOCHS,
|
|
46
|
+
PKEY: () => PKEY,
|
|
47
|
+
PROFILE_MAX_KEYS: () => PROFILE_MAX_KEYS,
|
|
48
|
+
PROFILE_MAX_VALUE_BYTES: () => PROFILE_MAX_VALUE_BYTES,
|
|
44
49
|
REBATE_BPS: () => REBATE_BPS,
|
|
45
50
|
REBATE_FLAT: () => REBATE_FLAT,
|
|
46
51
|
RESERVED_NAMES: () => RESERVED_NAMES,
|
|
@@ -56,6 +61,8 @@ __export(index_exports, {
|
|
|
56
61
|
V15_HEIGHT: () => V15_HEIGHT,
|
|
57
62
|
V16_HEIGHT: () => V16_HEIGHT,
|
|
58
63
|
V17_HEIGHT: () => V17_HEIGHT,
|
|
64
|
+
V18_HEIGHT: () => V18_HEIGHT,
|
|
65
|
+
V19_HEIGHT: () => V19_HEIGHT,
|
|
59
66
|
bid: () => bid,
|
|
60
67
|
buildRecord: () => buildRecord,
|
|
61
68
|
canonicalState: () => canonicalState,
|
|
@@ -70,6 +77,7 @@ __export(index_exports, {
|
|
|
70
77
|
nameClaim: () => nameClaim,
|
|
71
78
|
nameCommit: () => nameCommit,
|
|
72
79
|
nameCommitRecord: () => nameCommitRecord,
|
|
80
|
+
nameProfile: () => nameProfile,
|
|
73
81
|
nameRegFee: () => nameRegFee,
|
|
74
82
|
nameRenew: () => nameRenew,
|
|
75
83
|
nameSet: () => nameSet,
|
|
@@ -100,8 +108,8 @@ var NAME_TERM_EPOCHS = 8760;
|
|
|
100
108
|
var NAME_GRACE_EPOCHS = 720;
|
|
101
109
|
var NAME_PREMIUM_START = 20n;
|
|
102
110
|
var NAME_PREMIUM_DECAY_EPOCHS = 720;
|
|
103
|
-
function expiredClaimFee(name, epochsPastGraceEnd) {
|
|
104
|
-
const base = nameRegFee(name);
|
|
111
|
+
function expiredClaimFee(name, epochsPastGraceEnd, height) {
|
|
112
|
+
const base = nameRegFee(name, height);
|
|
105
113
|
if (epochsPastGraceEnd >= NAME_PREMIUM_DECAY_EPOCHS) return base;
|
|
106
114
|
const left = BigInt(NAME_PREMIUM_DECAY_EPOCHS - epochsPastGraceEnd);
|
|
107
115
|
const mult = 1n + (NAME_PREMIUM_START - 1n) * left / BigInt(NAME_PREMIUM_DECAY_EPOCHS);
|
|
@@ -122,7 +130,15 @@ var FEE_BPS_V16 = 150;
|
|
|
122
130
|
var REBATE_FLAT = 25000000n;
|
|
123
131
|
var REBATE_BPS = 50;
|
|
124
132
|
var DEPLOY_FEE = 1e8;
|
|
125
|
-
|
|
133
|
+
var V18_HEIGHT = 4e4;
|
|
134
|
+
var NAME_FEE_SHORT_V18 = 670000000n;
|
|
135
|
+
var NAME_FEE_V18 = 300000000n;
|
|
136
|
+
var V19_HEIGHT = 36700;
|
|
137
|
+
var PKEY = /^[a-z0-9](?:[a-z0-9.-]{0,30}[a-z0-9])?$/;
|
|
138
|
+
var PROFILE_MAX_KEYS = 16;
|
|
139
|
+
var PROFILE_MAX_VALUE_BYTES = 256;
|
|
140
|
+
function nameRegFee(name, height) {
|
|
141
|
+
if (height >= V18_HEIGHT) return name.length <= 4 ? NAME_FEE_SHORT_V18 : NAME_FEE_V18;
|
|
126
142
|
const n = name.length;
|
|
127
143
|
if (n <= 3) return 500000000n;
|
|
128
144
|
if (n === 4) return 200000000n;
|
|
@@ -192,6 +208,7 @@ var TRANSFER_KEYS = /* @__PURE__ */ new Set(["v", "t", "ticker", "to", "amount",
|
|
|
192
208
|
var OFFER_KEYS = /* @__PURE__ */ new Set(["v", "t", "give", "want", "min", "bid", "taker", "memo", "ts"]);
|
|
193
209
|
var BID_KEYS = /* @__PURE__ */ new Set(["v", "t", "want", "give", "memo", "ts"]);
|
|
194
210
|
var NAME_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "salt"]);
|
|
211
|
+
var NPROFILE_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "p"]);
|
|
195
212
|
function parseRecord(uri, payloadHashHex) {
|
|
196
213
|
if (new TextEncoder().encode(uri).length > MAX_RECORD_BYTES) return null;
|
|
197
214
|
let obj;
|
|
@@ -318,6 +335,21 @@ function parseRecord(uri, payloadHashHex) {
|
|
|
318
335
|
if (Object.keys(r).length !== 3) return null;
|
|
319
336
|
return r;
|
|
320
337
|
}
|
|
338
|
+
case "nprofile": {
|
|
339
|
+
if (!onlyKeys(r, NPROFILE_KEYS)) return null;
|
|
340
|
+
if (!isName(r.name)) return null;
|
|
341
|
+
const p = r.p;
|
|
342
|
+
if (!p || typeof p !== "object" || Array.isArray(p)) return null;
|
|
343
|
+
const keys = Object.keys(p);
|
|
344
|
+
if (keys.length > PROFILE_MAX_KEYS) return null;
|
|
345
|
+
for (const k of keys) {
|
|
346
|
+
if (!PKEY.test(k)) return null;
|
|
347
|
+
const val = p[k];
|
|
348
|
+
if (typeof val !== "string") return null;
|
|
349
|
+
if (new TextEncoder().encode(val).length > PROFILE_MAX_VALUE_BYTES) return null;
|
|
350
|
+
}
|
|
351
|
+
return r;
|
|
352
|
+
}
|
|
321
353
|
case "tmeta": {
|
|
322
354
|
if (!isTicker(r.ticker)) return null;
|
|
323
355
|
if (typeof r.hash !== "string" || !/^0x[0-9a-f]{64}$/.test(r.hash)) return null;
|
|
@@ -347,6 +379,7 @@ var nameXfer = (r) => buildRecord({ v: 1, t: "nxfer", ...r });
|
|
|
347
379
|
var nameSet = (r) => buildRecord({ v: 1, t: "nset", ...r });
|
|
348
380
|
var nameRenew = (r) => buildRecord({ v: 1, t: "nrenew", ...r });
|
|
349
381
|
var tokenMeta = (r) => buildRecord({ v: 1, t: "tmeta", ...r });
|
|
382
|
+
var nameProfile = (r) => buildRecord({ v: 1, t: "nprofile", ...r });
|
|
350
383
|
|
|
351
384
|
// src/resolve.ts
|
|
352
385
|
var ord = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
@@ -430,6 +463,7 @@ function resolve(events, tipHeight) {
|
|
|
430
463
|
const v12 = ev.height >= V12_HEIGHT;
|
|
431
464
|
const v15 = ev.height >= V15_HEIGHT;
|
|
432
465
|
const v16 = ev.height >= V16_HEIGHT;
|
|
466
|
+
const v19 = ev.height >= V19_HEIGHT;
|
|
433
467
|
const feeToTreasury = ev.kind === "propose" ? BigInt((ev.paidTo ?? {})[TREASURY_ADDR] ?? "0") : 0n;
|
|
434
468
|
if (ev.kind === "propose") {
|
|
435
469
|
const rec = parseRecord(ev.uri, ev.payloadHash);
|
|
@@ -528,7 +562,7 @@ function resolve(events, tipHeight) {
|
|
|
528
562
|
const cur = names.get(rec.name);
|
|
529
563
|
const epClaim = epochOf(ev.height);
|
|
530
564
|
if (cur && v15 && lapsed(cur, epClaim)) {
|
|
531
|
-
const fee = expiredClaimFee(rec.name, epClaim - (paidThrough(cur) + NAME_GRACE_EPOCHS));
|
|
565
|
+
const fee = expiredClaimFee(rec.name, epClaim - (paidThrough(cur) + NAME_GRACE_EPOCHS), ev.height);
|
|
532
566
|
if (feeToTreasury < fee) {
|
|
533
567
|
note(ev, ev.id, "name", false, "lapsed-name claim fee unpaid (decaying premium)");
|
|
534
568
|
continue;
|
|
@@ -542,7 +576,7 @@ function resolve(events, tipHeight) {
|
|
|
542
576
|
note(ev, ev.id, "name", true, "lapsed lease re-claimed (premium)");
|
|
543
577
|
continue;
|
|
544
578
|
}
|
|
545
|
-
if (feeToTreasury < nameRegFee(rec.name)) {
|
|
579
|
+
if (feeToTreasury < nameRegFee(rec.name, ev.height)) {
|
|
546
580
|
note(ev, ev.id, "name", false, "name registration fee unpaid");
|
|
547
581
|
continue;
|
|
548
582
|
}
|
|
@@ -567,7 +601,7 @@ function resolve(events, tipHeight) {
|
|
|
567
601
|
}
|
|
568
602
|
}
|
|
569
603
|
names.set(rec.name, cand);
|
|
570
|
-
feesPaid += nameRegFee(rec.name);
|
|
604
|
+
feesPaid += nameRegFee(rec.name, ev.height);
|
|
571
605
|
note(ev, ev.id, "name", true, cur ? "displaced prior holder" : void 0);
|
|
572
606
|
} else if (rec.t === "nxfer") {
|
|
573
607
|
const n = names.get(rec.name);
|
|
@@ -585,6 +619,7 @@ function resolve(events, tipHeight) {
|
|
|
585
619
|
}
|
|
586
620
|
n.owner = rec.to.toLowerCase();
|
|
587
621
|
n.addr = void 0;
|
|
622
|
+
n.profile = void 0;
|
|
588
623
|
note(ev, ev.id, "nxfer", true);
|
|
589
624
|
} else if (rec.t === "nset") {
|
|
590
625
|
const n = names.get(rec.name);
|
|
@@ -598,6 +633,22 @@ function resolve(events, tipHeight) {
|
|
|
598
633
|
}
|
|
599
634
|
n.addr = rec.addr.toLowerCase();
|
|
600
635
|
note(ev, ev.id, "nset", true);
|
|
636
|
+
} else if (rec.t === "nprofile") {
|
|
637
|
+
if (!v19) {
|
|
638
|
+
note(ev, ev.id, "nprofile", false, "before v1.9 activation");
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
const n = names.get(rec.name);
|
|
642
|
+
if (!n || n.owner !== who) {
|
|
643
|
+
note(ev, ev.id, "nprofile", false, "not the name owner");
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
if (v15 && lapsed(n, epochOf(ev.height))) {
|
|
647
|
+
note(ev, ev.id, "nprofile", false, "lease lapsed \u2014 claim it instead");
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
n.profile = Object.keys(rec.p).length ? { ...rec.p } : void 0;
|
|
651
|
+
note(ev, ev.id, "nprofile", true);
|
|
601
652
|
} else if (rec.t === "offer") {
|
|
602
653
|
const wantIsToken = isTokenWant(rec.want);
|
|
603
654
|
if ((wantIsToken || rec.min !== void 0 || rec.bid !== void 0) && !v12) {
|
|
@@ -745,12 +796,12 @@ function resolve(events, tipHeight) {
|
|
|
745
796
|
note(ev, ev.id, "nrenew", false, "grace period: only the owner may renew");
|
|
746
797
|
continue;
|
|
747
798
|
}
|
|
748
|
-
if (feeToTreasury < nameRegFee(rec.name)) {
|
|
799
|
+
if (feeToTreasury < nameRegFee(rec.name, ev.height)) {
|
|
749
800
|
note(ev, ev.id, "nrenew", false, "renewal fee unpaid");
|
|
750
801
|
continue;
|
|
751
802
|
}
|
|
752
803
|
n.paidThroughEpoch = paidThrough(n) + NAME_TERM_EPOCHS;
|
|
753
|
-
feesPaid += nameRegFee(rec.name);
|
|
804
|
+
feesPaid += nameRegFee(rec.name, ev.height);
|
|
754
805
|
note(ev, ev.id, "nrenew", true, `paid through epoch ${n.paidThroughEpoch}`);
|
|
755
806
|
} else if (rec.t === "tmeta") {
|
|
756
807
|
if (!v15) {
|
|
@@ -851,6 +902,7 @@ function resolve(events, tipHeight) {
|
|
|
851
902
|
giveName.owner = who;
|
|
852
903
|
giveName.locked = false;
|
|
853
904
|
giveName.addr = void 0;
|
|
905
|
+
giveName.profile = void 0;
|
|
854
906
|
if (ev.height >= V13_HEIGHT) {
|
|
855
907
|
giveName.effHeight = ev.height;
|
|
856
908
|
giveName.pos = ev.pos;
|
|
@@ -980,6 +1032,7 @@ function resolve(events, tipHeight) {
|
|
|
980
1032
|
n.owner = who;
|
|
981
1033
|
n.locked = false;
|
|
982
1034
|
n.addr = void 0;
|
|
1035
|
+
n.profile = void 0;
|
|
983
1036
|
if (ev.height >= V13_HEIGHT) {
|
|
984
1037
|
n.effHeight = ev.height;
|
|
985
1038
|
n.pos = ev.pos;
|
|
@@ -1050,6 +1103,7 @@ function resolve(events, tipHeight) {
|
|
|
1050
1103
|
}
|
|
1051
1104
|
const namesOut = {};
|
|
1052
1105
|
const tipV15 = tipHeight >= V15_HEIGHT;
|
|
1106
|
+
const tipV19 = tipHeight >= V19_HEIGHT;
|
|
1053
1107
|
const tipEpoch = epochOf(tipHeight);
|
|
1054
1108
|
for (const [nm, n] of [...names.entries()].sort(([a], [b]) => ord(a, b))) {
|
|
1055
1109
|
namesOut[nm] = {
|
|
@@ -1061,6 +1115,9 @@ function resolve(events, tipHeight) {
|
|
|
1061
1115
|
locked: n.locked,
|
|
1062
1116
|
...n.addr ? { addr: n.addr } : {},
|
|
1063
1117
|
...n.viaFill ? { viaFill: true } : {},
|
|
1118
|
+
// v1.9 profile materialized at v1.9+ tips ONLY (the apply is also gated) → every pre-v1.9 canonical
|
|
1119
|
+
// hash stays byte-identical; absent when empty/unset.
|
|
1120
|
+
...tipV19 && n.profile ? { profile: n.profile } : {},
|
|
1064
1121
|
// lease fields exist only at v1.5+ tips so every pre-v1.5 canonical hash stays pinned
|
|
1065
1122
|
...tipV15 ? { paidThroughEpoch: paidThrough(n), ...lapsed(n, tipEpoch) ? { expired: true } : {} } : {}
|
|
1066
1123
|
};
|
|
@@ -1100,11 +1157,16 @@ function canonicalState(s) {
|
|
|
1100
1157
|
MAX_ACTIVE_CLAIMS,
|
|
1101
1158
|
MAX_AMOUNT,
|
|
1102
1159
|
MAX_RECORD_BYTES,
|
|
1160
|
+
NAME_FEE_SHORT_V18,
|
|
1161
|
+
NAME_FEE_V18,
|
|
1103
1162
|
NAME_GRACE_EPOCHS,
|
|
1104
1163
|
NAME_PREMIUM_DECAY_EPOCHS,
|
|
1105
1164
|
NAME_PREMIUM_START,
|
|
1106
1165
|
NAME_RE,
|
|
1107
1166
|
NAME_TERM_EPOCHS,
|
|
1167
|
+
PKEY,
|
|
1168
|
+
PROFILE_MAX_KEYS,
|
|
1169
|
+
PROFILE_MAX_VALUE_BYTES,
|
|
1108
1170
|
REBATE_BPS,
|
|
1109
1171
|
REBATE_FLAT,
|
|
1110
1172
|
RESERVED_NAMES,
|
|
@@ -1120,6 +1182,8 @@ function canonicalState(s) {
|
|
|
1120
1182
|
V15_HEIGHT,
|
|
1121
1183
|
V16_HEIGHT,
|
|
1122
1184
|
V17_HEIGHT,
|
|
1185
|
+
V18_HEIGHT,
|
|
1186
|
+
V19_HEIGHT,
|
|
1123
1187
|
bid,
|
|
1124
1188
|
buildRecord,
|
|
1125
1189
|
canonicalState,
|
|
@@ -1134,6 +1198,7 @@ function canonicalState(s) {
|
|
|
1134
1198
|
nameClaim,
|
|
1135
1199
|
nameCommit,
|
|
1136
1200
|
nameCommitRecord,
|
|
1201
|
+
nameProfile,
|
|
1137
1202
|
nameRegFee,
|
|
1138
1203
|
nameRenew,
|
|
1139
1204
|
nameSet,
|
package/dist/index.d.cts
CHANGED
|
@@ -14,7 +14,7 @@ declare const NAME_PREMIUM_START = 20n;
|
|
|
14
14
|
declare const NAME_PREMIUM_DECAY_EPOCHS = 720;
|
|
15
15
|
/** Fee to claim a name whose lease lapsed (grace over): nameRegFee × a linearly-decaying
|
|
16
16
|
* premium. Pure in (name, epochsPastGraceEnd) — deterministic for every resolver. */
|
|
17
|
-
declare function expiredClaimFee(name: string, epochsPastGraceEnd: number): bigint;
|
|
17
|
+
declare function expiredClaimFee(name: string, epochsPastGraceEnd: number, height: number): bigint;
|
|
18
18
|
declare const MAX_RECORD_BYTES = 512;
|
|
19
19
|
declare const MAX_AMOUNT: bigint;
|
|
20
20
|
declare const SCORE_FILL = 100;
|
|
@@ -30,7 +30,14 @@ declare const FEE_BPS_V16 = 150;
|
|
|
30
30
|
declare const REBATE_FLAT = 25000000n;
|
|
31
31
|
declare const REBATE_BPS = 50;
|
|
32
32
|
declare const DEPLOY_FEE = 100000000;
|
|
33
|
-
declare
|
|
33
|
+
declare const V18_HEIGHT = 40000;
|
|
34
|
+
declare const NAME_FEE_SHORT_V18 = 670000000n;
|
|
35
|
+
declare const NAME_FEE_V18 = 300000000n;
|
|
36
|
+
declare const V19_HEIGHT = 36700;
|
|
37
|
+
declare const PKEY: RegExp;
|
|
38
|
+
declare const PROFILE_MAX_KEYS = 16;
|
|
39
|
+
declare const PROFILE_MAX_VALUE_BYTES = 256;
|
|
40
|
+
declare function nameRegFee(name: string, height: number): bigint;
|
|
34
41
|
declare const tradeFee: (want: bigint, bps?: number) => bigint;
|
|
35
42
|
declare const makerRebate: (value: bigint) => bigint;
|
|
36
43
|
declare const TICKER_RE: RegExp;
|
|
@@ -148,7 +155,13 @@ interface TokenMetaRecord {
|
|
|
148
155
|
ticker: string;
|
|
149
156
|
hash: string;
|
|
150
157
|
}
|
|
151
|
-
|
|
158
|
+
interface NameProfileRecord {
|
|
159
|
+
v: 1;
|
|
160
|
+
t: "nprofile";
|
|
161
|
+
name: string;
|
|
162
|
+
p: Record<string, string>;
|
|
163
|
+
}
|
|
164
|
+
type CairnXRecord = DeployRecord | MintRecord | TransferRecord | OfferRecord | BidRecord | OfferCancelAllRecord | NameCommitRecord | NameRecord | NameXferRecord | NameSetRecord | NameRenewRecord | TokenMetaRecord | NameProfileRecord;
|
|
152
165
|
interface ProposeEvent {
|
|
153
166
|
kind: "propose";
|
|
154
167
|
id: string;
|
|
@@ -204,6 +217,10 @@ interface NameState {
|
|
|
204
217
|
paidThroughEpoch?: number;
|
|
205
218
|
/** v1.5: true once the lease + grace lapsed (record kept for history; name is claimable) */
|
|
206
219
|
expired?: true;
|
|
220
|
+
/** v1.9: ENS-class identity — a charset-locked string→string map (doc 36). INERT cosmetic metadata
|
|
221
|
+
* (NOT a send target; the verified address is `addr`). Materialized at v1.9+ tips only, cleared on
|
|
222
|
+
* every ownership change, absent when empty. */
|
|
223
|
+
profile?: Record<string, string>;
|
|
207
224
|
}
|
|
208
225
|
type OfferStatus = "open" | "filled" | "cancelled" | "expired";
|
|
209
226
|
interface FillEntry {
|
|
@@ -325,6 +342,7 @@ declare const nameXfer: (r: Omit<NameXferRecord, "v" | "t">) => BuiltRecord;
|
|
|
325
342
|
declare const nameSet: (r: Omit<NameSetRecord, "v" | "t">) => BuiltRecord;
|
|
326
343
|
declare const nameRenew: (r: Omit<NameRenewRecord, "v" | "t">) => BuiltRecord;
|
|
327
344
|
declare const tokenMeta: (r: Omit<TokenMetaRecord, "v" | "t">) => BuiltRecord;
|
|
345
|
+
declare const nameProfile: (r: Omit<NameProfileRecord, "v" | "t">) => BuiltRecord;
|
|
328
346
|
|
|
329
347
|
declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
330
348
|
/** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
|
|
@@ -336,4 +354,4 @@ declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
|
336
354
|
* history.) Keys sort in ordinal (code-unit) order at every depth. */
|
|
337
355
|
declare function canonicalState(s: CairnXState): string;
|
|
338
356
|
|
|
339
|
-
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_COOLDOWN_BLOCKS, CLAIM_WINDOW_BLOCKS, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, EPOCH_LEN, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_RECORD_BYTES, type MintRecord, NAME_GRACE_EPOCHS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, type NameCommitRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
|
|
357
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_COOLDOWN_BLOCKS, CLAIM_WINDOW_BLOCKS, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, EPOCH_LEN, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_RECORD_BYTES, type MintRecord, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, type NameCommitRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, 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, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare const NAME_PREMIUM_START = 20n;
|
|
|
14
14
|
declare const NAME_PREMIUM_DECAY_EPOCHS = 720;
|
|
15
15
|
/** Fee to claim a name whose lease lapsed (grace over): nameRegFee × a linearly-decaying
|
|
16
16
|
* premium. Pure in (name, epochsPastGraceEnd) — deterministic for every resolver. */
|
|
17
|
-
declare function expiredClaimFee(name: string, epochsPastGraceEnd: number): bigint;
|
|
17
|
+
declare function expiredClaimFee(name: string, epochsPastGraceEnd: number, height: number): bigint;
|
|
18
18
|
declare const MAX_RECORD_BYTES = 512;
|
|
19
19
|
declare const MAX_AMOUNT: bigint;
|
|
20
20
|
declare const SCORE_FILL = 100;
|
|
@@ -30,7 +30,14 @@ declare const FEE_BPS_V16 = 150;
|
|
|
30
30
|
declare const REBATE_FLAT = 25000000n;
|
|
31
31
|
declare const REBATE_BPS = 50;
|
|
32
32
|
declare const DEPLOY_FEE = 100000000;
|
|
33
|
-
declare
|
|
33
|
+
declare const V18_HEIGHT = 40000;
|
|
34
|
+
declare const NAME_FEE_SHORT_V18 = 670000000n;
|
|
35
|
+
declare const NAME_FEE_V18 = 300000000n;
|
|
36
|
+
declare const V19_HEIGHT = 36700;
|
|
37
|
+
declare const PKEY: RegExp;
|
|
38
|
+
declare const PROFILE_MAX_KEYS = 16;
|
|
39
|
+
declare const PROFILE_MAX_VALUE_BYTES = 256;
|
|
40
|
+
declare function nameRegFee(name: string, height: number): bigint;
|
|
34
41
|
declare const tradeFee: (want: bigint, bps?: number) => bigint;
|
|
35
42
|
declare const makerRebate: (value: bigint) => bigint;
|
|
36
43
|
declare const TICKER_RE: RegExp;
|
|
@@ -148,7 +155,13 @@ interface TokenMetaRecord {
|
|
|
148
155
|
ticker: string;
|
|
149
156
|
hash: string;
|
|
150
157
|
}
|
|
151
|
-
|
|
158
|
+
interface NameProfileRecord {
|
|
159
|
+
v: 1;
|
|
160
|
+
t: "nprofile";
|
|
161
|
+
name: string;
|
|
162
|
+
p: Record<string, string>;
|
|
163
|
+
}
|
|
164
|
+
type CairnXRecord = DeployRecord | MintRecord | TransferRecord | OfferRecord | BidRecord | OfferCancelAllRecord | NameCommitRecord | NameRecord | NameXferRecord | NameSetRecord | NameRenewRecord | TokenMetaRecord | NameProfileRecord;
|
|
152
165
|
interface ProposeEvent {
|
|
153
166
|
kind: "propose";
|
|
154
167
|
id: string;
|
|
@@ -204,6 +217,10 @@ interface NameState {
|
|
|
204
217
|
paidThroughEpoch?: number;
|
|
205
218
|
/** v1.5: true once the lease + grace lapsed (record kept for history; name is claimable) */
|
|
206
219
|
expired?: true;
|
|
220
|
+
/** v1.9: ENS-class identity — a charset-locked string→string map (doc 36). INERT cosmetic metadata
|
|
221
|
+
* (NOT a send target; the verified address is `addr`). Materialized at v1.9+ tips only, cleared on
|
|
222
|
+
* every ownership change, absent when empty. */
|
|
223
|
+
profile?: Record<string, string>;
|
|
207
224
|
}
|
|
208
225
|
type OfferStatus = "open" | "filled" | "cancelled" | "expired";
|
|
209
226
|
interface FillEntry {
|
|
@@ -325,6 +342,7 @@ declare const nameXfer: (r: Omit<NameXferRecord, "v" | "t">) => BuiltRecord;
|
|
|
325
342
|
declare const nameSet: (r: Omit<NameSetRecord, "v" | "t">) => BuiltRecord;
|
|
326
343
|
declare const nameRenew: (r: Omit<NameRenewRecord, "v" | "t">) => BuiltRecord;
|
|
327
344
|
declare const tokenMeta: (r: Omit<TokenMetaRecord, "v" | "t">) => BuiltRecord;
|
|
345
|
+
declare const nameProfile: (r: Omit<NameProfileRecord, "v" | "t">) => BuiltRecord;
|
|
328
346
|
|
|
329
347
|
declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
330
348
|
/** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
|
|
@@ -336,4 +354,4 @@ declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
|
336
354
|
* history.) Keys sort in ordinal (code-unit) order at every depth. */
|
|
337
355
|
declare function canonicalState(s: CairnXState): string;
|
|
338
356
|
|
|
339
|
-
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_COOLDOWN_BLOCKS, CLAIM_WINDOW_BLOCKS, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, EPOCH_LEN, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_RECORD_BYTES, type MintRecord, NAME_GRACE_EPOCHS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, type NameCommitRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
|
|
357
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_COOLDOWN_BLOCKS, CLAIM_WINDOW_BLOCKS, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, EPOCH_LEN, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_RECORD_BYTES, type MintRecord, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, type NameCommitRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, 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, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
|
package/dist/index.js
CHANGED
|
@@ -13,8 +13,8 @@ var NAME_TERM_EPOCHS = 8760;
|
|
|
13
13
|
var NAME_GRACE_EPOCHS = 720;
|
|
14
14
|
var NAME_PREMIUM_START = 20n;
|
|
15
15
|
var NAME_PREMIUM_DECAY_EPOCHS = 720;
|
|
16
|
-
function expiredClaimFee(name, epochsPastGraceEnd) {
|
|
17
|
-
const base = nameRegFee(name);
|
|
16
|
+
function expiredClaimFee(name, epochsPastGraceEnd, height) {
|
|
17
|
+
const base = nameRegFee(name, height);
|
|
18
18
|
if (epochsPastGraceEnd >= NAME_PREMIUM_DECAY_EPOCHS) return base;
|
|
19
19
|
const left = BigInt(NAME_PREMIUM_DECAY_EPOCHS - epochsPastGraceEnd);
|
|
20
20
|
const mult = 1n + (NAME_PREMIUM_START - 1n) * left / BigInt(NAME_PREMIUM_DECAY_EPOCHS);
|
|
@@ -35,7 +35,15 @@ var FEE_BPS_V16 = 150;
|
|
|
35
35
|
var REBATE_FLAT = 25000000n;
|
|
36
36
|
var REBATE_BPS = 50;
|
|
37
37
|
var DEPLOY_FEE = 1e8;
|
|
38
|
-
|
|
38
|
+
var V18_HEIGHT = 4e4;
|
|
39
|
+
var NAME_FEE_SHORT_V18 = 670000000n;
|
|
40
|
+
var NAME_FEE_V18 = 300000000n;
|
|
41
|
+
var V19_HEIGHT = 36700;
|
|
42
|
+
var PKEY = /^[a-z0-9](?:[a-z0-9.-]{0,30}[a-z0-9])?$/;
|
|
43
|
+
var PROFILE_MAX_KEYS = 16;
|
|
44
|
+
var PROFILE_MAX_VALUE_BYTES = 256;
|
|
45
|
+
function nameRegFee(name, height) {
|
|
46
|
+
if (height >= V18_HEIGHT) return name.length <= 4 ? NAME_FEE_SHORT_V18 : NAME_FEE_V18;
|
|
39
47
|
const n = name.length;
|
|
40
48
|
if (n <= 3) return 500000000n;
|
|
41
49
|
if (n === 4) return 200000000n;
|
|
@@ -105,6 +113,7 @@ var TRANSFER_KEYS = /* @__PURE__ */ new Set(["v", "t", "ticker", "to", "amount",
|
|
|
105
113
|
var OFFER_KEYS = /* @__PURE__ */ new Set(["v", "t", "give", "want", "min", "bid", "taker", "memo", "ts"]);
|
|
106
114
|
var BID_KEYS = /* @__PURE__ */ new Set(["v", "t", "want", "give", "memo", "ts"]);
|
|
107
115
|
var NAME_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "salt"]);
|
|
116
|
+
var NPROFILE_KEYS = /* @__PURE__ */ new Set(["v", "t", "name", "p"]);
|
|
108
117
|
function parseRecord(uri, payloadHashHex) {
|
|
109
118
|
if (new TextEncoder().encode(uri).length > MAX_RECORD_BYTES) return null;
|
|
110
119
|
let obj;
|
|
@@ -231,6 +240,21 @@ function parseRecord(uri, payloadHashHex) {
|
|
|
231
240
|
if (Object.keys(r).length !== 3) return null;
|
|
232
241
|
return r;
|
|
233
242
|
}
|
|
243
|
+
case "nprofile": {
|
|
244
|
+
if (!onlyKeys(r, NPROFILE_KEYS)) return null;
|
|
245
|
+
if (!isName(r.name)) return null;
|
|
246
|
+
const p = r.p;
|
|
247
|
+
if (!p || typeof p !== "object" || Array.isArray(p)) return null;
|
|
248
|
+
const keys = Object.keys(p);
|
|
249
|
+
if (keys.length > PROFILE_MAX_KEYS) return null;
|
|
250
|
+
for (const k of keys) {
|
|
251
|
+
if (!PKEY.test(k)) return null;
|
|
252
|
+
const val = p[k];
|
|
253
|
+
if (typeof val !== "string") return null;
|
|
254
|
+
if (new TextEncoder().encode(val).length > PROFILE_MAX_VALUE_BYTES) return null;
|
|
255
|
+
}
|
|
256
|
+
return r;
|
|
257
|
+
}
|
|
234
258
|
case "tmeta": {
|
|
235
259
|
if (!isTicker(r.ticker)) return null;
|
|
236
260
|
if (typeof r.hash !== "string" || !/^0x[0-9a-f]{64}$/.test(r.hash)) return null;
|
|
@@ -260,6 +284,7 @@ var nameXfer = (r) => buildRecord({ v: 1, t: "nxfer", ...r });
|
|
|
260
284
|
var nameSet = (r) => buildRecord({ v: 1, t: "nset", ...r });
|
|
261
285
|
var nameRenew = (r) => buildRecord({ v: 1, t: "nrenew", ...r });
|
|
262
286
|
var tokenMeta = (r) => buildRecord({ v: 1, t: "tmeta", ...r });
|
|
287
|
+
var nameProfile = (r) => buildRecord({ v: 1, t: "nprofile", ...r });
|
|
263
288
|
|
|
264
289
|
// src/resolve.ts
|
|
265
290
|
var ord = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
@@ -343,6 +368,7 @@ function resolve(events, tipHeight) {
|
|
|
343
368
|
const v12 = ev.height >= V12_HEIGHT;
|
|
344
369
|
const v15 = ev.height >= V15_HEIGHT;
|
|
345
370
|
const v16 = ev.height >= V16_HEIGHT;
|
|
371
|
+
const v19 = ev.height >= V19_HEIGHT;
|
|
346
372
|
const feeToTreasury = ev.kind === "propose" ? BigInt((ev.paidTo ?? {})[TREASURY_ADDR] ?? "0") : 0n;
|
|
347
373
|
if (ev.kind === "propose") {
|
|
348
374
|
const rec = parseRecord(ev.uri, ev.payloadHash);
|
|
@@ -441,7 +467,7 @@ function resolve(events, tipHeight) {
|
|
|
441
467
|
const cur = names.get(rec.name);
|
|
442
468
|
const epClaim = epochOf(ev.height);
|
|
443
469
|
if (cur && v15 && lapsed(cur, epClaim)) {
|
|
444
|
-
const fee = expiredClaimFee(rec.name, epClaim - (paidThrough(cur) + NAME_GRACE_EPOCHS));
|
|
470
|
+
const fee = expiredClaimFee(rec.name, epClaim - (paidThrough(cur) + NAME_GRACE_EPOCHS), ev.height);
|
|
445
471
|
if (feeToTreasury < fee) {
|
|
446
472
|
note(ev, ev.id, "name", false, "lapsed-name claim fee unpaid (decaying premium)");
|
|
447
473
|
continue;
|
|
@@ -455,7 +481,7 @@ function resolve(events, tipHeight) {
|
|
|
455
481
|
note(ev, ev.id, "name", true, "lapsed lease re-claimed (premium)");
|
|
456
482
|
continue;
|
|
457
483
|
}
|
|
458
|
-
if (feeToTreasury < nameRegFee(rec.name)) {
|
|
484
|
+
if (feeToTreasury < nameRegFee(rec.name, ev.height)) {
|
|
459
485
|
note(ev, ev.id, "name", false, "name registration fee unpaid");
|
|
460
486
|
continue;
|
|
461
487
|
}
|
|
@@ -480,7 +506,7 @@ function resolve(events, tipHeight) {
|
|
|
480
506
|
}
|
|
481
507
|
}
|
|
482
508
|
names.set(rec.name, cand);
|
|
483
|
-
feesPaid += nameRegFee(rec.name);
|
|
509
|
+
feesPaid += nameRegFee(rec.name, ev.height);
|
|
484
510
|
note(ev, ev.id, "name", true, cur ? "displaced prior holder" : void 0);
|
|
485
511
|
} else if (rec.t === "nxfer") {
|
|
486
512
|
const n = names.get(rec.name);
|
|
@@ -498,6 +524,7 @@ function resolve(events, tipHeight) {
|
|
|
498
524
|
}
|
|
499
525
|
n.owner = rec.to.toLowerCase();
|
|
500
526
|
n.addr = void 0;
|
|
527
|
+
n.profile = void 0;
|
|
501
528
|
note(ev, ev.id, "nxfer", true);
|
|
502
529
|
} else if (rec.t === "nset") {
|
|
503
530
|
const n = names.get(rec.name);
|
|
@@ -511,6 +538,22 @@ function resolve(events, tipHeight) {
|
|
|
511
538
|
}
|
|
512
539
|
n.addr = rec.addr.toLowerCase();
|
|
513
540
|
note(ev, ev.id, "nset", true);
|
|
541
|
+
} else if (rec.t === "nprofile") {
|
|
542
|
+
if (!v19) {
|
|
543
|
+
note(ev, ev.id, "nprofile", false, "before v1.9 activation");
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
const n = names.get(rec.name);
|
|
547
|
+
if (!n || n.owner !== who) {
|
|
548
|
+
note(ev, ev.id, "nprofile", false, "not the name owner");
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
if (v15 && lapsed(n, epochOf(ev.height))) {
|
|
552
|
+
note(ev, ev.id, "nprofile", false, "lease lapsed \u2014 claim it instead");
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
n.profile = Object.keys(rec.p).length ? { ...rec.p } : void 0;
|
|
556
|
+
note(ev, ev.id, "nprofile", true);
|
|
514
557
|
} else if (rec.t === "offer") {
|
|
515
558
|
const wantIsToken = isTokenWant(rec.want);
|
|
516
559
|
if ((wantIsToken || rec.min !== void 0 || rec.bid !== void 0) && !v12) {
|
|
@@ -658,12 +701,12 @@ function resolve(events, tipHeight) {
|
|
|
658
701
|
note(ev, ev.id, "nrenew", false, "grace period: only the owner may renew");
|
|
659
702
|
continue;
|
|
660
703
|
}
|
|
661
|
-
if (feeToTreasury < nameRegFee(rec.name)) {
|
|
704
|
+
if (feeToTreasury < nameRegFee(rec.name, ev.height)) {
|
|
662
705
|
note(ev, ev.id, "nrenew", false, "renewal fee unpaid");
|
|
663
706
|
continue;
|
|
664
707
|
}
|
|
665
708
|
n.paidThroughEpoch = paidThrough(n) + NAME_TERM_EPOCHS;
|
|
666
|
-
feesPaid += nameRegFee(rec.name);
|
|
709
|
+
feesPaid += nameRegFee(rec.name, ev.height);
|
|
667
710
|
note(ev, ev.id, "nrenew", true, `paid through epoch ${n.paidThroughEpoch}`);
|
|
668
711
|
} else if (rec.t === "tmeta") {
|
|
669
712
|
if (!v15) {
|
|
@@ -764,6 +807,7 @@ function resolve(events, tipHeight) {
|
|
|
764
807
|
giveName.owner = who;
|
|
765
808
|
giveName.locked = false;
|
|
766
809
|
giveName.addr = void 0;
|
|
810
|
+
giveName.profile = void 0;
|
|
767
811
|
if (ev.height >= V13_HEIGHT) {
|
|
768
812
|
giveName.effHeight = ev.height;
|
|
769
813
|
giveName.pos = ev.pos;
|
|
@@ -893,6 +937,7 @@ function resolve(events, tipHeight) {
|
|
|
893
937
|
n.owner = who;
|
|
894
938
|
n.locked = false;
|
|
895
939
|
n.addr = void 0;
|
|
940
|
+
n.profile = void 0;
|
|
896
941
|
if (ev.height >= V13_HEIGHT) {
|
|
897
942
|
n.effHeight = ev.height;
|
|
898
943
|
n.pos = ev.pos;
|
|
@@ -963,6 +1008,7 @@ function resolve(events, tipHeight) {
|
|
|
963
1008
|
}
|
|
964
1009
|
const namesOut = {};
|
|
965
1010
|
const tipV15 = tipHeight >= V15_HEIGHT;
|
|
1011
|
+
const tipV19 = tipHeight >= V19_HEIGHT;
|
|
966
1012
|
const tipEpoch = epochOf(tipHeight);
|
|
967
1013
|
for (const [nm, n] of [...names.entries()].sort(([a], [b]) => ord(a, b))) {
|
|
968
1014
|
namesOut[nm] = {
|
|
@@ -974,6 +1020,9 @@ function resolve(events, tipHeight) {
|
|
|
974
1020
|
locked: n.locked,
|
|
975
1021
|
...n.addr ? { addr: n.addr } : {},
|
|
976
1022
|
...n.viaFill ? { viaFill: true } : {},
|
|
1023
|
+
// v1.9 profile materialized at v1.9+ tips ONLY (the apply is also gated) → every pre-v1.9 canonical
|
|
1024
|
+
// hash stays byte-identical; absent when empty/unset.
|
|
1025
|
+
...tipV19 && n.profile ? { profile: n.profile } : {},
|
|
977
1026
|
// lease fields exist only at v1.5+ tips so every pre-v1.5 canonical hash stays pinned
|
|
978
1027
|
...tipV15 ? { paidThroughEpoch: paidThrough(n), ...lapsed(n, tipEpoch) ? { expired: true } : {} } : {}
|
|
979
1028
|
};
|
|
@@ -1012,11 +1061,16 @@ export {
|
|
|
1012
1061
|
MAX_ACTIVE_CLAIMS,
|
|
1013
1062
|
MAX_AMOUNT,
|
|
1014
1063
|
MAX_RECORD_BYTES,
|
|
1064
|
+
NAME_FEE_SHORT_V18,
|
|
1065
|
+
NAME_FEE_V18,
|
|
1015
1066
|
NAME_GRACE_EPOCHS,
|
|
1016
1067
|
NAME_PREMIUM_DECAY_EPOCHS,
|
|
1017
1068
|
NAME_PREMIUM_START,
|
|
1018
1069
|
NAME_RE,
|
|
1019
1070
|
NAME_TERM_EPOCHS,
|
|
1071
|
+
PKEY,
|
|
1072
|
+
PROFILE_MAX_KEYS,
|
|
1073
|
+
PROFILE_MAX_VALUE_BYTES,
|
|
1020
1074
|
REBATE_BPS,
|
|
1021
1075
|
REBATE_FLAT,
|
|
1022
1076
|
RESERVED_NAMES,
|
|
@@ -1032,6 +1086,8 @@ export {
|
|
|
1032
1086
|
V15_HEIGHT,
|
|
1033
1087
|
V16_HEIGHT,
|
|
1034
1088
|
V17_HEIGHT,
|
|
1089
|
+
V18_HEIGHT,
|
|
1090
|
+
V19_HEIGHT,
|
|
1035
1091
|
bid,
|
|
1036
1092
|
buildRecord,
|
|
1037
1093
|
canonicalState,
|
|
@@ -1046,6 +1102,7 @@ export {
|
|
|
1046
1102
|
nameClaim,
|
|
1047
1103
|
nameCommit,
|
|
1048
1104
|
nameCommitRecord,
|
|
1105
|
+
nameProfile,
|
|
1049
1106
|
nameRegFee,
|
|
1050
1107
|
nameRenew,
|
|
1051
1108
|
nameSet,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inversealtruism/cairnx-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
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",
|
|
@@ -21,12 +21,8 @@
|
|
|
21
21
|
"MAKERS.md",
|
|
22
22
|
"test/vectors"
|
|
23
23
|
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
26
|
-
"test": "tsx test/vectors.test.ts && tsx test/name-decoy.test.ts"
|
|
27
|
-
},
|
|
28
24
|
"dependencies": {
|
|
29
|
-
"@inversealtruism/csd-codec": "
|
|
25
|
+
"@inversealtruism/csd-codec": "0.1.12"
|
|
30
26
|
},
|
|
31
27
|
"license": "MIT",
|
|
32
28
|
"sideEffects": false,
|
|
@@ -38,5 +34,9 @@
|
|
|
38
34
|
"url": "git+https://github.com/InverseAltruism/csd-sdk.git",
|
|
39
35
|
"directory": "packages/cairnx"
|
|
40
36
|
},
|
|
41
|
-
"homepage": "https://cairn-substrate.com/trade"
|
|
42
|
-
|
|
37
|
+
"homepage": "https://cairn-substrate.com/trade",
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
40
|
+
"test": "tsx test/vectors.test.ts && tsx test/name-decoy.test.ts"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/test/vectors/cases.json
CHANGED
|
@@ -4165,6 +4165,254 @@
|
|
|
4165
4165
|
}
|
|
4166
4166
|
}
|
|
4167
4167
|
}
|
|
4168
|
+
},
|
|
4169
|
+
{
|
|
4170
|
+
"name": "v18-short-name-premium-fee",
|
|
4171
|
+
"events": [
|
|
4172
|
+
{
|
|
4173
|
+
"kind": "propose",
|
|
4174
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800000",
|
|
4175
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4176
|
+
"uri": "{\"commit\":\"0xe9172ed8a29abd81a346e20476e8ec74c1fef0173dc1b3bcbd9fb09ac6686a17\",\"t\":\"ncommit\",\"v\":1}",
|
|
4177
|
+
"payloadHash": "0x721ebb06e32ea9a6e3a4f7b90fa002af7f9e51a626fced5fc82fc1d715594a61",
|
|
4178
|
+
"height": 40005,
|
|
4179
|
+
"pos": 1,
|
|
4180
|
+
"expiresEpoch": 5000,
|
|
4181
|
+
"paidTo": {}
|
|
4182
|
+
},
|
|
4183
|
+
{
|
|
4184
|
+
"kind": "propose",
|
|
4185
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800001",
|
|
4186
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4187
|
+
"uri": "{\"name\":\"abcd\",\"salt\":\"00ffee1122334455\",\"t\":\"name\",\"v\":1}",
|
|
4188
|
+
"payloadHash": "0xcb76f8a543e51c988e858ebba46f7f036042813879e9bf22045b04a58e7bfd9f",
|
|
4189
|
+
"height": 40007,
|
|
4190
|
+
"pos": 1,
|
|
4191
|
+
"expiresEpoch": 5000,
|
|
4192
|
+
"paidTo": {
|
|
4193
|
+
"0x6b09ce74e6070ebc982ab0fb793a211c4d24f016": "670000000"
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
],
|
|
4197
|
+
"tipHeight": 40010,
|
|
4198
|
+
"expectedState": {
|
|
4199
|
+
"balances": {},
|
|
4200
|
+
"bids": {},
|
|
4201
|
+
"feesPaid": "670000000",
|
|
4202
|
+
"names": {
|
|
4203
|
+
"abcd": {
|
|
4204
|
+
"claimId": "0x00000000000000000000000000000000000000000000000000000000f1800001",
|
|
4205
|
+
"effectiveHeight": 40005,
|
|
4206
|
+
"height": 40007,
|
|
4207
|
+
"locked": false,
|
|
4208
|
+
"name": "abcd",
|
|
4209
|
+
"owner": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4210
|
+
"paidThroughEpoch": 10093
|
|
4211
|
+
}
|
|
4212
|
+
},
|
|
4213
|
+
"offers": {},
|
|
4214
|
+
"tipHeight": 40010,
|
|
4215
|
+
"tokens": {}
|
|
4216
|
+
}
|
|
4217
|
+
},
|
|
4218
|
+
{
|
|
4219
|
+
"name": "v18-normal-name-flat-fee",
|
|
4220
|
+
"events": [
|
|
4221
|
+
{
|
|
4222
|
+
"kind": "propose",
|
|
4223
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800002",
|
|
4224
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4225
|
+
"uri": "{\"commit\":\"0xbb1d7e6d0e8f78e7882eca8879b3216354041ffa4e7c8d9eb4a0b07d0a8162ab\",\"t\":\"ncommit\",\"v\":1}",
|
|
4226
|
+
"payloadHash": "0x9f8abb7ac2c902a9e59fe2ae43c62812906de4e0f16edb6da58fac5be655c03d",
|
|
4227
|
+
"height": 40005,
|
|
4228
|
+
"pos": 1,
|
|
4229
|
+
"expiresEpoch": 5000,
|
|
4230
|
+
"paidTo": {}
|
|
4231
|
+
},
|
|
4232
|
+
{
|
|
4233
|
+
"kind": "propose",
|
|
4234
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800003",
|
|
4235
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4236
|
+
"uri": "{\"name\":\"alice\",\"salt\":\"00ffee1122334455\",\"t\":\"name\",\"v\":1}",
|
|
4237
|
+
"payloadHash": "0xa444df439fb371a52bac3918fdb2079c0b0e8aebdb5511d5941a4be923420c5f",
|
|
4238
|
+
"height": 40007,
|
|
4239
|
+
"pos": 1,
|
|
4240
|
+
"expiresEpoch": 5000,
|
|
4241
|
+
"paidTo": {
|
|
4242
|
+
"0x6b09ce74e6070ebc982ab0fb793a211c4d24f016": "300000000"
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
],
|
|
4246
|
+
"tipHeight": 40010,
|
|
4247
|
+
"expectedState": {
|
|
4248
|
+
"balances": {},
|
|
4249
|
+
"bids": {},
|
|
4250
|
+
"feesPaid": "300000000",
|
|
4251
|
+
"names": {
|
|
4252
|
+
"alice": {
|
|
4253
|
+
"claimId": "0x00000000000000000000000000000000000000000000000000000000f1800003",
|
|
4254
|
+
"effectiveHeight": 40005,
|
|
4255
|
+
"height": 40007,
|
|
4256
|
+
"locked": false,
|
|
4257
|
+
"name": "alice",
|
|
4258
|
+
"owner": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4259
|
+
"paidThroughEpoch": 10093
|
|
4260
|
+
}
|
|
4261
|
+
},
|
|
4262
|
+
"offers": {},
|
|
4263
|
+
"tipHeight": 40010,
|
|
4264
|
+
"tokens": {}
|
|
4265
|
+
}
|
|
4266
|
+
},
|
|
4267
|
+
{
|
|
4268
|
+
"name": "v18-old-fee-underpaid-rejected",
|
|
4269
|
+
"events": [
|
|
4270
|
+
{
|
|
4271
|
+
"kind": "propose",
|
|
4272
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800004",
|
|
4273
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4274
|
+
"uri": "{\"commit\":\"0xbb1d7e6d0e8f78e7882eca8879b3216354041ffa4e7c8d9eb4a0b07d0a8162ab\",\"t\":\"ncommit\",\"v\":1}",
|
|
4275
|
+
"payloadHash": "0x9f8abb7ac2c902a9e59fe2ae43c62812906de4e0f16edb6da58fac5be655c03d",
|
|
4276
|
+
"height": 40005,
|
|
4277
|
+
"pos": 1,
|
|
4278
|
+
"expiresEpoch": 5000,
|
|
4279
|
+
"paidTo": {}
|
|
4280
|
+
},
|
|
4281
|
+
{
|
|
4282
|
+
"kind": "propose",
|
|
4283
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800005",
|
|
4284
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4285
|
+
"uri": "{\"name\":\"alice\",\"salt\":\"00ffee1122334455\",\"t\":\"name\",\"v\":1}",
|
|
4286
|
+
"payloadHash": "0xa444df439fb371a52bac3918fdb2079c0b0e8aebdb5511d5941a4be923420c5f",
|
|
4287
|
+
"height": 40007,
|
|
4288
|
+
"pos": 1,
|
|
4289
|
+
"expiresEpoch": 5000,
|
|
4290
|
+
"paidTo": {
|
|
4291
|
+
"0x6b09ce74e6070ebc982ab0fb793a211c4d24f016": "50000000"
|
|
4292
|
+
}
|
|
4293
|
+
}
|
|
4294
|
+
],
|
|
4295
|
+
"tipHeight": 40010,
|
|
4296
|
+
"expectedState": {
|
|
4297
|
+
"balances": {},
|
|
4298
|
+
"bids": {},
|
|
4299
|
+
"feesPaid": "0",
|
|
4300
|
+
"names": {},
|
|
4301
|
+
"offers": {},
|
|
4302
|
+
"tipHeight": 40010,
|
|
4303
|
+
"tokens": {}
|
|
4304
|
+
}
|
|
4305
|
+
},
|
|
4306
|
+
{
|
|
4307
|
+
"name": "v18-below-gate-uses-old-curve",
|
|
4308
|
+
"events": [
|
|
4309
|
+
{
|
|
4310
|
+
"kind": "propose",
|
|
4311
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800006",
|
|
4312
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4313
|
+
"uri": "{\"commit\":\"0xbb1d7e6d0e8f78e7882eca8879b3216354041ffa4e7c8d9eb4a0b07d0a8162ab\",\"t\":\"ncommit\",\"v\":1}",
|
|
4314
|
+
"payloadHash": "0x9f8abb7ac2c902a9e59fe2ae43c62812906de4e0f16edb6da58fac5be655c03d",
|
|
4315
|
+
"height": 39988,
|
|
4316
|
+
"pos": 1,
|
|
4317
|
+
"expiresEpoch": 5000,
|
|
4318
|
+
"paidTo": {}
|
|
4319
|
+
},
|
|
4320
|
+
{
|
|
4321
|
+
"kind": "propose",
|
|
4322
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800007",
|
|
4323
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4324
|
+
"uri": "{\"name\":\"alice\",\"salt\":\"00ffee1122334455\",\"t\":\"name\",\"v\":1}",
|
|
4325
|
+
"payloadHash": "0xa444df439fb371a52bac3918fdb2079c0b0e8aebdb5511d5941a4be923420c5f",
|
|
4326
|
+
"height": 39990,
|
|
4327
|
+
"pos": 1,
|
|
4328
|
+
"expiresEpoch": 5000,
|
|
4329
|
+
"paidTo": {
|
|
4330
|
+
"0x6b09ce74e6070ebc982ab0fb793a211c4d24f016": "100000000"
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4333
|
+
],
|
|
4334
|
+
"tipHeight": 39995,
|
|
4335
|
+
"expectedState": {
|
|
4336
|
+
"balances": {},
|
|
4337
|
+
"bids": {},
|
|
4338
|
+
"feesPaid": "100000000",
|
|
4339
|
+
"names": {
|
|
4340
|
+
"alice": {
|
|
4341
|
+
"claimId": "0x00000000000000000000000000000000000000000000000000000000f1800007",
|
|
4342
|
+
"effectiveHeight": 39988,
|
|
4343
|
+
"height": 39990,
|
|
4344
|
+
"locked": false,
|
|
4345
|
+
"name": "alice",
|
|
4346
|
+
"owner": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4347
|
+
"paidThroughEpoch": 10093
|
|
4348
|
+
}
|
|
4349
|
+
},
|
|
4350
|
+
"offers": {},
|
|
4351
|
+
"tipHeight": 39995,
|
|
4352
|
+
"tokens": {}
|
|
4353
|
+
}
|
|
4354
|
+
},
|
|
4355
|
+
{
|
|
4356
|
+
"name": "v18-renewal-pays-new-fee",
|
|
4357
|
+
"events": [
|
|
4358
|
+
{
|
|
4359
|
+
"kind": "propose",
|
|
4360
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800008",
|
|
4361
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4362
|
+
"uri": "{\"commit\":\"0xbb1d7e6d0e8f78e7882eca8879b3216354041ffa4e7c8d9eb4a0b07d0a8162ab\",\"t\":\"ncommit\",\"v\":1}",
|
|
4363
|
+
"payloadHash": "0x9f8abb7ac2c902a9e59fe2ae43c62812906de4e0f16edb6da58fac5be655c03d",
|
|
4364
|
+
"height": 40005,
|
|
4365
|
+
"pos": 1,
|
|
4366
|
+
"expiresEpoch": 5000,
|
|
4367
|
+
"paidTo": {}
|
|
4368
|
+
},
|
|
4369
|
+
{
|
|
4370
|
+
"kind": "propose",
|
|
4371
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f1800009",
|
|
4372
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4373
|
+
"uri": "{\"name\":\"alice\",\"salt\":\"00ffee1122334455\",\"t\":\"name\",\"v\":1}",
|
|
4374
|
+
"payloadHash": "0xa444df439fb371a52bac3918fdb2079c0b0e8aebdb5511d5941a4be923420c5f",
|
|
4375
|
+
"height": 40007,
|
|
4376
|
+
"pos": 1,
|
|
4377
|
+
"expiresEpoch": 5000,
|
|
4378
|
+
"paidTo": {
|
|
4379
|
+
"0x6b09ce74e6070ebc982ab0fb793a211c4d24f016": "300000000"
|
|
4380
|
+
}
|
|
4381
|
+
},
|
|
4382
|
+
{
|
|
4383
|
+
"kind": "propose",
|
|
4384
|
+
"id": "0x00000000000000000000000000000000000000000000000000000000f180000a",
|
|
4385
|
+
"proposer": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4386
|
+
"uri": "{\"name\":\"alice\",\"t\":\"nrenew\",\"v\":1}",
|
|
4387
|
+
"payloadHash": "0xf354141593382a062fc2fc197d2a2eb0882088860e31688495ec7102460fcff2",
|
|
4388
|
+
"height": 40009,
|
|
4389
|
+
"pos": 1,
|
|
4390
|
+
"expiresEpoch": 5000,
|
|
4391
|
+
"paidTo": {
|
|
4392
|
+
"0x6b09ce74e6070ebc982ab0fb793a211c4d24f016": "300000000"
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
],
|
|
4396
|
+
"tipHeight": 40012,
|
|
4397
|
+
"expectedState": {
|
|
4398
|
+
"balances": {},
|
|
4399
|
+
"bids": {},
|
|
4400
|
+
"feesPaid": "600000000",
|
|
4401
|
+
"names": {
|
|
4402
|
+
"alice": {
|
|
4403
|
+
"claimId": "0x00000000000000000000000000000000000000000000000000000000f1800009",
|
|
4404
|
+
"effectiveHeight": 40005,
|
|
4405
|
+
"height": 40007,
|
|
4406
|
+
"locked": false,
|
|
4407
|
+
"name": "alice",
|
|
4408
|
+
"owner": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
|
|
4409
|
+
"paidThroughEpoch": 18853
|
|
4410
|
+
}
|
|
4411
|
+
},
|
|
4412
|
+
"offers": {},
|
|
4413
|
+
"tipHeight": 40012,
|
|
4414
|
+
"tokens": {}
|
|
4415
|
+
}
|
|
4168
4416
|
}
|
|
4169
4417
|
]
|
|
4170
4418
|
}
|