@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 +2 -2
- package/dist/billing.cjs +17 -45
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +1 -3
- package/dist/billing.d.ts +1 -3
- package/dist/billing.js +17 -45
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +17 -39
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +4 -4
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +17 -39
- package/dist/browser.js.map +1 -1
- package/dist/{compute-Bn6KcW3x.d.cts → compute-Ckyn8ils.d.cts} +1 -1
- package/dist/{compute-Do2t0Fo8.d.ts → compute-Cnw6rwSB.d.ts} +1 -1
- package/dist/compute.cjs +9 -7
- package/dist/compute.cjs.map +1 -1
- package/dist/compute.d.cts +2 -2
- package/dist/compute.d.ts +2 -2
- package/dist/compute.js +9 -7
- package/dist/compute.js.map +1 -1
- package/dist/{helpers-BRamdfGn.d.ts → helpers-DZL2bg9p.d.cts} +1 -5
- package/dist/{helpers-CfsfcGJO.d.cts → helpers-Dj2ME5rp.d.ts} +1 -5
- package/dist/{index-BbH7ZCIu.d.cts → index-U2vKBrry.d.cts} +1 -15
- package/dist/{index-BbH7ZCIu.d.ts → index-U2vKBrry.d.ts} +1 -15
- package/dist/index.cjs +18 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +18 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/billing.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, Hex, WalletClient, PublicClient } from 'viem';
|
|
2
|
-
import {
|
|
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 {
|
|
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,19 +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.
|
|
310
|
-
|
|
295
|
+
if (this.useSession) {
|
|
296
|
+
return this.makeSessionAuthenticatedRequest(url, method, body);
|
|
311
297
|
}
|
|
312
|
-
|
|
313
|
-
if (this.options.verbose) {
|
|
314
|
-
const data = await resp.json();
|
|
315
|
-
console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
|
|
316
|
-
return {
|
|
317
|
-
json: async () => data,
|
|
318
|
-
text: async () => JSON.stringify(data)
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
return resp;
|
|
298
|
+
return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
|
|
322
299
|
}
|
|
323
300
|
/**
|
|
324
301
|
* Make a request using session-based authentication (cookies)
|
|
@@ -485,6 +462,12 @@ var CHAIN_ID_TO_ENVIRONMENT = {
|
|
|
485
462
|
[SEPOLIA_CHAIN_ID.toString()]: "sepolia",
|
|
486
463
|
[MAINNET_CHAIN_ID.toString()]: "mainnet-alpha"
|
|
487
464
|
};
|
|
465
|
+
function getApiUrlOverride() {
|
|
466
|
+
const raw = process.env.ECLOUD_API_URL;
|
|
467
|
+
if (!raw) return void 0;
|
|
468
|
+
const trimmed = raw.trim().replace(/\/+$/, "");
|
|
469
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
470
|
+
}
|
|
488
471
|
function getEnvironmentConfig(environment, chainID) {
|
|
489
472
|
const env = ENVIRONMENTS[environment];
|
|
490
473
|
if (!env) {
|
|
@@ -502,15 +485,11 @@ function getEnvironmentConfig(environment, chainID) {
|
|
|
502
485
|
}
|
|
503
486
|
}
|
|
504
487
|
const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
|
|
488
|
+
const apiUrlOverride = getApiUrlOverride();
|
|
505
489
|
return {
|
|
506
490
|
...env,
|
|
507
491
|
chainID: BigInt(resolvedChainID),
|
|
508
|
-
...
|
|
509
|
-
userApiServerURL: process.env.ECLOUD_USER_API_URL
|
|
510
|
-
},
|
|
511
|
-
...process.env.ECLOUD_RPC_URL && {
|
|
512
|
-
defaultRPCURL: process.env.ECLOUD_RPC_URL
|
|
513
|
-
}
|
|
492
|
+
...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
|
|
514
493
|
};
|
|
515
494
|
}
|
|
516
495
|
function getBillingEnvironmentConfig(build) {
|
|
@@ -518,12 +497,11 @@ function getBillingEnvironmentConfig(build) {
|
|
|
518
497
|
if (!config) {
|
|
519
498
|
throw new Error(`Unknown billing environment: ${build}`);
|
|
520
499
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
};
|
|
500
|
+
const apiUrlOverride = getApiUrlOverride();
|
|
501
|
+
if (apiUrlOverride) {
|
|
502
|
+
return { billingApiServerURL: apiUrlOverride };
|
|
503
|
+
}
|
|
504
|
+
return config;
|
|
527
505
|
}
|
|
528
506
|
function getBuildType() {
|
|
529
507
|
const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
|
|
@@ -2066,7 +2044,7 @@ function createBillingModule(config) {
|
|
|
2066
2044
|
const address = walletClient.account.address;
|
|
2067
2045
|
const logger = getLogger(verbose);
|
|
2068
2046
|
const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
|
|
2069
|
-
const billingApi = new BillingApiClient(billingEnvConfig, walletClient
|
|
2047
|
+
const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
|
|
2070
2048
|
const environmentConfig = getEnvironmentConfig(environment);
|
|
2071
2049
|
const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
|
|
2072
2050
|
if (!usdcCreditsAddress) {
|
|
@@ -2230,12 +2208,6 @@ function createBillingModule(config) {
|
|
|
2230
2208
|
};
|
|
2231
2209
|
}
|
|
2232
2210
|
);
|
|
2233
|
-
},
|
|
2234
|
-
async getPaymentMethods() {
|
|
2235
|
-
return billingApi.getPaymentMethods();
|
|
2236
|
-
},
|
|
2237
|
-
async purchaseCredits(amountCents, paymentMethodId) {
|
|
2238
|
-
return billingApi.purchaseCredits(amountCents, paymentMethodId);
|
|
2239
2211
|
}
|
|
2240
2212
|
};
|
|
2241
2213
|
return module;
|