@typeberry/jam 0.2.0-0303f5b → 0.2.0-3f440a7
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/README.md +3 -3
- package/bootstrap-generator.mjs +37 -39
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +6125 -5460
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +161 -31
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +6346 -5511
- package/index.js.map +1 -1
- package/package.json +3 -2
package/bootstrap-network.mjs
CHANGED
|
@@ -24033,44 +24033,40 @@ var GpVersion;
|
|
|
24033
24033
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
24034
24034
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
24035
24035
|
GpVersion["V0_7_1"] = "0.7.1";
|
|
24036
|
-
GpVersion["V0_7_2"] = "0.7.2
|
|
24036
|
+
GpVersion["V0_7_2"] = "0.7.2";
|
|
24037
24037
|
})(GpVersion || (GpVersion = {}));
|
|
24038
24038
|
var TestSuite;
|
|
24039
24039
|
(function (TestSuite) {
|
|
24040
24040
|
TestSuite["W3F_DAVXY"] = "w3f-davxy";
|
|
24041
24041
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
24042
24042
|
})(TestSuite || (TestSuite = {}));
|
|
24043
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
24043
24044
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
24044
|
-
const DEFAULT_VERSION = GpVersion.
|
|
24045
|
+
const DEFAULT_VERSION = GpVersion.V0_7_2;
|
|
24045
24046
|
const env = typeof process === "undefined" ? {} : process.env;
|
|
24046
24047
|
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
24047
24048
|
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
24048
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
24049
24049
|
function parseCurrentVersion(env) {
|
|
24050
24050
|
if (env === undefined) {
|
|
24051
24051
|
return undefined;
|
|
24052
24052
|
}
|
|
24053
|
-
|
|
24054
|
-
|
|
24055
|
-
|
|
24056
|
-
|
|
24057
|
-
case GpVersion.V0_7_2:
|
|
24058
|
-
return env;
|
|
24059
|
-
default:
|
|
24060
|
-
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
24053
|
+
for (const v of Object.values(GpVersion)) {
|
|
24054
|
+
if (env === v) {
|
|
24055
|
+
return v;
|
|
24056
|
+
}
|
|
24061
24057
|
}
|
|
24058
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
24062
24059
|
}
|
|
24063
24060
|
function parseCurrentSuite(env) {
|
|
24064
24061
|
if (env === undefined) {
|
|
24065
24062
|
return undefined;
|
|
24066
24063
|
}
|
|
24067
|
-
|
|
24068
|
-
|
|
24069
|
-
|
|
24070
|
-
|
|
24071
|
-
default:
|
|
24072
|
-
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
24064
|
+
for (const s of Object.values(TestSuite)) {
|
|
24065
|
+
if (env === s) {
|
|
24066
|
+
return s;
|
|
24067
|
+
}
|
|
24073
24068
|
}
|
|
24069
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
24074
24070
|
}
|
|
24075
24071
|
class Compatibility {
|
|
24076
24072
|
static override(version) {
|
|
@@ -24231,6 +24227,13 @@ class WithDebug {
|
|
|
24231
24227
|
return debug_inspect(this);
|
|
24232
24228
|
}
|
|
24233
24229
|
}
|
|
24230
|
+
function lazyInspect(obj) {
|
|
24231
|
+
return {
|
|
24232
|
+
toString() {
|
|
24233
|
+
return debug_inspect(obj);
|
|
24234
|
+
},
|
|
24235
|
+
};
|
|
24236
|
+
}
|
|
24234
24237
|
|
|
24235
24238
|
;// CONCATENATED MODULE: ./packages/core/utils/dev.ts
|
|
24236
24239
|
const dev_env = typeof process === "undefined" ? {} : process.env;
|
|
@@ -28744,10 +28747,23 @@ class Bootnode {
|
|
|
28744
28747
|
}
|
|
28745
28748
|
}
|
|
28746
28749
|
|
|
28750
|
+
;// CONCATENATED MODULE: ./packages/jam/config/pvm-backend.ts
|
|
28751
|
+
/** Implemented PVM Backends names in THE SAME ORDER as enum. */
|
|
28752
|
+
const PvmBackendNames = (/* unused pure expression or super */ null && (["built-in", "ananas"]));
|
|
28753
|
+
/** Implemented PVM Backends to choose from. */
|
|
28754
|
+
var PvmBackend;
|
|
28755
|
+
(function (PvmBackend) {
|
|
28756
|
+
/** Built-in aka. Typeberry 🫐 interpreter. */
|
|
28757
|
+
PvmBackend[PvmBackend["BuiltIn"] = 0] = "BuiltIn";
|
|
28758
|
+
/** Ananas 🍍 interpreter. */
|
|
28759
|
+
PvmBackend[PvmBackend["Ananas"] = 1] = "Ananas";
|
|
28760
|
+
})(PvmBackend || (PvmBackend = {}));
|
|
28761
|
+
|
|
28747
28762
|
;// CONCATENATED MODULE: ./packages/jam/config/index.ts
|
|
28748
28763
|
|
|
28749
28764
|
|
|
28750
28765
|
|
|
28766
|
+
|
|
28751
28767
|
;// CONCATENATED MODULE: ./packages/jam/block/codec.ts
|
|
28752
28768
|
|
|
28753
28769
|
|
|
@@ -31300,6 +31316,7 @@ class AuthorshipOptions {
|
|
|
31300
31316
|
|
|
31301
31317
|
|
|
31302
31318
|
|
|
31319
|
+
|
|
31303
31320
|
const logger = Logger.new(import.meta.filename, "config");
|
|
31304
31321
|
/** Development config. Will accept unsealed blocks for now. */
|
|
31305
31322
|
const DEV_CONFIG = "dev";
|
|
@@ -31307,7 +31324,8 @@ const DEV_CONFIG = "dev";
|
|
|
31307
31324
|
const DEFAULT_CONFIG = "default";
|
|
31308
31325
|
const NODE_DEFAULTS = {
|
|
31309
31326
|
name: isBrowser() ? "browser" : external_node_os_default().hostname(),
|
|
31310
|
-
config: DEFAULT_CONFIG,
|
|
31327
|
+
config: [DEFAULT_CONFIG],
|
|
31328
|
+
pvm: PvmBackend.BuiltIn,
|
|
31311
31329
|
};
|
|
31312
31330
|
/** Chain spec chooser. */
|
|
31313
31331
|
var KnownChainSpec;
|
|
@@ -31359,24 +31377,136 @@ class NodeConfiguration {
|
|
|
31359
31377
|
this.authorship = authorship;
|
|
31360
31378
|
}
|
|
31361
31379
|
}
|
|
31362
|
-
function loadConfig(
|
|
31363
|
-
|
|
31364
|
-
|
|
31365
|
-
|
|
31366
|
-
|
|
31367
|
-
|
|
31368
|
-
|
|
31369
|
-
|
|
31380
|
+
function loadConfig(config, withRelPath) {
|
|
31381
|
+
logger.log `🔧 Loading config`;
|
|
31382
|
+
let mergedJson = {};
|
|
31383
|
+
for (const entry of config) {
|
|
31384
|
+
logger.log `🔧 Applying '${entry}'`;
|
|
31385
|
+
if (entry === DEV_CONFIG) {
|
|
31386
|
+
mergedJson = structuredClone(configs.dev); // clone to avoid mutating the original config. not doing a merge since dev and default should theoretically replace all properties.
|
|
31387
|
+
continue;
|
|
31388
|
+
}
|
|
31389
|
+
if (entry === DEFAULT_CONFIG) {
|
|
31390
|
+
mergedJson = structuredClone(configs.default);
|
|
31391
|
+
continue;
|
|
31392
|
+
}
|
|
31393
|
+
// try to parse as JSON
|
|
31394
|
+
try {
|
|
31395
|
+
const parsed = JSON.parse(entry);
|
|
31396
|
+
deepMerge(mergedJson, parsed);
|
|
31397
|
+
continue;
|
|
31398
|
+
}
|
|
31399
|
+
catch { }
|
|
31400
|
+
// if not, try to load as file
|
|
31401
|
+
if (entry.indexOf("=") === -1 && entry.endsWith(".json")) {
|
|
31402
|
+
try {
|
|
31403
|
+
const configFile = fs.readFileSync(withRelPath(entry), "utf8");
|
|
31404
|
+
const parsed = JSON.parse(configFile);
|
|
31405
|
+
deepMerge(mergedJson, parsed);
|
|
31406
|
+
}
|
|
31407
|
+
catch (e) {
|
|
31408
|
+
throw new Error(`Unable to load config from ${entry}: ${e}`);
|
|
31409
|
+
}
|
|
31410
|
+
}
|
|
31411
|
+
else {
|
|
31412
|
+
// finally try to process as a pseudo-jq query
|
|
31413
|
+
try {
|
|
31414
|
+
processQuery(mergedJson, entry, withRelPath);
|
|
31415
|
+
}
|
|
31416
|
+
catch (e) {
|
|
31417
|
+
throw new Error(`Error while processing '${entry}': ${e}`);
|
|
31418
|
+
}
|
|
31419
|
+
}
|
|
31370
31420
|
}
|
|
31371
31421
|
try {
|
|
31372
|
-
|
|
31373
|
-
|
|
31374
|
-
|
|
31375
|
-
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
31422
|
+
const parsed = parseFromJson(mergedJson, NodeConfiguration.fromJson);
|
|
31423
|
+
logger.log `🔧 Config ready`;
|
|
31424
|
+
return parsed;
|
|
31376
31425
|
}
|
|
31377
31426
|
catch (e) {
|
|
31378
|
-
throw new Error(`Unable to
|
|
31427
|
+
throw new Error(`Unable to parse config: ${e}`);
|
|
31428
|
+
}
|
|
31429
|
+
}
|
|
31430
|
+
function deepMerge(target, source) {
|
|
31431
|
+
if (!isJsonObject(source)) {
|
|
31432
|
+
throw new Error(`Expected object, got ${source}`);
|
|
31433
|
+
}
|
|
31434
|
+
for (const key in source) {
|
|
31435
|
+
if (isJsonObject(source[key])) {
|
|
31436
|
+
if (!isJsonObject(target[key])) {
|
|
31437
|
+
target[key] = {};
|
|
31438
|
+
}
|
|
31439
|
+
deepMerge(target[key], source[key]);
|
|
31440
|
+
}
|
|
31441
|
+
else {
|
|
31442
|
+
target[key] = source[key];
|
|
31443
|
+
}
|
|
31444
|
+
}
|
|
31445
|
+
}
|
|
31446
|
+
/**
|
|
31447
|
+
* Caution: updates input directly.
|
|
31448
|
+
* Processes a pseudo-jq query. Syntax:
|
|
31449
|
+
* .path.to.value = { ... } - updates value with the specified object by replacement
|
|
31450
|
+
* .path.to.value += { ... } - updates value with the specified object by merging
|
|
31451
|
+
* .path.to.value = file.json - updates value with the contents of file.json
|
|
31452
|
+
* .path.to.value += file.json - merges the contents of file.json onto value
|
|
31453
|
+
*/
|
|
31454
|
+
function processQuery(input, query, withRelPath) {
|
|
31455
|
+
const queryParts = query.split("=");
|
|
31456
|
+
if (queryParts.length === 2) {
|
|
31457
|
+
let [path, value] = queryParts.map((part) => part.trim());
|
|
31458
|
+
let merge = false;
|
|
31459
|
+
// detect += syntax
|
|
31460
|
+
if (path.endsWith("+")) {
|
|
31461
|
+
merge = true;
|
|
31462
|
+
path = path.slice(0, -1);
|
|
31463
|
+
}
|
|
31464
|
+
let parsedValue;
|
|
31465
|
+
if (value.endsWith(".json")) {
|
|
31466
|
+
try {
|
|
31467
|
+
const configFile = fs.readFileSync(withRelPath(value), "utf8");
|
|
31468
|
+
const parsed = JSON.parse(configFile);
|
|
31469
|
+
parsedValue = parsed;
|
|
31470
|
+
}
|
|
31471
|
+
catch (e) {
|
|
31472
|
+
throw new Error(`Unable to load config from ${value}: ${e}`);
|
|
31473
|
+
}
|
|
31474
|
+
}
|
|
31475
|
+
else {
|
|
31476
|
+
try {
|
|
31477
|
+
parsedValue = JSON.parse(value);
|
|
31478
|
+
}
|
|
31479
|
+
catch (e) {
|
|
31480
|
+
throw new Error(`Unrecognized syntax '${value}': ${e}`);
|
|
31481
|
+
}
|
|
31482
|
+
}
|
|
31483
|
+
let pathParts = path.split(".");
|
|
31484
|
+
// allow leading dot in path
|
|
31485
|
+
if (pathParts[0] === "") {
|
|
31486
|
+
pathParts = pathParts.slice(1);
|
|
31487
|
+
}
|
|
31488
|
+
let target = input;
|
|
31489
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
31490
|
+
const part = pathParts[i];
|
|
31491
|
+
if (!isJsonObject(target[part])) {
|
|
31492
|
+
target[part] = {};
|
|
31493
|
+
}
|
|
31494
|
+
if (i === pathParts.length - 1) {
|
|
31495
|
+
if (merge) {
|
|
31496
|
+
deepMerge(target[part], parsedValue);
|
|
31497
|
+
}
|
|
31498
|
+
else {
|
|
31499
|
+
target[part] = parsedValue;
|
|
31500
|
+
}
|
|
31501
|
+
return;
|
|
31502
|
+
}
|
|
31503
|
+
target = target[part];
|
|
31504
|
+
}
|
|
31379
31505
|
}
|
|
31506
|
+
throw new Error("Unrecognized syntax.");
|
|
31507
|
+
}
|
|
31508
|
+
function isJsonObject(value) {
|
|
31509
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31380
31510
|
}
|
|
31381
31511
|
|
|
31382
31512
|
;// CONCATENATED MODULE: ./packages/jam/config-node/index.ts
|