@inversealtruism/cairnx-core 0.1.16 → 0.1.18
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 +281 -8
- package/dist/index.cjs +38 -50
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +38 -50
- package/package.json +1 -1
- package/test/vectors/VECTORS.md +16 -6
- package/test/vectors/cases.json +2031 -0
- package/test/vectors/replay-hashes.json +10 -3
package/CONVENTION.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# CairnX Convention v1
|
|
2
2
|
|
|
3
|
-
**Status:**
|
|
3
|
+
**Status:** v2.1 (normative; supersedes the 2026-06-10 v1.0 draft) · **Domain:** `cairnx:v1` · **Base activation:** 29 860
|
|
4
|
+
|
|
5
|
+
**Version ladder** (each gate non-retroactive — below it, behavior + canonical hashes are byte-identical to history):
|
|
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
|
+
Sections §19–§24 are the normative semantics for v1.6–v2.1; §5.1 is the byte-level canonical-JSON contract that binds all of them.
|
|
9
|
+
|
|
10
|
+
> **Canonical copy.** This spec ships in the published `@inversealtruism/cairnx-core` package; the source of
|
|
11
|
+
> truth is `csd-sdk/packages/cairnx/CONVENTION.md`. Any in-repo mirror (e.g. the `cairnx` app repo) MUST be
|
|
12
|
+
> kept **byte-identical** to it on every change — a third-party implementer fetches the *published* copy, so
|
|
13
|
+
> it is the one that must never lag the code. Keep the two in lockstep when editing.
|
|
4
14
|
|
|
5
15
|
CairnX is a meta-asset and exchange convention on Compute Substrate (CSD). It defines fungible
|
|
6
16
|
tokens and atomic delivery-versus-payment trades using **only** the chain's existing `Propose`
|
|
@@ -143,15 +153,18 @@ is atomic at consensus level**: the buyer cannot pay without (the chain recordin
|
|
|
143
153
|
receiving, and the seller's tokens were already convention-locked. The fill costs only the
|
|
144
154
|
attest fee floor (0.05 CSD) plus the payment.
|
|
145
155
|
|
|
146
|
-
The **first valid fill in apply order wins**. `confidence` is ignored
|
|
156
|
+
The **first valid fill in apply order wins**. For a **CSD-priced** fill `confidence` is ignored
|
|
157
|
+
(set 100); a **token-priced** fill (§11) additionally requires the `confidence = 1 000 000` opt-in
|
|
158
|
+
marker or it is a no-op.
|
|
147
159
|
|
|
148
160
|
### 4.6 `cancel` — close an offer (an Attest)
|
|
149
161
|
|
|
150
162
|
`Attest` on the offer with **`score = 0`**, valid only when `attester == seller`. Releases the
|
|
151
163
|
lock, closes the offer. (Cancel and fill race in apply order like everything else.)
|
|
152
164
|
|
|
153
|
-
Other `score` values on CairnX offers are reserved (no-ops)
|
|
154
|
-
|
|
165
|
+
Other `score` values on CairnX offers are reserved (no-ops). The **claim-to-fill** exclusivity
|
|
166
|
+
extension shipped at v1.7 (height 34 000) and uses **`score = 50`** (`SCORE_CLAIM`) — *not* `score = 1`
|
|
167
|
+
(an earlier draft placeholder that was never implemented). See §20.
|
|
155
168
|
|
|
156
169
|
## 5. Resolver state (normative output)
|
|
157
170
|
|
|
@@ -177,6 +190,99 @@ event log and used locale collation; it is retired.)
|
|
|
177
190
|
Determinism requirement: the conformance suite enforces byte-identity, including
|
|
178
191
|
shuffle-invariance of inputs that consensus ordering re-sorts.
|
|
179
192
|
|
|
193
|
+
### 5.1 The byte-level canonical-JSON contract (normative — pin before a 2nd implementation exists)
|
|
194
|
+
|
|
195
|
+
"Canonical JSON" above is only as portable as these rules. They document exactly what the reference
|
|
196
|
+
canonicalizer (`@inversealtruism/csd-codec` `canonicalJson`, which bottoms out in ECMA-262
|
|
197
|
+
`JSON.stringify`) produces. An independent resolver that diverges on any of them will fork the
|
|
198
|
+
record-acceptance gate and/or the canonical-state hash on valid mainnet data. These are unmigratable
|
|
199
|
+
once a replay hash is pinned over data that exercises them, so they are stated here verbatim.
|
|
200
|
+
|
|
201
|
+
- **A1 — String escaping.** Escape **only** `"` → `\"`, `\` → `\\`, and the C0 controls U+0000–U+001F
|
|
202
|
+
(using the short escapes `\b \f \n \r \t`, otherwise lowercase `\u00XX`). Emit **every other**
|
|
203
|
+
codepoint as **raw UTF-8** — in particular do **NOT** escape `/` (solidus) and do **NOT** `\u`-escape
|
|
204
|
+
any non-ASCII codepoint (U+0080 and above). A token `name` of `"Café"` serializes the `é` as the raw
|
|
205
|
+
2-byte UTF-8 `0xC3 0xA9`, never `é`; an emoji serializes as its raw 4-byte UTF-8, never an
|
|
206
|
+
escaped surrogate pair. (Note: `memo` fields on transfer/offer/bid carry the same free-Unicode
|
|
207
|
+
surface inside the record `uri`, so they obey A1 too even though they are not in canonical state.)
|
|
208
|
+
**A1 is unsatisfiable for a lone/unpaired UTF-16 surrogate** (it has no valid UTF-8 form): V8 escapes
|
|
209
|
+
it to ASCII `\uXXXX` while a raw-UTF-8 resolver rejects/mangles it, so such a string is rejected
|
|
210
|
+
outright by **A7** before it can reach A1 — see A7.
|
|
211
|
+
- **A2 — Key ordering is UTF-16 code-unit order, NOT Unicode codepoint / UTF-8 byte order.** Sort object
|
|
212
|
+
keys by comparing their UTF-16 code units. These two orders are identical for all-BMP strings but
|
|
213
|
+
**diverge for non-BMP characters (U+10000+)**: a leading surrogate `0xD800–0xDBFF` sorts *below* BMP
|
|
214
|
+
chars `0xE000–0xFFFF` under UTF-16, but *above* all BMP chars under codepoint order. **Rust
|
|
215
|
+
`str::cmp` / Go `<` on `string` compare by UTF-8 bytes = codepoint order and are therefore WRONG** for
|
|
216
|
+
a non-BMP key — implementers MUST compare UTF-16 code units (JS `localeCompare` is also wrong; use the
|
|
217
|
+
default `<`/`>` on the JS string, i.e. code-unit order, which is what the resolver's `ord()` does).
|
|
218
|
+
- **A3 — Field types (bare number/boolean vs decimal string vs identity string).** Canonical state mixes
|
|
219
|
+
raw JSON integers and booleans with decimal-string amounts and raw identity strings. Emit as **bare
|
|
220
|
+
integers**: `decimals, height, effectiveHeight, expiresEpoch, feeBps, tipHeight, paidThroughEpoch`, and
|
|
221
|
+
(v1.7) `claimUntilHeight` (all JS-safe, < 2^53). Emit as **bare booleans**: `locked, viaFill, expired`.
|
|
222
|
+
Emit as **decimal strings**: `supply, minted, mintLimit, feesPaid`, every `balances.*.available`/`.locked`,
|
|
223
|
+
`want.value`, `want.amount`, `min`, `paid`, `delivered`, and each fill's `paid`/`.fee` (plus `.got` ONLY on
|
|
224
|
+
a partial `fills[]` entry — see the fill shapes below). Emit as **raw 0x-hex identity strings**: the offer
|
|
225
|
+
`id` (32-byte txid), the name `claimId` (32-byte anchor txid, present on **every** name), and (v1.7) the
|
|
226
|
+
offer `claimedBy` (20-byte addr). Emit as a nested **object**: the name `profile` (v1.9 nprofile — a flat
|
|
227
|
+
string→string map). **Two distinct fill shapes (the `got`-presence rule):** a whole-offer fill is the
|
|
228
|
+
singular object `fill` = `{buyer, txid, height, paid, fee}` and **OMITS `got`**; a partial-fillable (`min`)
|
|
229
|
+
offer instead carries an **array** `fills`, each entry `{buyer, txid, height, paid, fee, got}` **WITH
|
|
230
|
+
`got`** (`got` = the give-asset units delivered by that partial). An implementer who adds `got` to the
|
|
231
|
+
singular `fill` (or drops it from a `fills[]` entry) forks `sha256(canonicalState)`. Never serialize an
|
|
232
|
+
amount as a number or an `f64`; never stringify an integer field.
|
|
233
|
+
> **⚠ v1.7/v1.9 are part of this byte contract on every live tip past their gate** (`V17_HEIGHT=34000`
|
|
234
|
+
> claims, `V19_HEIGHT=36700` profiles). A second-language resolver built to an earlier copy of this list
|
|
235
|
+
> — omitting `claimedBy`/`claimUntilHeight`/`claimId`/`profile`/`fills` — **forks `sha256(canonicalState)`
|
|
236
|
+
> the moment any offer is claimed or any name carries a profile.** (Pinned on live data by
|
|
237
|
+
> `replay-hashes.json` at **every activation height through V20** — incl. 34 000 claims, 36 700 profiles,
|
|
238
|
+
> 38 400 grace; V18/V21 auto-pin once the chain tip crosses them. The static `cases.json` bar additionally
|
|
239
|
+
> pins the V20/V21/nprofile/name-op/lapse byte-contract with no live node required.)
|
|
240
|
+
- **A4 — Optional fields are OMITTED, never `null`.** A key whose value is absent is dropped entirely
|
|
241
|
+
(`addr, viaFill, min, bid, taker, paidThroughEpoch, expired`, token `name`/`mintLimit`/`tmeta`, and the
|
|
242
|
+
v1.7/v1.9 optionals `claimedBy`/`claimUntilHeight` (omitted unless the offer is claimed), `fill`
|
|
243
|
+
(omitted until first filled), `fills` (only on a `min` offer), `profile` (only when an nprofile is set)).
|
|
244
|
+
Never emit `"addr":null`.
|
|
245
|
+
- **A5 — The acceptance gate is a byte-exact round-trip (stronger than the hash check).** A record anchor
|
|
246
|
+
is accepted iff **both** `canonicalJson(JSON.parse(uri)) === uri` (byte-for-byte) **and**
|
|
247
|
+
`sha256(uri) === payload_hash`. The round-trip is what rejects duplicate keys, leading-zero amounts,
|
|
248
|
+
`+` signs, and insignificant whitespace; a record failing either check is a no-op and never enters
|
|
249
|
+
replay. The round-trip does **not** catch a lone surrogate (it survives `JSON.parse`→`canonicalJson`
|
|
250
|
+
identically as ASCII `\uXXXX`) — that class is rejected by **A7**, which every resolver MUST apply.
|
|
251
|
+
- **A6 — Integer grammar + the exact expressions.** Amounts match `^(0|[1-9][0-9]*)$` with
|
|
252
|
+
`MAX_AMOUNT = 2^96 − 1`. The taker fee is `tradeFee(want) = (want·FEE_BPS + 9999) / 10000` (integer
|
|
253
|
+
division = ceil of 1%). `epochOf(height) = floor(height / 30)`. Constants: `COMMIT_MAX_BLOCKS = 240`,
|
|
254
|
+
`NAME_TERM_EPOCHS = 8760`, `NAME_GRACE_EPOCHS = 720`. Tickers match `^[A-Z][A-Z0-9]{2,11}$`
|
|
255
|
+
(effective length **3–12**). **String length limits count UTF-16 CODE UNITS (JS `.length`)**, NOT
|
|
256
|
+
codepoints or UTF-8 bytes: the free-text token `name` ≤ **32** units and `memo` ≤ **64** units. An
|
|
257
|
+
astral codepoint (U+10000+) is **2** units, so a 16-emoji name is exactly 32 units (accepted) and a
|
|
258
|
+
17-emoji name is 34 (a no-op). A resolver counting `chars`/codepoints (Rust `str::chars().count()`)
|
|
259
|
+
or bytes would FORK at this boundary — implementers MUST count UTF-16 units (Rust
|
|
260
|
+
`s.encode_utf16().count()`). Pinned by the `determinism-name-length-utf16-boundary` vector.
|
|
261
|
+
- **A7 — String well-formedness (UTF-16).** A record whose decoded JSON contains **any non-well-formed
|
|
262
|
+
UTF-16 string** — a lone/unpaired surrogate (`0xD800–0xDBFF` not followed by `0xDC00–0xDFFF`, or a
|
|
263
|
+
bare `0xDC00–0xDFFF`) in **any** key or value at any depth — is an **INVALID no-op for every
|
|
264
|
+
conformant resolver**, rejected before schema validation. Rationale: such a string has no defined
|
|
265
|
+
raw-UTF-8 canonical form (A1), so accepting it would credit on a V8 resolver and reject on a
|
|
266
|
+
raw-UTF-8 one — a cross-language fork on identical chain bytes. Reference: `parseRecord`'s
|
|
267
|
+
`isWellFormedDeep` gate (records.ts), which runs immediately after the A5 round-trip. Implementers
|
|
268
|
+
MUST reproduce it (e.g. JS `String.prototype.isWellFormed`, Rust `str` is already well-formed so a
|
|
269
|
+
`serde_json` parse that surfaces the escape and re-encodes will reject — assert it explicitly).
|
|
270
|
+
|
|
271
|
+
The conformance suite **now includes** the A1–A4/A7 vectors (`determinism-nonascii-name-value-pinned`
|
|
272
|
+
covers a non-ASCII token name, an emoji/non-BMP name, and CJK; `determinism-lone-surrogate-rejected`
|
|
273
|
+
covers the A7 no-op; control-character and present-vs-absent optionals are exercised by
|
|
274
|
+
`determinism-a.test.ts`). A second-language resolver is conformant only if it reproduces every vector's
|
|
275
|
+
canonical state **and** the pinned `replay-hashes.json` on live data byte-for-byte.
|
|
276
|
+
|
|
277
|
+
**Activated since this section was first written (all gated, all in the byte contract above):** v1.6
|
|
278
|
+
(`V16_HEIGHT=33600`) raised the taker fee to `FEE_BPS_V16=150` and added the flat+`REBATE_BPS` maker
|
|
279
|
+
rebate on resting liquidity; v1.7 (`V17_HEIGHT=34000`) added claim-to-fill (`SCORE_CLAIM`, the offer
|
|
280
|
+
`claimedBy`/`claimUntilHeight` fields, `MAX_ACTIVE_CLAIMS`/`CLAIM_WINDOW_BLOCKS`/`CLAIM_COOLDOWN_BLOCKS`);
|
|
281
|
+
v1.8 (`V18_HEIGHT=40000`, dormant) retiers the name registration fee; v1.9 (`V19_HEIGHT=36700`) added the
|
|
282
|
+
`nprofile` record + the name `profile` map (`PROFILE_MAX_KEYS`/`PROFILE_MAX_VALUE_BYTES`, the `PKEY`
|
|
283
|
+
charset). *(Still genuinely future / not implemented: pooled `pools`/`shares` value and a `MAX_RESERVE`
|
|
284
|
+
cap — ecosystem doc 16 §4; these are NOT in canonical state today.)*
|
|
285
|
+
|
|
180
286
|
## 6. Honest limits & safety
|
|
181
287
|
|
|
182
288
|
- **Convention-enforced, not consensus-enforced.** The chain knows nothing about tokens; it
|
|
@@ -191,7 +297,10 @@ shuffle-invariance of inputs that consensus ordering re-sorts.
|
|
|
191
297
|
deterministically. **v1.3 closes this structurally:** from height 31 100, CSD-priced offers
|
|
192
298
|
must be taker-bound (§15) — a warning cannot hold users back from a full-payment loss, and a
|
|
193
299
|
no-escrow chain has nothing to refund from, so the unsafe shape is removed rather than warned
|
|
194
|
-
about. (
|
|
300
|
+
about. (A claim window was first dismissed here as impossible because a *payment-bearing*
|
|
301
|
+
reservation has nothing to refund — but v1.7's claim is **payment-free** (an `Attest`, not a
|
|
302
|
+
payment), so a losing claimer forfeits only the 0.05 CSD attest fee. On that basis v1.7 safely
|
|
303
|
+
**re-opens** untaken CSD offers via claim-to-fill — §20 — and v2.0/§23 bounds its late-fill edge.)
|
|
195
304
|
- **No unconfirmed chaining (no CPFP).** The mempool only accepts txs whose inputs exist in the
|
|
196
305
|
confirmed UTXO set — you cannot spend change that hasn't been mined. Sequential CairnX actions
|
|
197
306
|
from one key require one confirmation between them; client software must serialize and surface
|
|
@@ -208,9 +317,12 @@ shuffle-invariance of inputs that consensus ordering re-sorts.
|
|
|
208
317
|
|
|
209
318
|
| action | tx type | domain/ref | app fields | outputs |
|
|
210
319
|
|---|---|---|---|---|
|
|
211
|
-
| deploy/mint/transfer/offer | Propose | `cairnx:v1` | `uri` = record JSON, `payload_hash` = sha256(uri), `expires_epoch` per §4 | change
|
|
212
|
-
| fill | Attest | offer proposal id | `score=100
|
|
213
|
-
|
|
|
320
|
+
| deploy/mint/transfer/offer/bid/name-ops | Propose | `cairnx:v1` | `uri` = record JSON, `payload_hash` = sha256(uri), `expires_epoch` per §4 | fee/payment outputs per §10/§19 + change |
|
|
321
|
+
| fill (CSD-priced) | Attest | offer proposal id | `score=100` (confidence ignored) | payment to `want.payto` + treasury fee + maker rebate (§19) + change |
|
|
322
|
+
| fill (token-priced) | Attest | offer proposal id | `score=100, confidence=1 000 000` | change only (debit + in-kind fee are convention-side, §11) |
|
|
323
|
+
| claim (v1.7, untaken CSD offer) | Attest | offer proposal id | `score=50` | change only — payment-free reservation (§20) |
|
|
324
|
+
| cancel | Attest | offer proposal id | `score=0` | change only |
|
|
325
|
+
| ocancel | Propose | `cairnx:v1` | `uri` = `{t:"ocancel",…}` | change only |
|
|
214
326
|
|
|
215
327
|
Fee floors: Propose ≥ 25 000 000, Attest ≥ 5 000 000 base units. 1 CSD = 100 000 000 base units.
|
|
216
328
|
|
|
@@ -528,3 +640,164 @@ From height **32 000** every name is a **lease**:
|
|
|
528
640
|
`{logo, description, links}` document — self-certifying content, so the record stays tiny
|
|
529
641
|
(the 512-byte `uri` cap is untouched) and the metadata inherits the swarm's verify-on-read
|
|
530
642
|
property. State: `tokens[t].tmeta`. Records before v1.5 are no-ops.
|
|
643
|
+
|
|
644
|
+
---
|
|
645
|
+
|
|
646
|
+
# CairnX Convention v1.6 (fee update + maker rebate)
|
|
647
|
+
|
|
648
|
+
**Activation height: 33 600** (`V16_HEIGHT`; non-retroactive — pre-v1.6 offers keep the 1% fee and earn no rebate).
|
|
649
|
+
|
|
650
|
+
## 19. Taker fee 1% → 1.5%, and a maker rebate on resting liquidity
|
|
651
|
+
|
|
652
|
+
- **Fee bump.** The taker fee becomes `FEE_BPS_V16 = 150` (1.5%, `ceil`) instead of `FEE_BPS = 100` (1%).
|
|
653
|
+
The rate is **captured per-offer at creation height** into `offers[id].feeBps` (a bare-int canonical field,
|
|
654
|
+
§5.1-A3): an offer anchored ≥ 33 600 carries `feeBps = 150`, an earlier one keeps `100`. Every fill of that
|
|
655
|
+
offer (whole, partial, token-priced) uses the offer's own `feeBps` — so pre-v1.6 offers are byte-identical
|
|
656
|
+
forever. A third-party resolver MUST select the fee by **offer-creation height**, not by fill height.
|
|
657
|
+
- **Maker rebate (whole CSD-priced fills only).** On a whole fill of a **resting-liquidity** CSD-priced offer,
|
|
658
|
+
the taker additionally pays the **maker** (`offers[id].seller`) a rebate, as an extra output **in the same
|
|
659
|
+
fill tx**, reimbursing the maker's posting (Propose) cost:
|
|
660
|
+
`makerRebate(want) = REBATE_FLAT + ceil(REBATE_BPS × want / 10000)` with `REBATE_FLAT = 25 000 000`
|
|
661
|
+
(0.25 CSD) and `REBATE_BPS = 50` (0.5%).
|
|
662
|
+
- **`restingLiquidity` predicate (normative):** an offer qualifies iff
|
|
663
|
+
`(offer.taker !== undefined && offer.bid !== undefined)` — a taker-bound answer to a bid (the RFQ/MM lane) —
|
|
664
|
+
**OR** `(offer.height ≥ V17_HEIGHT && offer.taker === undefined)` — a v1.7 open ask (claim-to-fill).
|
|
665
|
+
Partial fills and token⇄token fills earn **no** rebate. (Keying on `bid` alone was a closed self-mint hole:
|
|
666
|
+
a maker could self-attach an unanchored bid to an open offer; the open-ask lane now earns it via `taker
|
|
667
|
+
=== undefined && height ≥ V17` regardless of `bid`, and a bid-answer rebate requires a real consenting taker.)
|
|
668
|
+
- **Same-tx output gate (the SUM rule).** The fill's required outputs are accumulated **per recipient**:
|
|
669
|
+
`want.payto += want.value`, `TREASURY += tradeFee(want, feeBps)`, and (if rebate applies) `seller += rebate`.
|
|
670
|
+
When `want.payto == seller` (the common default) the two amounts **SUM** — a resolver MUST check each
|
|
671
|
+
recipient against the summed requirement, never satisfy by `max()`. (`payto` can never be the treasury, so
|
|
672
|
+
those buckets never collide.) For a pre-v1.6 offer the rebate is 0 and this reduces to the two original checks.
|
|
673
|
+
|
|
674
|
+
---
|
|
675
|
+
|
|
676
|
+
# CairnX Convention v1.7 (claim-to-fill — race-safe open CSD offers)
|
|
677
|
+
|
|
678
|
+
**Activation height: 34 000** (`V17_HEIGHT`; non-retroactive — in `[V13, V17)` open CSD fills stay banned, §15).
|
|
679
|
+
|
|
680
|
+
## 20. Claim-to-fill — an untaken CSD offer is reserved before it is paid
|
|
681
|
+
|
|
682
|
+
v1.3 (§15) removed open CSD offers because the loser of a payment-bearing fill race loses a real payment.
|
|
683
|
+
v1.7 re-opens them safely by moving the race to a **payment-free reservation**: a losing claimer forfeits only
|
|
684
|
+
the 0.05 CSD attest fee, never a payment.
|
|
685
|
+
|
|
686
|
+
- **Claim** = an `Attest` on the offer with **`score = SCORE_CLAIM = 50`** (∉ {fill 100, cancel 0}, so it is an
|
|
687
|
+
inert no-op below V17 — non-retroactive). It grants the attester an **exclusive hold** of the offer for
|
|
688
|
+
`CLAIM_WINDOW_BLOCKS = 15` blocks: on grant the resolver records `offers[id].claimedBy = attester` and
|
|
689
|
+
`offers[id].claimUntilHeight = grantHeight + 15` (both canonical fields, §5.1-A3, present only while claimed).
|
|
690
|
+
- **Fill gate.** A `SCORE_FILL` fill on an **untaken** (`taker === undefined`) CSD-priced offer at height ≥ V17
|
|
691
|
+
is valid **only if** the offer is currently held **and the filler is the holder**: `claimHeld(o, h) &&
|
|
692
|
+
attester === o.claimedBy`, where `claimHeld(o, h) = (o.claimedBy !== undefined) && (h < o.claimUntilHeight)`
|
|
693
|
+
(v2.0 widens this — §23). A fill by anyone else, or with no live claim, is a no-op (offer stays open).
|
|
694
|
+
- **No new claim while held.** A `claim` on an offer that is already held (`claimHeld`) is a no-op.
|
|
695
|
+
- **`MAX_ACTIVE_CLAIMS = 3` per address.** A claim is rejected if the attester already holds 3 offers
|
|
696
|
+
(`liveN = count of offers x where x.claimedBy === attester && claimHeld(x, h)`). Anti-squat.
|
|
697
|
+
- **`CLAIM_COOLDOWN_BLOCKS = 15`.** The address whose hold just lapsed (`o.claimedBy === attester`) may not
|
|
698
|
+
immediately re-grab the **same** offer until `h ≥ o.claimUntilHeight + CLAIM_COOLDOWN_BLOCKS` (in v2.0, the
|
|
699
|
+
cooldown runs from the end of the hold = window + grace). Known bound (identical in the Python reference, so
|
|
700
|
+
not a fork): the cooldown keys on the last claimer, so a colluding A→B→A pair can recycle one offer — a
|
|
701
|
+
payment-free liveness nuisance on a single offer, never value loss.
|
|
702
|
+
- **Reorg note (client, not consensus):** claim→fill is two txs, so the payment has a reorg exposure a single-tx
|
|
703
|
+
fill lacks. Buyer software MUST wait a value-scaled confirmation depth (gambler's-ruin sized) on the claim
|
|
704
|
+
before broadcasting the fill — this is a client policy, not a resolver rule, and does not affect canonical state.
|
|
705
|
+
- Taker-bound offers need no claim (they were never in the race). Token⇄token offers are no-op-safe and ignore claims.
|
|
706
|
+
|
|
707
|
+
---
|
|
708
|
+
|
|
709
|
+
# CairnX Convention v1.8 (two-tier name registration fee)
|
|
710
|
+
|
|
711
|
+
**Activation height: 40 000** (`V18_HEIGHT`; non-retroactive — below it the §10 ENS curve applies unchanged).
|
|
712
|
+
|
|
713
|
+
## 21. Flat two-tier name fee
|
|
714
|
+
|
|
715
|
+
At/above V18, `nameRegFee(name, height)` (the fee for `name` claim/reveal, `nrenew`, and the base of the §17
|
|
716
|
+
lapsed-premium) becomes a flat **two-tier** schedule, replacing the §10 length curve:
|
|
717
|
+
|
|
718
|
+
- name length **≤ 4** chars → `NAME_FEE_SHORT_V18 = 670 000 000` (6.7 CSD);
|
|
719
|
+
- name length **≥ 5** chars → `NAME_FEE_V18 = 300 000 000` (3 CSD).
|
|
720
|
+
|
|
721
|
+
Below 40 000 the original 5-tier curve (§10: ≤3→5, 4→2, 5→1, 6–9→0.5, 10+→0.1 CSD) still applies — the fee is
|
|
722
|
+
selected by **anchor height**, so all historical replay is byte-identical. (Client builders should price a fee
|
|
723
|
+
output built within a few blocks *below* V18 at the V18 rate, since overpay is always accepted but underpay is a
|
|
724
|
+
no-op that forfeits the treasury output.)
|
|
725
|
+
|
|
726
|
+
---
|
|
727
|
+
|
|
728
|
+
# CairnX Convention v1.9 (nprofile — ENS-class identity)
|
|
729
|
+
|
|
730
|
+
**Activation height: 36 700** (`V19_HEIGHT`; non-retroactive — `nprofile` below it is a forward-compat no-op).
|
|
731
|
+
|
|
732
|
+
## 22. `nprofile` — owner-set identity metadata on a name
|
|
733
|
+
|
|
734
|
+
```json
|
|
735
|
+
{"v":1,"t":"nprofile","name":"alice","p":{"url":"https://alice.example","eth.address":"0x…"}}
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
- **Inert metadata.** `p` is a flat string→string map. It carries **no fee, no value, and is never a send
|
|
739
|
+
target** — the address a name resolves to for payment stays in `nset` (`names[x].addr`). A resolver keeps
|
|
740
|
+
no reserved keys; the app layer keeps send targets out of `p`.
|
|
741
|
+
- **Owner-gated, last-write-wins.** Valid iff the proposer is the current name owner and the lease is not
|
|
742
|
+
lapsed (§17). The new `p` **replaces** the prior profile; an **empty `p` (`{}`) clears it**.
|
|
743
|
+
- **Cleared on every ownership change** — `nxfer`, a name `fill`, and a lapsed-premium re-claim all clear
|
|
744
|
+
`profile` exactly as they clear `addr`.
|
|
745
|
+
- **Shape limits (deterministic):** keys match `PKEY = ^[a-z0-9](?:[a-z0-9.-]{0,30}[a-z0-9])?$` (ASCII only,
|
|
746
|
+
so the canonical key sort is invariant across UTF-16/codepoint/byte impls — future-proof vs a third-language
|
|
747
|
+
resolver); at most `PROFILE_MAX_KEYS = 16` keys; each value is a string of ≤ `PROFILE_MAX_VALUE_BYTES = 256`
|
|
748
|
+
**UTF-8 bytes**. Any violation → the record is a no-op.
|
|
749
|
+
- **State:** `names[x].profile` is a nested object, materialized **only at v1.9+ tips** and **only when set** —
|
|
750
|
+
so every pre-v1.9 canonical hash is byte-unchanged, and a name with no profile omits the key (§5.1-A4).
|
|
751
|
+
|
|
752
|
+
---
|
|
753
|
+
|
|
754
|
+
# CairnX Convention v2.0 (claim grace — the bounded late-fill fix)
|
|
755
|
+
|
|
756
|
+
**Activation height: 38 400** (`V20_HEIGHT`; non-retroactive — below it the strict 15-block window of §20 stands).
|
|
757
|
+
|
|
758
|
+
## 23. Bounded claim grace — a slightly-late in-window fill still delivers
|
|
759
|
+
|
|
760
|
+
v1.7's claim-to-fill had a fund-loss edge: a fill submitted inside the window but **mining at the window
|
|
761
|
+
boundary** (`height == claimUntilHeight`) was rejected by the resolver while its CSD payment was already
|
|
762
|
+
UTXO-final → the buyer paid and received nothing (the live `69.csd` incident). v2.0 fixes it without a race:
|
|
763
|
+
|
|
764
|
+
- At/above V20 the claim window widens to `CLAIM_WINDOW_BLOCKS_V20 = 40`, and a **bounded fill grace** of
|
|
765
|
+
`CLAIM_FILL_GRACE_BLOCKS = 5` is added. The **hold = window + grace = 45 blocks** is exclusive on **both**
|
|
766
|
+
sides — within it the claimer's fill is honored **AND** no other address may claim. So a slightly-late
|
|
767
|
+
in-window fill still delivers, and there is **no displacement race** (the holder is exclusive for the whole
|
|
768
|
+
hold; below the grace a new claim is rejected). Past the hold the offer **reopens** — the hold is **bounded,
|
|
769
|
+
not "until displaced."** `claimHeld(o, h)` becomes `h < o.claimUntilHeight + grace(o)`.
|
|
770
|
+
- **Era inference (no new stored field).** The grace is derived from the claim's era so its inverse is
|
|
771
|
+
unambiguous: a claim granted at ≥ V20 has `claimUntilHeight = grantHeight + 40 ≥ V20 + 40`; a pre-V20 claim
|
|
772
|
+
has `claimUntilHeight ≤ V20 + 14`; the range `[V20+15, V20+40)` is **unreachable**. Therefore
|
|
773
|
+
`grace(o) = (o.claimUntilHeight − 40 ≥ V20_HEIGHT) ? 5 : 0`. Below V20 the window is 15 and the grace is 0 —
|
|
774
|
+
byte-identical history.
|
|
775
|
+
- The `MAX_ACTIVE_CLAIMS` count and the `CLAIM_COOLDOWN_BLOCKS` both use the **hold** (window + grace), so the
|
|
776
|
+
grace can neither expand an address's concurrent reach past the cap nor be used to dodge the cooldown.
|
|
777
|
+
- **Offer-expiry interaction (client guard, not consensus).** `sweepExpired` runs before the fill, so a fill
|
|
778
|
+
mining between the offer's expiry and the hold-end would still burn the payment. Client software MUST refuse
|
|
779
|
+
to claim/fill unless the offer's lease/expiry outlives the **hold-end** (`claimUntilHeight + grace`), not
|
|
780
|
+
merely the tip. This is a client policy bounding what to sign; the resolver state is unchanged by it.
|
|
781
|
+
|
|
782
|
+
---
|
|
783
|
+
|
|
784
|
+
# CairnX Convention v2.1 (offer/bid duration cap)
|
|
785
|
+
|
|
786
|
+
**Activation height: 40 100** (`V21_HEIGHT`; non-retroactive — below it the effective expiry is the raw `expires_epoch`).
|
|
787
|
+
|
|
788
|
+
## 24. Maximum offer/bid lifetime — `MAX_OFFER_EPOCHS = 168` (≈ 7 days)
|
|
789
|
+
|
|
790
|
+
To keep resting inventory shallow (so an in-browser SPV light client's checkpoint stays near the tip rather
|
|
791
|
+
than being dragged back to the oldest open offer), an offer or bid may rest at most `MAX_OFFER_EPOCHS = 168`
|
|
792
|
+
epochs from its anchor:
|
|
793
|
+
|
|
794
|
+
- **Creation gate (≥ V21):** an `offer` or `bid` whose `expires_epoch − epochOf(anchorHeight) > 168` is a
|
|
795
|
+
**no-op at creation** (`v2.1: offer/bid duration exceeds the max`).
|
|
796
|
+
- **Lazy sweep cap (≥ V21):** the **effective** expiry used by `sweepExpired` is
|
|
797
|
+
`effExpiry = min(expires_epoch, epochOf(anchorHeight) + 168)` whenever the **sweep height** is ≥ V21. So an
|
|
798
|
+
over-cap offer/bid created **before** V21 (which was validly accepted at creation) auto-expires the moment a
|
|
799
|
+
sweep first runs at a height ≥ V21 past its capped expiry. The cap is gated by the **current sweep height**
|
|
800
|
+
(deterministic across replayers), so existing over-cap inventory expires at exactly the same height for
|
|
801
|
+
everyone. Below V21, `effExpiry = expires_epoch` — byte-identical history.
|
|
802
|
+
- **Client expiry-height closed form** (mirrors the resolver's height-gated sweep, for buy-safety guards):
|
|
803
|
+
`offerExpiryHeight = min( (expires_epoch+1)·30 , max( V21_HEIGHT , (epochOf(anchor)+168+1)·30 ) )`.
|
package/dist/index.cjs
CHANGED
|
@@ -143,7 +143,7 @@ var NAME_FEE_SHORT_V18 = 670000000n;
|
|
|
143
143
|
var NAME_FEE_V18 = 300000000n;
|
|
144
144
|
var V19_HEIGHT = 36700;
|
|
145
145
|
var V20_HEIGHT = 38400;
|
|
146
|
-
var V21_HEIGHT =
|
|
146
|
+
var V21_HEIGHT = 40100;
|
|
147
147
|
var MAX_OFFER_EPOCHS = 168;
|
|
148
148
|
var PKEY = /^[a-z0-9](?:[a-z0-9.-]{0,30}[a-z0-9])?$/;
|
|
149
149
|
var PROFILE_MAX_KEYS = 16;
|
|
@@ -467,6 +467,31 @@ function resolve(events, tipHeight) {
|
|
|
467
467
|
const claimGrace = (o) => o.claimUntilHeight !== void 0 && o.claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_FILL_GRACE_BLOCKS : 0;
|
|
468
468
|
const claimHeld = (o, height) => o.claimedBy !== void 0 && o.claimUntilHeight !== void 0 && height < o.claimUntilHeight + claimGrace(o);
|
|
469
469
|
const claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
470
|
+
const openFillReject = (o, height, who) => {
|
|
471
|
+
if (!(height >= V13_HEIGHT && !o.taker)) return void 0;
|
|
472
|
+
if (height < V17_HEIGHT) return "v1.3: open CSD-quoted fills disabled (offer must be taker-bound)";
|
|
473
|
+
if (!(claimHeld(o, height) && who === o.claimedBy)) return "v1.7: open offer \u2014 claim it first (no live claim by you)";
|
|
474
|
+
return void 0;
|
|
475
|
+
};
|
|
476
|
+
const deliverNameToBuyer = (n, who, ev) => {
|
|
477
|
+
n.owner = who;
|
|
478
|
+
n.locked = false;
|
|
479
|
+
n.addr = void 0;
|
|
480
|
+
n.profile = void 0;
|
|
481
|
+
if (ev.height >= V13_HEIGHT) {
|
|
482
|
+
n.effHeight = ev.height;
|
|
483
|
+
n.pos = ev.pos;
|
|
484
|
+
n.id = ev.txid;
|
|
485
|
+
n.height = ev.height;
|
|
486
|
+
n.viaFill = true;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
const releaseGiveLock = (o, who, amt) => {
|
|
490
|
+
const t = o.give.ticker;
|
|
491
|
+
bal(t, o.seller).locked -= amt;
|
|
492
|
+
bal(t, who).available += amt;
|
|
493
|
+
offerLock.delete(o.id);
|
|
494
|
+
};
|
|
470
495
|
for (const ev of ordered) {
|
|
471
496
|
if (ev.height < ACTIVATION_HEIGHT) continue;
|
|
472
497
|
if (ev.height !== pendingBlock) {
|
|
@@ -921,23 +946,8 @@ function resolve(events, tipHeight) {
|
|
|
921
946
|
buyer.available -= amt + fee;
|
|
922
947
|
bal(o.want.ticker, o.want.payto).available += amt;
|
|
923
948
|
if (fee > 0n) bal(o.want.ticker, TREASURY_ADDR).available += fee;
|
|
924
|
-
if (isNameGive(o.give))
|
|
925
|
-
|
|
926
|
-
giveName.locked = false;
|
|
927
|
-
giveName.addr = void 0;
|
|
928
|
-
giveName.profile = void 0;
|
|
929
|
-
if (ev.height >= V13_HEIGHT) {
|
|
930
|
-
giveName.effHeight = ev.height;
|
|
931
|
-
giveName.pos = ev.pos;
|
|
932
|
-
giveName.id = ev.txid;
|
|
933
|
-
giveName.height = ev.height;
|
|
934
|
-
giveName.viaFill = true;
|
|
935
|
-
}
|
|
936
|
-
} else {
|
|
937
|
-
bal(o.give.ticker, o.seller).locked -= giveLock;
|
|
938
|
-
bal(o.give.ticker, who).available += giveLock;
|
|
939
|
-
offerLock.delete(o.id);
|
|
940
|
-
}
|
|
949
|
+
if (isNameGive(o.give)) deliverNameToBuyer(giveName, who, ev);
|
|
950
|
+
else releaseGiveLock(o, who, giveLock);
|
|
941
951
|
o.status = "filled";
|
|
942
952
|
o.fill = { buyer: who, txid: ev.txid, height: ev.height, paid: amt.toString(), fee: fee.toString() };
|
|
943
953
|
markBidDone(o, who);
|
|
@@ -951,15 +961,10 @@ function resolve(events, tipHeight) {
|
|
|
951
961
|
note(ev, ev.txid, "fill", false, "taker-bound offer");
|
|
952
962
|
continue;
|
|
953
963
|
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
}
|
|
959
|
-
if (!(claimHeld(o, ev.height) && who === o.claimedBy)) {
|
|
960
|
-
note(ev, ev.txid, "fill", false, "v1.7: open offer \u2014 claim it first (no live claim by you)");
|
|
961
|
-
continue;
|
|
962
|
-
}
|
|
964
|
+
const blk = openFillReject(o, ev.height, who);
|
|
965
|
+
if (blk) {
|
|
966
|
+
note(ev, ev.txid, "fill", false, blk);
|
|
967
|
+
continue;
|
|
963
968
|
}
|
|
964
969
|
const pt = ev.paidTo ?? {};
|
|
965
970
|
const want = BigInt(o.want.value);
|
|
@@ -1016,15 +1021,10 @@ function resolve(events, tipHeight) {
|
|
|
1016
1021
|
note(ev, ev.txid, "fill", false, "taker-bound offer");
|
|
1017
1022
|
continue;
|
|
1018
1023
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
}
|
|
1024
|
-
if (!(claimHeld(o, ev.height) && who === o.claimedBy)) {
|
|
1025
|
-
note(ev, ev.txid, "fill", false, "v1.7: open offer \u2014 claim it first (no live claim by you)");
|
|
1026
|
-
continue;
|
|
1027
|
-
}
|
|
1024
|
+
const blk = openFillReject(o, ev.height, who);
|
|
1025
|
+
if (blk) {
|
|
1026
|
+
note(ev, ev.txid, "fill", false, blk);
|
|
1027
|
+
continue;
|
|
1028
1028
|
}
|
|
1029
1029
|
const pt = ev.paidTo ?? {};
|
|
1030
1030
|
const want = BigInt(o.want.value);
|
|
@@ -1052,26 +1052,14 @@ function resolve(events, tipHeight) {
|
|
|
1052
1052
|
note(ev, ev.txid, "fill", false, "name vanished (consensus violation)");
|
|
1053
1053
|
continue;
|
|
1054
1054
|
}
|
|
1055
|
-
n
|
|
1056
|
-
n.locked = false;
|
|
1057
|
-
n.addr = void 0;
|
|
1058
|
-
n.profile = void 0;
|
|
1059
|
-
if (ev.height >= V13_HEIGHT) {
|
|
1060
|
-
n.effHeight = ev.height;
|
|
1061
|
-
n.pos = ev.pos;
|
|
1062
|
-
n.id = ev.txid;
|
|
1063
|
-
n.height = ev.height;
|
|
1064
|
-
n.viaFill = true;
|
|
1065
|
-
}
|
|
1055
|
+
deliverNameToBuyer(n, who, ev);
|
|
1066
1056
|
} else {
|
|
1067
1057
|
const amt = offerLock.get(o.id);
|
|
1068
1058
|
if (amt === void 0) {
|
|
1069
1059
|
note(ev, ev.txid, "fill", false, "offer lock missing");
|
|
1070
1060
|
continue;
|
|
1071
1061
|
}
|
|
1072
|
-
|
|
1073
|
-
bal(o.give.ticker, who).available += amt;
|
|
1074
|
-
offerLock.delete(o.id);
|
|
1062
|
+
releaseGiveLock(o, who, amt);
|
|
1075
1063
|
}
|
|
1076
1064
|
feesPaid += fee;
|
|
1077
1065
|
o.status = "filled";
|
package/dist/index.d.cts
CHANGED
|
@@ -39,7 +39,7 @@ declare const NAME_FEE_SHORT_V18 = 670000000n;
|
|
|
39
39
|
declare const NAME_FEE_V18 = 300000000n;
|
|
40
40
|
declare const V19_HEIGHT = 36700;
|
|
41
41
|
declare const V20_HEIGHT = 38400;
|
|
42
|
-
declare const V21_HEIGHT =
|
|
42
|
+
declare const V21_HEIGHT = 40100;
|
|
43
43
|
declare const MAX_OFFER_EPOCHS = 168;
|
|
44
44
|
declare const PKEY: RegExp;
|
|
45
45
|
declare const PROFILE_MAX_KEYS = 16;
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ declare const NAME_FEE_SHORT_V18 = 670000000n;
|
|
|
39
39
|
declare const NAME_FEE_V18 = 300000000n;
|
|
40
40
|
declare const V19_HEIGHT = 36700;
|
|
41
41
|
declare const V20_HEIGHT = 38400;
|
|
42
|
-
declare const V21_HEIGHT =
|
|
42
|
+
declare const V21_HEIGHT = 40100;
|
|
43
43
|
declare const MAX_OFFER_EPOCHS = 168;
|
|
44
44
|
declare const PKEY: RegExp;
|
|
45
45
|
declare const PROFILE_MAX_KEYS = 16;
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var NAME_FEE_SHORT_V18 = 670000000n;
|
|
|
42
42
|
var NAME_FEE_V18 = 300000000n;
|
|
43
43
|
var V19_HEIGHT = 36700;
|
|
44
44
|
var V20_HEIGHT = 38400;
|
|
45
|
-
var V21_HEIGHT =
|
|
45
|
+
var V21_HEIGHT = 40100;
|
|
46
46
|
var MAX_OFFER_EPOCHS = 168;
|
|
47
47
|
var PKEY = /^[a-z0-9](?:[a-z0-9.-]{0,30}[a-z0-9])?$/;
|
|
48
48
|
var PROFILE_MAX_KEYS = 16;
|
|
@@ -366,6 +366,31 @@ function resolve(events, tipHeight) {
|
|
|
366
366
|
const claimGrace = (o) => o.claimUntilHeight !== void 0 && o.claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_FILL_GRACE_BLOCKS : 0;
|
|
367
367
|
const claimHeld = (o, height) => o.claimedBy !== void 0 && o.claimUntilHeight !== void 0 && height < o.claimUntilHeight + claimGrace(o);
|
|
368
368
|
const claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
369
|
+
const openFillReject = (o, height, who) => {
|
|
370
|
+
if (!(height >= V13_HEIGHT && !o.taker)) return void 0;
|
|
371
|
+
if (height < V17_HEIGHT) return "v1.3: open CSD-quoted fills disabled (offer must be taker-bound)";
|
|
372
|
+
if (!(claimHeld(o, height) && who === o.claimedBy)) return "v1.7: open offer \u2014 claim it first (no live claim by you)";
|
|
373
|
+
return void 0;
|
|
374
|
+
};
|
|
375
|
+
const deliverNameToBuyer = (n, who, ev) => {
|
|
376
|
+
n.owner = who;
|
|
377
|
+
n.locked = false;
|
|
378
|
+
n.addr = void 0;
|
|
379
|
+
n.profile = void 0;
|
|
380
|
+
if (ev.height >= V13_HEIGHT) {
|
|
381
|
+
n.effHeight = ev.height;
|
|
382
|
+
n.pos = ev.pos;
|
|
383
|
+
n.id = ev.txid;
|
|
384
|
+
n.height = ev.height;
|
|
385
|
+
n.viaFill = true;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
const releaseGiveLock = (o, who, amt) => {
|
|
389
|
+
const t = o.give.ticker;
|
|
390
|
+
bal(t, o.seller).locked -= amt;
|
|
391
|
+
bal(t, who).available += amt;
|
|
392
|
+
offerLock.delete(o.id);
|
|
393
|
+
};
|
|
369
394
|
for (const ev of ordered) {
|
|
370
395
|
if (ev.height < ACTIVATION_HEIGHT) continue;
|
|
371
396
|
if (ev.height !== pendingBlock) {
|
|
@@ -820,23 +845,8 @@ function resolve(events, tipHeight) {
|
|
|
820
845
|
buyer.available -= amt + fee;
|
|
821
846
|
bal(o.want.ticker, o.want.payto).available += amt;
|
|
822
847
|
if (fee > 0n) bal(o.want.ticker, TREASURY_ADDR).available += fee;
|
|
823
|
-
if (isNameGive(o.give))
|
|
824
|
-
|
|
825
|
-
giveName.locked = false;
|
|
826
|
-
giveName.addr = void 0;
|
|
827
|
-
giveName.profile = void 0;
|
|
828
|
-
if (ev.height >= V13_HEIGHT) {
|
|
829
|
-
giveName.effHeight = ev.height;
|
|
830
|
-
giveName.pos = ev.pos;
|
|
831
|
-
giveName.id = ev.txid;
|
|
832
|
-
giveName.height = ev.height;
|
|
833
|
-
giveName.viaFill = true;
|
|
834
|
-
}
|
|
835
|
-
} else {
|
|
836
|
-
bal(o.give.ticker, o.seller).locked -= giveLock;
|
|
837
|
-
bal(o.give.ticker, who).available += giveLock;
|
|
838
|
-
offerLock.delete(o.id);
|
|
839
|
-
}
|
|
848
|
+
if (isNameGive(o.give)) deliverNameToBuyer(giveName, who, ev);
|
|
849
|
+
else releaseGiveLock(o, who, giveLock);
|
|
840
850
|
o.status = "filled";
|
|
841
851
|
o.fill = { buyer: who, txid: ev.txid, height: ev.height, paid: amt.toString(), fee: fee.toString() };
|
|
842
852
|
markBidDone(o, who);
|
|
@@ -850,15 +860,10 @@ function resolve(events, tipHeight) {
|
|
|
850
860
|
note(ev, ev.txid, "fill", false, "taker-bound offer");
|
|
851
861
|
continue;
|
|
852
862
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
if (!(claimHeld(o, ev.height) && who === o.claimedBy)) {
|
|
859
|
-
note(ev, ev.txid, "fill", false, "v1.7: open offer \u2014 claim it first (no live claim by you)");
|
|
860
|
-
continue;
|
|
861
|
-
}
|
|
863
|
+
const blk = openFillReject(o, ev.height, who);
|
|
864
|
+
if (blk) {
|
|
865
|
+
note(ev, ev.txid, "fill", false, blk);
|
|
866
|
+
continue;
|
|
862
867
|
}
|
|
863
868
|
const pt = ev.paidTo ?? {};
|
|
864
869
|
const want = BigInt(o.want.value);
|
|
@@ -915,15 +920,10 @@ function resolve(events, tipHeight) {
|
|
|
915
920
|
note(ev, ev.txid, "fill", false, "taker-bound offer");
|
|
916
921
|
continue;
|
|
917
922
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
}
|
|
923
|
-
if (!(claimHeld(o, ev.height) && who === o.claimedBy)) {
|
|
924
|
-
note(ev, ev.txid, "fill", false, "v1.7: open offer \u2014 claim it first (no live claim by you)");
|
|
925
|
-
continue;
|
|
926
|
-
}
|
|
923
|
+
const blk = openFillReject(o, ev.height, who);
|
|
924
|
+
if (blk) {
|
|
925
|
+
note(ev, ev.txid, "fill", false, blk);
|
|
926
|
+
continue;
|
|
927
927
|
}
|
|
928
928
|
const pt = ev.paidTo ?? {};
|
|
929
929
|
const want = BigInt(o.want.value);
|
|
@@ -951,26 +951,14 @@ function resolve(events, tipHeight) {
|
|
|
951
951
|
note(ev, ev.txid, "fill", false, "name vanished (consensus violation)");
|
|
952
952
|
continue;
|
|
953
953
|
}
|
|
954
|
-
n
|
|
955
|
-
n.locked = false;
|
|
956
|
-
n.addr = void 0;
|
|
957
|
-
n.profile = void 0;
|
|
958
|
-
if (ev.height >= V13_HEIGHT) {
|
|
959
|
-
n.effHeight = ev.height;
|
|
960
|
-
n.pos = ev.pos;
|
|
961
|
-
n.id = ev.txid;
|
|
962
|
-
n.height = ev.height;
|
|
963
|
-
n.viaFill = true;
|
|
964
|
-
}
|
|
954
|
+
deliverNameToBuyer(n, who, ev);
|
|
965
955
|
} else {
|
|
966
956
|
const amt = offerLock.get(o.id);
|
|
967
957
|
if (amt === void 0) {
|
|
968
958
|
note(ev, ev.txid, "fill", false, "offer lock missing");
|
|
969
959
|
continue;
|
|
970
960
|
}
|
|
971
|
-
|
|
972
|
-
bal(o.give.ticker, who).available += amt;
|
|
973
|
-
offerLock.delete(o.id);
|
|
961
|
+
releaseGiveLock(o, who, amt);
|
|
974
962
|
}
|
|
975
963
|
feesPaid += fee;
|
|
976
964
|
o.status = "filled";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inversealtruism/cairnx-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "CairnX — tokens, atomic DvP trades and leased .csd names on Compute Substrate, as a pure deterministic convention library (Ordinals/Runes class). Ships the normative CONVENTION.md and the conformance vectors.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|