@activeledger/activeledger 5.0.2 → 5.1.1
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/es/cli/cli.d.ts.map +1 -1
- package/es/cli/cli.js +65 -4
- package/es/cli/cli.js.map +1 -1
- package/es/cli/health.d.ts +4 -0
- package/es/cli/health.d.ts.map +1 -0
- package/es/cli/health.js +46 -0
- package/es/cli/health.js.map +1 -0
- package/es/cli/hybrid.d.ts +5 -0
- package/es/cli/hybrid.d.ts.map +1 -0
- package/es/cli/hybrid.js +105 -0
- package/es/cli/hybrid.js.map +1 -0
- package/es/cli/hybridChange.d.ts +12 -0
- package/es/cli/hybridChange.d.ts.map +1 -0
- package/es/cli/hybridChange.js +56 -0
- package/es/cli/hybridChange.js.map +1 -0
- package/es/cli/program.d.ts +3 -0
- package/es/cli/program.d.ts.map +1 -0
- package/es/cli/program.js +67 -0
- package/es/cli/program.js.map +1 -0
- package/es/cli/startup.d.ts +11 -0
- package/es/cli/startup.d.ts.map +1 -0
- package/es/cli/startup.js +42 -0
- package/es/cli/startup.js.map +1 -0
- package/es/contracts/default/contract.d.ts +6 -0
- package/es/contracts/default/contract.d.ts.map +1 -1
- package/es/contracts/default/contract.js +120 -43
- package/es/contracts/default/contract.js.map +1 -1
- package/es/contracts/default/hybrid.d.ts +22 -0
- package/es/contracts/default/hybrid.d.ts.map +1 -0
- package/es/contracts/default/hybrid.js +222 -0
- package/es/contracts/default/hybrid.js.map +1 -0
- package/es/contracts/default/setup.d.ts +8 -0
- package/es/contracts/default/setup.d.ts.map +1 -1
- package/es/contracts/default/setup.js +147 -0
- package/es/contracts/default/setup.js.map +1 -1
- package/es/default.config.json +8 -1
- package/es/index.js +35 -9
- package/es/index.js.map +1 -1
- package/lib/cli/cli.d.ts.map +1 -1
- package/lib/cli/cli.js +64 -3
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/health.d.ts +4 -0
- package/lib/cli/health.d.ts.map +1 -0
- package/lib/cli/health.js +85 -0
- package/lib/cli/health.js.map +1 -0
- package/lib/cli/hybrid.d.ts +5 -0
- package/lib/cli/hybrid.d.ts.map +1 -0
- package/lib/cli/hybrid.js +142 -0
- package/lib/cli/hybrid.js.map +1 -0
- package/lib/cli/hybridChange.d.ts +12 -0
- package/lib/cli/hybridChange.d.ts.map +1 -0
- package/lib/cli/hybridChange.js +97 -0
- package/lib/cli/hybridChange.js.map +1 -0
- package/lib/cli/program.d.ts +3 -0
- package/lib/cli/program.d.ts.map +1 -0
- package/lib/cli/program.js +71 -0
- package/lib/cli/program.js.map +1 -0
- package/lib/cli/startup.d.ts +11 -0
- package/lib/cli/startup.d.ts.map +1 -0
- package/lib/cli/startup.js +46 -0
- package/lib/cli/startup.js.map +1 -0
- package/lib/contracts/default/contract.d.ts +6 -0
- package/lib/contracts/default/contract.d.ts.map +1 -1
- package/lib/contracts/default/contract.js +120 -43
- package/lib/contracts/default/contract.js.map +1 -1
- package/lib/contracts/default/hybrid.d.ts +22 -0
- package/lib/contracts/default/hybrid.d.ts.map +1 -0
- package/lib/contracts/default/hybrid.js +225 -0
- package/lib/contracts/default/hybrid.js.map +1 -0
- package/lib/contracts/default/setup.d.ts +8 -0
- package/lib/contracts/default/setup.d.ts.map +1 -1
- package/lib/contracts/default/setup.js +147 -0
- package/lib/contracts/default/setup.js.map +1 -1
- package/lib/default.config.json +8 -1
- package/lib/index.js +35 -9
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.signers = exports.submitChange = exports.signChange = exports.buildChange = exports.keyArgument = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const activeoptions_1 = require("@activeledger/activeoptions");
|
|
39
|
+
const activecrypto_1 = require("@activeledger/activecrypto");
|
|
40
|
+
const config = () => {
|
|
41
|
+
const file = activeoptions_1.ActiveOptions.get("config", "./config.json");
|
|
42
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
43
|
+
return {
|
|
44
|
+
host: activeoptions_1.ActiveOptions.get("host", "") || parsed.host,
|
|
45
|
+
network: activeoptions_1.ActiveOptions.get("network", "") || parsed.network || "",
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const identity = () => JSON.parse(fs.readFileSync(activeoptions_1.ActiveOptions.get("identity", "./.identity"), "utf8"));
|
|
49
|
+
const signer = (id) => new activecrypto_1.ActiveCrypto.KeyPair("rsa", id.prv.pkcs8pem);
|
|
50
|
+
const keyArgument = (arg) => {
|
|
51
|
+
if (/^[a-f0-9]{64}$/.test(arg))
|
|
52
|
+
return arg;
|
|
53
|
+
const pem = fs.existsSync(arg) ? fs.readFileSync(arg, "utf8") : arg;
|
|
54
|
+
if (pem.indexOf("-----BEGIN") === -1) {
|
|
55
|
+
throw new Error("expected a key hash, a PEM public key or a file holding one");
|
|
56
|
+
}
|
|
57
|
+
return activecrypto_1.ActiveCrypto.keyHash(pem);
|
|
58
|
+
};
|
|
59
|
+
exports.keyArgument = keyArgument;
|
|
60
|
+
const buildChange = (change) => {
|
|
61
|
+
const { host, network } = config();
|
|
62
|
+
if (!network) {
|
|
63
|
+
throw new Error("The network has not been asserted to the ledger yet");
|
|
64
|
+
}
|
|
65
|
+
const id = identity();
|
|
66
|
+
const tx = {
|
|
67
|
+
$namespace: "default",
|
|
68
|
+
$contract: "setup",
|
|
69
|
+
$entry: "hybrid",
|
|
70
|
+
$i: {
|
|
71
|
+
suggester: { type: "rsa", publicKey: id.pub.pkcs8pem, change },
|
|
72
|
+
},
|
|
73
|
+
$o: { [network.split("@")[0]]: {} },
|
|
74
|
+
};
|
|
75
|
+
const signed = signer(id).sign(tx);
|
|
76
|
+
return {
|
|
77
|
+
$tx: tx,
|
|
78
|
+
$selfsign: true,
|
|
79
|
+
$sigs: { suggester: signed, [host]: signed },
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
exports.buildChange = buildChange;
|
|
83
|
+
const signChange = (request) => {
|
|
84
|
+
const { host } = config();
|
|
85
|
+
request.$sigs[host] = signer(identity()).sign(request.$tx);
|
|
86
|
+
return request;
|
|
87
|
+
};
|
|
88
|
+
exports.signChange = signChange;
|
|
89
|
+
const submitChange = async (request) => {
|
|
90
|
+
const { host } = config();
|
|
91
|
+
const response = await activeoptions_1.ActiveRequest.send(`http://${host}`, "POST", [], request);
|
|
92
|
+
return response.data?.$summary?.errors ?? [];
|
|
93
|
+
};
|
|
94
|
+
exports.submitChange = submitChange;
|
|
95
|
+
const signers = (request) => Object.keys(request.$sigs).filter((k) => k !== "suggester");
|
|
96
|
+
exports.signers = signers;
|
|
97
|
+
//# sourceMappingURL=hybridChange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hybridChange.js","sourceRoot":"","sources":["../../src/cli/hybridChange.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAY,EAAE,+BAAW;AACzB,+DAA2E;AAC3E,6DAA0D;AAkB1D,MAAM,MAAM,GAAG,GAAsC,EAAE;IACrD,MAAM,IAAI,GAAG,6BAAa,CAAC,GAAG,CAAS,QAAQ,EAAE,eAAe,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACzD,OAAO;QACL,IAAI,EAAE,6BAAa,CAAC,GAAG,CAAS,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI;QAC1D,OAAO,EAAE,6BAAa,CAAC,GAAG,CAAS,SAAS,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE;KAC1E,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,GAA4B,EAAE,CAC7C,IAAI,CAAC,KAAK,CACR,EAAE,CAAC,YAAY,CAAC,6BAAa,CAAC,GAAG,CAAS,UAAU,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,CAC9E,CAAC;AAEJ,MAAM,MAAM,GAAG,CAAC,EAA2B,EAAE,EAAE,CAC7C,IAAI,2BAAY,CAAC,O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ources":["../../src/cli/program.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAgClD,eAAO,MAAM,gBAAgB,YAAa,MAAM,KAAG,GAAG,CAAC,UA2CrD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.supernodeProgram = void 0;
|
|
4
|
+
const activeoptions_1 = require("@activeledger/activeoptions");
|
|
5
|
+
const CONFIG_KEYS = [
|
|
6
|
+
"autostart",
|
|
7
|
+
"build",
|
|
8
|
+
"configVersion",
|
|
9
|
+
"consensus",
|
|
10
|
+
"contractCheckTimeout",
|
|
11
|
+
"contractMaxTimeout",
|
|
12
|
+
"cpus",
|
|
13
|
+
"db",
|
|
14
|
+
"debugToClient",
|
|
15
|
+
"gzip",
|
|
16
|
+
"max_memory",
|
|
17
|
+
"nanoGateway",
|
|
18
|
+
"neighbourhood",
|
|
19
|
+
"neighbourhoodRemap",
|
|
20
|
+
"network",
|
|
21
|
+
"p2pStream",
|
|
22
|
+
"p2pStreamServer",
|
|
23
|
+
"proxy",
|
|
24
|
+
"queue_retry",
|
|
25
|
+
"rebaseThrottle",
|
|
26
|
+
"remote",
|
|
27
|
+
"security",
|
|
28
|
+
"winston",
|
|
29
|
+
];
|
|
30
|
+
const supernodeProgram = (version) => ({
|
|
31
|
+
name: "activeledger",
|
|
32
|
+
version,
|
|
33
|
+
defaultCommand: "start",
|
|
34
|
+
commands: [
|
|
35
|
+
...activeoptions_1.Cli.COMMON_COMMANDS,
|
|
36
|
+
{ name: "hybrid", usage: "list|feeds|ban <keyhash>|unban <keyhash>|allow <key>|deny <key>|admission <open|allowlist>|min-version <semver>|sign <file>|submit <file>", description: "Manage the hybrids that follow this node" },
|
|
37
|
+
],
|
|
38
|
+
flags: [
|
|
39
|
+
...activeoptions_1.Cli.COMMON_FLAGS.map((f) => f.name === "config" ? { ...f, default: "./config.json" } : f),
|
|
40
|
+
...[
|
|
41
|
+
["stop", "Stop the node", "stop", "boolean"],
|
|
42
|
+
["restart", "Restart the node", "restart", "boolean"],
|
|
43
|
+
["auto", "Mark a restart as automatic", undefined, "boolean"],
|
|
44
|
+
["stats", "Print node statistics", undefined, "boolean"],
|
|
45
|
+
].map(([name, description, command, type]) => ({
|
|
46
|
+
name,
|
|
47
|
+
description,
|
|
48
|
+
command,
|
|
49
|
+
type,
|
|
50
|
+
group: "Legacy actions",
|
|
51
|
+
})),
|
|
52
|
+
{ name: "testnet", description: "Build a local test network", group: "Setup" },
|
|
53
|
+
{ name: "merge", description: "Merge configs to build a local network", group: "Setup" },
|
|
54
|
+
{ name: "assert", description: "Assert the config on-ledger", group: "Setup" },
|
|
55
|
+
{ name: "assert-network", description: "Assert the config as a network", group: "Setup" },
|
|
56
|
+
{ name: "sign", arg: "<file>", description: "Sign the asserted config", group: "Setup" },
|
|
57
|
+
{ name: "public", description: "Print the node's public key", group: "Setup" },
|
|
58
|
+
{ name: "setup-only", description: "Run setup then exit", group: "Setup" },
|
|
59
|
+
{ name: "db-only", description: "Start only the database", group: "Setup" },
|
|
60
|
+
{ name: "disable-autostart", description: "Do not start the helper processes", group: "Setup" },
|
|
61
|
+
{ name: "out", arg: "<file>", description: "hybrid allow|deny|admission|min-version: write the signed change to a file instead of sending it", group: "Hybrid" },
|
|
62
|
+
{ name: "hybrid-listen", arg: "<port>", description: "Port for the hybrid P2P listener", group: "Hybrid" },
|
|
63
|
+
{ name: "hybrid-max-feeds", arg: "<n>", description: "Most hybrid feeds served at once (default 32)", group: "Hybrid" },
|
|
64
|
+
{ name: "hybridMaxFeeds", hidden: true, description: "Config key for hybrid-max-feeds" },
|
|
65
|
+
{ name: "backup", arg: "[file]", description: "Back up the ledger", group: "Backup" },
|
|
66
|
+
{ name: "restore", arg: "<file>", description: "Restore the ledger from a backup", group: "Backup" },
|
|
67
|
+
...CONFIG_KEYS.map((name) => ({ name, hidden: true, description: "Config key override" })),
|
|
68
|
+
],
|
|
69
|
+
});
|
|
70
|
+
exports.supernodeProgram = supernodeProgram;
|
|
71
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":";;;AAuBA,+DAAkD;AAMlD,MAAM,WAAW,GAAG;IAClB,WAAW;IACX,OAAO;IACP,eAAe;IACf,WAAW;IACX,sBAAsB;IACtB,oBAAoB;IACpB,MAAM;IACN,IAAI;IACJ,eAAe;IACf,MAAM;IACN,YAAY;IACZ,aAAa;IACb,eAAe;IACf,oBAAoB;IACpB,SAAS;IACT,WAAW;IACX,iBAAiB;IACjB,OAAO;IACP,aAAa;IACb,gBAAgB;IAChB,QAAQ;IACR,UAAU;IACV,SAAS;CACV,CAAC;AAEK,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAkB,EAAE,CAAC,CAAC;IACpE,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,cAAc,EAAE,OAAO;IACvB,QAAQ,EAAE;QACR,GAAG,mBAAG,CAAC,eAAe;QACtB,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,2IAA2I,EAAE,WAAW,EAAE,0CAA0C,EAAE;KAChO;IACD,KAAK,EAAE;QACL,GAAG,mBAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5B,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAC7D;QACD,GACE;YACE,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,CAAC;YAC5C,CAAC,SAAS,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,CAAC;YACrD,CAAC,MAAM,EAAE,6BAA6B,EAAE,SAAS,EAAE,SAAS,CAAC;YAC7D,CAAC,OA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Q,EAAE,WAAW,EAAE,kCAAkC,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC1G,EAAE,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,+CAA+C,EAAE,KAAK,EAAE,QAAQ,EAAE;QACvH,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,iCAAiC,EAAE;QACxF,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,oBAAoB,EAAE,KAAK,EAAE,QAAQ,EAAE;QACrF,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,kCAAkC,EAAE,KAAK,EAAE,QAAQ,EAAE;QACpG,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC,CAAC;KAC3F;CACF,CAAC,CAAC;AA3CU,QAAA,gBAAgB,GAAhB,gBAAgB,CA2C1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const STARTUP_STEPS: string[];
|
|
2
|
+
export declare class Startup {
|
|
3
|
+
private static display?;
|
|
4
|
+
static init(version: string): void;
|
|
5
|
+
static begin(step: string): void;
|
|
6
|
+
static done(step?: string): void;
|
|
7
|
+
static fail(reason: string, step?: string): void;
|
|
8
|
+
static finish(): void;
|
|
9
|
+
private static release;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=startup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.d.ts","sourceRoot":"","sources":["../../src/cli/startup.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,aAAa,UAOzB,CAAC;AAMF,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAiB;IAExC,OAAc,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAQxC;IAED,OAAc,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEtC;IAED,OAAc,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAEtC;IAED,OAAc,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAItD;IAED,OAAc,MAAM,IAAI,IAAI,CAI3B;IAED,OAAO,CAAC,MAAM,CAAC,OAAO;CAGvB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Startup = exports.STARTUP_STEPS = void 0;
|
|
4
|
+
const activelogger_1 = require("@activeledger/activelogger");
|
|
5
|
+
const activeoptions_1 = require("@activeledger/activeoptions");
|
|
6
|
+
const program_1 = require("./program");
|
|
7
|
+
exports.STARTUP_STEPS = [
|
|
8
|
+
"config",
|
|
9
|
+
"identity",
|
|
10
|
+
"database",
|
|
11
|
+
"network",
|
|
12
|
+
"consensus",
|
|
13
|
+
"ready",
|
|
14
|
+
];
|
|
15
|
+
class Startup {
|
|
16
|
+
static display;
|
|
17
|
+
static init(version) {
|
|
18
|
+
Startup.display = new activeoptions_1.StartupDisplay((0, program_1.supernodeProgram)(version), exports.STARTUP_STEPS, {
|
|
19
|
+
json: !!activeoptions_1.ActiveOptions.get("json", false),
|
|
20
|
+
quiet: !!activeoptions_1.ActiveOptions.get("quiet", false),
|
|
21
|
+
managed: (0, activeoptions_1.isManaged)(),
|
|
22
|
+
});
|
|
23
|
+
activelogger_1.ActiveLogger.sink = (line) => Startup.display?.log(line);
|
|
24
|
+
}
|
|
25
|
+
static begin(step) {
|
|
26
|
+
Startup.display?.begin(step);
|
|
27
|
+
}
|
|
28
|
+
static done(step) {
|
|
29
|
+
Startup.display?.done(step);
|
|
30
|
+
}
|
|
31
|
+
static fail(reason, step) {
|
|
32
|
+
Startup.release();
|
|
33
|
+
Startup.display?.fail(reason, step);
|
|
34
|
+
Startup.display = undefined;
|
|
35
|
+
}
|
|
36
|
+
static finish() {
|
|
37
|
+
Startup.release();
|
|
38
|
+
Startup.display?.finish();
|
|
39
|
+
Startup.display = undefined;
|
|
40
|
+
}
|
|
41
|
+
static release() {
|
|
42
|
+
activelogger_1.ActiveLogger.sink = undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.Startup = Startup;
|
|
46
|
+
//# sourceMappingURL=startup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.js","sourceRoot":"","sources":["../../src/cli/startup.ts"],"names":[],"mappings":";;;AAuBA,6DAA0D;AAC1D,+DAAuF;AACvF,uCAA6C;AAEhC,QAAA,aAAa,GAAG;IAC3B,QAAQ;IACR,UAAU;IACV,UAAU;IACV,SAAS;IACT,WAAW;IACX,OAAO;CACR,CAAC;AAMF;IACU,MAAM,CAAC,OAAO,CAAkB;IAEjC,MAAM,CAAC,IAAI,CAAC,OAAe;QAChC,OAAO,CAAC,OAAO,GAAG,IAAI,8BAAc,CAAC,IAAA,0BAAgB,EAAC,OAAO,CAAC,EAAE,QAAA,aAAa,EAAE;YAC7E,IAAI,EAAE,CAAC,CAAC,6BAAa,CAAC,GAAG,CAAU,MAAM,EAAE,KAAK,CAAC;YACjD,KAAK,EAAE,CAAC,CAAC,6BAAa,CAAC,GAAG,CAAU,OAAO,EAAE,KAAK,CAAC;YACnD,OAAO,EAAE,IAAA,yBAAS,GAAE;SACrB,CAAC,CAAC;QAEH,2BAAY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,IAAY;QAC9B,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,IAAI,CAAC,IAAa;QAC9B,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,IAAI,CAAC,MAAc,EAAE,IAAa;QAC9C,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpC,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,MAAM;QAClB,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAC1B,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEO,MAAM,CAAC,OAAO;QACpB,2BAAY,CAAC,IAAI,GAAG,SAAS,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -11,6 +11,12 @@ export default class Contract extends Standard {
|
|
|
11
11
|
vote(): Promise<boolean>;
|
|
12
12
|
commit(): Promise<any>;
|
|
13
13
|
private static readonly REFERENCE_BUILD;
|
|
14
|
+
private static readonly LOCK_BUILD;
|
|
15
|
+
static recordLocks(state: any, versions: string[], all?: boolean): any;
|
|
16
|
+
static forgetLock(state: any, version: string): any;
|
|
17
|
+
private lockOutput;
|
|
18
|
+
private lockHeld;
|
|
19
|
+
private versionsToLock;
|
|
14
20
|
private useContractReferences;
|
|
15
21
|
private static readonly ES2025_BUILD;
|
|
16
22
|
private contractTarget;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/contracts/default/contract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/contracts/default/contract.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,QAAQ,EAAY,MAAM,+BAA+B,CAAC;AAyOnE,MAAM,CAA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CACjB,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,KAAK,IAAI,EACrE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,GAC7B,IAAI,CAKN;IAcD,OAAO,CAAC,qBAAqB;IAyB7B,OAAO,CAAC,mBAAmB;IAgBpB,OAAO,CACZ,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,KAAK,IAAI,EACrE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,GAC7B,IAAI,CAuCN;IAOM,SAAS,CACd,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,KAAK,IAAI,EACrE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,GAC7B,IAAI,CA6EN;IAOM,UAAU,CACf,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,KAAK,IAAI,EACrE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,GAC7B,IAAI,CAgDN;IAOM,YAAY,CACjB,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,KAAK,IAAI,EACrE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,GAC7B,IAAI,CAuEN;CACF"}
|
|
@@ -35,9 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const fs = __importStar(require("fs"));
|
|
37
37
|
const ts = __importStar(require("typescript-api"));
|
|
38
|
+
const source_1 = require("@activeledger/activecontracts/lib/source");
|
|
38
39
|
const activecontracts_1 = require("@activeledger/activecontracts");
|
|
39
40
|
const activeoptions_1 = require("@activeledger/activeoptions");
|
|
40
|
-
const activecrypto_1 = require("@activeledger/activecrypto");
|
|
41
41
|
const BANNED_IDENTIFIERS = [
|
|
42
42
|
"process",
|
|
43
43
|
"global",
|
|
@@ -305,6 +305,77 @@ class Contract extends activecontracts_1.Standard {
|
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
static REFERENCE_BUILD = 40100;
|
|
308
|
+
static LOCK_BUILD = 40300;
|
|
309
|
+
static recordLocks(state, versions, all = false) {
|
|
310
|
+
const locks = state.locks || { versions: [] };
|
|
311
|
+
if (all)
|
|
312
|
+
locks.all = true;
|
|
313
|
+
locks.versions = [...new Set([...(locks.versions || []), ...versions])].sort();
|
|
314
|
+
state.locks = locks;
|
|
315
|
+
return state;
|
|
316
|
+
}
|
|
317
|
+
static forgetLock(state, version) {
|
|
318
|
+
const locks = state.locks;
|
|
319
|
+
if (!locks)
|
|
320
|
+
return state;
|
|
321
|
+
if (version === "")
|
|
322
|
+
delete locks.all;
|
|
323
|
+
else
|
|
324
|
+
locks.versions = (locks.versions || []).filter((v) => v !== version);
|
|
325
|
+
state.locks = { ...locks, versions: locks.versions || [] };
|
|
326
|
+
return state;
|
|
327
|
+
}
|
|
328
|
+
lockOutput() {
|
|
329
|
+
if (activeoptions_1.ActiveOptions.get("build", 0) < Contract.LOCK_BUILD)
|
|
330
|
+
return undefined;
|
|
331
|
+
const outputs = Object.keys(this.transactions.$o || {});
|
|
332
|
+
if (!outputs.length)
|
|
333
|
+
return undefined;
|
|
334
|
+
if (outputs.length !== 1 || outputs[0].toLowerCase() !== this.contract) {
|
|
335
|
+
throw new Error("A lock output must be the contract stream");
|
|
336
|
+
}
|
|
337
|
+
const out = this.getActivityStreams(outputs[0]);
|
|
338
|
+
const held = out.getState();
|
|
339
|
+
if (!held ||
|
|
340
|
+
!held.contract ||
|
|
341
|
+
String(held.namespace || "").toLowerCase() !== this.namespace) {
|
|
342
|
+
throw new Error("A lock output must be a contract in the namespace");
|
|
343
|
+
}
|
|
344
|
+
return out;
|
|
345
|
+
}
|
|
346
|
+
lockHeld(out) {
|
|
347
|
+
if (fs.existsSync(this.rootDir + this.namespace + "/_LOCK." + this.contract + this.version)) {
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
const locks = out && out.getState().locks;
|
|
351
|
+
if (!locks)
|
|
352
|
+
return false;
|
|
353
|
+
return this.version === ""
|
|
354
|
+
? !!locks.all
|
|
355
|
+
: (locks.versions || []).includes(this.version.slice(1));
|
|
356
|
+
}
|
|
357
|
+
versionsToLock(txi, existing) {
|
|
358
|
+
const asked = txi.lock;
|
|
359
|
+
if (asked === undefined)
|
|
360
|
+
return [];
|
|
361
|
+
if (activeoptions_1.ActiveOptions.get("build", 0) < Contract.LOCK_BUILD) {
|
|
362
|
+
throw new Error(`Locking versions on update needs build ${Contract.LOCK_BUILD}`);
|
|
363
|
+
}
|
|
364
|
+
if (asked === "all")
|
|
365
|
+
return existing.filter((v) => v !== txi.version);
|
|
366
|
+
if (!Array.isArray(asked) ||
|
|
367
|
+
asked.length > 1000 ||
|
|
368
|
+
asked.some((v) => typeof v !== "string")) {
|
|
369
|
+
throw new Error('lock must be "all" or an array of version names');
|
|
370
|
+
}
|
|
371
|
+
for (const v of asked) {
|
|
372
|
+
if (v === txi.version)
|
|
373
|
+
throw new Error("Cannot lock the version being deployed");
|
|
374
|
+
if (!existing.includes(v))
|
|
375
|
+
throw new Error(`Cannot lock unknown version ${v}`);
|
|
376
|
+
}
|
|
377
|
+
return [...new Set(asked)];
|
|
378
|
+
}
|
|
308
379
|
useContractReferences() {
|
|
309
380
|
return (activeoptions_1.ActiveOptions.get("build", 0) >= Contract.REFERENCE_BUILD);
|
|
310
381
|
}
|
|
@@ -320,7 +391,7 @@ class Contract extends activecontracts_1.Standard {
|
|
|
320
391
|
: streamName;
|
|
321
392
|
}
|
|
322
393
|
static hashContractSource(base64) {
|
|
323
|
-
return
|
|
394
|
+
return source_1.ContractSource.hash(base64);
|
|
324
395
|
}
|
|
325
396
|
normaliseLegacyVersions(state) {
|
|
326
397
|
if (!state.contract)
|
|
@@ -336,21 +407,7 @@ class Contract extends activecontracts_1.Standard {
|
|
|
336
407
|
}
|
|
337
408
|
}
|
|
338
409
|
transpile(target) {
|
|
339
|
-
return
|
|
340
|
-
compilerOptions: {
|
|
341
|
-
alwaysStrict: true,
|
|
342
|
-
strictNullChecks: true,
|
|
343
|
-
noImplicitAny: true,
|
|
344
|
-
removeComments: true,
|
|
345
|
-
module: ts.ModuleKind.CommonJS,
|
|
346
|
-
moduleResolution: ts.ModuleResolutionKind.Classic,
|
|
347
|
-
target: target === "es2025"
|
|
348
|
-
? ts.ScriptTarget.ES2025
|
|
349
|
-
: ts.ScriptTarget.ES2017,
|
|
350
|
-
esModuleInterop: false,
|
|
351
|
-
ignoreDeprecations: "6.0",
|
|
352
|
-
},
|
|
353
|
-
}).outputText;
|
|
410
|
+
return source_1.ContractSource.transpile(this.transactions.$i[this.identity.getName()].contract, target);
|
|
354
411
|
}
|
|
355
412
|
securityScan(sourceCode, namespace) {
|
|
356
413
|
const allowedModules = ["@activeledger/activetoolkits", "@activeledger/activecontracts"];
|
|
@@ -645,15 +702,16 @@ class Contract extends activecontracts_1.Standard {
|
|
|
645
702
|
}
|
|
646
703
|
if (this.identity.getState().namespace == this.namespace) {
|
|
647
704
|
if (fs.existsSync(this.rootDir + this.namespace + "/" + this.contract + ".js")) {
|
|
648
|
-
|
|
649
|
-
this.
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
705
|
+
try {
|
|
706
|
+
if (!this.lockHeld(this.lockOutput())) {
|
|
707
|
+
return resolve(true);
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
710
|
+
return reject("Lock already exists");
|
|
711
|
+
}
|
|
654
712
|
}
|
|
655
|
-
|
|
656
|
-
return reject(
|
|
713
|
+
catch (e) {
|
|
714
|
+
return reject(e.message);
|
|
657
715
|
}
|
|
658
716
|
}
|
|
659
717
|
else {
|
|
@@ -677,29 +735,40 @@ class Contract extends activecontracts_1.Standard {
|
|
|
677
735
|
return reject(e.message);
|
|
678
736
|
}
|
|
679
737
|
if (this.identity.getState().namespace == this.namespace) {
|
|
680
|
-
|
|
681
|
-
this.
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
738
|
+
try {
|
|
739
|
+
if (this.lockHeld(this.lockOutput())) {
|
|
740
|
+
return resolve(true);
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
return reject("Lock doesn't exists");
|
|
744
|
+
}
|
|
686
745
|
}
|
|
687
|
-
|
|
688
|
-
return reject(
|
|
746
|
+
catch (e) {
|
|
747
|
+
return reject(e.message);
|
|
689
748
|
}
|
|
690
749
|
}
|
|
691
750
|
return reject("Invalid Namespace");
|
|
692
751
|
}
|
|
693
752
|
commitLock(resolve, reject) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
753
|
+
const files = new source_1.ContractFiles(this.rootDir);
|
|
754
|
+
if (!files.isLocked(this.namespace, this.contract, this.version)) {
|
|
755
|
+
files.lock(this.namespace, this.contract, this.version);
|
|
756
|
+
}
|
|
757
|
+
const out = this.lockOutput();
|
|
758
|
+
if (out) {
|
|
759
|
+
out.setState(Contract.recordLocks(out.getState(), this.version ? [this.version.slice(1)] : [], this.version === ""));
|
|
760
|
+
}
|
|
699
761
|
resolve(true);
|
|
700
762
|
}
|
|
701
763
|
commitUnlock(resolve, reject) {
|
|
702
|
-
|
|
764
|
+
const files = new source_1.ContractFiles(this.rootDir);
|
|
765
|
+
if (files.isLocked(this.namespace, this.contract, this.version)) {
|
|
766
|
+
files.unlock(this.namespace, this.contract, this.version);
|
|
767
|
+
}
|
|
768
|
+
const out = this.lockOutput();
|
|
769
|
+
if (out) {
|
|
770
|
+
out.setState(Contract.forgetLock(out.getState(), this.version ? this.version.slice(1) : ""));
|
|
771
|
+
}
|
|
703
772
|
resolve(true);
|
|
704
773
|
}
|
|
705
774
|
voteLink(resolve, reject) {
|
|
@@ -824,8 +893,7 @@ class Contract extends activecontracts_1.Standard {
|
|
|
824
893
|
}
|
|
825
894
|
state.compiled = {};
|
|
826
895
|
state.compiled[txi.version] = this.compiledEntry(txi.contract, stream.getName());
|
|
827
|
-
|
|
828
|
-
fs.writeFileSync(`${this.rootDir}${this.namespace}/${stream.getName()}@${txi.version}.js`, code);
|
|
896
|
+
new source_1.ContractFiles(this.rootDir).write(this.namespace, stream.getName(), txi.version, code);
|
|
829
897
|
stream.setState(state);
|
|
830
898
|
resolve(true);
|
|
831
899
|
}
|
|
@@ -842,6 +910,9 @@ class Contract extends activecontracts_1.Standard {
|
|
|
842
910
|
if (this.identity.getState().namespace == this.namespace) {
|
|
843
911
|
try {
|
|
844
912
|
this.assertContractOwner();
|
|
913
|
+
const output = Object.keys(this.transactions.$o || {})[0];
|
|
914
|
+
const current = output ? this.getActivityStreams(output).getState() : {};
|
|
915
|
+
this.versionsToLock(this.transactions.$i[this.identity.getName()], Object.keys(current?.contract || {}));
|
|
845
916
|
this.securityScan(Buffer.from(this.transactions.$i[this.identity.getName()].contract, "base64").toString(), this.namespace);
|
|
846
917
|
resolve(true);
|
|
847
918
|
}
|
|
@@ -863,6 +934,7 @@ class Contract extends activecontracts_1.Standard {
|
|
|
863
934
|
if (this.useContractReferences()) {
|
|
864
935
|
this.normaliseLegacyVersions(state);
|
|
865
936
|
}
|
|
937
|
+
const toLock = this.versionsToLock(txi, Object.keys(state.contract || {}));
|
|
866
938
|
state.contract[txi.version] = this.useContractReferences()
|
|
867
939
|
? {
|
|
868
940
|
umid: this.umid,
|
|
@@ -874,8 +946,13 @@ class Contract extends activecontracts_1.Standard {
|
|
|
874
946
|
state.identity = this.identity.getName();
|
|
875
947
|
}
|
|
876
948
|
state.compiled[txi.version] = this.compiledEntry(txi.contract, stream.getName());
|
|
877
|
-
|
|
878
|
-
|
|
949
|
+
new source_1.ContractFiles(this.rootDir).write(this.namespace, stream.getName(), txi.version, code);
|
|
950
|
+
const files = new source_1.ContractFiles(this.rootDir);
|
|
951
|
+
for (const version of toLock) {
|
|
952
|
+
files.lock(this.namespace, stream.getName(), "@" + version);
|
|
953
|
+
}
|
|
954
|
+
if (toLock.length)
|
|
955
|
+
Contract.recordLocks(state, toLock);
|
|
879
956
|
stream.setState(state);
|
|
880
957
|
resolve(true);
|
|
881
958
|
}
|