@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.
package/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- version=1.0.0-dev.1
2
- commit=2f1f9686f28371adcd7521bfd335c15cd928f61d
1
+ version=1.0.0-dev.2
2
+ commit=44b22091b826ce951383ff8a7fb2136c010abb56
package/dist/billing.cjs CHANGED
@@ -317,20 +317,6 @@ var BillingApiClient = class {
317
317
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
318
318
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
319
319
  }
320
- async getPaymentMethods() {
321
- const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
322
- const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
323
- return resp.json();
324
- }
325
- async purchaseCredits(amountCents, paymentMethodId) {
326
- const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
327
- const body = { amountCents };
328
- if (paymentMethodId) {
329
- body.paymentMethodId = paymentMethodId;
330
- }
331
- const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
332
- return resp.json();
333
- }
334
320
  // ==========================================================================
335
321
  // Internal Methods
336
322
  // ==========================================================================
@@ -340,19 +326,10 @@ var BillingApiClient = class {
340
326
  * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
341
327
  */
342
328
  async makeAuthenticatedRequest(url, method, productId, body) {
343
- if (this.options.verbose) {
344
- console.debug(`[BillingAPI] ${method} ${url}`);
329
+ if (this.useSession) {
330
+ return this.makeSessionAuthenticatedRequest(url, method, body);
345
331
  }
346
- const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
347
- if (this.options.verbose) {
348
- const data = await resp.json();
349
- console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
350
- return {
351
- json: async () => data,
352
- text: async () => JSON.stringify(data)
353
- };
354
- }
355
- return resp;
332
+ return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
356
333
  }
357
334
  /**
358
335
  * Make a request using session-based authentication (cookies)
@@ -519,6 +496,12 @@ var CHAIN_ID_TO_ENVIRONMENT = {
519
496
  [SEPOLIA_CHAIN_ID.toString()]: "sepolia",
520
497
  [MAINNET_CHAIN_ID.toString()]: "mainnet-alpha"
521
498
  };
499
+ function getApiUrlOverride() {
500
+ const raw = process.env.ECLOUD_API_URL;
501
+ if (!raw) return void 0;
502
+ const trimmed = raw.trim().replace(/\/+$/, "");
503
+ return trimmed.length > 0 ? trimmed : void 0;
504
+ }
522
505
  function getEnvironmentConfig(environment, chainID) {
523
506
  const env = ENVIRONMENTS[environment];
524
507
  if (!env) {
@@ -536,15 +519,11 @@ function getEnvironmentConfig(environment, chainID) {
536
519
  }
537
520
  }
538
521
  const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
522
+ const apiUrlOverride = getApiUrlOverride();
539
523
  return {
540
524
  ...env,
541
525
  chainID: BigInt(resolvedChainID),
542
- ...process.env.ECLOUD_USER_API_URL && {
543
- userApiServerURL: process.env.ECLOUD_USER_API_URL
544
- },
545
- ...process.env.ECLOUD_RPC_URL && {
546
- defaultRPCURL: process.env.ECLOUD_RPC_URL
547
- }
526
+ ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
548
527
  };
549
528
  }
550
529
  function getBillingEnvironmentConfig(build) {
@@ -552,12 +531,11 @@ function getBillingEnvironmentConfig(build) {
552
531
  if (!config) {
553
532
  throw new Error(`Unknown billing environment: ${build}`);
554
533
  }
555
- return {
556
- ...config,
557
- ...process.env.ECLOUD_BILLING_API_URL && {
558
- billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
559
- }
560
- };
534
+ const apiUrlOverride = getApiUrlOverride();
535
+ if (apiUrlOverride) {
536
+ return { billingApiServerURL: apiUrlOverride };
537
+ }
538
+ return config;
561
539
  }
562
540
  function getBuildType() {
563
541
  const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
@@ -2100,7 +2078,7 @@ function createBillingModule(config) {
2100
2078
  const address = walletClient.account.address;
2101
2079
  const logger = getLogger(verbose);
2102
2080
  const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
2103
- const billingApi = new BillingApiClient(billingEnvConfig, walletClient, { verbose });
2081
+ const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
2104
2082
  const environmentConfig = getEnvironmentConfig(environment);
2105
2083
  const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
2106
2084
  if (!usdcCreditsAddress) {
@@ -2264,12 +2242,6 @@ function createBillingModule(config) {
2264
2242
  };
2265
2243
  }
2266
2244
  );
2267
- },
2268
- async getPaymentMethods() {
2269
- return billingApi.getPaymentMethods();
2270
- },
2271
- async purchaseCredits(amountCents, paymentMethodId) {
2272
- return billingApi.purchaseCredits(amountCents, paymentMethodId);
2273
2245
  }
2274
2246
  };
2275
2247
  return module2;