@inversealtruism/cairnx-core 0.1.31 → 0.1.32
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 +14 -0
- package/dist/index.cjs +22 -23
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +21 -23
- package/package.json +1 -1
package/CONVENTION.md
CHANGED
|
@@ -215,6 +215,20 @@ once a replay hash is pinned over data that exercises them, so they are stated h
|
|
|
215
215
|
`str::cmp` / Go `<` on `string` compare by UTF-8 bytes = codepoint order and are therefore WRONG** for
|
|
216
216
|
a non-BMP key — implementers MUST compare UTF-16 code units (JS `localeCompare` is also wrong; use the
|
|
217
217
|
default `<`/`>` on the JS string, i.e. code-unit order, which is what the resolver's `ord()` does).
|
|
218
|
+
**The numeric-key trap, and it points in OPPOSITE directions for the two hashes we compute, so read
|
|
219
|
+
carefully.** Nprofile maps (and all-digit names) can carry numeric-looking keys like `"2"`/`"10"`:
|
|
220
|
+
- **payloadHash / the record `uri` (`canonicalJson`)** sorts keys by pure code unit: `canonicalJson` is
|
|
221
|
+
`Object.keys(o).sort()`, and although JS's native `Object.keys` enumerates integer-index keys ascending-
|
|
222
|
+
NUMERIC (`"1","2","10"`), the trailing `.sort()` overrides that to code-unit order (`"1","10","2"`). So
|
|
223
|
+
for the record hash, `"10"` sorts BEFORE `"2"`. Do NOT special-case numeric keys here.
|
|
224
|
+
- **`sha256(canonicalState)` (the STATE hash)** is a DIFFERENT serializer (`sortKeys` + `JSON.stringify`,
|
|
225
|
+
not `canonicalJson`), and it INHERITS `JSON.stringify`'s native enumeration: ECMAScript array-index keys
|
|
226
|
+
(the canonical decimal of an integer in `[0, 2^32-2]`) are emitted FIRST in ascending-NUMERIC order,
|
|
227
|
+
THEN the remaining keys in code-unit order, regardless of the intermediate `.sort()`. So for the state
|
|
228
|
+
hash, `"2"` sorts BEFORE `"10"`. An implementer who applies the record-hash's pure-code-unit rule here
|
|
229
|
+
(or who ignores the integer-first enumeration) forks `sha256(canonicalState)` the first time a profile
|
|
230
|
+
carries two numeric keys. The reference Python mirror encodes exactly this split (`canonicalJson` vs
|
|
231
|
+
`_js_obj_key_order`/`_js_stringify` in `conformance/cairnx_ref.py`); a third impl MUST reproduce both.
|
|
218
232
|
- **A3 — Field types (bare number/boolean vs decimal string vs identity string).** Canonical state mixes
|
|
219
233
|
raw JSON integers and booleans with decimal-string amounts and raw identity strings. Emit as **bare
|
|
220
234
|
integers**: `decimals, height, effectiveHeight, expiresEpoch, feeBps, tipHeight, paidThroughEpoch`, and
|
package/dist/index.cjs
CHANGED
|
@@ -97,6 +97,7 @@ __export(index_exports, {
|
|
|
97
97
|
V24_HEIGHT: () => V24_HEIGHT,
|
|
98
98
|
V25_HEIGHT: () => V25_HEIGHT,
|
|
99
99
|
V26_HEIGHT: () => V26_HEIGHT,
|
|
100
|
+
V27_HEIGHT: () => V27_HEIGHT,
|
|
100
101
|
ZERO_ADDR: () => ZERO_ADDR,
|
|
101
102
|
bid: () => bid,
|
|
102
103
|
blockReward: () => import_csd_codec4.blockReward,
|
|
@@ -227,6 +228,7 @@ var REG_FINALIZE_GRACE_BLOCKS = 20;
|
|
|
227
228
|
var MAX_PENDING_REG = 3;
|
|
228
229
|
var FINALIZE_TIP_MARGIN = 2;
|
|
229
230
|
var V26_HEIGHT = 51200;
|
|
231
|
+
var V27_HEIGHT = 52500;
|
|
230
232
|
var epochOf = (height) => Math.floor(height / import_csd_codec.EPOCH_LEN);
|
|
231
233
|
var claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
232
234
|
var claimWindowOf = (claimUntilHeight) => claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
@@ -553,6 +555,13 @@ function resolve(events, tipHeight) {
|
|
|
553
555
|
const b = bids.get(o.bid);
|
|
554
556
|
if (b && b.status === "open" && b.bidder === buyer) b.status = "done";
|
|
555
557
|
};
|
|
558
|
+
const voidOpenNameOffers = (name) => {
|
|
559
|
+
for (const o of offers.values()) if (o.status === "open" && isNameGive(o.give) && o.give.name === name) {
|
|
560
|
+
releaseGive(o);
|
|
561
|
+
o.status = "cancelled";
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
const earlierAnchor = (effHeight, pos, id, inc) => effHeight < inc.effHeight || effHeight === inc.effHeight && (pos < inc.pos || pos === inc.pos && id < inc.id);
|
|
556
565
|
const claimGrace = (o) => o.claimUntilHeight !== void 0 ? claimGraceOf(o.claimUntilHeight) : 0;
|
|
557
566
|
const claimHeld = (o, height) => o.claimedBy !== void 0 && o.claimUntilHeight !== void 0 && height < o.claimUntilHeight + claimGrace(o);
|
|
558
567
|
const openFillReject = (o, height, who) => {
|
|
@@ -702,7 +711,7 @@ function resolve(events, tipHeight) {
|
|
|
702
711
|
}
|
|
703
712
|
const cr = recaptures.get(rec.name);
|
|
704
713
|
const crActive = cr && ev.height > cr.finalizeBy ? void 0 : cr;
|
|
705
|
-
const better2 = !crActive || (effHeight
|
|
714
|
+
const better2 = !crActive || earlierAnchor(effHeight, ev.pos, ev.id, crActive);
|
|
706
715
|
if (!better2) {
|
|
707
716
|
note(ev, ev.id, "name", false, "recapture already reserved (earlier anchor wins)");
|
|
708
717
|
continue;
|
|
@@ -722,10 +731,7 @@ function resolve(events, tipHeight) {
|
|
|
722
731
|
note(ev, ev.id, "name", false, "lapsed-name claim fee unpaid (decaying premium)");
|
|
723
732
|
continue;
|
|
724
733
|
}
|
|
725
|
-
|
|
726
|
-
releaseGive(o);
|
|
727
|
-
o.status = "cancelled";
|
|
728
|
-
}
|
|
734
|
+
voidOpenNameOffers(rec.name);
|
|
729
735
|
names.set(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, viaFill: true, paidThroughEpoch: epClaim + NAME_TERM_EPOCHS });
|
|
730
736
|
feesPaid += fee;
|
|
731
737
|
note(ev, ev.id, "name", true, "lapsed lease re-claimed (premium)");
|
|
@@ -736,7 +742,7 @@ function resolve(events, tipHeight) {
|
|
|
736
742
|
note(ev, ev.id, "name", false, "v2.5: registration requires a commit-reveal (salt)");
|
|
737
743
|
continue;
|
|
738
744
|
}
|
|
739
|
-
const better2 = !curActive || !curActive.viaFill && (effHeight
|
|
745
|
+
const better2 = !curActive || !curActive.viaFill && earlierAnchor(effHeight, ev.pos, ev.id, curActive);
|
|
740
746
|
if (!better2) {
|
|
741
747
|
note(ev, ev.id, "name", false, curActive?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
|
|
742
748
|
continue;
|
|
@@ -748,10 +754,7 @@ function resolve(events, tipHeight) {
|
|
|
748
754
|
continue;
|
|
749
755
|
}
|
|
750
756
|
if (curActive) {
|
|
751
|
-
|
|
752
|
-
releaseGive(o);
|
|
753
|
-
o.status = "cancelled";
|
|
754
|
-
}
|
|
757
|
+
voidOpenNameOffers(rec.name);
|
|
755
758
|
}
|
|
756
759
|
names.set(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, pending: true, finalizeBy: effHeight + REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS });
|
|
757
760
|
note(ev, ev.id, "name", true, curActive ? "reserved (displaced prior reservation)" : "reserved (pending finalize)");
|
|
@@ -770,16 +773,13 @@ function resolve(events, tipHeight) {
|
|
|
770
773
|
locked: false,
|
|
771
774
|
...v15 ? { paidThroughEpoch: epClaim + NAME_TERM_EPOCHS } : {}
|
|
772
775
|
};
|
|
773
|
-
const better = !curActive || !curActive.viaFill && (effHeight
|
|
776
|
+
const better = !curActive || !curActive.viaFill && earlierAnchor(effHeight, ev.pos, ev.id, curActive);
|
|
774
777
|
if (!better) {
|
|
775
778
|
note(ev, ev.id, "name", false, curActive?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
|
|
776
779
|
continue;
|
|
777
780
|
}
|
|
778
781
|
if (curActive) {
|
|
779
|
-
|
|
780
|
-
releaseGive(o);
|
|
781
|
-
o.status = "cancelled";
|
|
782
|
-
}
|
|
782
|
+
voidOpenNameOffers(rec.name);
|
|
783
783
|
}
|
|
784
784
|
names.set(rec.name, cand);
|
|
785
785
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
@@ -808,8 +808,8 @@ function resolve(events, tipHeight) {
|
|
|
808
808
|
note(ev, ev.id, "nfinalize", false, "name registration fee unpaid");
|
|
809
809
|
continue;
|
|
810
810
|
}
|
|
811
|
-
n.pending
|
|
812
|
-
n.finalizeBy
|
|
811
|
+
delete n.pending;
|
|
812
|
+
delete n.finalizeBy;
|
|
813
813
|
n.paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS;
|
|
814
814
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
815
815
|
note(ev, ev.id, "nfinalize", true);
|
|
@@ -842,10 +842,7 @@ function resolve(events, tipHeight) {
|
|
|
842
842
|
note(ev, ev.id, "nfinalize", false, "recapture premium unpaid (decaying)");
|
|
843
843
|
continue;
|
|
844
844
|
}
|
|
845
|
-
|
|
846
|
-
releaseGive(o);
|
|
847
|
-
o.status = "cancelled";
|
|
848
|
-
}
|
|
845
|
+
voidOpenNameOffers(rec.name);
|
|
849
846
|
names.set(rec.name, { owner: who, effHeight: r.effHeight, pos: r.pos, id: r.id, height: r.height, locked: false, paidThroughEpoch: ep + NAME_TERM_EPOCHS });
|
|
850
847
|
recaptures.delete(rec.name);
|
|
851
848
|
feesPaid += fee;
|
|
@@ -958,8 +955,9 @@ function resolve(events, tipHeight) {
|
|
|
958
955
|
note(ev, ev.id, "offer", false, "name already locked by another offer");
|
|
959
956
|
continue;
|
|
960
957
|
}
|
|
961
|
-
|
|
962
|
-
|
|
958
|
+
const saleEmbargo = ev.height >= V27_HEIGHT ? REG_COMMIT_MAX_BLOCKS : COMMIT_MAX_BLOCKS;
|
|
959
|
+
if (ev.height >= V13_HEIGHT && !n.viaFill && ev.height - n.effHeight <= saleEmbargo) {
|
|
960
|
+
note(ev, ev.id, "offer", false, "name too young to sell (must out-age the reveal window)");
|
|
963
961
|
continue;
|
|
964
962
|
}
|
|
965
963
|
if (v15 && paidThrough(n) < ev.expiresEpoch) {
|
|
@@ -1496,6 +1494,7 @@ var import_csd_codec4 = require("@inversealtruism/csd-codec");
|
|
|
1496
1494
|
V24_HEIGHT,
|
|
1497
1495
|
V25_HEIGHT,
|
|
1498
1496
|
V26_HEIGHT,
|
|
1497
|
+
V27_HEIGHT,
|
|
1499
1498
|
ZERO_ADDR,
|
|
1500
1499
|
bid,
|
|
1501
1500
|
blockReward,
|
package/dist/index.d.cts
CHANGED
|
@@ -69,6 +69,7 @@ declare const REG_FINALIZE_GRACE_BLOCKS = 20;
|
|
|
69
69
|
declare const MAX_PENDING_REG = 3;
|
|
70
70
|
declare const FINALIZE_TIP_MARGIN = 2;
|
|
71
71
|
declare const V26_HEIGHT = 51200;
|
|
72
|
+
declare const V27_HEIGHT = 52500;
|
|
72
73
|
declare const epochOf: (height: number) => number;
|
|
73
74
|
declare const claimWindowAt: (height: number) => number;
|
|
74
75
|
declare const claimWindowOf: (claimUntilHeight: number) => number;
|
|
@@ -434,4 +435,4 @@ declare function paidToFromOutputs(outputs: readonly {
|
|
|
434
435
|
value: number;
|
|
435
436
|
}[]): Record<string, string>;
|
|
436
437
|
|
|
437
|
-
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, FEE_BPS, FEE_BPS_V16, FINALIZE_TIP_MARGIN, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, 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, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, 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, type Want, ZERO_ADDR, bid, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, requiredClaimDepth, resolve, tokenMeta, tradeFee, transfer };
|
|
438
|
+
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, FEE_BPS, FEE_BPS_V16, FINALIZE_TIP_MARGIN, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, 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, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, 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, type Want, ZERO_ADDR, bid, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, requiredClaimDepth, resolve, tokenMeta, tradeFee, transfer };
|
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ declare const REG_FINALIZE_GRACE_BLOCKS = 20;
|
|
|
69
69
|
declare const MAX_PENDING_REG = 3;
|
|
70
70
|
declare const FINALIZE_TIP_MARGIN = 2;
|
|
71
71
|
declare const V26_HEIGHT = 51200;
|
|
72
|
+
declare const V27_HEIGHT = 52500;
|
|
72
73
|
declare const epochOf: (height: number) => number;
|
|
73
74
|
declare const claimWindowAt: (height: number) => number;
|
|
74
75
|
declare const claimWindowOf: (claimUntilHeight: number) => number;
|
|
@@ -434,4 +435,4 @@ declare function paidToFromOutputs(outputs: readonly {
|
|
|
434
435
|
value: number;
|
|
435
436
|
}[]): Record<string, string>;
|
|
436
437
|
|
|
437
|
-
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, FEE_BPS, FEE_BPS_V16, FINALIZE_TIP_MARGIN, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, 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, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, 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, type Want, ZERO_ADDR, bid, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, requiredClaimDepth, resolve, tokenMeta, tradeFee, transfer };
|
|
438
|
+
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, FEE_BPS, FEE_BPS_V16, FINALIZE_TIP_MARGIN, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, 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, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, 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, type Want, ZERO_ADDR, bid, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, requiredClaimDepth, resolve, tokenMeta, tradeFee, transfer };
|
package/dist/index.js
CHANGED
|
@@ -87,6 +87,7 @@ var REG_FINALIZE_GRACE_BLOCKS = 20;
|
|
|
87
87
|
var MAX_PENDING_REG = 3;
|
|
88
88
|
var FINALIZE_TIP_MARGIN = 2;
|
|
89
89
|
var V26_HEIGHT = 51200;
|
|
90
|
+
var V27_HEIGHT = 52500;
|
|
90
91
|
var epochOf = (height) => Math.floor(height / EPOCH_LEN);
|
|
91
92
|
var claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
92
93
|
var claimWindowOf = (claimUntilHeight) => claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
@@ -413,6 +414,13 @@ function resolve(events, tipHeight) {
|
|
|
413
414
|
const b = bids.get(o.bid);
|
|
414
415
|
if (b && b.status === "open" && b.bidder === buyer) b.status = "done";
|
|
415
416
|
};
|
|
417
|
+
const voidOpenNameOffers = (name) => {
|
|
418
|
+
for (const o of offers.values()) if (o.status === "open" && isNameGive(o.give) && o.give.name === name) {
|
|
419
|
+
releaseGive(o);
|
|
420
|
+
o.status = "cancelled";
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
const earlierAnchor = (effHeight, pos, id, inc) => effHeight < inc.effHeight || effHeight === inc.effHeight && (pos < inc.pos || pos === inc.pos && id < inc.id);
|
|
416
424
|
const claimGrace = (o) => o.claimUntilHeight !== void 0 ? claimGraceOf(o.claimUntilHeight) : 0;
|
|
417
425
|
const claimHeld = (o, height) => o.claimedBy !== void 0 && o.claimUntilHeight !== void 0 && height < o.claimUntilHeight + claimGrace(o);
|
|
418
426
|
const openFillReject = (o, height, who) => {
|
|
@@ -562,7 +570,7 @@ function resolve(events, tipHeight) {
|
|
|
562
570
|
}
|
|
563
571
|
const cr = recaptures.get(rec.name);
|
|
564
572
|
const crActive = cr && ev.height > cr.finalizeBy ? void 0 : cr;
|
|
565
|
-
const better2 = !crActive || (effHeight
|
|
573
|
+
const better2 = !crActive || earlierAnchor(effHeight, ev.pos, ev.id, crActive);
|
|
566
574
|
if (!better2) {
|
|
567
575
|
note(ev, ev.id, "name", false, "recapture already reserved (earlier anchor wins)");
|
|
568
576
|
continue;
|
|
@@ -582,10 +590,7 @@ function resolve(events, tipHeight) {
|
|
|
582
590
|
note(ev, ev.id, "name", false, "lapsed-name claim fee unpaid (decaying premium)");
|
|
583
591
|
continue;
|
|
584
592
|
}
|
|
585
|
-
|
|
586
|
-
releaseGive(o);
|
|
587
|
-
o.status = "cancelled";
|
|
588
|
-
}
|
|
593
|
+
voidOpenNameOffers(rec.name);
|
|
589
594
|
names.set(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, viaFill: true, paidThroughEpoch: epClaim + NAME_TERM_EPOCHS });
|
|
590
595
|
feesPaid += fee;
|
|
591
596
|
note(ev, ev.id, "name", true, "lapsed lease re-claimed (premium)");
|
|
@@ -596,7 +601,7 @@ function resolve(events, tipHeight) {
|
|
|
596
601
|
note(ev, ev.id, "name", false, "v2.5: registration requires a commit-reveal (salt)");
|
|
597
602
|
continue;
|
|
598
603
|
}
|
|
599
|
-
const better2 = !curActive || !curActive.viaFill && (effHeight
|
|
604
|
+
const better2 = !curActive || !curActive.viaFill && earlierAnchor(effHeight, ev.pos, ev.id, curActive);
|
|
600
605
|
if (!better2) {
|
|
601
606
|
note(ev, ev.id, "name", false, curActive?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
|
|
602
607
|
continue;
|
|
@@ -608,10 +613,7 @@ function resolve(events, tipHeight) {
|
|
|
608
613
|
continue;
|
|
609
614
|
}
|
|
610
615
|
if (curActive) {
|
|
611
|
-
|
|
612
|
-
releaseGive(o);
|
|
613
|
-
o.status = "cancelled";
|
|
614
|
-
}
|
|
616
|
+
voidOpenNameOffers(rec.name);
|
|
615
617
|
}
|
|
616
618
|
names.set(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, pending: true, finalizeBy: effHeight + REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS });
|
|
617
619
|
note(ev, ev.id, "name", true, curActive ? "reserved (displaced prior reservation)" : "reserved (pending finalize)");
|
|
@@ -630,16 +632,13 @@ function resolve(events, tipHeight) {
|
|
|
630
632
|
locked: false,
|
|
631
633
|
...v15 ? { paidThroughEpoch: epClaim + NAME_TERM_EPOCHS } : {}
|
|
632
634
|
};
|
|
633
|
-
const better = !curActive || !curActive.viaFill && (effHeight
|
|
635
|
+
const better = !curActive || !curActive.viaFill && earlierAnchor(effHeight, ev.pos, ev.id, curActive);
|
|
634
636
|
if (!better) {
|
|
635
637
|
note(ev, ev.id, "name", false, curActive?.viaFill ? "name taken (purchased \u2014 not displaceable)" : "name taken (earlier anchor wins)");
|
|
636
638
|
continue;
|
|
637
639
|
}
|
|
638
640
|
if (curActive) {
|
|
639
|
-
|
|
640
|
-
releaseGive(o);
|
|
641
|
-
o.status = "cancelled";
|
|
642
|
-
}
|
|
641
|
+
voidOpenNameOffers(rec.name);
|
|
643
642
|
}
|
|
644
643
|
names.set(rec.name, cand);
|
|
645
644
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
@@ -668,8 +667,8 @@ function resolve(events, tipHeight) {
|
|
|
668
667
|
note(ev, ev.id, "nfinalize", false, "name registration fee unpaid");
|
|
669
668
|
continue;
|
|
670
669
|
}
|
|
671
|
-
n.pending
|
|
672
|
-
n.finalizeBy
|
|
670
|
+
delete n.pending;
|
|
671
|
+
delete n.finalizeBy;
|
|
673
672
|
n.paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS;
|
|
674
673
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
675
674
|
note(ev, ev.id, "nfinalize", true);
|
|
@@ -702,10 +701,7 @@ function resolve(events, tipHeight) {
|
|
|
702
701
|
note(ev, ev.id, "nfinalize", false, "recapture premium unpaid (decaying)");
|
|
703
702
|
continue;
|
|
704
703
|
}
|
|
705
|
-
|
|
706
|
-
releaseGive(o);
|
|
707
|
-
o.status = "cancelled";
|
|
708
|
-
}
|
|
704
|
+
voidOpenNameOffers(rec.name);
|
|
709
705
|
names.set(rec.name, { owner: who, effHeight: r.effHeight, pos: r.pos, id: r.id, height: r.height, locked: false, paidThroughEpoch: ep + NAME_TERM_EPOCHS });
|
|
710
706
|
recaptures.delete(rec.name);
|
|
711
707
|
feesPaid += fee;
|
|
@@ -818,8 +814,9 @@ function resolve(events, tipHeight) {
|
|
|
818
814
|
note(ev, ev.id, "offer", false, "name already locked by another offer");
|
|
819
815
|
continue;
|
|
820
816
|
}
|
|
821
|
-
|
|
822
|
-
|
|
817
|
+
const saleEmbargo = ev.height >= V27_HEIGHT ? REG_COMMIT_MAX_BLOCKS : COMMIT_MAX_BLOCKS;
|
|
818
|
+
if (ev.height >= V13_HEIGHT && !n.viaFill && ev.height - n.effHeight <= saleEmbargo) {
|
|
819
|
+
note(ev, ev.id, "offer", false, "name too young to sell (must out-age the reveal window)");
|
|
823
820
|
continue;
|
|
824
821
|
}
|
|
825
822
|
if (v15 && paidThrough(n) < ev.expiresEpoch) {
|
|
@@ -1364,6 +1361,7 @@ export {
|
|
|
1364
1361
|
V24_HEIGHT,
|
|
1365
1362
|
V25_HEIGHT,
|
|
1366
1363
|
V26_HEIGHT,
|
|
1364
|
+
V27_HEIGHT,
|
|
1367
1365
|
ZERO_ADDR,
|
|
1368
1366
|
bid,
|
|
1369
1367
|
blockReward2 as blockReward,
|