@typeberry/jam 0.2.0-c96e8ef → 0.2.0-daa61f5
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 +26 -17
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +6152 -5469
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +154 -31
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +6343 -5490
- 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) {
|
|
@@ -28744,10 +28740,23 @@ class Bootnode {
|
|
|
28744
28740
|
}
|
|
28745
28741
|
}
|
|
28746
28742
|
|
|
28743
|
+
;// CONCATENATED MODULE: ./packages/jam/config/pvm-backend.ts
|
|
28744
|
+
/** Implemented PVM Backends names in THE SAME ORDER as enum. */
|
|
28745
|
+
const PvmBackendNames = (/* unused pure expression or super */ null && (["built-in", "ananas"]));
|
|
28746
|
+
/** Implemented PVM Backends to choose from. */
|
|
28747
|
+
var PvmBackend;
|
|
28748
|
+
(function (PvmBackend) {
|
|
28749
|
+
/** Built-in aka. Typeberry 🫐 interpreter. */
|
|
28750
|
+
PvmBackend[PvmBackend["BuiltIn"] = 0] = "BuiltIn";
|
|
28751
|
+
/** Ananas 🍍 interpreter. */
|
|
28752
|
+
PvmBackend[PvmBackend["Ananas"] = 1] = "Ananas";
|
|
28753
|
+
})(PvmBackend || (PvmBackend = {}));
|
|
28754
|
+
|
|
28747
28755
|
;// CONCATENATED MODULE: ./packages/jam/config/index.ts
|
|
28748
28756
|
|
|
28749
28757
|
|
|
28750
28758
|
|
|
28759
|
+
|
|
28751
28760
|
;// CONCATENATED MODULE: ./packages/jam/block/codec.ts
|
|
28752
28761
|
|
|
28753
28762
|
|
|
@@ -31300,6 +31309,7 @@ class AuthorshipOptions {
|
|
|
31300
31309
|
|
|
31301
31310
|
|
|
31302
31311
|
|
|
31312
|
+
|
|
31303
31313
|
const logger = Logger.new(import.meta.filename, "config");
|
|
31304
31314
|
/** Development config. Will accept unsealed blocks for now. */
|
|
31305
31315
|
const DEV_CONFIG = "dev";
|
|
@@ -31307,7 +31317,8 @@ const DEV_CONFIG = "dev";
|
|
|
31307
31317
|
const DEFAULT_CONFIG = "default";
|
|
31308
31318
|
const NODE_DEFAULTS = {
|
|
31309
31319
|
name: isBrowser() ? "browser" : external_node_os_default().hostname(),
|
|
31310
|
-
config: DEFAULT_CONFIG,
|
|
31320
|
+
config: [DEFAULT_CONFIG],
|
|
31321
|
+
pvm: PvmBackend.BuiltIn,
|
|
31311
31322
|
};
|
|
31312
31323
|
/** Chain spec chooser. */
|
|
31313
31324
|
var KnownChainSpec;
|
|
@@ -31359,24 +31370,136 @@ class NodeConfiguration {
|
|
|
31359
31370
|
this.authorship = authorship;
|
|
31360
31371
|
}
|
|
31361
31372
|
}
|
|
31362
|
-
function loadConfig(
|
|
31363
|
-
|
|
31364
|
-
|
|
31365
|
-
|
|
31366
|
-
|
|
31367
|
-
|
|
31368
|
-
|
|
31369
|
-
|
|
31373
|
+
function loadConfig(config, withRelPath) {
|
|
31374
|
+
logger.log `🔧 Loading config`;
|
|
31375
|
+
let mergedJson = {};
|
|
31376
|
+
for (const entry of config) {
|
|
31377
|
+
logger.log `🔧 Applying '${entry}'`;
|
|
31378
|
+
if (entry === DEV_CONFIG) {
|
|
31379
|
+
mergedJson = structuredClone(configs.dev); // clone to avoid mutating the original config. not doing a merge since dev and default should theoretically replace all properties.
|
|
31380
|
+
continue;
|
|
31381
|
+
}
|
|
31382
|
+
if (entry === DEFAULT_CONFIG) {
|
|
31383
|
+
mergedJson = structuredClone(configs.default);
|
|
31384
|
+
continue;
|
|
31385
|
+
}
|
|
31386
|
+
// try to parse as JSON
|
|
31387
|
+
try {
|
|
31388
|
+
const parsed = JSON.parse(entry);
|
|
31389
|
+
deepMerge(mergedJson, parsed);
|
|
31390
|
+
continue;
|
|
31391
|
+
}
|
|
31392
|
+
catch { }
|
|
31393
|
+
// if not, try to load as file
|
|
31394
|
+
if (entry.indexOf("=") === -1 && entry.endsWith(".json")) {
|
|
31395
|
+
try {
|
|
31396
|
+
const configFile = fs.readFileSync(withRelPath(entry), "utf8");
|
|
31397
|
+
const parsed = JSON.parse(configFile);
|
|
31398
|
+
deepMerge(mergedJson, parsed);
|
|
31399
|
+
}
|
|
31400
|
+
catch (e) {
|
|
31401
|
+
throw new Error(`Unable to load config from ${entry}: ${e}`);
|
|
31402
|
+
}
|
|
31403
|
+
}
|
|
31404
|
+
else {
|
|
31405
|
+
// finally try to process as a pseudo-jq query
|
|
31406
|
+
try {
|
|
31407
|
+
processQuery(mergedJson, entry, withRelPath);
|
|
31408
|
+
}
|
|
31409
|
+
catch (e) {
|
|
31410
|
+
throw new Error(`Error while processing '${entry}': ${e}`);
|
|
31411
|
+
}
|
|
31412
|
+
}
|
|
31370
31413
|
}
|
|
31371
31414
|
try {
|
|
31372
|
-
|
|
31373
|
-
|
|
31374
|
-
|
|
31375
|
-
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
31415
|
+
const parsed = parseFromJson(mergedJson, NodeConfiguration.fromJson);
|
|
31416
|
+
logger.log `🔧 Config ready`;
|
|
31417
|
+
return parsed;
|
|
31376
31418
|
}
|
|
31377
31419
|
catch (e) {
|
|
31378
|
-
throw new Error(`Unable to
|
|
31420
|
+
throw new Error(`Unable to parse config: ${e}`);
|
|
31421
|
+
}
|
|
31422
|
+
}
|
|
31423
|
+
function deepMerge(target, source) {
|
|
31424
|
+
if (!isJsonObject(source)) {
|
|
31425
|
+
throw new Error(`Expected object, got ${source}`);
|
|
31426
|
+
}
|
|
31427
|
+
for (const key in source) {
|
|
31428
|
+
if (isJsonObject(source[key])) {
|
|
31429
|
+
if (!isJsonObject(target[key])) {
|
|
31430
|
+
target[key] = {};
|
|
31431
|
+
}
|
|
31432
|
+
deepMerge(target[key], source[key]);
|
|
31433
|
+
}
|
|
31434
|
+
else {
|
|
31435
|
+
target[key] = source[key];
|
|
31436
|
+
}
|
|
31437
|
+
}
|
|
31438
|
+
}
|
|
31439
|
+
/**
|
|
31440
|
+
* Caution: updates input directly.
|
|
31441
|
+
* Processes a pseudo-jq query. Syntax:
|
|
31442
|
+
* .path.to.value = { ... } - updates value with the specified object by replacement
|
|
31443
|
+
* .path.to.value += { ... } - updates value with the specified object by merging
|
|
31444
|
+
* .path.to.value = file.json - updates value with the contents of file.json
|
|
31445
|
+
* .path.to.value += file.json - merges the contents of file.json onto value
|
|
31446
|
+
*/
|
|
31447
|
+
function processQuery(input, query, withRelPath) {
|
|
31448
|
+
const queryParts = query.split("=");
|
|
31449
|
+
if (queryParts.length === 2) {
|
|
31450
|
+
let [path, value] = queryParts.map((part) => part.trim());
|
|
31451
|
+
let merge = false;
|
|
31452
|
+
// detect += syntax
|
|
31453
|
+
if (path.endsWith("+")) {
|
|
31454
|
+
merge = true;
|
|
31455
|
+
path = path.slice(0, -1);
|
|
31456
|
+
}
|
|
31457
|
+
let parsedValue;
|
|
31458
|
+
if (value.endsWith(".json")) {
|
|
31459
|
+
try {
|
|
31460
|
+
const configFile = fs.readFileSync(withRelPath(value), "utf8");
|
|
31461
|
+
const parsed = JSON.parse(configFile);
|
|
31462
|
+
parsedValue = parsed;
|
|
31463
|
+
}
|
|
31464
|
+
catch (e) {
|
|
31465
|
+
throw new Error(`Unable to load config from ${value}: ${e}`);
|
|
31466
|
+
}
|
|
31467
|
+
}
|
|
31468
|
+
else {
|
|
31469
|
+
try {
|
|
31470
|
+
parsedValue = JSON.parse(value);
|
|
31471
|
+
}
|
|
31472
|
+
catch (e) {
|
|
31473
|
+
throw new Error(`Unrecognized syntax '${value}': ${e}`);
|
|
31474
|
+
}
|
|
31475
|
+
}
|
|
31476
|
+
let pathParts = path.split(".");
|
|
31477
|
+
// allow leading dot in path
|
|
31478
|
+
if (pathParts[0] === "") {
|
|
31479
|
+
pathParts = pathParts.slice(1);
|
|
31480
|
+
}
|
|
31481
|
+
let target = input;
|
|
31482
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
31483
|
+
const part = pathParts[i];
|
|
31484
|
+
if (!isJsonObject(target[part])) {
|
|
31485
|
+
target[part] = {};
|
|
31486
|
+
}
|
|
31487
|
+
if (i === pathParts.length - 1) {
|
|
31488
|
+
if (merge) {
|
|
31489
|
+
deepMerge(target[part], parsedValue);
|
|
31490
|
+
}
|
|
31491
|
+
else {
|
|
31492
|
+
target[part] = parsedValue;
|
|
31493
|
+
}
|
|
31494
|
+
return;
|
|
31495
|
+
}
|
|
31496
|
+
target = target[part];
|
|
31497
|
+
}
|
|
31379
31498
|
}
|
|
31499
|
+
throw new Error("Unrecognized syntax.");
|
|
31500
|
+
}
|
|
31501
|
+
function isJsonObject(value) {
|
|
31502
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31380
31503
|
}
|
|
31381
31504
|
|
|
31382
31505
|
;// CONCATENATED MODULE: ./packages/jam/config-node/index.ts
|