@inversealtruism/cairnx-core 0.1.12 → 0.1.14
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 +15 -12
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -29,7 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
CONF_TOKEN_FILL: () => CONF_TOKEN_FILL,
|
|
30
30
|
DEPLOY_FEE: () => DEPLOY_FEE,
|
|
31
31
|
DOMAIN: () => DOMAIN,
|
|
32
|
-
EPOCH_LEN: () => EPOCH_LEN,
|
|
32
|
+
EPOCH_LEN: () => import_csd_codec.EPOCH_LEN,
|
|
33
33
|
FEE_BPS: () => FEE_BPS,
|
|
34
34
|
FEE_BPS_V16: () => FEE_BPS_V16,
|
|
35
35
|
HASH_RE: () => HASH_RE,
|
|
@@ -49,6 +49,7 @@ __export(index_exports, {
|
|
|
49
49
|
REBATE_BPS: () => REBATE_BPS,
|
|
50
50
|
REBATE_FLAT: () => REBATE_FLAT,
|
|
51
51
|
RESERVED_NAMES: () => RESERVED_NAMES,
|
|
52
|
+
SALT_RE: () => SALT_RE,
|
|
52
53
|
SCORE_CANCEL: () => SCORE_CANCEL,
|
|
53
54
|
SCORE_CLAIM: () => SCORE_CLAIM,
|
|
54
55
|
SCORE_FILL: () => SCORE_FILL,
|
|
@@ -94,6 +95,7 @@ __export(index_exports, {
|
|
|
94
95
|
module.exports = __toCommonJS(index_exports);
|
|
95
96
|
|
|
96
97
|
// src/types.ts
|
|
98
|
+
var import_csd_codec = require("@inversealtruism/csd-codec");
|
|
97
99
|
var DOMAIN = "cairnx:v1";
|
|
98
100
|
var ACTIVATION_HEIGHT = 29860;
|
|
99
101
|
var V11_HEIGHT = 29960;
|
|
@@ -103,7 +105,6 @@ var V14_HEIGHT = 31400;
|
|
|
103
105
|
var V15_HEIGHT = 32e3;
|
|
104
106
|
var V16_HEIGHT = 33600;
|
|
105
107
|
var V17_HEIGHT = 34e3;
|
|
106
|
-
var EPOCH_LEN = 30;
|
|
107
108
|
var NAME_TERM_EPOCHS = 8760;
|
|
108
109
|
var NAME_GRACE_EPOCHS = 720;
|
|
109
110
|
var NAME_PREMIUM_START = 20n;
|
|
@@ -153,14 +154,15 @@ var ADDR_RE = /^0x[0-9a-f]{40}$/;
|
|
|
153
154
|
var AMOUNT_RE = /^(0|[1-9][0-9]*)$/;
|
|
154
155
|
var NAME_RE = /^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
|
|
155
156
|
var HASH_RE = /^0x[0-9a-f]{64}$/;
|
|
157
|
+
var SALT_RE = /^[0-9a-fA-F]{16,128}$/;
|
|
156
158
|
var RESERVED_NAMES = /* @__PURE__ */ new Set(["csd", "treasury", "admin", "official", "root", "www", "support"]);
|
|
157
|
-
var COMMIT_MAX_BLOCKS = 8 * EPOCH_LEN;
|
|
158
|
-
var epochOf = (height) => Math.floor(height / EPOCH_LEN);
|
|
159
|
+
var COMMIT_MAX_BLOCKS = 8 * import_csd_codec.EPOCH_LEN;
|
|
160
|
+
var epochOf = (height) => Math.floor(height / import_csd_codec.EPOCH_LEN);
|
|
159
161
|
var isNameGive = (g) => typeof g.name === "string";
|
|
160
162
|
var isTokenWant = (w) => typeof w.ticker === "string";
|
|
161
163
|
|
|
162
164
|
// src/records.ts
|
|
163
|
-
var
|
|
165
|
+
var import_csd_codec2 = require("@inversealtruism/csd-codec");
|
|
164
166
|
function parseAmount(s, opts = {}) {
|
|
165
167
|
if (typeof s !== "string" || !AMOUNT_RE.test(s)) return null;
|
|
166
168
|
const v = BigInt(s);
|
|
@@ -173,7 +175,7 @@ var isTicker = (t) => typeof t === "string" && TICKER_RE.test(t);
|
|
|
173
175
|
var isHash = (h) => typeof h === "string" && HASH_RE.test(h);
|
|
174
176
|
var isName = (n) => typeof n === "string" && NAME_RE.test(n) && !RESERVED_NAMES.has(n);
|
|
175
177
|
function nameCommit(name, salt, owner) {
|
|
176
|
-
return (0,
|
|
178
|
+
return (0, import_csd_codec2.payloadHash)({ t: "cairnx:name:commit:v1", name, salt, owner: owner.toLowerCase() });
|
|
177
179
|
}
|
|
178
180
|
function strWellFormed(s) {
|
|
179
181
|
const wf = String.prototype.isWellFormed;
|
|
@@ -219,8 +221,8 @@ function parseRecord(uri, payloadHashHex) {
|
|
|
219
221
|
}
|
|
220
222
|
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return null;
|
|
221
223
|
try {
|
|
222
|
-
if ((0,
|
|
223
|
-
if ((0,
|
|
224
|
+
if ((0, import_csd_codec2.canonicalJson)(obj) !== uri) return null;
|
|
225
|
+
if ((0, import_csd_codec2.payloadHash)(obj).toLowerCase() !== payloadHashHex.toLowerCase()) return null;
|
|
224
226
|
} catch {
|
|
225
227
|
return null;
|
|
226
228
|
}
|
|
@@ -316,7 +318,7 @@ function parseRecord(uri, payloadHashHex) {
|
|
|
316
318
|
case "name": {
|
|
317
319
|
if (!onlyKeys(r, NAME_KEYS)) return null;
|
|
318
320
|
if (!isName(r.name)) return null;
|
|
319
|
-
if (r.salt !== void 0 && (typeof r.salt !== "string" ||
|
|
321
|
+
if (r.salt !== void 0 && (typeof r.salt !== "string" || !SALT_RE.test(r.salt))) return null;
|
|
320
322
|
return r;
|
|
321
323
|
}
|
|
322
324
|
case "nxfer": {
|
|
@@ -352,7 +354,7 @@ function parseRecord(uri, payloadHashHex) {
|
|
|
352
354
|
}
|
|
353
355
|
case "tmeta": {
|
|
354
356
|
if (!isTicker(r.ticker)) return null;
|
|
355
|
-
if (typeof r.hash !== "string" ||
|
|
357
|
+
if (typeof r.hash !== "string" || !HASH_RE.test(r.hash)) return null;
|
|
356
358
|
if (Object.keys(r).length !== 4) return null;
|
|
357
359
|
return r;
|
|
358
360
|
}
|
|
@@ -361,8 +363,8 @@ function parseRecord(uri, payloadHashHex) {
|
|
|
361
363
|
}
|
|
362
364
|
}
|
|
363
365
|
function buildRecord(record) {
|
|
364
|
-
const uri = (0,
|
|
365
|
-
const ph = (0,
|
|
366
|
+
const uri = (0, import_csd_codec2.canonicalJson)(record);
|
|
367
|
+
const ph = (0, import_csd_codec2.payloadHash)(record);
|
|
366
368
|
const back = parseRecord(uri, ph);
|
|
367
369
|
if (back === null) throw new Error("record does not validate against CONVENTION.md");
|
|
368
370
|
return { record, uri, payloadHash: ph };
|
|
@@ -1170,6 +1172,7 @@ function canonicalState(s) {
|
|
|
1170
1172
|
REBATE_BPS,
|
|
1171
1173
|
REBATE_FLAT,
|
|
1172
1174
|
RESERVED_NAMES,
|
|
1175
|
+
SALT_RE,
|
|
1173
1176
|
SCORE_CANCEL,
|
|
1174
1177
|
SCORE_CLAIM,
|
|
1175
1178
|
SCORE_FILL,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { EPOCH_LEN } from '@inversealtruism/csd-codec';
|
|
2
|
+
|
|
1
3
|
declare const DOMAIN = "cairnx:v1";
|
|
2
4
|
declare const ACTIVATION_HEIGHT = 29860;
|
|
3
5
|
declare const V11_HEIGHT = 29960;
|
|
@@ -7,7 +9,7 @@ declare const V14_HEIGHT = 31400;
|
|
|
7
9
|
declare const V15_HEIGHT = 32000;
|
|
8
10
|
declare const V16_HEIGHT = 33600;
|
|
9
11
|
declare const V17_HEIGHT = 34000;
|
|
10
|
-
|
|
12
|
+
|
|
11
13
|
declare const NAME_TERM_EPOCHS = 8760;
|
|
12
14
|
declare const NAME_GRACE_EPOCHS = 720;
|
|
13
15
|
declare const NAME_PREMIUM_START = 20n;
|
|
@@ -45,6 +47,7 @@ declare const ADDR_RE: RegExp;
|
|
|
45
47
|
declare const AMOUNT_RE: RegExp;
|
|
46
48
|
declare const NAME_RE: RegExp;
|
|
47
49
|
declare const HASH_RE: RegExp;
|
|
50
|
+
declare const SALT_RE: RegExp;
|
|
48
51
|
declare const RESERVED_NAMES: Set<string>;
|
|
49
52
|
declare const COMMIT_MAX_BLOCKS: number;
|
|
50
53
|
declare const epochOf: (height: number) => number;
|
|
@@ -354,4 +357,4 @@ declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
|
354
357
|
* history.) Keys sort in ordinal (code-unit) order at every depth. */
|
|
355
358
|
declare function canonicalState(s: CairnXState): string;
|
|
356
359
|
|
|
357
|
-
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_WINDOW_BLOCKS, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord,
|
|
360
|
+
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_WINDOW_BLOCKS, 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, 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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { EPOCH_LEN } from '@inversealtruism/csd-codec';
|
|
2
|
+
|
|
1
3
|
declare const DOMAIN = "cairnx:v1";
|
|
2
4
|
declare const ACTIVATION_HEIGHT = 29860;
|
|
3
5
|
declare const V11_HEIGHT = 29960;
|
|
@@ -7,7 +9,7 @@ declare const V14_HEIGHT = 31400;
|
|
|
7
9
|
declare const V15_HEIGHT = 32000;
|
|
8
10
|
declare const V16_HEIGHT = 33600;
|
|
9
11
|
declare const V17_HEIGHT = 34000;
|
|
10
|
-
|
|
12
|
+
|
|
11
13
|
declare const NAME_TERM_EPOCHS = 8760;
|
|
12
14
|
declare const NAME_GRACE_EPOCHS = 720;
|
|
13
15
|
declare const NAME_PREMIUM_START = 20n;
|
|
@@ -45,6 +47,7 @@ declare const ADDR_RE: RegExp;
|
|
|
45
47
|
declare const AMOUNT_RE: RegExp;
|
|
46
48
|
declare const NAME_RE: RegExp;
|
|
47
49
|
declare const HASH_RE: RegExp;
|
|
50
|
+
declare const SALT_RE: RegExp;
|
|
48
51
|
declare const RESERVED_NAMES: Set<string>;
|
|
49
52
|
declare const COMMIT_MAX_BLOCKS: number;
|
|
50
53
|
declare const epochOf: (height: number) => number;
|
|
@@ -354,4 +357,4 @@ declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
|
354
357
|
* history.) Keys sort in ordinal (code-unit) order at every depth. */
|
|
355
358
|
declare function canonicalState(s: CairnXState): string;
|
|
356
359
|
|
|
357
|
-
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_WINDOW_BLOCKS, COMMIT_MAX_BLOCKS, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DOMAIN, type DeployRecord,
|
|
360
|
+
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_WINDOW_BLOCKS, 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, 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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
|
+
import { EPOCH_LEN } from "@inversealtruism/csd-codec";
|
|
2
3
|
var DOMAIN = "cairnx:v1";
|
|
3
4
|
var ACTIVATION_HEIGHT = 29860;
|
|
4
5
|
var V11_HEIGHT = 29960;
|
|
@@ -8,7 +9,6 @@ var V14_HEIGHT = 31400;
|
|
|
8
9
|
var V15_HEIGHT = 32e3;
|
|
9
10
|
var V16_HEIGHT = 33600;
|
|
10
11
|
var V17_HEIGHT = 34e3;
|
|
11
|
-
var EPOCH_LEN = 30;
|
|
12
12
|
var NAME_TERM_EPOCHS = 8760;
|
|
13
13
|
var NAME_GRACE_EPOCHS = 720;
|
|
14
14
|
var NAME_PREMIUM_START = 20n;
|
|
@@ -58,6 +58,7 @@ var ADDR_RE = /^0x[0-9a-f]{40}$/;
|
|
|
58
58
|
var AMOUNT_RE = /^(0|[1-9][0-9]*)$/;
|
|
59
59
|
var NAME_RE = /^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
|
|
60
60
|
var HASH_RE = /^0x[0-9a-f]{64}$/;
|
|
61
|
+
var SALT_RE = /^[0-9a-fA-F]{16,128}$/;
|
|
61
62
|
var RESERVED_NAMES = /* @__PURE__ */ new Set(["csd", "treasury", "admin", "official", "root", "www", "support"]);
|
|
62
63
|
var COMMIT_MAX_BLOCKS = 8 * EPOCH_LEN;
|
|
63
64
|
var epochOf = (height) => Math.floor(height / EPOCH_LEN);
|
|
@@ -221,7 +222,7 @@ function parseRecord(uri, payloadHashHex) {
|
|
|
221
222
|
case "name": {
|
|
222
223
|
if (!onlyKeys(r, NAME_KEYS)) return null;
|
|
223
224
|
if (!isName(r.name)) return null;
|
|
224
|
-
if (r.salt !== void 0 && (typeof r.salt !== "string" ||
|
|
225
|
+
if (r.salt !== void 0 && (typeof r.salt !== "string" || !SALT_RE.test(r.salt))) return null;
|
|
225
226
|
return r;
|
|
226
227
|
}
|
|
227
228
|
case "nxfer": {
|
|
@@ -257,7 +258,7 @@ function parseRecord(uri, payloadHashHex) {
|
|
|
257
258
|
}
|
|
258
259
|
case "tmeta": {
|
|
259
260
|
if (!isTicker(r.ticker)) return null;
|
|
260
|
-
if (typeof r.hash !== "string" ||
|
|
261
|
+
if (typeof r.hash !== "string" || !HASH_RE.test(r.hash)) return null;
|
|
261
262
|
if (Object.keys(r).length !== 4) return null;
|
|
262
263
|
return r;
|
|
263
264
|
}
|
|
@@ -1074,6 +1075,7 @@ export {
|
|
|
1074
1075
|
REBATE_BPS,
|
|
1075
1076
|
REBATE_FLAT,
|
|
1076
1077
|
RESERVED_NAMES,
|
|
1078
|
+
SALT_RE,
|
|
1077
1079
|
SCORE_CANCEL,
|
|
1078
1080
|
SCORE_CLAIM,
|
|
1079
1081
|
SCORE_FILL,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inversealtruism/cairnx-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test/vectors"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@inversealtruism/csd-codec": "0.1.
|
|
25
|
+
"@inversealtruism/csd-codec": "0.1.14"
|
|
26
26
|
},
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"sideEffects": false,
|