meridian-core 0.1.0
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/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +46 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/analyze.d.ts +8 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +78 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/field.d.ts +8 -0
- package/dist/commands/field.d.ts.map +1 -0
- package/dist/commands/field.js +46 -0
- package/dist/commands/field.js.map +1 -0
- package/dist/commands/gravity.d.ts +8 -0
- package/dist/commands/gravity.d.ts.map +1 -0
- package/dist/commands/gravity.js +47 -0
- package/dist/commands/gravity.js.map +1 -0
- package/dist/commands/trace.d.ts +8 -0
- package/dist/commands/trace.d.ts.map +1 -0
- package/dist/commands/trace.js +37 -0
- package/dist/commands/trace.js.map +1 -0
- package/dist/commands/version.d.ts +8 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +21 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/errors.d.ts +21 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +37 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/input.d.ts +11 -0
- package/dist/lib/input.d.ts.map +1 -0
- package/dist/lib/input.js +38 -0
- package/dist/lib/input.js.map +1 -0
- package/dist/lib/manifest.d.ts +10 -0
- package/dist/lib/manifest.d.ts.map +1 -0
- package/dist/lib/manifest.js +35 -0
- package/dist/lib/manifest.js.map +1 -0
- package/dist/lib/options.d.ts +26 -0
- package/dist/lib/options.d.ts.map +1 -0
- package/dist/lib/options.js +44 -0
- package/dist/lib/options.js.map +1 -0
- package/dist/lib/output.d.ts +32 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +156 -0
- package/dist/lib/output.js.map +1 -0
- package/package.json +39 -0
- package/src/cli.ts +54 -0
- package/src/commands/analyze.ts +103 -0
- package/src/commands/field.ts +66 -0
- package/src/commands/gravity.ts +70 -0
- package/src/commands/trace.ts +51 -0
- package/src/commands/version.ts +21 -0
- package/src/index.ts +7 -0
- package/src/lib/errors.ts +42 -0
- package/src/lib/input.test.ts +38 -0
- package/src/lib/input.ts +43 -0
- package/src/lib/manifest.test.ts +60 -0
- package/src/lib/manifest.ts +41 -0
- package/src/lib/options.test.ts +27 -0
- package/src/lib/options.ts +47 -0
- package/src/lib/output.ts +180 -0
- package/tsconfig.json +10 -0
- package/vitest.config.ts +8 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Build the root `meridian` commander program with all subcommands attached.
|
|
4
|
+
*
|
|
5
|
+
* @returns Configured commander Command ready to parse argv
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildProgram(): Command;
|
|
8
|
+
/**
|
|
9
|
+
* Parse argv and run the MERIDIAN CLI.
|
|
10
|
+
*
|
|
11
|
+
* @param argv - Process argv (defaults to process.argv)
|
|
12
|
+
*/
|
|
13
|
+
export declare function runCli(argv?: string[]): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CA8BtC;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzE"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { MERIDIAN_VERSION } from '@meridian/core';
|
|
3
|
+
import { analyzeCommand } from './commands/analyze.js';
|
|
4
|
+
import { traceCommand } from './commands/trace.js';
|
|
5
|
+
import { fieldCommand } from './commands/field.js';
|
|
6
|
+
import { gravityCommand } from './commands/gravity.js';
|
|
7
|
+
import { versionCommand } from './commands/version.js';
|
|
8
|
+
/**
|
|
9
|
+
* Build the root `meridian` commander program with all subcommands attached.
|
|
10
|
+
*
|
|
11
|
+
* @returns Configured commander Command ready to parse argv
|
|
12
|
+
*/
|
|
13
|
+
export function buildProgram() {
|
|
14
|
+
const program = new Command('meridian')
|
|
15
|
+
.description('MERIDIAN — pre-execution intelligence for Stellar developers.\n' +
|
|
16
|
+
'Know what crosses before it does.')
|
|
17
|
+
.version(MERIDIAN_VERSION, '-v, --version', 'Print the MERIDIAN version')
|
|
18
|
+
.addHelpText('after', `
|
|
19
|
+
Examples:
|
|
20
|
+
$ meridian analyze <base64-xdr> --network testnet
|
|
21
|
+
$ cat tx.xdr | meridian analyze --network mainnet --json
|
|
22
|
+
$ meridian trace --file tx.xdr --network testnet
|
|
23
|
+
$ meridian gravity <base64-xdr> --ecosystem manifest.json
|
|
24
|
+
|
|
25
|
+
Environment:
|
|
26
|
+
STELLAR_RPC_TESTNET Soroban RPC endpoint for testnet (or use --rpc-url)
|
|
27
|
+
STELLAR_RPC_MAINNET Soroban RPC endpoint for mainnet (or use --rpc-url)
|
|
28
|
+
ANTHROPIC_API_KEY Claude API key for BRIEF synthesis (optional, falls back to a deterministic brief)
|
|
29
|
+
`);
|
|
30
|
+
program.addCommand(analyzeCommand(), { isDefault: true });
|
|
31
|
+
program.addCommand(traceCommand());
|
|
32
|
+
program.addCommand(fieldCommand());
|
|
33
|
+
program.addCommand(gravityCommand());
|
|
34
|
+
program.addCommand(versionCommand());
|
|
35
|
+
return program;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse argv and run the MERIDIAN CLI.
|
|
39
|
+
*
|
|
40
|
+
* @param argv - Process argv (defaults to process.argv)
|
|
41
|
+
*/
|
|
42
|
+
export async function runCli(argv = process.argv) {
|
|
43
|
+
const program = buildProgram();
|
|
44
|
+
await program.parseAsync(argv);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;SACpC,WAAW,CACV,iEAAiE;QAC/D,mCAAmC,CACtC;SACA,OAAO,CAAC,gBAAgB,EAAE,eAAe,EAAE,4BAA4B,CAAC;SACxE,WAAW,CACV,OAAO,EACP;;;;;;;;;;;CAWL,CACI,CAAC;IAEJ,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;IACnC,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;IACnC,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;IAErC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAiB,OAAO,CAAC,IAAI;IACxD,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAC/B,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/commands/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBpC;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CA0ExC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { analyze } from '@meridian/core';
|
|
3
|
+
import { synthesizeBrief, generateFallbackBrief } from '@meridian/ai';
|
|
4
|
+
import { resolveTxInput } from '../lib/input.js';
|
|
5
|
+
import { loadManifest } from '../lib/manifest.js';
|
|
6
|
+
import { failWithError, failWithMeridianError, isMeridianError } from '../lib/errors.js';
|
|
7
|
+
import { printAnalysis, printJson } from '../lib/output.js';
|
|
8
|
+
import { parseThreshold, withCommonOptions } from '../lib/options.js';
|
|
9
|
+
/**
|
|
10
|
+
* Build the `meridian analyze` subcommand (default command).
|
|
11
|
+
*
|
|
12
|
+
* @returns Configured commander Command
|
|
13
|
+
*/
|
|
14
|
+
export function analyzeCommand() {
|
|
15
|
+
const command = new Command('analyze').description('Run the full MERIDIAN pipeline (TRACE + FIELD + GRAVITY + BRIEF) on a transaction');
|
|
16
|
+
withCommonOptions(command)
|
|
17
|
+
.option('--skip-field', 'Skip the FIELD dependency-mapping layer')
|
|
18
|
+
.option('--skip-gravity', 'Skip the GRAVITY blast-radius layer')
|
|
19
|
+
.option('--confidence-threshold <n>', 'Minimum confidence required for a CLEAR verdict', parseThreshold)
|
|
20
|
+
.option('--no-brief', 'Skip GenAI BRIEF synthesis (structured layers only)')
|
|
21
|
+
.option('--api-key <key>', 'Anthropic API key for BRIEF synthesis (else read from env)')
|
|
22
|
+
.action(async (tx, options) => {
|
|
23
|
+
try {
|
|
24
|
+
const txXdr = await resolveTxInput(tx, options.file);
|
|
25
|
+
const ecosystem = await loadManifest(options.ecosystem);
|
|
26
|
+
const result = await analyze({
|
|
27
|
+
tx: txXdr,
|
|
28
|
+
network: options.network,
|
|
29
|
+
ecosystem,
|
|
30
|
+
options: {
|
|
31
|
+
skip_field: options.skipField,
|
|
32
|
+
skip_gravity: options.skipGravity,
|
|
33
|
+
confidence_threshold: options.confidenceThreshold,
|
|
34
|
+
rpc_url: options.rpcUrl,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
if (isMeridianError(result)) {
|
|
38
|
+
if (options.json) {
|
|
39
|
+
printJson(result);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
failWithMeridianError(result);
|
|
43
|
+
}
|
|
44
|
+
let brief = 'BRIEF synthesis skipped (--no-brief).';
|
|
45
|
+
let warnings = result.warnings;
|
|
46
|
+
if (options.brief) {
|
|
47
|
+
const briefInput = {
|
|
48
|
+
verdict: result.verdict,
|
|
49
|
+
confidence: result.confidence,
|
|
50
|
+
trace: result.trace,
|
|
51
|
+
field: result.field,
|
|
52
|
+
gravity: result.gravity,
|
|
53
|
+
fix_sequence: result.fix_sequence,
|
|
54
|
+
warnings: result.warnings,
|
|
55
|
+
};
|
|
56
|
+
const briefResult = await synthesizeBrief(briefInput, { apiKey: options.apiKey });
|
|
57
|
+
if (isMeridianError(briefResult)) {
|
|
58
|
+
brief = generateFallbackBrief(briefInput);
|
|
59
|
+
warnings = [...(result.warnings ?? []), briefResult.error];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
brief = briefResult;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const response = { ...result, brief, warnings };
|
|
66
|
+
if (options.json) {
|
|
67
|
+
printJson(response);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
printAnalysis(response);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
failWithError(err);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return command;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=analyze.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../src/commands/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAetE;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,CAChD,mFAAmF,CACpF,CAAC;IAEF,iBAAiB,CAAC,OAAO,CAAC;SACvB,MAAM,CAAC,cAAc,EAAE,yCAAyC,CAAC;SACjE,MAAM,CAAC,gBAAgB,EAAE,qCAAqC,CAAC;SAC/D,MAAM,CAAC,4BAA4B,EAAE,iDAAiD,EAAE,cAAc,CAAC;SACvG,MAAM,CAAC,YAAY,EAAE,qDAAqD,CAAC;SAC3E,MAAM,CAAC,iBAAiB,EAAE,4DAA4D,CAAC;SACvF,MAAM,CAAC,KAAK,EAAE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AAe,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;gBAElF,IAAI,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;oBACjC,KAAK,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;oBAC1C,QAAQ,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;gBAC7D,CAAC;qBAAM,CAAC;oBACN,KAAK,GAAG,WAAW,CAAC;gBACtB,CAAC;YACH,CAAC;YAED,MAAM,QAAQ,GAAoB,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;YAEjE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,SAAS,CAAC,QAAQ,CAAC,CAAC;gBACpB,OAAO;YACT,CAAC;YAED,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,aAAa,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/commands/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CA2CtC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildFieldGraph, trace } from '@meridian/core';
|
|
3
|
+
import { resolveTxInput } from '../lib/input.js';
|
|
4
|
+
import { loadManifest } from '../lib/manifest.js';
|
|
5
|
+
import { failWithError, failWithMeridianError, isMeridianError } from '../lib/errors.js';
|
|
6
|
+
import { printField, printJson } from '../lib/output.js';
|
|
7
|
+
import { withCommonOptions } from '../lib/options.js';
|
|
8
|
+
/**
|
|
9
|
+
* Build the `meridian field` subcommand.
|
|
10
|
+
*
|
|
11
|
+
* @returns Configured commander Command
|
|
12
|
+
*/
|
|
13
|
+
export function fieldCommand() {
|
|
14
|
+
const command = new Command('field').description('Run TRACE + FIELD — map the dependency graph touched by a transaction');
|
|
15
|
+
withCommonOptions(command).action(async (tx, options) => {
|
|
16
|
+
try {
|
|
17
|
+
const txXdr = await resolveTxInput(tx, options.file);
|
|
18
|
+
const manifest = await loadManifest(options.ecosystem);
|
|
19
|
+
const traceResult = await trace(txXdr, { network: options.network, rpcUrl: options.rpcUrl });
|
|
20
|
+
if (isMeridianError(traceResult)) {
|
|
21
|
+
if (options.json) {
|
|
22
|
+
printJson(traceResult);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
failWithMeridianError(traceResult);
|
|
26
|
+
}
|
|
27
|
+
const fieldResult = buildFieldGraph(traceResult, {
|
|
28
|
+
ledgerSequence: 0,
|
|
29
|
+
latestLedger: 0,
|
|
30
|
+
footprintContracts: [],
|
|
31
|
+
readOnly: [],
|
|
32
|
+
readWrite: [],
|
|
33
|
+
}, { network: options.network, manifest });
|
|
34
|
+
if (options.json) {
|
|
35
|
+
printJson(fieldResult);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
printField(fieldResult);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
failWithError(err);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return command;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/commands/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,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ACd,EACD,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,CACvC,CAAC;YAEF,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,SAAS,CAAC,WAAW,CAAC,CAAC;gBACvB,OAAO;YACT,CAAC;YAED,UAAU,CAAC,WAAW,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,aAAa,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gravity.d.ts","sourceRoot":"","sources":["../../src/commands/gravity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CA+CxC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildFieldGraph, scoreGravity, trace } from '@meridian/core';
|
|
3
|
+
import { resolveTxInput } from '../lib/input.js';
|
|
4
|
+
import { loadManifest } from '../lib/manifest.js';
|
|
5
|
+
import { failWithError, failWithMeridianError, isMeridianError } from '../lib/errors.js';
|
|
6
|
+
import { printGravity, printJson } from '../lib/output.js';
|
|
7
|
+
import { withCommonOptions } from '../lib/options.js';
|
|
8
|
+
/**
|
|
9
|
+
* Build the `meridian gravity` subcommand.
|
|
10
|
+
*
|
|
11
|
+
* @returns Configured commander Command
|
|
12
|
+
*/
|
|
13
|
+
export function gravityCommand() {
|
|
14
|
+
const command = new Command('gravity').description('Run TRACE + FIELD + GRAVITY — score the blast radius of a transaction');
|
|
15
|
+
withCommonOptions(command).action(async (tx, options) => {
|
|
16
|
+
try {
|
|
17
|
+
const txXdr = await resolveTxInput(tx, options.file);
|
|
18
|
+
const manifest = await loadManifest(options.ecosystem);
|
|
19
|
+
const traceResult = await trace(txXdr, { network: options.network, rpcUrl: options.rpcUrl });
|
|
20
|
+
if (isMeridianError(traceResult)) {
|
|
21
|
+
if (options.json) {
|
|
22
|
+
printJson(traceResult);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
failWithMeridianError(traceResult);
|
|
26
|
+
}
|
|
27
|
+
const fieldResult = buildFieldGraph(traceResult, {
|
|
28
|
+
ledgerSequence: 0,
|
|
29
|
+
latestLedger: 0,
|
|
30
|
+
footprintContracts: [],
|
|
31
|
+
readOnly: [],
|
|
32
|
+
readWrite: [],
|
|
33
|
+
}, { network: options.network, manifest });
|
|
34
|
+
const gravityResult = scoreGravity(traceResult, fieldResult, { manifest });
|
|
35
|
+
if (options.json) {
|
|
36
|
+
printJson(gravityResult);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
printGravity(gravityResult);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
failWithError(err);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return command;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=gravity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gravity.js","sourceRoot":"","sources":["../../src/commands/gravity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAUtD;;;;GAIG;AAC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CAAC,aAAa,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,aAAa,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/commands/trace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CA8BtC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { trace } from '@meridian/core';
|
|
3
|
+
import { resolveTxInput } from '../lib/input.js';
|
|
4
|
+
import { failWithError, failWithMeridianError, isMeridianError } from '../lib/errors.js';
|
|
5
|
+
import { printJson, printTrace } from '../lib/output.js';
|
|
6
|
+
import { withCommonOptions } from '../lib/options.js';
|
|
7
|
+
/**
|
|
8
|
+
* Build the `meridian trace` subcommand.
|
|
9
|
+
*
|
|
10
|
+
* @returns Configured commander Command
|
|
11
|
+
*/
|
|
12
|
+
export function traceCommand() {
|
|
13
|
+
const command = new Command('trace').description('Run the TRACE engine only — simulate a transaction and report the execution path');
|
|
14
|
+
withCommonOptions(command).action(async (tx, options) => {
|
|
15
|
+
try {
|
|
16
|
+
const txXdr = await resolveTxInput(tx, options.file);
|
|
17
|
+
const result = await trace(txXdr, { network: options.network, rpcUrl: options.rpcUrl });
|
|
18
|
+
if (isMeridianError(result)) {
|
|
19
|
+
if (options.json) {
|
|
20
|
+
printJson(result);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
failWithMeridianError(result);
|
|
24
|
+
}
|
|
25
|
+
if (options.json) {
|
|
26
|
+
printJson(result);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
printTrace(result);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
failWithError(err);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return command;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/commands/trace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAUtD;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAC9C,kFAAkF,CACnF,CAAC;IAEF,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,EAAsB,EAAE,OAA4B,EAAE,EAAE;QAC/F,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;YACrD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAExF,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC5B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;oBACjB,SAAS,CAAC,MAAM,CAAC,CAAC;oBAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;gBACD,qBAAqB,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;YAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,SAAS,CAAC,MAAM,CAAC,CAAC;gBAClB,OAAO;YACT,CAAC;YAED,UAAU,CAAC,MAAM,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,aAAa,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAWxC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { MERIDIAN_VERSION } from '@meridian/core';
|
|
3
|
+
import { printJson } from '../lib/output.js';
|
|
4
|
+
/**
|
|
5
|
+
* Build the `meridian version` subcommand.
|
|
6
|
+
*
|
|
7
|
+
* @returns Configured commander Command
|
|
8
|
+
*/
|
|
9
|
+
export function versionCommand() {
|
|
10
|
+
return new Command('version')
|
|
11
|
+
.description('Print MERIDIAN product and core engine version')
|
|
12
|
+
.option('--json', 'Print raw JSON instead of a formatted report')
|
|
13
|
+
.action((options) => {
|
|
14
|
+
if (options.json) {
|
|
15
|
+
printJson({ product: 'MERIDIAN', version: MERIDIAN_VERSION });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
console.log(`MERIDIAN v${MERIDIAN_VERSION}`);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;SAC1B,WAAW,CAAC,gDAAgD,CAAC;SAC7D,MAAM,CAAC,QAAQ,EAAE,8CAA8C,CAAC;SAChE,MAAM,CAAC,CAAC,OAA2B,EAAE,EAAE;QACtC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAC9D,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,aAAa,gBAAgB,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MeridianError } from '@meridian/core';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is a structured MeridianError.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Value to check
|
|
6
|
+
* @returns True if the value matches the MeridianError shape
|
|
7
|
+
*/
|
|
8
|
+
export declare function isMeridianError(value: unknown): value is MeridianError;
|
|
9
|
+
/**
|
|
10
|
+
* Print a MeridianError to stderr and exit the process with code 1.
|
|
11
|
+
*
|
|
12
|
+
* @param error - Structured MeridianError to report
|
|
13
|
+
*/
|
|
14
|
+
export declare function failWithMeridianError(error: MeridianError): never;
|
|
15
|
+
/**
|
|
16
|
+
* Print a generic error to stderr and exit the process with code 1.
|
|
17
|
+
*
|
|
18
|
+
* @param err - Error or unknown thrown value
|
|
19
|
+
*/
|
|
20
|
+
export declare function failWithError(err: unknown): never;
|
|
21
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAQtE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,CAKjE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAKjD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is a structured MeridianError.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Value to check
|
|
6
|
+
* @returns True if the value matches the MeridianError shape
|
|
7
|
+
*/
|
|
8
|
+
export function isMeridianError(value) {
|
|
9
|
+
return (typeof value === 'object' &&
|
|
10
|
+
value !== null &&
|
|
11
|
+
'layer' in value &&
|
|
12
|
+
'code' in value &&
|
|
13
|
+
'hint' in value);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Print a MeridianError to stderr and exit the process with code 1.
|
|
17
|
+
*
|
|
18
|
+
* @param error - Structured MeridianError to report
|
|
19
|
+
*/
|
|
20
|
+
export function failWithMeridianError(error) {
|
|
21
|
+
console.error(pc.red(pc.bold(`✖ [${error.layer}] ${error.code}`)));
|
|
22
|
+
console.error(pc.red(error.error));
|
|
23
|
+
console.error(pc.dim(`hint: ${error.hint}`));
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Print a generic error to stderr and exit the process with code 1.
|
|
28
|
+
*
|
|
29
|
+
* @param err - Error or unknown thrown value
|
|
30
|
+
*/
|
|
31
|
+
export function failWithError(err) {
|
|
32
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
33
|
+
console.error(pc.red(pc.bold('✖ Error')));
|
|
34
|
+
console.error(pc.red(message));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAO,IAAI,KAAK;QAChB,MAAM,IAAI,KAAK;QACf,MAAM,IAAI,KAAK,CAChB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAoB;IACxD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACnE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACnC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the transaction XDR from a positional argument, a file path, or stdin.
|
|
3
|
+
* Precedence: --file > positional arg > stdin.
|
|
4
|
+
*
|
|
5
|
+
* @param txArg - Positional tx argument, if provided
|
|
6
|
+
* @param filePath - Path to a file containing the base64 XDR, if provided
|
|
7
|
+
* @returns Trimmed base64-encoded transaction XDR
|
|
8
|
+
* @throws If no XDR could be resolved from any source
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveTxInput(txArg?: string, filePath?: string): Promise<string>;
|
|
11
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/lib/input.ts"],"names":[],"mappings":"AAeA;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBvF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
/**
|
|
3
|
+
* Read all data from stdin as a UTF-8 string.
|
|
4
|
+
*
|
|
5
|
+
* @returns Trimmed stdin contents
|
|
6
|
+
*/
|
|
7
|
+
async function readStdin() {
|
|
8
|
+
const chunks = [];
|
|
9
|
+
for await (const chunk of process.stdin) {
|
|
10
|
+
chunks.push(Buffer.from(chunk));
|
|
11
|
+
}
|
|
12
|
+
return Buffer.concat(chunks).toString('utf-8').trim();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the transaction XDR from a positional argument, a file path, or stdin.
|
|
16
|
+
* Precedence: --file > positional arg > stdin.
|
|
17
|
+
*
|
|
18
|
+
* @param txArg - Positional tx argument, if provided
|
|
19
|
+
* @param filePath - Path to a file containing the base64 XDR, if provided
|
|
20
|
+
* @returns Trimmed base64-encoded transaction XDR
|
|
21
|
+
* @throws If no XDR could be resolved from any source
|
|
22
|
+
*/
|
|
23
|
+
export async function resolveTxInput(txArg, filePath) {
|
|
24
|
+
if (filePath) {
|
|
25
|
+
const contents = await readFile(filePath, 'utf-8');
|
|
26
|
+
return contents.trim();
|
|
27
|
+
}
|
|
28
|
+
if (txArg && txArg.trim().length > 0) {
|
|
29
|
+
return txArg.trim();
|
|
30
|
+
}
|
|
31
|
+
if (!process.stdin.isTTY) {
|
|
32
|
+
const fromStdin = await readStdin();
|
|
33
|
+
if (fromStdin.length > 0)
|
|
34
|
+
return fromStdin;
|
|
35
|
+
}
|
|
36
|
+
throw new Error('No transaction XDR provided. Pass it as an argument, via --file <path>, or pipe it over stdin.');
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/lib/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;GAIG;AACH,KAAK,UAAU,SAAS;IACtB,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;AACxD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAc,EAAE,QAAiB;IACpE,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,MAAM,SAAS,EAAE,CAAC;QACpC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,SAAS,CAAC;IAC7C,CAAC;IAED,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EcosystemManifest } from '@meridian/core';
|
|
2
|
+
/**
|
|
3
|
+
* Load and parse an ecosystem manifest JSON file.
|
|
4
|
+
*
|
|
5
|
+
* @param filePath - Path to the manifest JSON file
|
|
6
|
+
* @returns Parsed EcosystemManifest, or undefined if no path was given
|
|
7
|
+
* @throws If the file cannot be read or does not contain valid JSON
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadManifest(filePath?: string): Promise<EcosystemManifest | undefined>;
|
|
10
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/lib/manifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CA8B5F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
/**
|
|
3
|
+
* Load and parse an ecosystem manifest JSON file.
|
|
4
|
+
*
|
|
5
|
+
* @param filePath - Path to the manifest JSON file
|
|
6
|
+
* @returns Parsed EcosystemManifest, or undefined if no path was given
|
|
7
|
+
* @throws If the file cannot be read or does not contain valid JSON
|
|
8
|
+
*/
|
|
9
|
+
export async function loadManifest(filePath) {
|
|
10
|
+
if (!filePath)
|
|
11
|
+
return undefined;
|
|
12
|
+
let raw;
|
|
13
|
+
try {
|
|
14
|
+
raw = await readFile(filePath, 'utf-8');
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
18
|
+
throw new Error(`Failed to read ecosystem manifest at ${filePath}: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
let parsed;
|
|
21
|
+
try {
|
|
22
|
+
parsed = JSON.parse(raw);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
26
|
+
throw new Error(`Ecosystem manifest at ${filePath} is not valid JSON: ${message}`);
|
|
27
|
+
}
|
|
28
|
+
if (typeof parsed !== 'object' ||
|
|
29
|
+
parsed === null ||
|
|
30
|
+
!Array.isArray(parsed.contracts)) {
|
|
31
|
+
throw new Error(`Ecosystem manifest at ${filePath} must be an object with a "contracts" array.`);
|
|
32
|
+
}
|
|
33
|
+
return parsed;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/lib/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAiB;IAClD,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IAEhC,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,wCAAwC,QAAQ,KAAK,OAAO,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,uBAAuB,OAAO,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,IACE,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,KAAK,IAAI;QACf,CAAC,KAAK,CAAC,OAAO,CAAE,MAAkC,CAAC,SAAS,CAAC,EAC7D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,yBAAyB,QAAQ,8CAA8C,CAChF,CAAC;IACJ,CAAC;IAED,OAAO,MAA2B,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { Network } from '@meridian/core';
|
|
3
|
+
/**
|
|
4
|
+
* Parse and validate a --network option value.
|
|
5
|
+
*
|
|
6
|
+
* @param value - Raw CLI argument
|
|
7
|
+
* @returns Validated Network
|
|
8
|
+
* @throws InvalidArgumentError if the value is not "mainnet" or "testnet"
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseNetwork(value: string): Network;
|
|
11
|
+
/**
|
|
12
|
+
* Parse and validate a --confidence-threshold option value.
|
|
13
|
+
*
|
|
14
|
+
* @param value - Raw CLI argument
|
|
15
|
+
* @returns Parsed float between 0 and 1
|
|
16
|
+
* @throws InvalidArgumentError if the value is not a number in range
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseThreshold(value: string): number;
|
|
19
|
+
/**
|
|
20
|
+
* Attach the options shared by every layer command (network, RPC, input, output).
|
|
21
|
+
*
|
|
22
|
+
* @param command - Commander command to extend
|
|
23
|
+
* @returns The same command, for chaining
|
|
24
|
+
*/
|
|
25
|
+
export declare function withCommonOptions(command: Command): Command;
|
|
26
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/lib/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAwB,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKnD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAQ3D"}
|