@layr-labs/ecloud-sdk 0.4.0-dev → 0.4.0-dev.0

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.js CHANGED
@@ -133,7 +133,10 @@ var init_session = __esm({
133
133
  });
134
134
 
135
135
  // src/client/modules/compute/app/index.ts
136
- import { parseAbi as parseAbi2, encodeFunctionData as encodeFunctionData3 } from "viem";
136
+ import {
137
+ parseAbi as parseAbi2,
138
+ encodeFunctionData as encodeFunctionData3
139
+ } from "viem";
137
140
 
138
141
  // src/client/common/docker/build.ts
139
142
  import * as child_process from "child_process";
@@ -2695,6 +2698,71 @@ var AppController_default = [
2695
2698
  ],
2696
2699
  stateMutability: "nonpayable"
2697
2700
  },
2701
+ {
2702
+ type: "function",
2703
+ name: "createAppWithIsolatedBilling",
2704
+ inputs: [
2705
+ {
2706
+ name: "salt",
2707
+ type: "bytes32",
2708
+ internalType: "bytes32"
2709
+ },
2710
+ {
2711
+ name: "release",
2712
+ type: "tuple",
2713
+ internalType: "structIAppController.Release",
2714
+ components: [
2715
+ {
2716
+ name: "rmsRelease",
2717
+ type: "tuple",
2718
+ internalType: "structIReleaseManagerTypes.Release",
2719
+ components: [
2720
+ {
2721
+ name: "artifacts",
2722
+ type: "tuple[]",
2723
+ internalType: "structIReleaseManagerTypes.Artifact[]",
2724
+ components: [
2725
+ {
2726
+ name: "digest",
2727
+ type: "bytes32",
2728
+ internalType: "bytes32"
2729
+ },
2730
+ {
2731
+ name: "registry",
2732
+ type: "string",
2733
+ internalType: "string"
2734
+ }
2735
+ ]
2736
+ },
2737
+ {
2738
+ name: "upgradeByTime",
2739
+ type: "uint32",
2740
+ internalType: "uint32"
2741
+ }
2742
+ ]
2743
+ },
2744
+ {
2745
+ name: "publicEnv",
2746
+ type: "bytes",
2747
+ internalType: "bytes"
2748
+ },
2749
+ {
2750
+ name: "encryptedEnv",
2751
+ type: "bytes",
2752
+ internalType: "bytes"
2753
+ }
2754
+ ]
2755
+ }
2756
+ ],
2757
+ outputs: [
2758
+ {
2759
+ name: "app",
2760
+ type: "address",
2761
+ internalType: "contractIApp"
2762
+ }
2763
+ ],
2764
+ stateMutability: "nonpayable"
2765
+ },
2698
2766
  {
2699
2767
  type: "function",
2700
2768
  name: "domainSeparator",
@@ -2727,6 +2795,25 @@ var AppController_default = [
2727
2795
  ],
2728
2796
  stateMutability: "view"
2729
2797
  },
2798
+ {
2799
+ type: "function",
2800
+ name: "getBillingType",
2801
+ inputs: [
2802
+ {
2803
+ name: "app",
2804
+ type: "address",
2805
+ internalType: "address"
2806
+ }
2807
+ ],
2808
+ outputs: [
2809
+ {
2810
+ name: "",
2811
+ type: "uint8",
2812
+ internalType: "uint8"
2813
+ }
2814
+ ],
2815
+ stateMutability: "view"
2816
+ },
2730
2817
  {
2731
2818
  type: "function",
2732
2819
  name: "getAppCreator",
@@ -2854,6 +2941,62 @@ var AppController_default = [
2854
2941
  ],
2855
2942
  stateMutability: "view"
2856
2943
  },
2944
+ {
2945
+ type: "function",
2946
+ name: "getAppsByBillingAccount",
2947
+ inputs: [
2948
+ {
2949
+ name: "account",
2950
+ type: "address",
2951
+ internalType: "address"
2952
+ },
2953
+ {
2954
+ name: "offset",
2955
+ type: "uint256",
2956
+ internalType: "uint256"
2957
+ },
2958
+ {
2959
+ name: "limit",
2960
+ type: "uint256",
2961
+ internalType: "uint256"
2962
+ }
2963
+ ],
2964
+ outputs: [
2965
+ {
2966
+ name: "apps",
2967
+ type: "address[]",
2968
+ internalType: "contractIApp[]"
2969
+ },
2970
+ {
2971
+ name: "appConfigsMem",
2972
+ type: "tuple[]",
2973
+ internalType: "structIAppController.AppConfig[]",
2974
+ components: [
2975
+ {
2976
+ name: "creator",
2977
+ type: "address",
2978
+ internalType: "address"
2979
+ },
2980
+ {
2981
+ name: "operatorSetId",
2982
+ type: "uint32",
2983
+ internalType: "uint32"
2984
+ },
2985
+ {
2986
+ name: "latestReleaseBlockNumber",
2987
+ type: "uint32",
2988
+ internalType: "uint32"
2989
+ },
2990
+ {
2991
+ name: "status",
2992
+ type: "uint8",
2993
+ internalType: "enumIAppController.AppStatus"
2994
+ }
2995
+ ]
2996
+ }
2997
+ ],
2998
+ stateMutability: "view"
2999
+ },
2857
3000
  {
2858
3001
  type: "function",
2859
3002
  name: "getAppsByCreator",
@@ -4109,9 +4252,10 @@ async function prepareDeployBatch(options, logger = noopLogger) {
4109
4252
  publicEnv: bytesToHex(release.publicEnv),
4110
4253
  encryptedEnv: bytesToHex(release.encryptedEnv)
4111
4254
  };
4255
+ const functionName = options.billTo === "app" ? "createAppWithIsolatedBilling" : "createApp";
4112
4256
  const createData = encodeFunctionData2({
4113
4257
  abi: AppController_default,
4114
- functionName: "createApp",
4258
+ functionName,
4115
4259
  args: [saltHex, releaseForViem]
4116
4260
  });
4117
4261
  const acceptAdminData = encodeFunctionData2({
@@ -4427,6 +4571,24 @@ async function getAppsByDeveloper(publicClient, environmentConfig, developer, of
4427
4571
  appConfigs: result[1]
4428
4572
  };
4429
4573
  }
4574
+ async function getBillingType(publicClient, environmentConfig, app) {
4575
+ const result = await publicClient.readContract({
4576
+ address: environmentConfig.appControllerAddress,
4577
+ abi: AppController_default,
4578
+ functionName: "getBillingType",
4579
+ args: [app]
4580
+ });
4581
+ return Number(result);
4582
+ }
4583
+ async function getAppsByBillingAccount(publicClient, environmentConfig, account, offset, limit) {
4584
+ const result = await publicClient.readContract({
4585
+ address: environmentConfig.appControllerAddress,
4586
+ abi: AppController_default,
4587
+ functionName: "getAppsByBillingAccount",
4588
+ args: [account, offset, limit]
4589
+ });
4590
+ return { apps: result[0], appConfigs: result[1] };
4591
+ }
4430
4592
  async function getAllAppsByDeveloper(publicClient, env, developer, pageSize = 100n) {
4431
4593
  let offset = 0n;
4432
4594
  const allApps = [];
@@ -4645,7 +4807,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4645
4807
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4646
4808
  var CanUpdateAppProfilePermission = "0x036fef61";
4647
4809
  function getDefaultClientId() {
4648
- const version = true ? "0.4.0-dev" : "0.0.0";
4810
+ const version = true ? "0.4.0-dev.0" : "0.0.0";
4649
4811
  return `ecloud-sdk/v${version}`;
4650
4812
  }
4651
4813
  var UserApiClient = class {
@@ -5425,7 +5587,8 @@ var ENVIRONMENTS = {
5425
5587
  erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
5426
5588
  kmsServerURL: "http://10.128.0.57:8080",
5427
5589
  userApiServerURL: "https://userapi-compute-sepolia-dev.eigencloud.xyz",
5428
- defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com"
5590
+ defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com",
5591
+ usdcCreditsAddress: "0xbdA3897c3A428763B59015C64AB766c288C97376"
5429
5592
  },
5430
5593
  sepolia: {
5431
5594
  name: "sepolia",
@@ -5975,7 +6138,7 @@ function getPostHogAPIKey() {
5975
6138
  if (process.env.ECLOUD_POSTHOG_KEY) {
5976
6139
  return process.env.ECLOUD_POSTHOG_KEY;
5977
6140
  }
5978
- return true ? "phc_BiKfywNft5iBI8N7MxmuVCkb4GGZj4mDFXYPmOPUAI8" : void 0;
6141
+ return typeof POSTHOG_API_KEY_BUILD_TIME !== "undefined" ? POSTHOG_API_KEY_BUILD_TIME : void 0;
5979
6142
  }
5980
6143
  function getPostHogEndpoint() {
5981
6144
  return process.env.ECLOUD_POSTHOG_ENDPOINT || "https://us.i.posthog.com";
@@ -6131,8 +6294,6 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
6131
6294
  },
6132
6295
  logger
6133
6296
  );
6134
- logger.debug("Checking quota availability...");
6135
- await checkQuotaAvailable(preflightCtx);
6136
6297
  const salt = generateRandomSalt();
6137
6298
  logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
6138
6299
  logger.debug("Calculating app ID...");
@@ -6145,6 +6306,13 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
6145
6306
  logger.info(``);
6146
6307
  logger.info(`App ID: ${appIDToBeDeployed}`);
6147
6308
  logger.info(``);
6309
+ if (!options.skipQuotaCheck) {
6310
+ logger.debug("Checking quota availability...");
6311
+ await checkQuotaAvailable(
6312
+ preflightCtx,
6313
+ options.billTo === "app" ? appIDToBeDeployed : void 0
6314
+ );
6315
+ }
6148
6316
  const release = await createReleaseFromImageDigest(
6149
6317
  {
6150
6318
  imageRef: options.imageRef,
@@ -6165,7 +6333,8 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
6165
6333
  salt,
6166
6334
  release,
6167
6335
  publicLogs,
6168
- imageRef: options.imageRef
6336
+ imageRef: options.imageRef,
6337
+ billTo: options.billTo
6169
6338
  },
6170
6339
  logger
6171
6340
  );
@@ -6246,8 +6415,6 @@ async function deploy(options, logger = defaultLogger) {
6246
6415
  },
6247
6416
  logger
6248
6417
  );
6249
- logger.debug("Checking quota availability...");
6250
- await checkQuotaAvailable(preflightCtx);
6251
6418
  logger.debug("Checking Docker...");
6252
6419
  await ensureDockerIsRunning();
6253
6420
  const dockerfilePath = options.dockerfilePath || "";
@@ -6267,6 +6434,13 @@ async function deploy(options, logger = defaultLogger) {
6267
6434
  logger.info(``);
6268
6435
  logger.info(`App ID: ${appIDToBeDeployed}`);
6269
6436
  logger.info(``);
6437
+ if (!options.skipQuotaCheck) {
6438
+ logger.debug("Checking quota availability...");
6439
+ await checkQuotaAvailable(
6440
+ preflightCtx,
6441
+ options.billTo === "app" ? appIDToBeDeployed : void 0
6442
+ );
6443
+ }
6270
6444
  logger.info("Preparing release...");
6271
6445
  const { release, finalImageRef } = await prepareRelease(
6272
6446
  {
@@ -6315,8 +6489,9 @@ async function deploy(options, logger = defaultLogger) {
6315
6489
  }
6316
6490
  );
6317
6491
  }
6318
- async function checkQuotaAvailable(preflightCtx) {
6319
- const { publicClient, environmentConfig, selfAddress: userAddress } = preflightCtx;
6492
+ async function checkQuotaAvailable(preflightCtx, quotaAddress) {
6493
+ const { publicClient, environmentConfig } = preflightCtx;
6494
+ const userAddress = quotaAddress || preflightCtx.selfAddress;
6320
6495
  let maxQuota;
6321
6496
  try {
6322
6497
  maxQuota = await getMaxActiveAppsPerUser(publicClient, environmentConfig, userAddress);
@@ -6367,8 +6542,6 @@ async function prepareDeploy(options, logger = defaultLogger) {
6367
6542
  },
6368
6543
  logger
6369
6544
  );
6370
- logger.debug("Checking quota availability...");
6371
- await checkQuotaAvailable(preflightCtx);
6372
6545
  logger.debug("Checking Docker...");
6373
6546
  await ensureDockerIsRunning();
6374
6547
  const dockerfilePath = options.dockerfilePath || "";
@@ -6376,8 +6549,8 @@ async function prepareDeploy(options, logger = defaultLogger) {
6376
6549
  const appName = options.appName;
6377
6550
  const envFilePath = options.envFilePath || "";
6378
6551
  const instanceType = options.instanceType;
6379
- const salt = generateRandomSalt();
6380
- logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
6552
+ const salt = options.salt ?? generateRandomSalt();
6553
+ logger.debug(`${options.salt ? "Using provided" : "Generated"} salt: ${Buffer.from(salt).toString("hex")}`);
6381
6554
  logger.debug("Calculating app ID...");
6382
6555
  const appIDToBeDeployed = await calculateAppID({
6383
6556
  publicClient: preflightCtx.publicClient,
@@ -6388,6 +6561,13 @@ async function prepareDeploy(options, logger = defaultLogger) {
6388
6561
  logger.info(``);
6389
6562
  logger.info(`App ID: ${appIDToBeDeployed}`);
6390
6563
  logger.info(``);
6564
+ if (!options.skipQuotaCheck) {
6565
+ logger.debug("Checking quota availability...");
6566
+ await checkQuotaAvailable(
6567
+ preflightCtx,
6568
+ options.billTo === "app" ? appIDToBeDeployed : void 0
6569
+ );
6570
+ }
6391
6571
  logger.info("Preparing release...");
6392
6572
  const { release, finalImageRef } = await prepareRelease(
6393
6573
  {
@@ -6411,7 +6591,8 @@ async function prepareDeploy(options, logger = defaultLogger) {
6411
6591
  salt,
6412
6592
  release,
6413
6593
  publicLogs,
6414
- imageRef: finalImageRef
6594
+ imageRef: finalImageRef,
6595
+ billTo: options.billTo
6415
6596
  },
6416
6597
  logger
6417
6598
  );
@@ -7573,6 +7754,9 @@ function createAppModule(ctx) {
7573
7754
  imageRef: opts.imageRef,
7574
7755
  logVisibility: opts.logVisibility,
7575
7756
  resourceUsageMonitoring: opts.resourceUsageMonitoring,
7757
+ billTo: opts.billTo,
7758
+ skipQuotaCheck: opts.skipQuotaCheck,
7759
+ salt: opts.salt,
7576
7760
  skipTelemetry
7577
7761
  },
7578
7762
  logger
@@ -7591,6 +7775,7 @@ function createAppModule(ctx) {
7591
7775
  imageDigest: opts.imageDigest,
7592
7776
  logVisibility: opts.logVisibility,
7593
7777
  resourceUsageMonitoring: opts.resourceUsageMonitoring,
7778
+ billTo: opts.billTo,
7594
7779
  skipTelemetry
7595
7780
  },
7596
7781
  logger
@@ -7818,6 +8003,12 @@ function createAppModule(ctx) {
7818
8003
  }
7819
8004
  );
7820
8005
  },
8006
+ async getBillingType(appId) {
8007
+ return getBillingType(publicClient, environment, appId);
8008
+ },
8009
+ async getAppsByBillingAccount(account2, offset, limit) {
8010
+ return getAppsByBillingAccount(publicClient, environment, account2, offset, limit);
8011
+ },
7821
8012
  async isDelegated() {
7822
8013
  return isDelegated({
7823
8014
  publicClient,
@@ -8716,6 +8907,95 @@ async function getCurrentInstanceType(preflightCtx, appID, logger, clientId) {
8716
8907
  }
8717
8908
  }
8718
8909
 
8910
+ // src/client/common/abis/USDCCredits.json
8911
+ var USDCCredits_default = [
8912
+ {
8913
+ type: "function",
8914
+ name: "purchaseCreditsFor",
8915
+ stateMutability: "nonpayable",
8916
+ inputs: [
8917
+ { name: "amount", type: "uint256" },
8918
+ { name: "account", type: "address" }
8919
+ ],
8920
+ outputs: []
8921
+ },
8922
+ {
8923
+ type: "function",
8924
+ name: "purchaseCredits",
8925
+ stateMutability: "nonpayable",
8926
+ inputs: [
8927
+ { name: "amount", type: "uint256" }
8928
+ ],
8929
+ outputs: []
8930
+ },
8931
+ {
8932
+ type: "function",
8933
+ name: "usdc",
8934
+ stateMutability: "view",
8935
+ inputs: [],
8936
+ outputs: [
8937
+ { name: "", type: "address" }
8938
+ ]
8939
+ },
8940
+ {
8941
+ type: "function",
8942
+ name: "minimumPurchase",
8943
+ stateMutability: "view",
8944
+ inputs: [],
8945
+ outputs: [
8946
+ { name: "", type: "uint256" }
8947
+ ]
8948
+ },
8949
+ {
8950
+ type: "event",
8951
+ name: "CreditsPurchased",
8952
+ inputs: [
8953
+ { name: "purchaser", type: "address", indexed: true },
8954
+ { name: "account", type: "address", indexed: true },
8955
+ { name: "amount", type: "uint256", indexed: false }
8956
+ ]
8957
+ }
8958
+ ];
8959
+
8960
+ // src/client/common/abis/ERC20.json
8961
+ var ERC20_default = [
8962
+ {
8963
+ type: "function",
8964
+ name: "approve",
8965
+ stateMutability: "nonpayable",
8966
+ inputs: [
8967
+ { name: "spender", type: "address" },
8968
+ { name: "amount", type: "uint256" }
8969
+ ],
8970
+ outputs: [
8971
+ { name: "", type: "bool" }
8972
+ ]
8973
+ },
8974
+ {
8975
+ type: "function",
8976
+ name: "balanceOf",
8977
+ stateMutability: "view",
8978
+ inputs: [
8979
+ { name: "account", type: "address" }
8980
+ ],
8981
+ outputs: [
8982
+ { name: "", type: "uint256" }
8983
+ ]
8984
+ },
8985
+ {
8986
+ type: "function",
8987
+ name: "allowance",
8988
+ stateMutability: "view",
8989
+ inputs: [
8990
+ { name: "owner", type: "address" },
8991
+ { name: "spender", type: "address" }
8992
+ ],
8993
+ outputs: [
8994
+ { name: "", type: "uint256" }
8995
+ ]
8996
+ }
8997
+ ];
8998
+
8719
8999
  // src/client/index.ts
8720
9000
  function createECloudClient(cfg) {
8721
9001
  cfg.privateKey = addHexPrefix(cfg.privateKey);
@@ -8761,6 +9041,7 @@ export {
8761
9041
  BuildError,
8762
9042
  BuildFailedError,
8763
9043
  ConflictError,
9044
+ ERC20_default as ERC20ABI,
8764
9045
  ForbiddenError,
8765
9046
  NoopClient,
8766
9047
  NotFoundError,
@@ -8768,6 +9049,7 @@ export {
8768
9049
  PostHogClient,
8769
9050
  SessionError,
8770
9051
  TimeoutError,
9052
+ USDCCredits_default as USDCCreditsABI,
8771
9053
  UserApiClient,
8772
9054
  addHexPrefix,
8773
9055
  addMetric,
@@ -8775,6 +9057,7 @@ export {
8775
9057
  assertValidFilePath,
8776
9058
  assertValidImageReference,
8777
9059
  assertValidPrivateKey,
9060
+ calculateAppID,
8778
9061
  checkERC7702Delegation,
8779
9062
  createApp,
8780
9063
  createAppEnvironment,
@@ -8804,9 +9087,11 @@ export {
8804
9087
  getAddressFromPrivateKey,
8805
9088
  getAllAppsByDeveloper,
8806
9089
  getAppLatestReleaseBlockNumbers,
9090
+ getAppsByBillingAccount,
8807
9091
  getAvailableEnvironments,
8808
9092
  getAvailableTemplates,
8809
9093
  getBillingEnvironmentConfig,
9094
+ getBillingType,
8810
9095
  getBlockTimestamps,
8811
9096
  getBuildType,
8812
9097
  getCategoryDescriptions,