@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.
@@ -1,3 +1,3 @@
1
- export { A as AppModule, j as AppModuleConfig, C as ComputeModule, d as ComputeModuleConfig, i as createAppModule, b as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, h as encodeTerminateAppData } from './compute-6WmcUluf.cjs';
1
+ export { A as AppModule, j as AppModuleConfig, C as ComputeModule, d as ComputeModuleConfig, i as createAppModule, b as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, h as encodeTerminateAppData } from './compute-DccJLbtV.cjs';
2
2
  import 'viem';
3
- import './index-WDunKGVL.cjs';
3
+ import './index-DD7ZLbqD.cjs';
package/dist/compute.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { A as AppModule, j as AppModuleConfig, C as ComputeModule, d as ComputeModuleConfig, i as createAppModule, b as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, h as encodeTerminateAppData } from './compute-D0TNHHmD.js';
1
+ export { A as AppModule, j as AppModuleConfig, C as ComputeModule, d as ComputeModuleConfig, i as createAppModule, b as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, h as encodeTerminateAppData } from './compute-DlilmZYC.js';
2
2
  import 'viem';
3
- import './index-WDunKGVL.js';
3
+ import './index-DD7ZLbqD.js';
package/dist/compute.js CHANGED
@@ -129,7 +129,10 @@ var init_session = __esm({
129
129
  });
130
130
 
131
131
  // src/client/modules/compute/app/index.ts
132
- import { parseAbi as parseAbi2, encodeFunctionData as encodeFunctionData3 } from "viem";
132
+ import {
133
+ parseAbi as parseAbi2,
134
+ encodeFunctionData as encodeFunctionData3
135
+ } from "viem";
133
136
 
134
137
  // src/client/common/docker/build.ts
135
138
  import * as child_process from "child_process";
@@ -2674,6 +2677,71 @@ var AppController_default = [
2674
2677
  ],
2675
2678
  stateMutability: "nonpayable"
2676
2679
  },
2680
+ {
2681
+ type: "function",
2682
+ name: "createAppWithIsolatedBilling",
2683
+ inputs: [
2684
+ {
2685
+ name: "salt",
2686
+ type: "bytes32",
2687
+ internalType: "bytes32"
2688
+ },
2689
+ {
2690
+ name: "release",
2691
+ type: "tuple",
2692
+ internalType: "structIAppController.Release",
2693
+ components: [
2694
+ {
2695
+ name: "rmsRelease",
2696
+ type: "tuple",
2697
+ internalType: "structIReleaseManagerTypes.Release",
2698
+ components: [
2699
+ {
2700
+ name: "artifacts",
2701
+ type: "tuple[]",
2702
+ internalType: "structIReleaseManagerTypes.Artifact[]",
2703
+ components: [
2704
+ {
2705
+ name: "digest",
2706
+ type: "bytes32",
2707
+ internalType: "bytes32"
2708
+ },
2709
+ {
2710
+ name: "registry",
2711
+ type: "string",
2712
+ internalType: "string"
2713
+ }
2714
+ ]
2715
+ },
2716
+ {
2717
+ name: "upgradeByTime",
2718
+ type: "uint32",
2719
+ internalType: "uint32"
2720
+ }
2721
+ ]
2722
+ },
2723
+ {
2724
+ name: "publicEnv",
2725
+ type: "bytes",
2726
+ internalType: "bytes"
2727
+ },
2728
+ {
2729
+ name: "encryptedEnv",
2730
+ type: "bytes",
2731
+ internalType: "bytes"
2732
+ }
2733
+ ]
2734
+ }
2735
+ ],
2736
+ outputs: [
2737
+ {
2738
+ name: "app",
2739
+ type: "address",
2740
+ internalType: "contractIApp"
2741
+ }
2742
+ ],
2743
+ stateMutability: "nonpayable"
2744
+ },
2677
2745
  {
2678
2746
  type: "function",
2679
2747
  name: "domainSeparator",
@@ -2706,6 +2774,25 @@ var AppController_default = [
2706
2774
  ],
2707
2775
  stateMutability: "view"
2708
2776
  },
2777
+ {
2778
+ type: "function",
2779
+ name: "getBillingType",
2780
+ inputs: [
2781
+ {
2782
+ name: "app",
2783
+ type: "address",
2784
+ internalType: "address"
2785
+ }
2786
+ ],
2787
+ outputs: [
2788
+ {
2789
+ name: "",
2790
+ type: "uint8",
2791
+ internalType: "uint8"
2792
+ }
2793
+ ],
2794
+ stateMutability: "view"
2795
+ },
2709
2796
  {
2710
2797
  type: "function",
2711
2798
  name: "getAppCreator",
@@ -2833,6 +2920,62 @@ var AppController_default = [
2833
2920
  ],
2834
2921
  stateMutability: "view"
2835
2922
  },
2923
+ {
2924
+ type: "function",
2925
+ name: "getAppsByBillingAccount",
2926
+ inputs: [
2927
+ {
2928
+ name: "account",
2929
+ type: "address",
2930
+ internalType: "address"
2931
+ },
2932
+ {
2933
+ name: "offset",
2934
+ type: "uint256",
2935
+ internalType: "uint256"
2936
+ },
2937
+ {
2938
+ name: "limit",
2939
+ type: "uint256",
2940
+ internalType: "uint256"
2941
+ }
2942
+ ],
2943
+ outputs: [
2944
+ {
2945
+ name: "apps",
2946
+ type: "address[]",
2947
+ internalType: "contractIApp[]"
2948
+ },
2949
+ {
2950
+ name: "appConfigsMem",
2951
+ type: "tuple[]",
2952
+ internalType: "structIAppController.AppConfig[]",
2953
+ components: [
2954
+ {
2955
+ name: "creator",
2956
+ type: "address",
2957
+ internalType: "address"
2958
+ },
2959
+ {
2960
+ name: "operatorSetId",
2961
+ type: "uint32",
2962
+ internalType: "uint32"
2963
+ },
2964
+ {
2965
+ name: "latestReleaseBlockNumber",
2966
+ type: "uint32",
2967
+ internalType: "uint32"
2968
+ },
2969
+ {
2970
+ name: "status",
2971
+ type: "uint8",
2972
+ internalType: "enumIAppController.AppStatus"
2973
+ }
2974
+ ]
2975
+ }
2976
+ ],
2977
+ stateMutability: "view"
2978
+ },
2836
2979
  {
2837
2980
  type: "function",
2838
2981
  name: "getAppsByCreator",
@@ -4067,9 +4210,10 @@ async function prepareDeployBatch(options, logger = noopLogger) {
4067
4210
  publicEnv: bytesToHex(release.publicEnv),
4068
4211
  encryptedEnv: bytesToHex(release.encryptedEnv)
4069
4212
  };
4213
+ const functionName = options.billTo === "app" ? "createAppWithIsolatedBilling" : "createApp";
4070
4214
  const createData = encodeFunctionData2({
4071
4215
  abi: AppController_default,
4072
- functionName: "createApp",
4216
+ functionName,
4073
4217
  args: [saltHex, releaseForViem]
4074
4218
  });
4075
4219
  const acceptAdminData = encodeFunctionData2({
@@ -4373,6 +4517,24 @@ async function getMaxActiveAppsPerUser(publicClient, environmentConfig, user) {
4373
4517
  });
4374
4518
  return Number(quota);
4375
4519
  }
4520
+ async function getBillingType(publicClient, environmentConfig, app) {
4521
+ const result = await publicClient.readContract({
4522
+ address: environmentConfig.appControllerAddress,
4523
+ abi: AppController_default,
4524
+ functionName: "getBillingType",
4525
+ args: [app]
4526
+ });
4527
+ return Number(result);
4528
+ }
4529
+ async function getAppsByBillingAccount(publicClient, environmentConfig, account, offset, limit) {
4530
+ const result = await publicClient.readContract({
4531
+ address: environmentConfig.appControllerAddress,
4532
+ abi: AppController_default,
4533
+ functionName: "getAppsByBillingAccount",
4534
+ args: [account, offset, limit]
4535
+ });
4536
+ return { apps: result[0], appConfigs: result[1] };
4537
+ }
4376
4538
  async function isDelegated(options) {
4377
4539
  const { publicClient, environmentConfig, address } = options;
4378
4540
  return checkERC7702Delegation(
@@ -4501,7 +4663,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4501
4663
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4502
4664
  var CanUpdateAppProfilePermission = "0x036fef61";
4503
4665
  function getDefaultClientId() {
4504
- const version = true ? "0.4.0-dev" : "0.0.0";
4666
+ const version = true ? "0.4.0-dev.0" : "0.0.0";
4505
4667
  return `ecloud-sdk/v${version}`;
4506
4668
  }
4507
4669
  var UserApiClient = class {
@@ -5062,7 +5224,8 @@ var ENVIRONMENTS = {
5062
5224
  erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
5063
5225
  kmsServerURL: "http://10.128.0.57:8080",
5064
5226
  userApiServerURL: "https://userapi-compute-sepolia-dev.eigencloud.xyz",
5065
- defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com"
5227
+ defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com",
5228
+ usdcCreditsAddress: "0xbdA3897c3A428763B59015C64AB766c288C97376"
5066
5229
  },
5067
5230
  sepolia: {
5068
5231
  name: "sepolia",
@@ -5250,7 +5413,7 @@ function getPostHogAPIKey() {
5250
5413
  if (process.env.ECLOUD_POSTHOG_KEY) {
5251
5414
  return process.env.ECLOUD_POSTHOG_KEY;
5252
5415
  }
5253
- return true ? "phc_BiKfywNft5iBI8N7MxmuVCkb4GGZj4mDFXYPmOPUAI8" : void 0;
5416
+ return typeof POSTHOG_API_KEY_BUILD_TIME !== "undefined" ? POSTHOG_API_KEY_BUILD_TIME : void 0;
5254
5417
  }
5255
5418
  function getPostHogEndpoint() {
5256
5419
  return process.env.ECLOUD_POSTHOG_ENDPOINT || "https://us.i.posthog.com";
@@ -5406,8 +5569,6 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
5406
5569
  },
5407
5570
  logger
5408
5571
  );
5409
- logger.debug("Checking quota availability...");
5410
- await checkQuotaAvailable(preflightCtx);
5411
5572
  const salt = generateRandomSalt();
5412
5573
  logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
5413
5574
  logger.debug("Calculating app ID...");
@@ -5420,6 +5581,13 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
5420
5581
  logger.info(``);
5421
5582
  logger.info(`App ID: ${appIDToBeDeployed}`);
5422
5583
  logger.info(``);
5584
+ if (!options.skipQuotaCheck) {
5585
+ logger.debug("Checking quota availability...");
5586
+ await checkQuotaAvailable(
5587
+ preflightCtx,
5588
+ options.billTo === "app" ? appIDToBeDeployed : void 0
5589
+ );
5590
+ }
5423
5591
  const release = await createReleaseFromImageDigest(
5424
5592
  {
5425
5593
  imageRef: options.imageRef,
@@ -5440,7 +5608,8 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
5440
5608
  salt,
5441
5609
  release,
5442
5610
  publicLogs,
5443
- imageRef: options.imageRef
5611
+ imageRef: options.imageRef,
5612
+ billTo: options.billTo
5444
5613
  },
5445
5614
  logger
5446
5615
  );
@@ -5521,8 +5690,6 @@ async function deploy(options, logger = defaultLogger) {
5521
5690
  },
5522
5691
  logger
5523
5692
  );
5524
- logger.debug("Checking quota availability...");
5525
- await checkQuotaAvailable(preflightCtx);
5526
5693
  logger.debug("Checking Docker...");
5527
5694
  await ensureDockerIsRunning();
5528
5695
  const dockerfilePath = options.dockerfilePath || "";
@@ -5542,6 +5709,13 @@ async function deploy(options, logger = defaultLogger) {
5542
5709
  logger.info(``);
5543
5710
  logger.info(`App ID: ${appIDToBeDeployed}`);
5544
5711
  logger.info(``);
5712
+ if (!options.skipQuotaCheck) {
5713
+ logger.debug("Checking quota availability...");
5714
+ await checkQuotaAvailable(
5715
+ preflightCtx,
5716
+ options.billTo === "app" ? appIDToBeDeployed : void 0
5717
+ );
5718
+ }
5545
5719
  logger.info("Preparing release...");
5546
5720
  const { release, finalImageRef } = await prepareRelease(
5547
5721
  {
@@ -5590,8 +5764,9 @@ async function deploy(options, logger = defaultLogger) {
5590
5764
  }
5591
5765
  );
5592
5766
  }
5593
- async function checkQuotaAvailable(preflightCtx) {
5594
- const { publicClient, environmentConfig, selfAddress: userAddress } = preflightCtx;
5767
+ async function checkQuotaAvailable(preflightCtx, quotaAddress) {
5768
+ const { publicClient, environmentConfig } = preflightCtx;
5769
+ const userAddress = quotaAddress || preflightCtx.selfAddress;
5595
5770
  let maxQuota;
5596
5771
  try {
5597
5772
  maxQuota = await getMaxActiveAppsPerUser(publicClient, environmentConfig, userAddress);
@@ -5642,8 +5817,6 @@ async function prepareDeploy(options, logger = defaultLogger) {
5642
5817
  },
5643
5818
  logger
5644
5819
  );
5645
- logger.debug("Checking quota availability...");
5646
- await checkQuotaAvailable(preflightCtx);
5647
5820
  logger.debug("Checking Docker...");
5648
5821
  await ensureDockerIsRunning();
5649
5822
  const dockerfilePath = options.dockerfilePath || "";
@@ -5651,8 +5824,8 @@ async function prepareDeploy(options, logger = defaultLogger) {
5651
5824
  const appName = options.appName;
5652
5825
  const envFilePath = options.envFilePath || "";
5653
5826
  const instanceType = options.instanceType;
5654
- const salt = generateRandomSalt();
5655
- logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
5827
+ const salt = options.salt ?? generateRandomSalt();
5828
+ logger.debug(`${options.salt ? "Using provided" : "Generated"} salt: ${Buffer.from(salt).toString("hex")}`);
5656
5829
  logger.debug("Calculating app ID...");
5657
5830
  const appIDToBeDeployed = await calculateAppID({
5658
5831
  publicClient: preflightCtx.publicClient,
@@ -5663,6 +5836,13 @@ async function prepareDeploy(options, logger = defaultLogger) {
5663
5836
  logger.info(``);
5664
5837
  logger.info(`App ID: ${appIDToBeDeployed}`);
5665
5838
  logger.info(``);
5839
+ if (!options.skipQuotaCheck) {
5840
+ logger.debug("Checking quota availability...");
5841
+ await checkQuotaAvailable(
5842
+ preflightCtx,
5843
+ options.billTo === "app" ? appIDToBeDeployed : void 0
5844
+ );
5845
+ }
5666
5846
  logger.info("Preparing release...");
5667
5847
  const { release, finalImageRef } = await prepareRelease(
5668
5848
  {
@@ -5686,7 +5866,8 @@ async function prepareDeploy(options, logger = defaultLogger) {
5686
5866
  salt,
5687
5867
  release,
5688
5868
  publicLogs,
5689
- imageRef: finalImageRef
5869
+ imageRef: finalImageRef,
5870
+ billTo: options.billTo
5690
5871
  },
5691
5872
  logger
5692
5873
  );
@@ -6848,6 +7029,9 @@ function createAppModule(ctx) {
6848
7029
  imageRef: opts.imageRef,
6849
7030
  logVisibility: opts.logVisibility,
6850
7031
  resourceUsageMonitoring: opts.resourceUsageMonitoring,
7032
+ billTo: opts.billTo,
7033
+ skipQuotaCheck: opts.skipQuotaCheck,
7034
+ salt: opts.salt,
6851
7035
  skipTelemetry
6852
7036
  },
6853
7037
  logger
@@ -6866,6 +7050,7 @@ function createAppModule(ctx) {
6866
7050
  imageDigest: opts.imageDigest,
6867
7051
  logVisibility: opts.logVisibility,
6868
7052
  resourceUsageMonitoring: opts.resourceUsageMonitoring,
7053
+ billTo: opts.billTo,
6869
7054
  skipTelemetry
6870
7055
  },
6871
7056
  logger
@@ -7093,6 +7278,12 @@ function createAppModule(ctx) {
7093
7278
  }
7094
7279
  );
7095
7280
  },
7281
+ async getBillingType(appId) {
7282
+ return getBillingType(publicClient, environment, appId);
7283
+ },
7284
+ async getAppsByBillingAccount(account2, offset, limit) {
7285
+ return getAppsByBillingAccount(publicClient, environment, account2, offset, limit);
7286
+ },
7096
7287
  async isDelegated() {
7097
7288
  return isDelegated({
7098
7289
  publicClient,