@phala/cloud 0.6.6-beta.1 → 0.6.7-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +19 -0
  2. package/dist/actions/apps/create_app_instance.d.ts +38 -0
  3. package/dist/actions/apps/get_app_pending_updates.d.ts +93 -0
  4. package/dist/actions/blockchains/remove_compose_hash.d.ts +77 -0
  5. package/dist/actions/cvms/commit_cvm_compose_file_update.d.ts +83 -11
  6. package/dist/actions/cvms/commit_cvm_provision.d.ts +191 -0
  7. package/dist/actions/cvms/commit_cvm_update.d.ts +77 -3
  8. package/dist/actions/cvms/confirm_cvm_patch.d.ts +80 -3
  9. package/dist/actions/cvms/cvm_draft.d.ts +1338 -0
  10. package/dist/actions/cvms/cvm_update_response.d.ts +154 -0
  11. package/dist/actions/cvms/get_cvm_init_scripts.d.ts +10 -16
  12. package/dist/actions/cvms/patch_cvm.d.ts +206 -62
  13. package/dist/actions/cvms/provision_cvm.d.ts +5 -7
  14. package/dist/actions/cvms/put_cvm_init_scripts.d.ts +49 -10
  15. package/dist/actions/cvms/update_cvm_envs.d.ts +129 -19
  16. package/dist/actions/cvms/update_docker_compose.d.ts +134 -20
  17. package/dist/actions/cvms/update_prelaunch_script.d.ts +134 -20
  18. package/dist/actions/cvms/upgrade_prelaunch_script.d.ts +145 -15
  19. package/dist/actions/cvms/wait_for_cvm_finality.d.ts +153 -0
  20. package/dist/actions/index.d.ts +5 -1
  21. package/dist/actions/kms/get_app_env_encrypt_pubkey.d.ts +31 -7
  22. package/dist/create-client.d.ts +1267 -22
  23. package/dist/index.js +2540 -1784
  24. package/dist/index.mjs +2509 -1785
  25. package/dist/types/app_compose.d.ts +8 -6
  26. package/dist/types/cvm_finality.d.ts +134 -0
  27. package/dist/types/cvm_info.d.ts +266 -0
  28. package/dist/types/cvm_info_v20251028.d.ts +37 -0
  29. package/dist/types/cvm_info_v20260121.d.ts +111 -0
  30. package/dist/types/index.d.ts +1 -0
  31. package/package.json +1 -1
@@ -30,7 +30,7 @@ import { type Client } from "../../client";
30
30
  * pre_launch_script: script
31
31
  * })
32
32
  *
33
- * if (result.status === 'precondition_required') {
33
+ * if ('compose_hash' in result) {
34
34
  * // Register compose hash on-chain and get transaction hash
35
35
  * const txHash = await registerComposeHashOnChain(
36
36
  * result.compose_hash,
@@ -56,7 +56,7 @@ import { type Client } from "../../client";
56
56
  * `UpdatePreLaunchScriptResult | unknown`
57
57
  *
58
58
  * Returns either:
59
- * - `{ status: "in_progress", ... }` - Update initiated successfully
59
+ * - `{ status: "in_progress", ... }` - Update accepted; `finality_wait` is present while waiting for on-chain finality
60
60
  * - `{ status: "precondition_required", compose_hash: "...", ... }` - Compose hash verification required
61
61
  *
62
62
  * Return type depends on schema parameter.
@@ -101,12 +101,12 @@ import { type Client } from "../../client";
101
101
  * })
102
102
  *
103
103
  * if (result.success) {
104
- * if (result.data.status === 'precondition_required') {
104
+ * if ('compose_hash' in result.data) {
105
105
  * console.log(`Compose hash: ${result.data.compose_hash}`)
106
106
  * console.log(`App ID: ${result.data.app_id}`)
107
107
  * // Register on-chain and retry with transaction_hash
108
- * } else {
109
- * console.log(`Update started: ${result.data.correlation_id}`)
108
+ * } else if ('correlation_id' in result.data) {
109
+ * console.log(`Update accepted: ${result.data.correlation_id}`)
110
110
  * }
111
111
  * } else {
112
112
  * if ("isRequestError" in result.error) {
@@ -154,9 +154,48 @@ export declare const UpdatePreLaunchScriptRequestSchema: z.ZodPipe<z.ZodObject<{
154
154
  transaction_hash?: string | undefined;
155
155
  }>>;
156
156
  declare const UpdatePreLaunchScriptInProgressSchema: z.ZodObject<{
157
- status: z.ZodLiteral<"in_progress">;
157
+ status: z.ZodUnion<readonly [z.ZodEnum<{
158
+ in_progress: "in_progress";
159
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
160
+ correlation_id: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
161
+ finality_wait: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
162
+ operation: z.ZodUnion<readonly [z.ZodEnum<{
163
+ create: "create";
164
+ update: "update";
165
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
166
+ correlation_id: z.ZodString;
167
+ phase: z.ZodUnion<readonly [z.ZodEnum<{
168
+ applying: "applying";
169
+ awaiting_finality: "awaiting_finality";
170
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
171
+ stage: z.ZodUnion<readonly [z.ZodEnum<{
172
+ finalized: "finalized";
173
+ safe: "safe";
174
+ submitted: "submitted";
175
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
176
+ stages: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
177
+ applying: "applying";
178
+ finalized: "finalized";
179
+ safe: "safe";
180
+ submitted: "submitted";
181
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>>>;
182
+ transaction: z.ZodNullable<z.ZodObject<{
183
+ hash: z.ZodString;
184
+ block_number: z.ZodNumber;
185
+ chain_id: z.ZodNumber;
186
+ }, z.core.$strip>>;
187
+ finality: z.ZodObject<{
188
+ block_tag: z.ZodNullable<z.ZodUnion<readonly [z.ZodEnum<{
189
+ finalized: "finalized";
190
+ latest: "latest";
191
+ safe: "safe";
192
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>;
193
+ policy_block_number: z.ZodNullable<z.ZodNumber>;
194
+ blocks_remaining: z.ZodNullable<z.ZodNumber>;
195
+ eta_seconds: z.ZodNullable<z.ZodNumber>;
196
+ }, z.core.$strip>;
197
+ }, z.core.$strip>>>>;
158
198
  message: z.ZodString;
159
- correlation_id: z.ZodString;
160
199
  }, z.core.$strip>;
161
200
  declare const UpdatePreLaunchScriptPreconditionRequiredSchema: z.ZodObject<{
162
201
  status: z.ZodLiteral<"precondition_required">;
@@ -196,10 +235,6 @@ declare const UpdatePreLaunchScriptPreconditionRequiredSchema: z.ZodObject<{
196
235
  }>>;
197
236
  }, z.core.$strip>;
198
237
  export declare const UpdatePreLaunchScriptResultSchema: z.ZodUnion<readonly [z.ZodObject<{
199
- status: z.ZodLiteral<"in_progress">;
200
- message: z.ZodString;
201
- correlation_id: z.ZodString;
202
- }, z.core.$strip>, z.ZodObject<{
203
238
  status: z.ZodLiteral<"precondition_required">;
204
239
  message: z.ZodString;
205
240
  compose_hash: z.ZodString;
@@ -238,6 +273,49 @@ export declare const UpdatePreLaunchScriptResultSchema: z.ZodUnion<readonly [z.Z
238
273
  }, z.core.$strip>, z.ZodObject<{
239
274
  status: z.ZodLiteral<"no_change">;
240
275
  message: z.ZodString;
276
+ }, z.core.$strip>, z.ZodObject<{
277
+ status: z.ZodUnion<readonly [z.ZodEnum<{
278
+ in_progress: "in_progress";
279
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
280
+ correlation_id: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
281
+ finality_wait: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
282
+ operation: z.ZodUnion<readonly [z.ZodEnum<{
283
+ create: "create";
284
+ update: "update";
285
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
286
+ correlation_id: z.ZodString;
287
+ phase: z.ZodUnion<readonly [z.ZodEnum<{
288
+ applying: "applying";
289
+ awaiting_finality: "awaiting_finality";
290
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
291
+ stage: z.ZodUnion<readonly [z.ZodEnum<{
292
+ finalized: "finalized";
293
+ safe: "safe";
294
+ submitted: "submitted";
295
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
296
+ stages: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
297
+ applying: "applying";
298
+ finalized: "finalized";
299
+ safe: "safe";
300
+ submitted: "submitted";
301
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>>>;
302
+ transaction: z.ZodNullable<z.ZodObject<{
303
+ hash: z.ZodString;
304
+ block_number: z.ZodNumber;
305
+ chain_id: z.ZodNumber;
306
+ }, z.core.$strip>>;
307
+ finality: z.ZodObject<{
308
+ block_tag: z.ZodNullable<z.ZodUnion<readonly [z.ZodEnum<{
309
+ finalized: "finalized";
310
+ latest: "latest";
311
+ safe: "safe";
312
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>;
313
+ policy_block_number: z.ZodNullable<z.ZodNumber>;
314
+ blocks_remaining: z.ZodNullable<z.ZodNumber>;
315
+ eta_seconds: z.ZodNullable<z.ZodNumber>;
316
+ }, z.core.$strip>;
317
+ }, z.core.$strip>>>>;
318
+ message: z.ZodString;
241
319
  }, z.core.$strip>]>;
242
320
  export type UpdatePreLaunchScriptRequest = z.input<typeof UpdatePreLaunchScriptRequestSchema>;
243
321
  export type UpdatePreLaunchScriptResult = z.infer<typeof UpdatePreLaunchScriptResultSchema>;
@@ -249,7 +327,7 @@ export type UpdatePreLaunchScriptPreconditionRequired = z.infer<typeof UpdatePre
249
327
  * @param client - The API client
250
328
  * @param request - Request parameters containing CVM ID and pre-launch script content
251
329
  * @param parameters - Optional behavior parameters
252
- * @returns Update result (either in_progress or precondition_required)
330
+ * @returns Whether registration is required, the update was accepted, or nothing changed
253
331
  */
254
332
  declare const updatePreLaunchScript: {
255
333
  (client: Client<import("../..").ApiVersion>, params: {
@@ -262,10 +340,6 @@ declare const updatePreLaunchScript: {
262
340
  compose_hash?: string | undefined;
263
341
  transaction_hash?: string | undefined;
264
342
  }): Promise<{
265
- status: "in_progress";
266
- message: string;
267
- correlation_id: string;
268
- } | {
269
343
  status: "precondition_required";
270
344
  message: string;
271
345
  compose_hash: string;
@@ -285,6 +359,28 @@ declare const updatePreLaunchScript: {
285
359
  } | {
286
360
  status: "no_change";
287
361
  message: string;
362
+ } | {
363
+ status: "in_progress" | (string & Record<never, never>);
364
+ correlation_id: string;
365
+ finality_wait?: {
366
+ operation: "create" | "update" | (string & Record<never, never>);
367
+ correlation_id: string;
368
+ phase: "applying" | "awaiting_finality" | (string & Record<never, never>);
369
+ stage: "finalized" | "safe" | "submitted" | (string & Record<never, never>);
370
+ stages?: ("applying" | "finalized" | "safe" | "submitted" | (string & Record<never, never>))[] | undefined;
371
+ transaction: {
372
+ hash: string;
373
+ block_number: number;
374
+ chain_id: number;
375
+ } | null;
376
+ finality: {
377
+ block_tag: "finalized" | "latest" | "safe" | (string & Record<never, never>) | null;
378
+ policy_block_number: number | null;
379
+ blocks_remaining: number | null;
380
+ eta_seconds: number | null;
381
+ };
382
+ } | null | undefined;
383
+ message: string;
288
384
  }>;
289
385
  <T extends z.ZodTypeAny>(client: Client<import("../..").ApiVersion>, params: {
290
386
  id?: string | undefined;
@@ -321,10 +417,6 @@ declare const updatePreLaunchScript: {
321
417
  compose_hash?: string | undefined;
322
418
  transaction_hash?: string | undefined;
323
419
  }): Promise<import("../..").SafeResult<{
324
- status: "in_progress";
325
- message: string;
326
- correlation_id: string;
327
- } | {
328
420
  status: "precondition_required";
329
421
  message: string;
330
422
  compose_hash: string;
@@ -344,6 +436,28 @@ declare const updatePreLaunchScript: {
344
436
  } | {
345
437
  status: "no_change";
346
438
  message: string;
439
+ } | {
440
+ status: "in_progress" | (string & Record<never, never>);
441
+ correlation_id: string;
442
+ finality_wait?: {
443
+ operation: "create" | "update" | (string & Record<never, never>);
444
+ correlation_id: string;
445
+ phase: "applying" | "awaiting_finality" | (string & Record<never, never>);
446
+ stage: "finalized" | "safe" | "submitted" | (string & Record<never, never>);
447
+ stages?: ("applying" | "finalized" | "safe" | "submitted" | (string & Record<never, never>))[] | undefined;
448
+ transaction: {
449
+ hash: string;
450
+ block_number: number;
451
+ chain_id: number;
452
+ } | null;
453
+ finality: {
454
+ block_tag: "finalized" | "latest" | "safe" | (string & Record<never, never>) | null;
455
+ policy_block_number: number | null;
456
+ blocks_remaining: number | null;
457
+ eta_seconds: number | null;
458
+ };
459
+ } | null | undefined;
460
+ message: string;
347
461
  }>>;
348
462
  <T extends z.ZodTypeAny>(client: Client<import("../..").ApiVersion>, params: {
349
463
  id?: string | undefined;
@@ -11,6 +11,12 @@ import { z } from "zod";
11
11
  * `precondition_required` with a compose hash to register on-chain. After
12
12
  * registration, retry with `compose_hash` and `transaction_hash`.
13
13
  *
14
+ * Pass `confirmFinalityReplacement: "none"` to require confirmation before
15
+ * replacing a waiting update. If the API returns HTTP 412 (`ERR-03-067`),
16
+ * review the pending update identified by `correlation_id` in the error details.
17
+ * Pass that exact ID to confirm replacement. If the pending ID changes, review
18
+ * the new update and confirm again. Omitting the option preserves the server default.
19
+ *
14
20
  * @example
15
21
  * ```typescript
16
22
  * import { createClient, upgradePreLaunchScript } from '@phala/cloud'
@@ -20,7 +26,7 @@ import { z } from "zod";
20
26
  * // Phase 1: kick off the upgrade
21
27
  * const result = await upgradePreLaunchScript(client, { id: 'cvm-123' })
22
28
  *
23
- * if (result.status === 'precondition_required') {
29
+ * if ('compose_hash' in result) {
24
30
  * // Register compose hash on-chain, then retry with the headers
25
31
  * const txHash = await registerComposeHashOnChain(result.compose_hash, result.kms_info)
26
32
  * await upgradePreLaunchScript(client, {
@@ -39,12 +45,14 @@ export declare const UpgradePreLaunchScriptRequestSchema: z.ZodPipe<z.ZodObject<
39
45
  name: z.ZodOptional<z.ZodString>;
40
46
  compose_hash: z.ZodOptional<z.ZodString>;
41
47
  transaction_hash: z.ZodOptional<z.ZodString>;
48
+ confirmFinalityReplacement: z.ZodOptional<z.ZodString>;
42
49
  }, z.core.$strip>, z.ZodTransform<{
43
50
  cvmId: string;
44
51
  request: {
45
52
  compose_hash: string | undefined;
46
53
  transaction_hash: string | undefined;
47
54
  };
55
+ confirmFinalityReplacement: string | undefined;
48
56
  _raw: {
49
57
  id?: string | undefined;
50
58
  uuid?: string | undefined;
@@ -53,6 +61,7 @@ export declare const UpgradePreLaunchScriptRequestSchema: z.ZodPipe<z.ZodObject<
53
61
  name?: string | undefined;
54
62
  compose_hash?: string | undefined;
55
63
  transaction_hash?: string | undefined;
64
+ confirmFinalityReplacement?: string | undefined;
56
65
  };
57
66
  }, {
58
67
  id?: string | undefined;
@@ -62,11 +71,51 @@ export declare const UpgradePreLaunchScriptRequestSchema: z.ZodPipe<z.ZodObject<
62
71
  name?: string | undefined;
63
72
  compose_hash?: string | undefined;
64
73
  transaction_hash?: string | undefined;
74
+ confirmFinalityReplacement?: string | undefined;
65
75
  }>>;
66
76
  declare const UpgradePreLaunchScriptInProgressSchema: z.ZodObject<{
67
- status: z.ZodLiteral<"in_progress">;
77
+ status: z.ZodUnion<readonly [z.ZodEnum<{
78
+ in_progress: "in_progress";
79
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
80
+ correlation_id: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
81
+ finality_wait: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
82
+ operation: z.ZodUnion<readonly [z.ZodEnum<{
83
+ create: "create";
84
+ update: "update";
85
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
86
+ correlation_id: z.ZodString;
87
+ phase: z.ZodUnion<readonly [z.ZodEnum<{
88
+ applying: "applying";
89
+ awaiting_finality: "awaiting_finality";
90
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
91
+ stage: z.ZodUnion<readonly [z.ZodEnum<{
92
+ finalized: "finalized";
93
+ safe: "safe";
94
+ submitted: "submitted";
95
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
96
+ stages: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
97
+ applying: "applying";
98
+ finalized: "finalized";
99
+ safe: "safe";
100
+ submitted: "submitted";
101
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>>>;
102
+ transaction: z.ZodNullable<z.ZodObject<{
103
+ hash: z.ZodString;
104
+ block_number: z.ZodNumber;
105
+ chain_id: z.ZodNumber;
106
+ }, z.core.$strip>>;
107
+ finality: z.ZodObject<{
108
+ block_tag: z.ZodNullable<z.ZodUnion<readonly [z.ZodEnum<{
109
+ finalized: "finalized";
110
+ latest: "latest";
111
+ safe: "safe";
112
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>;
113
+ policy_block_number: z.ZodNullable<z.ZodNumber>;
114
+ blocks_remaining: z.ZodNullable<z.ZodNumber>;
115
+ eta_seconds: z.ZodNullable<z.ZodNumber>;
116
+ }, z.core.$strip>;
117
+ }, z.core.$strip>>>>;
68
118
  message: z.ZodString;
69
- correlation_id: z.ZodString;
70
119
  }, z.core.$strip>;
71
120
  declare const UpgradePreLaunchScriptPreconditionRequiredSchema: z.ZodObject<{
72
121
  status: z.ZodLiteral<"precondition_required">;
@@ -106,10 +155,6 @@ declare const UpgradePreLaunchScriptPreconditionRequiredSchema: z.ZodObject<{
106
155
  }>>;
107
156
  }, z.core.$strip>;
108
157
  export declare const UpgradePreLaunchScriptResultSchema: z.ZodUnion<readonly [z.ZodObject<{
109
- status: z.ZodLiteral<"in_progress">;
110
- message: z.ZodString;
111
- correlation_id: z.ZodString;
112
- }, z.core.$strip>, z.ZodObject<{
113
158
  status: z.ZodLiteral<"precondition_required">;
114
159
  message: z.ZodString;
115
160
  compose_hash: z.ZodString;
@@ -145,6 +190,49 @@ export declare const UpgradePreLaunchScriptResultSchema: z.ZodUnion<readonly [z.
145
190
  gateway_app_id: `0x${string}`;
146
191
  k256_pubkey?: string | null | undefined;
147
192
  }>>;
193
+ }, z.core.$strip>, z.ZodObject<{
194
+ status: z.ZodUnion<readonly [z.ZodEnum<{
195
+ in_progress: "in_progress";
196
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
197
+ correlation_id: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
198
+ finality_wait: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
199
+ operation: z.ZodUnion<readonly [z.ZodEnum<{
200
+ create: "create";
201
+ update: "update";
202
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
203
+ correlation_id: z.ZodString;
204
+ phase: z.ZodUnion<readonly [z.ZodEnum<{
205
+ applying: "applying";
206
+ awaiting_finality: "awaiting_finality";
207
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
208
+ stage: z.ZodUnion<readonly [z.ZodEnum<{
209
+ finalized: "finalized";
210
+ safe: "safe";
211
+ submitted: "submitted";
212
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
213
+ stages: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
214
+ applying: "applying";
215
+ finalized: "finalized";
216
+ safe: "safe";
217
+ submitted: "submitted";
218
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>>>;
219
+ transaction: z.ZodNullable<z.ZodObject<{
220
+ hash: z.ZodString;
221
+ block_number: z.ZodNumber;
222
+ chain_id: z.ZodNumber;
223
+ }, z.core.$strip>>;
224
+ finality: z.ZodObject<{
225
+ block_tag: z.ZodNullable<z.ZodUnion<readonly [z.ZodEnum<{
226
+ finalized: "finalized";
227
+ latest: "latest";
228
+ safe: "safe";
229
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>;
230
+ policy_block_number: z.ZodNullable<z.ZodNumber>;
231
+ blocks_remaining: z.ZodNullable<z.ZodNumber>;
232
+ eta_seconds: z.ZodNullable<z.ZodNumber>;
233
+ }, z.core.$strip>;
234
+ }, z.core.$strip>>>>;
235
+ message: z.ZodString;
148
236
  }, z.core.$strip>]>;
149
237
  export type UpgradePreLaunchScriptRequest = z.input<typeof UpgradePreLaunchScriptRequestSchema>;
150
238
  export type UpgradePreLaunchScriptResult = z.infer<typeof UpgradePreLaunchScriptResultSchema>;
@@ -159,11 +247,8 @@ declare const upgradePreLaunchScript: {
159
247
  name?: string | undefined;
160
248
  compose_hash?: string | undefined;
161
249
  transaction_hash?: string | undefined;
250
+ confirmFinalityReplacement?: string | undefined;
162
251
  }): Promise<{
163
- status: "in_progress";
164
- message: string;
165
- correlation_id: string;
166
- } | {
167
252
  status: "precondition_required";
168
253
  message: string;
169
254
  compose_hash: string;
@@ -180,6 +265,28 @@ declare const upgradePreLaunchScript: {
180
265
  gateway_app_id: `0x${string}`;
181
266
  k256_pubkey?: string | null | undefined;
182
267
  };
268
+ } | {
269
+ status: "in_progress" | (string & Record<never, never>);
270
+ correlation_id: string;
271
+ finality_wait?: {
272
+ operation: "create" | "update" | (string & Record<never, never>);
273
+ correlation_id: string;
274
+ phase: "applying" | "awaiting_finality" | (string & Record<never, never>);
275
+ stage: "finalized" | "safe" | "submitted" | (string & Record<never, never>);
276
+ stages?: ("applying" | "finalized" | "safe" | "submitted" | (string & Record<never, never>))[] | undefined;
277
+ transaction: {
278
+ hash: string;
279
+ block_number: number;
280
+ chain_id: number;
281
+ } | null;
282
+ finality: {
283
+ block_tag: "finalized" | "latest" | "safe" | (string & Record<never, never>) | null;
284
+ policy_block_number: number | null;
285
+ blocks_remaining: number | null;
286
+ eta_seconds: number | null;
287
+ };
288
+ } | null | undefined;
289
+ message: string;
183
290
  }>;
184
291
  <T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
185
292
  id?: string | undefined;
@@ -189,6 +296,7 @@ declare const upgradePreLaunchScript: {
189
296
  name?: string | undefined;
190
297
  compose_hash?: string | undefined;
191
298
  transaction_hash?: string | undefined;
299
+ confirmFinalityReplacement?: string | undefined;
192
300
  }, parameters: {
193
301
  schema: T;
194
302
  }): Promise<z.infer<T>>;
@@ -200,6 +308,7 @@ declare const upgradePreLaunchScript: {
200
308
  name?: string | undefined;
201
309
  compose_hash?: string | undefined;
202
310
  transaction_hash?: string | undefined;
311
+ confirmFinalityReplacement?: string | undefined;
203
312
  }, parameters: {
204
313
  schema: false;
205
314
  }): Promise<unknown>;
@@ -212,11 +321,8 @@ declare const upgradePreLaunchScript: {
212
321
  name?: string | undefined;
213
322
  compose_hash?: string | undefined;
214
323
  transaction_hash?: string | undefined;
324
+ confirmFinalityReplacement?: string | undefined;
215
325
  }): Promise<import("../..").SafeResult<{
216
- status: "in_progress";
217
- message: string;
218
- correlation_id: string;
219
- } | {
220
326
  status: "precondition_required";
221
327
  message: string;
222
328
  compose_hash: string;
@@ -233,6 +339,28 @@ declare const upgradePreLaunchScript: {
233
339
  gateway_app_id: `0x${string}`;
234
340
  k256_pubkey?: string | null | undefined;
235
341
  };
342
+ } | {
343
+ status: "in_progress" | (string & Record<never, never>);
344
+ correlation_id: string;
345
+ finality_wait?: {
346
+ operation: "create" | "update" | (string & Record<never, never>);
347
+ correlation_id: string;
348
+ phase: "applying" | "awaiting_finality" | (string & Record<never, never>);
349
+ stage: "finalized" | "safe" | "submitted" | (string & Record<never, never>);
350
+ stages?: ("applying" | "finalized" | "safe" | "submitted" | (string & Record<never, never>))[] | undefined;
351
+ transaction: {
352
+ hash: string;
353
+ block_number: number;
354
+ chain_id: number;
355
+ } | null;
356
+ finality: {
357
+ block_tag: "finalized" | "latest" | "safe" | (string & Record<never, never>) | null;
358
+ policy_block_number: number | null;
359
+ blocks_remaining: number | null;
360
+ eta_seconds: number | null;
361
+ };
362
+ } | null | undefined;
363
+ message: string;
236
364
  }>>;
237
365
  <T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
238
366
  id?: string | undefined;
@@ -242,6 +370,7 @@ declare const upgradePreLaunchScript: {
242
370
  name?: string | undefined;
243
371
  compose_hash?: string | undefined;
244
372
  transaction_hash?: string | undefined;
373
+ confirmFinalityReplacement?: string | undefined;
245
374
  }, parameters: {
246
375
  schema: T;
247
376
  }): Promise<import("../..").SafeResult<z.infer<T>>>;
@@ -253,6 +382,7 @@ declare const upgradePreLaunchScript: {
253
382
  name?: string | undefined;
254
383
  compose_hash?: string | undefined;
255
384
  transaction_hash?: string | undefined;
385
+ confirmFinalityReplacement?: string | undefined;
256
386
  }, parameters: {
257
387
  schema: false;
258
388
  }): Promise<import("../..").SafeResult<unknown>>;
@@ -0,0 +1,153 @@
1
+ import { z } from "zod";
2
+ import type { ApiVersion, Client, SafeResult } from "../../client";
3
+ import { type CvmFinalityWait } from "../../types/cvm_finality";
4
+ import { type CvmIdInput } from "../../types/cvm_id";
5
+ import { PhalaCloudError } from "../../utils/errors";
6
+ export declare const CvmFinalityOperationSchema: z.ZodPipe<z.ZodObject<{
7
+ correlation_id: z.ZodString;
8
+ operation_type: z.ZodString;
9
+ status: z.ZodUnion<readonly [z.ZodEnum<{
10
+ cancelled: "cancelled";
11
+ completed: "completed";
12
+ failed: "failed";
13
+ in_progress: "in_progress";
14
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
15
+ finality_wait: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
16
+ operation: z.ZodUnion<readonly [z.ZodEnum<{
17
+ create: "create";
18
+ update: "update";
19
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
20
+ correlation_id: z.ZodString;
21
+ phase: z.ZodUnion<readonly [z.ZodEnum<{
22
+ applying: "applying";
23
+ awaiting_finality: "awaiting_finality";
24
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
25
+ stage: z.ZodUnion<readonly [z.ZodEnum<{
26
+ finalized: "finalized";
27
+ safe: "safe";
28
+ submitted: "submitted";
29
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>;
30
+ stages: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
31
+ applying: "applying";
32
+ finalized: "finalized";
33
+ safe: "safe";
34
+ submitted: "submitted";
35
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>>>;
36
+ transaction: z.ZodNullable<z.ZodObject<{
37
+ hash: z.ZodString;
38
+ block_number: z.ZodNumber;
39
+ chain_id: z.ZodNumber;
40
+ }, z.core.$strip>>;
41
+ finality: z.ZodObject<{
42
+ block_tag: z.ZodNullable<z.ZodUnion<readonly [z.ZodEnum<{
43
+ finalized: "finalized";
44
+ latest: "latest";
45
+ safe: "safe";
46
+ }>, z.ZodCustom<string & Record<never, never>, string & Record<never, never>>]>>;
47
+ policy_block_number: z.ZodNullable<z.ZodNumber>;
48
+ blocks_remaining: z.ZodNullable<z.ZodNumber>;
49
+ eta_seconds: z.ZodNullable<z.ZodNumber>;
50
+ }, z.core.$strip>;
51
+ }, z.core.$strip>>>>;
52
+ failure_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ error_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
+ }, z.core.$strip>, z.ZodTransform<{
55
+ correlation_id: string;
56
+ operation_type: string;
57
+ status: "cancelled" | "completed" | "failed" | "in_progress" | (string & Record<never, never>);
58
+ finality_wait?: {
59
+ operation: "create" | "update" | (string & Record<never, never>);
60
+ correlation_id: string;
61
+ phase: "applying" | "awaiting_finality" | (string & Record<never, never>);
62
+ stage: "finalized" | "safe" | "submitted" | (string & Record<never, never>);
63
+ stages?: ("applying" | "finalized" | "safe" | "submitted" | (string & Record<never, never>))[] | undefined;
64
+ transaction: {
65
+ hash: string;
66
+ block_number: number;
67
+ chain_id: number;
68
+ } | null;
69
+ finality: {
70
+ block_tag: "finalized" | "latest" | "safe" | (string & Record<never, never>) | null;
71
+ policy_block_number: number | null;
72
+ blocks_remaining: number | null;
73
+ eta_seconds: number | null;
74
+ };
75
+ } | null | undefined;
76
+ failure_reason?: string | null | undefined;
77
+ error_message?: string | null | undefined;
78
+ }, {
79
+ correlation_id: string;
80
+ operation_type: string;
81
+ status: "cancelled" | "completed" | "failed" | "in_progress" | (string & Record<never, never>);
82
+ finality_wait?: {
83
+ operation: "create" | "update" | (string & Record<never, never>);
84
+ correlation_id: string;
85
+ phase: "applying" | "awaiting_finality" | (string & Record<never, never>);
86
+ stage: "finalized" | "safe" | "submitted" | (string & Record<never, never>);
87
+ stages?: ("applying" | "finalized" | "safe" | "submitted" | (string & Record<never, never>))[] | undefined;
88
+ transaction: {
89
+ hash: string;
90
+ block_number: number;
91
+ chain_id: number;
92
+ } | null;
93
+ finality: {
94
+ block_tag: "finalized" | "latest" | "safe" | (string & Record<never, never>) | null;
95
+ policy_block_number: number | null;
96
+ blocks_remaining: number | null;
97
+ eta_seconds: number | null;
98
+ };
99
+ } | null | undefined;
100
+ failure_reason?: string | null | undefined;
101
+ error_message?: string | null | undefined;
102
+ }>>;
103
+ export type CvmFinalityOperation = z.infer<typeof CvmFinalityOperationSchema>;
104
+ export type WaitForCvmFinalityRequest = CvmIdInput & {
105
+ /** The correlation ID returned when Phala Cloud accepted the operation. */
106
+ correlationId: string;
107
+ };
108
+ export interface WaitForCvmFinalityOptions {
109
+ /** Maximum local wait in milliseconds (default: 30 minutes). Does not cancel the operation. */
110
+ timeoutMs?: number;
111
+ /** Time between reads in milliseconds (default: 15 seconds), before server retry guidance. */
112
+ pollIntervalMs?: number;
113
+ /** Stops waiting locally without canceling the operation. */
114
+ signal?: AbortSignal;
115
+ /** Called on the first reported stage and whenever the stage or phase changes. */
116
+ onStage?: (status: CvmFinalityWait) => void;
117
+ }
118
+ export type WaitForCvmFinalityResult = CvmFinalityOperation & {
119
+ status: "completed";
120
+ };
121
+ declare const OperationFailureReasonSchema: z.ZodEnum<{
122
+ apply_failed: "apply_failed";
123
+ boot_failed: "boot_failed";
124
+ cancelled: "cancelled";
125
+ outdated: "outdated";
126
+ registration_removed: "registration_removed";
127
+ superseded: "superseded";
128
+ tx_dropped: "tx_dropped";
129
+ tx_reverted: "tx_reverted";
130
+ }>;
131
+ export type CvmFinalityWaitErrorReason = z.infer<typeof OperationFailureReasonSchema> | "failed" | "timeout" | "aborted" | "callback_failed" | "unexpected";
132
+ export declare class CvmFinalityWaitError extends Error {
133
+ readonly reason: CvmFinalityWaitErrorReason;
134
+ /** Terminal operation, including the raw server failure reason if it is unrecognized. */
135
+ readonly operation?: CvmFinalityOperation | undefined;
136
+ readonly cause?: unknown;
137
+ constructor(reason: CvmFinalityWaitErrorReason, message: string,
138
+ /** Terminal operation, including the raw server failure reason if it is unrecognized. */
139
+ operation?: CvmFinalityOperation | undefined, cause?: unknown);
140
+ }
141
+ export type WaitForCvmFinalityError = CvmFinalityWaitError | PhalaCloudError | z.ZodError;
142
+ /**
143
+ * Wait for the operation identified by its acceptance correlation ID to complete.
144
+ * On-chain finality alone is not completion: Phala Cloud still has to apply the change.
145
+ * A missing operation or an absent finality status is not a terminal result.
146
+ * If the correlation ID does not appear in the operation history, polling continues
147
+ * until `timeoutMs`; there is no separate grace period. A timeout error's `cause`
148
+ * is the last transient polling error, if there was one.
149
+ */
150
+ export declare function waitForCvmFinality(client: Client<ApiVersion>, request: WaitForCvmFinalityRequest, options?: WaitForCvmFinalityOptions): Promise<WaitForCvmFinalityResult>;
151
+ /** Like waitForCvmFinality, but returns the failure instead of throwing. */
152
+ export declare function safeWaitForCvmFinality(client: Client<ApiVersion>, request: WaitForCvmFinalityRequest, options?: WaitForCvmFinalityOptions): Promise<SafeResult<WaitForCvmFinalityResult, WaitForCvmFinalityError>>;
153
+ export {};