@hsuite/smart-engines-cli 1.0.3 → 1.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/dist/__tests__/helpers/fixtures.d.ts +48 -0
- package/dist/__tests__/helpers/fixtures.d.ts.map +1 -0
- package/dist/__tests__/helpers/fixtures.js +79 -0
- package/dist/__tests__/helpers/fixtures.js.map +1 -0
- package/dist/_lib/cluster.d.ts +12 -0
- package/dist/_lib/cluster.d.ts.map +1 -0
- package/dist/_lib/cluster.js +45 -0
- package/dist/_lib/cluster.js.map +1 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +19 -7
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/governance.d.ts +42 -0
- package/dist/commands/governance.d.ts.map +1 -0
- package/dist/commands/governance.js +144 -0
- package/dist/commands/governance.js.map +1 -0
- package/dist/commands/hist-balance.d.ts +52 -0
- package/dist/commands/hist-balance.d.ts.map +1 -0
- package/dist/commands/hist-balance.js +134 -0
- package/dist/commands/hist-balance.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +2 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/personhood.d.ts +42 -0
- package/dist/commands/personhood.d.ts.map +1 -0
- package/dist/commands/personhood.js +150 -0
- package/dist/commands/personhood.js.map +1 -0
- package/dist/commands/subscribe.d.ts.map +1 -1
- package/dist/commands/subscribe.js +25 -6
- package/dist/commands/subscribe.js.map +1 -1
- package/dist/commands/verify.d.ts +43 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +231 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic XRPL ed25519 fixture.
|
|
3
|
+
*
|
|
4
|
+
* Provenance — derived once with:
|
|
5
|
+
* node -e "const {Wallet}=require('xrpl'); const w=Wallet.fromSeed('sEdTyaBYHfQhWt9ycB9QJsRKH8UUEuD'); console.log(w.address, w.publicKey)"
|
|
6
|
+
*
|
|
7
|
+
* Expected signature derived by running the validator's exact verifier
|
|
8
|
+
* path (libs/security-core/src/auth/web3-auth.service.ts:334-340):
|
|
9
|
+
* const hex = Buffer.from(message, 'utf-8').toString('hex').toUpperCase();
|
|
10
|
+
* sign(hex, wallet.privateKey) // ripple-keypairs
|
|
11
|
+
*
|
|
12
|
+
* If `EXPECTED_SIGNATURE` drifts, the CLI's signFn no longer produces what
|
|
13
|
+
* the validator's web3-auth verifier accepts. That's an auth-contract
|
|
14
|
+
* regression — every developer's `subscribe`/`deploy` breaks silently.
|
|
15
|
+
*/
|
|
16
|
+
export declare const XRPL_FIXTURE: {
|
|
17
|
+
readonly seed: "sEdTyaBYHfQhWt9ycB9QJsRKH8UUEuD";
|
|
18
|
+
readonly address: "rNHjsSoFgEMPZi4kE5rfw6c8k6tTUX8eng";
|
|
19
|
+
readonly publicKey: "ED652CD3EAB154510CBFCF4AEDEE4EAEB295D32EA7CE358F0B25D26203003F5DED";
|
|
20
|
+
/** Plain-text payload signed in the deterministic-signature assertion. */
|
|
21
|
+
readonly payload: "hello-smart-engines";
|
|
22
|
+
/** Output of `sign(hex(payload).upper, fixture.privateKey)`. */
|
|
23
|
+
readonly expectedSignature: "CFF9ABD65D3BBC985FE8A8C899DAC26B16DAB95B13AE2B2CB3DEAC2CA0E54F7791307B22971180D6016422EEE2E36ACFECCC7B7C3A1CB7701CE28D243E16BF03";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Reproduce the validator's verifier check verbatim.
|
|
27
|
+
*
|
|
28
|
+
* Mirrors `verifyXRPLSignature` at
|
|
29
|
+
* libs/security-core/src/auth/web3-auth.service.ts:328-350 — same hex
|
|
30
|
+
* canonicalization, same ripple-keypairs.verify entry point. Used by the
|
|
31
|
+
* signFn spec to cross-check the CLI's output WITHOUT importing the heavy
|
|
32
|
+
* NestJS-bound web3-auth.service.ts class graph.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validatorVerifyXrplSignature(publicKey: string, message: string, signature: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Build a throwaway tmp directory and return its path + a cleanup fn.
|
|
37
|
+
*
|
|
38
|
+
* Usage:
|
|
39
|
+
* const { dir, cleanup } = makeTempDir('hsuite-init-');
|
|
40
|
+
* afterEach(cleanup);
|
|
41
|
+
*/
|
|
42
|
+
export declare function makeTempDir(prefix?: string): {
|
|
43
|
+
dir: string;
|
|
44
|
+
cleanup: () => void;
|
|
45
|
+
};
|
|
46
|
+
/** Build the path for an env file inside a tmp dir. */
|
|
47
|
+
export declare function envPathIn(dir: string, name?: string): string;
|
|
48
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/fixtures.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY;;;;IAIvB,0EAA0E;;IAE1E,gEAAgE;;CAGxD,CAAC;AAEX;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAKT;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAqB,GAAG;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAMA;AAED,uDAAuD;AACvD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,SAAe,GAAG,MAAM,CAElE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XRPL_FIXTURE = void 0;
|
|
4
|
+
exports.validatorVerifyXrplSignature = validatorVerifyXrplSignature;
|
|
5
|
+
exports.makeTempDir = makeTempDir;
|
|
6
|
+
exports.envPathIn = envPathIn;
|
|
7
|
+
/**
|
|
8
|
+
* Shared test fixtures for the @hsuite/smart-engines-cli specs.
|
|
9
|
+
*
|
|
10
|
+
* Centralises the XRPL seed/address/pubkey we sign with, the expected
|
|
11
|
+
* deterministic signature for a canonical payload, and a tmp-dir helper
|
|
12
|
+
* so individual specs don't repeat boilerplate.
|
|
13
|
+
*
|
|
14
|
+
* The fixture seed is fresh (generated 2026-05-22 with xrpl.Wallet.generate)
|
|
15
|
+
* and is NOT funded on any network. Re-deriving from this seed yields the
|
|
16
|
+
* same address / pubkey / signature on every machine — that's the whole
|
|
17
|
+
* point of an ed25519-with-deterministic-K (RFC 8032) signer.
|
|
18
|
+
*/
|
|
19
|
+
const fs_1 = require("fs");
|
|
20
|
+
const os_1 = require("os");
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
/**
|
|
23
|
+
* Deterministic XRPL ed25519 fixture.
|
|
24
|
+
*
|
|
25
|
+
* Provenance — derived once with:
|
|
26
|
+
* node -e "const {Wallet}=require('xrpl'); const w=Wallet.fromSeed('sEdTyaBYHfQhWt9ycB9QJsRKH8UUEuD'); console.log(w.address, w.publicKey)"
|
|
27
|
+
*
|
|
28
|
+
* Expected signature derived by running the validator's exact verifier
|
|
29
|
+
* path (libs/security-core/src/auth/web3-auth.service.ts:334-340):
|
|
30
|
+
* const hex = Buffer.from(message, 'utf-8').toString('hex').toUpperCase();
|
|
31
|
+
* sign(hex, wallet.privateKey) // ripple-keypairs
|
|
32
|
+
*
|
|
33
|
+
* If `EXPECTED_SIGNATURE` drifts, the CLI's signFn no longer produces what
|
|
34
|
+
* the validator's web3-auth verifier accepts. That's an auth-contract
|
|
35
|
+
* regression — every developer's `subscribe`/`deploy` breaks silently.
|
|
36
|
+
*/
|
|
37
|
+
exports.XRPL_FIXTURE = {
|
|
38
|
+
seed: 'sEdTyaBYHfQhWt9ycB9QJsRKH8UUEuD',
|
|
39
|
+
address: 'rNHjsSoFgEMPZi4kE5rfw6c8k6tTUX8eng',
|
|
40
|
+
publicKey: 'ED652CD3EAB154510CBFCF4AEDEE4EAEB295D32EA7CE358F0B25D26203003F5DED',
|
|
41
|
+
/** Plain-text payload signed in the deterministic-signature assertion. */
|
|
42
|
+
payload: 'hello-smart-engines',
|
|
43
|
+
/** Output of `sign(hex(payload).upper, fixture.privateKey)`. */
|
|
44
|
+
expectedSignature: 'CFF9ABD65D3BBC985FE8A8C899DAC26B16DAB95B13AE2B2CB3DEAC2CA0E54F7791307B22971180D6016422EEE2E36ACFECCC7B7C3A1CB7701CE28D243E16BF03',
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Reproduce the validator's verifier check verbatim.
|
|
48
|
+
*
|
|
49
|
+
* Mirrors `verifyXRPLSignature` at
|
|
50
|
+
* libs/security-core/src/auth/web3-auth.service.ts:328-350 — same hex
|
|
51
|
+
* canonicalization, same ripple-keypairs.verify entry point. Used by the
|
|
52
|
+
* signFn spec to cross-check the CLI's output WITHOUT importing the heavy
|
|
53
|
+
* NestJS-bound web3-auth.service.ts class graph.
|
|
54
|
+
*/
|
|
55
|
+
function validatorVerifyXrplSignature(publicKey, message, signature) {
|
|
56
|
+
const messageHex = Buffer.from(message, 'utf-8').toString('hex').toUpperCase();
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
58
|
+
const { verify } = require('ripple-keypairs');
|
|
59
|
+
return verify(messageHex, signature, publicKey);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Build a throwaway tmp directory and return its path + a cleanup fn.
|
|
63
|
+
*
|
|
64
|
+
* Usage:
|
|
65
|
+
* const { dir, cleanup } = makeTempDir('hsuite-init-');
|
|
66
|
+
* afterEach(cleanup);
|
|
67
|
+
*/
|
|
68
|
+
function makeTempDir(prefix = 'hsuite-cli-spec-') {
|
|
69
|
+
const dir = (0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), prefix));
|
|
70
|
+
return {
|
|
71
|
+
dir,
|
|
72
|
+
cleanup: () => (0, fs_1.rmSync)(dir, { recursive: true, force: true }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Build the path for an env file inside a tmp dir. */
|
|
76
|
+
function envPathIn(dir, name = '.env.local') {
|
|
77
|
+
return (0, path_1.join)(dir, name);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/fixtures.ts"],"names":[],"mappings":";;;AAmDA,oEASC;AASD,kCASC;AAGD,8BAEC;AAnFD;;;;;;;;;;;GAWG;AACH,2BAAyC;AACzC,2BAA4B;AAC5B,+BAA4B;AAE5B;;;;;;;;;;;;;;GAcG;AACU,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,iCAAiC;IACvC,OAAO,EAAE,oCAAoC;IAC7C,SAAS,EAAE,oEAAoE;IAC/E,0EAA0E;IAC1E,OAAO,EAAE,qBAAqB;IAC9B,gEAAgE;IAChE,iBAAiB,EACf,kIAAkI;CAC5H,CAAC;AAEX;;;;;;;;GAQG;AACH,SAAgB,4BAA4B,CAC1C,SAAiB,EACjB,OAAe,EACf,SAAiB;IAEjB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/E,8DAA8D;IAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,MAAM,GAAG,kBAAkB;IAIrD,MAAM,GAAG,GAAG,IAAA,gBAAW,EAAC,IAAA,WAAI,EAAC,IAAA,WAAM,GAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,OAAO;QACL,GAAG;QACH,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,WAAM,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,SAAgB,SAAS,CAAC,GAAW,EAAE,IAAI,GAAG,YAAY;IACxD,OAAO,IAAA,WAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Public SDK-bootstrap host for the Smart Engines testnet. */
|
|
2
|
+
export declare const DEFAULT_GATEWAY = "https://gateway.testnet.hsuite.network";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the gateway URL to connect to. Bootstraps decentralized cluster
|
|
5
|
+
* discovery against `bootstrap`; on an empty registry or any failure,
|
|
6
|
+
* falls back to `bootstrap` itself (a working round-robin gateway).
|
|
7
|
+
*
|
|
8
|
+
* @param bootstrap fully-qualified bootstrap URL (the `--gateway` value)
|
|
9
|
+
* @returns the gateway URL the CLI should talk to
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveGatewayUrl(bootstrap: string): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=cluster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster.d.ts","sourceRoot":"","sources":["../../src/_lib/cluster.ts"],"names":[],"mappings":"AAiBA,+DAA+D;AAC/D,eAAO,MAAM,eAAe,2CAA2C,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY1E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_GATEWAY = void 0;
|
|
4
|
+
exports.resolveGatewayUrl = resolveGatewayUrl;
|
|
5
|
+
/**
|
|
6
|
+
* Cluster bootstrap — resolve a working gateway URL via decentralized
|
|
7
|
+
* cluster discovery.
|
|
8
|
+
*
|
|
9
|
+
* The CLI bootstraps against the public round-robin host
|
|
10
|
+
* `gateway.testnet.hsuite.network` — 3 DNS A-records over the 3 genesis
|
|
11
|
+
* cluster ingress LBs (HANDOFF arc-v13-do-deploy §11). It fetches the
|
|
12
|
+
* cluster registry through the SDK's `ClusterDiscoveryClient` and picks a
|
|
13
|
+
* random active cluster, so the CLI follows permissionless cluster
|
|
14
|
+
* join/leave with no code edits.
|
|
15
|
+
*
|
|
16
|
+
* If the registry is empty or unreachable it falls back to the bootstrap
|
|
17
|
+
* host itself — which is already a working gateway, round-robined across
|
|
18
|
+
* the clusters — so the CLI degrades gracefully instead of failing.
|
|
19
|
+
*/
|
|
20
|
+
const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
|
|
21
|
+
/** Public SDK-bootstrap host for the Smart Engines testnet. */
|
|
22
|
+
exports.DEFAULT_GATEWAY = 'https://gateway.testnet.hsuite.network';
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the gateway URL to connect to. Bootstraps decentralized cluster
|
|
25
|
+
* discovery against `bootstrap`; on an empty registry or any failure,
|
|
26
|
+
* falls back to `bootstrap` itself (a working round-robin gateway).
|
|
27
|
+
*
|
|
28
|
+
* @param bootstrap fully-qualified bootstrap URL (the `--gateway` value)
|
|
29
|
+
* @returns the gateway URL the CLI should talk to
|
|
30
|
+
*/
|
|
31
|
+
async function resolveGatewayUrl(bootstrap) {
|
|
32
|
+
const allowInsecure = bootstrap.startsWith('http://');
|
|
33
|
+
try {
|
|
34
|
+
const discovery = new smart_engines_sdk_1.ClusterDiscoveryClient({
|
|
35
|
+
bootstrap: [bootstrap],
|
|
36
|
+
allowInsecure,
|
|
37
|
+
});
|
|
38
|
+
const url = await discovery.getRandomGatewayUrl();
|
|
39
|
+
return url ?? bootstrap;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return bootstrap;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=cluster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/_lib/cluster.ts"],"names":[],"mappings":";;;AA4BA,8CAYC;AAxCD;;;;;;;;;;;;;;GAcG;AACH,iEAAmE;AAEnE,+DAA+D;AAClD,QAAA,eAAe,GAAG,wCAAwC,CAAC;AAExE;;;;;;;GAOG;AACI,KAAK,UAAU,iBAAiB,CAAC,SAAiB;IACvD,MAAM,aAAa,GAAG,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACtD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,0CAAsB,CAAC;YAC3C,SAAS,EAAE,CAAC,SAAS,CAAC;YACtB,aAAa;SACd,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,mBAAmB,EAAE,CAAC;QAClD,OAAO,GAAG,IAAI,SAAS,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgEpC,eAAO,MAAM,aAAa,SAyItB,CAAC"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -61,6 +61,7 @@ const path_1 = require("path");
|
|
|
61
61
|
const readline = __importStar(require("readline"));
|
|
62
62
|
const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
|
|
63
63
|
const env_1 = require("../_lib/env");
|
|
64
|
+
const cluster_1 = require("../_lib/cluster");
|
|
64
65
|
/**
|
|
65
66
|
* Block until the user presses Enter on stdin. Skipped in non-interactive
|
|
66
67
|
* mode (env `CI=true`, no TTY, or `--non-interactive` flag) — caller is
|
|
@@ -88,7 +89,7 @@ exports.deployCommand = new commander_1.Command('deploy')
|
|
|
88
89
|
.description('Deploy a smart-app from a JSON manifest (init → push → deploy)')
|
|
89
90
|
.requiredOption('--manifest <file>', 'JSON manifest path')
|
|
90
91
|
.option('--env <file>', 'Env file with auth creds', '.env.local')
|
|
91
|
-
.option('--gateway <url>', '
|
|
92
|
+
.option('--gateway <url>', 'Bootstrap host — seed for decentralized cluster discovery', cluster_1.DEFAULT_GATEWAY)
|
|
92
93
|
.option('--non-interactive', 'Skip the wait-for-Enter between init and deploy', false)
|
|
93
94
|
.action(async (opts) => {
|
|
94
95
|
console.log(chalk_1.default.bold.cyan('\n hsuite deploy\n'));
|
|
@@ -109,17 +110,27 @@ exports.deployCommand = new commander_1.Command('deploy')
|
|
|
109
110
|
console.log(chalk_1.default.gray(` name: ${manifest.name}`));
|
|
110
111
|
console.log(chalk_1.default.gray(` port: ${manifest.port}`));
|
|
111
112
|
console.log(chalk_1.default.gray(` services: ${manifest.services.join(', ') || '(none)'}`));
|
|
112
|
-
console.log(chalk_1.default.gray(` tag:
|
|
113
|
-
console.log(chalk_1.default.gray(`
|
|
113
|
+
console.log(chalk_1.default.gray(` tag: ${manifest.tag}`));
|
|
114
|
+
console.log(chalk_1.default.gray(` bootstrap: ${opts.gateway}\n`));
|
|
114
115
|
const env = (0, env_1.readEnv)(opts.env);
|
|
115
116
|
const signer = (0, env_1.buildSignerFromEnv)(env);
|
|
117
|
+
// Decentralized cluster discovery: bootstrap → registry → random node.
|
|
118
|
+
// Falls back to the bootstrap host (a working round-robin gateway).
|
|
119
|
+
let spinner = (0, ora_1.default)('discovering cluster...').start();
|
|
120
|
+
const gatewayUrl = await (0, cluster_1.resolveGatewayUrl)(opts.gateway);
|
|
121
|
+
spinner.succeed(`cluster: ${gatewayUrl}`);
|
|
116
122
|
const client = new smart_engines_sdk_1.BaasClient({
|
|
117
|
-
hostUrl:
|
|
123
|
+
hostUrl: gatewayUrl,
|
|
118
124
|
appId: env.get('SUBSCRIPTION_APP_ID') ?? 'pending',
|
|
119
|
-
allowInsecure:
|
|
120
|
-
|
|
125
|
+
allowInsecure: gatewayUrl.startsWith('http://'),
|
|
126
|
+
// Paths are the apps' real /api/* routes; the ingress routes each
|
|
127
|
+
// prefix straight to its service — no host-proxy prefix.
|
|
128
|
+
pathPrefix: '',
|
|
129
|
+
// deployment.init runs the smart-app entity DKG ceremony synchronously
|
|
130
|
+
// across the validator cluster — well past the 30s default. 3 min.
|
|
131
|
+
timeout: 180_000,
|
|
121
132
|
});
|
|
122
|
-
|
|
133
|
+
spinner = (0, ora_1.default)('authenticate...').start();
|
|
123
134
|
try {
|
|
124
135
|
await client.authenticate({
|
|
125
136
|
chain: signer.chain,
|
|
@@ -184,6 +195,7 @@ exports.deployCommand = new commander_1.Command('deploy')
|
|
|
184
195
|
try {
|
|
185
196
|
deployRes = await client.deployment.deploy(init.appId, {
|
|
186
197
|
tag: manifest.tag,
|
|
198
|
+
port: manifest.port,
|
|
187
199
|
replicas: manifest.replicas ?? 1,
|
|
188
200
|
env: manifest.env,
|
|
189
201
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,yCAAoC;AACpC,kDAA0B;AAC1B,8CAAsB;AACtB,2BAA8D;AAC9D,+BAA+B;AAC/B,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ACd,IAAI,CAAC;QACH,SAAS,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE;YACrD,GAAG,EAAE,QAAQ,CAAC,GAAG;YACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,CAAC;YAChC,GAAG,EAAE,QAAQ,CAAC,GAAG;SAClB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,kBAAmB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,aAAa,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;IAE9C,IAAA,eAAS,EAAC,IAAI,CAAC,GAAG,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hsuite governance simulate` — dry-run a `GovernanceMolecule.validate(...)`
|
|
3
|
+
* against fixture data without depending on the rules-engine package.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* hsuite governance simulate --proposal <file> [--server <url>] [--format json|plain]
|
|
7
|
+
*
|
|
8
|
+
* The `<file>` is a JSON document of shape `{ config, context }` matching the
|
|
9
|
+
* SDK's `GovernanceSimulateRequest` type.
|
|
10
|
+
*
|
|
11
|
+
* Exit codes:
|
|
12
|
+
* 0 — `result.isValid === true`
|
|
13
|
+
* 1 — `result.isValid === false` (proposal/vote/etc. rejected by the molecule)
|
|
14
|
+
* 2 — input or transport error (missing file, malformed JSON, HTTP failure)
|
|
15
|
+
*/
|
|
16
|
+
import { Command } from 'commander';
|
|
17
|
+
import { SmartEngineClient } from '@hsuite/smart-engines-sdk';
|
|
18
|
+
/**
|
|
19
|
+
* Internal SDK builder — exposed for tests to inject a stub.
|
|
20
|
+
*
|
|
21
|
+
* Each call returns a `SmartEngineClient` configured for the given server.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildSdkClient(server: string): SmartEngineClient;
|
|
24
|
+
/**
|
|
25
|
+
* Pure logic separated from `commander` for testability.
|
|
26
|
+
*
|
|
27
|
+
* Returns the exit code rather than calling `process.exit`. The action
|
|
28
|
+
* handler wraps this and exits.
|
|
29
|
+
*/
|
|
30
|
+
export declare function runGovernanceSimulate(opts: {
|
|
31
|
+
proposal: string;
|
|
32
|
+
server?: string;
|
|
33
|
+
format?: 'json' | 'plain';
|
|
34
|
+
/** Test seam — override the SDK constructor. */
|
|
35
|
+
clientFactory?: (server: string) => Pick<SmartEngineClient, 'governance'>;
|
|
36
|
+
/** Test seam — capture stdout instead of writing to process. */
|
|
37
|
+
out?: (line: string) => void;
|
|
38
|
+
/** Test seam — capture stderr instead of writing to process. */
|
|
39
|
+
err?: (line: string) => void;
|
|
40
|
+
}): Promise<number>;
|
|
41
|
+
export declare const governanceCommand: Command;
|
|
42
|
+
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/commands/governance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAiD9D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAKhE;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,gDAAgD;IAChD,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;IAC1E,gEAAgE;IAChE,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,gEAAgE;IAChE,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CA+ClB;AAED,eAAO,MAAM,iBAAiB,SAiB3B,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.governanceCommand = void 0;
|
|
7
|
+
exports.buildSdkClient = buildSdkClient;
|
|
8
|
+
exports.runGovernanceSimulate = runGovernanceSimulate;
|
|
9
|
+
/**
|
|
10
|
+
* `hsuite governance simulate` — dry-run a `GovernanceMolecule.validate(...)`
|
|
11
|
+
* against fixture data without depending on the rules-engine package.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* hsuite governance simulate --proposal <file> [--server <url>] [--format json|plain]
|
|
15
|
+
*
|
|
16
|
+
* The `<file>` is a JSON document of shape `{ config, context }` matching the
|
|
17
|
+
* SDK's `GovernanceSimulateRequest` type.
|
|
18
|
+
*
|
|
19
|
+
* Exit codes:
|
|
20
|
+
* 0 — `result.isValid === true`
|
|
21
|
+
* 1 — `result.isValid === false` (proposal/vote/etc. rejected by the molecule)
|
|
22
|
+
* 2 — input or transport error (missing file, malformed JSON, HTTP failure)
|
|
23
|
+
*/
|
|
24
|
+
const commander_1 = require("commander");
|
|
25
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
26
|
+
const fs_1 = require("fs");
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
|
|
29
|
+
const DEFAULT_SERVER = 'https://v3-testnet-gateway.hsuite.network';
|
|
30
|
+
/** Exit-code-bearing error so the action handler can branch precisely. */
|
|
31
|
+
class CliExit extends Error {
|
|
32
|
+
code;
|
|
33
|
+
constructor(code, message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.code = code;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function readProposal(file) {
|
|
39
|
+
const path = (0, path_1.resolve)(file);
|
|
40
|
+
if (!(0, fs_1.existsSync)(path)) {
|
|
41
|
+
throw new CliExit(2, `proposal file not found: ${path}`);
|
|
42
|
+
}
|
|
43
|
+
let raw;
|
|
44
|
+
try {
|
|
45
|
+
raw = (0, fs_1.readFileSync)(path, 'utf8');
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
throw new CliExit(2, `unable to read proposal file: ${err.message}`);
|
|
49
|
+
}
|
|
50
|
+
let parsed;
|
|
51
|
+
try {
|
|
52
|
+
parsed = JSON.parse(raw);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
throw new CliExit(2, `malformed JSON in proposal file: ${err.message}`);
|
|
56
|
+
}
|
|
57
|
+
if (!parsed ||
|
|
58
|
+
typeof parsed !== 'object' ||
|
|
59
|
+
!('config' in parsed) ||
|
|
60
|
+
!('context' in parsed)) {
|
|
61
|
+
throw new CliExit(2, 'proposal file must be JSON with shape { "config": {...}, "context": {...} }');
|
|
62
|
+
}
|
|
63
|
+
return parsed;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Internal SDK builder — exposed for tests to inject a stub.
|
|
67
|
+
*
|
|
68
|
+
* Each call returns a `SmartEngineClient` configured for the given server.
|
|
69
|
+
*/
|
|
70
|
+
function buildSdkClient(server) {
|
|
71
|
+
return new smart_engines_sdk_1.SmartEngineClient({
|
|
72
|
+
baseUrl: server,
|
|
73
|
+
allowInsecure: server.startsWith('http://'),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Pure logic separated from `commander` for testability.
|
|
78
|
+
*
|
|
79
|
+
* Returns the exit code rather than calling `process.exit`. The action
|
|
80
|
+
* handler wraps this and exits.
|
|
81
|
+
*/
|
|
82
|
+
async function runGovernanceSimulate(opts) {
|
|
83
|
+
const write = opts.out ?? ((line) => console.log(line));
|
|
84
|
+
const writeErr = opts.err ?? ((line) => console.error(line));
|
|
85
|
+
const server = opts.server ?? DEFAULT_SERVER;
|
|
86
|
+
const format = opts.format ?? 'plain';
|
|
87
|
+
let request;
|
|
88
|
+
try {
|
|
89
|
+
request = readProposal(opts.proposal);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
if (err instanceof CliExit) {
|
|
93
|
+
writeErr(chalk_1.default.red(` ${err.message}`));
|
|
94
|
+
return err.code;
|
|
95
|
+
}
|
|
96
|
+
writeErr(chalk_1.default.red(` unexpected error: ${err.message}`));
|
|
97
|
+
return 2;
|
|
98
|
+
}
|
|
99
|
+
const client = (opts.clientFactory ?? buildSdkClient)(server);
|
|
100
|
+
let result;
|
|
101
|
+
try {
|
|
102
|
+
result = await client.governance.simulate(request);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
writeErr(chalk_1.default.red(` simulate failed: ${err.message}`));
|
|
106
|
+
return 2;
|
|
107
|
+
}
|
|
108
|
+
if (format === 'json') {
|
|
109
|
+
write(JSON.stringify(result, null, 2));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const status = result.isValid
|
|
113
|
+
? chalk_1.default.bold.green('VALID')
|
|
114
|
+
: chalk_1.default.bold.red('INVALID');
|
|
115
|
+
write(` ${status}`);
|
|
116
|
+
if (result.reason) {
|
|
117
|
+
write(chalk_1.default.gray(` reason: ${result.reason}`));
|
|
118
|
+
}
|
|
119
|
+
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
120
|
+
write(chalk_1.default.gray(` metadata: ${JSON.stringify(result.metadata)}`));
|
|
121
|
+
}
|
|
122
|
+
if (result.validatedAt) {
|
|
123
|
+
write(chalk_1.default.gray(` validated: ${result.validatedAt}`));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return result.isValid ? 0 : 1;
|
|
127
|
+
}
|
|
128
|
+
exports.governanceCommand = new commander_1.Command('governance')
|
|
129
|
+
.description('Governance proposal dry-run')
|
|
130
|
+
.addCommand(new commander_1.Command('simulate')
|
|
131
|
+
.description('Dry-run a GovernanceMolecule.validate(...) against a fixture file')
|
|
132
|
+
.requiredOption('--proposal <file>', 'JSON file with shape { config, context }')
|
|
133
|
+
.option('--server <url>', 'Validator base URL', DEFAULT_SERVER)
|
|
134
|
+
.option('--format <format>', 'Output format: json | plain', 'plain')
|
|
135
|
+
.action(async (opts) => {
|
|
136
|
+
const format = opts.format === 'json' ? 'json' : 'plain';
|
|
137
|
+
const code = await runGovernanceSimulate({
|
|
138
|
+
proposal: opts.proposal,
|
|
139
|
+
server: opts.server,
|
|
140
|
+
format,
|
|
141
|
+
});
|
|
142
|
+
process.exit(code);
|
|
143
|
+
}));
|
|
144
|
+
//# sourceMappingURL=governance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/commands/governance.ts"],"names":[],"mappings":";;;;;;AAyEA,wCAKC;AAQD,sDAyDC;AA/ID;;;;;;;;;;;;;;GAcG;AACH,yCAAoC;AACpC,kDAA0B;AAC1B,2BAA8C;AAC9C,+BAA+B;AAC/B,iEAA8D;AAM9D,MAAM,cAAc,GAAG,2CAA2C,CAAC;AAEnE,0EAA0E;AAC1E,MAAM,OAAQ,SAAQ,KAAK;IAEP;IADlB,YACkB,IAAY,EAC5B,OAAe;QAEf,KAAK,CAAC,OAA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C;KACpB,WAAW,CAAC,mEAAmE,CAAC;KAChF,cAAc,CAAC,mBAAmB,EAAE,0CAA0C,CAAC;KAC/E,MAAM,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,CAAC;KAC9D,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,EAAE,OAAO,CAAC;KACnE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IACzD,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC;QACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM;KACP,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC,CAAC,CACL,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hsuite hist-balance query` — ad-hoc historical-balance query.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the SDK's `HistoricalBalanceClient` so operators / smart-app devs
|
|
5
|
+
* can sanity-check archive reads from a terminal without writing a script:
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* hsuite hist-balance query \
|
|
9
|
+
* --chain hedera \
|
|
10
|
+
* --entity 0.0.5555 \
|
|
11
|
+
* --account 0.0.1234 \
|
|
12
|
+
* --at 1700000000 \
|
|
13
|
+
* --server https://validator.example.com
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Exit codes:
|
|
17
|
+
* 0 success
|
|
18
|
+
* 1 input error (missing/invalid flag, unsupported chain, etc.)
|
|
19
|
+
* 2 transport or server error (network, 4xx, 5xx)
|
|
20
|
+
*
|
|
21
|
+
* Zero internal `@hsuite/*` deps beyond `@hsuite/smart-engines-sdk`, which
|
|
22
|
+
* itself is decoupled from server-side libs by design (PR-CLEANUP #576).
|
|
23
|
+
*/
|
|
24
|
+
import { Command } from 'commander';
|
|
25
|
+
import { HistoricalBalanceClient } from '@hsuite/smart-engines-sdk';
|
|
26
|
+
type RunArgs = {
|
|
27
|
+
chain?: string;
|
|
28
|
+
entity?: string;
|
|
29
|
+
account?: string;
|
|
30
|
+
at?: string;
|
|
31
|
+
server?: string;
|
|
32
|
+
format?: string;
|
|
33
|
+
authToken?: string;
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Pure-function core (no `process.exit`, no `console.log`) so tests can
|
|
38
|
+
* exercise the full code path and assert on the returned exit code +
|
|
39
|
+
* captured streams.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runHistBalanceQuery(args: RunArgs, io: {
|
|
42
|
+
out: (msg: string) => void;
|
|
43
|
+
err: (msg: string) => void;
|
|
44
|
+
sdk?: (config: {
|
|
45
|
+
baseUrl: string;
|
|
46
|
+
authToken?: string;
|
|
47
|
+
apiKey?: string;
|
|
48
|
+
}) => Pick<HistoricalBalanceClient, 'getBalance'>;
|
|
49
|
+
}): Promise<number>;
|
|
50
|
+
export declare const histBalanceCommand: Command;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=hist-balance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hist-balance.d.ts","sourceRoot":"","sources":["../../src/commands/hist-balance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,uBAAuB,EAGxB,MAAM,2BAA2B,CAAC;AAEnC,KAAK,OAAO,GAAG;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,OAAO,EACb,EAAE,EAAE;IACF,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,KAAK,IAAI,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;CACnD,GACA,OAAO,CAAC,MAAM,CAAC,CA6FjB;AAED,eAAO,MAAM,kBAAkB,SAE9B,CAAC"}
|