@layr-labs/ecloud-sdk 0.5.0 → 1.0.0-dev.1

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/browser.cjs CHANGED
@@ -349,7 +349,13 @@ function getEnvironmentConfig(environment, chainID) {
349
349
  const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
350
350
  return {
351
351
  ...env,
352
- chainID: BigInt(resolvedChainID)
352
+ chainID: BigInt(resolvedChainID),
353
+ ...process.env.ECLOUD_USER_API_URL && {
354
+ userApiServerURL: process.env.ECLOUD_USER_API_URL
355
+ },
356
+ ...process.env.ECLOUD_RPC_URL && {
357
+ defaultRPCURL: process.env.ECLOUD_RPC_URL
358
+ }
353
359
  };
354
360
  }
355
361
  function getBillingEnvironmentConfig(build) {
@@ -357,10 +363,15 @@ function getBillingEnvironmentConfig(build) {
357
363
  if (!config) {
358
364
  throw new Error(`Unknown billing environment: ${build}`);
359
365
  }
360
- return config;
366
+ return {
367
+ ...config,
368
+ ...process.env.ECLOUD_BILLING_API_URL && {
369
+ billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
370
+ }
371
+ };
361
372
  }
362
373
  function getBuildType() {
363
- const buildTimeType = true ? "prod"?.toLowerCase() : void 0;
374
+ const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
364
375
  const runtimeType = process.env.BUILD_TYPE?.toLowerCase();
365
376
  const buildType = buildTimeType || runtimeType;
366
377
  if (buildType === "dev") {
@@ -717,7 +728,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
717
728
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
718
729
  var CanUpdateAppProfilePermission = "0x036fef61";
719
730
  function getDefaultClientId() {
720
- const version = true ? "0.5.0" : "0.0.0";
731
+ const version = true ? "1.0.0-dev.1" : "0.0.0";
721
732
  return `ecloud-sdk/v${version}`;
722
733
  }
723
734
  var UserApiClient = class {
@@ -1305,6 +1316,20 @@ var BillingApiClient = class {
1305
1316
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
1306
1317
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
1307
1318
  }
1319
+ async getPaymentMethods() {
1320
+ const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
1321
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
1322
+ return resp.json();
1323
+ }
1324
+ async purchaseCredits(amountCents, paymentMethodId) {
1325
+ const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
1326
+ const body = { amountCents };
1327
+ if (paymentMethodId) {
1328
+ body.paymentMethodId = paymentMethodId;
1329
+ }
1330
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
1331
+ return resp.json();
1332
+ }
1308
1333
  // ==========================================================================
1309
1334
  // Internal Methods
1310
1335
  // ==========================================================================
@@ -1314,10 +1339,19 @@ var BillingApiClient = class {
1314
1339
  * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
1315
1340
  */
1316
1341
  async makeAuthenticatedRequest(url, method, productId, body) {
1317
- if (this.useSession) {
1318
- return this.makeSessionAuthenticatedRequest(url, method, body);
1342
+ if (this.options.verbose) {
1343
+ console.debug(`[BillingAPI] ${method} ${url}`);
1344
+ }
1345
+ const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1346
+ if (this.options.verbose) {
1347
+ const data = await resp.json();
1348
+ console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
1349
+ return {
1350
+ json: async () => data,
1351
+ text: async () => JSON.stringify(data)
1352
+ };
1319
1353
  }
1320
- return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1354
+ return resp;
1321
1355
  }
1322
1356
  /**
1323
1357
  * Make a request using session-based authentication (cookies)