@layr-labs/ecloud-sdk 1.0.0-dev.3 → 1.0.0-devep1
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 +6 -49
- 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 +6 -49
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +6 -43
- 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 +6 -43
- package/dist/browser.js.map +1 -1
- package/dist/{compute-yAqGf5hM.d.cts → compute-Ckyn8ils.d.cts} +1 -1
- package/dist/{compute-BbgMH6Ef.d.ts → compute-Cnw6rwSB.d.ts} +1 -1
- package/dist/compute.cjs +325 -59
- 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 +325 -59
- package/dist/compute.js.map +1 -1
- package/dist/{helpers-GWlLS3gz.d.ts → helpers-DZL2bg9p.d.cts} +1 -5
- package/dist/{helpers-CnlJ5yPE.d.cts → helpers-Dj2ME5rp.d.ts} +1 -5
- package/dist/{index-Bac4HjC0.d.cts → index-U2vKBrry.d.cts} +1 -17
- package/dist/{index-Bac4HjC0.d.ts → index-U2vKBrry.d.ts} +1 -17
- package/dist/index.cjs +330 -101
- 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 +330 -101
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/tools/ecloud-drain-watcher-linux-amd64 +0 -0
- package/tools/tls-keygen-linux-amd64 +0 -0
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,22 +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
|
-
|
|
311
|
-
if (body) {
|
|
312
|
-
console.debug(`[BillingAPI] Payload:`, JSON.stringify(body, null, 2));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
|
|
316
|
-
if (this.options.verbose) {
|
|
317
|
-
const data = await resp.json();
|
|
318
|
-
console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
|
|
319
|
-
return {
|
|
320
|
-
json: async () => data,
|
|
321
|
-
text: async () => JSON.stringify(data)
|
|
322
|
-
};
|
|
295
|
+
if (this.useSession) {
|
|
296
|
+
return this.makeSessionAuthenticatedRequest(url, method, body);
|
|
323
297
|
}
|
|
324
|
-
return
|
|
298
|
+
return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
|
|
325
299
|
}
|
|
326
300
|
/**
|
|
327
301
|
* Make a request using session-based authentication (cookies)
|
|
@@ -515,13 +489,7 @@ function getEnvironmentConfig(environment, chainID) {
|
|
|
515
489
|
return {
|
|
516
490
|
...env,
|
|
517
491
|
chainID: BigInt(resolvedChainID),
|
|
518
|
-
...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
|
|
519
|
-
...process.env.ECLOUD_USER_API_URL && {
|
|
520
|
-
userApiServerURL: process.env.ECLOUD_USER_API_URL
|
|
521
|
-
},
|
|
522
|
-
...process.env.ECLOUD_RPC_URL && {
|
|
523
|
-
defaultRPCURL: process.env.ECLOUD_RPC_URL
|
|
524
|
-
}
|
|
492
|
+
...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
|
|
525
493
|
};
|
|
526
494
|
}
|
|
527
495
|
function getBillingEnvironmentConfig(build) {
|
|
@@ -533,12 +501,7 @@ function getBillingEnvironmentConfig(build) {
|
|
|
533
501
|
if (apiUrlOverride) {
|
|
534
502
|
return { billingApiServerURL: apiUrlOverride };
|
|
535
503
|
}
|
|
536
|
-
return
|
|
537
|
-
...config,
|
|
538
|
-
...process.env.ECLOUD_BILLING_API_URL && {
|
|
539
|
-
billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
|
|
540
|
-
}
|
|
541
|
-
};
|
|
504
|
+
return config;
|
|
542
505
|
}
|
|
543
506
|
function getBuildType() {
|
|
544
507
|
const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
|
|
@@ -2081,7 +2044,7 @@ function createBillingModule(config) {
|
|
|
2081
2044
|
const address = walletClient.account.address;
|
|
2082
2045
|
const logger = getLogger(verbose);
|
|
2083
2046
|
const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
|
|
2084
|
-
const billingApi = new BillingApiClient(billingEnvConfig, walletClient
|
|
2047
|
+
const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
|
|
2085
2048
|
const environmentConfig = getEnvironmentConfig(environment);
|
|
2086
2049
|
const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
|
|
2087
2050
|
if (!usdcCreditsAddress) {
|
|
@@ -2245,12 +2208,6 @@ function createBillingModule(config) {
|
|
|
2245
2208
|
};
|
|
2246
2209
|
}
|
|
2247
2210
|
);
|
|
2248
|
-
},
|
|
2249
|
-
async getPaymentMethods() {
|
|
2250
|
-
return billingApi.getPaymentMethods();
|
|
2251
|
-
},
|
|
2252
|
-
async purchaseCredits(amountCents, paymentMethodId) {
|
|
2253
|
-
return billingApi.purchaseCredits(amountCents, paymentMethodId);
|
|
2254
2211
|
}
|
|
2255
2212
|
};
|
|
2256
2213
|
return module;
|