@layr-labs/ecloud-sdk 1.0.0-devep8 → 1.0.0

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-DFqQ7v8_.cjs';
2
+ import { ai as SubscriptionOpts, ag as SubscribeResponse, ab as ProductSubscriptionResponse, k as CancelResponse, Z as PaymentMethodsResponse, s as CreditPurchaseResponse, ac as RedeemCouponResponse } from './index-BVnxNfqb.cjs';
3
3
 
4
4
  /**
5
5
  * Main Billing namespace entry point
@@ -42,6 +42,7 @@ interface BillingModule {
42
42
  purchaseCredits: (amountCents: number, paymentMethodId?: string) => Promise<CreditPurchaseResponse>;
43
43
  /** Check if Base chain is configured for this environment */
44
44
  hasBaseSupport: () => boolean;
45
+ redeemCoupon: (code: string) => Promise<RedeemCouponResponse>;
45
46
  }
46
47
  interface BillingModuleConfig {
47
48
  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-DFqQ7v8_.js';
2
+ import { ai as SubscriptionOpts, ag as SubscribeResponse, ab as ProductSubscriptionResponse, k as CancelResponse, Z as PaymentMethodsResponse, s as CreditPurchaseResponse, ac as RedeemCouponResponse } from './index-BVnxNfqb.js';
3
3
 
4
4
  /**
5
5
  * Main Billing namespace entry point
@@ -42,6 +42,7 @@ interface BillingModule {
42
42
  purchaseCredits: (amountCents: number, paymentMethodId?: string) => Promise<CreditPurchaseResponse>;
43
43
  /** Check if Base chain is configured for this environment */
44
44
  hasBaseSupport: () => boolean;
45
+ redeemCoupon: (code: string) => Promise<RedeemCouponResponse>;
45
46
  }
46
47
  interface BillingModuleConfig {
47
48
  verbose?: boolean;
package/dist/billing.js CHANGED
@@ -298,6 +298,63 @@ var BillingApiClient = class {
298
298
  return resp.json();
299
299
  }
300
300
  // ==========================================================================
301
+ // Admin - Coupon Methods
302
+ // ==========================================================================
303
+ async createCoupon(amountCents) {
304
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons`;
305
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { amountCents });
306
+ return resp.json();
307
+ }
308
+ async listCoupons(opts) {
309
+ const params = new URLSearchParams();
310
+ if (opts?.offset !== void 0) params.set("offset", opts.offset.toString());
311
+ if (opts?.limit !== void 0) params.set("limit", opts.limit.toString());
312
+ if (opts?.active !== void 0) params.set("active", opts.active.toString());
313
+ if (opts?.redeemed !== void 0) params.set("redeemed", opts.redeemed.toString());
314
+ const qs = params.toString();
315
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons${qs ? `?${qs}` : ""}`;
316
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
317
+ return resp.json();
318
+ }
319
+ async getCoupon(id) {
320
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}`;
321
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
322
+ return resp.json();
323
+ }
324
+ async deactivateCoupon(id) {
325
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}/deactivate`;
326
+ await this.makeAuthenticatedRequest(endpoint, "POST", "compute");
327
+ }
328
+ async redeemCouponForUser(id, address) {
329
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}/redeem`;
330
+ await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { address });
331
+ }
332
+ // ==========================================================================
333
+ // Admin - Admin Management Methods
334
+ // ==========================================================================
335
+ async addAdmin(address) {
336
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins`;
337
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { address });
338
+ return resp.json();
339
+ }
340
+ async removeAdmin(address) {
341
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins/${address}`;
342
+ await this.makeAuthenticatedRequest(endpoint, "DELETE", "compute");
343
+ }
344
+ async listAdmins() {
345
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins`;
346
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
347
+ return resp.json();
348
+ }
349
+ // ==========================================================================
350
+ // User - Coupon Redemption
351
+ // ==========================================================================
352
+ async redeemCoupon(code) {
353
+ const endpoint = `${this.config.billingApiServerURL}/v1/coupons/redeem`;
354
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { code });
355
+ return resp.json();
356
+ }
357
+ // ==========================================================================
301
358
  // Internal Methods
302
359
  // ==========================================================================
303
360
  /**
@@ -449,14 +506,13 @@ var BILLING_ENVIRONMENTS = {
449
506
  billingApiServerURL: "https://billingapi.eigencloud.xyz"
450
507
  }
451
508
  };
452
- var PLATFORM_ENV_TESTNET_SEPOLIA = "testnet-sepolia";
453
- var PLATFORM_ENV_MAINNET_ETHEREUM = "mainnet-ethereum";
454
- var DEFAULT_APP_BASE_DOMAIN = "eigencloud.xyz";
455
509
  var ENVIRONMENTS = {
456
510
  "sepolia-dev": {
457
511
  name: "sepolia",
458
512
  build: "dev",
459
513
  appControllerAddress: "0xa86DC1C47cb2518327fB4f9A1627F51966c83B92",
514
+ releaseAbiVersion: "v1.5",
515
+ // AppController upgraded to v1.5.x (containerPolicy)
460
516
  permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,
461
517
  erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
462
518
  kmsServerURL: "http://10.128.0.57:8080",
@@ -464,14 +520,14 @@ var ENVIRONMENTS = {
464
520
  defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com",
465
521
  usdcCreditsAddress: "0xbdA3897c3A428763B59015C64AB766c288C97376",
466
522
  baseUsdcCreditsAddress: "0x7673a47463F80c6a3553Db9E54c8cDcd5313d0ac",
467
- baseRPCURL: "https://base-sepolia-rpc.publicnode.com",
468
- platformEnv: PLATFORM_ENV_TESTNET_SEPOLIA,
469
- appBaseDomain: DEFAULT_APP_BASE_DOMAIN
523
+ baseRPCURL: "https://base-sepolia-rpc.publicnode.com"
470
524
  },
471
525
  sepolia: {
472
526
  name: "sepolia",
473
527
  build: "prod",
474
528
  appControllerAddress: "0x0dd810a6ffba6a9820a10d97b659f07d8d23d4E2",
529
+ releaseAbiVersion: "v1.4",
530
+ // prod still on AppController v1.4.0 (3-field Release)
475
531
  permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,
476
532
  erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
477
533
  kmsServerURL: "http://10.128.15.203:8080",
@@ -480,22 +536,20 @@ var ENVIRONMENTS = {
480
536
  billingRPCURL: "https://ethereum-rpc.publicnode.com",
481
537
  usdcCreditsAddress: "0xed9c88640ca9149Bd9f7ee6620074af10F2E145d",
482
538
  baseUsdcCreditsAddress: "0x7673a47463F80c6a3553Db9E54c8cDcd5313d0ac",
483
- baseRPCURL: "https://base-sepolia-rpc.publicnode.com",
484
- platformEnv: PLATFORM_ENV_TESTNET_SEPOLIA,
485
- appBaseDomain: DEFAULT_APP_BASE_DOMAIN
539
+ baseRPCURL: "https://base-sepolia-rpc.publicnode.com"
486
540
  },
487
541
  "mainnet-alpha": {
488
542
  name: "mainnet-alpha",
489
543
  build: "prod",
490
544
  appControllerAddress: "0xc38d35Fc995e75342A21CBd6D770305b142Fbe67",
545
+ releaseAbiVersion: "v1.4",
546
+ // prod still on AppController v1.4.0 (3-field Release)
491
547
  permissionControllerAddress: ChainAddresses[MAINNET_CHAIN_ID].PermissionController,
492
548
  erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
493
549
  kmsServerURL: "http://10.128.0.2:8080",
494
550
  userApiServerURL: "https://userapi-compute.eigencloud.xyz",
495
551
  defaultRPCURL: "https://ethereum-rpc.publicnode.com",
496
- usdcCreditsAddress: "0xed9c88640ca9149Bd9f7ee6620074af10F2E145d",
497
- platformEnv: PLATFORM_ENV_MAINNET_ETHEREUM,
498
- appBaseDomain: DEFAULT_APP_BASE_DOMAIN
552
+ usdcCreditsAddress: "0xed9c88640ca9149Bd9f7ee6620074af10F2E145d"
499
553
  }
500
554
  };
501
555
  var CHAIN_ID_TO_ENVIRONMENT = {
@@ -555,7 +609,7 @@ function getBillingEnvironmentConfig(build) {
555
609
  };
556
610
  }
557
611
  function getBuildType() {
558
- const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
612
+ const buildTimeType = true ? "prod"?.toLowerCase() : void 0;
559
613
  const runtimeType = process.env.BUILD_TYPE?.toLowerCase();
560
614
  const buildType = buildTimeType || runtimeType;
561
615
  if (buildType === "dev") {
@@ -2330,6 +2384,9 @@ function createBillingModule(config) {
2330
2384
  },
2331
2385
  hasBaseSupport() {
2332
2386
  return !!baseUsdcCreditsAddress && !!baseRPCURL;
2387
+ },
2388
+ async redeemCoupon(code) {
2389
+ return billingApi.redeemCoupon(code);
2333
2390
  }
2334
2391
  };
2335
2392
  return module;