@lionden/plugin-deploy 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.
Files changed (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/dist/deploy-task.d.ts +83 -0
  4. package/dist/deploy-task.d.ts.map +1 -0
  5. package/dist/deploy-task.js +599 -0
  6. package/dist/deploy-task.js.map +1 -0
  7. package/dist/deployment-manager.d.ts +80 -0
  8. package/dist/deployment-manager.d.ts.map +1 -0
  9. package/dist/deployment-manager.js +521 -0
  10. package/dist/deployment-manager.js.map +1 -0
  11. package/dist/deployment-state.d.ts +40 -0
  12. package/dist/deployment-state.d.ts.map +1 -0
  13. package/dist/deployment-state.js +204 -0
  14. package/dist/deployment-state.js.map +1 -0
  15. package/dist/deployment-types.d.ts +112 -0
  16. package/dist/deployment-types.d.ts.map +1 -0
  17. package/dist/deployment-types.js +9 -0
  18. package/dist/deployment-types.js.map +1 -0
  19. package/dist/errors.d.ts +7 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +10 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/index.d.ts +13 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +184 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/leo-sources.d.ts +11 -0
  28. package/dist/leo-sources.d.ts.map +1 -0
  29. package/dist/leo-sources.js +31 -0
  30. package/dist/leo-sources.js.map +1 -0
  31. package/dist/leo-version.d.ts +2 -0
  32. package/dist/leo-version.d.ts.map +1 -0
  33. package/dist/leo-version.js +10 -0
  34. package/dist/leo-version.js.map +1 -0
  35. package/dist/on-chain-check.d.ts +34 -0
  36. package/dist/on-chain-check.d.ts.map +1 -0
  37. package/dist/on-chain-check.js +84 -0
  38. package/dist/on-chain-check.js.map +1 -0
  39. package/dist/preflight.d.ts +94 -0
  40. package/dist/preflight.d.ts.map +1 -0
  41. package/dist/preflight.js +288 -0
  42. package/dist/preflight.js.map +1 -0
  43. package/dist/prove.d.ts +11 -0
  44. package/dist/prove.d.ts.map +1 -0
  45. package/dist/prove.js +19 -0
  46. package/dist/prove.js.map +1 -0
  47. package/dist/recipe-task.d.ts +18 -0
  48. package/dist/recipe-task.d.ts.map +1 -0
  49. package/dist/recipe-task.js +201 -0
  50. package/dist/recipe-task.js.map +1 -0
  51. package/dist/recipe-types.d.ts +95 -0
  52. package/dist/recipe-types.d.ts.map +1 -0
  53. package/dist/recipe-types.js +10 -0
  54. package/dist/recipe-types.js.map +1 -0
  55. package/dist/upgrade-task.d.ts +30 -0
  56. package/dist/upgrade-task.d.ts.map +1 -0
  57. package/dist/upgrade-task.js +315 -0
  58. package/dist/upgrade-task.js.map +1 -0
  59. package/package.json +39 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Utility for reading Leo source files from a directory.
3
+ * Extracted to avoid circular dependencies between deploy-task and upgrade-task.
4
+ */
5
+ import * as fs from "node:fs";
6
+ import * as path from "node:path";
7
+ /**
8
+ * Read all .leo source files from an absolute source directory.
9
+ * Uses the discovered sourceDir (from discoverUnits) rather than
10
+ * deriving the path from the program ID.
11
+ */
12
+ export function readLeoSourcesFromDir(sourceDir) {
13
+ if (!fs.existsSync(sourceDir))
14
+ return "";
15
+ const sources = [];
16
+ collectLeoFiles(sourceDir, sources);
17
+ return sources.join("\n");
18
+ }
19
+ function collectLeoFiles(dir, results) {
20
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
21
+ for (const entry of entries) {
22
+ const fullPath = path.join(dir, entry.name);
23
+ if (entry.isDirectory()) {
24
+ collectLeoFiles(fullPath, results);
25
+ }
26
+ else if (entry.name.endsWith(".leo")) {
27
+ results.push(fs.readFileSync(fullPath, "utf-8"));
28
+ }
29
+ }
30
+ }
31
+ //# sourceMappingURL=leo-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leo-sources.js","sourceRoot":"","sources":["../src/leo-sources.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACrD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,EAAE,CAAC;IAEzC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,eAAe,CAAC,GAAW,EAAE,OAAiB;IACrD,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function supportsLeoProgramRename(leoVersion: string): boolean;
2
+ //# sourceMappingURL=leo-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leo-version.d.ts","sourceRoot":"","sources":["../src/leo-version.ts"],"names":[],"mappings":"AAEA,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAMpE"}
@@ -0,0 +1,10 @@
1
+ const STABLE_LEO_VERSION_RE = /^(\d+)\.(\d+)\.(\d+)$/;
2
+ export function supportsLeoProgramRename(leoVersion) {
3
+ const match = STABLE_LEO_VERSION_RE.exec(leoVersion);
4
+ if (!match)
5
+ return false;
6
+ const major = Number(match[1]);
7
+ const minor = Number(match[2]);
8
+ return major > 4 || (major === 4 && minor >= 3);
9
+ }
10
+ //# sourceMappingURL=leo-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leo-version.js","sourceRoot":"","sources":["../src/leo-version.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD,MAAM,UAAU,wBAAwB,CAAC,UAAkB;IACzD,MAAM,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,OAAO,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * On-chain program existence checks.
3
+ *
4
+ * Used by DeploymentManager for devnode session validation and by the
5
+ * pre-flight pipeline to detect already-deployed programs.
6
+ */
7
+ import type { NetworkConnection } from "@lionden/network";
8
+ import type { DegradedDeploymentRecord } from "./deployment-types.js";
9
+ export type OnChainCheckResult = {
10
+ readonly exists: true;
11
+ readonly source: string;
12
+ readonly edition: number | null;
13
+ } | {
14
+ readonly exists: false;
15
+ readonly source: null;
16
+ };
17
+ /**
18
+ * Check whether a program is deployed on-chain.
19
+ * Returns source when found, null when not.
20
+ */
21
+ export declare function checkProgramOnChain(connection: NetworkConnection, programId: string): Promise<OnChainCheckResult>;
22
+ export declare function getRequiredProgramEdition(connection: NetworkConnection, programId: string, actionDescription: string): Promise<number>;
23
+ export declare function waitForProgramEditionAdvance(connection: NetworkConnection, programId: string, previousEdition: number, timeoutMs: number): Promise<number>;
24
+ /**
25
+ * Build a DegradedDeploymentRecord from an on-chain program source.
26
+ * Used when a program is discovered on-chain with no local provenance.
27
+ */
28
+ export declare function createDegradedRecord(programId: string, network: string, endpoint: string, source: string, edition: number, historyCount?: number): DegradedDeploymentRecord;
29
+ /**
30
+ * Batch-fetch compiled Aleo sources for a list of program IDs.
31
+ * Missing programs are omitted from the result map.
32
+ */
33
+ export declare function fetchImportSources(connection: NetworkConnection, importIds: string[]): Promise<Map<string, string>>;
34
+ //# sourceMappingURL=on-chain-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-chain-check.d.ts","sourceRoot":"","sources":["../src/on-chain-check.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAMtE,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,GACD;IACE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;CACvB,CAAC;AAEN;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,kBAAkB,CAAC,CAO7B;AAED,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAsB,4BAA4B,CAChD,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAMD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,SAAI,GACf,wBAAwB,CAgB1B;AAMD;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAc9B"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * On-chain program existence checks.
3
+ *
4
+ * Used by DeploymentManager for devnode session validation and by the
5
+ * pre-flight pipeline to detect already-deployed programs.
6
+ */
7
+ /**
8
+ * Check whether a program is deployed on-chain.
9
+ * Returns source when found, null when not.
10
+ */
11
+ export async function checkProgramOnChain(connection, programId) {
12
+ const source = await connection.getProgramSource(programId);
13
+ if (source === null) {
14
+ return { exists: false, source: null };
15
+ }
16
+ const edition = await connection.getProgramEdition(programId);
17
+ return { exists: true, source, edition };
18
+ }
19
+ export async function getRequiredProgramEdition(connection, programId, actionDescription) {
20
+ const edition = await connection.getProgramEdition(programId);
21
+ if (typeof edition === "number" && Number.isInteger(edition) && edition >= 0) {
22
+ return edition;
23
+ }
24
+ throw new Error(`Unable to ${actionDescription} for "${programId}": on-chain program edition could not be observed.`);
25
+ }
26
+ export async function waitForProgramEditionAdvance(connection, programId, previousEdition, timeoutMs) {
27
+ const deadline = Date.now() + timeoutMs;
28
+ while (Date.now() <= deadline) {
29
+ const edition = await connection.getProgramEdition(programId);
30
+ if (typeof edition === "number" && Number.isInteger(edition) && edition > previousEdition) {
31
+ return edition;
32
+ }
33
+ const remaining = deadline - Date.now();
34
+ if (remaining <= 0)
35
+ break;
36
+ await new Promise((resolve) => setTimeout(resolve, Math.min(500, remaining)));
37
+ }
38
+ throw new Error(`Timed out waiting for "${programId}" on-chain edition to advance beyond ${previousEdition}.`);
39
+ }
40
+ // ---------------------------------------------------------------------------
41
+ // createDegradedRecord
42
+ // ---------------------------------------------------------------------------
43
+ /**
44
+ * Build a DegradedDeploymentRecord from an on-chain program source.
45
+ * Used when a program is discovered on-chain with no local provenance.
46
+ */
47
+ export function createDegradedRecord(programId, network, endpoint, source, edition, historyCount = 0) {
48
+ void source; // source kept in the signature for callers; not stored on the record
49
+ return {
50
+ status: "degraded",
51
+ programId,
52
+ network,
53
+ endpoint,
54
+ updatedAt: new Date().toISOString(),
55
+ edition,
56
+ historyCount,
57
+ txId: null,
58
+ blockHeight: null,
59
+ deployerAddress: null,
60
+ deployedAt: null,
61
+ feePaid: null,
62
+ };
63
+ }
64
+ // ---------------------------------------------------------------------------
65
+ // fetchImportSources
66
+ // ---------------------------------------------------------------------------
67
+ /**
68
+ * Batch-fetch compiled Aleo sources for a list of program IDs.
69
+ * Missing programs are omitted from the result map.
70
+ */
71
+ export async function fetchImportSources(connection, importIds) {
72
+ const results = await Promise.all(importIds.map(async (id) => {
73
+ const source = await connection.getProgramSource(id);
74
+ return [id, source];
75
+ }));
76
+ const map = new Map();
77
+ for (const [id, source] of results) {
78
+ if (source !== null) {
79
+ map.set(id, source);
80
+ }
81
+ }
82
+ return map;
83
+ }
84
+ //# sourceMappingURL=on-chain-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-chain-check.js","sourceRoot":"","sources":["../src/on-chain-check.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAA6B,EAC7B,SAAiB;IAEjB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,gBAAg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MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Pre-flight validation pipeline.
3
+ *
4
+ * Pure validation — never writes state. Returns structured results with
5
+ * per-program outcomes for deploy.
6
+ */
7
+ import type { LionDenResolvedConfig, ResolvedNetworkConfig, ResolvedSdkKeyCacheConfig, SdkLogLevel } from "@lionden/config";
8
+ import type { DependencyGraph } from "@lionden/leo-compiler";
9
+ import type { NetworkConnection } from "@lionden/network";
10
+ import type { DeploymentRecord } from "./deployment-types.js";
11
+ export interface PreflightWarning {
12
+ readonly code: string;
13
+ readonly message: string;
14
+ }
15
+ export interface PreflightError {
16
+ readonly code: string;
17
+ readonly message: string;
18
+ readonly recoverable: boolean;
19
+ }
20
+ export interface ProgramPreflightOutcome {
21
+ readonly programId: string;
22
+ readonly action: "deploy" | "skip";
23
+ readonly reason?: "already-deployed" | "already-in-state";
24
+ readonly record?: DeploymentRecord;
25
+ readonly feeEstimate?: bigint;
26
+ }
27
+ export interface DeployPreflightResult {
28
+ readonly passed: boolean;
29
+ readonly warnings: PreflightWarning[];
30
+ readonly errors: PreflightError[];
31
+ readonly programs: ProgramPreflightOutcome[];
32
+ readonly totalFeeEstimate?: bigint;
33
+ }
34
+ /**
35
+ * Check whether a program is already deployed on-chain.
36
+ *
37
+ * - If on-chain and skipDeployed=true → action: "skip"
38
+ * - If on-chain and skipDeployed=false → fatal error
39
+ * - If not on-chain → action: "deploy"
40
+ */
41
+ export declare function checkAlreadyDeployed(connection: NetworkConnection, programId: string, existingRecord: DeploymentRecord | null, skipDeployed: boolean): Promise<{
42
+ outcome: ProgramPreflightOutcome;
43
+ error: PreflightError | null;
44
+ }>;
45
+ /**
46
+ * Check that all imports of a program are available — either already on-chain
47
+ * or scheduled for deployment earlier in the same run.
48
+ *
49
+ * HTTP only (devnode skips — imports are guaranteed by local compilation).
50
+ */
51
+ export declare function checkImportsAvailable(connection: NetworkConnection, graph: DependencyGraph, programId: string, deployTargets: Set<string>, localSources: Map<string, string>): Promise<PreflightError[]>;
52
+ /**
53
+ * Estimate the deployment fee for a program.
54
+ * Returns the estimate in microcredits, or undefined if estimation fails.
55
+ * HTTP only (devnode skips proof generation so fee estimation is not meaningful).
56
+ */
57
+ export declare function checkFeeEstimate(connection: NetworkConnection, programId: string, aleoSource: string, importSources: Map<string, string>, signerPrivateKey?: string, keyCache?: ResolvedSdkKeyCacheConfig, logLevel?: SdkLogLevel): Promise<{
58
+ estimate: bigint | undefined;
59
+ warning: PreflightWarning | null;
60
+ }>;
61
+ /**
62
+ * Check that the deployer's balance is sufficient to cover estimated fees.
63
+ * Warns if balance < 1.5x total estimate, errors if < 1x.
64
+ * HTTP only.
65
+ */
66
+ export declare function checkBalanceSufficient(connection: NetworkConnection, totalEstimate: bigint, signerAddress?: string): Promise<{
67
+ warning: PreflightWarning | null;
68
+ error: PreflightError | null;
69
+ }>;
70
+ export interface RunDeployPreflightOptions {
71
+ programs: Array<{
72
+ programId: string;
73
+ aleoSource: string | undefined;
74
+ existingRecord: DeploymentRecord | null;
75
+ }>;
76
+ connection: NetworkConnection;
77
+ networkConfig: ResolvedNetworkConfig;
78
+ config: LionDenResolvedConfig;
79
+ skipDeployed: boolean;
80
+ /** All program IDs being deployed in this run (for import availability checks) */
81
+ deployTargets: Set<string>;
82
+ /** Compiled Aleo sources for local deps not yet on-chain (programId → source) */
83
+ localSources: Map<string, string>;
84
+ /** Dependency graph for import checks */
85
+ graph: DependencyGraph;
86
+ /** Override signing key for fee estimation and balance checks. When set, overrides connection.privateKey. */
87
+ signerPrivateKey?: string;
88
+ }
89
+ /**
90
+ * Run pre-flight validation for a set of programs to be deployed.
91
+ * Pure — never writes state.
92
+ */
93
+ export declare function runDeployPreflight(opts: RunDeployPreflightOptions): Promise<DeployPreflightResult>;
94
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAO9D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,CAAC;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IA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,IAAI,CAAA;CAAE,CAAC,CAkC7E;AAMD,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,KAAK,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,cAAc,EAAE,gBAAgB,GAAG,IAAI,CAAC;KACzC,CAAC,CAAC;IACH,UAAU,EAAE,iBAAiB,CAAC;IAC9B,aAAa,EAAE,qBAAqB,CAAC;IACrC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,YAAY,EAAE,OAAO,CAAC;IACtB,kFAAkF;IAClF,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,iFAAiF;IACjF,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,yCAAyC;IACzC,KAAK,EAAE,eAAe,CAAC;IACvB,6GAA6G;IAC7G,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CA+JhC"}
@@ -0,0 +1,288 @@
1
+ /**
2
+ * Pre-flight validation pipeline.
3
+ *
4
+ * Pure validation — never writes state. Returns structured results with
5
+ * per-program outcomes for deploy.
6
+ */
7
+ import { checkProgramOnChain, fetchImportSources } from "./on-chain-check.js";
8
+ // ---------------------------------------------------------------------------
9
+ // Individual checks — deploy
10
+ // ---------------------------------------------------------------------------
11
+ /**
12
+ * Check whether a program is already deployed on-chain.
13
+ *
14
+ * - If on-chain and skipDeployed=true → action: "skip"
15
+ * - If on-chain and skipDeployed=false → fatal error
16
+ * - If not on-chain → action: "deploy"
17
+ */
18
+ export async function checkAlreadyDeployed(connection, programId, existingRecord, skipDeployed) {
19
+ // For devnode: always validate via getProgramSource (memory-first policy)
20
+ // For HTTP: also check on-chain existence
21
+ const { exists } = await checkProgramOnChain(connection, programId);
22
+ if (!exists) {
23
+ return {
24
+ outcome: { programId, action: "deploy" },
25
+ error: null,
26
+ };
27
+ }
28
+ // Program exists on-chain
29
+ if (!skipDeployed) {
30
+ return {
31
+ outcome: {
32
+ programId,
33
+ action: "skip",
34
+ reason: "already-deployed",
35
+ record: existingRecord ?? undefined,
36
+ },
37
+ error: {
38
+ code: "ALREADY_DEPLOYED",
39
+ message: `Program "${programId}" is already deployed on-chain and ` +
40
+ `--no-skip-deployed was specified. Remove the flag to skip it.`,
41
+ recoverable: false,
42
+ },
43
+ };
44
+ }
45
+ return {
46
+ outcome: {
47
+ programId,
48
+ action: "skip",
49
+ reason: existingRecord ? "already-in-state" : "already-deployed",
50
+ record: existingRecord ?? undefined,
51
+ },
52
+ error: null,
53
+ };
54
+ }
55
+ /**
56
+ * Check that all imports of a program are available — either already on-chain
57
+ * or scheduled for deployment earlier in the same run.
58
+ *
59
+ * HTTP only (devnode skips — imports are guaranteed by local compilation).
60
+ */
61
+ export async function checkImportsAvailable(connection, graph, programId, deployTargets, localSources) {
62
+ const errors = [];
63
+ const imports = graph.imports.get(programId) ?? [];
64
+ for (const importId of imports) {
65
+ // Check if scheduled for deployment earlier in this run
66
+ if (deployTargets.has(importId))
67
+ continue;
68
+ // Check if we have the source locally (local dep not yet on-chain in this batch)
69
+ if (localSources.has(importId))
70
+ continue;
71
+ // Check if on-chain
72
+ const { exists } = await checkProgramOnChain(connection, importId);
73
+ if (!exists) {
74
+ errors.push({
75
+ code: "MISSING_IMPORT",
76
+ message: `Program "${programId}" imports "${importId}" which is not deployed on-chain ` +
77
+ `and not scheduled for deployment in this run.`,
78
+ recoverable: false,
79
+ });
80
+ }
81
+ }
82
+ return errors;
83
+ }
84
+ /**
85
+ * Estimate the deployment fee for a program.
86
+ * Returns the estimate in microcredits, or undefined if estimation fails.
87
+ * HTTP only (devnode skips proof generation so fee estimation is not meaningful).
88
+ */
89
+ export async function checkFeeEstimate(connection, programId, aleoSource, importSources, signerPrivateKey, keyCache, logLevel) {
90
+ try {
91
+ const { createSdkObjects, withSuppressedSdkConsoleNoise } = await import("@lionden/network");
92
+ const sdk = await createSdkObjects({
93
+ network: connection.networkId,
94
+ endpoint: connection.endpoint,
95
+ privateKey: signerPrivateKey ?? connection.privateKey,
96
+ apiKey: connection.apiKey,
97
+ egressPolicy: connection.egressPolicy,
98
+ keyCache,
99
+ logLevel,
100
+ });
101
+ const pm = sdk.programManager;
102
+ if (typeof pm.estimateDeploymentFee !== "function") {
103
+ return {
104
+ estimate: undefined,
105
+ warning: {
106
+ code: "FEE_ESTIMATION_UNAVAILABLE",
107
+ message: `Fee estimation not available in this SDK version. Cannot estimate deployment cost for "${programId}".`,
108
+ },
109
+ };
110
+ }
111
+ // Build imports object for SDK
112
+ const importsObj = {};
113
+ for (const [id, src] of importSources) {
114
+ importsObj[id] = src;
115
+ }
116
+ const estimatedFee = await withSuppressedSdkConsoleNoise(() => pm.estimateDeploymentFee(aleoSource, Object.keys(importsObj).length > 0 ? importsObj : undefined));
117
+ return {
118
+ estimate: BigInt(estimatedFee),
119
+ warning: null,
120
+ };
121
+ }
122
+ catch (err) {
123
+ return {
124
+ estimate: undefined,
125
+ warning: {
126
+ code: "FEE_ESTIMATION_FAILED",
127
+ message: `Failed to estimate deployment fee for "${programId}": ${err instanceof Error ? err.message : String(err)}`,
128
+ },
129
+ };
130
+ }
131
+ }
132
+ /**
133
+ * Check that the deployer's balance is sufficient to cover estimated fees.
134
+ * Warns if balance < 1.5x total estimate, errors if < 1x.
135
+ * HTTP only.
136
+ */
137
+ export async function checkBalanceSufficient(connection, totalEstimate, signerAddress) {
138
+ if (totalEstimate === 0n) {
139
+ return { warning: null, error: null };
140
+ }
141
+ const balance = await connection.getBalance(signerAddress);
142
+ const bufferThreshold = (totalEstimate * 3n) / 2n; // 1.5x
143
+ if (balance < totalEstimate) {
144
+ return {
145
+ warning: null,
146
+ error: {
147
+ code: "INSUFFICIENT_BALANCE",
148
+ message: `Deployer balance (${balance} microcredits) is less than the estimated total fee ` +
149
+ `(${totalEstimate} microcredits). Deployment will likely fail.`,
150
+ recoverable: false,
151
+ },
152
+ };
153
+ }
154
+ if (balance < bufferThreshold) {
155
+ return {
156
+ warning: {
157
+ code: "LOW_BALANCE",
158
+ message: `Deployer balance (${balance} microcredits) is less than 1.5x the estimated total fee ` +
159
+ `(${totalEstimate} microcredits). Consider adding more credits to cover fees.`,
160
+ },
161
+ error: null,
162
+ };
163
+ }
164
+ return { warning: null, error: null };
165
+ }
166
+ /**
167
+ * Run pre-flight validation for a set of programs to be deployed.
168
+ * Pure — never writes state.
169
+ */
170
+ export async function runDeployPreflight(opts) {
171
+ const { programs, connection, networkConfig, skipDeployed, deployTargets, localSources, graph, signerPrivateKey, } = opts;
172
+ const isDevnode = networkConfig.type === "devnode";
173
+ const warnings = [];
174
+ const errors = [];
175
+ const outcomes = [];
176
+ // Track which programs in this batch are confirmed to deploy
177
+ // (used as "known to deploy" for import checks of later programs)
178
+ const confirmedDeployTargets = new Set(deployTargets);
179
+ let totalFeeEstimate;
180
+ for (const prog of programs) {
181
+ const { programId, aleoSource, existingRecord } = prog;
182
+ // 1. Check if already deployed
183
+ const { outcome: deployedOutcome, error: deployedErr } = await checkAlreadyDeployed(connection, programId, existingRecord, skipDeployed);
184
+ if (deployedErr) {
185
+ errors.push(deployedErr);
186
+ outcomes.push(deployedOutcome);
187
+ continue;
188
+ }
189
+ if (deployedOutcome.action === "skip") {
190
+ outcomes.push(deployedOutcome);
191
+ // Do NOT add to confirmedDeployTargets — it's being skipped
192
+ confirmedDeployTargets.delete(programId);
193
+ continue;
194
+ }
195
+ // This program will be deployed — run HTTP-only checks
196
+ if (!isDevnode) {
197
+ // 2. Check compiled artifacts present (HTTP only — needed for import/fee checks)
198
+ if (aleoSource === undefined) {
199
+ errors.push({
200
+ code: "MISSING_ARTIFACTS",
201
+ message: `No compiled .aleo source found for "${programId}". ` +
202
+ `Run \`lionden compile\` before running preflight.`,
203
+ recoverable: false,
204
+ });
205
+ outcomes.push({ programId, action: "deploy" });
206
+ continue;
207
+ }
208
+ // 3. Check imports available
209
+ const importErrors = await checkImportsAvailable(connection, graph, programId, confirmedDeployTargets, localSources);
210
+ errors.push(...importErrors);
211
+ if (importErrors.length > 0) {
212
+ outcomes.push({ programId, action: "deploy" });
213
+ continue;
214
+ }
215
+ // 4. Fee estimation
216
+ // Collect import sources for fee estimation.
217
+ // Local sources (deps in this batch) are known; all other imports (including
218
+ // credits.aleo and other external programs) are fetched from on-chain.
219
+ const importIds = graph.imports.get(programId) ?? [];
220
+ const importSourcesForFee = new Map();
221
+ const onChainImportIds = [];
222
+ for (const id of importIds) {
223
+ const local = localSources.get(id);
224
+ if (local) {
225
+ importSourcesForFee.set(id, local);
226
+ }
227
+ else {
228
+ onChainImportIds.push(id);
229
+ }
230
+ }
231
+ if (onChainImportIds.length > 0) {
232
+ const fetched = await fetchImportSources(connection, onChainImportIds);
233
+ for (const [id, src] of fetched) {
234
+ importSourcesForFee.set(id, src);
235
+ }
236
+ }
237
+ const { estimate, warning: feeWarning } = await checkFeeEstimate(connection, programId, aleoSource, importSourcesForFee, signerPrivateKey, opts.config.sdk.keyCache, opts.config.sdk.logLevel);
238
+ if (feeWarning)
239
+ warnings.push(feeWarning);
240
+ if (estimate !== undefined) {
241
+ totalFeeEstimate = (totalFeeEstimate ?? 0n) + estimate;
242
+ }
243
+ outcomes.push({ programId, action: "deploy", feeEstimate: estimate });
244
+ }
245
+ else {
246
+ outcomes.push({ programId, action: "deploy" });
247
+ }
248
+ }
249
+ // 5. Balance check (HTTP only, batch)
250
+ if (!isDevnode && totalFeeEstimate !== undefined && totalFeeEstimate > 0n) {
251
+ // Derive signer address if a signer key override is provided
252
+ let signerAddress;
253
+ if (signerPrivateKey) {
254
+ try {
255
+ const { createSdkObjects } = await import("@lionden/network");
256
+ const sdk = await createSdkObjects({
257
+ network: connection.networkId,
258
+ endpoint: connection.endpoint,
259
+ privateKey: signerPrivateKey,
260
+ apiKey: connection.apiKey,
261
+ egressPolicy: connection.egressPolicy,
262
+ logLevel: opts.config.sdk.logLevel,
263
+ });
264
+ const account = sdk.account;
265
+ signerAddress =
266
+ typeof account.address === "function"
267
+ ? account.address().to_string()
268
+ : String(account.address ?? account);
269
+ }
270
+ catch {
271
+ // Best-effort; fall back to connection default
272
+ }
273
+ }
274
+ const { warning: balanceWarning, error: balanceError } = await checkBalanceSufficient(connection, totalFeeEstimate, signerAddress);
275
+ if (balanceWarning)
276
+ warnings.push(balanceWarning);
277
+ if (balanceError)
278
+ errors.push(balanceError);
279
+ }
280
+ return {
281
+ passed: errors.length === 0,
282
+ warnings,
283
+ errors,
284
+ programs: outcomes,
285
+ totalFeeEstimate,
286
+ };
287
+ }
288
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAiC9E,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,UAA6B,EAC7B,SAAiB,EACjB,cAAuC,EACvC,YAAqB;IAErB,0EAA0E;IAC1E,0CAA0C;IAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,mBAAmB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAEpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;YACxC,KAAK,EAAE,IAAI;SACZ,CAAC;IACJ,CAAC;IAED,0BAA0B;IAC1B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO;YACL,OAAO,EAAE;gBACP,SAAS;gBACT,MAAM,EAAE,MAAM;gBACd,MAAM,EAAE,kBAAkB;gBAC1B,MAAM,EAAE,cAAc,IAAI,SAAS;aACpC;Y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D,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC;oBACjC,OAAO,EAAE,UAAU,CAAC,SAAS;oBAC7B,QAAQ,EAAE,UAAU,CAAC,QAAQ;oBAC7B,UAAU,EAAE,gBAAgB;oBAC5B,MAAM,EAAE,UAAU,CAAC,MAAM;oBACzB,YAAY,EAAE,UAAU,CAAC,YAAY;oBACrC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ;iBACnC,CAAC,CAAC;gBACH,MAAM,OAAO,GAAG,GAAG,CAAC,OAAc,CAAC;gBACnC,aAAa;oBACX,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU;wBACnC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE;wBAC/B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC;YAC3C,CAAC;YAAC,MAAM,CAAC;gBACP,+CAA+C;YACjD,CAAC;QACH,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,sBAAsB,CACnF,UAAU,EACV,gBAAgB,EAChB,aAAa,CACd,CAAC;QACF,IAAI,cAAc;YAAE,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClD,IAAI,YAAY;YAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC3B,QAAQ;QACR,MAAM;QACN,QAAQ,EAAE,QAAQ;QAClB,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { LionDenRuntimeEnvironment } from "@lionden/core";
2
+ /**
3
+ * Resolve whether to build standard/proven transactions, shared by the deploy
4
+ * and upgrade actions. Precedence: an explicit per-call/task arg wins; then an
5
+ * explicit `--prove[=true|false]` global (so `--prove=false` disables proving
6
+ * even when LIONDEN_PROVE is set); then a truthy LIONDEN_PROVE env var; else
7
+ * false. The env is parsed permissively (e.g. `1`/`yes`/`on`); silent here —
8
+ * a worker-side reader must not warn per call (Finding 3).
9
+ */
10
+ export declare function resolveProveOption(args: Record<string, unknown>, lre: LionDenRuntimeEnvironment): boolean;
11
+ //# sourceMappingURL=prove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE/D;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,yBAAyB,GAC7B,OAAO,CAMT"}
package/dist/prove.js ADDED
@@ -0,0 +1,19 @@
1
+ import { parseBooleanEnv } from "@lionden/config";
2
+ /**
3
+ * Resolve whether to build standard/proven transactions, shared by the deploy
4
+ * and upgrade actions. Precedence: an explicit per-call/task arg wins; then an
5
+ * explicit `--prove[=true|false]` global (so `--prove=false` disables proving
6
+ * even when LIONDEN_PROVE is set); then a truthy LIONDEN_PROVE env var; else
7
+ * false. The env is parsed permissively (e.g. `1`/`yes`/`on`); silent here —
8
+ * a worker-side reader must not warn per call (Finding 3).
9
+ */
10
+ export function resolveProveOption(args, lre) {
11
+ const explicit = args["prove"];
12
+ if (typeof explicit === "boolean")
13
+ return explicit;
14
+ const global = lre.globalOptions["prove"];
15
+ if (typeof global === "boolean")
16
+ return global; // I5: honor explicit false, not just === true
17
+ return parseBooleanEnv(process.env["LIONDEN_PROVE"], false);
18
+ }
19
+ //# sourceMappingURL=prove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prove.js","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAA6B,EAC7B,GAA8B;IAE9B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,OAAO,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACnD,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,OAAO,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,CAAC,8CAA8C;IAC9F,OAAO,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Recipe task — run a deployment recipe from the CLI.
3
+ *
4
+ * A recipe is a user-defined async function exported from a TypeScript/JS file.
5
+ * The task compiles the project once, creates a DeploymentContext, then calls
6
+ * the recipe function.
7
+ *
8
+ * Usage:
9
+ * lionden recipe --file ./recipes/setup.ts
10
+ * lionden recipe --file ./recipes/setup.ts --export setupToken
11
+ * lionden recipe --file ./recipes/setup.ts --network testnet
12
+ */
13
+ import type { LionDenRuntimeEnvironment } from "@lionden/core";
14
+ import type { NetworkConnection } from "@lionden/network";
15
+ import type { DeploymentContext } from "./recipe-types.js";
16
+ export declare function recipeAction(args: Record<string, unknown>, lre: LionDenRuntimeEnvironment): Promise<unknown>;
17
+ export declare function createCliDeploymentContext(lre: LionDenRuntimeEnvironment, connection: NetworkConnection, networkName: string, resolvedProve?: boolean): DeploymentContext;
18
+ //# sourceMappingURL=recipe-task.d.ts.map