@layr-labs/ecloud-sdk 1.0.0-dev.3 → 1.0.0-devep1

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,5 +1,5 @@
1
1
  import { Address, Hex, WalletClient, PublicClient } from 'viem';
2
- import { a6 as SubscriptionOpts, a4 as SubscribeResponse, a0 as ProductSubscriptionResponse, g as CancelResponse, M as PaymentMethodsResponse, m as CreditPurchaseResponse } from './index-Bac4HjC0.cjs';
2
+ import { a3 as SubscriptionOpts, a1 as SubscribeResponse, Z as ProductSubscriptionResponse, g as CancelResponse } from './index-U2vKBrry.cjs';
3
3
 
4
4
  /**
5
5
  * Main Billing namespace entry point
@@ -33,8 +33,6 @@ interface BillingModule {
33
33
  getTopUpInfo: () => Promise<TopUpInfo>;
34
34
  /** Purchase credits with USDC on-chain */
35
35
  topUp: (opts: TopUpOpts) => Promise<TopUpResult>;
36
- getPaymentMethods: () => Promise<PaymentMethodsResponse>;
37
- purchaseCredits: (amountCents: number, paymentMethodId?: string) => Promise<CreditPurchaseResponse>;
38
36
  }
39
37
  interface BillingModuleConfig {
40
38
  verbose?: boolean;
package/dist/billing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Address, Hex, WalletClient, PublicClient } from 'viem';
2
- import { a6 as SubscriptionOpts, a4 as SubscribeResponse, a0 as ProductSubscriptionResponse, g as CancelResponse, M as PaymentMethodsResponse, m as CreditPurchaseResponse } from './index-Bac4HjC0.js';
2
+ import { a3 as SubscriptionOpts, a1 as SubscribeResponse, Z as ProductSubscriptionResponse, g as CancelResponse } from './index-U2vKBrry.js';
3
3
 
4
4
  /**
5
5
  * Main Billing namespace entry point
@@ -33,8 +33,6 @@ interface BillingModule {
33
33
  getTopUpInfo: () => Promise<TopUpInfo>;
34
34
  /** Purchase credits with USDC on-chain */
35
35
  topUp: (opts: TopUpOpts) => Promise<TopUpResult>;
36
- getPaymentMethods: () => Promise<PaymentMethodsResponse>;
37
- purchaseCredits: (amountCents: number, paymentMethodId?: string) => Promise<CreditPurchaseResponse>;
38
36
  }
39
37
  interface BillingModuleConfig {
40
38
  verbose?: boolean;
package/dist/billing.js CHANGED
@@ -283,20 +283,6 @@ var BillingApiClient = class {
283
283
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
284
284
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
285
285
  }
286
- async getPaymentMethods() {
287
- const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
288
- const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
289
- return resp.json();
290
- }
291
- async purchaseCredits(amountCents, paymentMethodId) {
292
- const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
293
- const body = { amountCents };
294
- if (paymentMethodId) {
295
- body.paymentMethodId = paymentMethodId;
296
- }
297
- const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
298
- return resp.json();
299
- }
300
286
  // ==========================================================================
301
287
  // Internal Methods
302
288
  // ==========================================================================
@@ -306,22 +292,10 @@ var BillingApiClient = class {
306
292
  * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
307
293
  */
308
294
  async makeAuthenticatedRequest(url, method, productId, body) {
309
- if (this.options.verbose) {
310
- console.debug(`[BillingAPI] ${method} ${url}`);
311
- if (body) {
312
- console.debug(`[BillingAPI] Payload:`, JSON.stringify(body, null, 2));
313
- }
314
- }
315
- const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
316
- if (this.options.verbose) {
317
- const data = await resp.json();
318
- console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
319
- return {
320
- json: async () => data,
321
- text: async () => JSON.stringify(data)
322
- };
295
+ if (this.useSession) {
296
+ return this.makeSessionAuthenticatedRequest(url, method, body);
323
297
  }
324
- return resp;
298
+ return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
325
299
  }
326
300
  /**
327
301
  * Make a request using session-based authentication (cookies)
@@ -515,13 +489,7 @@ function getEnvironmentConfig(environment, chainID) {
515
489
  return {
516
490
  ...env,
517
491
  chainID: BigInt(resolvedChainID),
518
- ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {},
519
- ...process.env.ECLOUD_USER_API_URL && {
520
- userApiServerURL: process.env.ECLOUD_USER_API_URL
521
- },
522
- ...process.env.ECLOUD_RPC_URL && {
523
- defaultRPCURL: process.env.ECLOUD_RPC_URL
524
- }
492
+ ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
525
493
  };
526
494
  }
527
495
  function getBillingEnvironmentConfig(build) {
@@ -533,12 +501,7 @@ function getBillingEnvironmentConfig(build) {
533
501
  if (apiUrlOverride) {
534
502
  return { billingApiServerURL: apiUrlOverride };
535
503
  }
536
- return {
537
- ...config,
538
- ...process.env.ECLOUD_BILLING_API_URL && {
539
- billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
540
- }
541
- };
504
+ return config;
542
505
  }
543
506
  function getBuildType() {
544
507
  const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
@@ -2081,7 +2044,7 @@ function createBillingModule(config) {
2081
2044
  const address = walletClient.account.address;
2082
2045
  const logger = getLogger(verbose);
2083
2046
  const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
2084
- const billingApi = new BillingApiClient(billingEnvConfig, walletClient, { verbose });
2047
+ const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
2085
2048
  const environmentConfig = getEnvironmentConfig(environment);
2086
2049
  const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
2087
2050
  if (!usdcCreditsAddress) {
@@ -2245,12 +2208,6 @@ function createBillingModule(config) {
2245
2208
  };
2246
2209
  }
2247
2210
  );
2248
- },
2249
- async getPaymentMethods() {
2250
- return billingApi.getPaymentMethods();
2251
- },
2252
- async purchaseCredits(amountCents, paymentMethodId) {
2253
- return billingApi.purchaseCredits(amountCents, paymentMethodId);
2254
2211
  }
2255
2212
  };
2256
2213
  return module;