@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/VERSION
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
version=1.0.0-dev.
|
|
2
|
-
commit=
|
|
1
|
+
version=1.0.0-dev.2
|
|
2
|
+
commit=44b22091b826ce951383ff8a7fb2136c010abb56
|
package/dist/billing.cjs
CHANGED
|
@@ -317,20 +317,6 @@ var BillingApiClient = class {
|
|
|
317
317
|
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
|
|
318
318
|
await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
|
|
319
319
|
}
|
|
320
|
-
async getPaymentMethods() {
|
|
321
|
-
const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
|
|
322
|
-
const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
|
|
323
|
-
return resp.json();
|
|
324
|
-
}
|
|
325
|
-
async purchaseCredits(amountCents, paymentMethodId) {
|
|
326
|
-
const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
|
|
327
|
-
const body = { amountCents };
|
|
328
|
-
if (paymentMethodId) {
|
|
329
|
-
body.paymentMethodId = paymentMethodId;
|
|
330
|
-
}
|
|
331
|
-
const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
|
|
332
|
-
return resp.json();
|
|
333
|
-
}
|
|
334
320
|
// ==========================================================================
|
|
335
321
|
// Internal Methods
|
|
336
322
|
// ==========================================================================
|
|
@@ -340,19 +326,10 @@ var BillingApiClient = class {
|
|
|
340
326
|
* Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
|
|
341
327
|
*/
|
|
342
328
|
async makeAuthenticatedRequest(url, method, productId, body) {
|
|
343
|
-
if (this.
|
|
344
|
-
|
|
329
|
+
if (this.useSession) {
|
|
330
|
+
return this.makeSessionAuthenticatedRequest(url, method, body);
|
|
345
331
|
}
|
|
346
|
-
|
|
347
|
-
if (this.options.verbose) {
|
|
348
|
-
const data = await resp.json();
|
|
349
|
-
console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
|
|
350
|
-
return {
|
|
351
|
-
json: async () => data,
|
|
352
|
-
text: async () => JSON.stringify(data)
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
return resp;
|
|
332
|
+
return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
|
|
356
333
|
}
|
|
357
334
|
/**
|
|
358
335
|
* Make a request using session-based authentication (cookies)
|
|
@@ -519,6 +496,12 @@ var CHAIN_ID_TO_ENVIRONMENT = {
|
|
|
519
496
|
[SEPOLIA_CHAIN_ID.toString()]: "sepolia",
|
|
520
497
|
[MAINNET_CHAIN_ID.toString()]: "mainnet-alpha"
|
|
521
498
|
};
|
|
499
|
+
function getApiUrlOverride() {
|
|
500
|
+
const raw = process.env.ECLOUD_API_URL;
|
|
501
|
+
if (!raw) return void 0;
|
|
502
|
+
const trimmed = raw.trim().replace(/\/+$/, "");
|
|
503
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
504
|
+
}
|
|
522
505
|
function getEnvironmentConfig(environment, chainID) {
|
|
523
506
|
const env = ENVIRONMENTS[environment];
|
|
524
507
|
if (!env) {
|
|
@@ -536,15 +519,11 @@ function getEnvironmentConfig(environment, chainID) {
|
|
|
536
519
|
}
|
|
537
520
|
}
|
|
538
521
|
const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
|
|
522
|
+
const apiUrlOverride = getApiUrlOverride();
|
|
539
523
|
return {
|
|
540
524
|
...env,
|
|
541
525
|
chainID: BigInt(resolvedChainID),
|
|
542
|
-
...
|
|
543
|
-
userApiServerURL: process.env.ECLOUD_USER_API_URL
|
|
544
|
-
},
|
|
545
|
-
...process.env.ECLOUD_RPC_URL && {
|
|
546
|
-
defaultRPCURL: process.env.ECLOUD_RPC_URL
|
|
547
|
-
}
|
|
526
|
+
...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
|
|
548
527
|
};
|
|
549
528
|
}
|
|
550
529
|
function getBillingEnvironmentConfig(build) {
|
|
@@ -552,12 +531,11 @@ function getBillingEnvironmentConfig(build) {
|
|
|
552
531
|
if (!config) {
|
|
553
532
|
throw new Error(`Unknown billing environment: ${build}`);
|
|
554
533
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
};
|
|
534
|
+
const apiUrlOverride = getApiUrlOverride();
|
|
535
|
+
if (apiUrlOverride) {
|
|
536
|
+
return { billingApiServerURL: apiUrlOverride };
|
|
537
|
+
}
|
|
538
|
+
return config;
|
|
561
539
|
}
|
|
562
540
|
function getBuildType() {
|
|
563
541
|
const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
|
|
@@ -2100,7 +2078,7 @@ function createBillingModule(config) {
|
|
|
2100
2078
|
const address = walletClient.account.address;
|
|
2101
2079
|
const logger = getLogger(verbose);
|
|
2102
2080
|
const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
|
|
2103
|
-
const billingApi = new BillingApiClient(billingEnvConfig, walletClient
|
|
2081
|
+
const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
|
|
2104
2082
|
const environmentConfig = getEnvironmentConfig(environment);
|
|
2105
2083
|
const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
|
|
2106
2084
|
if (!usdcCreditsAddress) {
|
|
@@ -2264,12 +2242,6 @@ function createBillingModule(config) {
|
|
|
2264
2242
|
};
|
|
2265
2243
|
}
|
|
2266
2244
|
);
|
|
2267
|
-
},
|
|
2268
|
-
async getPaymentMethods() {
|
|
2269
|
-
return billingApi.getPaymentMethods();
|
|
2270
|
-
},
|
|
2271
|
-
async purchaseCredits(amountCents, paymentMethodId) {
|
|
2272
|
-
return billingApi.purchaseCredits(amountCents, paymentMethodId);
|
|
2273
2245
|
}
|
|
2274
2246
|
};
|
|
2275
2247
|
return module2;
|