@layr-labs/ecloud-sdk 0.2.0 → 0.2.1-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,101 @@
1
- import { Address, Hex } from 'viem';
1
+ import { PublicClient, Address, Hex } from 'viem';
2
+
3
+ /**
4
+ * Contract interactions
5
+ *
6
+ * This module handles on-chain contract interactions using viem.
7
+ *
8
+ * Accepts viem's WalletClient and PublicClient directly, which abstract over both
9
+ * local accounts (privateKeyToAccount) and external signers (MetaMask, etc.).
10
+ *
11
+ * @example
12
+ * // CLI usage with private key
13
+ * const { walletClient, publicClient } = createClients({ privateKey, rpcUrl, chainId });
14
+ * await deployApp({ walletClient, publicClient, environmentConfig, ... }, logger);
15
+ *
16
+ * @example
17
+ * // Browser usage with external wallet
18
+ * const walletClient = createWalletClient({ chain, transport: custom(window.ethereum!) });
19
+ * const publicClient = createPublicClient({ chain, transport: custom(window.ethereum!) });
20
+ * await deployApp({ walletClient, publicClient, environmentConfig, ... }, logger);
21
+ */
22
+
23
+ /**
24
+ * Gas estimation result
25
+ */
26
+ interface GasEstimate {
27
+ /** Estimated gas limit for the transaction */
28
+ gasLimit: bigint;
29
+ /** Max fee per gas (EIP-1559) */
30
+ maxFeePerGas: bigint;
31
+ /** Max priority fee per gas (EIP-1559) */
32
+ maxPriorityFeePerGas: bigint;
33
+ /** Maximum cost in wei (gasLimit * maxFeePerGas) */
34
+ maxCostWei: bigint;
35
+ /** Maximum cost formatted as ETH string */
36
+ maxCostEth: string;
37
+ }
38
+ /**
39
+ * Options for estimating transaction gas
40
+ */
41
+ interface EstimateGasOptions {
42
+ publicClient: PublicClient;
43
+ from: Address;
44
+ to: Address;
45
+ data: Hex;
46
+ value?: bigint;
47
+ }
48
+ /**
49
+ * Format Wei to ETH string
50
+ */
51
+ declare function formatETH(wei: bigint): string;
52
+ /**
53
+ * Estimate gas cost for a transaction
54
+ *
55
+ * Use this to get cost estimate before prompting user for confirmation.
56
+ */
57
+ declare function estimateTransactionGas(options: EstimateGasOptions): Promise<GasEstimate>;
58
+ /**
59
+ * Get active app count for a user
60
+ */
61
+ declare function getActiveAppCount(publicClient: PublicClient, environmentConfig: EnvironmentConfig, user: Address): Promise<number>;
62
+ /**
63
+ * Get max active apps per user (quota limit)
64
+ */
65
+ declare function getMaxActiveAppsPerUser(publicClient: PublicClient, environmentConfig: EnvironmentConfig, user: Address): Promise<number>;
66
+ /**
67
+ * Get apps by creator (paginated)
68
+ */
69
+ interface AppConfig {
70
+ release: any;
71
+ status: number;
72
+ }
73
+ declare function getAppsByCreator(publicClient: PublicClient, environmentConfig: EnvironmentConfig, creator: Address, offset: bigint, limit: bigint): Promise<{
74
+ apps: Address[];
75
+ appConfigs: AppConfig[];
76
+ }>;
77
+ /**
78
+ * Get apps by developer
79
+ */
80
+ declare function getAppsByDeveloper(publicClient: PublicClient, environmentConfig: EnvironmentConfig, developer: Address, offset: bigint, limit: bigint): Promise<{
81
+ apps: Address[];
82
+ appConfigs: AppConfig[];
83
+ }>;
84
+ /**
85
+ * Fetch all apps by a developer by auto-pagination
86
+ */
87
+ declare function getAllAppsByDeveloper(publicClient: PublicClient, env: EnvironmentConfig, developer: Address, pageSize?: bigint): Promise<{
88
+ apps: Address[];
89
+ appConfigs: AppConfig[];
90
+ }>;
91
+ /**
92
+ * Get latest release block numbers for multiple apps
93
+ */
94
+ declare function getAppLatestReleaseBlockNumbers(publicClient: PublicClient, environmentConfig: EnvironmentConfig, appIDs: Address[]): Promise<Map<Address, number>>;
95
+ /**
96
+ * Get block timestamps for multiple block numbers
97
+ */
98
+ declare function getBlockTimestamps(publicClient: PublicClient, blockNumbers: number[]): Promise<Map<number, number>>;
2
99
 
3
100
  /**
4
101
  * Core types for ECloud SDK
@@ -20,10 +117,7 @@ interface DeployAppOpts {
20
117
  /** Log visibility setting - required */
21
118
  logVisibility: logVisibility;
22
119
  /** Optional gas params from estimation */
23
- gas?: {
24
- maxFeePerGas?: bigint;
25
- maxPriorityFeePerGas?: bigint;
26
- };
120
+ gas?: GasEstimate;
27
121
  }
28
122
  interface UpgradeAppOpts {
29
123
  /** Path to Dockerfile (if building from Dockerfile) - either this or imageRef is required */
@@ -36,10 +130,7 @@ interface UpgradeAppOpts {
36
130
  instanceType: string;
37
131
  /** Log visibility setting - required */
38
132
  logVisibility: logVisibility;
39
- gas?: {
40
- maxFeePerGas?: bigint;
41
- maxPriorityFeePerGas?: bigint;
42
- };
133
+ gas?: GasEstimate;
43
134
  }
44
135
  /** Options for prepareDeploy */
45
136
  interface PrepareDeployOpts {
@@ -166,10 +257,7 @@ interface PreparedUpgrade {
166
257
  imageRef: string;
167
258
  }
168
259
  interface LifecycleOpts {
169
- gas?: {
170
- maxFeePerGas?: bigint;
171
- maxPriorityFeePerGas?: bigint;
172
- };
260
+ gas?: GasEstimate;
173
261
  }
174
262
  interface AppRecord {
175
263
  id: AppId;
@@ -267,7 +355,9 @@ interface AppProfile {
267
355
  /** X (Twitter) URL (optional) */
268
356
  xURL?: string;
269
357
  /** Path to image file (optional) */
270
- imagePath?: string;
358
+ image?: Blob | File;
359
+ /** Image name (optional) */
360
+ imageName?: string;
271
361
  }
272
362
  /**
273
363
  * Profile response from API
@@ -339,4 +429,4 @@ interface BillingEnvironmentConfig {
339
429
  billingApiServerURL: string;
340
430
  }
341
431
 
342
- export type { AppId as A, BillingEnvironmentConfig as B, ChainID as C, DeployResult as D, EnvironmentConfig as E, CancelResponse as F, GasOpts as G, ProductSubscriptionResponse as H, ImageDigestResult as I, SubscriptionOpts as J, Logger as L, NoActiveSubscriptionResponse as N, PreparedDeploy as P, Release as R, SubscriptionStatus as S, UpgradeAppOpts as U, PreparedUpgrade as a, DeployAppOpts as b, PrepareDeployOpts as c, PrepareUpgradeOpts as d, PrepareDeployFromVerifiableBuildOpts as e, PrepareUpgradeFromVerifiableBuildOpts as f, ExecuteDeployResult as g, ExecuteUpgradeResult as h, PreparedDeployData as i, PreparedUpgradeData as j, LifecycleOpts as k, logVisibility as l, AppRecord as m, DeployOptions as n, ParsedEnvironment as o, DockerImageConfig as p, AppProfile as q, AppProfileResponse as r, ProductID as s, SubscriptionLineItem as t, CreateSubscriptionResponse as u, CheckoutCreatedResponse as v, AlreadyActiveResponse as w, PaymentIssueResponse as x, SubscribeResponse as y, CancelSuccessResponse as z };
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 };