@layr-labs/ecloud-sdk 0.2.1-dev → 0.3.0-dev

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.
@@ -1,4 +1,4 @@
1
- import { PublicClient, Address, Hex } from 'viem';
1
+ import { PublicClient, Address, Hex, WalletClient } from 'viem';
2
2
 
3
3
  /**
4
4
  * Contract interactions
@@ -55,6 +55,245 @@ declare function formatETH(wei: bigint): string;
55
55
  * Use this to get cost estimate before prompting user for confirmation.
56
56
  */
57
57
  declare function estimateTransactionGas(options: EstimateGasOptions): Promise<GasEstimate>;
58
+ /**
59
+ * Deploy app options
60
+ */
61
+ interface DeployAppOptions {
62
+ walletClient: WalletClient;
63
+ publicClient: PublicClient;
64
+ environmentConfig: EnvironmentConfig;
65
+ salt: Uint8Array;
66
+ release: Release;
67
+ publicLogs: boolean;
68
+ imageRef: string;
69
+ gas?: GasEstimate;
70
+ }
71
+ /**
72
+ * Options for calculateAppID
73
+ */
74
+ interface CalculateAppIDOptions {
75
+ publicClient: PublicClient;
76
+ environmentConfig: EnvironmentConfig;
77
+ ownerAddress: Address;
78
+ salt: Uint8Array;
79
+ }
80
+ /**
81
+ * Prepared deploy batch ready for gas estimation and execution
82
+ */
83
+ interface PreparedDeployBatch {
84
+ /** The app ID that will be deployed */
85
+ appId: Address;
86
+ /** The salt used for deployment */
87
+ salt: Uint8Array;
88
+ /** Batch executions to be sent */
89
+ executions: Array<{
90
+ target: Address;
91
+ value: bigint;
92
+ callData: Hex;
93
+ }>;
94
+ /** Wallet client for sending transaction */
95
+ walletClient: WalletClient;
96
+ /** Public client for reading chain state */
97
+ publicClient: PublicClient;
98
+ /** Environment configuration */
99
+ environmentConfig: EnvironmentConfig;
100
+ }
101
+ /**
102
+ * Prepared upgrade batch ready for gas estimation and execution
103
+ */
104
+ interface PreparedUpgradeBatch {
105
+ /** The app ID being upgraded */
106
+ appId: Address;
107
+ /** Batch executions to be sent */
108
+ executions: Array<{
109
+ target: Address;
110
+ value: bigint;
111
+ callData: Hex;
112
+ }>;
113
+ /** Wallet client for sending transaction */
114
+ walletClient: WalletClient;
115
+ /** Public client for reading chain state */
116
+ publicClient: PublicClient;
117
+ /** Environment configuration */
118
+ environmentConfig: EnvironmentConfig;
119
+ }
120
+ /**
121
+ * Calculate app ID from owner address and salt
122
+ */
123
+ declare function calculateAppID(options: CalculateAppIDOptions): Promise<Address>;
124
+ /**
125
+ * Options for preparing a deploy batch
126
+ */
127
+ interface PrepareDeployBatchOptions {
128
+ walletClient: WalletClient;
129
+ publicClient: PublicClient;
130
+ environmentConfig: EnvironmentConfig;
131
+ salt: Uint8Array;
132
+ release: Release;
133
+ publicLogs: boolean;
134
+ imageRef: string;
135
+ }
136
+ /**
137
+ * Prepare deploy batch - creates executions without sending transaction
138
+ *
139
+ * Use this to get the prepared batch for gas estimation before executing.
140
+ */
141
+ declare function prepareDeployBatch(options: PrepareDeployBatchOptions, logger?: Logger): Promise<PreparedDeployBatch>;
142
+ /**
143
+ * Execute a prepared deploy batch
144
+ */
145
+ declare function executeDeployBatch(data: PreparedDeployData, context: {
146
+ walletClient: WalletClient;
147
+ publicClient: PublicClient;
148
+ environmentConfig: EnvironmentConfig;
149
+ }, gas?: GasEstimate, logger?: Logger): Promise<{
150
+ appId: Address;
151
+ txHash: Hex;
152
+ }>;
153
+ /**
154
+ * Deploy app on-chain (convenience wrapper that prepares and executes)
155
+ */
156
+ declare function deployApp(options: DeployAppOptions, logger?: Logger): Promise<{
157
+ appId: Address;
158
+ txHash: Hex;
159
+ }>;
160
+ /**
161
+ * Check if wallet account supports EIP-7702 signing
162
+ *
163
+ * Local accounts (from privateKeyToAccount) support signAuthorization.
164
+ * JSON-RPC accounts (browser wallets like MetaMask) do not.
165
+ */
166
+ declare function supportsEIP7702(walletClient: WalletClient): boolean;
167
+ /**
168
+ * Options for sequential deployment (non-EIP-7702)
169
+ */
170
+ interface ExecuteDeploySequentialOptions {
171
+ walletClient: WalletClient;
172
+ publicClient: PublicClient;
173
+ environmentConfig: EnvironmentConfig;
174
+ /** Prepared deployment data from prepareDeployBatch */
175
+ data: PreparedDeployData;
176
+ /** Whether to set public logs permission */
177
+ publicLogs: boolean;
178
+ /** Optional callback for progress updates */
179
+ onProgress?: DeployProgressCallback;
180
+ }
181
+ /**
182
+ * Execute deployment as sequential transactions (non-EIP-7702 fallback)
183
+ *
184
+ * Use this for browser wallets (JSON-RPC accounts) that don't support signAuthorization.
185
+ * This requires 2-3 wallet signatures instead of 1, but works with all wallet types.
186
+ *
187
+ * Steps:
188
+ * 1. createApp - Creates the app on-chain
189
+ * 2. acceptAdmin - Accepts admin role for the app
190
+ * 3. setAppointee (optional) - Sets public logs permission
191
+ */
192
+ declare function executeDeploySequential(options: ExecuteDeploySequentialOptions, logger?: Logger): Promise<SequentialDeployResult>;
193
+ /**
194
+ * Result from EIP-5792 batched deployment
195
+ */
196
+ interface BatchedDeployResult {
197
+ appId: Address;
198
+ /** Batch ID from sendCalls (can be used with getCallsStatus) */
199
+ batchId: string;
200
+ /** Transaction receipts from the batch */
201
+ receipts: Array<{
202
+ transactionHash: Hex;
203
+ }>;
204
+ }
205
+ /**
206
+ * Options for EIP-5792 batched deployment
207
+ */
208
+ interface ExecuteDeployBatchedOptions {
209
+ walletClient: WalletClient;
210
+ publicClient: PublicClient;
211
+ environmentConfig: EnvironmentConfig;
212
+ /** Prepared deployment data from prepareDeployBatch */
213
+ data: PreparedDeployData;
214
+ /** Whether to set public logs permission */
215
+ publicLogs: boolean;
216
+ /** Optional callback for progress updates */
217
+ onProgress?: DeployProgressCallback;
218
+ }
219
+ /**
220
+ * Check if wallet supports EIP-5792 (sendCalls/wallet_sendCalls)
221
+ *
222
+ * This checks the wallet's capabilities to see if it supports atomic batch calls.
223
+ * MetaMask and other modern wallets are adding support for this standard.
224
+ */
225
+ declare function supportsEIP5792(walletClient: WalletClient): Promise<boolean>;
226
+ /**
227
+ * Execute deployment using EIP-5792 sendCalls (batched wallet calls)
228
+ *
229
+ * This batches all deployment transactions (createApp, acceptAdmin, setPublicLogs)
230
+ * into a single wallet interaction. Better UX than sequential transactions.
231
+ *
232
+ * Use this for browser wallets that support EIP-5792 but not EIP-7702.
233
+ *
234
+ * @returns BatchedDeployResult with appId and batch receipts
235
+ */
236
+ declare function executeDeployBatched(options: ExecuteDeployBatchedOptions, logger?: Logger): Promise<BatchedDeployResult>;
237
+ /**
238
+ * Upgrade app options
239
+ */
240
+ interface UpgradeAppOptions {
241
+ walletClient: WalletClient;
242
+ publicClient: PublicClient;
243
+ environmentConfig: EnvironmentConfig;
244
+ appID: Address;
245
+ release: Release;
246
+ publicLogs: boolean;
247
+ needsPermissionChange: boolean;
248
+ imageRef: string;
249
+ gas?: GasEstimate;
250
+ }
251
+ /**
252
+ * Options for preparing an upgrade batch
253
+ */
254
+ interface PrepareUpgradeBatchOptions {
255
+ walletClient: WalletClient;
256
+ publicClient: PublicClient;
257
+ environmentConfig: EnvironmentConfig;
258
+ appID: Address;
259
+ release: Release;
260
+ publicLogs: boolean;
261
+ needsPermissionChange: boolean;
262
+ imageRef: string;
263
+ }
264
+ /**
265
+ * Prepare upgrade batch - creates executions without sending transaction
266
+ *
267
+ * Use this to get the prepared batch for gas estimation before executing.
268
+ */
269
+ declare function prepareUpgradeBatch(options: PrepareUpgradeBatchOptions): Promise<PreparedUpgradeBatch>;
270
+ /**
271
+ * Execute a prepared upgrade batch
272
+ */
273
+ declare function executeUpgradeBatch(data: PreparedUpgradeData, context: {
274
+ walletClient: WalletClient;
275
+ publicClient: PublicClient;
276
+ environmentConfig: EnvironmentConfig;
277
+ }, gas?: GasEstimate, logger?: Logger): Promise<Hex>;
278
+ /**
279
+ * Upgrade app on-chain (convenience wrapper that prepares and executes)
280
+ */
281
+ declare function upgradeApp(options: UpgradeAppOptions, logger?: Logger): Promise<Hex>;
282
+ /**
283
+ * Send and wait for transaction with confirmation support
284
+ */
285
+ interface SendTransactionOptions {
286
+ walletClient: WalletClient;
287
+ publicClient: PublicClient;
288
+ environmentConfig: EnvironmentConfig;
289
+ to: Address;
290
+ data: Hex;
291
+ value?: bigint;
292
+ pendingMessage: string;
293
+ txDescription: string;
294
+ gas?: GasEstimate;
295
+ }
296
+ declare function sendAndWaitForTransaction(options: SendTransactionOptions, logger?: Logger): Promise<Hex>;
58
297
  /**
59
298
  * Get active app count for a user
60
299
  */
@@ -96,6 +335,44 @@ declare function getAppLatestReleaseBlockNumbers(publicClient: PublicClient, env
96
335
  * Get block timestamps for multiple block numbers
97
336
  */
98
337
  declare function getBlockTimestamps(publicClient: PublicClient, blockNumbers: number[]): Promise<Map<number, number>>;
338
+ /**
339
+ * Suspend options
340
+ */
341
+ interface SuspendOptions {
342
+ walletClient: WalletClient;
343
+ publicClient: PublicClient;
344
+ environmentConfig: EnvironmentConfig;
345
+ account: Address;
346
+ apps: Address[];
347
+ }
348
+ /**
349
+ * Suspend apps for an account
350
+ */
351
+ declare function suspend(options: SuspendOptions, logger?: Logger): Promise<Hex | false>;
352
+ /**
353
+ * Options for checking delegation status
354
+ */
355
+ interface IsDelegatedOptions {
356
+ publicClient: PublicClient;
357
+ environmentConfig: EnvironmentConfig;
358
+ address: Address;
359
+ }
360
+ /**
361
+ * Check if account is delegated to the ERC-7702 delegator
362
+ */
363
+ declare function isDelegated(options: IsDelegatedOptions): Promise<boolean>;
364
+ /**
365
+ * Undelegate options
366
+ */
367
+ interface UndelegateOptions {
368
+ walletClient: WalletClient;
369
+ publicClient: PublicClient;
370
+ environmentConfig: EnvironmentConfig;
371
+ }
372
+ /**
373
+ * Undelegate account (removes EIP-7702 delegation)
374
+ */
375
+ declare function undelegate(options: UndelegateOptions, logger?: Logger): Promise<Hex>;
99
376
 
100
377
  /**
101
378
  * Core types for ECloud SDK
@@ -342,6 +619,10 @@ interface Logger {
342
619
  warn(message: string, ...args: any[]): void;
343
620
  error(message: string, ...args: any[]): void;
344
621
  }
622
+ /**
623
+ * No-op logger for browser usage when logging is not needed
624
+ */
625
+ declare const noopLogger: Logger;
345
626
  /**
346
627
  * Profile information for an app
347
628
  */
@@ -379,6 +660,12 @@ interface SubscriptionLineItem {
379
660
  currency: string;
380
661
  subtotal: number;
381
662
  }
663
+ interface CreateSubscriptionOptions {
664
+ /** URL to redirect to after successful checkout */
665
+ successUrl?: string;
666
+ /** URL to redirect to if checkout is canceled */
667
+ cancelUrl?: string;
668
+ }
382
669
  interface CreateSubscriptionResponse {
383
670
  checkoutUrl: string;
384
671
  }
@@ -421,6 +708,10 @@ interface ProductSubscriptionResponse {
421
708
  }
422
709
  interface SubscriptionOpts {
423
710
  productId?: ProductID;
711
+ /** URL to redirect to after successful checkout */
712
+ successUrl?: string;
713
+ /** URL to redirect to if checkout is canceled */
714
+ cancelUrl?: string;
424
715
  }
425
716
  interface BillingEnvironmentConfig {
426
717
  billingApiServerURL: string;
@@ -428,5 +719,25 @@ interface BillingEnvironmentConfig {
428
719
  interface BillingEnvironmentConfig {
429
720
  billingApiServerURL: string;
430
721
  }
722
+ /**
723
+ * Progress callback for sequential deployment
724
+ * Called after each step completes
725
+ */
726
+ type DeployProgressCallback = (step: DeployStep, txHash?: Hex) => void;
727
+ /**
728
+ * Steps in sequential deployment flow
729
+ */
730
+ type DeployStep = "createApp" | "acceptAdmin" | "setPublicLogs" | "complete";
731
+ /**
732
+ * Result from sequential deployment
733
+ */
734
+ interface SequentialDeployResult {
735
+ appId: AppId;
736
+ txHashes: {
737
+ createApp: Hex;
738
+ acceptAdmin: Hex;
739
+ setPublicLogs?: Hex;
740
+ };
741
+ }
431
742
 
432
- export { getBlockTimestamps as $, type AppId as A, type BillingEnvironmentConfig as B, type AppProfile as C, type DeployAppOpts as D, type EstimateGasOptions as E, type AppProfileResponse as F, type GasEstimate as G, type ProductID as H, type ImageDigestResult as I, type ChainID as J, type SubscriptionLineItem as K, type LifecycleOpts as L, type CreateSubscriptionResponse as M, type CheckoutCreatedResponse as N, type AlreadyActiveResponse as O, type PrepareDeployOpts as P, type PaymentIssueResponse as Q, type Release as R, type SubscriptionStatus as S, type SubscribeResponse as T, type UpgradeAppOpts as U, type CancelSuccessResponse as V, type NoActiveSubscriptionResponse as W, type CancelResponse as X, type ProductSubscriptionResponse as Y, type SubscriptionOpts as Z, getAppLatestReleaseBlockNumbers as _, getAppsByCreator as a, getAppsByDeveloper as b, getActiveAppCount as c, getMaxActiveAppsPerUser as d, estimateTransactionGas as e, formatETH as f, getAllAppsByDeveloper as g, type AppConfig as h, type PrepareUpgradeOpts as i, type PrepareDeployFromVerifiableBuildOpts as j, type PrepareUpgradeFromVerifiableBuildOpts as k, type logVisibility as l, type GasOpts as m, type ExecuteDeployResult as n, type ExecuteUpgradeResult as o, type PreparedDeployData as p, type PreparedUpgradeData as q, type PreparedDeploy as r, type PreparedUpgrade as s, type AppRecord as t, type DeployOptions as u, type DeployResult as v, type EnvironmentConfig as w, type ParsedEnvironment as x, type DockerImageConfig as y, type Logger as z };
743
+ export { type PreparedDeploy as $, type AppId as A, type SuspendOptions as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EstimateGasOptions as E, type UndelegateOptions as F, type GasEstimate as G, type ExecuteDeploySequentialOptions as H, type IsDelegatedOptions as I, type ExecuteDeployBatchedOptions as J, type BatchedDeployResult as K, noopLogger as L, type logVisibility as M, type DeployAppOpts as N, type UpgradeAppOpts as O, type PrepareDeployBatchOptions as P, type PrepareDeployOpts as Q, type PrepareUpgradeOpts as R, type SendTransactionOptions as S, type PrepareDeployFromVerifiableBuildOpts as T, type UpgradeAppOptions as U, type PrepareUpgradeFromVerifiableBuildOpts as V, type GasOpts as W, type ExecuteDeployResult as X, type ExecuteUpgradeResult as Y, type PreparedDeployData as Z, type PreparedUpgradeData as _, getAppsByCreator as a, type PreparedUpgrade as a0, type LifecycleOpts as a1, type AppRecord as a2, type DeployOptions as a3, type DeployResult as a4, type BillingEnvironmentConfig as a5, type EnvironmentConfig as a6, type Release as a7, type ParsedEnvironment as a8, type ImageDigestResult as a9, type DockerImageConfig as aa, type Logger as ab, type AppProfile as ac, type AppProfileResponse as ad, type ProductID as ae, type ChainID as af, type SubscriptionStatus as ag, type SubscriptionLineItem as ah, type CreateSubscriptionOptions as ai, type CreateSubscriptionResponse as aj, type CheckoutCreatedResponse as ak, type AlreadyActiveResponse as al, type PaymentIssueResponse as am, type SubscribeResponse as an, type CancelSuccessResponse as ao, type NoActiveSubscriptionResponse as ap, type CancelResponse as aq, type ProductSubscriptionResponse as ar, type SubscriptionOpts as as, type DeployProgressCallback as at, type DeployStep as au, type SequentialDeployResult as av, getAppLatestReleaseBlockNumbers as aw, getBlockTimestamps as ax, getAppsByDeveloper as b, getActiveAppCount as c, getMaxActiveAppsPerUser as d, estimateTransactionGas as e, formatETH as f, getAllAppsByDeveloper as g, executeDeployBatch as h, deployApp as i, calculateAppID as j, executeDeploySequential as k, executeDeployBatched as l, supportsEIP5792 as m, prepareUpgradeBatch as n, executeUpgradeBatch as o, prepareDeployBatch as p, sendAndWaitForTransaction as q, isDelegated as r, supportsEIP7702 as s, suspend as t, upgradeApp as u, undelegate as v, type AppConfig as w, type PrepareUpgradeBatchOptions as x, type PreparedDeployBatch as y, type PreparedUpgradeBatch as z };