@inversealtruism/cairnx-core 0.1.38 → 0.1.41
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/CONVENTION.md +59 -3
- package/dist/index.cjs +102 -6
- package/dist/index.d.cts +136 -9
- package/dist/index.d.ts +136 -9
- package/dist/index.js +97 -6
- package/package.json +3 -3
- package/test/vectors/cases-v29.json +886 -0
- package/test/vectors/replay-corpus.json +1 -0
- package/test/vectors/replay-hashes.json +9 -3
package/CONVENTION.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# CairnX Convention v1
|
|
2
2
|
|
|
3
|
-
**Status:** v2.
|
|
3
|
+
**Status:** v2.9 (normative; v2.9 pending activation at `V29_HEIGHT`, see §32; v2.8 activated at 60 000, crossed 2026-07-23; supersedes the 2026-06-10 v1.0 draft) · **Domain:** `cairnx:v1` · **Base activation:** 29 860
|
|
4
4
|
|
|
5
5
|
**Version ladder** (each gate non-retroactive — below it, behavior + canonical hashes are byte-identical to history):
|
|
6
6
|
v1.1 @ 29 960 · v1.2 @ 30 300 · v1.3 @ 31 100 · v1.4 @ 31 400 · v1.5 @ 32 000 · v1.6 @ 33 600 (§19) ·
|
|
7
7
|
v1.7 @ 34 000 (§20) · v1.9 @ 36 700 (§22) · v2.0 @ 38 400 (§23) · v1.8 @ 40 000 (§21) · v2.1 @ 40 100 (§24) ·
|
|
8
8
|
v2.2 @ 41 300 (§25) · v2.4 @ 46 400 (§27) · v2.5 @ 46 440 (§28) · v2.6 @ 46 480 (§29) · v2.7 @ 46 520 (§30) ·
|
|
9
|
-
v2.3 @ 52 000 (§26) · v2.8 @
|
|
10
|
-
Sections §19–§
|
|
9
|
+
v2.3 @ 52 000 (§26) · v2.8 @ 60 000 (§31) · v2.9 @ 88 000 (§32, PENDING activation).
|
|
10
|
+
Sections §19–§32 are the normative semantics for v1.6–v2.9; §5.1 is the byte-level canonical-JSON contract that binds all of them.
|
|
11
11
|
Activation order is by HEIGHT, not by version number (v1.8 activated after v2.0; v2.3 activates after v2.4–v2.7): a
|
|
12
12
|
replayer gates each rule on its own height constant, never on "version X implies version Y is active".
|
|
13
13
|
|
|
@@ -146,6 +146,8 @@ CairnX meaning for deploys. The **deployer** is the anchoring proposer.
|
|
|
146
146
|
chain itself rejects fill attempts (C5), and the resolver releases the lock. Offers SHOULD
|
|
147
147
|
use short windows (e.g. tip-epoch + 24 ≈ 1 day).
|
|
148
148
|
- An offer is identified by its **proposal id (txid)**.
|
|
149
|
+
- `memo` (64 UTF-16 units max) and `ts` are optional free fields with the same rules as
|
|
150
|
+
`transfer` (4.3); `ts` MUST be a JS-safe integer (A8).
|
|
149
151
|
|
|
150
152
|
### 4.5 `fill` — atomic delivery-versus-payment (an Attest, not a Propose)
|
|
151
153
|
|
|
@@ -290,6 +292,16 @@ once a replay hash is pinned over data that exercises them, so they are stated h
|
|
|
290
292
|
`isWellFormedDeep` gate (records.ts), which runs immediately after the A5 round-trip. Implementers
|
|
291
293
|
MUST reproduce it (e.g. JS `String.prototype.isWellFormed`, Rust `str` is already well-formed so a
|
|
292
294
|
`serde_json` parse that surfaces the escape and re-encodes will reject — assert it explicitly).
|
|
295
|
+
- **A8. The closed record schema and the `ts` bound.** Every record type's key set is CLOSED
|
|
296
|
+
(records.ts `onlyKeys` exact-key allowlists, mirrored by `_only_keys` in the Python reference):
|
|
297
|
+
an unknown key anywhere in a record makes it an invalid no-op, never a tolerated extra. The
|
|
298
|
+
optional free field `ts` (on `transfer`, `offer` and `bid`) MUST be a JSON integer number with
|
|
299
|
+
absolute value at most 2^53 - 1 (a JS-safe integer; a boolean is NOT an integer). A `ts` of 2^53
|
|
300
|
+
or above round-trips byte-identically through a bignum/decimal parser but exceeds the IEEE-754
|
|
301
|
+
exact range, so a JS resolver and a bignum porter would disagree on ONE mined transfer and fork
|
|
302
|
+
sha256(canonicalState). Out-of-range, fractional, boolean or non-number `ts` is an invalid no-op.
|
|
303
|
+
Reference: the three `Number.isSafeInteger(r.ts)` gates in records.ts and `is_safe_int` in
|
|
304
|
+
cairnx_ref.py. Pinned by the `ts` rows of the parse-gate differential (conformance/crosscheck.mjs).
|
|
293
305
|
|
|
294
306
|
The conformance suite **now includes** the A1–A4/A7 vectors (`determinism-nonascii-name-value-pinned`
|
|
295
307
|
covers a non-ASCII token name, an emoji/non-BMP name, and CJK; `determinism-lone-surrogate-rejected`
|
|
@@ -503,6 +515,8 @@ of the book is instead built from **bids**, on-chain discovery records:
|
|
|
503
515
|
- "I will pay `give.value` CSD (>0) for `want`" — `want` is a token amount or `{name}`.
|
|
504
516
|
The **bidder** = proposer. `expires_epoch` = the bid's validity window. Cancel = Attest
|
|
505
517
|
`score=0` by the bidder. **Non-binding**: nothing is locked; honoring it is reputational.
|
|
518
|
+
- `memo` (64 UTF-16 units max) and `ts` are optional free fields, same rules as 4.3; `ts` MUST
|
|
519
|
+
be a JS-safe integer (A8).
|
|
506
520
|
- **Fulfillment** is the two-step RFQ: the asset owner anchors a **taker-bound offer**
|
|
507
521
|
(`taker = bidder`, price ≤ bid) optionally tagged `"bid":"<bidId>"`; the bidder's client
|
|
508
522
|
detects the responding offer and fills it atomically. Two anchors + one fill — the
|
|
@@ -1119,3 +1133,45 @@ never false-accept a denied fclaim.
|
|
|
1119
1133
|
no-ops) AND a tightening (a stale core still grants legacy claims a fresh core rejects). Every replayer,
|
|
1120
1134
|
resolver, and client bundle MUST run the v2.8 core before the tip crosses `V28_HEIGHT`. Below the gate every
|
|
1121
1135
|
rule above is inert and all replay is byte-identical.
|
|
1136
|
+
|
|
1137
|
+
## 32. v2.9: replay-feed de-duplication and the open-holds concurrent-claim count
|
|
1138
|
+
|
|
1139
|
+
Two `resolve()`-side corrections that both move canonical state, so both ride ONE height gate,
|
|
1140
|
+
`V29_HEIGHT` = 88 000 (set 2026-07-20 by operator decision; the REBIND audit's M4 + M5). Each rule keys on
|
|
1141
|
+
the triggering EVENT's OWN height (`>= V29_HEIGHT`), never on the tip: non-retroactive, so every pre-V29
|
|
1142
|
+
event replays byte-identically forever and a mixed-version fleet cannot fork below the gate.
|
|
1143
|
+
|
|
1144
|
+
**M4: duplicate-event drop (reject-more).** The §3 consensus ordering sorts events but never de-duplicates,
|
|
1145
|
+
so a double-fed transaction (an overlapping scanner page delivered verbatim) applies twice; on the §12
|
|
1146
|
+
partial-fill path that double-credits `paid` / `delivered`. A transaction has ONE identity: a `Propose`'s
|
|
1147
|
+
`id`, an `Attest`'s `txid`. At an event height `>= V29_HEIGHT` the FIRST occurrence in consensus order
|
|
1148
|
+
(§3: height, propose-before-attest, pos, ordinal id/txid) is kept and every later occurrence of the same
|
|
1149
|
+
identity is dropped BEFORE apply. Below the gate nothing is dropped. A duplicate pair shares one txid and
|
|
1150
|
+
therefore one mined block, so both copies always land on the same side of the gate; there is no straddle
|
|
1151
|
+
case. (The cairnx service also de-duplicates its attestation pull at scan time; that is a transport-side
|
|
1152
|
+
defensive measure, deliberately NOT part of this convention. Only the `resolve()` drop is normative.)
|
|
1153
|
+
|
|
1154
|
+
**M5: the concurrent-hold cap counts only OPEN holds (relaxation).** §20/§31 cap an address at
|
|
1155
|
+
`MAX_ACTIVE_CLAIMS` (= 3) live holds, counted as `claimedBy === who && claimHeld(o, h)`. A FILLED offer
|
|
1156
|
+
keeps its last-write-wins `claimedBy` / `claimUntilHeight` / `claimTxid` (§31 fund-safety: never cleared),
|
|
1157
|
+
so a completed buy kept consuming a cap slot until its hold window lapsed: three completed fclaim buys
|
|
1158
|
+
wrongly denied a fourth honest claim. At a counting event's height `>= V29_HEIGHT` the count admits only
|
|
1159
|
+
holds whose offer is still `open`: `claimedBy === who && claimHeld(o, h) && (h < V29_HEIGHT ||
|
|
1160
|
+
o.status === "open")`. A filled offer has SETTLED; its residual claim fields are a record, not a live
|
|
1161
|
+
reservation. The post-V29 count is a strict SUBSET of the pre-V29 count, so the rule can only GRANT a
|
|
1162
|
+
claim, never newly deny one. Normatively the same clause applies to BOTH counting sites (the §31 fclaim
|
|
1163
|
+
grant ladder and the §20 legacy `SCORE_CLAIM` handler); in the legacy handler it is provably unreachable
|
|
1164
|
+
(`SCORE_CLAIM` at height `>= V28_HEIGHT` is rejected by §31, and `V29 > V28`), and is kept for symmetry.
|
|
1165
|
+
|
|
1166
|
+
**Canonical surface.** No new fields. Both rules change only WHICH events apply, so pre-V29 canonical
|
|
1167
|
+
hashes (every pinned vector and the whole live-chain replay below 88 000) are byte-identical; the v2.9
|
|
1168
|
+
divergence height is pinned by the fork-lens vector set (`cases-v29.json`).
|
|
1169
|
+
|
|
1170
|
+
- **Adoption note (HARD adoption gate, sharper than §31):** M5 GRANTS holds a stale replayer still
|
|
1171
|
+
DENIES, so a stale replayer forks the moment the chain crosses `V29_HEIGHT` with a post-gate grant in
|
|
1172
|
+
flight: it rejects claims (and the fills routed through them) that the canonical chain accepts. Every
|
|
1173
|
+
replayer, resolver, and client bundle (cairnx service, clarvis, the vendored site and wallet bundles,
|
|
1174
|
+
cairn-sdk, cairn-cli, csd-indexer, the Python oracle) MUST run the v2.9 core and be CONFIRMED live
|
|
1175
|
+
before the tip crosses 88 000, never "publish and hope". The `replay-hashes.json` V29 entry is pinned
|
|
1176
|
+
only POST-crossing from the live chain (see CONSENSUS_CHANGES.md); a pre-crossing V29 hash would be an
|
|
1177
|
+
invented pin and is forbidden.
|
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
EPOCH_LEN: () => import_csd_codec5.EPOCH_LEN,
|
|
40
40
|
FCLAIM_KEYS: () => FCLAIM_KEYS,
|
|
41
41
|
FCLAIM_MAX_EPOCH_AHEAD: () => FCLAIM_MAX_EPOCH_AHEAD,
|
|
42
|
+
FCLAIM_WINDOW_MIN: () => FCLAIM_WINDOW_MIN,
|
|
42
43
|
FEE_BPS: () => FEE_BPS,
|
|
43
44
|
FEE_BPS_V16: () => FEE_BPS_V16,
|
|
44
45
|
FEE_GATE_MARGIN_BLOCKS: () => FEE_GATE_MARGIN_BLOCKS,
|
|
@@ -106,6 +107,7 @@ __export(index_exports, {
|
|
|
106
107
|
V26_HEIGHT: () => V26_HEIGHT,
|
|
107
108
|
V27_HEIGHT: () => V27_HEIGHT,
|
|
108
109
|
V28_HEIGHT: () => V28_HEIGHT,
|
|
110
|
+
V29_HEIGHT: () => V29_HEIGHT,
|
|
109
111
|
ZERO_ADDR: () => ZERO_ADDR,
|
|
110
112
|
bid: () => bid,
|
|
111
113
|
bindOfferTerms: () => bindOfferTerms,
|
|
@@ -125,7 +127,9 @@ __export(index_exports, {
|
|
|
125
127
|
fclaimEpochFor: () => fclaimEpochFor,
|
|
126
128
|
fclaimHoldEnd: () => fclaimHoldEnd,
|
|
127
129
|
feeBpsAt: () => feeBpsAt,
|
|
130
|
+
fillEndorsement: () => fillEndorsement,
|
|
128
131
|
fillIsSafe: () => fillIsSafe,
|
|
132
|
+
fillOutputPlan: () => fillOutputPlan,
|
|
129
133
|
fillTargetId: () => fillTargetId,
|
|
130
134
|
finalizeWinnerCheck: () => finalizeWinnerCheck,
|
|
131
135
|
hasLiveClaim: () => hasLiveClaim,
|
|
@@ -162,6 +166,7 @@ __export(index_exports, {
|
|
|
162
166
|
tokenMeta: () => tokenMeta,
|
|
163
167
|
tradeFee: () => tradeFee,
|
|
164
168
|
transfer: () => transfer,
|
|
169
|
+
unsafeMintProvenOfferTerms: () => unsafeMintProvenOfferTerms,
|
|
165
170
|
verifyFillSpv: () => verifyFillSpv
|
|
166
171
|
});
|
|
167
172
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -259,9 +264,14 @@ var FINALIZE_TIP_MARGIN = 2;
|
|
|
259
264
|
var V26_HEIGHT = 46480;
|
|
260
265
|
var V27_HEIGHT = 46520;
|
|
261
266
|
var V28_HEIGHT = 6e4;
|
|
267
|
+
var V29_HEIGHT = 88e3;
|
|
262
268
|
var epochOf = (height) => Math.floor(height / import_csd_codec.EPOCH_LEN);
|
|
263
269
|
var claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
264
|
-
var
|
|
270
|
+
var FCLAIM_WINDOW_MIN = CLAIM_WINDOW_BLOCKS_V20 + CLAIM_FILL_GRACE_BLOCKS + 1;
|
|
271
|
+
var claimWindowOf = (claimUntilHeight, claimTxid) => {
|
|
272
|
+
if (claimTxid !== void 0) return FCLAIM_WINDOW_MIN;
|
|
273
|
+
return claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
274
|
+
};
|
|
265
275
|
var claimGraceOf = (claimUntilHeight, claimTxid) => claimTxid !== void 0 ? 0 : claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_FILL_GRACE_BLOCKS : 0;
|
|
266
276
|
var fclaimEpochFor = (tipHeight, offerExpiresEpoch) => Math.min(epochOf(tipHeight + CLAIM_WINDOW_BLOCKS_V20 + CLAIM_FILL_GRACE_BLOCKS), offerExpiresEpoch);
|
|
267
277
|
var fclaimHoldEnd = (expiresEpoch) => (expiresEpoch + 1) * import_csd_codec.EPOCH_LEN - 1;
|
|
@@ -523,6 +533,17 @@ function resolve(events, tipHeight) {
|
|
|
523
533
|
b.kind === "propose" ? b.id : b.txid
|
|
524
534
|
)
|
|
525
535
|
);
|
|
536
|
+
const eid = (e) => e.kind === "propose" ? e.id : e.txid;
|
|
537
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
538
|
+
const applied = [];
|
|
539
|
+
for (const e of ordered) {
|
|
540
|
+
if (e.height >= V29_HEIGHT) {
|
|
541
|
+
const k = eid(e);
|
|
542
|
+
if (seenIds.has(k)) continue;
|
|
543
|
+
seenIds.add(k);
|
|
544
|
+
}
|
|
545
|
+
applied.push(e);
|
|
546
|
+
}
|
|
526
547
|
const tokens = /* @__PURE__ */ new Map();
|
|
527
548
|
const balances = /* @__PURE__ */ new Map();
|
|
528
549
|
const names = /* @__PURE__ */ new Map();
|
|
@@ -631,7 +652,7 @@ function resolve(events, tipHeight) {
|
|
|
631
652
|
bal(t, who).available += amt;
|
|
632
653
|
offerLock.delete(o.id);
|
|
633
654
|
};
|
|
634
|
-
for (const ev of
|
|
655
|
+
for (const ev of applied) {
|
|
635
656
|
if (ev.height < ACTIVATION_HEIGHT) continue;
|
|
636
657
|
if (ev.height !== pendingBlock) {
|
|
637
658
|
applyPendingCancels();
|
|
@@ -1153,6 +1174,10 @@ function resolve(events, tipHeight) {
|
|
|
1153
1174
|
fclaims.set(ev.id, { offer: rec.offer, proposer: who, expiresEpoch: E, height: ev.height, granted: false });
|
|
1154
1175
|
note(ev, ev.id, "fclaim", false, why);
|
|
1155
1176
|
};
|
|
1177
|
+
if (!Number.isSafeInteger(E)) {
|
|
1178
|
+
deny("expiresEpoch out of safe-integer range");
|
|
1179
|
+
continue;
|
|
1180
|
+
}
|
|
1156
1181
|
if (!target) {
|
|
1157
1182
|
deny("unknown offer");
|
|
1158
1183
|
continue;
|
|
@@ -1190,7 +1215,7 @@ function resolve(events, tipHeight) {
|
|
|
1190
1215
|
continue;
|
|
1191
1216
|
}
|
|
1192
1217
|
let liveN = 0;
|
|
1193
|
-
for (const x of offers.values()) if (x.claimedBy === who && claimHeld(x, ev.height)) liveN++;
|
|
1218
|
+
for (const x of offers.values()) if (x.claimedBy === who && claimHeld(x, ev.height) && (ev.height < V29_HEIGHT || x.status === "open")) liveN++;
|
|
1194
1219
|
if (liveN >= MAX_ACTIVE_CLAIMS) {
|
|
1195
1220
|
deny(`max ${MAX_ACTIVE_CLAIMS} live claims per address`);
|
|
1196
1221
|
continue;
|
|
@@ -1444,7 +1469,7 @@ function resolve(events, tipHeight) {
|
|
|
1444
1469
|
continue;
|
|
1445
1470
|
}
|
|
1446
1471
|
let liveN = 0;
|
|
1447
|
-
for (const x of offers.values()) if (x.claimedBy === who && claimHeld(x, ev.height)) liveN++;
|
|
1472
|
+
for (const x of offers.values()) if (x.claimedBy === who && claimHeld(x, ev.height) && (ev.height < V29_HEIGHT || x.status === "open")) liveN++;
|
|
1448
1473
|
if (liveN >= MAX_ACTIVE_CLAIMS) {
|
|
1449
1474
|
note(ev, ev.txid, "claim", false, `max ${MAX_ACTIVE_CLAIMS} live claims per address`);
|
|
1450
1475
|
continue;
|
|
@@ -1578,10 +1603,22 @@ function requiredFillOutputs(offer2, payRaw) {
|
|
|
1578
1603
|
add(offer2.seller, p.rebate);
|
|
1579
1604
|
return [...need].map(([to, value]) => ({ to, value }));
|
|
1580
1605
|
}
|
|
1606
|
+
function fillOutputPlan(offer2, payRaw) {
|
|
1607
|
+
const preview = previewFill(offer2, payRaw);
|
|
1608
|
+
if (isTokenWant(offer2.want)) {
|
|
1609
|
+
if (offer2.status !== "open") return { kind: "undeliverable", reason: "not-open", preview };
|
|
1610
|
+
return { kind: "token-settled", outputs: [], confidence: CONF_TOKEN_FILL, preview };
|
|
1611
|
+
}
|
|
1612
|
+
if (!preview.deliverable) return { kind: "undeliverable", reason: preview.reason === "not-open" || preview.reason === "below-min" ? preview.reason : "zero-delivery", preview };
|
|
1613
|
+
const outputs = requiredFillOutputs(offer2, payRaw);
|
|
1614
|
+
if (outputs === null) return { kind: "undeliverable", reason: "zero-delivery", preview };
|
|
1615
|
+
return { kind: "csd-outputs", outputs, preview };
|
|
1616
|
+
}
|
|
1581
1617
|
var FEE_GATE_MARGIN_BLOCKS = 5;
|
|
1582
1618
|
var NAME_FEE_GATES = [V18_HEIGHT, V24_HEIGHT];
|
|
1583
1619
|
var buildFeeHeight = (tip) => {
|
|
1584
1620
|
const t = Number(tip);
|
|
1621
|
+
if (!Number.isSafeInteger(t) || t < 0) throw new RangeError(`buildFeeHeight: tip must be a non-negative safe integer, got ${String(tip)}`);
|
|
1585
1622
|
for (const g of NAME_FEE_GATES) if (t < g && t >= g - FEE_GATE_MARGIN_BLOCKS) return g;
|
|
1586
1623
|
return t;
|
|
1587
1624
|
};
|
|
@@ -1613,6 +1650,29 @@ function fillIsSafe(offer2, me, pay, tip) {
|
|
|
1613
1650
|
}
|
|
1614
1651
|
return { safe: true, reason: "ok", preview };
|
|
1615
1652
|
}
|
|
1653
|
+
function fillEndorsement(offer2, me, pay, tip, opts) {
|
|
1654
|
+
const preview = previewFill(offer2, pay);
|
|
1655
|
+
const refuse = (reason) => ({ verdict: "refused", reason, preview });
|
|
1656
|
+
if (offer2.status !== "open") return refuse(`offer is ${offer2.status}`);
|
|
1657
|
+
if (offer2.taker !== void 0 && offer2.taker.toLowerCase() !== me.toLowerCase())
|
|
1658
|
+
return refuse("taker-bound offer - not bound to you");
|
|
1659
|
+
if (isOpenClaimLane(offer2, tip) && !hasLiveClaim(offer2, me, tip))
|
|
1660
|
+
return refuse("open CSD offer - claim it first and fill while your claim is live");
|
|
1661
|
+
const expected = fillTargetId(offer2, tip);
|
|
1662
|
+
const holdRouted = expected.toLowerCase() !== offer2.id.toLowerCase();
|
|
1663
|
+
if (opts?.fillTargetId !== void 0) {
|
|
1664
|
+
if (String(opts.fillTargetId).toLowerCase() !== expected.toLowerCase()) return refuse(holdRouted ? "v2.8: a live fclaim hold routes this fill - the attest must target the fclaim txid, not the offer id (an offer-txid fill is chain-rejected after the payment moved)" : "the attested fill target does not match this offer's routing (attest the offer id)");
|
|
1665
|
+
} else if (holdRouted) {
|
|
1666
|
+
return refuse("v2.8: a live fclaim hold routes this fill - pass opts.fillTargetId (use fillTargetId(offer, tip)) so the endorsement can verify what your attest targets");
|
|
1667
|
+
}
|
|
1668
|
+
if (isTokenWant(offer2.want))
|
|
1669
|
+
return { verdict: "not-endorsable", reason: "token-priced want - deliverability is the attester's token balance, which a pure record predicate cannot see; NOT an endorsement and NOT a refusal (verify your token balance + proven terms, then proceed)", preview };
|
|
1670
|
+
if (!preview.deliverable) {
|
|
1671
|
+
if (preview.reason === "below-min") return refuse("payment is below the offer minimum");
|
|
1672
|
+
return refuse("this payment would deliver 0 tokens - refusing (the CSD would be lost)");
|
|
1673
|
+
}
|
|
1674
|
+
return { verdict: "endorsed", reason: "ok", preview };
|
|
1675
|
+
}
|
|
1616
1676
|
function finalizeWinnerCheck(nameState, me, commitHeight, tip) {
|
|
1617
1677
|
const m = me.toLowerCase();
|
|
1618
1678
|
if (!nameState) return { safe: false, reason: "no reservation on-chain (displaced, swept, or never accepted) \u2014 a finalize now would burn the fee" };
|
|
@@ -1735,23 +1795,45 @@ async function verifyFillSpv(offerId, fclaimTxid, me, io, opts) {
|
|
|
1735
1795
|
}
|
|
1736
1796
|
const dp = previewFill({ ...r.offer, status: "open" }, pay);
|
|
1737
1797
|
if (!dp.deliverable || dp.got < 1n) return no("this fill would deliver 0 units - refusing (the CSD would be lost)");
|
|
1798
|
+
if (opts.sums !== void 0) {
|
|
1799
|
+
const req = requiredFillOutputs({ ...r.offer, status: "open" }, pay);
|
|
1800
|
+
if (req === null) return no("the proven offer state cannot size this payment - refusing");
|
|
1801
|
+
const proven2 = new Map(req.map((o) => [o.to, o.value]));
|
|
1802
|
+
const planned = /* @__PURE__ */ new Map();
|
|
1803
|
+
try {
|
|
1804
|
+
for (const [a, v] of Object.entries(opts.sums)) {
|
|
1805
|
+
const k = String(a).toLowerCase();
|
|
1806
|
+
planned.set(k, (planned.get(k) ?? 0n) + BigInt(v));
|
|
1807
|
+
}
|
|
1808
|
+
} catch {
|
|
1809
|
+
return no("invalid sums (amounts must be base-unit integers)");
|
|
1810
|
+
}
|
|
1811
|
+
const sumsKeys = /* @__PURE__ */ new Set([...proven2.keys(), ...planned.keys()]);
|
|
1812
|
+
for (const k of sumsKeys) if ((proven2.get(k) ?? 0n) !== (planned.get(k) ?? 0n)) return no(`payment does not match the proven fill progress (${k}: planned ${(planned.get(k) ?? 0n).toString()}, proven state requires ${(proven2.get(k) ?? 0n).toString()}) - refusing (an overpay past the real remainder is unrecoverable)`);
|
|
1813
|
+
}
|
|
1738
1814
|
const holdEnd = fclaimHoldEnd(E);
|
|
1739
1815
|
if (holdEnd < tip + FILL_TIP_MARGIN) return no(`too close to the hold deadline (holdEnd ${holdEnd}, tip ${tip}) - would strand`);
|
|
1740
1816
|
return { safe: true, reason: "ok" };
|
|
1741
1817
|
}
|
|
1818
|
+
var unsafeMintProvenOfferTerms = (t) => t;
|
|
1742
1819
|
var feeBpsAt = (height) => height >= V11_HEIGHT ? height >= V16_HEIGHT ? FEE_BPS_V16 : FEE_BPS : 0;
|
|
1743
1820
|
function provenOfferTerms(offerRec, provenHeight) {
|
|
1744
1821
|
const w = offerRec.want;
|
|
1822
|
+
const g = offerRec.give;
|
|
1745
1823
|
return {
|
|
1746
1824
|
height: Number(provenHeight),
|
|
1747
1825
|
feeBps: feeBpsAt(Number(provenHeight)),
|
|
1748
1826
|
value: w.value !== void 0 ? String(w.value) : void 0,
|
|
1749
1827
|
taker: offerRec.taker !== void 0 ? String(offerRec.taker).toLowerCase() : void 0,
|
|
1750
1828
|
bid: offerRec.bid !== void 0 ? String(offerRec.bid).toLowerCase() : void 0,
|
|
1751
|
-
min: offerRec.min !== void 0 ? String(offerRec.min) : void 0
|
|
1829
|
+
min: offerRec.min !== void 0 ? String(offerRec.min) : void 0,
|
|
1830
|
+
giveTicker: g.ticker !== void 0 ? String(g.ticker) : void 0,
|
|
1831
|
+
giveAmount: g.amount !== void 0 ? String(g.amount) : void 0,
|
|
1832
|
+
giveName: g.name !== void 0 ? String(g.name) : void 0,
|
|
1833
|
+
wantType: isTokenWant(offerRec.want) ? "token" : "csd"
|
|
1752
1834
|
};
|
|
1753
1835
|
}
|
|
1754
|
-
function bindOfferTerms(servedOffer, t) {
|
|
1836
|
+
function bindOfferTerms(servedOffer, t, opts) {
|
|
1755
1837
|
const o = servedOffer;
|
|
1756
1838
|
const s = (v) => v === void 0 || v === null ? "" : String(v).toLowerCase();
|
|
1757
1839
|
if (Number(o?.height) !== t.height) return true;
|
|
@@ -1762,6 +1844,15 @@ function bindOfferTerms(servedOffer, t) {
|
|
|
1762
1844
|
const om = o?.min;
|
|
1763
1845
|
if ((om !== void 0 && om !== null) !== (t.min !== void 0)) return true;
|
|
1764
1846
|
if (t.min !== void 0 && String(om) !== t.min) return true;
|
|
1847
|
+
if (opts?.wantType) {
|
|
1848
|
+
if (t.wantType === void 0 || typeof o?.want?.ticker === "string" !== (t.wantType === "token")) return true;
|
|
1849
|
+
}
|
|
1850
|
+
if (opts?.give) {
|
|
1851
|
+
const g = o?.give;
|
|
1852
|
+
if ((g?.ticker !== void 0 && g?.ticker !== null) !== (t.giveTicker !== void 0) || t.giveTicker !== void 0 && String(g?.ticker) !== t.giveTicker) return true;
|
|
1853
|
+
if ((g?.amount !== void 0 && g?.amount !== null) !== (t.giveAmount !== void 0) || t.giveAmount !== void 0 && String(g?.amount) !== t.giveAmount) return true;
|
|
1854
|
+
if ((g?.name !== void 0 && g?.name !== null) !== (t.giveName !== void 0) || t.giveName !== void 0 && String(g?.name) !== t.giveName) return true;
|
|
1855
|
+
}
|
|
1765
1856
|
return false;
|
|
1766
1857
|
}
|
|
1767
1858
|
function bindProvenOffer(offerEv) {
|
|
@@ -1806,6 +1897,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
1806
1897
|
EPOCH_LEN,
|
|
1807
1898
|
FCLAIM_KEYS,
|
|
1808
1899
|
FCLAIM_MAX_EPOCH_AHEAD,
|
|
1900
|
+
FCLAIM_WINDOW_MIN,
|
|
1809
1901
|
FEE_BPS,
|
|
1810
1902
|
FEE_BPS_V16,
|
|
1811
1903
|
FEE_GATE_MARGIN_BLOCKS,
|
|
@@ -1873,6 +1965,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
1873
1965
|
V26_HEIGHT,
|
|
1874
1966
|
V27_HEIGHT,
|
|
1875
1967
|
V28_HEIGHT,
|
|
1968
|
+
V29_HEIGHT,
|
|
1876
1969
|
ZERO_ADDR,
|
|
1877
1970
|
bid,
|
|
1878
1971
|
bindOfferTerms,
|
|
@@ -1892,7 +1985,9 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
1892
1985
|
fclaimEpochFor,
|
|
1893
1986
|
fclaimHoldEnd,
|
|
1894
1987
|
feeBpsAt,
|
|
1988
|
+
fillEndorsement,
|
|
1895
1989
|
fillIsSafe,
|
|
1990
|
+
fillOutputPlan,
|
|
1896
1991
|
fillTargetId,
|
|
1897
1992
|
finalizeWinnerCheck,
|
|
1898
1993
|
hasLiveClaim,
|
|
@@ -1929,5 +2024,6 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
1929
2024
|
tokenMeta,
|
|
1930
2025
|
tradeFee,
|
|
1931
2026
|
transfer,
|
|
2027
|
+
unsafeMintProvenOfferTerms,
|
|
1932
2028
|
verifyFillSpv
|
|
1933
2029
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -73,9 +73,11 @@ declare const FINALIZE_TIP_MARGIN = 2;
|
|
|
73
73
|
declare const V26_HEIGHT = 46480;
|
|
74
74
|
declare const V27_HEIGHT = 46520;
|
|
75
75
|
declare const V28_HEIGHT = 60000;
|
|
76
|
+
declare const V29_HEIGHT = 88000;
|
|
76
77
|
declare const epochOf: (height: number) => number;
|
|
77
78
|
declare const claimWindowAt: (height: number) => number;
|
|
78
|
-
declare const
|
|
79
|
+
declare const FCLAIM_WINDOW_MIN: number;
|
|
80
|
+
declare const claimWindowOf: (claimUntilHeight: number, claimTxid?: string) => number;
|
|
79
81
|
declare const claimGraceOf: (claimUntilHeight: number, claimTxid?: string) => number;
|
|
80
82
|
declare const fclaimEpochFor: (tipHeight: number, offerExpiresEpoch: number) => number;
|
|
81
83
|
declare const fclaimHoldEnd: (expiresEpoch: number) => number;
|
|
@@ -486,11 +488,53 @@ declare function previewFill(offer: OfferState, payRaw: bigint | string | number
|
|
|
486
488
|
* claims/takers. Until 2026-07-06 this map was hand-mirrored in the wallet's fillOffer, the cairnx
|
|
487
489
|
* service txbuild, and TWICE in the cairn trade UI — four copies of fund-loss-class math with no
|
|
488
490
|
* cross-repo lock. This is now the only place it lives; test/preflight.test.ts pins it against the
|
|
489
|
-
* real resolver (outputs accepted; any single-unit per-address underpayment refused).
|
|
491
|
+
* real resolver (outputs accepted; any single-unit per-address underpayment refused).
|
|
492
|
+
*
|
|
493
|
+
* DOC CORRECTION (B6b / REBIND M1) - the `[]` vs `null` asymmetry is a live hazard, not a convenience:
|
|
494
|
+
* `[]` (token want) means "no CSD outputs are required", it does NOT mean "this fill is checked". Every
|
|
495
|
+
* caller whose safety loop is `for (const o of outs) ...` iterates ZERO times on a token fill and passes
|
|
496
|
+
* silently, while the undeliverable-CSD case (`null`) is explicitly refused. That asymmetry is the
|
|
497
|
+
* mechanical reason the token-fill hole (W1) propagated to every consumer. The token side of a fill is
|
|
498
|
+
* settled from the ATTESTER's token balance and carries the CONF_TOKEN_FILL confidence marker; nothing
|
|
499
|
+
* in this return value verifies any of that.
|
|
500
|
+
* @deprecated Use `fillOutputPlan` - it returns the same math behind a DISCRIMINATED result, so the
|
|
501
|
+
* token-want case cannot be silently conflated with "nothing to check". This function's behavior is
|
|
502
|
+
* FROZEN (published npm API; `[]` is load-bearing in downstream builders and tests) and it will keep
|
|
503
|
+
* working; new callers should not add to the need-map-loop hazard. */
|
|
490
504
|
declare function requiredFillOutputs(offer: OfferState, payRaw: bigint | string | number): {
|
|
491
505
|
to: string;
|
|
492
506
|
value: bigint;
|
|
493
507
|
}[] | null;
|
|
508
|
+
/** B6b (REBIND M1): the DISCRIMINATED successor to requiredFillOutputs. Same math (it calls
|
|
509
|
+
* requiredFillOutputs - the addr->sum map still lives in exactly one place); the difference is that the
|
|
510
|
+
* three outcomes a caller must treat differently are now three distinct kinds instead of `[] | null`:
|
|
511
|
+
* "csd-outputs" - build EXACTLY these CSD outputs (payto + treasury fee + maker rebate, merged per
|
|
512
|
+
* address). The normal CSD-priced case.
|
|
513
|
+
* "token-settled" - a token-priced offer: there are NO CSD outputs to build, and that is NOT the same
|
|
514
|
+
* as "checked". The fill debits the ATTESTER's want-token balance and the attest MUST
|
|
515
|
+
* carry `confidence` (= CONF_TOKEN_FILL, resolve.ts requires the explicit marker).
|
|
516
|
+
* Verify your token balance and terms yourself before signing.
|
|
517
|
+
* "undeliverable" - the resolver would reject this payment AFTER the CSD moved; do not sign.
|
|
518
|
+
* ADDITIVE and default-safe: requiredFillOutputs is unchanged in behavior (its `[]` is load-bearing in
|
|
519
|
+
* published consumers); this wrapper only makes the pivot impossible to fall through silently. */
|
|
520
|
+
type FillOutputPlan = {
|
|
521
|
+
kind: "csd-outputs";
|
|
522
|
+
outputs: {
|
|
523
|
+
to: string;
|
|
524
|
+
value: bigint;
|
|
525
|
+
}[];
|
|
526
|
+
preview: FillPreview;
|
|
527
|
+
} | {
|
|
528
|
+
kind: "token-settled";
|
|
529
|
+
outputs: [];
|
|
530
|
+
confidence: number;
|
|
531
|
+
preview: FillPreview;
|
|
532
|
+
} | {
|
|
533
|
+
kind: "undeliverable";
|
|
534
|
+
reason: "not-open" | "not-csd-priced" | "below-min" | "zero-delivery";
|
|
535
|
+
preview: FillPreview;
|
|
536
|
+
};
|
|
537
|
+
declare function fillOutputPlan(offer: OfferState, payRaw: bigint | string | number): FillOutputPlan;
|
|
494
538
|
/** Name-fee build heuristic (app-side, NOT a resolver rule): a name-fee OUTPUT built just below a fee
|
|
495
539
|
* gate but mined at/after it underpays the new tier → resolver rejects → the treasury-fee UTXO is
|
|
496
540
|
* forfeit. Within FEE_GATE_MARGIN_BLOCKS below ANY upcoming fee gate, price the BUILD at that gate:
|
|
@@ -514,15 +558,59 @@ declare function hasLiveClaim(offer: OfferState, me: string, tip: number): boole
|
|
|
514
558
|
declare function fillTargetId(offer: OfferState, tip: number): string;
|
|
515
559
|
/** The union verdict a client must clear BEFORE signing a fill of `offer` paying `pay`, as `me`, at `tip`.
|
|
516
560
|
* Closes C2/C3/C4: status open, deliverability >= 1 token, live-claim holdership for the open-CSD lane,
|
|
517
|
-
* and taker match.
|
|
518
|
-
*
|
|
519
|
-
*
|
|
561
|
+
* and taker match. Returns the preview so the caller can size outputs.
|
|
562
|
+
*
|
|
563
|
+
* DOC CORRECTION (B6b / REBIND W10) - the historical claim that `safe:true` means "the fill is guaranteed
|
|
564
|
+
* to be accepted by the deterministic gates a payer can verify at signing time" OVER-STATES this predicate
|
|
565
|
+
* on two counts, both live:
|
|
566
|
+
* 1. For a TOKEN-priced want it returns `safe:true` unconditionally ("deliverability is the buyer's
|
|
567
|
+
* balance"). That is an honest statement of what it cannot see, but as a boolean it reads as an
|
|
568
|
+
* ENDORSEMENT of the un-verifiable path - the never-over-claim rule this codebase holds elsewhere.
|
|
569
|
+
* 2. It never receives the FILL TARGET id, so it cannot implement the v2.8 Correction-1 clause: during
|
|
570
|
+
* a live fclaim hold the chain rejects an attest on the OFFER txid (the payment must attest the
|
|
571
|
+
* FCLAIM txid), and this predicate says `safe:true` for exactly that doomed fill.
|
|
572
|
+
* @deprecated Use `fillEndorsement` - a discriminated verdict ("endorsed" / "refused" / "not-endorsable")
|
|
573
|
+
* plus the `fillTargetId` parameter that closes both gaps. This function's verdicts are FROZEN (published
|
|
574
|
+
* npm API; flipping them could hard-refuse honest fills in unknowable third-party dApps) and it keeps
|
|
575
|
+
* working; it must not be "hardened" in place. */
|
|
520
576
|
interface FillSafety {
|
|
521
577
|
safe: boolean;
|
|
522
578
|
reason: string;
|
|
523
579
|
preview: FillPreview;
|
|
524
580
|
}
|
|
525
581
|
declare function fillIsSafe(offer: OfferState, me: string, pay: bigint | string | number, tip: number): FillSafety;
|
|
582
|
+
/** B6b (REBIND W10): the DISCRIMINATED successor to fillIsSafe. Three verdicts, and consuming them
|
|
583
|
+
* correctly is part of the contract:
|
|
584
|
+
* "endorsed" - every deterministic gate a payer can verify at signing time passes (status, taker,
|
|
585
|
+
* open-lane holdership, deliverability, and - NEW - the v2.8 fill-target routing).
|
|
586
|
+
* "refused" - the chain WILL reject this fill after the payment moved. Do not sign.
|
|
587
|
+
* "not-endorsable" - a TOKEN-priced want: deliverability is the attester's token balance, which this
|
|
588
|
+
* pure predicate cannot see. This is HONEST NON-ENDORSEMENT, not refusal: proceed
|
|
589
|
+
* with your own token-balance and proven-terms checks (a consumer that treats this
|
|
590
|
+
* as "refuse" hard-blocks every honest token fill - the named B7f trap).
|
|
591
|
+
*
|
|
592
|
+
* `opts.fillTargetId` is the proposal txid your attest will actually target. Pass it whenever you have
|
|
593
|
+
* it (= `fillTargetId(offer, tip)` for an honest builder). The v2.8 Correction-1 clause (resolve.ts
|
|
594
|
+
* openFillReject): during a live fclaim hold an attest on the OFFER txid is rejected while the payment
|
|
595
|
+
* still moves - the exact doomed fill the deprecated fillIsSafe endorses. If the offer carries a live
|
|
596
|
+
* fclaim-hold routing and no target is supplied, the endorsement fails CLOSED with instructions rather
|
|
597
|
+
* than guessing what your builder will attest. */
|
|
598
|
+
type FillEndorsement = {
|
|
599
|
+
verdict: "endorsed";
|
|
600
|
+
reason: "ok";
|
|
601
|
+
preview: FillPreview;
|
|
602
|
+
} | {
|
|
603
|
+
verdict: "refused";
|
|
604
|
+
reason: string;
|
|
605
|
+
preview: FillPreview;
|
|
606
|
+
} | {
|
|
607
|
+
verdict: "not-endorsable";
|
|
608
|
+
reason: string;
|
|
609
|
+
preview: FillPreview;
|
|
610
|
+
};
|
|
611
|
+
declare function fillEndorsement(offer: OfferState, me: string, pay: bigint | string | number, tip: number, opts?: {
|
|
612
|
+
fillTargetId?: string;
|
|
613
|
+
}): FillEndorsement;
|
|
526
614
|
/** C1: may `me` safely sign the fee-bearing registration `nfinalize` for `nameState` committed at
|
|
527
615
|
* `commitHeight`? The reg fee rides nfinalize; a finalize on a reservation that was displaced, has
|
|
528
616
|
* expired, OR is raised before the displacement contest froze is REJECTED after the fee moved (a burn).
|
|
@@ -599,10 +687,21 @@ interface FillVerdict {
|
|
|
599
687
|
* replay cannot see the buyer's other-offer holds, and MAX_ACTIVE_CLAIMS is the one grant clause counted
|
|
600
688
|
* across offers, so without this the surface would false-accept a cap-denied fclaim. `opts.pay` overrides the
|
|
601
689
|
* payment (base units to want.payto) for a PARTIAL tail-fill; defaults to the offer's full want.value.
|
|
690
|
+
*
|
|
691
|
+
* `opts.sums` (OPT-IN, B6a / REBIND W3; default OFF = byte-identical verdicts for existing callers) binds the
|
|
692
|
+
* caller's PLANNED per-address CSD payment sums to the PROVEN offer state: requiredFillOutputs is re-run over
|
|
693
|
+
* the merkle-proven, replayed offer (so `paid`/`delivered` are the chain's, not a served lie) and the caller's
|
|
694
|
+
* map must match it EXACTLY, address for address. This closes the W3 overpay: a resolver serving `paid:"0"`
|
|
695
|
+
* for a 90%-filled partial made callers size the FULL want while the chain credits only the remainder - the
|
|
696
|
+
* difference was permanently overpaid. Pass the SAME per-address sums you will build (the wallet's need-map
|
|
697
|
+
* shape: payto + treasury fee + maker rebate, MERGED per address - `payto === seller` merges the rebate leg).
|
|
698
|
+
* DELIBERATELY NOT the scalar `dp.pay !== pay` form: that refuses honest fills on both live callers (the
|
|
699
|
+
* wallet's per-address sum includes the maker rebate when payto === seller; the site passes no pay at all).
|
|
602
700
|
*/
|
|
603
701
|
declare function verifyFillSpv(offerId: string, fclaimTxid: string, me: string, io: FillSpvIo, opts: {
|
|
604
702
|
myLiveHoldsAtGrant: number;
|
|
605
703
|
pay?: bigint | string | number;
|
|
704
|
+
sums?: Record<string, bigint | string | number>;
|
|
606
705
|
}): Promise<FillVerdict>;
|
|
607
706
|
interface ProvenOfferTerms {
|
|
608
707
|
height: number;
|
|
@@ -611,9 +710,20 @@ interface ProvenOfferTerms {
|
|
|
611
710
|
taker?: string;
|
|
612
711
|
bid?: string;
|
|
613
712
|
min?: string;
|
|
614
|
-
|
|
713
|
+
giveTicker?: string;
|
|
714
|
+
giveAmount?: string;
|
|
715
|
+
giveName?: string;
|
|
716
|
+
wantType?: "csd" | "token";
|
|
717
|
+
}
|
|
718
|
+
declare const PROVEN_TERMS_MINT: unique symbol;
|
|
719
|
+
type MintedProvenOfferTerms = ProvenOfferTerms & {
|
|
720
|
+
readonly [PROVEN_TERMS_MINT]: "cairnx-core/provenOfferTerms";
|
|
721
|
+
};
|
|
722
|
+
/** UNSAFE escape hatch, TESTS ONLY: brand a hand-built terms object. Production code must never call this -
|
|
723
|
+
* hand-built terms are exactly the W2 defect class the brand exists to make unrepresentable. */
|
|
724
|
+
declare const unsafeMintProvenOfferTerms: (t: ProvenOfferTerms) => MintedProvenOfferTerms;
|
|
615
725
|
declare const feeBpsAt: (height: number) => number;
|
|
616
|
-
declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number):
|
|
726
|
+
declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number): MintedProvenOfferTerms;
|
|
617
727
|
/**
|
|
618
728
|
* The fill-boundary TERM-MISMATCH verdict: `true` iff any fee/rebate/partial-sizing field of the resolver-
|
|
619
729
|
* SERVED offer diverges from the merkle-proven terms `t`. FAIL-CLOSED semantics (any divergence => true =>
|
|
@@ -628,12 +738,29 @@ declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number):
|
|
|
628
738
|
* both mismatch. EXPLICIT presence (a served min="" must not slip past a proven-absent min).
|
|
629
739
|
* `value` is bound only when `t.value` is defined so a token<->token offer (no CSD value) is not spuriously
|
|
630
740
|
* refused; a caller that binds want.value separately (the site does) may still pass it here (redundant-safe).
|
|
741
|
+
*
|
|
742
|
+
* B6a (REBIND W2 legs + W7) OPT-IN legs, via the third argument (default OFF: a 2-arg call is byte-identical
|
|
743
|
+
* to the pre-B6 predicate on every input). The 3-arg overload requires MINTED terms (the brand), so a caller
|
|
744
|
+
* adopting the new legs cannot feed them a hand-built terms object that leaves the new fields undefined -
|
|
745
|
+
* that shape would false-refuse every honest fill (the W2 trap this file documents).
|
|
746
|
+
* opts.give - bind give.ticker / give.amount / give.name: EXPLICIT PRESENCE (a served give growing or
|
|
747
|
+
* losing a field mismatches) AND verbatim string equality. Closes the W7 shortchange (a
|
|
748
|
+
* genuine offer served with give.amount inflated a millionfold passes every legacy leg).
|
|
749
|
+
* opts.wantType - the SYMMETRIC want-type refusal: the served offer's want type (token iff want.ticker is
|
|
750
|
+
* a string, the isTokenWant pivot) must equal the proven type. The legacy value leg already
|
|
751
|
+
* catches proven-CSD-served-as-token (String(undefined) mismatches t.value); this closes
|
|
752
|
+
* the reverse, proven-token-served-as-CSD, which today only wallet.ts catches one-sidedly.
|
|
631
753
|
*/
|
|
754
|
+
interface BindTermsOpts {
|
|
755
|
+
give?: boolean;
|
|
756
|
+
wantType?: boolean;
|
|
757
|
+
}
|
|
632
758
|
declare function bindOfferTerms(servedOffer: unknown, t: ProvenOfferTerms): boolean;
|
|
759
|
+
declare function bindOfferTerms(servedOffer: unknown, t: MintedProvenOfferTerms, opts: BindTermsOpts): boolean;
|
|
633
760
|
declare function bindProvenOffer(offerEv: ProvenPropose): {
|
|
634
761
|
payto: string;
|
|
635
762
|
seller: string;
|
|
636
|
-
terms:
|
|
763
|
+
terms: MintedProvenOfferTerms;
|
|
637
764
|
} | null;
|
|
638
765
|
|
|
639
766
|
declare function paidToFromOutputs(outputs: readonly {
|
|
@@ -641,4 +768,4 @@ declare function paidToFromOutputs(outputs: readonly {
|
|
|
641
768
|
value: number;
|
|
642
769
|
}[]): Record<string, string>;
|
|
643
770
|
|
|
644
|
-
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, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEntry, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, 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, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, 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, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillIsSafe, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, verifyFillSpv };
|
|
771
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, 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, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, 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, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, 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, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|