@inversealtruism/cairnx-core 0.1.15 → 0.1.17
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/dist/index.cjs +17 -2
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
HASH_RE: () => HASH_RE,
|
|
38
38
|
MAX_ACTIVE_CLAIMS: () => MAX_ACTIVE_CLAIMS,
|
|
39
39
|
MAX_AMOUNT: () => MAX_AMOUNT,
|
|
40
|
+
MAX_OFFER_EPOCHS: () => MAX_OFFER_EPOCHS,
|
|
40
41
|
MAX_RECORD_BYTES: () => MAX_RECORD_BYTES,
|
|
41
42
|
NAME_FEE_SHORT_V18: () => NAME_FEE_SHORT_V18,
|
|
42
43
|
NAME_FEE_V18: () => NAME_FEE_V18,
|
|
@@ -67,6 +68,7 @@ __export(index_exports, {
|
|
|
67
68
|
V18_HEIGHT: () => V18_HEIGHT,
|
|
68
69
|
V19_HEIGHT: () => V19_HEIGHT,
|
|
69
70
|
V20_HEIGHT: () => V20_HEIGHT,
|
|
71
|
+
V21_HEIGHT: () => V21_HEIGHT,
|
|
70
72
|
bid: () => bid,
|
|
71
73
|
buildRecord: () => buildRecord,
|
|
72
74
|
canonicalState: () => canonicalState,
|
|
@@ -141,6 +143,8 @@ var NAME_FEE_SHORT_V18 = 670000000n;
|
|
|
141
143
|
var NAME_FEE_V18 = 300000000n;
|
|
142
144
|
var V19_HEIGHT = 36700;
|
|
143
145
|
var V20_HEIGHT = 38400;
|
|
146
|
+
var V21_HEIGHT = 40100;
|
|
147
|
+
var MAX_OFFER_EPOCHS = 168;
|
|
144
148
|
var PKEY = /^[a-z0-9](?:[a-z0-9.-]{0,30}[a-z0-9])?$/;
|
|
145
149
|
var PROFILE_MAX_KEYS = 16;
|
|
146
150
|
var PROFILE_MAX_VALUE_BYTES = 256;
|
|
@@ -438,16 +442,17 @@ function resolve(events, tipHeight) {
|
|
|
438
442
|
b.available += amt;
|
|
439
443
|
}
|
|
440
444
|
};
|
|
445
|
+
const effExpiry = (e, height) => height >= V21_HEIGHT ? Math.min(e.expiresEpoch, epochOf(e.height) + MAX_OFFER_EPOCHS) : e.expiresEpoch;
|
|
441
446
|
const sweepExpired = (height) => {
|
|
442
447
|
const ep = epochOf(height);
|
|
443
448
|
for (const o of offers.values()) {
|
|
444
|
-
if (o.status === "open" && ep > o
|
|
449
|
+
if (o.status === "open" && ep > effExpiry(o, height)) {
|
|
445
450
|
releaseGive(o);
|
|
446
451
|
o.status = "expired";
|
|
447
452
|
}
|
|
448
453
|
}
|
|
449
454
|
for (const b of bids.values()) {
|
|
450
|
-
if (b.status === "open" && ep > b
|
|
455
|
+
if (b.status === "open" && ep > effExpiry(b, height)) b.status = "expired";
|
|
451
456
|
}
|
|
452
457
|
};
|
|
453
458
|
const V15_EPOCH = epochOf(V15_HEIGHT);
|
|
@@ -682,6 +687,10 @@ function resolve(events, tipHeight) {
|
|
|
682
687
|
note(ev, ev.id, "offer", false, "already expired at anchor");
|
|
683
688
|
continue;
|
|
684
689
|
}
|
|
690
|
+
if (ev.height >= V21_HEIGHT && ev.expiresEpoch - epochOf(ev.height) > MAX_OFFER_EPOCHS) {
|
|
691
|
+
note(ev, ev.id, "offer", false, "v2.1: offer duration exceeds the max");
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
685
694
|
const give = rec.give;
|
|
686
695
|
if (isNameGive(give)) {
|
|
687
696
|
if (!v11) {
|
|
@@ -751,6 +760,10 @@ function resolve(events, tipHeight) {
|
|
|
751
760
|
note(ev, ev.id, "bid", false, "already expired at anchor");
|
|
752
761
|
continue;
|
|
753
762
|
}
|
|
763
|
+
if (ev.height >= V21_HEIGHT && ev.expiresEpoch - epochOf(ev.height) > MAX_OFFER_EPOCHS) {
|
|
764
|
+
note(ev, ev.id, "bid", false, "v2.1: bid duration exceeds the max");
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
754
767
|
bids.set(ev.id, {
|
|
755
768
|
id: ev.id,
|
|
756
769
|
bidder: who,
|
|
@@ -1168,6 +1181,7 @@ function canonicalState(s) {
|
|
|
1168
1181
|
HASH_RE,
|
|
1169
1182
|
MAX_ACTIVE_CLAIMS,
|
|
1170
1183
|
MAX_AMOUNT,
|
|
1184
|
+
MAX_OFFER_EPOCHS,
|
|
1171
1185
|
MAX_RECORD_BYTES,
|
|
1172
1186
|
NAME_FEE_SHORT_V18,
|
|
1173
1187
|
NAME_FEE_V18,
|
|
@@ -1198,6 +1212,7 @@ function canonicalState(s) {
|
|
|
1198
1212
|
V18_HEIGHT,
|
|
1199
1213
|
V19_HEIGHT,
|
|
1200
1214
|
V20_HEIGHT,
|
|
1215
|
+
V21_HEIGHT,
|
|
1201
1216
|
bid,
|
|
1202
1217
|
buildRecord,
|
|
1203
1218
|
canonicalState,
|
package/dist/index.d.cts
CHANGED
|
@@ -39,6 +39,8 @@ 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 = 40100;
|
|
43
|
+
declare const MAX_OFFER_EPOCHS = 168;
|
|
42
44
|
declare const PKEY: RegExp;
|
|
43
45
|
declare const PROFILE_MAX_KEYS = 16;
|
|
44
46
|
declare const PROFILE_MAX_VALUE_BYTES = 256;
|
|
@@ -360,4 +362,4 @@ declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
|
360
362
|
* history.) Keys sort in ordinal (code-unit) order at every depth. */
|
|
361
363
|
declare function canonicalState(s: CairnXState): string;
|
|
362
364
|
|
|
363
|
-
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_RECORD_BYTES, type MintRecord, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, type NameCommitRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SALT_RE, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, 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, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
|
|
365
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_RECORD_BYTES, type MintRecord, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, type NameCommitRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SALT_RE, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, 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, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ 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 = 40100;
|
|
43
|
+
declare const MAX_OFFER_EPOCHS = 168;
|
|
42
44
|
declare const PKEY: RegExp;
|
|
43
45
|
declare const PROFILE_MAX_KEYS = 16;
|
|
44
46
|
declare const PROFILE_MAX_VALUE_BYTES = 256;
|
|
@@ -360,4 +362,4 @@ declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
|
360
362
|
* history.) Keys sort in ordinal (code-unit) order at every depth. */
|
|
361
363
|
declare function canonicalState(s: CairnXState): string;
|
|
362
364
|
|
|
363
|
-
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_RECORD_BYTES, type MintRecord, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, type NameCommitRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SALT_RE, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, 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, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
|
|
365
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, type BalanceState, type BidRecord, type BidState, type BidStatus, type BuiltRecord, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord, FEE_BPS, FEE_BPS_V16, type FillEntry, type Give, HASH_RE, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_RECORD_BYTES, type MintRecord, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, type NameCommitRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, REBATE_BPS, REBATE_FLAT, RESERVED_NAMES, SALT_RE, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, 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, type Want, bid, buildRecord, canonicalState, deploy, epochOf, expiredClaimFee, isName, isNameGive, isTokenWant, makerRebate, mint, nameClaim, nameCommit, nameCommitRecord, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, parseAmount, parseRecord, resolve, tokenMeta, tradeFee, transfer };
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,8 @@ 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 = 40100;
|
|
46
|
+
var MAX_OFFER_EPOCHS = 168;
|
|
45
47
|
var PKEY = /^[a-z0-9](?:[a-z0-9.-]{0,30}[a-z0-9])?$/;
|
|
46
48
|
var PROFILE_MAX_KEYS = 16;
|
|
47
49
|
var PROFILE_MAX_VALUE_BYTES = 256;
|
|
@@ -339,16 +341,17 @@ function resolve(events, tipHeight) {
|
|
|
339
341
|
b.available += amt;
|
|
340
342
|
}
|
|
341
343
|
};
|
|
344
|
+
const effExpiry = (e, height) => height >= V21_HEIGHT ? Math.min(e.expiresEpoch, epochOf(e.height) + MAX_OFFER_EPOCHS) : e.expiresEpoch;
|
|
342
345
|
const sweepExpired = (height) => {
|
|
343
346
|
const ep = epochOf(height);
|
|
344
347
|
for (const o of offers.values()) {
|
|
345
|
-
if (o.status === "open" && ep > o
|
|
348
|
+
if (o.status === "open" && ep > effExpiry(o, height)) {
|
|
346
349
|
releaseGive(o);
|
|
347
350
|
o.status = "expired";
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
353
|
for (const b of bids.values()) {
|
|
351
|
-
if (b.status === "open" && ep > b
|
|
354
|
+
if (b.status === "open" && ep > effExpiry(b, height)) b.status = "expired";
|
|
352
355
|
}
|
|
353
356
|
};
|
|
354
357
|
const V15_EPOCH = epochOf(V15_HEIGHT);
|
|
@@ -583,6 +586,10 @@ function resolve(events, tipHeight) {
|
|
|
583
586
|
note(ev, ev.id, "offer", false, "already expired at anchor");
|
|
584
587
|
continue;
|
|
585
588
|
}
|
|
589
|
+
if (ev.height >= V21_HEIGHT && ev.expiresEpoch - epochOf(ev.height) > MAX_OFFER_EPOCHS) {
|
|
590
|
+
note(ev, ev.id, "offer", false, "v2.1: offer duration exceeds the max");
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
586
593
|
const give = rec.give;
|
|
587
594
|
if (isNameGive(give)) {
|
|
588
595
|
if (!v11) {
|
|
@@ -652,6 +659,10 @@ function resolve(events, tipHeight) {
|
|
|
652
659
|
note(ev, ev.id, "bid", false, "already expired at anchor");
|
|
653
660
|
continue;
|
|
654
661
|
}
|
|
662
|
+
if (ev.height >= V21_HEIGHT && ev.expiresEpoch - epochOf(ev.height) > MAX_OFFER_EPOCHS) {
|
|
663
|
+
note(ev, ev.id, "bid", false, "v2.1: bid duration exceeds the max");
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
655
666
|
bids.set(ev.id, {
|
|
656
667
|
id: ev.id,
|
|
657
668
|
bidder: who,
|
|
@@ -1068,6 +1079,7 @@ export {
|
|
|
1068
1079
|
HASH_RE,
|
|
1069
1080
|
MAX_ACTIVE_CLAIMS,
|
|
1070
1081
|
MAX_AMOUNT,
|
|
1082
|
+
MAX_OFFER_EPOCHS,
|
|
1071
1083
|
MAX_RECORD_BYTES,
|
|
1072
1084
|
NAME_FEE_SHORT_V18,
|
|
1073
1085
|
NAME_FEE_V18,
|
|
@@ -1098,6 +1110,7 @@ export {
|
|
|
1098
1110
|
V18_HEIGHT,
|
|
1099
1111
|
V19_HEIGHT,
|
|
1100
1112
|
V20_HEIGHT,
|
|
1113
|
+
V21_HEIGHT,
|
|
1101
1114
|
bid,
|
|
1102
1115
|
buildRecord,
|
|
1103
1116
|
canonicalState,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inversealtruism/cairnx-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
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",
|