@inversealtruism/cairnx-core 0.1.31 → 0.1.33
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 +190 -3
- package/dist/index.cjs +25 -26
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +24 -26
- package/package.json +1 -1
- package/test/vectors/cases.json +6522 -6522
- package/test/vectors/replay-hashes.json +6 -3
package/CONVENTION.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
# CairnX Convention v1
|
|
2
2
|
|
|
3
|
-
**Status:** v2.
|
|
3
|
+
**Status:** v2.7 (normative; 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
|
-
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
|
-
|
|
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
|
+
v2.2 @ 41 300 (§25) · v2.4 @ 49 200 (§27) · v2.5 @ 51 000 (§28) · v2.6 @ 51 200 (§29) · v2.3 @ 52 000 (§26) ·
|
|
9
|
+
v2.7 @ 52 500 (§30).
|
|
10
|
+
Sections §19–§30 are the normative semantics for v1.6–v2.7; §5.1 is the byte-level canonical-JSON contract that binds all of them.
|
|
11
|
+
Activation order is by HEIGHT, not by version number (v1.8 activated after v2.0; v2.3 activates after v2.6): a
|
|
12
|
+
replayer gates each rule on its own height constant, never on "version X implies version Y is active".
|
|
9
13
|
|
|
10
14
|
> **Canonical copy.** This spec ships in the published `@inversealtruism/cairnx-core` package; the source of
|
|
11
15
|
> truth is `csd-sdk/packages/cairnx/CONVENTION.md`. Any in-repo mirror (e.g. the `cairnx` app repo) MUST be
|
|
@@ -215,6 +219,20 @@ once a replay hash is pinned over data that exercises them, so they are stated h
|
|
|
215
219
|
`str::cmp` / Go `<` on `string` compare by UTF-8 bytes = codepoint order and are therefore WRONG** for
|
|
216
220
|
a non-BMP key — implementers MUST compare UTF-16 code units (JS `localeCompare` is also wrong; use the
|
|
217
221
|
default `<`/`>` on the JS string, i.e. code-unit order, which is what the resolver's `ord()` does).
|
|
222
|
+
**The numeric-key trap, and it points in OPPOSITE directions for the two hashes we compute, so read
|
|
223
|
+
carefully.** Nprofile maps (and all-digit names) can carry numeric-looking keys like `"2"`/`"10"`:
|
|
224
|
+
- **payloadHash / the record `uri` (`canonicalJson`)** sorts keys by pure code unit: `canonicalJson` is
|
|
225
|
+
`Object.keys(o).sort()`, and although JS's native `Object.keys` enumerates integer-index keys ascending-
|
|
226
|
+
NUMERIC (`"1","2","10"`), the trailing `.sort()` overrides that to code-unit order (`"1","10","2"`). So
|
|
227
|
+
for the record hash, `"10"` sorts BEFORE `"2"`. Do NOT special-case numeric keys here.
|
|
228
|
+
- **`sha256(canonicalState)` (the STATE hash)** is a DIFFERENT serializer (`sortKeys` + `JSON.stringify`,
|
|
229
|
+
not `canonicalJson`), and it INHERITS `JSON.stringify`'s native enumeration: ECMAScript array-index keys
|
|
230
|
+
(the canonical decimal of an integer in `[0, 2^32-2]`) are emitted FIRST in ascending-NUMERIC order,
|
|
231
|
+
THEN the remaining keys in code-unit order, regardless of the intermediate `.sort()`. So for the state
|
|
232
|
+
hash, `"2"` sorts BEFORE `"10"`. An implementer who applies the record-hash's pure-code-unit rule here
|
|
233
|
+
(or who ignores the integer-first enumeration) forks `sha256(canonicalState)` the first time a profile
|
|
234
|
+
carries two numeric keys. The reference Python mirror encodes exactly this split (`canonicalJson` vs
|
|
235
|
+
`_js_obj_key_order`/`_js_stringify` in `conformance/cairnx_ref.py`); a third impl MUST reproduce both.
|
|
218
236
|
- **A3 — Field types (bare number/boolean vs decimal string vs identity string).** Canonical state mixes
|
|
219
237
|
raw JSON integers and booleans with decimal-string amounts and raw identity strings. Emit as **bare
|
|
220
238
|
integers**: `decimals, height, effectiveHeight, expiresEpoch, feeBps, tipHeight, paidThroughEpoch`, and
|
|
@@ -801,3 +819,172 @@ epochs from its anchor:
|
|
|
801
819
|
everyone. Below V21, `effExpiry = expires_epoch` — byte-identical history.
|
|
802
820
|
- **Client expiry-height closed form** (mirrors the resolver's height-gated sweep, for buy-safety guards):
|
|
803
821
|
`offerExpiryHeight = min( (expires_epoch+1)·30 , max( V21_HEIGHT , (epochOf(anchor)+168+1)·30 ) )`.
|
|
822
|
+
|
|
823
|
+
---
|
|
824
|
+
|
|
825
|
+
# CairnX Convention v2.2 (offer/bid duration cap removed, anchor-keyed)
|
|
826
|
+
|
|
827
|
+
**Activation height: 41 300** (`V22_HEIGHT`; non-retroactive; keyed on the offer/bid ANCHOR height, not the sweep height).
|
|
828
|
+
|
|
829
|
+
## 25. The §24 cap applies only to the [V21, V22) anchor era
|
|
830
|
+
|
|
831
|
+
The §24 lifetime cap proved to be an infrastructure symptom, not a market need, and was lifted:
|
|
832
|
+
|
|
833
|
+
- **Anchor ≥ 41 300:** the raw `expires_epoch` binds. No creation gate, no capped `effExpiry`. The 1-week
|
|
834
|
+
suggestion survives only as CLIENT policy (the reference UI defaults to it); it is not consensus.
|
|
835
|
+
- **Anchor in [40 100, 41 300):** the §24 rules apply to that offer/bid FOREVER (creation gate at its
|
|
836
|
+
anchor, capped `effExpiry` in every later sweep). Era membership is fixed by the anchor, so every
|
|
837
|
+
replayer ages the same record identically regardless of when it replays.
|
|
838
|
+
- **Anchor < 40 100:** raw `expires_epoch` binds (pre-V21 history, unchanged).
|
|
839
|
+
- **Client closed form:** for anchor ≥ V22, `offerExpiryHeight = (expires_epoch+1)·30`; for the [V21, V22)
|
|
840
|
+
era use the §24 formula; below V21 use the raw form.
|
|
841
|
+
- **Adoption note:** a relaxation. A v2.1-only replayer rejects (no-ops) a long-dated offer the chain
|
|
842
|
+
accepts, so its book diverges from the canonical one from the first over-cap anchor onward. Every
|
|
843
|
+
replayer must run the v2.2 core before the tip crosses 41 300 (already long past; stated for the record).
|
|
844
|
+
|
|
845
|
+
---
|
|
846
|
+
|
|
847
|
+
# CairnX Convention v2.3 (`nset` to the zero address clears the record)
|
|
848
|
+
|
|
849
|
+
**Activation height: 52 000** (`V23_HEIGHT`; non-retroactive; keyed on the `nset` event height).
|
|
850
|
+
|
|
851
|
+
## 26. Clearing a name's payment target
|
|
852
|
+
|
|
853
|
+
`ZERO_ADDR = 0x` + 40 hex zeros.
|
|
854
|
+
|
|
855
|
+
- **Event height ≥ 52 000:** an owner `nset` whose `addr` equals `ZERO_ADDR` CLEARS the record: the
|
|
856
|
+
canonical state materializes the name with NO `addr` key (absent, not `null`). A cleared name resolves
|
|
857
|
+
to its OWNER address (the §9 fallback) and drops out of the reverse-resolution / primary-name candidate
|
|
858
|
+
set. This is the supported way to switch which of several names is an address's primary.
|
|
859
|
+
- **Event height < 52 000:** the identical record literally sets `addr` to the zero address (historical
|
|
860
|
+
behavior, byte-identical replay). The zero address has always been a VALID `addr`, so there is no
|
|
861
|
+
parser change in either direction.
|
|
862
|
+
- **Guards unchanged:** `nset` on a lapsed lease stays a no-op (§17); owner-only as before.
|
|
863
|
+
- **Adoption note (fund safety, the harder direction):** a stale (pre-v2.3) replayer shows a cleared name
|
|
864
|
+
still pointing at `0x000...0`. A payer trusting that stale view burns funds to the zero address. Wallets
|
|
865
|
+
MUST refuse to pay `0x000...0` regardless (the reference wallet hard-blocks it), and every replayer must
|
|
866
|
+
run the v2.3 core before the tip crosses 52 000.
|
|
867
|
+
|
|
868
|
+
---
|
|
869
|
+
|
|
870
|
+
# CairnX Convention v2.4 (length-graded registration fee increase)
|
|
871
|
+
|
|
872
|
+
**Activation height: 49 200** (`V24_HEIGHT`; non-retroactive; keyed on the FEE-BEARING event's height).
|
|
873
|
+
|
|
874
|
+
## 27. The fee curve
|
|
875
|
+
|
|
876
|
+
`nameRegFee(name, height)` selects the regime by the height of the event that carries the fee: the `name`
|
|
877
|
+
reveal below v2.5, the winner's `nfinalize` at/after v2.5 (§28), and every renewal at its own event height.
|
|
878
|
+
|
|
879
|
+
| name length | < 40 000 | ≥ 40 000 (v1.8) | ≥ 49 200 (v2.4) |
|
|
880
|
+
|---|---|---|---|
|
|
881
|
+
| ≤ 3 chars | 5 CSD | 6.7 CSD | 15 CSD |
|
|
882
|
+
| 4 chars | 2 CSD | 6.7 CSD | 10 CSD |
|
|
883
|
+
| 5 chars | 1 CSD | 3 CSD | 5 CSD |
|
|
884
|
+
| 6 - 9 chars | 0.5 CSD | 3 CSD | 5 CSD |
|
|
885
|
+
| ≥ 10 chars | 0.1 CSD | 3 CSD | 3 CSD |
|
|
886
|
+
|
|
887
|
+
- Underpayment is a **no-op** (`name registration fee unpaid`), and the §10 warning applies with force:
|
|
888
|
+
the attached payment outputs still settle on-chain. An underpaid registration or renewal is a burn.
|
|
889
|
+
- **Adoption note (BOTH directions are hard):** a stale replayer ACCEPTS an underpaid post-49 200
|
|
890
|
+
registration the chain rejects (it shows a phantom owner), and a stale wallet ATTACHES the old fee and
|
|
891
|
+
burns it. Every replayer and every fee-quoting client must run the v2.4 core before the tip crosses
|
|
892
|
+
49 200.
|
|
893
|
+
|
|
894
|
+
---
|
|
895
|
+
|
|
896
|
+
# CairnX Convention v2.5 (sealed-reservation registration)
|
|
897
|
+
|
|
898
|
+
**Activation height: 51 000** (`V25_HEIGHT`; non-retroactive; keyed on the reveal event height).
|
|
899
|
+
|
|
900
|
+
Root fix for the reveal fee-burn: pre-v2.5, every losing racer in a §9 commit-reveal race paid the FULL
|
|
901
|
+
registration fee for nothing (payment-without-delivery). At/after v2.5 the reveal is payment-free; only
|
|
902
|
+
the settled winner ever pays.
|
|
903
|
+
|
|
904
|
+
## 28. Commit, payment-free reveal, freeze, winner-only finalize
|
|
905
|
+
|
|
906
|
+
- **Commit (unchanged):** a prior `ncommit` per §9. Back-dating is unchanged: the reveal's effective
|
|
907
|
+
anchor `effHeight` is its commit's height.
|
|
908
|
+
- **Reveal window shrinks:** at/after v2.5 a reveal must land within `REG_COMMIT_MAX_BLOCKS = 8` blocks
|
|
909
|
+
of its commit (below v2.5: 240). One constant serves as BOTH the reveal window and the displacement
|
|
910
|
+
freeze, so no back-dated challenger can appear after the freeze has passed. Direct no-salt registration
|
|
911
|
+
is rejected at/after v2.5 (`v2.5: registration requires a commit-reveal (salt)`): an unsealed
|
|
912
|
+
registration could not be finalized.
|
|
913
|
+
- **Reveal (`name` record, height ≥ 51 000):** carries NO registration fee. Creates a PENDING reservation,
|
|
914
|
+
materialized in canonical state as the name with `pending: true` and
|
|
915
|
+
`finalizeBy = effHeight + 8 + 20` (`REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS`).
|
|
916
|
+
- **Contest while pending:** a rival reveal with a strictly earlier `(effHeight, pos, id)` (numeric on
|
|
917
|
+
`effHeight` and `pos`, ordinal code-unit on `id`; earliest wins) DISPLACES the reservation; the displaced party has lost only its
|
|
918
|
+
~0.25 CSD anchor. A FINALIZED name can never be displaced: any window-valid challenger has an
|
|
919
|
+
`effHeight` within 8 blocks of the current height, which is strictly later than a finalized name's
|
|
920
|
+
(its freeze has passed). Names owned `viaFill` are likewise never displaced.
|
|
921
|
+
- **Per-address cap:** at most `MAX_PENDING_REG = 3` concurrent un-finalized reservations per owner
|
|
922
|
+
(expired ones and a re-reveal of the same name do not count); excess reveals are no-ops.
|
|
923
|
+
- **Finalize (`nfinalize` record):** `{v:1, t:"nfinalize", name, salt}`. Valid iff ALL of: the name is
|
|
924
|
+
pending and owned by the sender; `salt` re-derives the SAME commit that anchored the reservation
|
|
925
|
+
(`sha256` per §9, binding name + salt + owner, and the commit's height must equal the reservation's
|
|
926
|
+
`effHeight`); the freeze has passed (`ev.height > effHeight + 8`); the reservation has not expired
|
|
927
|
+
(`ev.height ≤ finalizeBy`); and the payment to the treasury covers `nameRegFee(name, ev.height)`
|
|
928
|
+
(§27, priced at the FINALIZE height). On success the `pending`/`finalizeBy` keys become ABSENT, the
|
|
929
|
+
lease starts (`paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS`), and the name is NOT
|
|
930
|
+
`viaFill`.
|
|
931
|
+
- **Reservation expiry (lazy):** past `finalizeBy` an un-finalized reservation is swept exactly like a
|
|
932
|
+
lapsed lease (at each event height and at the tip+1 closing sweep): the name record is DELETED and the
|
|
933
|
+
name reopens. The would-be winner has lost only anchors, never the registration fee.
|
|
934
|
+
- **Client timing rule** (`FINALIZE_TIP_MARGIN = 2`, client-side only): sign the finalize at
|
|
935
|
+
`effHeight + 8 + 2` or later so one reorg cannot un-freeze the contest under a fee-bearing tx. The
|
|
936
|
+
20-block grace exists so a slow inclusion still lands before `finalizeBy`.
|
|
937
|
+
- **Adoption note (hard gate):** a stale (pre-v2.5) wallet crossing 51 000 attaches the registration fee
|
|
938
|
+
to what is now a payment-free reveal; the resolver ignores the fee and the payment burns. Every
|
|
939
|
+
replayer AND every fee-attaching client must run the v2.5 core before the tip crosses 51 000.
|
|
940
|
+
|
|
941
|
+
---
|
|
942
|
+
|
|
943
|
+
# CairnX Convention v2.6 (sealed-reservation recapture)
|
|
944
|
+
|
|
945
|
+
**Activation height: 51 200** (`V26_HEIGHT`; non-retroactive; keyed on the reveal event height).
|
|
946
|
+
|
|
947
|
+
The §28 cure applied to LAPSED-name recapture (§17), whose losing racer previously forfeited the full
|
|
948
|
+
decaying premium (up to hundreds of CSD).
|
|
949
|
+
|
|
950
|
+
## 29. Recapture through the same sealed machinery
|
|
951
|
+
|
|
952
|
+
- **Reveal on a lapsed name (height ≥ 51 200):** payment-free. Creates a recapture reservation in an
|
|
953
|
+
INTERNAL `recaptures` map. The reservation is NOT materialized in canonical state, and the lapsed
|
|
954
|
+
record in `names` is left untouched (it is the premium basis; an abandoned reservation can never
|
|
955
|
+
bypass the premium). Below v2.6, recapture stays pay-now at reveal (§17, byte-identical).
|
|
956
|
+
- **Same windows and contest:** reveal window and freeze are `REG_COMMIT_MAX_BLOCKS = 8`;
|
|
957
|
+
`finalizeBy = effHeight + 8 + 20`; lowest `(effHeight, pos, id)` displaces among reservations; its own
|
|
958
|
+
`MAX_PENDING_REG = 3` per-address cap; overdue reservations are lazily swept.
|
|
959
|
+
- **Finalize:** the same `nfinalize` record, salt-bound to the recapture commit. The winner pays the §17
|
|
960
|
+
decaying premium priced at the FINALIZE height (slightly more decayed than at reveal: rounding favors
|
|
961
|
+
the payer). On success the name becomes a normal fresh lease under the new owner, NOT `viaFill`
|
|
962
|
+
(displacement-immune by the same freeze arithmetic as §28).
|
|
963
|
+
- **Replayer note:** because the reservation map is internal, pre-v2.6 canonical hashes are untouched,
|
|
964
|
+
but a third-party resolver MUST still replicate the map (reveal, displacement, expiry) to agree on
|
|
965
|
+
which later `nfinalize` succeeds. The map is defined by this section plus the reference resolver and
|
|
966
|
+
its Python mirror; the v2.6 conformance vectors pin it.
|
|
967
|
+
- **Adoption note (hard gate):** same shape as §28. A stale wallet attaches the premium to a
|
|
968
|
+
payment-free recapture reveal and burns it. All replayers and clients on the v2.6 core before 51 200.
|
|
969
|
+
|
|
970
|
+
---
|
|
971
|
+
|
|
972
|
+
# CairnX Convention v2.7 (young-name sale embargo shrinks)
|
|
973
|
+
|
|
974
|
+
**Activation height: 52 500** (`V27_HEIGHT`; non-retroactive; keyed on the OFFER event height).
|
|
975
|
+
|
|
976
|
+
## 30. Sale embargo: 240 blocks becomes 8
|
|
977
|
+
|
|
978
|
+
A name `offer` (§17 sale path) whose event height `H` satisfies `H − effHeight ≤ embargo` is a no-op
|
|
979
|
+
(`name too young to sell (must out-age the reveal window)`), where `effHeight` is the name's effective
|
|
980
|
+
anchor. `viaFill` names were never embargoed.
|
|
981
|
+
|
|
982
|
+
- **`H` < 52 500:** `embargo = COMMIT_MAX_BLOCKS` (240 blocks, ≈ 8 h). The pre-sealed rule: a fresh name
|
|
983
|
+
had to out-age every lurking back-dated reveal before it could be sold.
|
|
984
|
+
- **`H` ≥ 52 500:** `embargo = REG_COMMIT_MAX_BLOCKS` (8 blocks, ≈ 16 min). Under §28/§29 a finalized
|
|
985
|
+
name is displacement-immune the moment its freeze passes, so out-aging the old 240-block window is
|
|
986
|
+
redundant; 8 matches the freeze itself.
|
|
987
|
+
- The gate keys on the OFFER's height, so the same young name can be unsellable at 52 499 and sellable
|
|
988
|
+
at 52 501. Deterministic for every replayer; no name-age era bookkeeping is needed.
|
|
989
|
+
- **Adoption note:** a relaxation (fresh cores accept a sale a stale core no-ops), so every replayer must
|
|
990
|
+
run the v2.7 core before the tip crosses 52 500.
|
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,
|
|
@@ -180,7 +181,7 @@ var DEPLOY_FEE = 1e8;
|
|
|
180
181
|
var V18_HEIGHT = 4e4;
|
|
181
182
|
var NAME_FEE_SHORT_V18 = 670000000n;
|
|
182
183
|
var NAME_FEE_V18 = 300000000n;
|
|
183
|
-
var V24_HEIGHT =
|
|
184
|
+
var V24_HEIGHT = 46400;
|
|
184
185
|
var NAME_FEE_LEN3_V24 = 1500000000n;
|
|
185
186
|
var NAME_FEE_LEN4_V24 = 1000000000n;
|
|
186
187
|
var NAME_FEE_MID_V24 = 500000000n;
|
|
@@ -221,12 +222,13 @@ var HASH_RE = /^0x[0-9a-f]{64}$/;
|
|
|
221
222
|
var SALT_RE = /^[0-9a-fA-F]{16,128}$/;
|
|
222
223
|
var RESERVED_NAMES = /* @__PURE__ */ new Set(["csd", "treasury", "admin", "official", "root", "www", "support"]);
|
|
223
224
|
var COMMIT_MAX_BLOCKS = 8 * import_csd_codec.EPOCH_LEN;
|
|
224
|
-
var V25_HEIGHT =
|
|
225
|
+
var V25_HEIGHT = 46440;
|
|
225
226
|
var REG_COMMIT_MAX_BLOCKS = 8;
|
|
226
227
|
var REG_FINALIZE_GRACE_BLOCKS = 20;
|
|
227
228
|
var MAX_PENDING_REG = 3;
|
|
228
229
|
var FINALIZE_TIP_MARGIN = 2;
|
|
229
|
-
var V26_HEIGHT =
|
|
230
|
+
var V26_HEIGHT = 46480;
|
|
231
|
+
var V27_HEIGHT = 46520;
|
|
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
|
@@ -37,7 +37,7 @@ declare const DEPLOY_FEE = 100000000;
|
|
|
37
37
|
declare const V18_HEIGHT = 40000;
|
|
38
38
|
declare const NAME_FEE_SHORT_V18 = 670000000n;
|
|
39
39
|
declare const NAME_FEE_V18 = 300000000n;
|
|
40
|
-
declare const V24_HEIGHT =
|
|
40
|
+
declare const V24_HEIGHT = 46400;
|
|
41
41
|
declare const NAME_FEE_LEN3_V24 = 1500000000n;
|
|
42
42
|
declare const NAME_FEE_LEN4_V24 = 1000000000n;
|
|
43
43
|
declare const NAME_FEE_MID_V24 = 500000000n;
|
|
@@ -63,12 +63,13 @@ declare const HASH_RE: RegExp;
|
|
|
63
63
|
declare const SALT_RE: RegExp;
|
|
64
64
|
declare const RESERVED_NAMES: Set<string>;
|
|
65
65
|
declare const COMMIT_MAX_BLOCKS: number;
|
|
66
|
-
declare const V25_HEIGHT =
|
|
66
|
+
declare const V25_HEIGHT = 46440;
|
|
67
67
|
declare const REG_COMMIT_MAX_BLOCKS = 8;
|
|
68
68
|
declare const REG_FINALIZE_GRACE_BLOCKS = 20;
|
|
69
69
|
declare const MAX_PENDING_REG = 3;
|
|
70
70
|
declare const FINALIZE_TIP_MARGIN = 2;
|
|
71
|
-
declare const V26_HEIGHT =
|
|
71
|
+
declare const V26_HEIGHT = 46480;
|
|
72
|
+
declare const V27_HEIGHT = 46520;
|
|
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
|
@@ -37,7 +37,7 @@ declare const DEPLOY_FEE = 100000000;
|
|
|
37
37
|
declare const V18_HEIGHT = 40000;
|
|
38
38
|
declare const NAME_FEE_SHORT_V18 = 670000000n;
|
|
39
39
|
declare const NAME_FEE_V18 = 300000000n;
|
|
40
|
-
declare const V24_HEIGHT =
|
|
40
|
+
declare const V24_HEIGHT = 46400;
|
|
41
41
|
declare const NAME_FEE_LEN3_V24 = 1500000000n;
|
|
42
42
|
declare const NAME_FEE_LEN4_V24 = 1000000000n;
|
|
43
43
|
declare const NAME_FEE_MID_V24 = 500000000n;
|
|
@@ -63,12 +63,13 @@ declare const HASH_RE: RegExp;
|
|
|
63
63
|
declare const SALT_RE: RegExp;
|
|
64
64
|
declare const RESERVED_NAMES: Set<string>;
|
|
65
65
|
declare const COMMIT_MAX_BLOCKS: number;
|
|
66
|
-
declare const V25_HEIGHT =
|
|
66
|
+
declare const V25_HEIGHT = 46440;
|
|
67
67
|
declare const REG_COMMIT_MAX_BLOCKS = 8;
|
|
68
68
|
declare const REG_FINALIZE_GRACE_BLOCKS = 20;
|
|
69
69
|
declare const MAX_PENDING_REG = 3;
|
|
70
70
|
declare const FINALIZE_TIP_MARGIN = 2;
|
|
71
|
-
declare const V26_HEIGHT =
|
|
71
|
+
declare const V26_HEIGHT = 46480;
|
|
72
|
+
declare const V27_HEIGHT = 46520;
|
|
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
|
@@ -40,7 +40,7 @@ var DEPLOY_FEE = 1e8;
|
|
|
40
40
|
var V18_HEIGHT = 4e4;
|
|
41
41
|
var NAME_FEE_SHORT_V18 = 670000000n;
|
|
42
42
|
var NAME_FEE_V18 = 300000000n;
|
|
43
|
-
var V24_HEIGHT =
|
|
43
|
+
var V24_HEIGHT = 46400;
|
|
44
44
|
var NAME_FEE_LEN3_V24 = 1500000000n;
|
|
45
45
|
var NAME_FEE_LEN4_V24 = 1000000000n;
|
|
46
46
|
var NAME_FEE_MID_V24 = 500000000n;
|
|
@@ -81,12 +81,13 @@ var HASH_RE = /^0x[0-9a-f]{64}$/;
|
|
|
81
81
|
var SALT_RE = /^[0-9a-fA-F]{16,128}$/;
|
|
82
82
|
var RESERVED_NAMES = /* @__PURE__ */ new Set(["csd", "treasury", "admin", "official", "root", "www", "support"]);
|
|
83
83
|
var COMMIT_MAX_BLOCKS = 8 * EPOCH_LEN;
|
|
84
|
-
var V25_HEIGHT =
|
|
84
|
+
var V25_HEIGHT = 46440;
|
|
85
85
|
var REG_COMMIT_MAX_BLOCKS = 8;
|
|
86
86
|
var REG_FINALIZE_GRACE_BLOCKS = 20;
|
|
87
87
|
var MAX_PENDING_REG = 3;
|
|
88
88
|
var FINALIZE_TIP_MARGIN = 2;
|
|
89
|
-
var V26_HEIGHT =
|
|
89
|
+
var V26_HEIGHT = 46480;
|
|
90
|
+
var V27_HEIGHT = 46520;
|
|
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,
|