@layr-labs/ecloud-sdk 0.1.1 → 0.1.2-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.
package/dist/compute.cjs CHANGED
@@ -40,6 +40,7 @@ module.exports = __toCommonJS(compute_exports);
40
40
 
41
41
  // src/client/modules/compute/app/index.ts
42
42
  var import_viem9 = require("viem");
43
+ var import_accounts5 = require("viem/accounts");
43
44
 
44
45
  // src/client/common/config/environment.ts
45
46
  var SEPOLIA_CHAIN_ID = 11155111;
@@ -114,7 +115,7 @@ function getEnvironmentConfig(environment, chainID) {
114
115
  };
115
116
  }
116
117
  function getBuildType() {
117
- const buildTimeType = true ? "prod"?.toLowerCase() : void 0;
118
+ const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
118
119
  const runtimeType = process.env.BUILD_TYPE?.toLowerCase();
119
120
  const buildType = buildTimeType || runtimeType;
120
121
  if (buildType === "dev") {
@@ -162,6 +163,7 @@ async function buildDockerImage(buildContext, dockerfilePath, tag, logger) {
162
163
  tag,
163
164
  "-f",
164
165
  dockerfilePath,
166
+ "--load",
165
167
  "--progress=plain",
166
168
  buildContext
167
169
  ];
@@ -287,7 +289,7 @@ async function pullDockerImage(docker, imageTag, platform2 = "linux/amd64", logg
287
289
  var child_process2 = __toESM(require("child_process"), 1);
288
290
  var import_child_process = require("child_process");
289
291
  var import_util2 = require("util");
290
- var execAsync = (0, import_util2.promisify)(import_child_process.exec);
292
+ var execFileAsync = (0, import_util2.promisify)(import_child_process.execFile);
291
293
  async function pushDockerImage(docker, imageRef, logger) {
292
294
  logger?.info?.(`Pushing image ${imageRef}...`);
293
295
  return new Promise((resolve2, reject) => {
@@ -354,7 +356,7 @@ async function verifyImageExists(imageRef, logger) {
354
356
  let retries = 5;
355
357
  while (retries > 0) {
356
358
  try {
357
- await execAsync(`docker manifest inspect ${imageRef}`, {
359
+ await execFileAsync("docker", ["manifest", "inspect", imageRef], {
358
360
  maxBuffer: 10 * 1024 * 1024,
359
361
  timeout: 1e4
360
362
  // 10 second timeout
@@ -828,10 +830,10 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
828
830
  // src/client/common/registry/digest.ts
829
831
  var child_process3 = __toESM(require("child_process"), 1);
830
832
  var import_util3 = require("util");
831
- var execFileAsync = (0, import_util3.promisify)(child_process3.execFile);
833
+ var execFileAsync2 = (0, import_util3.promisify)(child_process3.execFile);
832
834
  async function getImageDigestAndName(imageRef) {
833
835
  try {
834
- const { stdout } = await execFileAsync(
836
+ const { stdout } = await execFileAsync2(
835
837
  "docker",
836
838
  ["manifest", "inspect", imageRef],
837
839
  { maxBuffer: 10 * 1024 * 1024 }
@@ -871,7 +873,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
871
873
  }
872
874
  async function extractDigestFromSinglePlatform(manifest, imageRef) {
873
875
  try {
874
- const { stdout } = await execFileAsync("docker", ["inspect", imageRef], {
876
+ const { stdout } = await execFileAsync2("docker", ["inspect", imageRef], {
875
877
  maxBuffer: 10 * 1024 * 1024
876
878
  });
877
879
  const inspectData = JSON.parse(stdout);
@@ -2205,6 +2207,25 @@ var ERC7702Delegator_default = [
2205
2207
  ];
2206
2208
 
2207
2209
  // src/client/common/contract/eip7702.ts
2210
+ async function estimateBatchGas(options) {
2211
+ const { publicClient, executions } = options;
2212
+ const fees = await publicClient.estimateFeesPerGas();
2213
+ const baseGas = 100000n;
2214
+ const perExecutionGas = 50000n;
2215
+ const estimatedGas = baseGas + BigInt(executions.length) * perExecutionGas;
2216
+ const gasLimit = estimatedGas * 120n / 100n;
2217
+ const maxFeePerGas = fees.maxFeePerGas;
2218
+ const maxPriorityFeePerGas = fees.maxPriorityFeePerGas;
2219
+ const maxCostWei = gasLimit * maxFeePerGas;
2220
+ const maxCostEth = formatETH(maxCostWei);
2221
+ return {
2222
+ gasLimit,
2223
+ maxFeePerGas,
2224
+ maxPriorityFeePerGas,
2225
+ maxCostWei,
2226
+ maxCostEth
2227
+ };
2228
+ }
2208
2229
  async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
2209
2230
  const code = await publicClient.getBytecode({ address: account });
2210
2231
  if (!code) {
@@ -2390,7 +2411,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
2390
2411
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
2391
2412
  var CanUpdateAppProfilePermission = "0x036fef61";
2392
2413
  function getDefaultClientId() {
2393
- const version = true ? "0.1.1" : "0.0.0";
2414
+ const version = true ? "0.1.2-dev" : "0.0.0";
2394
2415
  return `ecloud-sdk/v${version}`;
2395
2416
  }
2396
2417
  var UserApiClient = class {
@@ -4142,6 +4163,15 @@ var PermissionController_default = [
4142
4163
  ];
4143
4164
 
4144
4165
  // src/client/common/contract/caller.ts
4166
+ function formatETH(wei) {
4167
+ const eth = Number(wei) / 1e18;
4168
+ const costStr = eth.toFixed(6);
4169
+ const trimmed = costStr.replace(/\.?0+$/, "");
4170
+ if (trimmed === "0" && wei > 0n) {
4171
+ return "<0.000001";
4172
+ }
4173
+ return trimmed;
4174
+ }
4145
4175
  async function calculateAppID(privateKey, rpcUrl, environmentConfig, salt) {
4146
4176
  const privateKeyHex = addHexPrefix(privateKey);
4147
4177
  const account = (0, import_accounts2.privateKeyToAccount)(privateKeyHex);
@@ -4246,20 +4276,20 @@ async function prepareDeployBatch(options, logger) {
4246
4276
  environmentConfig
4247
4277
  };
4248
4278
  }
4249
- async function executeDeployBatch(prepared, gas, logger) {
4279
+ async function executeDeployBatch(data, context, gas, logger) {
4250
4280
  const pendingMessage = "Deploying new app...";
4251
4281
  const txHash = await executeBatch(
4252
4282
  {
4253
- walletClient: prepared.walletClient,
4254
- publicClient: prepared.publicClient,
4255
- environmentConfig: prepared.environmentConfig,
4256
- executions: prepared.executions,
4283
+ walletClient: context.walletClient,
4284
+ publicClient: context.publicClient,
4285
+ environmentConfig: context.environmentConfig,
4286
+ executions: data.executions,
4257
4287
  pendingMessage,
4258
4288
  gas
4259
4289
  },
4260
4290
  logger
4261
4291
  );
4262
- return { appId: prepared.appId, txHash };
4292
+ return { appId: data.appId, txHash };
4263
4293
  }
4264
4294
  async function deployApp(options, logger) {
4265
4295
  const prepared = await prepareDeployBatch(
@@ -4273,7 +4303,17 @@ async function deployApp(options, logger) {
4273
4303
  },
4274
4304
  logger
4275
4305
  );
4276
- return executeDeployBatch(prepared, options.gas, logger);
4306
+ const data = {
4307
+ appId: prepared.appId,
4308
+ salt: prepared.salt,
4309
+ executions: prepared.executions
4310
+ };
4311
+ const context = {
4312
+ walletClient: prepared.walletClient,
4313
+ publicClient: prepared.publicClient,
4314
+ environmentConfig: prepared.environmentConfig
4315
+ };
4316
+ return executeDeployBatch(data, context, options.gas, logger);
4277
4317
  }
4278
4318
  async function prepareUpgradeBatch(options) {
4279
4319
  const {
@@ -4369,14 +4409,14 @@ async function prepareUpgradeBatch(options) {
4369
4409
  environmentConfig
4370
4410
  };
4371
4411
  }
4372
- async function executeUpgradeBatch(prepared, gas, logger) {
4373
- const pendingMessage = `Upgrading app ${prepared.appId}...`;
4412
+ async function executeUpgradeBatch(data, context, gas, logger) {
4413
+ const pendingMessage = `Upgrading app ${data.appId}...`;
4374
4414
  const txHash = await executeBatch(
4375
4415
  {
4376
- walletClient: prepared.walletClient,
4377
- publicClient: prepared.publicClient,
4378
- environmentConfig: prepared.environmentConfig,
4379
- executions: prepared.executions,
4416
+ walletClient: context.walletClient,
4417
+ publicClient: context.publicClient,
4418
+ environmentConfig: context.environmentConfig,
4419
+ executions: data.executions,
4380
4420
  pendingMessage,
4381
4421
  gas
4382
4422
  },
@@ -4394,7 +4434,16 @@ async function upgradeApp(options, logger) {
4394
4434
  publicLogs: options.publicLogs,
4395
4435
  needsPermissionChange: options.needsPermissionChange
4396
4436
  });
4397
- return executeUpgradeBatch(prepared, options.gas, logger);
4437
+ const data = {
4438
+ appId: prepared.appId,
4439
+ executions: prepared.executions
4440
+ };
4441
+ const context = {
4442
+ walletClient: prepared.walletClient,
4443
+ publicClient: prepared.publicClient,
4444
+ environmentConfig: prepared.environmentConfig
4445
+ };
4446
+ return executeUpgradeBatch(data, context, options.gas, logger);
4398
4447
  }
4399
4448
  async function sendAndWaitForTransaction(options, logger) {
4400
4449
  const {
@@ -5213,6 +5262,141 @@ function generateRandomSalt() {
5213
5262
  crypto.getRandomValues(salt);
5214
5263
  return salt;
5215
5264
  }
5265
+ async function prepareDeploy(options, logger = defaultLogger) {
5266
+ return withSDKTelemetry(
5267
+ {
5268
+ functionName: "prepareDeploy",
5269
+ skipTelemetry: options.skipTelemetry,
5270
+ properties: {
5271
+ environment: options.environment || "sepolia"
5272
+ }
5273
+ },
5274
+ async () => {
5275
+ validateDeployOptions(options);
5276
+ const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
5277
+ const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
5278
+ logger.debug("Performing preflight checks...");
5279
+ const preflightCtx = await doPreflightChecks(
5280
+ {
5281
+ privateKey: options.privateKey,
5282
+ rpcUrl: options.rpcUrl,
5283
+ environment: options.environment
5284
+ },
5285
+ logger
5286
+ );
5287
+ logger.debug("Checking quota availability...");
5288
+ await checkQuotaAvailable(preflightCtx);
5289
+ logger.debug("Checking Docker...");
5290
+ await ensureDockerIsRunning();
5291
+ const dockerfilePath = options.dockerfilePath || "";
5292
+ const imageRef = options.imageRef || "";
5293
+ const appName = options.appName;
5294
+ const envFilePath = options.envFilePath || "";
5295
+ const instanceType = options.instanceType;
5296
+ const salt = generateRandomSalt();
5297
+ logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
5298
+ logger.debug("Calculating app ID...");
5299
+ const appIDToBeDeployed = await calculateAppID(
5300
+ preflightCtx.privateKey,
5301
+ options.rpcUrl || preflightCtx.rpcUrl,
5302
+ preflightCtx.environmentConfig,
5303
+ salt
5304
+ );
5305
+ logger.info(``);
5306
+ logger.info(`App ID: ${appIDToBeDeployed}`);
5307
+ logger.info(``);
5308
+ logger.info("Preparing release...");
5309
+ const { release, finalImageRef } = await prepareRelease(
5310
+ {
5311
+ dockerfilePath,
5312
+ imageRef,
5313
+ envFilePath,
5314
+ logRedirect,
5315
+ resourceUsageAllow,
5316
+ instanceType,
5317
+ environmentConfig: preflightCtx.environmentConfig,
5318
+ appId: appIDToBeDeployed
5319
+ },
5320
+ logger
5321
+ );
5322
+ logger.debug("Preparing deploy batch...");
5323
+ const batch = await prepareDeployBatch(
5324
+ {
5325
+ privateKey: preflightCtx.privateKey,
5326
+ rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
5327
+ environmentConfig: preflightCtx.environmentConfig,
5328
+ salt,
5329
+ release,
5330
+ publicLogs
5331
+ },
5332
+ logger
5333
+ );
5334
+ logger.debug("Estimating gas...");
5335
+ const gasEstimate = await estimateBatchGas({
5336
+ publicClient: batch.publicClient,
5337
+ environmentConfig: batch.environmentConfig,
5338
+ executions: batch.executions
5339
+ });
5340
+ const data = {
5341
+ appId: batch.appId,
5342
+ salt: batch.salt,
5343
+ executions: batch.executions
5344
+ };
5345
+ return {
5346
+ prepared: {
5347
+ data,
5348
+ appName,
5349
+ imageRef: finalImageRef
5350
+ },
5351
+ gasEstimate
5352
+ };
5353
+ }
5354
+ );
5355
+ }
5356
+ async function executeDeploy(options) {
5357
+ const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5358
+ return withSDKTelemetry(
5359
+ {
5360
+ functionName: "executeDeploy",
5361
+ skipTelemetry
5362
+ },
5363
+ async () => {
5364
+ logger.info("Deploying on-chain...");
5365
+ const { appId, txHash } = await executeDeployBatch(prepared.data, context, gas, logger);
5366
+ return {
5367
+ appId,
5368
+ txHash,
5369
+ appName: prepared.appName,
5370
+ imageRef: prepared.imageRef
5371
+ };
5372
+ }
5373
+ );
5374
+ }
5375
+ async function watchDeployment(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId, skipTelemetry) {
5376
+ return withSDKTelemetry(
5377
+ {
5378
+ functionName: "watchDeployment",
5379
+ skipTelemetry,
5380
+ properties: {
5381
+ environment
5382
+ }
5383
+ },
5384
+ async () => {
5385
+ const environmentConfig = getEnvironmentConfig(environment);
5386
+ logger.info("Waiting for app to start...");
5387
+ return watchUntilRunning(
5388
+ {
5389
+ privateKey,
5390
+ rpcUrl,
5391
+ environmentConfig,
5392
+ appId,
5393
+ clientId
5394
+ },
5395
+ logger
5396
+ );
5397
+ }
5398
+ );
5399
+ }
5216
5400
 
5217
5401
  // src/client/common/utils/permissions.ts
5218
5402
  var import_viem8 = require("viem");
@@ -5344,6 +5528,125 @@ async function upgrade(options, logger = defaultLogger) {
5344
5528
  }
5345
5529
  );
5346
5530
  }
5531
+ async function prepareUpgrade(options, logger = defaultLogger) {
5532
+ return withSDKTelemetry(
5533
+ {
5534
+ functionName: "prepareUpgrade",
5535
+ skipTelemetry: options.skipTelemetry,
5536
+ properties: {
5537
+ environment: options.environment || "sepolia"
5538
+ }
5539
+ },
5540
+ async () => {
5541
+ logger.debug("Performing preflight checks...");
5542
+ const preflightCtx = await doPreflightChecks(
5543
+ {
5544
+ privateKey: options.privateKey,
5545
+ rpcUrl: options.rpcUrl,
5546
+ environment: options.environment
5547
+ },
5548
+ logger
5549
+ );
5550
+ const appID = validateUpgradeOptions(options);
5551
+ const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
5552
+ const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
5553
+ logger.debug("Checking Docker...");
5554
+ await ensureDockerIsRunning();
5555
+ const dockerfilePath = options.dockerfilePath || "";
5556
+ const imageRef = options.imageRef || "";
5557
+ const envFilePath = options.envFilePath || "";
5558
+ const instanceType = options.instanceType;
5559
+ logger.info("Preparing release...");
5560
+ const { release, finalImageRef } = await prepareRelease(
5561
+ {
5562
+ dockerfilePath,
5563
+ imageRef,
5564
+ envFilePath,
5565
+ logRedirect,
5566
+ resourceUsageAllow,
5567
+ instanceType,
5568
+ environmentConfig: preflightCtx.environmentConfig,
5569
+ appId: appID
5570
+ },
5571
+ logger
5572
+ );
5573
+ logger.debug("Checking current log permission state...");
5574
+ const currentlyPublic = await checkAppLogPermission(preflightCtx, appID, logger);
5575
+ const needsPermissionChange = currentlyPublic !== publicLogs;
5576
+ logger.debug("Preparing upgrade batch...");
5577
+ const batch = await prepareUpgradeBatch({
5578
+ privateKey: preflightCtx.privateKey,
5579
+ rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
5580
+ environmentConfig: preflightCtx.environmentConfig,
5581
+ appId: appID,
5582
+ release,
5583
+ publicLogs,
5584
+ needsPermissionChange
5585
+ });
5586
+ logger.debug("Estimating gas...");
5587
+ const gasEstimate = await estimateBatchGas({
5588
+ publicClient: batch.publicClient,
5589
+ environmentConfig: batch.environmentConfig,
5590
+ executions: batch.executions
5591
+ });
5592
+ const data = {
5593
+ appId: batch.appId,
5594
+ executions: batch.executions
5595
+ };
5596
+ return {
5597
+ prepared: {
5598
+ data,
5599
+ appId: appID,
5600
+ imageRef: finalImageRef
5601
+ },
5602
+ gasEstimate
5603
+ };
5604
+ }
5605
+ );
5606
+ }
5607
+ async function executeUpgrade(options) {
5608
+ const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5609
+ return withSDKTelemetry(
5610
+ {
5611
+ functionName: "executeUpgrade",
5612
+ skipTelemetry
5613
+ },
5614
+ async () => {
5615
+ logger.info("Upgrading on-chain...");
5616
+ const txHash = await executeUpgradeBatch(prepared.data, context, gas, logger);
5617
+ return {
5618
+ appId: prepared.appId,
5619
+ imageRef: prepared.imageRef,
5620
+ txHash
5621
+ };
5622
+ }
5623
+ );
5624
+ }
5625
+ async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId, skipTelemetry) {
5626
+ return withSDKTelemetry(
5627
+ {
5628
+ functionName: "watchUpgrade",
5629
+ skipTelemetry,
5630
+ properties: {
5631
+ environment
5632
+ }
5633
+ },
5634
+ async () => {
5635
+ const environmentConfig = getEnvironmentConfig(environment);
5636
+ logger.info("Waiting for upgrade to complete...");
5637
+ await watchUntilUpgradeComplete(
5638
+ {
5639
+ privateKey,
5640
+ rpcUrl,
5641
+ environmentConfig,
5642
+ appId,
5643
+ clientId
5644
+ },
5645
+ logger
5646
+ );
5647
+ }
5648
+ );
5649
+ }
5347
5650
 
5348
5651
  // src/client/modules/compute/app/create.ts
5349
5652
  var fs7 = __toESM(require("fs"), 1);
@@ -5441,8 +5744,8 @@ var path4 = __toESM(require("path"), 1);
5441
5744
  var os3 = __toESM(require("os"), 1);
5442
5745
  var import_child_process2 = require("child_process");
5443
5746
  var import_util4 = require("util");
5444
- var execAsync2 = (0, import_util4.promisify)(import_child_process2.exec);
5445
- var execFileAsync2 = (0, import_util4.promisify)(import_child_process2.execFile);
5747
+ var execAsync = (0, import_util4.promisify)(import_child_process2.exec);
5748
+ var execFileAsync3 = (0, import_util4.promisify)(import_child_process2.execFile);
5446
5749
  async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5447
5750
  if (!repoURL) {
5448
5751
  throw new Error("repoURL is required");
@@ -5451,13 +5754,13 @@ async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5451
5754
  Cloning repo: ${repoURL} \u2192 ${targetDir}
5452
5755
  `);
5453
5756
  try {
5454
- await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5757
+ await execAsync(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5455
5758
  maxBuffer: 10 * 1024 * 1024
5456
5759
  });
5457
- await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5760
+ await execFileAsync3("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5458
5761
  maxBuffer: 10 * 1024 * 1024
5459
5762
  });
5460
- await execFileAsync2(
5763
+ await execFileAsync3(
5461
5764
  "git",
5462
5765
  ["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
5463
5766
  { maxBuffer: 10 * 1024 * 1024 }
@@ -5502,14 +5805,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
5502
5805
  }
5503
5806
  async function cloneSparse(repoURL, ref, subPath, tempDir) {
5504
5807
  try {
5505
- await execFileAsync2("git", ["init", tempDir]);
5506
- await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5507
- await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5808
+ await execFileAsync3("git", ["init", tempDir]);
5809
+ await execFileAsync3("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5810
+ await execFileAsync3("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5508
5811
  const sparseCheckoutPath = path4.join(tempDir, ".git/info/sparse-checkout");
5509
5812
  fs5.writeFileSync(sparseCheckoutPath, `${subPath}
5510
5813
  `);
5511
- await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
5512
- await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
5814
+ await execFileAsync3("git", ["-C", tempDir, "fetch", "origin", ref]);
5815
+ await execFileAsync3("git", ["-C", tempDir, "checkout", ref]);
5513
5816
  } catch (error) {
5514
5817
  throw new Error(`Failed to clone sparse repository: ${error.message}`);
5515
5818
  }
@@ -6084,6 +6387,151 @@ function createAppModule(ctx) {
6084
6387
  imageRef: result.imageRef
6085
6388
  };
6086
6389
  },
6390
+ // Granular deploy control
6391
+ async prepareDeploy(opts) {
6392
+ return prepareDeploy(
6393
+ {
6394
+ privateKey,
6395
+ rpcUrl: ctx.rpcUrl,
6396
+ environment: ctx.environment,
6397
+ appName: opts.name,
6398
+ instanceType: opts.instanceType,
6399
+ dockerfilePath: opts.dockerfile,
6400
+ envFilePath: opts.envFile,
6401
+ imageRef: opts.imageRef,
6402
+ logVisibility: opts.logVisibility,
6403
+ resourceUsageMonitoring: opts.resourceUsageMonitoring,
6404
+ skipTelemetry
6405
+ },
6406
+ logger
6407
+ );
6408
+ },
6409
+ async executeDeploy(prepared, gas) {
6410
+ const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
6411
+ const chain = getChainFromID(environment.chainID);
6412
+ const publicClient = (0, import_viem9.createPublicClient)({
6413
+ chain,
6414
+ transport: (0, import_viem9.http)(ctx.rpcUrl)
6415
+ });
6416
+ const walletClient = (0, import_viem9.createWalletClient)({
6417
+ account,
6418
+ chain,
6419
+ transport: (0, import_viem9.http)(ctx.rpcUrl)
6420
+ });
6421
+ const result = await executeDeploy({
6422
+ prepared,
6423
+ context: {
6424
+ walletClient,
6425
+ publicClient,
6426
+ environmentConfig: environment
6427
+ },
6428
+ gas,
6429
+ logger,
6430
+ skipTelemetry
6431
+ });
6432
+ return {
6433
+ appId: result.appId,
6434
+ txHash: result.txHash,
6435
+ appName: result.appName,
6436
+ imageRef: result.imageRef
6437
+ };
6438
+ },
6439
+ async watchDeployment(appId) {
6440
+ return watchDeployment(
6441
+ appId,
6442
+ privateKey,
6443
+ ctx.rpcUrl,
6444
+ ctx.environment,
6445
+ logger,
6446
+ ctx.clientId,
6447
+ skipTelemetry
6448
+ );
6449
+ },
6450
+ // Granular upgrade control
6451
+ async prepareUpgrade(appId, opts) {
6452
+ return prepareUpgrade(
6453
+ {
6454
+ appId,
6455
+ privateKey,
6456
+ rpcUrl: ctx.rpcUrl,
6457
+ environment: ctx.environment,
6458
+ instanceType: opts.instanceType,
6459
+ dockerfilePath: opts.dockerfile,
6460
+ envFilePath: opts.envFile,
6461
+ imageRef: opts.imageRef,
6462
+ logVisibility: opts.logVisibility,
6463
+ resourceUsageMonitoring: opts.resourceUsageMonitoring,
6464
+ skipTelemetry
6465
+ },
6466
+ logger
6467
+ );
6468
+ },
6469
+ async executeUpgrade(prepared, gas) {
6470
+ const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
6471
+ const chain = getChainFromID(environment.chainID);
6472
+ const publicClient = (0, import_viem9.createPublicClient)({
6473
+ chain,
6474
+ transport: (0, import_viem9.http)(ctx.rpcUrl)
6475
+ });
6476
+ const walletClient = (0, import_viem9.createWalletClient)({
6477
+ account,
6478
+ chain,
6479
+ transport: (0, import_viem9.http)(ctx.rpcUrl)
6480
+ });
6481
+ const result = await executeUpgrade({
6482
+ prepared,
6483
+ context: {
6484
+ walletClient,
6485
+ publicClient,
6486
+ environmentConfig: environment
6487
+ },
6488
+ gas,
6489
+ logger,
6490
+ skipTelemetry
6491
+ });
6492
+ return {
6493
+ appId: result.appId,
6494
+ txHash: result.txHash,
6495
+ imageRef: result.imageRef
6496
+ };
6497
+ },
6498
+ async watchUpgrade(appId) {
6499
+ return watchUpgrade(
6500
+ appId,
6501
+ privateKey,
6502
+ ctx.rpcUrl,
6503
+ ctx.environment,
6504
+ logger,
6505
+ ctx.clientId,
6506
+ skipTelemetry
6507
+ );
6508
+ },
6509
+ // Profile management
6510
+ async setProfile(appId, profile) {
6511
+ return withSDKTelemetry(
6512
+ {
6513
+ functionName: "setProfile",
6514
+ skipTelemetry,
6515
+ properties: { environment: ctx.environment }
6516
+ },
6517
+ async () => {
6518
+ const userApiClient = new UserApiClient(
6519
+ environment,
6520
+ privateKey,
6521
+ ctx.rpcUrl,
6522
+ ctx.clientId
6523
+ );
6524
+ return userApiClient.uploadAppProfile(
6525
+ appId,
6526
+ profile.name,
6527
+ profile.website,
6528
+ profile.description,
6529
+ profile.xURL,
6530
+ profile.imagePath
6531
+ );
6532
+ }
6533
+ );
6534
+ },
6087
6535
  async logs(opts) {
6088
6536
  return logs(
6089
6537
  {