@inversealtruism/cairnx-core 0.2.0 → 0.2.2
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 +44 -0
- package/CONVENTION.md +150 -150
- package/MAKERS.md +4 -7
- package/README.md +7 -6
- package/dist/index.cjs +1061 -874
- package/dist/index.d.cts +70 -13
- package/dist/index.d.ts +70 -13
- package/dist/index.js +1057 -874
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -19,6 +19,8 @@ declare const NAME_PREMIUM_DECAY_EPOCHS = 720;
|
|
|
19
19
|
declare function expiredClaimFee(name: string, epochsPastGraceEnd: number, height: number): bigint;
|
|
20
20
|
declare const MAX_RECORD_BYTES = 512;
|
|
21
21
|
declare const MAX_AMOUNT: bigint;
|
|
22
|
+
/** The most decimals a token deploy may declare (parseRecord refuses a deploy above it). */
|
|
23
|
+
declare const MAX_TOKEN_DECIMALS = 8;
|
|
22
24
|
declare const SCORE_FILL = 100;
|
|
23
25
|
declare const SCORE_CANCEL = 0;
|
|
24
26
|
declare const SCORE_CLAIM = 50;
|
|
@@ -427,6 +429,7 @@ declare const nameProfile: (r: Omit<NameProfileRecord, "v" | "t">) => BuiltRecor
|
|
|
427
429
|
declare const fclaim: (r: Omit<FclaimRecord, "v" | "t">) => BuiltRecord;
|
|
428
430
|
|
|
429
431
|
declare function ptAmt(v: unknown): bigint;
|
|
432
|
+
|
|
430
433
|
declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
431
434
|
/** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
|
|
432
435
|
* The canonical surface is the DATA ONLY: {tipHeight, tokens, balances, names, offers, bids,
|
|
@@ -477,8 +480,9 @@ interface FillPreview {
|
|
|
477
480
|
/** Preview a fill of `offer` paying `payRaw` CSD base units to the seller. Pure; no I/O. */
|
|
478
481
|
declare function previewFill(offer: OfferState, payRaw: bigint | string | number): FillPreview;
|
|
479
482
|
/** The exact CSD outputs a fill of `offer` paying `payRaw` must carry to clear the resolver's value
|
|
480
|
-
* gate
|
|
481
|
-
*
|
|
483
|
+
* gate: the addr→sum map of `applyFill` (whole: payto + treasury fee + maker rebate) and the payment and
|
|
484
|
+
* fee checks of `applyPartialFill` (partial: clamped payment + fee on the clamped amount, NO rebate), both in
|
|
485
|
+
* src/resolve/attest.ts, as a build-ready output
|
|
482
486
|
* list. Amounts are ACCUMULATED per address (payto === seller is the common case; the resolver checks
|
|
483
487
|
* the per-address SUM, so two merged entries must merge here too), insertion order payto → treasury →
|
|
484
488
|
* seller, zero-value entries omitted (a 0 output is unbuildable and the resolver requires nothing).
|
|
@@ -512,7 +516,7 @@ declare function requiredFillOutputs(offer: OfferState, payRaw: bigint | string
|
|
|
512
516
|
* address). The normal CSD-priced case.
|
|
513
517
|
* "token-settled" - a token-priced offer: there are NO CSD outputs to build, and that is NOT the same
|
|
514
518
|
* as "checked". The fill debits the ATTESTER's want-token balance and the attest MUST
|
|
515
|
-
* carry `confidence` (= CONF_TOKEN_FILL
|
|
519
|
+
* carry `confidence` (= CONF_TOKEN_FILL; `applyTokenFill` in src/resolve/attest.ts requires the explicit marker).
|
|
516
520
|
* Verify your token balance and terms yourself before signing.
|
|
517
521
|
* "undeliverable" - the resolver would reject this payment AFTER the CSD moved; do not sign.
|
|
518
522
|
* ADDITIVE and default-safe: requiredFillOutputs is unchanged in behavior (its `[]` is load-bearing in
|
|
@@ -545,10 +549,10 @@ declare function fillOutputPlan(offer: OfferState, payRaw: bigint | string | num
|
|
|
545
549
|
declare const FEE_GATE_MARGIN_BLOCKS = 5;
|
|
546
550
|
declare const buildFeeHeight: (tip: number) => number;
|
|
547
551
|
/** 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
|
|
552
|
+
* Such an offer may be filled ONLY by the holder of a LIVE claim (`openFillReject`, src/resolve/attest.ts). */
|
|
549
553
|
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 (
|
|
554
|
+
/** Does `me` currently hold a LIVE claim on `offer` at `tip`? Mirrors `claimHeld` (src/resolve/context.ts) + the
|
|
555
|
+
* who===claimedBy check in `openFillReject` (src/resolve/attest.ts). For a pre-V17 open offer, open fills are banned entirely. */
|
|
552
556
|
declare function hasLiveClaim(offer: OfferState, me: string, tip: number): boolean;
|
|
553
557
|
/** v2.8 Correction 1 mirror (§31): the proposal txid a fill of `offer` MUST attest at `tip`. During a live
|
|
554
558
|
* fclaim hold (V28+) the payment must target the FCLAIM txid, not the offer id (an offer-txid fill is
|
|
@@ -590,8 +594,8 @@ declare function fillIsSafe(offer: OfferState, me: string, pay: bigint | string
|
|
|
590
594
|
* as "refuse" hard-blocks every honest token fill - the named B7f trap).
|
|
591
595
|
*
|
|
592
596
|
* `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
|
-
*
|
|
597
|
+
* it (= `fillTargetId(offer, tip)` for an honest builder). The v2.8 Correction-1 clause (`openFillReject`,
|
|
598
|
+
* src/resolve/attest.ts): during a live fclaim hold an attest on the OFFER txid is rejected while the payment
|
|
595
599
|
* still moves - the exact doomed fill the deprecated fillIsSafe endorses. If the offer carries a live
|
|
596
600
|
* fclaim-hold routing and no target is supplied, the endorsement fails CLOSED with instructions rather
|
|
597
601
|
* than guessing what your builder will attest. */
|
|
@@ -627,13 +631,14 @@ declare function fillEndorsement(offer: OfferState, me: string, pay: bigint | st
|
|
|
627
631
|
* re-fetched) name record — never a cached one — as `nameState` (undefined = 404 / unregistered = loss).
|
|
628
632
|
*
|
|
629
633
|
* Pass `tip` to ALSO gate the finalize WINDOW, both sides, mirroring the resolver's authoritative checks
|
|
630
|
-
* (resolve.ts
|
|
634
|
+
* (`applyNfinalize` in src/resolve/names.ts rejects unless `ev.height > effHeight + REG_COMMIT_MAX_BLOCKS`, and rejects when
|
|
631
635
|
* `ev.height > finalizeBy`) with the client-side FINALIZE_TIP_MARGIN band the site's finalizeReady applies:
|
|
632
636
|
* the tx signs at `tip` but mines at tip+1 or later, so the margin keeps a boundary-signed finalize from
|
|
633
637
|
* mining outside the window (too early: rejected as unfrozen; too late: past the deadline — either way the
|
|
634
638
|
* fee burns). The window is derived purely from `eff` (never the resolver's `finalizeBy`), so a lying
|
|
635
639
|
* `finalizeBy` cannot widen it — but per the trust scope above, a lying `eff` still can for a caller that
|
|
636
|
-
* does not supply an independent `commitHeight`. `tip` is optional; without it the winner-only path runs.
|
|
640
|
+
* does not supply an independent `commitHeight`. `tip` is optional; without it the winner-only path runs. A
|
|
641
|
+
* supplied `tip` that is not a non-negative safe integer is refused. */
|
|
637
642
|
declare function finalizeWinnerCheck(nameState: NameState | null | undefined, me: string, commitHeight: number, tip?: number | null): {
|
|
638
643
|
safe: boolean;
|
|
639
644
|
reason: string;
|
|
@@ -683,7 +688,7 @@ interface FillVerdict {
|
|
|
683
688
|
* not-mine hold, a below-depth signing, a zero-delivery fill, a stranded past-deadline broadcast).
|
|
684
689
|
*
|
|
685
690
|
* `opts.myLiveHoldsAtGrant` (REQUIRED) is the buyer's count of OTHER live fclaim/legacy holds at the moment
|
|
686
|
-
* THIS fclaim was granted, asserted by the authoring client (
|
|
691
|
+
* THIS fclaim was granted, asserted by the authoring client (countOtherHoldsAtGrant computes it). The lane-scoped
|
|
687
692
|
* replay cannot see the buyer's other-offer holds, and MAX_ACTIVE_CLAIMS is the one grant clause counted
|
|
688
693
|
* across offers, so without this the surface would false-accept a cap-denied fclaim. `opts.pay` overrides the
|
|
689
694
|
* payment (base units to want.payto) for a PARTIAL tail-fill; defaults to the offer's full want.value.
|
|
@@ -716,6 +721,8 @@ interface ProvenOfferTerms {
|
|
|
716
721
|
giveAmount?: string;
|
|
717
722
|
giveName?: string;
|
|
718
723
|
wantType?: "csd" | "token";
|
|
724
|
+
wantTicker?: string;
|
|
725
|
+
wantAmount?: string;
|
|
719
726
|
}
|
|
720
727
|
declare const PROVEN_TERMS_MINT: unique symbol;
|
|
721
728
|
type MintedProvenOfferTerms = ProvenOfferTerms & {
|
|
@@ -752,7 +759,8 @@ declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number):
|
|
|
752
759
|
* wantType - the SYMMETRIC want-type refusal: the served offer's want type (token iff want.ticker is
|
|
753
760
|
* a string, the isTokenWant pivot) must equal the proven type. The value leg already
|
|
754
761
|
* catches proven-CSD-served-as-token (String(undefined) mismatches t.value); this closes
|
|
755
|
-
* the reverse, proven-token-served-as-CSD.
|
|
762
|
+
* the reverse, proven-token-served-as-CSD. For a proven token want the served want.ticker
|
|
763
|
+
* and want.amount must also equal the proven price, verbatim.
|
|
756
764
|
*/
|
|
757
765
|
interface BindTermsOpts {
|
|
758
766
|
give?: boolean;
|
|
@@ -798,4 +806,53 @@ declare function myProvenFillClosedOffer(fill: ProvenEvent | null, fclaim: {
|
|
|
798
806
|
offer: string;
|
|
799
807
|
}, offerEv: ProvenEvent | null, me: string, grantHeight: number): boolean;
|
|
800
808
|
|
|
801
|
-
|
|
809
|
+
declare const LEGACY_HOLD_SUNSET_HEIGHT: number;
|
|
810
|
+
/** The count, or a refusal the caller must treat as unsafe (fail closed). */
|
|
811
|
+
type HoldCount = {
|
|
812
|
+
ok: true;
|
|
813
|
+
count: number;
|
|
814
|
+
} | {
|
|
815
|
+
ok: false;
|
|
816
|
+
reason: string;
|
|
817
|
+
};
|
|
818
|
+
/** An fclaim Propose the buyer may hold, read from a merkle-bound block. `proposer` is the prevout-bound author,
|
|
819
|
+
* or the buyer when it cannot be bound (over-counting only refuses a fill; under-counting can burn one). */
|
|
820
|
+
interface HoldCandidate {
|
|
821
|
+
id: string;
|
|
822
|
+
height: number;
|
|
823
|
+
pos: number;
|
|
824
|
+
proposer: string;
|
|
825
|
+
uri: string;
|
|
826
|
+
payloadHash: string;
|
|
827
|
+
expiresEpoch: number;
|
|
828
|
+
}
|
|
829
|
+
/** The fclaim being filled: its id, its proven block height and position, and the offer it reserves. */
|
|
830
|
+
interface HoldTarget {
|
|
831
|
+
id: string;
|
|
832
|
+
height: number;
|
|
833
|
+
pos: number;
|
|
834
|
+
offer: string;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* An upper bound of the buyer's live holds on other offers when `target` was granted: distinct other offers with
|
|
838
|
+
* an fclaim by `me` applied before the target (height, then position in the block) whose hold is still live at the
|
|
839
|
+
* target's height. `closed` names fclaims whose offer the buyer's own proven fill closed (myProvenFillClosedOffer);
|
|
840
|
+
* they are skipped. An earlier fclaim the resolver denied is still counted: its denial is not visible here.
|
|
841
|
+
* Domain: grants at or above LEGACY_HOLD_SUNSET_HEIGHT. Below it a legacy SCORE_CLAIM hold from before V28 can
|
|
842
|
+
* still be live and count against the cap, so the result is a refusal.
|
|
843
|
+
*/
|
|
844
|
+
declare function countOtherHoldsAtGrant(candidates: readonly HoldCandidate[], target: HoldTarget, me: string, closed?: ReadonlySet<string>): HoldCount;
|
|
845
|
+
|
|
846
|
+
/** Fields of the merkle-proven Propose: its app domain and expires_epoch, its inclusion height, and its author
|
|
847
|
+
* (csd-crypto authorOf). */
|
|
848
|
+
interface ProvenOfferTx {
|
|
849
|
+
domain: string;
|
|
850
|
+
height: number;
|
|
851
|
+
expiresEpoch: number | bigint;
|
|
852
|
+
seller: string;
|
|
853
|
+
}
|
|
854
|
+
/** Why the proven offer Propose is not an offer the resolver admits (the resolver's own note for the record
|
|
855
|
+
* rules), or null when it passes. */
|
|
856
|
+
declare function provenOfferRefusal(rec: OfferRecord, tx: ProvenOfferTx): string | null;
|
|
857
|
+
|
|
858
|
+
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 HoldCandidate, type HoldCount, type HoldReplay, type HoldTarget, LEGACY_HOLD_SUNSET_HEIGHT, type LegacyBindOpts, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MAX_TOKEN_DECIMALS, 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 ProvenOfferTx, 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, burnedPayment, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, countOtherHoldsAtGrant, deploy, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, myProvenFillClosedOffer, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferRefusal, provenOfferTerms, ptAmt, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ declare const NAME_PREMIUM_DECAY_EPOCHS = 720;
|
|
|
19
19
|
declare function expiredClaimFee(name: string, epochsPastGraceEnd: number, height: number): bigint;
|
|
20
20
|
declare const MAX_RECORD_BYTES = 512;
|
|
21
21
|
declare const MAX_AMOUNT: bigint;
|
|
22
|
+
/** The most decimals a token deploy may declare (parseRecord refuses a deploy above it). */
|
|
23
|
+
declare const MAX_TOKEN_DECIMALS = 8;
|
|
22
24
|
declare const SCORE_FILL = 100;
|
|
23
25
|
declare const SCORE_CANCEL = 0;
|
|
24
26
|
declare const SCORE_CLAIM = 50;
|
|
@@ -427,6 +429,7 @@ declare const nameProfile: (r: Omit<NameProfileRecord, "v" | "t">) => BuiltRecor
|
|
|
427
429
|
declare const fclaim: (r: Omit<FclaimRecord, "v" | "t">) => BuiltRecord;
|
|
428
430
|
|
|
429
431
|
declare function ptAmt(v: unknown): bigint;
|
|
432
|
+
|
|
430
433
|
declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
431
434
|
/** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
|
|
432
435
|
* The canonical surface is the DATA ONLY: {tipHeight, tokens, balances, names, offers, bids,
|
|
@@ -477,8 +480,9 @@ interface FillPreview {
|
|
|
477
480
|
/** Preview a fill of `offer` paying `payRaw` CSD base units to the seller. Pure; no I/O. */
|
|
478
481
|
declare function previewFill(offer: OfferState, payRaw: bigint | string | number): FillPreview;
|
|
479
482
|
/** The exact CSD outputs a fill of `offer` paying `payRaw` must carry to clear the resolver's value
|
|
480
|
-
* gate
|
|
481
|
-
*
|
|
483
|
+
* gate: the addr→sum map of `applyFill` (whole: payto + treasury fee + maker rebate) and the payment and
|
|
484
|
+
* fee checks of `applyPartialFill` (partial: clamped payment + fee on the clamped amount, NO rebate), both in
|
|
485
|
+
* src/resolve/attest.ts, as a build-ready output
|
|
482
486
|
* list. Amounts are ACCUMULATED per address (payto === seller is the common case; the resolver checks
|
|
483
487
|
* the per-address SUM, so two merged entries must merge here too), insertion order payto → treasury →
|
|
484
488
|
* seller, zero-value entries omitted (a 0 output is unbuildable and the resolver requires nothing).
|
|
@@ -512,7 +516,7 @@ declare function requiredFillOutputs(offer: OfferState, payRaw: bigint | string
|
|
|
512
516
|
* address). The normal CSD-priced case.
|
|
513
517
|
* "token-settled" - a token-priced offer: there are NO CSD outputs to build, and that is NOT the same
|
|
514
518
|
* as "checked". The fill debits the ATTESTER's want-token balance and the attest MUST
|
|
515
|
-
* carry `confidence` (= CONF_TOKEN_FILL
|
|
519
|
+
* carry `confidence` (= CONF_TOKEN_FILL; `applyTokenFill` in src/resolve/attest.ts requires the explicit marker).
|
|
516
520
|
* Verify your token balance and terms yourself before signing.
|
|
517
521
|
* "undeliverable" - the resolver would reject this payment AFTER the CSD moved; do not sign.
|
|
518
522
|
* ADDITIVE and default-safe: requiredFillOutputs is unchanged in behavior (its `[]` is load-bearing in
|
|
@@ -545,10 +549,10 @@ declare function fillOutputPlan(offer: OfferState, payRaw: bigint | string | num
|
|
|
545
549
|
declare const FEE_GATE_MARGIN_BLOCKS = 5;
|
|
546
550
|
declare const buildFeeHeight: (tip: number) => number;
|
|
547
551
|
/** 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
|
|
552
|
+
* Such an offer may be filled ONLY by the holder of a LIVE claim (`openFillReject`, src/resolve/attest.ts). */
|
|
549
553
|
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 (
|
|
554
|
+
/** Does `me` currently hold a LIVE claim on `offer` at `tip`? Mirrors `claimHeld` (src/resolve/context.ts) + the
|
|
555
|
+
* who===claimedBy check in `openFillReject` (src/resolve/attest.ts). For a pre-V17 open offer, open fills are banned entirely. */
|
|
552
556
|
declare function hasLiveClaim(offer: OfferState, me: string, tip: number): boolean;
|
|
553
557
|
/** v2.8 Correction 1 mirror (§31): the proposal txid a fill of `offer` MUST attest at `tip`. During a live
|
|
554
558
|
* fclaim hold (V28+) the payment must target the FCLAIM txid, not the offer id (an offer-txid fill is
|
|
@@ -590,8 +594,8 @@ declare function fillIsSafe(offer: OfferState, me: string, pay: bigint | string
|
|
|
590
594
|
* as "refuse" hard-blocks every honest token fill - the named B7f trap).
|
|
591
595
|
*
|
|
592
596
|
* `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
|
-
*
|
|
597
|
+
* it (= `fillTargetId(offer, tip)` for an honest builder). The v2.8 Correction-1 clause (`openFillReject`,
|
|
598
|
+
* src/resolve/attest.ts): during a live fclaim hold an attest on the OFFER txid is rejected while the payment
|
|
595
599
|
* still moves - the exact doomed fill the deprecated fillIsSafe endorses. If the offer carries a live
|
|
596
600
|
* fclaim-hold routing and no target is supplied, the endorsement fails CLOSED with instructions rather
|
|
597
601
|
* than guessing what your builder will attest. */
|
|
@@ -627,13 +631,14 @@ declare function fillEndorsement(offer: OfferState, me: string, pay: bigint | st
|
|
|
627
631
|
* re-fetched) name record — never a cached one — as `nameState` (undefined = 404 / unregistered = loss).
|
|
628
632
|
*
|
|
629
633
|
* Pass `tip` to ALSO gate the finalize WINDOW, both sides, mirroring the resolver's authoritative checks
|
|
630
|
-
* (resolve.ts
|
|
634
|
+
* (`applyNfinalize` in src/resolve/names.ts rejects unless `ev.height > effHeight + REG_COMMIT_MAX_BLOCKS`, and rejects when
|
|
631
635
|
* `ev.height > finalizeBy`) with the client-side FINALIZE_TIP_MARGIN band the site's finalizeReady applies:
|
|
632
636
|
* the tx signs at `tip` but mines at tip+1 or later, so the margin keeps a boundary-signed finalize from
|
|
633
637
|
* mining outside the window (too early: rejected as unfrozen; too late: past the deadline — either way the
|
|
634
638
|
* fee burns). The window is derived purely from `eff` (never the resolver's `finalizeBy`), so a lying
|
|
635
639
|
* `finalizeBy` cannot widen it — but per the trust scope above, a lying `eff` still can for a caller that
|
|
636
|
-
* does not supply an independent `commitHeight`. `tip` is optional; without it the winner-only path runs.
|
|
640
|
+
* does not supply an independent `commitHeight`. `tip` is optional; without it the winner-only path runs. A
|
|
641
|
+
* supplied `tip` that is not a non-negative safe integer is refused. */
|
|
637
642
|
declare function finalizeWinnerCheck(nameState: NameState | null | undefined, me: string, commitHeight: number, tip?: number | null): {
|
|
638
643
|
safe: boolean;
|
|
639
644
|
reason: string;
|
|
@@ -683,7 +688,7 @@ interface FillVerdict {
|
|
|
683
688
|
* not-mine hold, a below-depth signing, a zero-delivery fill, a stranded past-deadline broadcast).
|
|
684
689
|
*
|
|
685
690
|
* `opts.myLiveHoldsAtGrant` (REQUIRED) is the buyer's count of OTHER live fclaim/legacy holds at the moment
|
|
686
|
-
* THIS fclaim was granted, asserted by the authoring client (
|
|
691
|
+
* THIS fclaim was granted, asserted by the authoring client (countOtherHoldsAtGrant computes it). The lane-scoped
|
|
687
692
|
* replay cannot see the buyer's other-offer holds, and MAX_ACTIVE_CLAIMS is the one grant clause counted
|
|
688
693
|
* across offers, so without this the surface would false-accept a cap-denied fclaim. `opts.pay` overrides the
|
|
689
694
|
* payment (base units to want.payto) for a PARTIAL tail-fill; defaults to the offer's full want.value.
|
|
@@ -716,6 +721,8 @@ interface ProvenOfferTerms {
|
|
|
716
721
|
giveAmount?: string;
|
|
717
722
|
giveName?: string;
|
|
718
723
|
wantType?: "csd" | "token";
|
|
724
|
+
wantTicker?: string;
|
|
725
|
+
wantAmount?: string;
|
|
719
726
|
}
|
|
720
727
|
declare const PROVEN_TERMS_MINT: unique symbol;
|
|
721
728
|
type MintedProvenOfferTerms = ProvenOfferTerms & {
|
|
@@ -752,7 +759,8 @@ declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number):
|
|
|
752
759
|
* wantType - the SYMMETRIC want-type refusal: the served offer's want type (token iff want.ticker is
|
|
753
760
|
* a string, the isTokenWant pivot) must equal the proven type. The value leg already
|
|
754
761
|
* catches proven-CSD-served-as-token (String(undefined) mismatches t.value); this closes
|
|
755
|
-
* the reverse, proven-token-served-as-CSD.
|
|
762
|
+
* the reverse, proven-token-served-as-CSD. For a proven token want the served want.ticker
|
|
763
|
+
* and want.amount must also equal the proven price, verbatim.
|
|
756
764
|
*/
|
|
757
765
|
interface BindTermsOpts {
|
|
758
766
|
give?: boolean;
|
|
@@ -798,4 +806,53 @@ declare function myProvenFillClosedOffer(fill: ProvenEvent | null, fclaim: {
|
|
|
798
806
|
offer: string;
|
|
799
807
|
}, offerEv: ProvenEvent | null, me: string, grantHeight: number): boolean;
|
|
800
808
|
|
|
801
|
-
|
|
809
|
+
declare const LEGACY_HOLD_SUNSET_HEIGHT: number;
|
|
810
|
+
/** The count, or a refusal the caller must treat as unsafe (fail closed). */
|
|
811
|
+
type HoldCount = {
|
|
812
|
+
ok: true;
|
|
813
|
+
count: number;
|
|
814
|
+
} | {
|
|
815
|
+
ok: false;
|
|
816
|
+
reason: string;
|
|
817
|
+
};
|
|
818
|
+
/** An fclaim Propose the buyer may hold, read from a merkle-bound block. `proposer` is the prevout-bound author,
|
|
819
|
+
* or the buyer when it cannot be bound (over-counting only refuses a fill; under-counting can burn one). */
|
|
820
|
+
interface HoldCandidate {
|
|
821
|
+
id: string;
|
|
822
|
+
height: number;
|
|
823
|
+
pos: number;
|
|
824
|
+
proposer: string;
|
|
825
|
+
uri: string;
|
|
826
|
+
payloadHash: string;
|
|
827
|
+
expiresEpoch: number;
|
|
828
|
+
}
|
|
829
|
+
/** The fclaim being filled: its id, its proven block height and position, and the offer it reserves. */
|
|
830
|
+
interface HoldTarget {
|
|
831
|
+
id: string;
|
|
832
|
+
height: number;
|
|
833
|
+
pos: number;
|
|
834
|
+
offer: string;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* An upper bound of the buyer's live holds on other offers when `target` was granted: distinct other offers with
|
|
838
|
+
* an fclaim by `me` applied before the target (height, then position in the block) whose hold is still live at the
|
|
839
|
+
* target's height. `closed` names fclaims whose offer the buyer's own proven fill closed (myProvenFillClosedOffer);
|
|
840
|
+
* they are skipped. An earlier fclaim the resolver denied is still counted: its denial is not visible here.
|
|
841
|
+
* Domain: grants at or above LEGACY_HOLD_SUNSET_HEIGHT. Below it a legacy SCORE_CLAIM hold from before V28 can
|
|
842
|
+
* still be live and count against the cap, so the result is a refusal.
|
|
843
|
+
*/
|
|
844
|
+
declare function countOtherHoldsAtGrant(candidates: readonly HoldCandidate[], target: HoldTarget, me: string, closed?: ReadonlySet<string>): HoldCount;
|
|
845
|
+
|
|
846
|
+
/** Fields of the merkle-proven Propose: its app domain and expires_epoch, its inclusion height, and its author
|
|
847
|
+
* (csd-crypto authorOf). */
|
|
848
|
+
interface ProvenOfferTx {
|
|
849
|
+
domain: string;
|
|
850
|
+
height: number;
|
|
851
|
+
expiresEpoch: number | bigint;
|
|
852
|
+
seller: string;
|
|
853
|
+
}
|
|
854
|
+
/** Why the proven offer Propose is not an offer the resolver admits (the resolver's own note for the record
|
|
855
|
+
* rules), or null when it passes. */
|
|
856
|
+
declare function provenOfferRefusal(rec: OfferRecord, tx: ProvenOfferTx): string | null;
|
|
857
|
+
|
|
858
|
+
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 HoldCandidate, type HoldCount, type HoldReplay, type HoldTarget, LEGACY_HOLD_SUNSET_HEIGHT, type LegacyBindOpts, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MAX_TOKEN_DECIMALS, 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 ProvenOfferTx, 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, burnedPayment, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, countOtherHoldsAtGrant, deploy, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, myProvenFillClosedOffer, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferRefusal, provenOfferTerms, ptAmt, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|