@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 @@
1
+ {"version":3,"file":"recipe-task.d.ts","sourceRoot":"","sources":["../src/recipe-task.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,kBAAkB,CAAC;AAM1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAM3D,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,yBAAyB,GAC7B,OAAO,CAAC,OAAO,CAAC,CAmDlB;AAMD,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,yBAAyB,EAC9B,UAAU,EAAE,iBAAiB,EAC7B,WAAW,EAAE,MAAM,EACnB,aAAa,UAAQ,GACpB,iBAAiB,CAgGnB"}
@@ -0,0 +1,201 @@
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 * as path from "node:path";
14
+ import { createNamedAccountAccessor, normalizeProgramId } from "@lionden/config";
15
+ import { logAction, programNameFromTarget, sourceProgramNameFromTarget } from "@lionden/core";
16
+ import { DEVNODE_ACCOUNTS } from "@lionden/network";
17
+ import { DeployError } from "./errors.js";
18
+ import { resolveProveOption } from "./prove.js";
19
+ // ---------------------------------------------------------------------------
20
+ // Recipe action
21
+ // ---------------------------------------------------------------------------
22
+ export async function recipeAction(args, lre) {
23
+ const file = args["file"];
24
+ if (!file) {
25
+ throw new DeployError("The --file option is required.\nUsage: lionden recipe --file ./recipes/setup.ts");
26
+ }
27
+ const exportName = args["export"] ?? "default";
28
+ // Capture the explicit network separately from the resolved `networkName`: only
29
+ // an explicitly-supplied network is forwarded into the implicit compile, so a
30
+ // default run (no `network` arg) leaves compile on `config.defaultNetwork`.
31
+ const explicitNetwork = typeof args["network"] === "string" ? args["network"] : undefined;
32
+ const networkName = explicitNetwork ?? lre.config.defaultNetwork;
33
+ const noCompile = args["noCompile"] ?? false;
34
+ // 1. Compile first (unless --no-compile). Forward the explicit network so the
35
+ // implicit compile resolves imported on-chain sources + `.env` from the
36
+ // deploying network; omit it on a default run (byte-for-byte unchanged).
37
+ if (!noCompile) {
38
+ if (explicitNetwork) {
39
+ await lre.tasks.run("compile", { network: explicitNetwork });
40
+ }
41
+ else {
42
+ await lre.tasks.run("compile");
43
+ }
44
+ }
45
+ // 2. Connect to network
46
+ const networkManager = lre.network;
47
+ const connection = await networkManager.connect(networkName);
48
+ // 3. Create deployment context. Resolve the run-level prove preference once
49
+ // (programmatic args.prove → --prove global → LIONDEN_PROVE → false) so
50
+ // ctx.execute inherits it; per-call opts can still override.
51
+ const resolvedRecipeProve = resolveProveOption(args, lre);
52
+ const ctx = createCliDeploymentContext(lre, connection, networkName, resolvedRecipeProve);
53
+ // 4. Import and run recipe — resolve relative to project root, not cwd
54
+ const resolved = path.isAbsolute(file) ? file : path.resolve(lre.config.paths.root, file);
55
+ const mod = await import(resolved);
56
+ const recipeFn = mod[exportName];
57
+ if (typeof recipeFn !== "function") {
58
+ throw new DeployError(`No function "${exportName}" exported from "${file}".`);
59
+ }
60
+ console.log(`${logAction("Running recipe")} ${resolved}#${exportName} on network "${networkName}"`);
61
+ const result = await recipeFn(ctx);
62
+ return result;
63
+ }
64
+ // ---------------------------------------------------------------------------
65
+ // CLI deployment context factory
66
+ // ---------------------------------------------------------------------------
67
+ export function createCliDeploymentContext(lre, connection, networkName, resolvedProve = false) {
68
+ return {
69
+ lre,
70
+ connection,
71
+ network: networkName,
72
+ accounts: connection.type === "devnode" ? DEVNODE_ACCOUNTS : [],
73
+ namedAccounts: lre.namedAccounts,
74
+ named: createNamedAccountAccessor(lre.namedAccounts, networkName),
75
+ async deploy(program, opts) {
76
+ const programName = programNameFromTarget(program);
77
+ const sourceProgramName = sourceProgramNameFromTarget(program);
78
+ const normalizedId = normalizeProgramId(programName);
79
+ const normalizedSourceId = normalizeProgramId(sourceProgramName);
80
+ const rename = normalizedSourceId === normalizedId ? undefined : normalizedId;
81
+ const expectedSourceProgramId = rename ? normalizedSourceId : undefined;
82
+ const defaultNoCompile = !rename;
83
+ const deploymentCache = lre.deployments;
84
+ if (!opts?.noSkipDeployed) {
85
+ const cached = getCachedDeployment(deploymentCache, normalizedId, networkName);
86
+ if (isCompleteMatchingRecord(cached, normalizedId, expectedSourceProgramId)) {
87
+ return { programId: normalizedId, txId: cached.txId };
88
+ }
89
+ }
90
+ const taskResult = await lre.tasks.run("deploy", {
91
+ program: rename ? normalizedSourceId : programName,
92
+ ...(rename ? { rename } : {}),
93
+ network: networkName,
94
+ noCompile: opts?.noCompile ?? defaultNoCompile,
95
+ priorityFee: opts?.priorityFee,
96
+ noSkipDeployed: opts?.noSkipDeployed,
97
+ // Forward the recipe's authoritative prove value (a per-call override
98
+ // wins; otherwise inherit the run-level `resolvedProve`), mirroring
99
+ // ctx.execute. resolvedProve already encodes the full args > --prove >
100
+ // LIONDEN_PROVE precedence, so passing it explicitly keeps deploy and
101
+ // execute consistent — including programmatic `tasks.run("recipe", {
102
+ // prove })` and an explicit `{ prove: false }` that must beat a truthy
103
+ // ambient env (Finding 2 escape hatch + run-level inheritance).
104
+ prove: opts?.prove ?? resolvedProve,
105
+ });
106
+ if (rename) {
107
+ const results = getDeployResults(taskResult);
108
+ const deployed = getDeployResultForProgram(results, normalizedId);
109
+ if (deployed) {
110
+ return {
111
+ programId: normalizeProgramId(deployed.programId),
112
+ txId: deployed.txId,
113
+ };
114
+ }
115
+ const cached = getCachedDeployment(deploymentCache, normalizedId, networkName);
116
+ if (isCompleteMatchingRecord(cached, normalizedId, expectedSourceProgramId)) {
117
+ return { programId: normalizedId, txId: cached.txId };
118
+ }
119
+ throw createEmptyDeployResultError(programName, normalizedId, networkName, cached, true);
120
+ }
121
+ const results = getDeployResults(taskResult);
122
+ const deployed = getDeployResultForProgram(results, normalizedId);
123
+ if (deployed) {
124
+ return {
125
+ programId: normalizeProgramId(deployed.programId),
126
+ txId: deployed.txId,
127
+ };
128
+ }
129
+ const cached = getCachedDeployment(deploymentCache, normalizedId, networkName);
130
+ if (isCompleteMatchingRecord(cached, normalizedId)) {
131
+ return { programId: normalizedId, txId: cached.txId };
132
+ }
133
+ throw createEmptyDeployResultError(programName, normalizedId, networkName, cached);
134
+ },
135
+ async execute(programId, transitionName, args, opts) {
136
+ const mode = opts?.mode ?? "onchain";
137
+ const awaitOpt = mode === "onchain" ? { awaitConfirmation: opts?.awaitConfirmation ?? true } : {};
138
+ const result = await connection.execute(programId, transitionName, args, {
139
+ mode,
140
+ fee: opts?.fee,
141
+ prove: opts?.prove ?? resolvedProve,
142
+ signer: opts?.signer,
143
+ ...awaitOpt,
144
+ });
145
+ return {
146
+ outputs: result.outputs,
147
+ ...(result.rawOutputs === undefined ? {} : { rawOutputs: result.rawOutputs }),
148
+ txId: result.txId,
149
+ };
150
+ },
151
+ };
152
+ }
153
+ function getCachedDeployment(deploymentCache, programId, networkName) {
154
+ return deploymentCache?.getCached(programId, networkName) ?? null;
155
+ }
156
+ function isCompleteDeploymentWithTxId(record) {
157
+ return record?.status === "complete" && typeof record.txId === "string" && record.txId.length > 0;
158
+ }
159
+ function getDeployResultForProgram(results, normalizedId) {
160
+ return results.find((result) => normalizeProgramId(result.programId) === normalizedId);
161
+ }
162
+ function getDeployResults(taskResult) {
163
+ const wrapped = taskResult;
164
+ if (wrapped.mode !== "deploy") {
165
+ throw new DeployError(`Expected deploy task to return mode "deploy", got "${wrapped.mode}". ` +
166
+ `This may indicate --preflight or --dry-run was passed unexpectedly.`);
167
+ }
168
+ if (!Array.isArray(wrapped.results)) {
169
+ throw new DeployError('Expected deploy task to return { mode: "deploy", results: [...] }.');
170
+ }
171
+ return wrapped.results;
172
+ }
173
+ function isCompleteMatchingRecord(record, normalizedId, expectedSourceProgramId) {
174
+ const maybeRecord = record ?? null;
175
+ if (!isCompleteDeploymentWithTxId(maybeRecord))
176
+ return false;
177
+ if (expectedSourceProgramId === undefined) {
178
+ return (maybeRecord.sourceProgramId === undefined || maybeRecord.sourceProgramId === normalizedId);
179
+ }
180
+ return (maybeRecord.programId === normalizedId &&
181
+ maybeRecord.sourceProgramId === expectedSourceProgramId);
182
+ }
183
+ function createEmptyDeployResultError(requestedProgram, normalizedId, networkName, cached, expectsRename = false) {
184
+ const cacheRequirement = expectsRename
185
+ ? "no complete cached deployment with matching rename provenance exists"
186
+ : "no complete cached deployment with a txId exists";
187
+ return new DeployError(`Deploy task produced no transaction for "${requestedProgram}" on network "${networkName}", ` +
188
+ `and ${cacheRequirement} for "${normalizedId}" ` +
189
+ `(${describeCachedDeployment(cached)}). ` +
190
+ `Use { noSkipDeployed: true } when the recipe must fail instead of reusing or skipping an existing deployment.`);
191
+ }
192
+ function describeCachedDeployment(cached) {
193
+ if (!cached) {
194
+ return "cached state: none";
195
+ }
196
+ if (cached.status === "complete") {
197
+ return "cached state: complete record without txId";
198
+ }
199
+ return `cached state: ${cached.status} record without txId`;
200
+ }
201
+ //# sourceMappingURL=recipe-task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe-task.js","sourceRoot":"","sources":["../src/recipe-task.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAE9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGhD,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAA6B,EAC7B,GAA8B;IAE9B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAuB,CAAC;IAChD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,WAAW,CACnB,iFAAiF,CAClF,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAI,IAAI,CAAC,QAAQ,CAAY,IAAI,SAAS,CAAC;IAC3D,gFAAgF;IAChF,8EAA8E;IAC9E,4EAA4E;IAC5E,MAAM,eAAe,GACnB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAI,CAAC,SAAS,CAAY,CAAC,CAAC,CAAC,SAAS,CAAC;IAChF,MAAM,WAAW,GAAG,eAAe,IAAI,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC;IACjE,MAAM,SAAS,GAAI,IAAI,CAAC,WAAW,CAAa,IAAI,KAAK,CAAC;I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 -0,0 +1,95 @@
1
+ /**
2
+ * Deployment recipe types.
3
+ *
4
+ * A deployment recipe is a reusable async function that deploys programs
5
+ * and executes setup transactions. The same recipe can run from tests
6
+ * (via TestContext, which structurally satisfies DeploymentContext) or
7
+ * from the CLI (via `lionden recipe --file ./path.ts`).
8
+ */
9
+ import type { NamedAccountAccessor, NamedAccounts } from "@lionden/config";
10
+ import type { LionDenRuntimeEnvironment, ProgramDeploymentTarget } from "@lionden/core";
11
+ import type { DevnodeAccount, NetworkConnection, RawTransitionOutput, Signer } from "@lionden/network";
12
+ export type { ProgramDeploymentTarget };
13
+ export interface DeploymentContext {
14
+ /** Deploy a program by name or generated wrapper. Deploys transitive deps first. */
15
+ deploy(program: ProgramDeploymentTarget, options?: RecipeDeployOptions): Promise<RecipeDeployResult>;
16
+ /** Execute a transition on a deployed program. */
17
+ execute(programId: string, transitionName: string, args: string[], options?: RecipeExecuteOptions): Promise<RecipeExecuteResult>;
18
+ /** Pre-funded devnode accounts (empty on non-devnode networks). */
19
+ readonly accounts: readonly DevnodeAccount[];
20
+ /** Active network connection. */
21
+ readonly connection: NetworkConnection;
22
+ /** Full LRE for advanced use cases. */
23
+ readonly lre: LionDenRuntimeEnvironment;
24
+ /** The network name this context is connected to. */
25
+ readonly network: string;
26
+ /**
27
+ * Resolved named accounts for the active network.
28
+ * Empty object ({}) when no namedAccounts are configured in the project.
29
+ */
30
+ readonly namedAccounts: NamedAccounts;
31
+ /** Domain-native accessor for required named account roles. */
32
+ readonly named: NamedAccountAccessor;
33
+ }
34
+ export interface RecipeDeployOptions {
35
+ priorityFee?: number;
36
+ noCompile?: boolean;
37
+ /** Fail instead of reusing or skipping already-deployed programs. */
38
+ noSkipDeployed?: boolean;
39
+ /**
40
+ * Override proof generation for this deploy. When omitted, the deploy task
41
+ * self-resolves the run-level preference (`--prove` / `LIONDEN_PROVE`); set
42
+ * it (e.g. `{ prove: false }`) to skip proving one fixture deploy while the
43
+ * rest of the recipe proves.
44
+ */
45
+ prove?: boolean;
46
+ }
47
+ export interface RecipeDeployResult {
48
+ readonly programId: string;
49
+ readonly txId: string;
50
+ }
51
+ export interface RecipeExecuteOptions {
52
+ mode?: "local" | "onchain";
53
+ fee?: number;
54
+ /**
55
+ * Override proof generation for this execution. Defaults to the recipe's
56
+ * run-level prove preference (`--prove` / `LIONDEN_PROVE`); a per-call value
57
+ * beats it.
58
+ */
59
+ prove?: boolean;
60
+ signer?: Signer;
61
+ /**
62
+ * On-chain mode only. When omitted or `true`, the call awaits confirmation
63
+ * and returns the matching transition's parsed outputs. When `false`, the
64
+ * call returns immediately after broadcast with `outputs: []`; callers can
65
+ * fetch outputs later via `connection.getTransitionOutputs(...)`.
66
+ */
67
+ awaitConfirmation?: boolean;
68
+ }
69
+ export interface RecipeExecuteResult {
70
+ readonly outputs: string[];
71
+ /**
72
+ * Faithful on-chain output shape including the `idOnly` discriminator for
73
+ * dynamic-record outputs. Present only when the call awaited confirmation.
74
+ */
75
+ readonly rawOutputs?: readonly RawTransitionOutput[];
76
+ readonly txId?: string;
77
+ }
78
+ /**
79
+ * A deployment recipe is an async function that receives a {@link DeploymentContext}
80
+ * and performs deployment + setup steps. Recipes are the reusable unit — the
81
+ * same function can run from both tests and CLI.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * import type { DeploymentRecipe } from "@lionden/plugin-deploy";
86
+ *
87
+ * export const setupToken: DeploymentRecipe<{ tokenId: string }> = async (ctx) => {
88
+ * const result = await ctx.deploy("token", { noCompile: true });
89
+ * await ctx.execute("token.aleo", "mint_public", [ctx.accounts[0].address, "1000u64"]);
90
+ * return { tokenId: result.programId };
91
+ * };
92
+ * ```
93
+ */
94
+ export type DeploymentRecipe<T = void> = (ctx: DeploymentContext) => Promise<T>;
95
+ //# sourceMappingURL=recipe-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe-types.d.ts","sourceRoot":"","sources":["../src/recipe-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OA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,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Deployment recipe types.
3
+ *
4
+ * A deployment recipe is a reusable async function that deploys programs
5
+ * and executes setup transactions. The same recipe can run from tests
6
+ * (via TestContext, which structurally satisfies DeploymentContext) or
7
+ * from the CLI (via `lionden recipe --file ./path.ts`).
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=recipe-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe-types.js","sourceRoot":"","sources":["../src/recipe-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Upgrade task implementation (thin).
3
+ *
4
+ * Flow: connect → resolve signer → guard a prior record exists → compile v2 →
5
+ * build upgrade tx → broadcast → wait → record → fire hook → optional export.
6
+ *
7
+ * No ABI-compatibility, constructor-immutability, edition, or admin-address
8
+ * validation — Leo's built-in tooling owns upgrade correctness. The newly
9
+ * compiled ABI is still recorded so `export` has it.
10
+ */
11
+ import { type LionDenRuntimeEnvironment } from "@lionden/core";
12
+ export interface UpgradeOptions {
13
+ /** Program to upgrade (required) */
14
+ program: string;
15
+ /** Priority fee in microcredits */
16
+ priorityFee?: number;
17
+ /** Skip waiting for transaction confirmation */
18
+ skipConfirm?: boolean;
19
+ /** Target network (overrides defaultNetwork) */
20
+ network?: string;
21
+ /** Build a standard/proven transaction even on devnode. */
22
+ prove?: boolean;
23
+ }
24
+ export interface UpgradeResult {
25
+ readonly programId: string;
26
+ readonly txId: string;
27
+ readonly blockHeight: number;
28
+ }
29
+ export declare function upgradeAction(args: Record<string, unknown>, lre: LionDenRuntimeEnvironment): Promise<UpgradeResult>;
30
+ //# sourceMappingURL=upgrade-task.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-task.d.ts","sourceRoot":"","sources":["../src/upgrade-task.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAEL,KAAK,yBAAyB,EAK/B,MAAM,eAAe,CAAC;AAuBvB,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAMD,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,yBAAyB,GAC7B,OAAO,CAAC,aAAa,CAAC,CAwQxB"}