@layr-labs/ecloud-sdk 1.0.0-devep8 → 1.0.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.
@@ -0,0 +1,465 @@
1
+ import { WalletClient, PublicClient, Address, Hex } from 'viem';
2
+ import { a4 as PreparedDeploy, L as GasEstimate, F as EnvironmentConfig, U as Logger, w as DeployResult, a7 as PreparedUpgrade, A as AppId, t as DeployAppOpts, an as UpgradeAppOpts, a0 as PrepareDeployOpts, $ as PrepareDeployFromVerifiableBuildOpts, I as ExecuteDeployResult, a3 as PrepareUpgradeOpts, a2 as PrepareUpgradeFromVerifiableBuildOpts, K as ExecuteUpgradeResult, g as AppProfile, h as AppProfileResponse, R as LifecycleOpts, e as AppConfig } from './index-BVnxNfqb.js';
3
+ import { L as LogVisibility, R as ResourceUsageMonitoring } from './validation-D3yIUF-Z.js';
4
+
5
+ /**
6
+ * Main deploy function
7
+ *
8
+ * This is the main entry point for deploying applications to ecloud TEE.
9
+ * It orchestrates all the steps: build, push, encrypt, and deploy on-chain.
10
+ *
11
+ * NOTE: This SDK function is non-interactive. All required parameters must be
12
+ * provided explicitly. Use the CLI for interactive parameter collection.
13
+ */
14
+
15
+ /**
16
+ * Required deploy options for SDK (non-interactive)
17
+ *
18
+ * Accepts viem's WalletClient and PublicClient for transaction signing.
19
+ * The caller is responsible for creating these clients (e.g., from a private key).
20
+ */
21
+ interface SDKDeployOptions {
22
+ /** Wallet client for signing transactions */
23
+ walletClient: WalletClient;
24
+ /** Public client for reading blockchain state */
25
+ publicClient: PublicClient;
26
+ /** Environment name (e.g., 'sepolia', 'mainnet-alpha') - defaults to 'sepolia' */
27
+ environment?: string;
28
+ /** Path to Dockerfile (if building from Dockerfile) - either this or imageRef is required */
29
+ dockerfilePath?: string;
30
+ /** Image reference (registry/path:tag) - either this or dockerfilePath is required */
31
+ imageRef?: string;
32
+ /** Path to .env file - optional */
33
+ envFilePath?: string;
34
+ /** App name - required */
35
+ appName: string;
36
+ /** Instance type SKU - required */
37
+ instanceType: string;
38
+ /** Log visibility setting - required */
39
+ logVisibility: LogVisibility;
40
+ /** Resource usage monitoring setting - optional, defaults to 'enable' */
41
+ resourceUsageMonitoring?: ResourceUsageMonitoring;
42
+ /** Billing mode: developer (default) or app (isolated billing) */
43
+ billTo?: "developer" | "app";
44
+ /** Skip quota check */
45
+ skipQuotaCheck?: boolean;
46
+ /** Optional salt for deterministic app address prediction (32 bytes) */
47
+ salt?: Uint8Array | Buffer;
48
+ /** Optional gas params from estimation (use result from prepareDeploy) */
49
+ gas?: GasEstimate;
50
+ /** Skip telemetry (used when called from CLI) - optional */
51
+ skipTelemetry?: boolean;
52
+ }
53
+ /**
54
+ * Result from prepareDeploy - includes prepared batch and gas estimate
55
+ */
56
+ interface PrepareDeployResult {
57
+ /** Prepared deployment state */
58
+ prepared: PreparedDeploy;
59
+ /** Gas estimate for the batch transaction */
60
+ gasEstimate: GasEstimate;
61
+ }
62
+ /** Options for executing a prepared deployment */
63
+ interface ExecuteDeployOptions {
64
+ prepared: PreparedDeploy;
65
+ context: {
66
+ walletClient: WalletClient;
67
+ publicClient: PublicClient;
68
+ environmentConfig: EnvironmentConfig;
69
+ };
70
+ gas?: GasEstimate;
71
+ logger?: Logger;
72
+ skipTelemetry?: boolean;
73
+ }
74
+ /**
75
+ * Options for verifiable build deployment
76
+ *
77
+ * Similar to SDKDeployOptions but uses a pre-built image with known digest
78
+ * instead of building from Dockerfile.
79
+ */
80
+ interface VerifiableBuildOptions {
81
+ /** Wallet client for signing transactions */
82
+ walletClient: WalletClient;
83
+ /** Public client for reading blockchain state */
84
+ publicClient: PublicClient;
85
+ /** Environment name (e.g., 'sepolia', 'mainnet-alpha') - defaults to 'sepolia' */
86
+ environment?: string;
87
+ /** Image reference (registry/path:tag) - required */
88
+ imageRef: string;
89
+ /** Image digest (sha256:...) - required */
90
+ imageDigest: string;
91
+ /** Path to .env file - optional */
92
+ envFilePath?: string;
93
+ /** App name - required */
94
+ appName: string;
95
+ /** Instance type SKU - required */
96
+ instanceType: string;
97
+ /** Log visibility setting - required */
98
+ logVisibility: LogVisibility;
99
+ /** Resource usage monitoring setting - optional, defaults to 'enable' */
100
+ resourceUsageMonitoring?: ResourceUsageMonitoring;
101
+ /** Billing mode: developer (default) or app (isolated billing) */
102
+ billTo?: "developer" | "app";
103
+ /** Skip quota check */
104
+ skipQuotaCheck?: boolean;
105
+ /** Skip telemetry (used when called from CLI) - optional */
106
+ skipTelemetry?: boolean;
107
+ }
108
+ /**
109
+ * Prepare a deployment from a pre-built image (already layered) without using Docker locally.
110
+ *
111
+ * This is intended for verifiable builds where the build service outputs:
112
+ * - imageRef (tagged image URL)
113
+ * - imageDigest (sha256:... digest)
114
+ *
115
+ * Flow is the same as prepareDeploy, except:
116
+ * - Skips ensureDockerIsRunning()
117
+ * - Skips prepareRelease() image layering and digest extraction
118
+ * - Uses provided imageDigest + derived registry name to construct the Release struct
119
+ */
120
+ declare function prepareDeployFromVerifiableBuild(options: VerifiableBuildOptions, logger?: Logger): Promise<PrepareDeployResult>;
121
+ /**
122
+ * Prepare deployment - does all work up to the transaction
123
+ *
124
+ * This allows CLI to:
125
+ * 1. Call prepareDeploy to build image, prepare release, get gas estimate
126
+ * 2. Prompt user to confirm the cost
127
+ * 3. Call executeDeploy with confirmed gas params
128
+ */
129
+ declare function prepareDeploy(options: Omit<SDKDeployOptions, "gas"> & {
130
+ skipTelemetry?: boolean;
131
+ }, logger?: Logger): Promise<PrepareDeployResult>;
132
+ /**
133
+ * Execute a prepared deployment
134
+ *
135
+ * Call this after prepareDeploy and user confirmation.
136
+ * Note: This only submits the on-chain transaction. Call watchDeployment separately
137
+ * to wait for the app to be running.
138
+ */
139
+ declare function executeDeploy(options: ExecuteDeployOptions): Promise<DeployResult>;
140
+ /**
141
+ * Watch a deployment until the app is running
142
+ *
143
+ * Call this after executeDeploy to wait for the app to be provisioned.
144
+ * Can be called separately to allow for intermediate operations (e.g., profile upload).
145
+ */
146
+ interface WatchDeploymentOptions {
147
+ timeoutSeconds?: number;
148
+ }
149
+ declare function watchDeployment(appId: string, walletClient: WalletClient, publicClient: PublicClient, environmentConfig: EnvironmentConfig, logger?: Logger, skipTelemetry?: boolean, opts?: WatchDeploymentOptions): Promise<string | undefined>;
150
+
151
+ /**
152
+ * Main upgrade function
153
+ *
154
+ * This is the main entry point for upgrading existing applications on ecloud TEE.
155
+ * It orchestrates all the steps: build, push, encrypt, and upgrade on-chain.
156
+ *
157
+ * NOTE: This SDK function is non-interactive. All required parameters must be
158
+ * provided explicitly. Use the CLI for interactive parameter collection.
159
+ */
160
+
161
+ /**
162
+ * Required upgrade options for SDK (non-interactive)
163
+ */
164
+ interface SDKUpgradeOptions {
165
+ /** App ID to upgrade - required */
166
+ appId: string | Address;
167
+ /** Wallet client for signing transactions */
168
+ walletClient: WalletClient;
169
+ /** Public client for reading blockchain state */
170
+ publicClient: PublicClient;
171
+ /** Environment name (e.g., 'sepolia', 'mainnet-alpha') - defaults to 'sepolia' */
172
+ environment?: string;
173
+ /** Path to Dockerfile (if building from Dockerfile) - either this or imageRef is required */
174
+ dockerfilePath?: string;
175
+ /** Image reference (registry/path:tag) - either this or dockerfilePath is required */
176
+ imageRef?: string;
177
+ /** Path to .env file - optional */
178
+ envFilePath?: string;
179
+ /** Instance type SKU - required */
180
+ instanceType: string;
181
+ /** Log visibility setting - required */
182
+ logVisibility: LogVisibility;
183
+ /** Resource usage monitoring setting - optional, defaults to 'enable' */
184
+ resourceUsageMonitoring?: ResourceUsageMonitoring;
185
+ /** Optional gas params from estimation (use result from prepareUpgrade) */
186
+ gas?: GasEstimate;
187
+ /** Skip telemetry (used when called from CLI) - optional */
188
+ skipTelemetry?: boolean;
189
+ }
190
+ interface UpgradeResult {
191
+ /** App ID (contract address) */
192
+ appId: AppId;
193
+ /** Final image reference */
194
+ imageRef: string;
195
+ /** Transaction hash */
196
+ txHash: Hex;
197
+ }
198
+ /**
199
+ * Result from prepareUpgrade - includes prepared batch and gas estimate
200
+ */
201
+ interface PrepareUpgradeResult {
202
+ /** Prepared upgrade state */
203
+ prepared: PreparedUpgrade;
204
+ /** Gas estimate for the batch transaction */
205
+ gasEstimate: GasEstimate;
206
+ }
207
+ /** Options for executing a prepared upgrade */
208
+ interface ExecuteUpgradeOptions {
209
+ prepared: PreparedUpgrade;
210
+ context: {
211
+ walletClient: WalletClient;
212
+ publicClient: PublicClient;
213
+ environmentConfig: EnvironmentConfig;
214
+ };
215
+ gas?: GasEstimate;
216
+ logger?: Logger;
217
+ skipTelemetry?: boolean;
218
+ }
219
+ /**
220
+ * Prepare an upgrade from a pre-built image (already layered) without using Docker locally.
221
+ *
222
+ * Intended for verifiable builds: build service provides imageRef + imageDigest (sha256:...).
223
+ * This skips:
224
+ * - ensureDockerIsRunning()
225
+ * - prepareRelease() layering/digest extraction
226
+ */
227
+ declare function prepareUpgradeFromVerifiableBuild(options: Omit<SDKUpgradeOptions, "gas" | "dockerfilePath" | "imageRef"> & {
228
+ imageRef: string;
229
+ imageDigest: string;
230
+ skipTelemetry?: boolean;
231
+ }, logger?: Logger): Promise<PrepareUpgradeResult>;
232
+ /**
233
+ * Prepare upgrade - does all work up to the transaction
234
+ *
235
+ * This allows CLI to:
236
+ * 1. Call prepareUpgrade to build image, prepare release, get gas estimate
237
+ * 2. Prompt user to confirm the cost
238
+ * 3. Call executeUpgrade with confirmed gas params
239
+ */
240
+ declare function prepareUpgrade(options: Omit<SDKUpgradeOptions, "gas"> & {
241
+ skipTelemetry?: boolean;
242
+ }, logger?: Logger): Promise<PrepareUpgradeResult>;
243
+ /**
244
+ * Execute a prepared upgrade
245
+ *
246
+ * Call this after prepareUpgrade and user confirmation.
247
+ * Note: This only submits the on-chain transaction. Call watchUpgrade separately
248
+ * to wait for the upgrade to complete.
249
+ */
250
+ declare function executeUpgrade(options: ExecuteUpgradeOptions): Promise<UpgradeResult>;
251
+ /**
252
+ * Watch an upgrade until it completes
253
+ *
254
+ * Call this after executeUpgrade to wait for the upgrade to finish.
255
+ * Can be called separately to allow for intermediate operations.
256
+ */
257
+ interface WatchUpgradeOptions {
258
+ timeoutSeconds?: number;
259
+ }
260
+ declare function watchUpgrade(appId: string, walletClient: WalletClient, publicClient: PublicClient, environmentConfig: EnvironmentConfig, logger?: Logger, skipTelemetry?: boolean, opts?: WatchUpgradeOptions): Promise<void>;
261
+
262
+ /**
263
+ * Create command
264
+ *
265
+ * Creates a new app project from a template
266
+ *
267
+ * NOTE: This SDK function is non-interactive. All required parameters must be
268
+ * provided explicitly. Use the CLI for interactive parameter collection.
269
+ */
270
+
271
+ /**
272
+ * Required create app options for SDK (non-interactive)
273
+ */
274
+ interface SDKCreateAppOpts {
275
+ /** Project name - required */
276
+ name: string;
277
+ /** Programming language - required (typescript, golang, rust, python) */
278
+ language: string;
279
+ /** Template name/category (e.g., "minimal") or custom template URL - optional, defaults to first available */
280
+ template?: string;
281
+ /** Template version/ref - optional */
282
+ templateVersion?: string;
283
+ /** Verbose output - optional */
284
+ verbose?: boolean;
285
+ /** Skip telemetry (used when called from CLI) - optional */
286
+ skipTelemetry?: boolean;
287
+ }
288
+ /**
289
+ * Legacy interface for backward compatibility
290
+ * @deprecated Use SDKCreateAppOpts instead
291
+ */
292
+ interface CreateAppOpts {
293
+ name?: string;
294
+ language?: string;
295
+ template?: string;
296
+ templateVersion?: string;
297
+ verbose?: boolean;
298
+ skipTelemetry?: boolean;
299
+ }
300
+ declare const PRIMARY_LANGUAGES: string[];
301
+ /**
302
+ * Get available template categories for a language
303
+ */
304
+ declare function getAvailableTemplates(language: string): Promise<Array<{
305
+ name: string;
306
+ description: string;
307
+ }>>;
308
+ /**
309
+ * Create a new app project from template
310
+ *
311
+ * This function is non-interactive and requires all parameters to be provided explicitly.
312
+ *
313
+ * @param options - Required options including name and language
314
+ * @param logger - Optional logger instance
315
+ * @throws Error if required parameters are missing or invalid
316
+ */
317
+ declare function createApp(options: SDKCreateAppOpts | CreateAppOpts, logger?: Logger): Promise<void>;
318
+
319
+ /**
320
+ * Logs command
321
+ *
322
+ * View app logs with optional watch mode
323
+ *
324
+ * NOTE: This SDK function is non-interactive. All required parameters must be
325
+ * provided explicitly. Use the CLI for interactive parameter collection.
326
+ */
327
+
328
+ /**
329
+ * Required logs options for SDK (non-interactive)
330
+ */
331
+ interface LogsOptions {
332
+ /** App ID (address) or app name - required */
333
+ appID: string | Address;
334
+ /** Watch logs continuously - optional */
335
+ watch?: boolean;
336
+ /** Client ID for API requests - optional */
337
+ clientId?: string;
338
+ }
339
+ /**
340
+ * View app logs
341
+ *
342
+ * This function is non-interactive and requires appID to be provided explicitly.
343
+ *
344
+ * @param options - Required options including appID
345
+ * @param walletClient - Viem WalletClient for signing requests
346
+ * @param publicClient - Viem PublicClient for chain queries
347
+ * @param environmentConfig - Environment configuration
348
+ * @param logger - Optional logger instance
349
+ * @param skipTelemetry - Skip telemetry (for CLI usage)
350
+ * @throws Error if appID is missing or invalid
351
+ */
352
+ declare function logs(options: LogsOptions, walletClient: WalletClient, publicClient: PublicClient, environmentConfig: EnvironmentConfig, logger?: Logger, skipTelemetry?: boolean): Promise<void>;
353
+
354
+ /**
355
+ * Main App namespace entry point
356
+ */
357
+
358
+ /**
359
+ * Encode start app call data for gas estimation
360
+ */
361
+ declare function encodeStartAppData(appId: AppId): Hex;
362
+ /**
363
+ * Encode stop app call data for gas estimation
364
+ */
365
+ declare function encodeStopAppData(appId: AppId): Hex;
366
+ /**
367
+ * Encode terminate app call data for gas estimation
368
+ */
369
+ declare function encodeTerminateAppData(appId: AppId): Hex;
370
+ interface AppModule {
371
+ create: (opts: CreateAppOpts) => Promise<void>;
372
+ deploy: (opts: DeployAppOpts) => Promise<{
373
+ appId: AppId;
374
+ tx: Hex;
375
+ appName: string;
376
+ imageRef: string;
377
+ ipAddress?: string;
378
+ }>;
379
+ upgrade: (appId: AppId, opts: UpgradeAppOpts) => Promise<{
380
+ tx: Hex;
381
+ appId: AppId;
382
+ imageRef: string;
383
+ }>;
384
+ prepareDeploy: (opts: PrepareDeployOpts) => Promise<{
385
+ prepared: PreparedDeploy;
386
+ gasEstimate: GasEstimate;
387
+ }>;
388
+ prepareDeployFromVerifiableBuild: (opts: PrepareDeployFromVerifiableBuildOpts) => Promise<{
389
+ prepared: PreparedDeploy;
390
+ gasEstimate: GasEstimate;
391
+ }>;
392
+ executeDeploy: (prepared: PreparedDeploy, gas?: GasEstimate) => Promise<ExecuteDeployResult>;
393
+ watchDeployment: (appId: AppId, opts?: WatchDeploymentOptions) => Promise<string | undefined>;
394
+ prepareUpgrade: (appId: AppId, opts: PrepareUpgradeOpts) => Promise<{
395
+ prepared: PreparedUpgrade;
396
+ gasEstimate: GasEstimate;
397
+ }>;
398
+ prepareUpgradeFromVerifiableBuild: (appId: AppId, opts: PrepareUpgradeFromVerifiableBuildOpts) => Promise<{
399
+ prepared: PreparedUpgrade;
400
+ gasEstimate: GasEstimate;
401
+ }>;
402
+ executeUpgrade: (prepared: PreparedUpgrade, gas?: GasEstimate) => Promise<ExecuteUpgradeResult>;
403
+ watchUpgrade: (appId: AppId, opts?: WatchUpgradeOptions) => Promise<void>;
404
+ setProfile: (appId: AppId, profile: AppProfile) => Promise<AppProfileResponse>;
405
+ logs: (opts: LogsOptions) => Promise<void>;
406
+ start: (appId: AppId, opts?: LifecycleOpts) => Promise<{
407
+ tx: Hex | false;
408
+ }>;
409
+ stop: (appId: AppId, opts?: LifecycleOpts) => Promise<{
410
+ tx: Hex | false;
411
+ }>;
412
+ terminate: (appId: AppId, opts?: LifecycleOpts) => Promise<{
413
+ tx: Hex | false;
414
+ }>;
415
+ getBillingType: (appId: AppId) => Promise<number>;
416
+ getAppsByBillingAccount: (account: Address, offset: bigint, limit: bigint) => Promise<{
417
+ apps: Address[];
418
+ appConfigs: AppConfig[];
419
+ }>;
420
+ isDelegated: () => Promise<boolean>;
421
+ undelegate: () => Promise<{
422
+ tx: Hex | false;
423
+ }>;
424
+ }
425
+ interface AppModuleConfig {
426
+ verbose?: boolean;
427
+ walletClient: WalletClient;
428
+ publicClient: PublicClient;
429
+ environment: string;
430
+ clientId?: string;
431
+ skipTelemetry?: boolean;
432
+ /**
433
+ * Optional logger override. Defaults to a stdout/stderr logger that respects
434
+ * `verbose`. Callers producing machine-readable output pass a logger that
435
+ * keeps progress off stdout.
436
+ */
437
+ logger?: Logger;
438
+ }
439
+ declare function createAppModule(ctx: AppModuleConfig): AppModule;
440
+
441
+ /**
442
+ * Main Compute namespace entry point
443
+ */
444
+
445
+ interface ComputeModule {
446
+ app: AppModule;
447
+ }
448
+ interface ComputeModuleConfig {
449
+ verbose?: boolean;
450
+ walletClient: WalletClient;
451
+ publicClient: PublicClient;
452
+ environment: string;
453
+ clientId?: string;
454
+ skipTelemetry?: boolean;
455
+ /**
456
+ * Optional logger override. When provided, the module routes all progress
457
+ * output through it instead of the default stdout/stderr logger. Callers
458
+ * emitting machine-readable output (e.g. `--json`) pass a logger that writes
459
+ * to stderr so stdout stays pure.
460
+ */
461
+ logger?: Logger;
462
+ }
463
+ declare function createComputeModule(config: ComputeModuleConfig): ComputeModule;
464
+
465
+ export { type AppModule as A, type ComputeModule as C, type LogsOptions as L, PRIMARY_LANGUAGES as P, type SDKCreateAppOpts as S, type WatchDeploymentOptions as W, type ComputeModuleConfig as a, type CreateAppOpts as b, type PrepareDeployResult as c, type PrepareUpgradeResult as d, type SDKDeployOptions as e, type SDKUpgradeOptions as f, type WatchUpgradeOptions as g, createApp as h, createComputeModule as i, encodeStartAppData as j, encodeStopAppData as k, encodeTerminateAppData as l, executeDeploy as m, executeUpgrade as n, getAvailableTemplates as o, logs as p, prepareDeploy as q, prepareDeployFromVerifiableBuild as r, prepareUpgrade as s, prepareUpgradeFromVerifiableBuild as t, watchUpgrade as u, type AppModuleConfig as v, watchDeployment as w, createAppModule as x };