@layr-labs/ecloud-sdk 1.0.0-dev.1 → 1.0.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.
@@ -1,4 +1,4 @@
1
- import { E as EnvironmentConfig, a7 as SubscriptionStatus, f as BillingEnvironmentConfig, $ as ProductID, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, z as GetSubscriptionOptions, a0 as ProductSubscriptionResponse, M as PaymentMethodsResponse, m as CreditPurchaseResponse, G as GasEstimate, H as Logger } from './index-BbH7ZCIu.js';
1
+ import { E as EnvironmentConfig, a4 as SubscriptionStatus, f as BillingEnvironmentConfig, Y as ProductID, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, y as GetSubscriptionOptions, Z as ProductSubscriptionResponse, G as GasEstimate, F as Logger } from './index-U2vKBrry.cjs';
2
2
  import { Address, Hex, WalletClient, PublicClient, SignAuthorizationReturnType, Chain } from 'viem';
3
3
 
4
4
  /**
@@ -733,8 +733,6 @@ interface BillingApiClientOptions {
733
733
  * When false (default), uses EIP-712 typed data signatures for each request.
734
734
  */
735
735
  useSession?: boolean;
736
- /** Log request/response details to stderr */
737
- verbose?: boolean;
738
736
  }
739
737
  /**
740
738
  * BillingAPI Client for managing product subscriptions.
@@ -798,8 +796,6 @@ declare class BillingApiClient {
798
796
  createSubscription(productId?: ProductID, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
799
797
  getSubscription(productId?: ProductID, options?: GetSubscriptionOptions): Promise<ProductSubscriptionResponse>;
800
798
  cancelSubscription(productId?: ProductID): Promise<void>;
801
- getPaymentMethods(): Promise<PaymentMethodsResponse>;
802
- purchaseCredits(amountCents: number, paymentMethodId?: string): Promise<CreditPurchaseResponse>;
803
799
  /**
804
800
  * Make an authenticated request to the billing API
805
801
  *
@@ -1,4 +1,4 @@
1
- import { E as EnvironmentConfig, a7 as SubscriptionStatus, f as BillingEnvironmentConfig, $ as ProductID, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, z as GetSubscriptionOptions, a0 as ProductSubscriptionResponse, M as PaymentMethodsResponse, m as CreditPurchaseResponse, G as GasEstimate, H as Logger } from './index-BbH7ZCIu.cjs';
1
+ import { E as EnvironmentConfig, a4 as SubscriptionStatus, f as BillingEnvironmentConfig, Y as ProductID, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, y as GetSubscriptionOptions, Z as ProductSubscriptionResponse, G as GasEstimate, F as Logger } from './index-U2vKBrry.js';
2
2
  import { Address, Hex, WalletClient, PublicClient, SignAuthorizationReturnType, Chain } from 'viem';
3
3
 
4
4
  /**
@@ -733,8 +733,6 @@ interface BillingApiClientOptions {
733
733
  * When false (default), uses EIP-712 typed data signatures for each request.
734
734
  */
735
735
  useSession?: boolean;
736
- /** Log request/response details to stderr */
737
- verbose?: boolean;
738
736
  }
739
737
  /**
740
738
  * BillingAPI Client for managing product subscriptions.
@@ -798,8 +796,6 @@ declare class BillingApiClient {
798
796
  createSubscription(productId?: ProductID, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
799
797
  getSubscription(productId?: ProductID, options?: GetSubscriptionOptions): Promise<ProductSubscriptionResponse>;
800
798
  cancelSubscription(productId?: ProductID): Promise<void>;
801
- getPaymentMethods(): Promise<PaymentMethodsResponse>;
802
- purchaseCredits(amountCents: number, paymentMethodId?: string): Promise<CreditPurchaseResponse>;
803
799
  /**
804
800
  * Make an authenticated request to the billing API
805
801
  *
@@ -749,20 +749,6 @@ interface SubscriptionOpts {
749
749
  /** URL to redirect to if checkout is canceled */
750
750
  cancelUrl?: string;
751
751
  }
752
- interface PaymentMethod {
753
- id: string;
754
- stripePaymentMethodId: string;
755
- createdAt: string;
756
- }
757
- interface PaymentMethodsResponse {
758
- paymentMethods: PaymentMethod[];
759
- }
760
- interface CreditPurchaseResponse {
761
- purchaseId?: string;
762
- checkoutSessionId?: string;
763
- checkoutUrl?: string;
764
- amountCents: string;
765
- }
766
752
  interface BillingEnvironmentConfig {
767
753
  billingApiServerURL: string;
768
754
  }
@@ -790,4 +776,4 @@ interface SequentialDeployResult {
790
776
  };
791
777
  }
792
778
 
793
- export { type ProductID as $, type AppId as A, type BatchedDeployResult as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EnvironmentConfig as E, type IsDelegatedOptions as F, type GasEstimate as G, type Logger as H, type ImageDigestResult as I, type PaymentIssueResponse as J, type PaymentMethod as K, type LifecycleOpts as L, type PaymentMethodsResponse as M, type NoActiveSubscriptionResponse as N, type PrepareDeployBatchOptions as O, type ParsedEnvironment as P, type PrepareDeployFromVerifiableBuildOpts as Q, type PrepareDeployOpts as R, type PrepareUpgradeBatchOptions as S, type PrepareUpgradeFromVerifiableBuildOpts as T, type PrepareUpgradeOpts as U, type PreparedDeploy as V, type PreparedDeployBatch as W, type PreparedDeployData as X, type PreparedUpgrade as Y, type PreparedUpgradeBatch as Z, type PreparedUpgradeData as _, type AlreadyActiveResponse as a, type ProductSubscriptionResponse as a0, type Release as a1, type SendTransactionOptions as a2, type SequentialDeployResult as a3, type SubscribeResponse as a4, type SubscriptionLineItem as a5, type SubscriptionOpts as a6, type SubscriptionStatus as a7, type SuspendOptions as a8, type UndelegateOptions as a9, undelegate as aA, upgradeApp as aB, getAppLatestReleaseBlockNumbers as aC, getBlockTimestamps as aD, type UpgradeAppOptions as aa, type UpgradeAppOpts as ab, calculateAppID as ac, deployApp as ad, estimateTransactionGas as ae, executeDeployBatch as af, executeDeployBatched as ag, executeDeploySequential as ah, executeUpgradeBatch as ai, formatETH as aj, getActiveAppCount as ak, getAllAppsByDeveloper as al, getAppsByBillingAccount as am, getAppsByCreator as an, getAppsByDeveloper as ao, getBillingType as ap, getMaxActiveAppsPerUser as aq, isDelegated as ar, type logVisibility as as, noopLogger as at, prepareDeployBatch as au, prepareUpgradeBatch as av, sendAndWaitForTransaction as aw, supportsEIP5792 as ax, supportsEIP7702 as ay, suspend as az, type AppConfig as b, type AppProfile as c, type AppProfileResponse as d, type AppRecord as e, type BillingEnvironmentConfig as f, type CancelResponse as g, type CancelSuccessResponse as h, type ChainID as i, type CheckoutCreatedResponse as j, type CreateSubscriptionOptions as k, type CreateSubscriptionResponse as l, type CreditPurchaseResponse as m, type DeployAppOpts as n, type DeployOptions as o, type DeployProgressCallback as p, type DeployResult as q, type DeployStep as r, type DockerImageConfig as s, type EstimateGasOptions as t, type ExecuteDeployBatchedOptions as u, type ExecuteDeployResult as v, type ExecuteDeploySequentialOptions as w, type ExecuteUpgradeResult as x, type GasOpts as y, type GetSubscriptionOptions as z };
779
+ export { type SendTransactionOptions as $, type AppId as A, type BatchedDeployResult as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EnvironmentConfig as E, type Logger as F, type GasEstimate as G, type PaymentIssueResponse as H, type ImageDigestResult as I, type PrepareDeployBatchOptions as J, type PrepareDeployFromVerifiableBuildOpts as K, type LifecycleOpts as L, type PrepareDeployOpts as M, type NoActiveSubscriptionResponse as N, type PrepareUpgradeBatchOptions as O, type ParsedEnvironment as P, type PrepareUpgradeFromVerifiableBuildOpts as Q, type PrepareUpgradeOpts as R, type PreparedDeploy as S, type PreparedDeployBatch as T, type PreparedDeployData as U, type PreparedUpgrade as V, type PreparedUpgradeBatch as W, type PreparedUpgradeData as X, type ProductID as Y, type ProductSubscriptionResponse as Z, type Release as _, type AlreadyActiveResponse as a, type SequentialDeployResult as a0, type SubscribeResponse as a1, type SubscriptionLineItem as a2, type SubscriptionOpts as a3, type SubscriptionStatus as a4, type SuspendOptions as a5, type UndelegateOptions as a6, type UpgradeAppOptions as a7, type UpgradeAppOpts as a8, calculateAppID as a9, getBlockTimestamps as aA, deployApp as aa, estimateTransactionGas as ab, executeDeployBatch as ac, executeDeployBatched as ad, executeDeploySequential as ae, executeUpgradeBatch as af, formatETH as ag, getActiveAppCount as ah, getAllAppsByDeveloper as ai, getAppsByBillingAccount as aj, getAppsByCreator as ak, getAppsByDeveloper as al, getBillingType as am, getMaxActiveAppsPerUser as an, isDelegated as ao, type logVisibility as ap, noopLogger as aq, prepareDeployBatch as ar, prepareUpgradeBatch as as, sendAndWaitForTransaction as at, supportsEIP5792 as au, supportsEIP7702 as av, suspend as aw, undelegate as ax, upgradeApp as ay, getAppLatestReleaseBlockNumbers as az, type AppConfig as b, type AppProfile as c, type AppProfileResponse as d, type AppRecord as e, type BillingEnvironmentConfig as f, type CancelResponse as g, type CancelSuccessResponse as h, type ChainID as i, type CheckoutCreatedResponse as j, type CreateSubscriptionOptions as k, type CreateSubscriptionResponse as l, type DeployAppOpts as m, type DeployOptions as n, type DeployProgressCallback as o, type DeployResult as p, type DeployStep as q, type DockerImageConfig as r, type EstimateGasOptions as s, type ExecuteDeployBatchedOptions as t, type ExecuteDeployResult as u, type ExecuteDeploySequentialOptions as v, type ExecuteUpgradeResult as w, type GasOpts as x, type GetSubscriptionOptions as y, type IsDelegatedOptions as z };
@@ -749,20 +749,6 @@ interface SubscriptionOpts {
749
749
  /** URL to redirect to if checkout is canceled */
750
750
  cancelUrl?: string;
751
751
  }
752
- interface PaymentMethod {
753
- id: string;
754
- stripePaymentMethodId: string;
755
- createdAt: string;
756
- }
757
- interface PaymentMethodsResponse {
758
- paymentMethods: PaymentMethod[];
759
- }
760
- interface CreditPurchaseResponse {
761
- purchaseId?: string;
762
- checkoutSessionId?: string;
763
- checkoutUrl?: string;
764
- amountCents: string;
765
- }
766
752
  interface BillingEnvironmentConfig {
767
753
  billingApiServerURL: string;
768
754
  }
@@ -790,4 +776,4 @@ interface SequentialDeployResult {
790
776
  };
791
777
  }
792
778
 
793
- export { type ProductID as $, type AppId as A, type BatchedDeployResult as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EnvironmentConfig as E, type IsDelegatedOptions as F, type GasEstimate as G, type Logger as H, type ImageDigestResult as I, type PaymentIssueResponse as J, type PaymentMethod as K, type LifecycleOpts as L, type PaymentMethodsResponse as M, type NoActiveSubscriptionResponse as N, type PrepareDeployBatchOptions as O, type ParsedEnvironment as P, type PrepareDeployFromVerifiableBuildOpts as Q, type PrepareDeployOpts as R, type PrepareUpgradeBatchOptions as S, type PrepareUpgradeFromVerifiableBuildOpts as T, type PrepareUpgradeOpts as U, type PreparedDeploy as V, type PreparedDeployBatch as W, type PreparedDeployData as X, type PreparedUpgrade as Y, type PreparedUpgradeBatch as Z, type PreparedUpgradeData as _, type AlreadyActiveResponse as a, type ProductSubscriptionResponse as a0, type Release as a1, type SendTransactionOptions as a2, type SequentialDeployResult as a3, type SubscribeResponse as a4, type SubscriptionLineItem as a5, type SubscriptionOpts as a6, type SubscriptionStatus as a7, type SuspendOptions as a8, type UndelegateOptions as a9, undelegate as aA, upgradeApp as aB, getAppLatestReleaseBlockNumbers as aC, getBlockTimestamps as aD, type UpgradeAppOptions as aa, type UpgradeAppOpts as ab, calculateAppID as ac, deployApp as ad, estimateTransactionGas as ae, executeDeployBatch as af, executeDeployBatched as ag, executeDeploySequential as ah, executeUpgradeBatch as ai, formatETH as aj, getActiveAppCount as ak, getAllAppsByDeveloper as al, getAppsByBillingAccount as am, getAppsByCreator as an, getAppsByDeveloper as ao, getBillingType as ap, getMaxActiveAppsPerUser as aq, isDelegated as ar, type logVisibility as as, noopLogger as at, prepareDeployBatch as au, prepareUpgradeBatch as av, sendAndWaitForTransaction as aw, supportsEIP5792 as ax, supportsEIP7702 as ay, suspend as az, type AppConfig as b, type AppProfile as c, type AppProfileResponse as d, type AppRecord as e, type BillingEnvironmentConfig as f, type CancelResponse as g, type CancelSuccessResponse as h, type ChainID as i, type CheckoutCreatedResponse as j, type CreateSubscriptionOptions as k, type CreateSubscriptionResponse as l, type CreditPurchaseResponse as m, type DeployAppOpts as n, type DeployOptions as o, type DeployProgressCallback as p, type DeployResult as q, type DeployStep as r, type DockerImageConfig as s, type EstimateGasOptions as t, type ExecuteDeployBatchedOptions as u, type ExecuteDeployResult as v, type ExecuteDeploySequentialOptions as w, type ExecuteUpgradeResult as x, type GasOpts as y, type GetSubscriptionOptions as z };
779
+ export { type SendTransactionOptions as $, type AppId as A, type BatchedDeployResult as B, type CalculateAppIDOptions as C, type DeployAppOptions as D, type EnvironmentConfig as E, type Logger as F, type GasEstimate as G, type PaymentIssueResponse as H, type ImageDigestResult as I, type PrepareDeployBatchOptions as J, type PrepareDeployFromVerifiableBuildOpts as K, type LifecycleOpts as L, type PrepareDeployOpts as M, type NoActiveSubscriptionResponse as N, type PrepareUpgradeBatchOptions as O, type ParsedEnvironment as P, type PrepareUpgradeFromVerifiableBuildOpts as Q, type PrepareUpgradeOpts as R, type PreparedDeploy as S, type PreparedDeployBatch as T, type PreparedDeployData as U, type PreparedUpgrade as V, type PreparedUpgradeBatch as W, type PreparedUpgradeData as X, type ProductID as Y, type ProductSubscriptionResponse as Z, type Release as _, type AlreadyActiveResponse as a, type SequentialDeployResult as a0, type SubscribeResponse as a1, type SubscriptionLineItem as a2, type SubscriptionOpts as a3, type SubscriptionStatus as a4, type SuspendOptions as a5, type UndelegateOptions as a6, type UpgradeAppOptions as a7, type UpgradeAppOpts as a8, calculateAppID as a9, getBlockTimestamps as aA, deployApp as aa, estimateTransactionGas as ab, executeDeployBatch as ac, executeDeployBatched as ad, executeDeploySequential as ae, executeUpgradeBatch as af, formatETH as ag, getActiveAppCount as ah, getAllAppsByDeveloper as ai, getAppsByBillingAccount as aj, getAppsByCreator as ak, getAppsByDeveloper as al, getBillingType as am, getMaxActiveAppsPerUser as an, isDelegated as ao, type logVisibility as ap, noopLogger as aq, prepareDeployBatch as ar, prepareUpgradeBatch as as, sendAndWaitForTransaction as at, supportsEIP5792 as au, supportsEIP7702 as av, suspend as aw, undelegate as ax, upgradeApp as ay, getAppLatestReleaseBlockNumbers as az, type AppConfig as b, type AppProfile as c, type AppProfileResponse as d, type AppRecord as e, type BillingEnvironmentConfig as f, type CancelResponse as g, type CancelSuccessResponse as h, type ChainID as i, type CheckoutCreatedResponse as j, type CreateSubscriptionOptions as k, type CreateSubscriptionResponse as l, type DeployAppOpts as m, type DeployOptions as n, type DeployProgressCallback as o, type DeployResult as p, type DeployStep as q, type DockerImageConfig as r, type EstimateGasOptions as s, type ExecuteDeployBatchedOptions as t, type ExecuteDeployResult as u, type ExecuteDeploySequentialOptions as v, type ExecuteUpgradeResult as w, type GasOpts as x, type GetSubscriptionOptions as y, type IsDelegatedOptions as z };
package/dist/index.cjs CHANGED
@@ -4986,7 +4986,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4986
4986
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4987
4987
  var CanUpdateAppProfilePermission = "0x036fef61";
4988
4988
  function getDefaultClientId() {
4989
- const version = true ? "1.0.0-dev.1" : "0.0.0";
4989
+ const version = true ? "1.0.0-dev.2" : "0.0.0";
4990
4990
  return `ecloud-sdk/v${version}`;
4991
4991
  }
4992
4992
  var UserApiClient = class {
@@ -5804,6 +5804,12 @@ var CHAIN_ID_TO_ENVIRONMENT = {
5804
5804
  [SEPOLIA_CHAIN_ID.toString()]: "sepolia",
5805
5805
  [MAINNET_CHAIN_ID.toString()]: "mainnet-alpha"
5806
5806
  };
5807
+ function getApiUrlOverride() {
5808
+ const raw = process.env.ECLOUD_API_URL;
5809
+ if (!raw) return void 0;
5810
+ const trimmed = raw.trim().replace(/\/+$/, "");
5811
+ return trimmed.length > 0 ? trimmed : void 0;
5812
+ }
5807
5813
  function getEnvironmentConfig(environment, chainID) {
5808
5814
  const env = ENVIRONMENTS[environment];
5809
5815
  if (!env) {
@@ -5821,15 +5827,11 @@ function getEnvironmentConfig(environment, chainID) {
5821
5827
  }
5822
5828
  }
5823
5829
  const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
5830
+ const apiUrlOverride = getApiUrlOverride();
5824
5831
  return {
5825
5832
  ...env,
5826
5833
  chainID: BigInt(resolvedChainID),
5827
- ...process.env.ECLOUD_USER_API_URL && {
5828
- userApiServerURL: process.env.ECLOUD_USER_API_URL
5829
- },
5830
- ...process.env.ECLOUD_RPC_URL && {
5831
- defaultRPCURL: process.env.ECLOUD_RPC_URL
5832
- }
5834
+ ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
5833
5835
  };
5834
5836
  }
5835
5837
  function getBillingEnvironmentConfig(build) {
@@ -5837,12 +5839,11 @@ function getBillingEnvironmentConfig(build) {
5837
5839
  if (!config) {
5838
5840
  throw new Error(`Unknown billing environment: ${build}`);
5839
5841
  }
5840
- return {
5841
- ...config,
5842
- ...process.env.ECLOUD_BILLING_API_URL && {
5843
- billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
5844
- }
5845
- };
5842
+ const apiUrlOverride = getApiUrlOverride();
5843
+ if (apiUrlOverride) {
5844
+ return { billingApiServerURL: apiUrlOverride };
5845
+ }
5846
+ return config;
5846
5847
  }
5847
5848
  function getBuildType() {
5848
5849
  const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
@@ -6147,20 +6148,6 @@ var BillingApiClient = class {
6147
6148
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
6148
6149
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
6149
6150
  }
6150
- async getPaymentMethods() {
6151
- const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
6152
- const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
6153
- return resp.json();
6154
- }
6155
- async purchaseCredits(amountCents, paymentMethodId) {
6156
- const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
6157
- const body = { amountCents };
6158
- if (paymentMethodId) {
6159
- body.paymentMethodId = paymentMethodId;
6160
- }
6161
- const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
6162
- return resp.json();
6163
- }
6164
6151
  // ==========================================================================
6165
6152
  // Internal Methods
6166
6153
  // ==========================================================================
@@ -6170,19 +6157,10 @@ var BillingApiClient = class {
6170
6157
  * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
6171
6158
  */
6172
6159
  async makeAuthenticatedRequest(url, method, productId, body) {
6173
- if (this.options.verbose) {
6174
- console.debug(`[BillingAPI] ${method} ${url}`);
6175
- }
6176
- const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
6177
- if (this.options.verbose) {
6178
- const data = await resp.json();
6179
- console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
6180
- return {
6181
- json: async () => data,
6182
- text: async () => JSON.stringify(data)
6183
- };
6160
+ if (this.useSession) {
6161
+ return this.makeSessionAuthenticatedRequest(url, method, body);
6184
6162
  }
6185
- return resp;
6163
+ return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
6186
6164
  }
6187
6165
  /**
6188
6166
  * Make a request using session-based authentication (cookies)
@@ -8371,7 +8349,7 @@ function createBillingModule(config) {
8371
8349
  const address = walletClient.account.address;
8372
8350
  const logger = getLogger(verbose);
8373
8351
  const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
8374
- const billingApi = new BillingApiClient(billingEnvConfig, walletClient, { verbose });
8352
+ const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
8375
8353
  const environmentConfig = getEnvironmentConfig(environment);
8376
8354
  const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
8377
8355
  if (!usdcCreditsAddress) {
@@ -8535,12 +8513,6 @@ function createBillingModule(config) {
8535
8513
  };
8536
8514
  }
8537
8515
  );
8538
- },
8539
- async getPaymentMethods() {
8540
- return billingApi.getPaymentMethods();
8541
- },
8542
- async purchaseCredits(amountCents, paymentMethodId) {
8543
- return billingApi.purchaseCredits(amountCents, paymentMethodId);
8544
8516
  }
8545
8517
  };
8546
8518
  return module2;