@layr-labs/ecloud-sdk 0.2.0-dev.1 → 0.2.0-dev.2

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.
@@ -17,10 +17,17 @@ import {
17
17
  getLogger,
18
18
  stripHexPrefix,
19
19
  withSDKTelemetry
20
- } from "./chunk-FY7UU55U.js";
20
+ } from "./chunk-ZEZS5CNB.js";
21
21
 
22
22
  // src/client/common/contract/eip7702.ts
23
- import { encodeFunctionData as encodeFunctionData2, encodeAbiParameters, decodeErrorResult as decodeErrorResult2 } from "viem";
23
+ import {
24
+ encodeFunctionData as encodeFunctionData2,
25
+ encodeAbiParameters,
26
+ decodeErrorResult as decodeErrorResult2,
27
+ keccak256,
28
+ toBytes,
29
+ concat
30
+ } from "viem";
24
31
 
25
32
  // src/client/common/abis/ERC7702Delegator.json
26
33
  var ERC7702Delegator_default = [
@@ -2749,20 +2756,20 @@ async function prepareDeployBatch(options, logger) {
2749
2756
  environmentConfig
2750
2757
  };
2751
2758
  }
2752
- async function executeDeployBatch(data, context, gas, logger) {
2759
+ async function executeDeployBatch(prepared, gas, logger) {
2753
2760
  const pendingMessage = "Deploying new app...";
2754
2761
  const txHash = await executeBatch(
2755
2762
  {
2756
- walletClient: context.walletClient,
2757
- publicClient: context.publicClient,
2758
- environmentConfig: context.environmentConfig,
2759
- executions: data.executions,
2763
+ walletClient: prepared.walletClient,
2764
+ publicClient: prepared.publicClient,
2765
+ environmentConfig: prepared.environmentConfig,
2766
+ executions: prepared.executions,
2760
2767
  pendingMessage,
2761
2768
  gas
2762
2769
  },
2763
2770
  logger
2764
2771
  );
2765
- return { appId: data.appId, txHash };
2772
+ return { appId: prepared.appId, txHash };
2766
2773
  }
2767
2774
  async function deployApp(options, logger) {
2768
2775
  const prepared = await prepareDeployBatch(
@@ -2776,17 +2783,7 @@ async function deployApp(options, logger) {
2776
2783
  },
2777
2784
  logger
2778
2785
  );
2779
- const data = {
2780
- appId: prepared.appId,
2781
- salt: prepared.salt,
2782
- executions: prepared.executions
2783
- };
2784
- const context = {
2785
- walletClient: prepared.walletClient,
2786
- publicClient: prepared.publicClient,
2787
- environmentConfig: prepared.environmentConfig
2788
- };
2789
- return executeDeployBatch(data, context, options.gas, logger);
2786
+ return executeDeployBatch(prepared, options.gas, logger);
2790
2787
  }
2791
2788
  async function prepareUpgradeBatch(options) {
2792
2789
  const {
@@ -2882,14 +2879,14 @@ async function prepareUpgradeBatch(options) {
2882
2879
  environmentConfig
2883
2880
  };
2884
2881
  }
2885
- async function executeUpgradeBatch(data, context, gas, logger) {
2886
- const pendingMessage = `Upgrading app ${data.appId}...`;
2882
+ async function executeUpgradeBatch(prepared, gas, logger) {
2883
+ const pendingMessage = `Upgrading app ${prepared.appId}...`;
2887
2884
  const txHash = await executeBatch(
2888
2885
  {
2889
- walletClient: context.walletClient,
2890
- publicClient: context.publicClient,
2891
- environmentConfig: context.environmentConfig,
2892
- executions: data.executions,
2886
+ walletClient: prepared.walletClient,
2887
+ publicClient: prepared.publicClient,
2888
+ environmentConfig: prepared.environmentConfig,
2889
+ executions: prepared.executions,
2893
2890
  pendingMessage,
2894
2891
  gas
2895
2892
  },
@@ -2907,16 +2904,7 @@ async function upgradeApp(options, logger) {
2907
2904
  publicLogs: options.publicLogs,
2908
2905
  needsPermissionChange: options.needsPermissionChange
2909
2906
  });
2910
- const data = {
2911
- appId: prepared.appId,
2912
- executions: prepared.executions
2913
- };
2914
- const context = {
2915
- walletClient: prepared.walletClient,
2916
- publicClient: prepared.publicClient,
2917
- environmentConfig: prepared.environmentConfig
2918
- };
2919
- return executeUpgradeBatch(data, context, options.gas, logger);
2907
+ return executeUpgradeBatch(prepared, options.gas, logger);
2920
2908
  }
2921
2909
  async function sendAndWaitForTransaction(options, logger) {
2922
2910
  const {
@@ -3207,55 +3195,27 @@ async function undelegate(options, logger) {
3207
3195
  }
3208
3196
 
3209
3197
  // src/client/common/contract/eip7702.ts
3210
- var EXECUTE_BATCH_MODE = "0x0100000000000000000000000000000000000000000000000000000000000000";
3211
- var GAS_LIMIT_BUFFER_PERCENTAGE = 20n;
3212
- var GAS_PRICE_BUFFER_PERCENTAGE = 100n;
3213
- function encodeExecuteBatchData(executions) {
3214
- const encodedExecutions = encodeAbiParameters(
3215
- [
3216
- {
3217
- type: "tuple[]",
3218
- components: [
3219
- { name: "target", type: "address" },
3220
- { name: "value", type: "uint256" },
3221
- { name: "callData", type: "bytes" }
3222
- ]
3223
- }
3224
- ],
3225
- [executions]
3226
- );
3227
- return encodeFunctionData2({
3228
- abi: ERC7702Delegator_default,
3229
- functionName: "execute",
3230
- args: [EXECUTE_BATCH_MODE, encodedExecutions]
3231
- });
3232
- }
3233
3198
  async function estimateBatchGas(options) {
3234
- const { publicClient, account, executions } = options;
3235
- const executeBatchData = encodeExecuteBatchData(executions);
3236
- const [gasTipCap, block, estimatedGas] = await Promise.all([
3237
- publicClient.estimateMaxPriorityFeePerGas(),
3238
- publicClient.getBlock(),
3239
- publicClient.estimateGas({
3240
- account,
3241
- to: account,
3242
- data: executeBatchData
3243
- })
3244
- ]);
3245
- const baseFee = block.baseFeePerGas ?? 0n;
3246
- const maxFeePerGas = (baseFee + gasTipCap) * (100n + GAS_PRICE_BUFFER_PERCENTAGE) / 100n;
3247
- const gasLimit = estimatedGas * (100n + GAS_LIMIT_BUFFER_PERCENTAGE) / 100n;
3199
+ const { publicClient, executions } = options;
3200
+ const fees = await publicClient.estimateFeesPerGas();
3201
+ const baseGas = 100000n;
3202
+ const perExecutionGas = 50000n;
3203
+ const estimatedGas = baseGas + BigInt(executions.length) * perExecutionGas;
3204
+ const gasLimit = estimatedGas * 120n / 100n;
3205
+ const maxFeePerGas = fees.maxFeePerGas;
3206
+ const maxPriorityFeePerGas = fees.maxPriorityFeePerGas;
3248
3207
  const maxCostWei = gasLimit * maxFeePerGas;
3208
+ const maxCostEth = formatETH(maxCostWei);
3249
3209
  return {
3250
3210
  gasLimit,
3251
3211
  maxFeePerGas,
3252
- maxPriorityFeePerGas: gasTipCap,
3212
+ maxPriorityFeePerGas,
3253
3213
  maxCostWei,
3254
- maxCostEth: formatETH(maxCostWei)
3214
+ maxCostEth
3255
3215
  };
3256
3216
  }
3257
3217
  async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
3258
- const code = await publicClient.getCode({ address: account });
3218
+ const code = await publicClient.getBytecode({ address: account });
3259
3219
  if (!code) {
3260
3220
  return false;
3261
3221
  }
@@ -3272,7 +3232,36 @@ async function executeBatch(options, logger) {
3272
3232
  if (!chain) {
3273
3233
  throw new Error("Wallet client must have a chain");
3274
3234
  }
3275
- const executeBatchData = encodeExecuteBatchData(executions);
3235
+ const encodedExecutions = encodeAbiParameters(
3236
+ [
3237
+ {
3238
+ type: "tuple[]",
3239
+ components: [
3240
+ { name: "target", type: "address" },
3241
+ { name: "value", type: "uint256" },
3242
+ { name: "callData", type: "bytes" }
3243
+ ]
3244
+ }
3245
+ ],
3246
+ [executions]
3247
+ );
3248
+ const executeBatchMode = "0x0100000000000000000000000000000000000000000000000000000000000000";
3249
+ let executeBatchData;
3250
+ try {
3251
+ executeBatchData = encodeFunctionData2({
3252
+ abi: ERC7702Delegator_default,
3253
+ functionName: "execute",
3254
+ args: [executeBatchMode, encodedExecutions]
3255
+ });
3256
+ } catch {
3257
+ const functionSignature = "execute(bytes32,bytes)";
3258
+ const selector = keccak256(toBytes(functionSignature)).slice(0, 10);
3259
+ const encodedParams = encodeAbiParameters(
3260
+ [{ type: "bytes32" }, { type: "bytes" }],
3261
+ [executeBatchMode, encodedExecutions]
3262
+ );
3263
+ executeBatchData = concat([selector, encodedParams]);
3264
+ }
3276
3265
  const isDelegated2 = await checkERC7702Delegation(
3277
3266
  publicClient,
3278
3267
  account.address,
@@ -3654,7 +3643,6 @@ async function buildDockerImage(buildContext, dockerfilePath, tag, logger) {
3654
3643
  tag,
3655
3644
  "-f",
3656
3645
  dockerfilePath,
3657
- "--load",
3658
3646
  "--progress=plain",
3659
3647
  buildContext
3660
3648
  ];
@@ -3778,9 +3766,9 @@ async function pullDockerImage(docker, imageTag, platform = "linux/amd64", logge
3778
3766
 
3779
3767
  // src/client/common/docker/push.ts
3780
3768
  import * as child_process2 from "child_process";
3781
- import { execFile } from "child_process";
3769
+ import { exec as exec3 } from "child_process";
3782
3770
  import { promisify as promisify2 } from "util";
3783
- var execFileAsync = promisify2(execFile);
3771
+ var execAsync = promisify2(exec3);
3784
3772
  async function pushDockerImage(docker, imageRef, logger) {
3785
3773
  logger?.info?.(`Pushing image ${imageRef}...`);
3786
3774
  return new Promise((resolve2, reject) => {
@@ -3821,9 +3809,9 @@ async function pushDockerImage(docker, imageRef, logger) {
3821
3809
  if (!output.includes("digest:") && !output.includes("pushed") && !output.includes("Pushed")) {
3822
3810
  logger?.debug?.("No clear success indicator in push output, verifying...");
3823
3811
  }
3812
+ logger?.info?.("Image push completed successfully");
3824
3813
  try {
3825
3814
  await verifyImageExists(imageRef, logger);
3826
- logger?.info?.("Image push completed successfully");
3827
3815
  resolve2();
3828
3816
  } catch (error) {
3829
3817
  reject(error);
@@ -3847,7 +3835,7 @@ async function verifyImageExists(imageRef, logger) {
3847
3835
  let retries = 5;
3848
3836
  while (retries > 0) {
3849
3837
  try {
3850
- await execFileAsync("docker", ["manifest", "inspect", imageRef], {
3838
+ await execAsync(`docker manifest inspect ${imageRef}`, {
3851
3839
  maxBuffer: 10 * 1024 * 1024,
3852
3840
  timeout: 1e4
3853
3841
  // 10 second timeout
@@ -4305,10 +4293,10 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
4305
4293
  // src/client/common/registry/digest.ts
4306
4294
  import * as child_process3 from "child_process";
4307
4295
  import { promisify as promisify3 } from "util";
4308
- var execFileAsync2 = promisify3(child_process3.execFile);
4296
+ var execFileAsync = promisify3(child_process3.execFile);
4309
4297
  async function getImageDigestAndName(imageRef) {
4310
4298
  try {
4311
- const { stdout } = await execFileAsync2(
4299
+ const { stdout } = await execFileAsync(
4312
4300
  "docker",
4313
4301
  ["manifest", "inspect", imageRef],
4314
4302
  { maxBuffer: 10 * 1024 * 1024 }
@@ -4348,7 +4336,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
4348
4336
  }
4349
4337
  async function extractDigestFromSinglePlatform(manifest, imageRef) {
4350
4338
  try {
4351
- const { stdout } = await execFileAsync2("docker", ["inspect", imageRef], {
4339
+ const { stdout } = await execFileAsync("docker", ["inspect", imageRef], {
4352
4340
  maxBuffer: 10 * 1024 * 1024
4353
4341
  });
4354
4342
  const inspectData = JSON.parse(stdout);
@@ -4646,67 +4634,6 @@ Please verify the image exists: docker manifest inspect ${finalImageRef}`
4646
4634
  };
4647
4635
  }
4648
4636
 
4649
- // src/client/common/release/prebuilt.ts
4650
- async function createReleaseFromImageDigest(options, logger) {
4651
- const { imageRef, imageDigest, envFilePath, instanceType, environmentConfig, appId } = options;
4652
- if (!/^sha256:[0-9a-f]{64}$/i.test(imageDigest)) {
4653
- throw new Error(`imageDigest must be in format sha256:<64 hex>, got: ${imageDigest}`);
4654
- }
4655
- let publicEnv = {};
4656
- let privateEnv = {};
4657
- if (envFilePath) {
4658
- logger.info("Parsing environment file...");
4659
- const parsed = parseAndValidateEnvFile(envFilePath);
4660
- publicEnv = parsed.public;
4661
- privateEnv = parsed.private;
4662
- } else {
4663
- logger.info("Continuing without environment file");
4664
- }
4665
- publicEnv["EIGEN_MACHINE_TYPE_PUBLIC"] = instanceType;
4666
- logger.info(`Instance type: ${instanceType}`);
4667
- logger.info("Encrypting environment variables...");
4668
- const { encryptionKey } = getKMSKeysForEnvironment(
4669
- environmentConfig.name,
4670
- environmentConfig.build
4671
- );
4672
- const protectedHeaders = getAppProtectedHeaders(appId);
4673
- const privateEnvBytes = Buffer.from(JSON.stringify(privateEnv));
4674
- const encryptedEnvStr = await encryptRSAOAEPAndAES256GCM(
4675
- encryptionKey,
4676
- privateEnvBytes,
4677
- protectedHeaders
4678
- );
4679
- const digestHex = imageDigest.split(":")[1];
4680
- const digestBytes = new Uint8Array(Buffer.from(digestHex, "hex"));
4681
- if (digestBytes.length !== 32) {
4682
- throw new Error(`Digest must be exactly 32 bytes, got ${digestBytes.length}`);
4683
- }
4684
- const registry = extractRegistryNameNoDocker(imageRef);
4685
- return {
4686
- rmsRelease: {
4687
- artifacts: [{ digest: digestBytes, registry }],
4688
- upgradeByTime: Math.floor(Date.now() / 1e3) + 3600
4689
- },
4690
- publicEnv: new Uint8Array(Buffer.from(JSON.stringify(publicEnv))),
4691
- encryptedEnv: new Uint8Array(Buffer.from(encryptedEnvStr))
4692
- };
4693
- }
4694
- function extractRegistryNameNoDocker(imageRef) {
4695
- let name = imageRef;
4696
- const tagIndex = name.lastIndexOf(":");
4697
- if (tagIndex !== -1 && !name.substring(tagIndex + 1).includes("/")) {
4698
- name = name.substring(0, tagIndex);
4699
- }
4700
- const digestIndex = name.indexOf("@");
4701
- if (digestIndex !== -1) {
4702
- name = name.substring(0, digestIndex);
4703
- }
4704
- if ([...name].filter((c) => c === "/").length === 1) {
4705
- name = `docker.io/${name}`;
4706
- }
4707
- return name;
4708
- }
4709
-
4710
4637
  // src/client/common/contract/watcher.ts
4711
4638
  var WATCH_POLL_INTERVAL_SECONDS = 5;
4712
4639
  var APP_STATUS_RUNNING = "Running";
@@ -4888,97 +4815,6 @@ function validatePrivateKey(key) {
4888
4815
  }
4889
4816
 
4890
4817
  // src/client/modules/compute/app/deploy.ts
4891
- async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger) {
4892
- return withSDKTelemetry(
4893
- {
4894
- functionName: "prepareDeployFromVerifiableBuild",
4895
- skipTelemetry: options.skipTelemetry,
4896
- properties: {
4897
- environment: options.environment || "sepolia"
4898
- }
4899
- },
4900
- async () => {
4901
- if (!options.privateKey) throw new Error("privateKey is required for deployment");
4902
- if (!options.imageRef) throw new Error("imageRef is required for deployment");
4903
- if (!options.imageDigest) throw new Error("imageDigest is required for deployment");
4904
- assertValidImageReference(options.imageRef);
4905
- validateAppName(options.appName);
4906
- validateLogVisibility(options.logVisibility);
4907
- if (!/^sha256:[0-9a-f]{64}$/i.test(options.imageDigest)) {
4908
- throw new Error(
4909
- `imageDigest must be in format sha256:<64 hex>, got: ${options.imageDigest}`
4910
- );
4911
- }
4912
- const { publicLogs } = validateLogVisibility(options.logVisibility);
4913
- validateResourceUsageMonitoring(options.resourceUsageMonitoring);
4914
- logger.debug("Performing preflight checks...");
4915
- const preflightCtx = await doPreflightChecks(
4916
- {
4917
- privateKey: options.privateKey,
4918
- rpcUrl: options.rpcUrl,
4919
- environment: options.environment
4920
- },
4921
- logger
4922
- );
4923
- logger.debug("Checking quota availability...");
4924
- await checkQuotaAvailable(preflightCtx);
4925
- const salt = generateRandomSalt();
4926
- logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
4927
- logger.debug("Calculating app ID...");
4928
- const appIDToBeDeployed = await calculateAppID(
4929
- preflightCtx.privateKey,
4930
- options.rpcUrl || preflightCtx.rpcUrl,
4931
- preflightCtx.environmentConfig,
4932
- salt
4933
- );
4934
- logger.info(``);
4935
- logger.info(`App ID: ${appIDToBeDeployed}`);
4936
- logger.info(``);
4937
- const release = await createReleaseFromImageDigest(
4938
- {
4939
- imageRef: options.imageRef,
4940
- imageDigest: options.imageDigest,
4941
- envFilePath: options.envFilePath,
4942
- instanceType: options.instanceType,
4943
- environmentConfig: preflightCtx.environmentConfig,
4944
- appId: appIDToBeDeployed
4945
- },
4946
- logger
4947
- );
4948
- logger.debug("Preparing deploy batch...");
4949
- const batch = await prepareDeployBatch(
4950
- {
4951
- privateKey: preflightCtx.privateKey,
4952
- rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
4953
- environmentConfig: preflightCtx.environmentConfig,
4954
- salt,
4955
- release,
4956
- publicLogs
4957
- },
4958
- logger
4959
- );
4960
- logger.debug("Estimating gas...");
4961
- const gasEstimate = await estimateBatchGas({
4962
- publicClient: batch.publicClient,
4963
- account: batch.walletClient.account.address,
4964
- executions: batch.executions
4965
- });
4966
- const data = {
4967
- appId: batch.appId,
4968
- salt: batch.salt,
4969
- executions: batch.executions
4970
- };
4971
- return {
4972
- prepared: {
4973
- data,
4974
- appName: options.appName,
4975
- imageRef: options.imageRef
4976
- },
4977
- gasEstimate
4978
- };
4979
- }
4980
- );
4981
- }
4982
4818
  function validateDeployOptions(options) {
4983
4819
  if (!options.privateKey) {
4984
4820
  throw new Error("privateKey is required for deployment");
@@ -5199,27 +5035,26 @@ async function prepareDeploy(options, logger = defaultLogger) {
5199
5035
  logger.debug("Estimating gas...");
5200
5036
  const gasEstimate = await estimateBatchGas({
5201
5037
  publicClient: batch.publicClient,
5202
- account: batch.walletClient.account.address,
5038
+ environmentConfig: batch.environmentConfig,
5203
5039
  executions: batch.executions
5204
5040
  });
5205
- const data = {
5206
- appId: batch.appId,
5207
- salt: batch.salt,
5208
- executions: batch.executions
5209
- };
5210
5041
  return {
5211
5042
  prepared: {
5212
- data,
5043
+ batch,
5213
5044
  appName,
5214
- imageRef: finalImageRef
5045
+ imageRef: finalImageRef,
5046
+ preflightCtx: {
5047
+ privateKey: preflightCtx.privateKey,
5048
+ rpcUrl: preflightCtx.rpcUrl,
5049
+ environmentConfig: preflightCtx.environmentConfig
5050
+ }
5215
5051
  },
5216
5052
  gasEstimate
5217
5053
  };
5218
5054
  }
5219
5055
  );
5220
5056
  }
5221
- async function executeDeploy(options) {
5222
- const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5057
+ async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetry) {
5223
5058
  return withSDKTelemetry(
5224
5059
  {
5225
5060
  functionName: "executeDeploy",
@@ -5227,7 +5062,7 @@ async function executeDeploy(options) {
5227
5062
  },
5228
5063
  async () => {
5229
5064
  logger.info("Deploying on-chain...");
5230
- const { appId, txHash } = await executeDeployBatch(prepared.data, context, gas, logger);
5065
+ const { appId, txHash } = await executeDeployBatch(prepared.batch, gas, logger);
5231
5066
  return {
5232
5067
  appId,
5233
5068
  txHash,
@@ -5289,81 +5124,6 @@ async function checkAppLogPermission(preflightCtx, appAddress, logger) {
5289
5124
  }
5290
5125
 
5291
5126
  // src/client/modules/compute/app/upgrade.ts
5292
- async function prepareUpgradeFromVerifiableBuild(options, logger = defaultLogger) {
5293
- return withSDKTelemetry(
5294
- {
5295
- functionName: "prepareUpgradeFromVerifiableBuild",
5296
- skipTelemetry: options.skipTelemetry,
5297
- properties: {
5298
- environment: options.environment || "sepolia"
5299
- }
5300
- },
5301
- async () => {
5302
- logger.debug("Performing preflight checks...");
5303
- const preflightCtx = await doPreflightChecks(
5304
- {
5305
- privateKey: options.privateKey,
5306
- rpcUrl: options.rpcUrl,
5307
- environment: options.environment
5308
- },
5309
- logger
5310
- );
5311
- const appID = validateUpgradeOptions(options);
5312
- assertValidImageReference(options.imageRef);
5313
- if (!/^sha256:[0-9a-f]{64}$/i.test(options.imageDigest)) {
5314
- throw new Error(
5315
- `imageDigest must be in format sha256:<64 hex>, got: ${options.imageDigest}`
5316
- );
5317
- }
5318
- const { publicLogs } = validateLogVisibility(options.logVisibility);
5319
- validateResourceUsageMonitoring(options.resourceUsageMonitoring);
5320
- const envFilePath = options.envFilePath || "";
5321
- logger.info("Preparing release (verifiable build, no local layering)...");
5322
- const release = await createReleaseFromImageDigest(
5323
- {
5324
- imageRef: options.imageRef,
5325
- imageDigest: options.imageDigest,
5326
- envFilePath,
5327
- instanceType: options.instanceType,
5328
- environmentConfig: preflightCtx.environmentConfig,
5329
- appId: appID
5330
- },
5331
- logger
5332
- );
5333
- logger.debug("Checking current log permission state...");
5334
- const currentlyPublic = await checkAppLogPermission(preflightCtx, appID, logger);
5335
- const needsPermissionChange = currentlyPublic !== publicLogs;
5336
- logger.debug("Preparing upgrade batch...");
5337
- const batch = await prepareUpgradeBatch({
5338
- privateKey: preflightCtx.privateKey,
5339
- rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
5340
- environmentConfig: preflightCtx.environmentConfig,
5341
- appId: appID,
5342
- release,
5343
- publicLogs,
5344
- needsPermissionChange
5345
- });
5346
- logger.debug("Estimating gas...");
5347
- const gasEstimate = await estimateBatchGas({
5348
- publicClient: batch.publicClient,
5349
- account: batch.walletClient.account.address,
5350
- executions: batch.executions
5351
- });
5352
- const data = {
5353
- appId: batch.appId,
5354
- executions: batch.executions
5355
- };
5356
- return {
5357
- prepared: {
5358
- data,
5359
- appId: appID,
5360
- imageRef: options.imageRef
5361
- },
5362
- gasEstimate
5363
- };
5364
- }
5365
- );
5366
- }
5367
5127
  function validateUpgradeOptions(options) {
5368
5128
  if (!options.privateKey) {
5369
5129
  throw new Error("privateKey is required for upgrade");
@@ -5526,26 +5286,26 @@ async function prepareUpgrade(options, logger = defaultLogger) {
5526
5286
  logger.debug("Estimating gas...");
5527
5287
  const gasEstimate = await estimateBatchGas({
5528
5288
  publicClient: batch.publicClient,
5529
- account: batch.walletClient.account.address,
5289
+ environmentConfig: batch.environmentConfig,
5530
5290
  executions: batch.executions
5531
5291
  });
5532
- const data = {
5533
- appId: batch.appId,
5534
- executions: batch.executions
5535
- };
5536
5292
  return {
5537
5293
  prepared: {
5538
- data,
5294
+ batch,
5539
5295
  appId: appID,
5540
- imageRef: finalImageRef
5296
+ imageRef: finalImageRef,
5297
+ preflightCtx: {
5298
+ privateKey: preflightCtx.privateKey,
5299
+ rpcUrl: preflightCtx.rpcUrl,
5300
+ environmentConfig: preflightCtx.environmentConfig
5301
+ }
5541
5302
  },
5542
5303
  gasEstimate
5543
5304
  };
5544
5305
  }
5545
5306
  );
5546
5307
  }
5547
- async function executeUpgrade(options) {
5548
- const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5308
+ async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemetry) {
5549
5309
  return withSDKTelemetry(
5550
5310
  {
5551
5311
  functionName: "executeUpgrade",
@@ -5553,7 +5313,7 @@ async function executeUpgrade(options) {
5553
5313
  },
5554
5314
  async () => {
5555
5315
  logger.info("Upgrading on-chain...");
5556
- const txHash = await executeUpgradeBatch(prepared.data, context, gas, logger);
5316
+ const txHash = await executeUpgradeBatch(prepared.batch, gas, logger);
5557
5317
  return {
5558
5318
  appId: prepared.appId,
5559
5319
  imageRef: prepared.imageRef,
@@ -5682,10 +5442,10 @@ import * as path6 from "path";
5682
5442
  import * as fs5 from "fs";
5683
5443
  import * as path4 from "path";
5684
5444
  import * as os2 from "os";
5685
- import { exec as exec3, execFile as execFile3 } from "child_process";
5445
+ import { exec as exec4, execFile as execFile2 } from "child_process";
5686
5446
  import { promisify as promisify4 } from "util";
5687
- var execAsync = promisify4(exec3);
5688
- var execFileAsync3 = promisify4(execFile3);
5447
+ var execAsync2 = promisify4(exec4);
5448
+ var execFileAsync2 = promisify4(execFile2);
5689
5449
  async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5690
5450
  if (!repoURL) {
5691
5451
  throw new Error("repoURL is required");
@@ -5694,13 +5454,13 @@ async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5694
5454
  Cloning repo: ${repoURL} \u2192 ${targetDir}
5695
5455
  `);
5696
5456
  try {
5697
- await execAsync(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5457
+ await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5698
5458
  maxBuffer: 10 * 1024 * 1024
5699
5459
  });
5700
- await execFileAsync3("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5460
+ await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5701
5461
  maxBuffer: 10 * 1024 * 1024
5702
5462
  });
5703
- await execFileAsync3(
5463
+ await execFileAsync2(
5704
5464
  "git",
5705
5465
  ["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
5706
5466
  { maxBuffer: 10 * 1024 * 1024 }
@@ -5745,14 +5505,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
5745
5505
  }
5746
5506
  async function cloneSparse(repoURL, ref, subPath, tempDir) {
5747
5507
  try {
5748
- await execFileAsync3("git", ["init", tempDir]);
5749
- await execFileAsync3("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5750
- await execFileAsync3("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5508
+ await execFileAsync2("git", ["init", tempDir]);
5509
+ await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5510
+ await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5751
5511
  const sparseCheckoutPath = path4.join(tempDir, ".git/info/sparse-checkout");
5752
5512
  fs5.writeFileSync(sparseCheckoutPath, `${subPath}
5753
5513
  `);
5754
- await execFileAsync3("git", ["-C", tempDir, "fetch", "origin", ref]);
5755
- await execFileAsync3("git", ["-C", tempDir, "checkout", ref]);
5514
+ await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
5515
+ await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
5756
5516
  } catch (error) {
5757
5517
  throw new Error(`Failed to clone sparse repository: ${error.message}`);
5758
5518
  }
@@ -6245,14 +6005,7 @@ async function logs(options, logger = defaultLogger, skipTelemetry = false) {
6245
6005
  }
6246
6006
 
6247
6007
  // src/client/modules/compute/app/index.ts
6248
- import {
6249
- parseAbi,
6250
- encodeFunctionData as encodeFunctionData3,
6251
- createWalletClient as createWalletClient2,
6252
- createPublicClient as createPublicClient4,
6253
- http as http4
6254
- } from "viem";
6255
- import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
6008
+ import { parseAbi, encodeFunctionData as encodeFunctionData3 } from "viem";
6256
6009
  var CONTROLLER_ABI = parseAbi([
6257
6010
  "function startApp(address appId)",
6258
6011
  "function stopApp(address appId)",
@@ -6335,187 +6088,6 @@ function createAppModule(ctx) {
6335
6088
  imageRef: result.imageRef
6336
6089
  };
6337
6090
  },
6338
- // Granular deploy control
6339
- async prepareDeploy(opts) {
6340
- return prepareDeploy(
6341
- {
6342
- privateKey,
6343
- rpcUrl: ctx.rpcUrl,
6344
- environment: ctx.environment,
6345
- appName: opts.name,
6346
- instanceType: opts.instanceType,
6347
- dockerfilePath: opts.dockerfile,
6348
- envFilePath: opts.envFile,
6349
- imageRef: opts.imageRef,
6350
- logVisibility: opts.logVisibility,
6351
- resourceUsageMonitoring: opts.resourceUsageMonitoring,
6352
- skipTelemetry
6353
- },
6354
- logger
6355
- );
6356
- },
6357
- async prepareDeployFromVerifiableBuild(opts) {
6358
- return prepareDeployFromVerifiableBuild(
6359
- {
6360
- privateKey,
6361
- rpcUrl: ctx.rpcUrl,
6362
- environment: ctx.environment,
6363
- appName: opts.name,
6364
- instanceType: opts.instanceType,
6365
- envFilePath: opts.envFile,
6366
- imageRef: opts.imageRef,
6367
- imageDigest: opts.imageDigest,
6368
- logVisibility: opts.logVisibility,
6369
- resourceUsageMonitoring: opts.resourceUsageMonitoring,
6370
- skipTelemetry
6371
- },
6372
- logger
6373
- );
6374
- },
6375
- async executeDeploy(prepared, gas) {
6376
- const account = privateKeyToAccount3(privateKey);
6377
- const chain = getChainFromID(environment.chainID);
6378
- const publicClient = createPublicClient4({
6379
- chain,
6380
- transport: http4(ctx.rpcUrl)
6381
- });
6382
- const walletClient = createWalletClient2({
6383
- account,
6384
- chain,
6385
- transport: http4(ctx.rpcUrl)
6386
- });
6387
- const result = await executeDeploy({
6388
- prepared,
6389
- context: {
6390
- walletClient,
6391
- publicClient,
6392
- environmentConfig: environment
6393
- },
6394
- gas,
6395
- logger,
6396
- skipTelemetry
6397
- });
6398
- return {
6399
- appId: result.appId,
6400
- txHash: result.txHash,
6401
- appName: result.appName,
6402
- imageRef: result.imageRef
6403
- };
6404
- },
6405
- async watchDeployment(appId) {
6406
- return watchDeployment(
6407
- appId,
6408
- privateKey,
6409
- ctx.rpcUrl,
6410
- ctx.environment,
6411
- logger,
6412
- ctx.clientId,
6413
- skipTelemetry
6414
- );
6415
- },
6416
- // Granular upgrade control
6417
- async prepareUpgrade(appId, opts) {
6418
- return prepareUpgrade(
6419
- {
6420
- appId,
6421
- privateKey,
6422
- rpcUrl: ctx.rpcUrl,
6423
- environment: ctx.environment,
6424
- instanceType: opts.instanceType,
6425
- dockerfilePath: opts.dockerfile,
6426
- envFilePath: opts.envFile,
6427
- imageRef: opts.imageRef,
6428
- logVisibility: opts.logVisibility,
6429
- resourceUsageMonitoring: opts.resourceUsageMonitoring,
6430
- skipTelemetry
6431
- },
6432
- logger
6433
- );
6434
- },
6435
- async prepareUpgradeFromVerifiableBuild(appId, opts) {
6436
- return prepareUpgradeFromVerifiableBuild(
6437
- {
6438
- appId,
6439
- privateKey,
6440
- rpcUrl: ctx.rpcUrl,
6441
- environment: ctx.environment,
6442
- instanceType: opts.instanceType,
6443
- envFilePath: opts.envFile,
6444
- imageRef: opts.imageRef,
6445
- imageDigest: opts.imageDigest,
6446
- logVisibility: opts.logVisibility,
6447
- resourceUsageMonitoring: opts.resourceUsageMonitoring,
6448
- skipTelemetry
6449
- },
6450
- logger
6451
- );
6452
- },
6453
- async executeUpgrade(prepared, gas) {
6454
- const account = privateKeyToAccount3(privateKey);
6455
- const chain = getChainFromID(environment.chainID);
6456
- const publicClient = createPublicClient4({
6457
- chain,
6458
- transport: http4(ctx.rpcUrl)
6459
- });
6460
- const walletClient = createWalletClient2({
6461
- account,
6462
- chain,
6463
- transport: http4(ctx.rpcUrl)
6464
- });
6465
- const result = await executeUpgrade({
6466
- prepared,
6467
- context: {
6468
- walletClient,
6469
- publicClient,
6470
- environmentConfig: environment
6471
- },
6472
- gas,
6473
- logger,
6474
- skipTelemetry
6475
- });
6476
- return {
6477
- appId: result.appId,
6478
- txHash: result.txHash,
6479
- imageRef: result.imageRef
6480
- };
6481
- },
6482
- async watchUpgrade(appId) {
6483
- return watchUpgrade(
6484
- appId,
6485
- privateKey,
6486
- ctx.rpcUrl,
6487
- ctx.environment,
6488
- logger,
6489
- ctx.clientId,
6490
- skipTelemetry
6491
- );
6492
- },
6493
- // Profile management
6494
- async setProfile(appId, profile) {
6495
- return withSDKTelemetry(
6496
- {
6497
- functionName: "setProfile",
6498
- skipTelemetry,
6499
- properties: { environment: ctx.environment }
6500
- },
6501
- async () => {
6502
- const userApiClient = new UserApiClient(
6503
- environment,
6504
- privateKey,
6505
- ctx.rpcUrl,
6506
- ctx.clientId
6507
- );
6508
- return userApiClient.uploadAppProfile(
6509
- appId,
6510
- profile.name,
6511
- profile.website,
6512
- profile.description,
6513
- profile.xURL,
6514
- profile.imagePath
6515
- );
6516
- }
6517
- );
6518
- },
6519
6091
  async logs(opts) {
6520
6092
  return logs(
6521
6093
  {
@@ -6695,11 +6267,9 @@ export {
6695
6267
  validateUpgradeParams,
6696
6268
  validateCreateAppParams,
6697
6269
  validateLogsParams,
6698
- prepareDeployFromVerifiableBuild,
6699
6270
  prepareDeploy,
6700
6271
  executeDeploy,
6701
6272
  watchDeployment,
6702
- prepareUpgradeFromVerifiableBuild,
6703
6273
  prepareUpgrade,
6704
6274
  executeUpgrade,
6705
6275
  watchUpgrade,
@@ -6716,4 +6286,4 @@ export {
6716
6286
  createAppModule,
6717
6287
  createComputeModule
6718
6288
  };
6719
- //# sourceMappingURL=chunk-O7EU5JL7.js.map
6289
+ //# sourceMappingURL=chunk-4SKRNFKQ.js.map