@inversealtruism/cairnx-core 0.1.44 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/dist/index.cjs +4 -19
- package/dist/index.d.cts +20 -14
- package/dist/index.d.ts +20 -14
- package/dist/index.js +5 -20
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
Breaking for callers that hand-build `ProvenOfferTerms` or rely on the old two-argument verdict; see Migration.
|
|
6
|
+
|
|
7
|
+
- `bindOfferTerms` checks the give and wantType legs by default. A served offer whose `give` (ticker, amount
|
|
8
|
+
or name) or want type differs from the merkle-proven offer now counts as a mismatch with the two-argument
|
|
9
|
+
call too. To opt out, pass `{ give: false, wantType: false }`: that returns the 0.1.44 two-argument verdict
|
|
10
|
+
on every input. Opting out of one leg leaves the other on.
|
|
11
|
+
- Type change: with a leg on, the terms must come from `provenOfferTerms` or `bindProvenOffer` (the
|
|
12
|
+
`MintedProvenOfferTerms` brand). A hand-built `ProvenOfferTerms` compiles only with both legs off (the new
|
|
13
|
+
`LegacyBindOpts` type). At runtime, hand-built terms passed without the opt-out lack the give and wantType
|
|
14
|
+
fields and are refused (the predicate returns `true`).
|
|
15
|
+
- Callers that already pass `{ give: true, wantType: true }` with minted terms get the same verdicts as before.
|
|
16
|
+
- Depends on csd-codec 0.1.18 (reject-more input canon, see `CONSENSUS_CHANGES.md`); `records.ts` imports
|
|
17
|
+
the codec's well-formed UTF-16 predicate instead of its own copy, with the same verdicts.
|
|
18
|
+
- `resolve()` and canonical state are byte-identical to 0.1.44.
|
|
19
|
+
|
|
20
|
+
Migration. Callers that already pass `{ give: true, wantType: true }` with minted terms need no change (the
|
|
21
|
+
site's `swapguard.js`, the wallet's `wallet.ts` and cairn-sdk's `fillverify.ts` production path). These move
|
|
22
|
+
together with the 0.2.0 pin:
|
|
23
|
+
- cairn-sdk `test/fillverify.test.ts`: the two-argument assertions on hand-built terms expect the old default
|
|
24
|
+
(the inflated give passing); pass `{ give: false, wantType: false }` there or expect the refusal.
|
|
25
|
+
- cairn-sdk `src/fillverify.ts`: the result's `terms` field is typed `ProvenOfferTerms`, which drops the mint
|
|
26
|
+
brand, so a dApp passing it back to `bindOfferTerms` without the opt-out no longer compiles; type it
|
|
27
|
+
`MintedProvenOfferTerms`.
|
|
28
|
+
- cairn `test/b7a-flip.test.mjs`: its two-argument call asserts the give leg is off; it now refuses.
|
|
29
|
+
- cairn-wallet `src/vendor/cairnx-spv.js` and `cairnx-spv.d.ts`: the vendored bundle keeps the 0.1.x
|
|
30
|
+
contract (legs opt-in) until it is re-vendored from 0.2.0.
|
|
31
|
+
|
|
32
|
+
## 0.1.44
|
|
33
|
+
|
|
34
|
+
- `rfqFillAllIn(n, feeBps?)` (`cairnx-core/mm`) takes the offer's fee rate; omitted or null keeps
|
|
35
|
+
`FEE_BPS_V16`, so every existing one-argument call returns the same number.
|
|
36
|
+
- `epochOf` now lives in `csd-codec` next to `EPOCH_LEN` and is re-exported from the root unchanged.
|
|
37
|
+
- New root exports, none read by `resolve()`: `ptAmt` (the resolver's own paidTo amount reader),
|
|
38
|
+
`burnedPayment` (what a refused record paid to the treasury, and for a fill to the offer's seller and payto,
|
|
39
|
+
never counting the payer) and `myProvenFillClosedOffer` (whether a buyer's own merkle-proven full fill closed
|
|
40
|
+
the offer behind one of its fclaim holds, for the V29 cross-offer hold count).
|
|
41
|
+
- `resolve()` and canonical state are byte-identical to 0.1.43.
|
|
42
|
+
|
|
43
|
+
## 0.1.43
|
|
44
|
+
|
|
45
|
+
- New subpath `@inversealtruism/cairnx-core/mm` (ESM and CJS, built to `dist/mm/`). The root export, the
|
|
46
|
+
resolver and every consensus file are unchanged; `dist/index.*` is byte-identical to 0.1.42.
|
|
47
|
+
- `mm` holds the market maker's non-consensus math in one place for the maker service and the site:
|
|
48
|
+
`sizeBid`, `acceptBid`, `tierFor` (bid sizing against the indicative ladder), `tradeNotional` (contractual
|
|
49
|
+
volume of a fill), `expScaled`, `sunriseTimeMult` and `sunriseCurve` (the Sunrise spot curve), and the
|
|
50
|
+
RFQ all-in sums `rfqBuyAllIn` and `rfqFillAllIn`, and `priorBuyers` (the returning-buyer rule: buyers of fills
|
|
51
|
+
of offers the maker sold) (built from `tradeFee`, `makerRebate`, `FEE_BPS_V16` and the
|
|
52
|
+
codec's minimum fees).
|
|
53
|
+
- New Sunrise order pricing: `sunriseOrderCost` is the integral of the spot curve over an order, rounded up;
|
|
54
|
+
`sunriseAnswerPrice` adds a flat margin and a per-token floor; `sunriseTokensFor` inverts it for a budget.
|
|
55
|
+
`expm1Scaled` is the fixed-point e^z - 1 behind it (scale 1e18).
|
package/dist/index.cjs
CHANGED
|
@@ -302,27 +302,12 @@ var isName = (n) => typeof n === "string" && NAME_RE.test(n) && !RESERVED_NAMES.
|
|
|
302
302
|
function nameCommit(name, salt, owner) {
|
|
303
303
|
return (0, import_csd_codec2.payloadHash)({ t: "cairnx:name:commit:v1", name, salt, owner: owner.toLowerCase() });
|
|
304
304
|
}
|
|
305
|
-
function strWellFormed(s) {
|
|
306
|
-
const wf = String.prototype.isWellFormed;
|
|
307
|
-
if (typeof wf === "function") return wf.call(s);
|
|
308
|
-
for (let i = 0; i < s.length; i++) {
|
|
309
|
-
const c = s.charCodeAt(i);
|
|
310
|
-
if (c >= 55296 && c <= 56319) {
|
|
311
|
-
const n = s.charCodeAt(i + 1);
|
|
312
|
-
if (!(n >= 56320 && n <= 57343)) return false;
|
|
313
|
-
i++;
|
|
314
|
-
} else if (c >= 56320 && c <= 57343) {
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
305
|
function isWellFormedDeep(v) {
|
|
321
|
-
if (typeof v === "string") return
|
|
306
|
+
if (typeof v === "string") return (0, import_csd_codec2.isWellFormedUtf16)(v);
|
|
322
307
|
if (Array.isArray(v)) return v.every(isWellFormedDeep);
|
|
323
308
|
if (v && typeof v === "object") {
|
|
324
309
|
for (const [k, val] of Object.entries(v)) {
|
|
325
|
-
if (!
|
|
310
|
+
if (!(0, import_csd_codec2.isWellFormedUtf16)(k)) return false;
|
|
326
311
|
if (!isWellFormedDeep(val)) return false;
|
|
327
312
|
}
|
|
328
313
|
}
|
|
@@ -1884,10 +1869,10 @@ function bindOfferTerms(servedOffer, t, opts) {
|
|
|
1884
1869
|
const om = o?.min;
|
|
1885
1870
|
if ((om !== void 0 && om !== null) !== (t.min !== void 0)) return true;
|
|
1886
1871
|
if (t.min !== void 0 && String(om) !== t.min) return true;
|
|
1887
|
-
if (opts?.wantType) {
|
|
1872
|
+
if (opts?.wantType !== false) {
|
|
1888
1873
|
if (t.wantType === void 0 || typeof o?.want?.ticker === "string" !== (t.wantType === "token")) return true;
|
|
1889
1874
|
}
|
|
1890
|
-
if (opts?.give) {
|
|
1875
|
+
if (opts?.give !== false) {
|
|
1891
1876
|
const g = o?.give;
|
|
1892
1877
|
if ((g?.ticker !== void 0 && g?.ticker !== null) !== (t.giveTicker !== void 0) || t.giveTicker !== void 0 && String(g?.ticker) !== t.giveTicker) return true;
|
|
1893
1878
|
if ((g?.amount !== void 0 && g?.amount !== null) !== (t.giveAmount !== void 0) || t.giveAmount !== void 0 && String(g?.amount) !== t.giveAmount) return true;
|
package/dist/index.d.cts
CHANGED
|
@@ -741,24 +741,30 @@ declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number):
|
|
|
741
741
|
* `value` is bound only when `t.value` is defined so a token<->token offer (no CSD value) is not spuriously
|
|
742
742
|
* refused; a caller that binds want.value separately (the site does) may still pass it here (redundant-safe).
|
|
743
743
|
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
744
|
+
* The give and wantType legs (REBIND W2 legs + W7) are ON by default. Their third-argument switches opt out
|
|
745
|
+
* explicitly (`false`); omitted or `undefined` keeps a leg on. With a leg on the terms must be MINTED (the
|
|
746
|
+
* brand), because a hand-built terms object leaves the give/wantType fields undefined and would refuse every
|
|
747
|
+
* honest fill (the W2 trap this file documents). A plain ProvenOfferTerms is accepted only with both legs
|
|
748
|
+
* off, which is the pre-B6 predicate exactly (`scripts/seal-differential.mjs` step 5).
|
|
749
|
+
* give - bind give.ticker / give.amount / give.name: EXPLICIT PRESENCE (a served give growing or
|
|
750
|
+
* losing a field mismatches) AND verbatim string equality. Closes the W7 shortchange (a
|
|
751
|
+
* genuine offer served with give.amount inflated a millionfold passes every other leg).
|
|
752
|
+
* wantType - the SYMMETRIC want-type refusal: the served offer's want type (token iff want.ticker is
|
|
753
|
+
* a string, the isTokenWant pivot) must equal the proven type. The value leg already
|
|
754
|
+
* catches proven-CSD-served-as-token (String(undefined) mismatches t.value); this closes
|
|
755
|
+
* the reverse, proven-token-served-as-CSD.
|
|
755
756
|
*/
|
|
756
757
|
interface BindTermsOpts {
|
|
757
758
|
give?: boolean;
|
|
758
759
|
wantType?: boolean;
|
|
759
760
|
}
|
|
760
|
-
|
|
761
|
-
|
|
761
|
+
/** Both legs off: the pre-B6 verdict, for callers that hold hand-built (unminted) terms. */
|
|
762
|
+
type LegacyBindOpts = {
|
|
763
|
+
give: false;
|
|
764
|
+
wantType: false;
|
|
765
|
+
};
|
|
766
|
+
declare function bindOfferTerms(servedOffer: unknown, t: MintedProvenOfferTerms, opts?: BindTermsOpts): boolean;
|
|
767
|
+
declare function bindOfferTerms(servedOffer: unknown, t: ProvenOfferTerms, opts: LegacyBindOpts): boolean;
|
|
762
768
|
declare function bindProvenOffer(offerEv: ProvenPropose): {
|
|
763
769
|
payto: string;
|
|
764
770
|
seller: string;
|
|
@@ -792,4 +798,4 @@ declare function myProvenFillClosedOffer(fill: ProvenEvent | null, fclaim: {
|
|
|
792
798
|
offer: string;
|
|
793
799
|
}, offerEv: ProvenEvent | null, me: string, grantHeight: number): boolean;
|
|
794
800
|
|
|
795
|
-
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, burnedPayment, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, myProvenFillClosedOffer, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, ptAmt, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|
|
801
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, type LegacyBindOpts, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, burnedPayment, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, myProvenFillClosedOffer, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, ptAmt, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|
package/dist/index.d.ts
CHANGED
|
@@ -741,24 +741,30 @@ declare function provenOfferTerms(offerRec: OfferRecord, provenHeight: number):
|
|
|
741
741
|
* `value` is bound only when `t.value` is defined so a token<->token offer (no CSD value) is not spuriously
|
|
742
742
|
* refused; a caller that binds want.value separately (the site does) may still pass it here (redundant-safe).
|
|
743
743
|
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
744
|
+
* The give and wantType legs (REBIND W2 legs + W7) are ON by default. Their third-argument switches opt out
|
|
745
|
+
* explicitly (`false`); omitted or `undefined` keeps a leg on. With a leg on the terms must be MINTED (the
|
|
746
|
+
* brand), because a hand-built terms object leaves the give/wantType fields undefined and would refuse every
|
|
747
|
+
* honest fill (the W2 trap this file documents). A plain ProvenOfferTerms is accepted only with both legs
|
|
748
|
+
* off, which is the pre-B6 predicate exactly (`scripts/seal-differential.mjs` step 5).
|
|
749
|
+
* give - bind give.ticker / give.amount / give.name: EXPLICIT PRESENCE (a served give growing or
|
|
750
|
+
* losing a field mismatches) AND verbatim string equality. Closes the W7 shortchange (a
|
|
751
|
+
* genuine offer served with give.amount inflated a millionfold passes every other leg).
|
|
752
|
+
* wantType - the SYMMETRIC want-type refusal: the served offer's want type (token iff want.ticker is
|
|
753
|
+
* a string, the isTokenWant pivot) must equal the proven type. The value leg already
|
|
754
|
+
* catches proven-CSD-served-as-token (String(undefined) mismatches t.value); this closes
|
|
755
|
+
* the reverse, proven-token-served-as-CSD.
|
|
755
756
|
*/
|
|
756
757
|
interface BindTermsOpts {
|
|
757
758
|
give?: boolean;
|
|
758
759
|
wantType?: boolean;
|
|
759
760
|
}
|
|
760
|
-
|
|
761
|
-
|
|
761
|
+
/** Both legs off: the pre-B6 verdict, for callers that hold hand-built (unminted) terms. */
|
|
762
|
+
type LegacyBindOpts = {
|
|
763
|
+
give: false;
|
|
764
|
+
wantType: false;
|
|
765
|
+
};
|
|
766
|
+
declare function bindOfferTerms(servedOffer: unknown, t: MintedProvenOfferTerms, opts?: BindTermsOpts): boolean;
|
|
767
|
+
declare function bindOfferTerms(servedOffer: unknown, t: ProvenOfferTerms, opts: LegacyBindOpts): boolean;
|
|
762
768
|
declare function bindProvenOffer(offerEv: ProvenPropose): {
|
|
763
769
|
payto: string;
|
|
764
770
|
seller: string;
|
|
@@ -792,4 +798,4 @@ declare function myProvenFillClosedOffer(fill: ProvenEvent | null, fclaim: {
|
|
|
792
798
|
offer: string;
|
|
793
799
|
}, offerEv: ProvenEvent | null, me: string, grantHeight: number): boolean;
|
|
794
800
|
|
|
795
|
-
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, burnedPayment, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, myProvenFillClosedOffer, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, ptAmt, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|
|
801
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, type LegacyBindOpts, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, burnedPayment, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, myProvenFillClosedOffer, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, ptAmt, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|
package/dist/index.js
CHANGED
|
@@ -111,7 +111,7 @@ var isNameGive = (g) => typeof g.name === "string";
|
|
|
111
111
|
var isTokenWant = (w) => typeof w.ticker === "string";
|
|
112
112
|
|
|
113
113
|
// src/records.ts
|
|
114
|
-
import { canonicalJson, payloadHash } from "@inversealtruism/csd-codec";
|
|
114
|
+
import { canonicalJson, payloadHash, isWellFormedUtf16 } from "@inversealtruism/csd-codec";
|
|
115
115
|
function parseAmount(s, opts = {}) {
|
|
116
116
|
if (typeof s !== "string" || !AMOUNT_RE.test(s)) return null;
|
|
117
117
|
const v = BigInt(s);
|
|
@@ -126,27 +126,12 @@ var isName = (n) => typeof n === "string" && NAME_RE.test(n) && !RESERVED_NAMES.
|
|
|
126
126
|
function nameCommit(name, salt, owner) {
|
|
127
127
|
return payloadHash({ t: "cairnx:name:commit:v1", name, salt, owner: owner.toLowerCase() });
|
|
128
128
|
}
|
|
129
|
-
function strWellFormed(s) {
|
|
130
|
-
const wf = String.prototype.isWellFormed;
|
|
131
|
-
if (typeof wf === "function") return wf.call(s);
|
|
132
|
-
for (let i = 0; i < s.length; i++) {
|
|
133
|
-
const c = s.charCodeAt(i);
|
|
134
|
-
if (c >= 55296 && c <= 56319) {
|
|
135
|
-
const n = s.charCodeAt(i + 1);
|
|
136
|
-
if (!(n >= 56320 && n <= 57343)) return false;
|
|
137
|
-
i++;
|
|
138
|
-
} else if (c >= 56320 && c <= 57343) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
129
|
function isWellFormedDeep(v) {
|
|
145
|
-
if (typeof v === "string") return
|
|
130
|
+
if (typeof v === "string") return isWellFormedUtf16(v);
|
|
146
131
|
if (Array.isArray(v)) return v.every(isWellFormedDeep);
|
|
147
132
|
if (v && typeof v === "object") {
|
|
148
133
|
for (const [k, val] of Object.entries(v)) {
|
|
149
|
-
if (!
|
|
134
|
+
if (!isWellFormedUtf16(k)) return false;
|
|
150
135
|
if (!isWellFormedDeep(val)) return false;
|
|
151
136
|
}
|
|
152
137
|
}
|
|
@@ -1708,10 +1693,10 @@ function bindOfferTerms(servedOffer, t, opts) {
|
|
|
1708
1693
|
const om = o?.min;
|
|
1709
1694
|
if ((om !== void 0 && om !== null) !== (t.min !== void 0)) return true;
|
|
1710
1695
|
if (t.min !== void 0 && String(om) !== t.min) return true;
|
|
1711
|
-
if (opts?.wantType) {
|
|
1696
|
+
if (opts?.wantType !== false) {
|
|
1712
1697
|
if (t.wantType === void 0 || typeof o?.want?.ticker === "string" !== (t.wantType === "token")) return true;
|
|
1713
1698
|
}
|
|
1714
|
-
if (opts?.give) {
|
|
1699
|
+
if (opts?.give !== false) {
|
|
1715
1700
|
const g = o?.give;
|
|
1716
1701
|
if ((g?.ticker !== void 0 && g?.ticker !== null) !== (t.giveTicker !== void 0) || t.giveTicker !== void 0 && String(g?.ticker) !== t.giveTicker) return true;
|
|
1717
1702
|
if ((g?.amount !== void 0 && g?.amount !== null) !== (t.giveAmount !== void 0) || t.giveAmount !== void 0 && String(g?.amount) !== t.giveAmount) return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inversealtruism/cairnx-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18"
|
|
6
6
|
},
|
|
@@ -35,12 +35,13 @@
|
|
|
35
35
|
"dist",
|
|
36
36
|
"LICENSE",
|
|
37
37
|
"README.md",
|
|
38
|
+
"CHANGELOG.md",
|
|
38
39
|
"CONVENTION.md",
|
|
39
40
|
"MAKERS.md",
|
|
40
41
|
"test/vectors"
|
|
41
42
|
],
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@inversealtruism/csd-codec": "0.1.
|
|
44
|
+
"@inversealtruism/csd-codec": "0.1.18"
|
|
44
45
|
},
|
|
45
46
|
"license": "MIT",
|
|
46
47
|
"sideEffects": false,
|