@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/index.cjs CHANGED
@@ -117,6 +117,7 @@ module.exports = __toCommonJS(index_exports);
117
117
 
118
118
  // src/client/modules/compute/app/index.ts
119
119
  var import_viem9 = require("viem");
120
+ var import_accounts5 = require("viem/accounts");
120
121
 
121
122
  // src/client/common/config/environment.ts
122
123
  var SEPOLIA_CHAIN_ID = 11155111;
@@ -206,7 +207,7 @@ function getBillingEnvironmentConfig(build) {
206
207
  return config;
207
208
  }
208
209
  function getBuildType() {
209
- const buildTimeType = true ? "prod"?.toLowerCase() : void 0;
210
+ const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
210
211
  const runtimeType = process.env.BUILD_TYPE?.toLowerCase();
211
212
  const buildType = buildTimeType || runtimeType;
212
213
  if (buildType === "dev") {
@@ -257,6 +258,7 @@ async function buildDockerImage(buildContext, dockerfilePath, tag, logger) {
257
258
  tag,
258
259
  "-f",
259
260
  dockerfilePath,
261
+ "--load",
260
262
  "--progress=plain",
261
263
  buildContext
262
264
  ];
@@ -382,7 +384,7 @@ async function pullDockerImage(docker, imageTag, platform2 = "linux/amd64", logg
382
384
  var child_process2 = __toESM(require("child_process"), 1);
383
385
  var import_child_process = require("child_process");
384
386
  var import_util2 = require("util");
385
- var execAsync = (0, import_util2.promisify)(import_child_process.exec);
387
+ var execFileAsync = (0, import_util2.promisify)(import_child_process.execFile);
386
388
  async function pushDockerImage(docker, imageRef, logger) {
387
389
  logger?.info?.(`Pushing image ${imageRef}...`);
388
390
  return new Promise((resolve2, reject) => {
@@ -449,7 +451,7 @@ async function verifyImageExists(imageRef, logger) {
449
451
  let retries = 5;
450
452
  while (retries > 0) {
451
453
  try {
452
- await execAsync(`docker manifest inspect ${imageRef}`, {
454
+ await execFileAsync("docker", ["manifest", "inspect", imageRef], {
453
455
  maxBuffer: 10 * 1024 * 1024,
454
456
  timeout: 1e4
455
457
  // 10 second timeout
@@ -923,10 +925,10 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
923
925
  // src/client/common/registry/digest.ts
924
926
  var child_process3 = __toESM(require("child_process"), 1);
925
927
  var import_util3 = require("util");
926
- var execFileAsync = (0, import_util3.promisify)(child_process3.execFile);
928
+ var execFileAsync2 = (0, import_util3.promisify)(child_process3.execFile);
927
929
  async function getImageDigestAndName(imageRef) {
928
930
  try {
929
- const { stdout } = await execFileAsync(
931
+ const { stdout } = await execFileAsync2(
930
932
  "docker",
931
933
  ["manifest", "inspect", imageRef],
932
934
  { maxBuffer: 10 * 1024 * 1024 }
@@ -966,7 +968,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
966
968
  }
967
969
  async function extractDigestFromSinglePlatform(manifest, imageRef) {
968
970
  try {
969
- const { stdout } = await execFileAsync("docker", ["inspect", imageRef], {
971
+ const { stdout } = await execFileAsync2("docker", ["inspect", imageRef], {
970
972
  maxBuffer: 10 * 1024 * 1024
971
973
  });
972
974
  const inspectData = JSON.parse(stdout);
@@ -2525,7 +2527,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
2525
2527
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
2526
2528
  var CanUpdateAppProfilePermission = "0x036fef61";
2527
2529
  function getDefaultClientId() {
2528
- const version = true ? "0.1.1" : "0.0.0";
2530
+ const version = true ? "0.1.2-dev" : "0.0.0";
2529
2531
  return `ecloud-sdk/v${version}`;
2530
2532
  }
2531
2533
  var UserApiClient = class {
@@ -4423,20 +4425,20 @@ async function prepareDeployBatch(options, logger) {
4423
4425
  environmentConfig
4424
4426
  };
4425
4427
  }
4426
- async function executeDeployBatch(prepared, gas, logger) {
4428
+ async function executeDeployBatch(data, context, gas, logger) {
4427
4429
  const pendingMessage = "Deploying new app...";
4428
4430
  const txHash = await executeBatch(
4429
4431
  {
4430
- walletClient: prepared.walletClient,
4431
- publicClient: prepared.publicClient,
4432
- environmentConfig: prepared.environmentConfig,
4433
- executions: prepared.executions,
4432
+ walletClient: context.walletClient,
4433
+ publicClient: context.publicClient,
4434
+ environmentConfig: context.environmentConfig,
4435
+ executions: data.executions,
4434
4436
  pendingMessage,
4435
4437
  gas
4436
4438
  },
4437
4439
  logger
4438
4440
  );
4439
- return { appId: prepared.appId, txHash };
4441
+ return { appId: data.appId, txHash };
4440
4442
  }
4441
4443
  async function deployApp(options, logger) {
4442
4444
  const prepared = await prepareDeployBatch(
@@ -4450,7 +4452,17 @@ async function deployApp(options, logger) {
4450
4452
  },
4451
4453
  logger
4452
4454
  );
4453
- return executeDeployBatch(prepared, options.gas, logger);
4455
+ const data = {
4456
+ appId: prepared.appId,
4457
+ salt: prepared.salt,
4458
+ executions: prepared.executions
4459
+ };
4460
+ const context = {
4461
+ walletClient: prepared.walletClient,
4462
+ publicClient: prepared.publicClient,
4463
+ environmentConfig: prepared.environmentConfig
4464
+ };
4465
+ return executeDeployBatch(data, context, options.gas, logger);
4454
4466
  }
4455
4467
  async function prepareUpgradeBatch(options) {
4456
4468
  const {
@@ -4546,14 +4558,14 @@ async function prepareUpgradeBatch(options) {
4546
4558
  environmentConfig
4547
4559
  };
4548
4560
  }
4549
- async function executeUpgradeBatch(prepared, gas, logger) {
4550
- const pendingMessage = `Upgrading app ${prepared.appId}...`;
4561
+ async function executeUpgradeBatch(data, context, gas, logger) {
4562
+ const pendingMessage = `Upgrading app ${data.appId}...`;
4551
4563
  const txHash = await executeBatch(
4552
4564
  {
4553
- walletClient: prepared.walletClient,
4554
- publicClient: prepared.publicClient,
4555
- environmentConfig: prepared.environmentConfig,
4556
- executions: prepared.executions,
4565
+ walletClient: context.walletClient,
4566
+ publicClient: context.publicClient,
4567
+ environmentConfig: context.environmentConfig,
4568
+ executions: data.executions,
4557
4569
  pendingMessage,
4558
4570
  gas
4559
4571
  },
@@ -4571,7 +4583,16 @@ async function upgradeApp(options, logger) {
4571
4583
  publicLogs: options.publicLogs,
4572
4584
  needsPermissionChange: options.needsPermissionChange
4573
4585
  });
4574
- return executeUpgradeBatch(prepared, options.gas, logger);
4586
+ const data = {
4587
+ appId: prepared.appId,
4588
+ executions: prepared.executions
4589
+ };
4590
+ const context = {
4591
+ walletClient: prepared.walletClient,
4592
+ publicClient: prepared.publicClient,
4593
+ environmentConfig: prepared.environmentConfig
4594
+ };
4595
+ return executeUpgradeBatch(data, context, options.gas, logger);
4575
4596
  }
4576
4597
  async function sendAndWaitForTransaction(options, logger) {
4577
4598
  const {
@@ -5756,23 +5777,24 @@ async function prepareDeploy(options, logger = defaultLogger) {
5756
5777
  environmentConfig: batch.environmentConfig,
5757
5778
  executions: batch.executions
5758
5779
  });
5780
+ const data = {
5781
+ appId: batch.appId,
5782
+ salt: batch.salt,
5783
+ executions: batch.executions
5784
+ };
5759
5785
  return {
5760
5786
  prepared: {
5761
- batch,
5787
+ data,
5762
5788
  appName,
5763
- imageRef: finalImageRef,
5764
- preflightCtx: {
5765
- privateKey: preflightCtx.privateKey,
5766
- rpcUrl: preflightCtx.rpcUrl,
5767
- environmentConfig: preflightCtx.environmentConfig
5768
- }
5789
+ imageRef: finalImageRef
5769
5790
  },
5770
5791
  gasEstimate
5771
5792
  };
5772
5793
  }
5773
5794
  );
5774
5795
  }
5775
- async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetry) {
5796
+ async function executeDeploy(options) {
5797
+ const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5776
5798
  return withSDKTelemetry(
5777
5799
  {
5778
5800
  functionName: "executeDeploy",
@@ -5780,7 +5802,7 @@ async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetr
5780
5802
  },
5781
5803
  async () => {
5782
5804
  logger.info("Deploying on-chain...");
5783
- const { appId, txHash } = await executeDeployBatch(prepared.batch, gas, logger);
5805
+ const { appId, txHash } = await executeDeployBatch(prepared.data, context, gas, logger);
5784
5806
  return {
5785
5807
  appId,
5786
5808
  txHash,
@@ -6007,23 +6029,23 @@ async function prepareUpgrade(options, logger = defaultLogger) {
6007
6029
  environmentConfig: batch.environmentConfig,
6008
6030
  executions: batch.executions
6009
6031
  });
6032
+ const data = {
6033
+ appId: batch.appId,
6034
+ executions: batch.executions
6035
+ };
6010
6036
  return {
6011
6037
  prepared: {
6012
- batch,
6038
+ data,
6013
6039
  appId: appID,
6014
- imageRef: finalImageRef,
6015
- preflightCtx: {
6016
- privateKey: preflightCtx.privateKey,
6017
- rpcUrl: preflightCtx.rpcUrl,
6018
- environmentConfig: preflightCtx.environmentConfig
6019
- }
6040
+ imageRef: finalImageRef
6020
6041
  },
6021
6042
  gasEstimate
6022
6043
  };
6023
6044
  }
6024
6045
  );
6025
6046
  }
6026
- async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemetry) {
6047
+ async function executeUpgrade(options) {
6048
+ const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
6027
6049
  return withSDKTelemetry(
6028
6050
  {
6029
6051
  functionName: "executeUpgrade",
@@ -6031,7 +6053,7 @@ async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemet
6031
6053
  },
6032
6054
  async () => {
6033
6055
  logger.info("Upgrading on-chain...");
6034
- const txHash = await executeUpgradeBatch(prepared.batch, gas, logger);
6056
+ const txHash = await executeUpgradeBatch(prepared.data, context, gas, logger);
6035
6057
  return {
6036
6058
  appId: prepared.appId,
6037
6059
  imageRef: prepared.imageRef,
@@ -6162,8 +6184,8 @@ var path5 = __toESM(require("path"), 1);
6162
6184
  var os3 = __toESM(require("os"), 1);
6163
6185
  var import_child_process2 = require("child_process");
6164
6186
  var import_util4 = require("util");
6165
- var execAsync2 = (0, import_util4.promisify)(import_child_process2.exec);
6166
- var execFileAsync2 = (0, import_util4.promisify)(import_child_process2.execFile);
6187
+ var execAsync = (0, import_util4.promisify)(import_child_process2.exec);
6188
+ var execFileAsync3 = (0, import_util4.promisify)(import_child_process2.execFile);
6167
6189
  async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
6168
6190
  if (!repoURL) {
6169
6191
  throw new Error("repoURL is required");
@@ -6172,13 +6194,13 @@ async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
6172
6194
  Cloning repo: ${repoURL} \u2192 ${targetDir}
6173
6195
  `);
6174
6196
  try {
6175
- await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
6197
+ await execAsync(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
6176
6198
  maxBuffer: 10 * 1024 * 1024
6177
6199
  });
6178
- await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
6200
+ await execFileAsync3("git", ["-C", targetDir, "checkout", "--quiet", ref], {
6179
6201
  maxBuffer: 10 * 1024 * 1024
6180
6202
  });
6181
- await execFileAsync2(
6203
+ await execFileAsync3(
6182
6204
  "git",
6183
6205
  ["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
6184
6206
  { maxBuffer: 10 * 1024 * 1024 }
@@ -6223,14 +6245,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
6223
6245
  }
6224
6246
  async function cloneSparse(repoURL, ref, subPath, tempDir) {
6225
6247
  try {
6226
- await execFileAsync2("git", ["init", tempDir]);
6227
- await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
6228
- await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
6248
+ await execFileAsync3("git", ["init", tempDir]);
6249
+ await execFileAsync3("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
6250
+ await execFileAsync3("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
6229
6251
  const sparseCheckoutPath = path5.join(tempDir, ".git/info/sparse-checkout");
6230
6252
  fs5.writeFileSync(sparseCheckoutPath, `${subPath}
6231
6253
  `);
6232
- await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
6233
- await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
6254
+ await execFileAsync3("git", ["-C", tempDir, "fetch", "origin", ref]);
6255
+ await execFileAsync3("git", ["-C", tempDir, "checkout", ref]);
6234
6256
  } catch (error) {
6235
6257
  throw new Error(`Failed to clone sparse repository: ${error.message}`);
6236
6258
  }
@@ -6805,6 +6827,151 @@ function createAppModule(ctx) {
6805
6827
  imageRef: result.imageRef
6806
6828
  };
6807
6829
  },
6830
+ // Granular deploy control
6831
+ async prepareDeploy(opts) {
6832
+ return prepareDeploy(
6833
+ {
6834
+ privateKey,
6835
+ rpcUrl: ctx.rpcUrl,
6836
+ environment: ctx.environment,
6837
+ appName: opts.name,
6838
+ instanceType: opts.instanceType,
6839
+ dockerfilePath: opts.dockerfile,
6840
+ envFilePath: opts.envFile,
6841
+ imageRef: opts.imageRef,
6842
+ logVisibility: opts.logVisibility,
6843
+ resourceUsageMonitoring: opts.resourceUsageMonitoring,
6844
+ skipTelemetry
6845
+ },
6846
+ logger
6847
+ );
6848
+ },
6849
+ async executeDeploy(prepared, gas) {
6850
+ const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
6851
+ const chain = getChainFromID(environment.chainID);
6852
+ const publicClient = (0, import_viem9.createPublicClient)({
6853
+ chain,
6854
+ transport: (0, import_viem9.http)(ctx.rpcUrl)
6855
+ });
6856
+ const walletClient = (0, import_viem9.createWalletClient)({
6857
+ account,
6858
+ chain,
6859
+ transport: (0, import_viem9.http)(ctx.rpcUrl)
6860
+ });
6861
+ const result = await executeDeploy({
6862
+ prepared,
6863
+ context: {
6864
+ walletClient,
6865
+ publicClient,
6866
+ environmentConfig: environment
6867
+ },
6868
+ gas,
6869
+ logger,
6870
+ skipTelemetry
6871
+ });
6872
+ return {
6873
+ appId: result.appId,
6874
+ txHash: result.txHash,
6875
+ appName: result.appName,
6876
+ imageRef: result.imageRef
6877
+ };
6878
+ },
6879
+ async watchDeployment(appId) {
6880
+ return watchDeployment(
6881
+ appId,
6882
+ privateKey,
6883
+ ctx.rpcUrl,
6884
+ ctx.environment,
6885
+ logger,
6886
+ ctx.clientId,
6887
+ skipTelemetry
6888
+ );
6889
+ },
6890
+ // Granular upgrade control
6891
+ async prepareUpgrade(appId, opts) {
6892
+ return prepareUpgrade(
6893
+ {
6894
+ appId,
6895
+ privateKey,
6896
+ rpcUrl: ctx.rpcUrl,
6897
+ environment: ctx.environment,
6898
+ instanceType: opts.instanceType,
6899
+ dockerfilePath: opts.dockerfile,
6900
+ envFilePath: opts.envFile,
6901
+ imageRef: opts.imageRef,
6902
+ logVisibility: opts.logVisibility,
6903
+ resourceUsageMonitoring: opts.resourceUsageMonitoring,
6904
+ skipTelemetry
6905
+ },
6906
+ logger
6907
+ );
6908
+ },
6909
+ async executeUpgrade(prepared, gas) {
6910
+ const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
6911
+ const chain = getChainFromID(environment.chainID);
6912
+ const publicClient = (0, import_viem9.createPublicClient)({
6913
+ chain,
6914
+ transport: (0, import_viem9.http)(ctx.rpcUrl)
6915
+ });
6916
+ const walletClient = (0, import_viem9.createWalletClient)({
6917
+ account,
6918
+ chain,
6919
+ transport: (0, import_viem9.http)(ctx.rpcUrl)
6920
+ });
6921
+ const result = await executeUpgrade({
6922
+ prepared,
6923
+ context: {
6924
+ walletClient,
6925
+ publicClient,
6926
+ environmentConfig: environment
6927
+ },
6928
+ gas,
6929
+ logger,
6930
+ skipTelemetry
6931
+ });
6932
+ return {
6933
+ appId: result.appId,
6934
+ txHash: result.txHash,
6935
+ imageRef: result.imageRef
6936
+ };
6937
+ },
6938
+ async watchUpgrade(appId) {
6939
+ return watchUpgrade(
6940
+ appId,
6941
+ privateKey,
6942
+ ctx.rpcUrl,
6943
+ ctx.environment,
6944
+ logger,
6945
+ ctx.clientId,
6946
+ skipTelemetry
6947
+ );
6948
+ },
6949
+ // Profile management
6950
+ async setProfile(appId, profile) {
6951
+ return withSDKTelemetry(
6952
+ {
6953
+ functionName: "setProfile",
6954
+ skipTelemetry,
6955
+ properties: { environment: ctx.environment }
6956
+ },
6957
+ async () => {
6958
+ const userApiClient = new UserApiClient(
6959
+ environment,
6960
+ privateKey,
6961
+ ctx.rpcUrl,
6962
+ ctx.clientId
6963
+ );
6964
+ return userApiClient.uploadAppProfile(
6965
+ appId,
6966
+ profile.name,
6967
+ profile.website,
6968
+ profile.description,
6969
+ profile.xURL,
6970
+ profile.imagePath
6971
+ );
6972
+ }
6973
+ );
6974
+ },
6808
6975
  async logs(opts) {
6809
6976
  return logs(
6810
6977
  {
@@ -6955,10 +7122,10 @@ function createComputeModule(config) {
6955
7122
 
6956
7123
  // src/client/common/utils/billingapi.ts
6957
7124
  var import_axios2 = __toESM(require("axios"), 1);
6958
- var import_accounts5 = require("viem/accounts");
7125
+ var import_accounts6 = require("viem/accounts");
6959
7126
  var BillingApiClient = class {
6960
7127
  constructor(config, privateKey) {
6961
- this.account = (0, import_accounts5.privateKeyToAccount)(privateKey);
7128
+ this.account = (0, import_accounts6.privateKeyToAccount)(privateKey);
6962
7129
  this.config = config;
6963
7130
  }
6964
7131
  async createSubscription(productId = "compute") {
@@ -7028,7 +7195,7 @@ Please check:
7028
7195
 
7029
7196
  // src/client/common/auth/keyring.ts
7030
7197
  var import_keyring = require("@napi-rs/keyring");
7031
- var import_accounts6 = require("viem/accounts");
7198
+ var import_accounts7 = require("viem/accounts");
7032
7199
  var SERVICE_NAME = "ecloud";
7033
7200
  var ACCOUNT_NAME = "key";
7034
7201
  var EIGENX_SERVICE_NAME = "eigenx-cli";
@@ -7173,7 +7340,7 @@ function validatePrivateKey2(privateKey) {
7173
7340
  }
7174
7341
  function getAddressFromPrivateKey(privateKey) {
7175
7342
  const normalized = normalizePrivateKey(privateKey);
7176
- return (0, import_accounts6.privateKeyToAddress)(normalized);
7343
+ return (0, import_accounts7.privateKeyToAddress)(normalized);
7177
7344
  }
7178
7345
  function decodeGoKeyringValue(rawValue) {
7179
7346
  if (rawValue.startsWith(GO_KEYRING_BASE64_PREFIX)) {
@@ -7255,10 +7422,10 @@ async function requirePrivateKey(options) {
7255
7422
  }
7256
7423
 
7257
7424
  // src/client/common/auth/generate.ts
7258
- var import_accounts7 = require("viem/accounts");
7425
+ var import_accounts8 = require("viem/accounts");
7259
7426
  function generateNewPrivateKey() {
7260
- const privateKey = (0, import_accounts7.generatePrivateKey)();
7261
- const address = (0, import_accounts7.privateKeyToAddress)(privateKey);
7427
+ const privateKey = (0, import_accounts8.generatePrivateKey)();
7428
+ const address = (0, import_accounts8.privateKeyToAddress)(privateKey);
7262
7429
  return {
7263
7430
  privateKey,
7264
7431
  address