@inversealtruism/cairnx-core 0.1.8

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.
@@ -0,0 +1,325 @@
1
+ declare const DOMAIN = "cairnx:v1";
2
+ declare const ACTIVATION_HEIGHT = 29860;
3
+ declare const V11_HEIGHT = 29960;
4
+ declare const V12_HEIGHT = 30300;
5
+ declare const V13_HEIGHT = 31100;
6
+ declare const V14_HEIGHT = 31400;
7
+ declare const V15_HEIGHT = 32000;
8
+ declare const EPOCH_LEN = 30;
9
+ declare const NAME_TERM_EPOCHS = 8760;
10
+ declare const NAME_GRACE_EPOCHS = 720;
11
+ declare const NAME_PREMIUM_START = 20n;
12
+ declare const NAME_PREMIUM_DECAY_EPOCHS = 720;
13
+ /** Fee to claim a name whose lease lapsed (grace over): nameRegFee × a linearly-decaying
14
+ * premium. Pure in (name, epochsPastGraceEnd) — deterministic for every resolver. */
15
+ declare function expiredClaimFee(name: string, epochsPastGraceEnd: number): bigint;
16
+ declare const MAX_RECORD_BYTES = 512;
17
+ declare const MAX_AMOUNT: bigint;
18
+ declare const SCORE_FILL = 100;
19
+ declare const SCORE_CANCEL = 0;
20
+ declare const CONF_TOKEN_FILL = 1000000;
21
+ declare const TREASURY_ADDR = "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016";
22
+ declare const FEE_BPS = 100;
23
+ declare const DEPLOY_FEE = 100000000;
24
+ declare function nameRegFee(name: string): bigint;
25
+ declare const tradeFee: (want: bigint) => bigint;
26
+ declare const TICKER_RE: RegExp;
27
+ declare const ADDR_RE: RegExp;
28
+ declare const AMOUNT_RE: RegExp;
29
+ declare const NAME_RE: RegExp;
30
+ declare const HASH_RE: RegExp;
31
+ declare const RESERVED_NAMES: Set<string>;
32
+ declare const COMMIT_MAX_BLOCKS: number;
33
+ declare const epochOf: (height: number) => number;
34
+ interface DeployRecord {
35
+ v: 1;
36
+ t: "deploy";
37
+ ticker: string;
38
+ name?: string;
39
+ decimals: number;
40
+ supply: string;
41
+ mint: "open" | "issuer";
42
+ mintLimit?: string;
43
+ }
44
+ interface MintRecord {
45
+ v: 1;
46
+ t: "mint";
47
+ ticker: string;
48
+ amount?: string;
49
+ }
50
+ interface TransferRecord {
51
+ v: 1;
52
+ t: "transfer";
53
+ ticker: string;
54
+ to: string;
55
+ amount: string;
56
+ memo?: string;
57
+ ts?: number;
58
+ }
59
+ type Give = {
60
+ ticker: string;
61
+ amount: string;
62
+ } | {
63
+ name: string;
64
+ };
65
+ type Want = {
66
+ value: string;
67
+ payto?: string;
68
+ } | {
69
+ ticker: string;
70
+ amount: string;
71
+ payto?: string;
72
+ };
73
+ interface OfferRecord {
74
+ v: 1;
75
+ t: "offer";
76
+ give: Give;
77
+ want: Want;
78
+ /** v1.2: smallest payment a partial fill may make (CSD-priced token offers only) */
79
+ min?: string;
80
+ /** v1.2: txid of the bid this offer responds to (informational RFQ link) */
81
+ bid?: string;
82
+ taker?: string;
83
+ memo?: string;
84
+ ts?: number;
85
+ }
86
+ interface BidRecord {
87
+ v: 1;
88
+ t: "bid";
89
+ want: {
90
+ ticker: string;
91
+ amount: string;
92
+ } | {
93
+ name: string;
94
+ };
95
+ give: {
96
+ value: string;
97
+ };
98
+ memo?: string;
99
+ ts?: number;
100
+ }
101
+ interface OfferCancelAllRecord {
102
+ v: 1;
103
+ t: "ocancel";
104
+ ticker?: string;
105
+ name?: string;
106
+ }
107
+ interface NameCommitRecord {
108
+ v: 1;
109
+ t: "ncommit";
110
+ commit: string;
111
+ }
112
+ interface NameRecord {
113
+ v: 1;
114
+ t: "name";
115
+ name: string;
116
+ salt?: string;
117
+ }
118
+ interface NameXferRecord {
119
+ v: 1;
120
+ t: "nxfer";
121
+ name: string;
122
+ to: string;
123
+ }
124
+ interface NameSetRecord {
125
+ v: 1;
126
+ t: "nset";
127
+ name: string;
128
+ addr: string;
129
+ }
130
+ interface NameRenewRecord {
131
+ v: 1;
132
+ t: "nrenew";
133
+ name: string;
134
+ }
135
+ interface TokenMetaRecord {
136
+ v: 1;
137
+ t: "tmeta";
138
+ ticker: string;
139
+ hash: string;
140
+ }
141
+ type CairnXRecord = DeployRecord | MintRecord | TransferRecord | OfferRecord | BidRecord | OfferCancelAllRecord | NameCommitRecord | NameRecord | NameXferRecord | NameSetRecord | NameRenewRecord | TokenMetaRecord;
142
+ interface ProposeEvent {
143
+ kind: "propose";
144
+ id: string;
145
+ proposer: string;
146
+ uri: string;
147
+ payloadHash: string;
148
+ expiresEpoch: number;
149
+ height: number;
150
+ pos: number;
151
+ paidTo: Record<string, string>;
152
+ }
153
+ interface AttestEvent {
154
+ kind: "attest";
155
+ txid: string;
156
+ proposalId: string;
157
+ attester: string;
158
+ score: number;
159
+ confidence: number;
160
+ height: number;
161
+ pos: number;
162
+ paidTo: Record<string, string>;
163
+ }
164
+ type ChainEvent = ProposeEvent | AttestEvent;
165
+ interface TokenState {
166
+ ticker: string;
167
+ deployId: string;
168
+ deployer: string;
169
+ name?: string;
170
+ decimals: number;
171
+ supply: string;
172
+ minted: string;
173
+ mint: "open" | "issuer";
174
+ mintLimit?: string;
175
+ height: number;
176
+ /** v1.5: issuer-set csd-swarm content hash for {logo, description, links} (last write wins) */
177
+ tmeta?: string;
178
+ }
179
+ interface BalanceState {
180
+ available: string;
181
+ locked: string;
182
+ }
183
+ interface NameState {
184
+ name: string;
185
+ owner: string;
186
+ claimId: string;
187
+ height: number;
188
+ effectiveHeight: number;
189
+ addr?: string;
190
+ locked: boolean;
191
+ /** v1.3: ownership basis is a paid fill — record is displacement-immune (claimId/heights = the fill) */
192
+ viaFill?: true;
193
+ /** v1.5: the lease — owned through this epoch; +grace for owner-only renewal; then premium re-claim */
194
+ paidThroughEpoch?: number;
195
+ /** v1.5: true once the lease + grace lapsed (record kept for history; name is claimable) */
196
+ expired?: true;
197
+ }
198
+ type OfferStatus = "open" | "filled" | "cancelled" | "expired";
199
+ interface FillEntry {
200
+ buyer: string;
201
+ txid: string;
202
+ height: number;
203
+ paid: string;
204
+ fee: string;
205
+ got?: string;
206
+ }
207
+ interface OfferState {
208
+ id: string;
209
+ seller: string;
210
+ give: Give;
211
+ want: {
212
+ value: string;
213
+ payto: string;
214
+ } | {
215
+ ticker: string;
216
+ amount: string;
217
+ payto: string;
218
+ };
219
+ taker?: string;
220
+ status: OfferStatus;
221
+ expiresEpoch: number;
222
+ height: number;
223
+ feeBps: number;
224
+ /** v1.2 partial fills: the maker's per-fill payment floor; presence ⇒ partially fillable */
225
+ min?: string;
226
+ /** v1.2: cumulative payment received / give delivered so far (partial offers only) */
227
+ paid?: string;
228
+ delivered?: string;
229
+ /** v1.2: every partial fill in apply order */
230
+ fills?: FillEntry[];
231
+ /** v1.2: the bid this offer responds to */
232
+ bid?: string;
233
+ fill?: FillEntry;
234
+ }
235
+ type BidStatus = "open" | "cancelled" | "expired" | "done";
236
+ interface BidState {
237
+ id: string;
238
+ bidder: string;
239
+ want: {
240
+ ticker: string;
241
+ amount: string;
242
+ } | {
243
+ name: string;
244
+ };
245
+ give: {
246
+ value: string;
247
+ };
248
+ status: BidStatus;
249
+ expiresEpoch: number;
250
+ height: number;
251
+ /** offers anchored in response (tagged with this bid's id), in apply order */
252
+ offers: string[];
253
+ }
254
+ interface AppliedEvent {
255
+ height: number;
256
+ pos: number;
257
+ id: string;
258
+ kind: string;
259
+ ok: boolean;
260
+ note?: string;
261
+ }
262
+ interface CairnXState {
263
+ tipHeight: number;
264
+ tokens: Record<string, TokenState>;
265
+ balances: Record<string, Record<string, BalanceState>>;
266
+ names: Record<string, NameState>;
267
+ offers: Record<string, OfferState>;
268
+ bids: Record<string, BidState>;
269
+ events: AppliedEvent[];
270
+ feesPaid: string;
271
+ }
272
+ declare const isNameGive: (g: Give) => g is {
273
+ name: string;
274
+ };
275
+ declare const isTokenWant: (w: Want | OfferState["want"]) => w is {
276
+ ticker: string;
277
+ amount: string;
278
+ payto?: string;
279
+ };
280
+
281
+ interface BuiltRecord {
282
+ record: CairnXRecord;
283
+ uri: string;
284
+ payloadHash: string;
285
+ }
286
+ declare function parseAmount(s: unknown, opts?: {
287
+ allowZero?: boolean;
288
+ }): bigint | null;
289
+ /** A claimable name: lowercase-ASCII, 1–32, no leading/trailing hyphen, not reserved. */
290
+ declare const isName: (n: unknown) => n is string;
291
+ /** Deterministic commit hash for front-run-proof name registration (commit-reveal). */
292
+ declare function nameCommit(name: string, salt: string, owner: string): string;
293
+ /**
294
+ * Parse + validate a record from an anchored `uri`. Returns null for anything invalid —
295
+ * per CONVENTION §3, invalid is a no-op, never an error that poisons the replay.
296
+ * Requirements enforced here: uri is canonical JSON of the record, ≤512 bytes,
297
+ * payload_hash commits to it, schema rules of §4.
298
+ */
299
+ declare function parseRecord(uri: string, payloadHashHex: string): CairnXRecord | null;
300
+ /** Build (and self-validate) a record → {record, uri, payloadHash} ready to anchor. */
301
+ declare function buildRecord(record: CairnXRecord): BuiltRecord;
302
+ declare const deploy: (r: Omit<DeployRecord, "v" | "t">) => BuiltRecord;
303
+ declare const mint: (r: Omit<MintRecord, "v" | "t">) => BuiltRecord;
304
+ declare const transfer: (r: Omit<TransferRecord, "v" | "t">) => BuiltRecord;
305
+ declare const offer: (r: Omit<OfferRecord, "v" | "t">) => BuiltRecord;
306
+ declare const bid: (r: Omit<BidRecord, "v" | "t">) => BuiltRecord;
307
+ declare const offerCancelAll: (r?: Omit<OfferCancelAllRecord, "v" | "t">) => BuiltRecord;
308
+ declare const nameCommitRecord: (r: Omit<NameCommitRecord, "v" | "t">) => BuiltRecord;
309
+ declare const nameClaim: (r: Omit<NameRecord, "v" | "t">) => BuiltRecord;
310
+ declare const nameXfer: (r: Omit<NameXferRecord, "v" | "t">) => BuiltRecord;
311
+ declare const nameSet: (r: Omit<NameSetRecord, "v" | "t">) => BuiltRecord;
312
+ declare const nameRenew: (r: Omit<NameRenewRecord, "v" | "t">) => BuiltRecord;
313
+ declare const tokenMeta: (r: Omit<TokenMetaRecord, "v" | "t">) => BuiltRecord;
314
+
315
+ declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
316
+ /** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
317
+ * The canonical surface is the DATA ONLY: {tipHeight, tokens, balances, names, offers, bids,
318
+ * feesPaid}. The applied-event log is deliberately EXCLUDED — its free-text reason strings are
319
+ * implementation diagnostics, and making them normative would force every third-party resolver
320
+ * to reproduce English prose byte-for-byte. (Format 1, pre-2026-06-12, included the log and
321
+ * sorted with localeCompare; pinned format-1 hashes live in test/vectors/replay-hashes.json
322
+ * history.) Keys sort in ordinal (code-unit) order at every depth. */
323
+ declare function canonicalState(s: CairnXState): string;
324
+
325
+ export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, EPOCH_LEN, FEE_BPS, type FillEntry, type Give, HASH_RE, 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, RESERVED_NAMES, SCORE_CANCEL, SCORE_FILL, TICKER_RE, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, mint, nameClaim, nameCommit, nameCommitRecord, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
@@ -0,0 +1,325 @@
1
+ declare const DOMAIN = "cairnx:v1";
2
+ declare const ACTIVATION_HEIGHT = 29860;
3
+ declare const V11_HEIGHT = 29960;
4
+ declare const V12_HEIGHT = 30300;
5
+ declare const V13_HEIGHT = 31100;
6
+ declare const V14_HEIGHT = 31400;
7
+ declare const V15_HEIGHT = 32000;
8
+ declare const EPOCH_LEN = 30;
9
+ declare const NAME_TERM_EPOCHS = 8760;
10
+ declare const NAME_GRACE_EPOCHS = 720;
11
+ declare const NAME_PREMIUM_START = 20n;
12
+ declare const NAME_PREMIUM_DECAY_EPOCHS = 720;
13
+ /** Fee to claim a name whose lease lapsed (grace over): nameRegFee × a linearly-decaying
14
+ * premium. Pure in (name, epochsPastGraceEnd) — deterministic for every resolver. */
15
+ declare function expiredClaimFee(name: string, epochsPastGraceEnd: number): bigint;
16
+ declare const MAX_RECORD_BYTES = 512;
17
+ declare const MAX_AMOUNT: bigint;
18
+ declare const SCORE_FILL = 100;
19
+ declare const SCORE_CANCEL = 0;
20
+ declare const CONF_TOKEN_FILL = 1000000;
21
+ declare const TREASURY_ADDR = "0x6b09ce74e6070ebc982ab0fb793a211c4d24f016";
22
+ declare const FEE_BPS = 100;
23
+ declare const DEPLOY_FEE = 100000000;
24
+ declare function nameRegFee(name: string): bigint;
25
+ declare const tradeFee: (want: bigint) => bigint;
26
+ declare const TICKER_RE: RegExp;
27
+ declare const ADDR_RE: RegExp;
28
+ declare const AMOUNT_RE: RegExp;
29
+ declare const NAME_RE: RegExp;
30
+ declare const HASH_RE: RegExp;
31
+ declare const RESERVED_NAMES: Set<string>;
32
+ declare const COMMIT_MAX_BLOCKS: number;
33
+ declare const epochOf: (height: number) => number;
34
+ interface DeployRecord {
35
+ v: 1;
36
+ t: "deploy";
37
+ ticker: string;
38
+ name?: string;
39
+ decimals: number;
40
+ supply: string;
41
+ mint: "open" | "issuer";
42
+ mintLimit?: string;
43
+ }
44
+ interface MintRecord {
45
+ v: 1;
46
+ t: "mint";
47
+ ticker: string;
48
+ amount?: string;
49
+ }
50
+ interface TransferRecord {
51
+ v: 1;
52
+ t: "transfer";
53
+ ticker: string;
54
+ to: string;
55
+ amount: string;
56
+ memo?: string;
57
+ ts?: number;
58
+ }
59
+ type Give = {
60
+ ticker: string;
61
+ amount: string;
62
+ } | {
63
+ name: string;
64
+ };
65
+ type Want = {
66
+ value: string;
67
+ payto?: string;
68
+ } | {
69
+ ticker: string;
70
+ amount: string;
71
+ payto?: string;
72
+ };
73
+ interface OfferRecord {
74
+ v: 1;
75
+ t: "offer";
76
+ give: Give;
77
+ want: Want;
78
+ /** v1.2: smallest payment a partial fill may make (CSD-priced token offers only) */
79
+ min?: string;
80
+ /** v1.2: txid of the bid this offer responds to (informational RFQ link) */
81
+ bid?: string;
82
+ taker?: string;
83
+ memo?: string;
84
+ ts?: number;
85
+ }
86
+ interface BidRecord {
87
+ v: 1;
88
+ t: "bid";
89
+ want: {
90
+ ticker: string;
91
+ amount: string;
92
+ } | {
93
+ name: string;
94
+ };
95
+ give: {
96
+ value: string;
97
+ };
98
+ memo?: string;
99
+ ts?: number;
100
+ }
101
+ interface OfferCancelAllRecord {
102
+ v: 1;
103
+ t: "ocancel";
104
+ ticker?: string;
105
+ name?: string;
106
+ }
107
+ interface NameCommitRecord {
108
+ v: 1;
109
+ t: "ncommit";
110
+ commit: string;
111
+ }
112
+ interface NameRecord {
113
+ v: 1;
114
+ t: "name";
115
+ name: string;
116
+ salt?: string;
117
+ }
118
+ interface NameXferRecord {
119
+ v: 1;
120
+ t: "nxfer";
121
+ name: string;
122
+ to: string;
123
+ }
124
+ interface NameSetRecord {
125
+ v: 1;
126
+ t: "nset";
127
+ name: string;
128
+ addr: string;
129
+ }
130
+ interface NameRenewRecord {
131
+ v: 1;
132
+ t: "nrenew";
133
+ name: string;
134
+ }
135
+ interface TokenMetaRecord {
136
+ v: 1;
137
+ t: "tmeta";
138
+ ticker: string;
139
+ hash: string;
140
+ }
141
+ type CairnXRecord = DeployRecord | MintRecord | TransferRecord | OfferRecord | BidRecord | OfferCancelAllRecord | NameCommitRecord | NameRecord | NameXferRecord | NameSetRecord | NameRenewRecord | TokenMetaRecord;
142
+ interface ProposeEvent {
143
+ kind: "propose";
144
+ id: string;
145
+ proposer: string;
146
+ uri: string;
147
+ payloadHash: string;
148
+ expiresEpoch: number;
149
+ height: number;
150
+ pos: number;
151
+ paidTo: Record<string, string>;
152
+ }
153
+ interface AttestEvent {
154
+ kind: "attest";
155
+ txid: string;
156
+ proposalId: string;
157
+ attester: string;
158
+ score: number;
159
+ confidence: number;
160
+ height: number;
161
+ pos: number;
162
+ paidTo: Record<string, string>;
163
+ }
164
+ type ChainEvent = ProposeEvent | AttestEvent;
165
+ interface TokenState {
166
+ ticker: string;
167
+ deployId: string;
168
+ deployer: string;
169
+ name?: string;
170
+ decimals: number;
171
+ supply: string;
172
+ minted: string;
173
+ mint: "open" | "issuer";
174
+ mintLimit?: string;
175
+ height: number;
176
+ /** v1.5: issuer-set csd-swarm content hash for {logo, description, links} (last write wins) */
177
+ tmeta?: string;
178
+ }
179
+ interface BalanceState {
180
+ available: string;
181
+ locked: string;
182
+ }
183
+ interface NameState {
184
+ name: string;
185
+ owner: string;
186
+ claimId: string;
187
+ height: number;
188
+ effectiveHeight: number;
189
+ addr?: string;
190
+ locked: boolean;
191
+ /** v1.3: ownership basis is a paid fill — record is displacement-immune (claimId/heights = the fill) */
192
+ viaFill?: true;
193
+ /** v1.5: the lease — owned through this epoch; +grace for owner-only renewal; then premium re-claim */
194
+ paidThroughEpoch?: number;
195
+ /** v1.5: true once the lease + grace lapsed (record kept for history; name is claimable) */
196
+ expired?: true;
197
+ }
198
+ type OfferStatus = "open" | "filled" | "cancelled" | "expired";
199
+ interface FillEntry {
200
+ buyer: string;
201
+ txid: string;
202
+ height: number;
203
+ paid: string;
204
+ fee: string;
205
+ got?: string;
206
+ }
207
+ interface OfferState {
208
+ id: string;
209
+ seller: string;
210
+ give: Give;
211
+ want: {
212
+ value: string;
213
+ payto: string;
214
+ } | {
215
+ ticker: string;
216
+ amount: string;
217
+ payto: string;
218
+ };
219
+ taker?: string;
220
+ status: OfferStatus;
221
+ expiresEpoch: number;
222
+ height: number;
223
+ feeBps: number;
224
+ /** v1.2 partial fills: the maker's per-fill payment floor; presence ⇒ partially fillable */
225
+ min?: string;
226
+ /** v1.2: cumulative payment received / give delivered so far (partial offers only) */
227
+ paid?: string;
228
+ delivered?: string;
229
+ /** v1.2: every partial fill in apply order */
230
+ fills?: FillEntry[];
231
+ /** v1.2: the bid this offer responds to */
232
+ bid?: string;
233
+ fill?: FillEntry;
234
+ }
235
+ type BidStatus = "open" | "cancelled" | "expired" | "done";
236
+ interface BidState {
237
+ id: string;
238
+ bidder: string;
239
+ want: {
240
+ ticker: string;
241
+ amount: string;
242
+ } | {
243
+ name: string;
244
+ };
245
+ give: {
246
+ value: string;
247
+ };
248
+ status: BidStatus;
249
+ expiresEpoch: number;
250
+ height: number;
251
+ /** offers anchored in response (tagged with this bid's id), in apply order */
252
+ offers: string[];
253
+ }
254
+ interface AppliedEvent {
255
+ height: number;
256
+ pos: number;
257
+ id: string;
258
+ kind: string;
259
+ ok: boolean;
260
+ note?: string;
261
+ }
262
+ interface CairnXState {
263
+ tipHeight: number;
264
+ tokens: Record<string, TokenState>;
265
+ balances: Record<string, Record<string, BalanceState>>;
266
+ names: Record<string, NameState>;
267
+ offers: Record<string, OfferState>;
268
+ bids: Record<string, BidState>;
269
+ events: AppliedEvent[];
270
+ feesPaid: string;
271
+ }
272
+ declare const isNameGive: (g: Give) => g is {
273
+ name: string;
274
+ };
275
+ declare const isTokenWant: (w: Want | OfferState["want"]) => w is {
276
+ ticker: string;
277
+ amount: string;
278
+ payto?: string;
279
+ };
280
+
281
+ interface BuiltRecord {
282
+ record: CairnXRecord;
283
+ uri: string;
284
+ payloadHash: string;
285
+ }
286
+ declare function parseAmount(s: unknown, opts?: {
287
+ allowZero?: boolean;
288
+ }): bigint | null;
289
+ /** A claimable name: lowercase-ASCII, 1–32, no leading/trailing hyphen, not reserved. */
290
+ declare const isName: (n: unknown) => n is string;
291
+ /** Deterministic commit hash for front-run-proof name registration (commit-reveal). */
292
+ declare function nameCommit(name: string, salt: string, owner: string): string;
293
+ /**
294
+ * Parse + validate a record from an anchored `uri`. Returns null for anything invalid —
295
+ * per CONVENTION §3, invalid is a no-op, never an error that poisons the replay.
296
+ * Requirements enforced here: uri is canonical JSON of the record, ≤512 bytes,
297
+ * payload_hash commits to it, schema rules of §4.
298
+ */
299
+ declare function parseRecord(uri: string, payloadHashHex: string): CairnXRecord | null;
300
+ /** Build (and self-validate) a record → {record, uri, payloadHash} ready to anchor. */
301
+ declare function buildRecord(record: CairnXRecord): BuiltRecord;
302
+ declare const deploy: (r: Omit<DeployRecord, "v" | "t">) => BuiltRecord;
303
+ declare const mint: (r: Omit<MintRecord, "v" | "t">) => BuiltRecord;
304
+ declare const transfer: (r: Omit<TransferRecord, "v" | "t">) => BuiltRecord;
305
+ declare const offer: (r: Omit<OfferRecord, "v" | "t">) => BuiltRecord;
306
+ declare const bid: (r: Omit<BidRecord, "v" | "t">) => BuiltRecord;
307
+ declare const offerCancelAll: (r?: Omit<OfferCancelAllRecord, "v" | "t">) => BuiltRecord;
308
+ declare const nameCommitRecord: (r: Omit<NameCommitRecord, "v" | "t">) => BuiltRecord;
309
+ declare const nameClaim: (r: Omit<NameRecord, "v" | "t">) => BuiltRecord;
310
+ declare const nameXfer: (r: Omit<NameXferRecord, "v" | "t">) => BuiltRecord;
311
+ declare const nameSet: (r: Omit<NameSetRecord, "v" | "t">) => BuiltRecord;
312
+ declare const nameRenew: (r: Omit<NameRenewRecord, "v" | "t">) => BuiltRecord;
313
+ declare const tokenMeta: (r: Omit<TokenMetaRecord, "v" | "t">) => BuiltRecord;
314
+
315
+ declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
316
+ /** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
317
+ * The canonical surface is the DATA ONLY: {tipHeight, tokens, balances, names, offers, bids,
318
+ * feesPaid}. The applied-event log is deliberately EXCLUDED — its free-text reason strings are
319
+ * implementation diagnostics, and making them normative would force every third-party resolver
320
+ * to reproduce English prose byte-for-byte. (Format 1, pre-2026-06-12, included the log and
321
+ * sorted with localeCompare; pinned format-1 hashes live in test/vectors/replay-hashes.json
322
+ * history.) Keys sort in ordinal (code-unit) order at every depth. */
323
+ declare function canonicalState(s: CairnXState): string;
324
+
325
+ export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, EPOCH_LEN, FEE_BPS, type FillEntry, type Give, HASH_RE, 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, RESERVED_NAMES, SCORE_CANCEL, SCORE_FILL, TICKER_RE, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, mint, nameClaim, nameCommit, nameCommitRecord, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };