@inversealtruism/cairnx-core 0.2.0 → 0.2.1
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/CHANGELOG.md +7 -0
- package/CONVENTION.md +150 -150
- package/MAKERS.md +4 -7
- package/README.md +7 -6
- package/dist/index.cjs +1021 -867
- package/dist/index.d.cts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +1021 -867
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -427,6 +427,7 @@ declare const nameProfile: (r: Omit<NameProfileRecord, "v" | "t">) => BuiltRecor
|
|
|
427
427
|
declare const fclaim: (r: Omit<FclaimRecord, "v" | "t">) => BuiltRecord;
|
|
428
428
|
|
|
429
429
|
declare function ptAmt(v: unknown): bigint;
|
|
430
|
+
|
|
430
431
|
declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
431
432
|
/** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
|
|
432
433
|
* The canonical surface is the DATA ONLY: {tipHeight, tokens, balances, names, offers, bids,
|
|
@@ -477,8 +478,9 @@ interface FillPreview {
|
|
|
477
478
|
/** Preview a fill of `offer` paying `payRaw` CSD base units to the seller. Pure; no I/O. */
|
|
478
479
|
declare function previewFill(offer: OfferState, payRaw: bigint | string | number): FillPreview;
|
|
479
480
|
/** The exact CSD outputs a fill of `offer` paying `payRaw` must carry to clear the resolver's value
|
|
480
|
-
* gate
|
|
481
|
-
*
|
|
481
|
+
* gate: the addr→sum map of `applyFill` (whole: payto + treasury fee + maker rebate) and the payment and
|
|
482
|
+
* fee checks of `applyPartialFill` (partial: clamped payment + fee on the clamped amount, NO rebate), both in
|
|
483
|
+
* src/resolve/attest.ts, as a build-ready output
|
|
482
484
|
* list. Amounts are ACCUMULATED per address (payto === seller is the common case; the resolver checks
|
|
483
485
|
* the per-address SUM, so two merged entries must merge here too), insertion order payto → treasury →
|
|
484
486
|
* seller, zero-value entries omitted (a 0 output is unbuildable and the resolver requires nothing).
|
|
@@ -512,7 +514,7 @@ declare function requiredFillOutputs(offer: OfferState, payRaw: bigint | string
|
|
|
512
514
|
* address). The normal CSD-priced case.
|
|
513
515
|
* "token-settled" - a token-priced offer: there are NO CSD outputs to build, and that is NOT the same
|
|
514
516
|
* as "checked". The fill debits the ATTESTER's want-token balance and the attest MUST
|
|
515
|
-
* carry `confidence` (= CONF_TOKEN_FILL
|
|
517
|
+
* carry `confidence` (= CONF_TOKEN_FILL; `applyTokenFill` in src/resolve/attest.ts requires the explicit marker).
|
|
516
518
|
* Verify your token balance and terms yourself before signing.
|
|
517
519
|
* "undeliverable" - the resolver would reject this payment AFTER the CSD moved; do not sign.
|
|
518
520
|
* ADDITIVE and default-safe: requiredFillOutputs is unchanged in behavior (its `[]` is load-bearing in
|
|
@@ -545,10 +547,10 @@ declare function fillOutputPlan(offer: OfferState, payRaw: bigint | string | num
|
|
|
545
547
|
declare const FEE_GATE_MARGIN_BLOCKS = 5;
|
|
546
548
|
declare const buildFeeHeight: (tip: number) => number;
|
|
547
549
|
/** Is the offer an OPEN (untaken) CSD-priced offer subject to the v1.7 claim-to-fill gate at `tip`?
|
|
548
|
-
* Such an offer may be filled ONLY by the holder of a LIVE claim (resolve.ts
|
|
550
|
+
* Such an offer may be filled ONLY by the holder of a LIVE claim (`openFillReject`, src/resolve/attest.ts). */
|
|
549
551
|
declare function isOpenClaimLane(offer: OfferState, tip: number): boolean;
|
|
550
|
-
/** Does `me` currently hold a LIVE claim on `offer` at `tip`? Mirrors resolve.ts
|
|
551
|
-
* who===claimedBy check (
|
|
552
|
+
/** Does `me` currently hold a LIVE claim on `offer` at `tip`? Mirrors `claimHeld` (src/resolve/context.ts) + the
|
|
553
|
+
* who===claimedBy check in `openFillReject` (src/resolve/attest.ts). For a pre-V17 open offer, open fills are banned entirely. */
|
|
552
554
|
declare function hasLiveClaim(offer: OfferState, me: string, tip: number): boolean;
|
|
553
555
|
/** v2.8 Correction 1 mirror (§31): the proposal txid a fill of `offer` MUST attest at `tip`. During a live
|
|
554
556
|
* fclaim hold (V28+) the payment must target the FCLAIM txid, not the offer id (an offer-txid fill is
|
|
@@ -590,8 +592,8 @@ declare function fillIsSafe(offer: OfferState, me: string, pay: bigint | string
|
|
|
590
592
|
* as "refuse" hard-blocks every honest token fill - the named B7f trap).
|
|
591
593
|
*
|
|
592
594
|
* `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 (
|
|
594
|
-
*
|
|
595
|
+
* it (= `fillTargetId(offer, tip)` for an honest builder). The v2.8 Correction-1 clause (`openFillReject`,
|
|
596
|
+
* src/resolve/attest.ts): during a live fclaim hold an attest on the OFFER txid is rejected while the payment
|
|
595
597
|
* still moves - the exact doomed fill the deprecated fillIsSafe endorses. If the offer carries a live
|
|
596
598
|
* fclaim-hold routing and no target is supplied, the endorsement fails CLOSED with instructions rather
|
|
597
599
|
* than guessing what your builder will attest. */
|
|
@@ -627,7 +629,7 @@ declare function fillEndorsement(offer: OfferState, me: string, pay: bigint | st
|
|
|
627
629
|
* re-fetched) name record — never a cached one — as `nameState` (undefined = 404 / unregistered = loss).
|
|
628
630
|
*
|
|
629
631
|
* Pass `tip` to ALSO gate the finalize WINDOW, both sides, mirroring the resolver's authoritative checks
|
|
630
|
-
* (resolve.ts
|
|
632
|
+
* (`applyNfinalize` in src/resolve/names.ts rejects unless `ev.height > effHeight + REG_COMMIT_MAX_BLOCKS`, and rejects when
|
|
631
633
|
* `ev.height > finalizeBy`) with the client-side FINALIZE_TIP_MARGIN band the site's finalizeReady applies:
|
|
632
634
|
* the tx signs at `tip` but mines at tip+1 or later, so the margin keeps a boundary-signed finalize from
|
|
633
635
|
* mining outside the window (too early: rejected as unfrozen; too late: past the deadline — either way the
|
package/dist/index.d.ts
CHANGED
|
@@ -427,6 +427,7 @@ declare const nameProfile: (r: Omit<NameProfileRecord, "v" | "t">) => BuiltRecor
|
|
|
427
427
|
declare const fclaim: (r: Omit<FclaimRecord, "v" | "t">) => BuiltRecord;
|
|
428
428
|
|
|
429
429
|
declare function ptAmt(v: unknown): bigint;
|
|
430
|
+
|
|
430
431
|
declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
431
432
|
/** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
|
|
432
433
|
* The canonical surface is the DATA ONLY: {tipHeight, tokens, balances, names, offers, bids,
|
|
@@ -477,8 +478,9 @@ interface FillPreview {
|
|
|
477
478
|
/** Preview a fill of `offer` paying `payRaw` CSD base units to the seller. Pure; no I/O. */
|
|
478
479
|
declare function previewFill(offer: OfferState, payRaw: bigint | string | number): FillPreview;
|
|
479
480
|
/** The exact CSD outputs a fill of `offer` paying `payRaw` must carry to clear the resolver's value
|
|
480
|
-
* gate
|
|
481
|
-
*
|
|
481
|
+
* gate: the addr→sum map of `applyFill` (whole: payto + treasury fee + maker rebate) and the payment and
|
|
482
|
+
* fee checks of `applyPartialFill` (partial: clamped payment + fee on the clamped amount, NO rebate), both in
|
|
483
|
+
* src/resolve/attest.ts, as a build-ready output
|
|
482
484
|
* list. Amounts are ACCUMULATED per address (payto === seller is the common case; the resolver checks
|
|
483
485
|
* the per-address SUM, so two merged entries must merge here too), insertion order payto → treasury →
|
|
484
486
|
* seller, zero-value entries omitted (a 0 output is unbuildable and the resolver requires nothing).
|
|
@@ -512,7 +514,7 @@ declare function requiredFillOutputs(offer: OfferState, payRaw: bigint | string
|
|
|
512
514
|
* address). The normal CSD-priced case.
|
|
513
515
|
* "token-settled" - a token-priced offer: there are NO CSD outputs to build, and that is NOT the same
|
|
514
516
|
* as "checked". The fill debits the ATTESTER's want-token balance and the attest MUST
|
|
515
|
-
* carry `confidence` (= CONF_TOKEN_FILL
|
|
517
|
+
* carry `confidence` (= CONF_TOKEN_FILL; `applyTokenFill` in src/resolve/attest.ts requires the explicit marker).
|
|
516
518
|
* Verify your token balance and terms yourself before signing.
|
|
517
519
|
* "undeliverable" - the resolver would reject this payment AFTER the CSD moved; do not sign.
|
|
518
520
|
* ADDITIVE and default-safe: requiredFillOutputs is unchanged in behavior (its `[]` is load-bearing in
|
|
@@ -545,10 +547,10 @@ declare function fillOutputPlan(offer: OfferState, payRaw: bigint | string | num
|
|
|
545
547
|
declare const FEE_GATE_MARGIN_BLOCKS = 5;
|
|
546
548
|
declare const buildFeeHeight: (tip: number) => number;
|
|
547
549
|
/** Is the offer an OPEN (untaken) CSD-priced offer subject to the v1.7 claim-to-fill gate at `tip`?
|
|
548
|
-
* Such an offer may be filled ONLY by the holder of a LIVE claim (resolve.ts
|
|
550
|
+
* Such an offer may be filled ONLY by the holder of a LIVE claim (`openFillReject`, src/resolve/attest.ts). */
|
|
549
551
|
declare function isOpenClaimLane(offer: OfferState, tip: number): boolean;
|
|
550
|
-
/** Does `me` currently hold a LIVE claim on `offer` at `tip`? Mirrors resolve.ts
|
|
551
|
-
* who===claimedBy check (
|
|
552
|
+
/** Does `me` currently hold a LIVE claim on `offer` at `tip`? Mirrors `claimHeld` (src/resolve/context.ts) + the
|
|
553
|
+
* who===claimedBy check in `openFillReject` (src/resolve/attest.ts). For a pre-V17 open offer, open fills are banned entirely. */
|
|
552
554
|
declare function hasLiveClaim(offer: OfferState, me: string, tip: number): boolean;
|
|
553
555
|
/** v2.8 Correction 1 mirror (§31): the proposal txid a fill of `offer` MUST attest at `tip`. During a live
|
|
554
556
|
* fclaim hold (V28+) the payment must target the FCLAIM txid, not the offer id (an offer-txid fill is
|
|
@@ -590,8 +592,8 @@ declare function fillIsSafe(offer: OfferState, me: string, pay: bigint | string
|
|
|
590
592
|
* as "refuse" hard-blocks every honest token fill - the named B7f trap).
|
|
591
593
|
*
|
|
592
594
|
* `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 (
|
|
594
|
-
*
|
|
595
|
+
* it (= `fillTargetId(offer, tip)` for an honest builder). The v2.8 Correction-1 clause (`openFillReject`,
|
|
596
|
+
* src/resolve/attest.ts): during a live fclaim hold an attest on the OFFER txid is rejected while the payment
|
|
595
597
|
* still moves - the exact doomed fill the deprecated fillIsSafe endorses. If the offer carries a live
|
|
596
598
|
* fclaim-hold routing and no target is supplied, the endorsement fails CLOSED with instructions rather
|
|
597
599
|
* than guessing what your builder will attest. */
|
|
@@ -627,7 +629,7 @@ declare function fillEndorsement(offer: OfferState, me: string, pay: bigint | st
|
|
|
627
629
|
* re-fetched) name record — never a cached one — as `nameState` (undefined = 404 / unregistered = loss).
|
|
628
630
|
*
|
|
629
631
|
* Pass `tip` to ALSO gate the finalize WINDOW, both sides, mirroring the resolver's authoritative checks
|
|
630
|
-
* (resolve.ts
|
|
632
|
+
* (`applyNfinalize` in src/resolve/names.ts rejects unless `ev.height > effHeight + REG_COMMIT_MAX_BLOCKS`, and rejects when
|
|
631
633
|
* `ev.height > finalizeBy`) with the client-side FINALIZE_TIP_MARGIN band the site's finalizeReady applies:
|
|
632
634
|
* the tx signs at `tip` but mines at tip+1 or later, so the margin keeps a boundary-signed finalize from
|
|
633
635
|
* mining outside the window (too early: rejected as unfrozen; too late: past the deadline — either way the
|