@layr-labs/ecloud-sdk 1.0.0-dev.2 → 1.0.0-dev.4

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
@@ -300,7 +300,9 @@ var ENVIRONMENTS = {
300
300
  kmsServerURL: "http://10.128.0.57:8080",
301
301
  userApiServerURL: "https://userapi-compute-sepolia-dev.eigencloud.xyz",
302
302
  defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com",
303
- usdcCreditsAddress: "0xbdA3897c3A428763B59015C64AB766c288C97376"
303
+ usdcCreditsAddress: "0xbdA3897c3A428763B59015C64AB766c288C97376",
304
+ baseUsdcCreditsAddress: "0x7673a47463F80c6a3553Db9E54c8cDcd5313d0ac",
305
+ baseRPCURL: "https://base-sepolia-rpc.publicnode.com"
304
306
  },
305
307
  sepolia: {
306
308
  name: "sepolia",
@@ -312,7 +314,9 @@ var ENVIRONMENTS = {
312
314
  userApiServerURL: "https://userapi-compute-sepolia-prod.eigencloud.xyz",
313
315
  defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com",
314
316
  billingRPCURL: "https://ethereum-rpc.publicnode.com",
315
- usdcCreditsAddress: "0xed9c88640ca9149Bd9f7ee6620074af10F2E145d"
317
+ usdcCreditsAddress: "0xed9c88640ca9149Bd9f7ee6620074af10F2E145d",
318
+ baseUsdcCreditsAddress: "0x7673a47463F80c6a3553Db9E54c8cDcd5313d0ac",
319
+ baseRPCURL: "https://base-sepolia-rpc.publicnode.com"
316
320
  },
317
321
  "mainnet-alpha": {
318
322
  name: "mainnet-alpha",
@@ -357,7 +361,13 @@ function getEnvironmentConfig(environment, chainID) {
357
361
  return {
358
362
  ...env,
359
363
  chainID: BigInt(resolvedChainID),
360
- ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
364
+ ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {},
365
+ ...process.env.ECLOUD_USER_API_URL && {
366
+ userApiServerURL: process.env.ECLOUD_USER_API_URL
367
+ },
368
+ ...process.env.ECLOUD_RPC_URL && {
369
+ defaultRPCURL: process.env.ECLOUD_RPC_URL
370
+ }
361
371
  };
362
372
  }
363
373
  function getBillingEnvironmentConfig(build) {
@@ -369,7 +379,12 @@ function getBillingEnvironmentConfig(build) {
369
379
  if (apiUrlOverride) {
370
380
  return { billingApiServerURL: apiUrlOverride };
371
381
  }
372
- return config;
382
+ return {
383
+ ...config,
384
+ ...process.env.ECLOUD_BILLING_API_URL && {
385
+ billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
386
+ }
387
+ };
373
388
  }
374
389
  function getBuildType() {
375
390
  const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
@@ -404,7 +419,7 @@ var import_accounts = require("viem/accounts");
404
419
 
405
420
  // src/client/common/constants.ts
406
421
  var import_chains = require("viem/chains");
407
- var SUPPORTED_CHAINS = [import_chains.mainnet, import_chains.sepolia];
422
+ var SUPPORTED_CHAINS = [import_chains.mainnet, import_chains.sepolia, import_chains.baseSepolia];
408
423
 
409
424
  // src/client/common/utils/helpers.ts
410
425
  function getChainFromID(chainID, fallback2 = import_chains2.sepolia) {
@@ -729,7 +744,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
729
744
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
730
745
  var CanUpdateAppProfilePermission = "0x036fef61";
731
746
  function getDefaultClientId() {
732
- const version = true ? "1.0.0-dev.2" : "0.0.0";
747
+ const version = true ? "1.0.0-dev.4" : "0.0.0";
733
748
  return `ecloud-sdk/v${version}`;
734
749
  }
735
750
  var UserApiClient = class {
@@ -1317,6 +1332,20 @@ var BillingApiClient = class {
1317
1332
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
1318
1333
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
1319
1334
  }
1335
+ async getPaymentMethods() {
1336
+ const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
1337
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
1338
+ return resp.json();
1339
+ }
1340
+ async purchaseCredits(amountCents, paymentMethodId) {
1341
+ const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
1342
+ const body = { amountCents };
1343
+ if (paymentMethodId) {
1344
+ body.paymentMethodId = paymentMethodId;
1345
+ }
1346
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
1347
+ return resp.json();
1348
+ }
1320
1349
  // ==========================================================================
1321
1350
  // Internal Methods
1322
1351
  // ==========================================================================
@@ -1326,10 +1355,22 @@ var BillingApiClient = class {
1326
1355
  * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
1327
1356
  */
1328
1357
  async makeAuthenticatedRequest(url, method, productId, body) {
1329
- if (this.useSession) {
1330
- return this.makeSessionAuthenticatedRequest(url, method, body);
1358
+ if (this.options.verbose) {
1359
+ console.debug(`[BillingAPI] ${method} ${url}`);
1360
+ if (body) {
1361
+ console.debug(`[BillingAPI] Payload:`, JSON.stringify(body, null, 2));
1362
+ }
1363
+ }
1364
+ const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1365
+ if (this.options.verbose) {
1366
+ const data = await resp.json();
1367
+ console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
1368
+ return {
1369
+ json: async () => data,
1370
+ text: async () => JSON.stringify(data)
1371
+ };
1331
1372
  }
1332
- return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1373
+ return resp;
1333
1374
  }
1334
1375
  /**
1335
1376
  * Make a request using session-based authentication (cookies)