@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/VERSION +2 -2
- package/dist/billing.cjs +147 -34
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +13 -3
- package/dist/billing.d.ts +13 -3
- package/dist/billing.js +147 -34
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +50 -9
- 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 +51 -10
- package/dist/browser.js.map +1 -1
- package/dist/{compute-Cnw6rwSB.d.ts → compute-B6SZ0VQG.d.ts} +1 -1
- package/dist/{compute-Ckyn8ils.d.cts → compute-BK4PxhNh.d.cts} +1 -1
- package/dist/compute.cjs +15 -5
- 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 +16 -6
- package/dist/compute.js.map +1 -1
- package/dist/{helpers-DZL2bg9p.d.cts → helpers-F7CeDSVX.d.ts} +7 -2
- package/dist/{helpers-Dj2ME5rp.d.ts → helpers-Qq5W-qNn.d.cts} +7 -2
- package/dist/{index-U2vKBrry.d.cts → index-BoCE0hIh.d.cts} +19 -1
- package/dist/{index-U2vKBrry.d.ts → index-BoCE0hIh.d.ts} +19 -1
- package/dist/index.cjs +116 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +116 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/tools/tls-keygen-linux-amd64 +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as ComputeModule } from './compute-
|
|
2
|
-
export { a as ComputeModuleConfig, b as CreateAppOpts, L as LogsOptions, P as PRIMARY_LANGUAGES, S as SDKCreateAppOpts, c as createApp, d as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, g as encodeTerminateAppData, h as getAvailableTemplates, l as logs } from './compute-
|
|
1
|
+
import { C as ComputeModule } from './compute-BK4PxhNh.cjs';
|
|
2
|
+
export { a as ComputeModuleConfig, b as CreateAppOpts, L as LogsOptions, P as PRIMARY_LANGUAGES, S as SDKCreateAppOpts, c as createApp, d as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, g as encodeTerminateAppData, h as getAvailableTemplates, l as logs } from './compute-BK4PxhNh.cjs';
|
|
3
3
|
import { BillingModule } from './billing.cjs';
|
|
4
|
-
export { BillingModuleConfig, createBillingModule } from './billing.cjs';
|
|
4
|
+
export { BillingChain, BillingModuleConfig, TopUpInfo, TopUpOpts, TopUpResult, createBillingModule } from './billing.cjs';
|
|
5
5
|
import { WalletClient, PublicClient, Address, Hex } from 'viem';
|
|
6
6
|
export { AttestClient, AttestClientConfig, JwtProvider } from './attest.cjs';
|
|
7
|
-
import {
|
|
8
|
-
export { a as AlreadyActiveResponse, c as AppProfile, d as AppProfileResponse, e as AppRecord, f as BillingEnvironmentConfig, g as CancelResponse, h as CancelSuccessResponse, i as ChainID, j as CheckoutCreatedResponse, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, m as
|
|
9
|
-
import { L as LogVisibility, aj as ResourceUsageMonitoring } from './helpers-
|
|
10
|
-
export { A as AppInfo, d as AppMetrics, e as AppProfileInfo, ak as AppRelease, al as AppReleaseBuild, am as AppResponse, B as BillingApiClient, C as ComputeApiConfig, l as CreateAppParams,
|
|
7
|
+
import { V as PreparedDeploy, G as GasEstimate, E as EnvironmentConfig, H as Logger, q as DeployResult, Y as PreparedUpgrade, A as AppId } from './index-BoCE0hIh.cjs';
|
|
8
|
+
export { a as AlreadyActiveResponse, c as AppProfile, d as AppProfileResponse, e as AppRecord, f as BillingEnvironmentConfig, g as CancelResponse, h as CancelSuccessResponse, i as ChainID, j as CheckoutCreatedResponse, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, m as CreditPurchaseResponse, n as DeployAppOpts, o as DeployOptions, p as DeployProgressCallback, r as DeployStep, s as DockerImageConfig, t as EstimateGasOptions, v as ExecuteDeployResult, x as ExecuteUpgradeResult, y as GasOpts, z as GetSubscriptionOptions, I as ImageDigestResult, L as LifecycleOpts, N as NoActiveSubscriptionResponse, P as ParsedEnvironment, J as PaymentIssueResponse, K as PaymentMethod, M as PaymentMethodsResponse, Q as PrepareDeployFromVerifiableBuildOpts, R as PrepareDeployOpts, T as PrepareUpgradeFromVerifiableBuildOpts, U as PrepareUpgradeOpts, X as PreparedDeployData, _ as PreparedUpgradeData, $ as ProductID, a0 as ProductSubscriptionResponse, a1 as Release, a3 as SequentialDeployResult, a4 as SubscribeResponse, a5 as SubscriptionLineItem, a6 as SubscriptionOpts, a7 as SubscriptionStatus, ab as UpgradeAppOpts, ac as calculateAppID, ae as estimateTransactionGas, aj as formatETH, al as getAllAppsByDeveloper, aC as getAppLatestReleaseBlockNumbers, am as getAppsByBillingAccount, ap as getBillingType, aD as getBlockTimestamps, as as logVisibility, at as noopLogger } from './index-BoCE0hIh.cjs';
|
|
9
|
+
import { L as LogVisibility, aj as ResourceUsageMonitoring } from './helpers-Qq5W-qNn.cjs';
|
|
10
|
+
export { A as AppInfo, d as AppMetrics, e as AppProfileInfo, ak as AppRelease, al as AppReleaseBuild, am as AppResponse, an as BASE_SEPOLIA_CHAIN_ID, B as BillingApiClient, C as ComputeApiConfig, l as CreateAppParams, ao as DeployParams, E as EstimateBatchGasOptions, G as GeneratedKey, o as LoginRequest, p as LoginResult, q as LogsParams, a as SessionError, S as SessionInfo, b as SiweMessageParams, r as SiweMessageResult, ap as UpgradeParams, U as UserApiClient, t as addHexPrefix, aq as assertValidFilePath, u as assertValidImageReference, v as assertValidPrivateKey, w as checkERC7702Delegation, x as createSiweMessage, ar as createViemClients, y as estimateBatchGas, D as extractAppNameFromImage, F as generateNewPrivateKey, H as generateNonce, I as getAvailableEnvironments, K as getBillingEnvironmentConfig, M as getBuildType, N as getChainFromID, O as getComputeApiSession, P as getEnvironmentConfig, R as isEnvironmentAvailable, T as isMainnet, V as isSessionValid, W as isSiweMessageExpired, X as isSiweMessageNotYetValid, Y as isSubscriptionActive, $ as loginToComputeApi, a2 as logoutFromComputeApi, a3 as parseSiweMessage, a4 as sanitizeString, a5 as sanitizeURL, a6 as sanitizeXURL, a7 as stripHexPrefix, a8 as validateAppID, a9 as validateAppName, aa as validateCreateAppParams, as as validateDeployParams, ab as validateDescription, at as validateFilePath, au as validateImagePath, ac as validateImageReference, ad as validateInstanceTypeSKU, ae as validateLogVisibility, af as validateLogsParams, ag as validatePrivateKeyFormat, av as validateResourceUsageMonitoring, ah as validateURL, aw as validateUpgradeParams, ai as validateXURL } from './helpers-Qq5W-qNn.cjs';
|
|
11
11
|
|
|
12
12
|
interface SubmitBuildRequest {
|
|
13
13
|
repoUrl: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as ComputeModule } from './compute-
|
|
2
|
-
export { a as ComputeModuleConfig, b as CreateAppOpts, L as LogsOptions, P as PRIMARY_LANGUAGES, S as SDKCreateAppOpts, c as createApp, d as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, g as encodeTerminateAppData, h as getAvailableTemplates, l as logs } from './compute-
|
|
1
|
+
import { C as ComputeModule } from './compute-B6SZ0VQG.js';
|
|
2
|
+
export { a as ComputeModuleConfig, b as CreateAppOpts, L as LogsOptions, P as PRIMARY_LANGUAGES, S as SDKCreateAppOpts, c as createApp, d as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, g as encodeTerminateAppData, h as getAvailableTemplates, l as logs } from './compute-B6SZ0VQG.js';
|
|
3
3
|
import { BillingModule } from './billing.js';
|
|
4
|
-
export { BillingModuleConfig, createBillingModule } from './billing.js';
|
|
4
|
+
export { BillingChain, BillingModuleConfig, TopUpInfo, TopUpOpts, TopUpResult, createBillingModule } from './billing.js';
|
|
5
5
|
import { WalletClient, PublicClient, Address, Hex } from 'viem';
|
|
6
6
|
export { AttestClient, AttestClientConfig, JwtProvider } from './attest.js';
|
|
7
|
-
import {
|
|
8
|
-
export { a as AlreadyActiveResponse, c as AppProfile, d as AppProfileResponse, e as AppRecord, f as BillingEnvironmentConfig, g as CancelResponse, h as CancelSuccessResponse, i as ChainID, j as CheckoutCreatedResponse, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, m as
|
|
9
|
-
import { L as LogVisibility, aj as ResourceUsageMonitoring } from './helpers-
|
|
10
|
-
export { A as AppInfo, d as AppMetrics, e as AppProfileInfo, ak as AppRelease, al as AppReleaseBuild, am as AppResponse, B as BillingApiClient, C as ComputeApiConfig, l as CreateAppParams,
|
|
7
|
+
import { V as PreparedDeploy, G as GasEstimate, E as EnvironmentConfig, H as Logger, q as DeployResult, Y as PreparedUpgrade, A as AppId } from './index-BoCE0hIh.js';
|
|
8
|
+
export { a as AlreadyActiveResponse, c as AppProfile, d as AppProfileResponse, e as AppRecord, f as BillingEnvironmentConfig, g as CancelResponse, h as CancelSuccessResponse, i as ChainID, j as CheckoutCreatedResponse, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, m as CreditPurchaseResponse, n as DeployAppOpts, o as DeployOptions, p as DeployProgressCallback, r as DeployStep, s as DockerImageConfig, t as EstimateGasOptions, v as ExecuteDeployResult, x as ExecuteUpgradeResult, y as GasOpts, z as GetSubscriptionOptions, I as ImageDigestResult, L as LifecycleOpts, N as NoActiveSubscriptionResponse, P as ParsedEnvironment, J as PaymentIssueResponse, K as PaymentMethod, M as PaymentMethodsResponse, Q as PrepareDeployFromVerifiableBuildOpts, R as PrepareDeployOpts, T as PrepareUpgradeFromVerifiableBuildOpts, U as PrepareUpgradeOpts, X as PreparedDeployData, _ as PreparedUpgradeData, $ as ProductID, a0 as ProductSubscriptionResponse, a1 as Release, a3 as SequentialDeployResult, a4 as SubscribeResponse, a5 as SubscriptionLineItem, a6 as SubscriptionOpts, a7 as SubscriptionStatus, ab as UpgradeAppOpts, ac as calculateAppID, ae as estimateTransactionGas, aj as formatETH, al as getAllAppsByDeveloper, aC as getAppLatestReleaseBlockNumbers, am as getAppsByBillingAccount, ap as getBillingType, aD as getBlockTimestamps, as as logVisibility, at as noopLogger } from './index-BoCE0hIh.js';
|
|
9
|
+
import { L as LogVisibility, aj as ResourceUsageMonitoring } from './helpers-F7CeDSVX.js';
|
|
10
|
+
export { A as AppInfo, d as AppMetrics, e as AppProfileInfo, ak as AppRelease, al as AppReleaseBuild, am as AppResponse, an as BASE_SEPOLIA_CHAIN_ID, B as BillingApiClient, C as ComputeApiConfig, l as CreateAppParams, ao as DeployParams, E as EstimateBatchGasOptions, G as GeneratedKey, o as LoginRequest, p as LoginResult, q as LogsParams, a as SessionError, S as SessionInfo, b as SiweMessageParams, r as SiweMessageResult, ap as UpgradeParams, U as UserApiClient, t as addHexPrefix, aq as assertValidFilePath, u as assertValidImageReference, v as assertValidPrivateKey, w as checkERC7702Delegation, x as createSiweMessage, ar as createViemClients, y as estimateBatchGas, D as extractAppNameFromImage, F as generateNewPrivateKey, H as generateNonce, I as getAvailableEnvironments, K as getBillingEnvironmentConfig, M as getBuildType, N as getChainFromID, O as getComputeApiSession, P as getEnvironmentConfig, R as isEnvironmentAvailable, T as isMainnet, V as isSessionValid, W as isSiweMessageExpired, X as isSiweMessageNotYetValid, Y as isSubscriptionActive, $ as loginToComputeApi, a2 as logoutFromComputeApi, a3 as parseSiweMessage, a4 as sanitizeString, a5 as sanitizeURL, a6 as sanitizeXURL, a7 as stripHexPrefix, a8 as validateAppID, a9 as validateAppName, aa as validateCreateAppParams, as as validateDeployParams, ab as validateDescription, at as validateFilePath, au as validateImagePath, ac as validateImageReference, ad as validateInstanceTypeSKU, ae as validateLogVisibility, af as validateLogsParams, ag as validatePrivateKeyFormat, av as validateResourceUsageMonitoring, ah as validateURL, aw as validateUpgradeParams, ai as validateXURL } from './helpers-F7CeDSVX.js';
|
|
11
11
|
|
|
12
12
|
interface SubmitBuildRequest {
|
|
13
13
|
repoUrl: string;
|
package/dist/index.js
CHANGED
|
@@ -143,8 +143,8 @@ import * as child_process from "child_process";
|
|
|
143
143
|
import { promisify } from "util";
|
|
144
144
|
|
|
145
145
|
// src/client/common/constants.ts
|
|
146
|
-
import { sepolia, mainnet } from "viem/chains";
|
|
147
|
-
var SUPPORTED_CHAINS = [mainnet, sepolia];
|
|
146
|
+
import { sepolia, mainnet, baseSepolia } from "viem/chains";
|
|
147
|
+
var SUPPORTED_CHAINS = [mainnet, sepolia, baseSepolia];
|
|
148
148
|
var DOCKER_PLATFORM = "linux/amd64";
|
|
149
149
|
var REGISTRY_PROPAGATION_WAIT_SECONDS = 3;
|
|
150
150
|
var LAYERED_DOCKERFILE_NAME = "Dockerfile.eigencompute";
|
|
@@ -4837,7 +4837,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
|
4837
4837
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
4838
4838
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
4839
4839
|
function getDefaultClientId() {
|
|
4840
|
-
const version = true ? "1.0.0-dev.
|
|
4840
|
+
const version = true ? "1.0.0-dev.4" : "0.0.0";
|
|
4841
4841
|
return `ecloud-sdk/v${version}`;
|
|
4842
4842
|
}
|
|
4843
4843
|
var UserApiClient = class {
|
|
@@ -5596,6 +5596,7 @@ function validateLogsParams(params) {
|
|
|
5596
5596
|
// src/client/common/config/environment.ts
|
|
5597
5597
|
var SEPOLIA_CHAIN_ID = 11155111;
|
|
5598
5598
|
var MAINNET_CHAIN_ID = 1;
|
|
5599
|
+
var BASE_SEPOLIA_CHAIN_ID = 84532;
|
|
5599
5600
|
var CommonAddresses = {
|
|
5600
5601
|
ERC7702Delegator: "0x63c0c19a282a1b52b07dd5a65b58948a07dae32b"
|
|
5601
5602
|
};
|
|
@@ -5625,7 +5626,9 @@ var ENVIRONMENTS = {
|
|
|
5625
5626
|
kmsServerURL: "http://10.128.0.57:8080",
|
|
5626
5627
|
userApiServerURL: "https://userapi-compute-sepolia-dev.eigencloud.xyz",
|
|
5627
5628
|
defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
5628
|
-
usdcCreditsAddress: "0xbdA3897c3A428763B59015C64AB766c288C97376"
|
|
5629
|
+
usdcCreditsAddress: "0xbdA3897c3A428763B59015C64AB766c288C97376",
|
|
5630
|
+
baseUsdcCreditsAddress: "0x7673a47463F80c6a3553Db9E54c8cDcd5313d0ac",
|
|
5631
|
+
baseRPCURL: "https://base-sepolia-rpc.publicnode.com"
|
|
5629
5632
|
},
|
|
5630
5633
|
sepolia: {
|
|
5631
5634
|
name: "sepolia",
|
|
@@ -5637,7 +5640,9 @@ var ENVIRONMENTS = {
|
|
|
5637
5640
|
userApiServerURL: "https://userapi-compute-sepolia-prod.eigencloud.xyz",
|
|
5638
5641
|
defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
5639
5642
|
billingRPCURL: "https://ethereum-rpc.publicnode.com",
|
|
5640
|
-
usdcCreditsAddress: "0xed9c88640ca9149Bd9f7ee6620074af10F2E145d"
|
|
5643
|
+
usdcCreditsAddress: "0xed9c88640ca9149Bd9f7ee6620074af10F2E145d",
|
|
5644
|
+
baseUsdcCreditsAddress: "0x7673a47463F80c6a3553Db9E54c8cDcd5313d0ac",
|
|
5645
|
+
baseRPCURL: "https://base-sepolia-rpc.publicnode.com"
|
|
5641
5646
|
},
|
|
5642
5647
|
"mainnet-alpha": {
|
|
5643
5648
|
name: "mainnet-alpha",
|
|
@@ -5682,7 +5687,13 @@ function getEnvironmentConfig(environment, chainID) {
|
|
|
5682
5687
|
return {
|
|
5683
5688
|
...env,
|
|
5684
5689
|
chainID: BigInt(resolvedChainID),
|
|
5685
|
-
...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
|
|
5690
|
+
...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {},
|
|
5691
|
+
...process.env.ECLOUD_USER_API_URL && {
|
|
5692
|
+
userApiServerURL: process.env.ECLOUD_USER_API_URL
|
|
5693
|
+
},
|
|
5694
|
+
...process.env.ECLOUD_RPC_URL && {
|
|
5695
|
+
defaultRPCURL: process.env.ECLOUD_RPC_URL
|
|
5696
|
+
}
|
|
5686
5697
|
};
|
|
5687
5698
|
}
|
|
5688
5699
|
function getBillingEnvironmentConfig(build) {
|
|
@@ -5694,7 +5705,12 @@ function getBillingEnvironmentConfig(build) {
|
|
|
5694
5705
|
if (apiUrlOverride) {
|
|
5695
5706
|
return { billingApiServerURL: apiUrlOverride };
|
|
5696
5707
|
}
|
|
5697
|
-
return
|
|
5708
|
+
return {
|
|
5709
|
+
...config,
|
|
5710
|
+
...process.env.ECLOUD_BILLING_API_URL && {
|
|
5711
|
+
billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
|
|
5712
|
+
}
|
|
5713
|
+
};
|
|
5698
5714
|
}
|
|
5699
5715
|
function getBuildType() {
|
|
5700
5716
|
const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
|
|
@@ -5999,6 +6015,20 @@ var BillingApiClient = class {
|
|
|
5999
6015
|
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
|
|
6000
6016
|
await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
|
|
6001
6017
|
}
|
|
6018
|
+
async getPaymentMethods() {
|
|
6019
|
+
const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
|
|
6020
|
+
const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
|
|
6021
|
+
return resp.json();
|
|
6022
|
+
}
|
|
6023
|
+
async purchaseCredits(amountCents, paymentMethodId) {
|
|
6024
|
+
const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
|
|
6025
|
+
const body = { amountCents };
|
|
6026
|
+
if (paymentMethodId) {
|
|
6027
|
+
body.paymentMethodId = paymentMethodId;
|
|
6028
|
+
}
|
|
6029
|
+
const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
|
|
6030
|
+
return resp.json();
|
|
6031
|
+
}
|
|
6002
6032
|
// ==========================================================================
|
|
6003
6033
|
// Internal Methods
|
|
6004
6034
|
// ==========================================================================
|
|
@@ -6008,10 +6038,22 @@ var BillingApiClient = class {
|
|
|
6008
6038
|
* Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
|
|
6009
6039
|
*/
|
|
6010
6040
|
async makeAuthenticatedRequest(url, method, productId, body) {
|
|
6011
|
-
if (this.
|
|
6012
|
-
|
|
6041
|
+
if (this.options.verbose) {
|
|
6042
|
+
console.debug(`[BillingAPI] ${method} ${url}`);
|
|
6043
|
+
if (body) {
|
|
6044
|
+
console.debug(`[BillingAPI] Payload:`, JSON.stringify(body, null, 2));
|
|
6045
|
+
}
|
|
6046
|
+
}
|
|
6047
|
+
const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
|
|
6048
|
+
if (this.options.verbose) {
|
|
6049
|
+
const data = await resp.json();
|
|
6050
|
+
console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
|
|
6051
|
+
return {
|
|
6052
|
+
json: async () => data,
|
|
6053
|
+
text: async () => JSON.stringify(data)
|
|
6054
|
+
};
|
|
6013
6055
|
}
|
|
6014
|
-
return
|
|
6056
|
+
return resp;
|
|
6015
6057
|
}
|
|
6016
6058
|
/**
|
|
6017
6059
|
* Make a request using session-based authentication (cookies)
|
|
@@ -8193,44 +8235,78 @@ var ERC20_default = [
|
|
|
8193
8235
|
|
|
8194
8236
|
// src/client/modules/billing/index.ts
|
|
8195
8237
|
function createBillingModule(config) {
|
|
8196
|
-
const { verbose = false, skipTelemetry = false, walletClient, publicClient, environment } = config;
|
|
8238
|
+
const { verbose = false, skipTelemetry = false, walletClient, publicClient, environment, privateKey } = config;
|
|
8197
8239
|
if (!walletClient.account) {
|
|
8198
8240
|
throw new Error("WalletClient must have an account attached");
|
|
8199
8241
|
}
|
|
8200
8242
|
const address = walletClient.account.address;
|
|
8201
8243
|
const logger = getLogger(verbose);
|
|
8202
8244
|
const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
|
|
8203
|
-
const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
|
|
8245
|
+
const billingApi = new BillingApiClient(billingEnvConfig, walletClient, { verbose });
|
|
8204
8246
|
const environmentConfig = getEnvironmentConfig(environment);
|
|
8205
|
-
|
|
8206
|
-
if (!usdcCreditsAddress) {
|
|
8247
|
+
if (!environmentConfig.usdcCreditsAddress) {
|
|
8207
8248
|
throw new Error(`USDCCredits contract address not configured for environment "${environment}"`);
|
|
8208
8249
|
}
|
|
8250
|
+
const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
|
|
8251
|
+
const baseUsdcCreditsAddress = environmentConfig.baseUsdcCreditsAddress;
|
|
8252
|
+
const baseRPCURL = environmentConfig.baseRPCURL;
|
|
8253
|
+
function resolveChainConfig(chain) {
|
|
8254
|
+
if (chain === "base") {
|
|
8255
|
+
if (!baseUsdcCreditsAddress || !baseRPCURL) {
|
|
8256
|
+
throw new Error(`Base chain not configured for environment "${environment}"`);
|
|
8257
|
+
}
|
|
8258
|
+
if (!privateKey) {
|
|
8259
|
+
throw new Error("Private key required for Base chain transactions");
|
|
8260
|
+
}
|
|
8261
|
+
const baseClients = createClients({
|
|
8262
|
+
privateKey,
|
|
8263
|
+
rpcUrl: baseRPCURL,
|
|
8264
|
+
chainId: BigInt(BASE_SEPOLIA_CHAIN_ID)
|
|
8265
|
+
});
|
|
8266
|
+
return {
|
|
8267
|
+
pub: baseClients.publicClient,
|
|
8268
|
+
wallet: baseClients.walletClient,
|
|
8269
|
+
creditsAddress: baseUsdcCreditsAddress,
|
|
8270
|
+
envConfig: {
|
|
8271
|
+
...environmentConfig,
|
|
8272
|
+
chainID: BigInt(BASE_SEPOLIA_CHAIN_ID),
|
|
8273
|
+
defaultRPCURL: baseRPCURL
|
|
8274
|
+
}
|
|
8275
|
+
};
|
|
8276
|
+
}
|
|
8277
|
+
return {
|
|
8278
|
+
pub: publicClient,
|
|
8279
|
+
wallet: walletClient,
|
|
8280
|
+
creditsAddress: usdcCreditsAddress,
|
|
8281
|
+
envConfig: environmentConfig
|
|
8282
|
+
};
|
|
8283
|
+
}
|
|
8209
8284
|
const module = {
|
|
8210
8285
|
address,
|
|
8211
|
-
async getTopUpInfo() {
|
|
8212
|
-
const
|
|
8213
|
-
|
|
8286
|
+
async getTopUpInfo(opts) {
|
|
8287
|
+
const { pub, creditsAddress } = resolveChainConfig(opts?.chain);
|
|
8288
|
+
const usdcAddress = await pub.readContract({
|
|
8289
|
+
address: creditsAddress,
|
|
8214
8290
|
abi: USDCCredits_default,
|
|
8215
8291
|
functionName: "usdc"
|
|
8216
8292
|
});
|
|
8217
8293
|
const [minimumPurchase, usdcBalance, currentAllowance] = await Promise.all([
|
|
8218
|
-
|
|
8219
|
-
address:
|
|
8294
|
+
pub.readContract({
|
|
8295
|
+
address: creditsAddress,
|
|
8220
8296
|
abi: USDCCredits_default,
|
|
8221
8297
|
functionName: "minimumPurchase"
|
|
8222
8298
|
}),
|
|
8223
|
-
|
|
8299
|
+
pub.readContract({
|
|
8224
8300
|
address: usdcAddress,
|
|
8225
8301
|
abi: ERC20_default,
|
|
8226
8302
|
functionName: "balanceOf",
|
|
8227
8303
|
args: [address]
|
|
8228
8304
|
}),
|
|
8229
|
-
|
|
8305
|
+
pub.readContract({
|
|
8230
8306
|
address: usdcAddress,
|
|
8231
8307
|
abi: ERC20_default,
|
|
8232
8308
|
functionName: "allowance",
|
|
8233
|
-
args: [address,
|
|
8309
|
+
args: [address, creditsAddress]
|
|
8234
8310
|
})
|
|
8235
8311
|
]);
|
|
8236
8312
|
return { usdcAddress, minimumPurchase, usdcBalance, currentAllowance };
|
|
@@ -8240,11 +8316,12 @@ function createBillingModule(config) {
|
|
|
8240
8316
|
{
|
|
8241
8317
|
functionName: "topUp",
|
|
8242
8318
|
skipTelemetry,
|
|
8243
|
-
properties: { amount: opts.amount.toString() }
|
|
8319
|
+
properties: { amount: opts.amount.toString(), chain: opts.chain || "ethereum" }
|
|
8244
8320
|
},
|
|
8245
8321
|
async () => {
|
|
8246
8322
|
const targetAccount = opts.account ?? address;
|
|
8247
|
-
const {
|
|
8323
|
+
const { pub, wallet, creditsAddress, envConfig } = resolveChainConfig(opts.chain);
|
|
8324
|
+
const { usdcAddress, currentAllowance } = await module.getTopUpInfo({ chain: opts.chain });
|
|
8248
8325
|
const executions = [];
|
|
8249
8326
|
if (currentAllowance < opts.amount) {
|
|
8250
8327
|
executions.push({
|
|
@@ -8253,12 +8330,12 @@ function createBillingModule(config) {
|
|
|
8253
8330
|
callData: encodeFunctionData4({
|
|
8254
8331
|
abi: ERC20_default,
|
|
8255
8332
|
functionName: "approve",
|
|
8256
|
-
args: [
|
|
8333
|
+
args: [creditsAddress, opts.amount]
|
|
8257
8334
|
})
|
|
8258
8335
|
});
|
|
8259
8336
|
}
|
|
8260
8337
|
executions.push({
|
|
8261
|
-
target:
|
|
8338
|
+
target: creditsAddress,
|
|
8262
8339
|
value: 0n,
|
|
8263
8340
|
callData: encodeFunctionData4({
|
|
8264
8341
|
abi: USDCCredits_default,
|
|
@@ -8268,9 +8345,9 @@ function createBillingModule(config) {
|
|
|
8268
8345
|
});
|
|
8269
8346
|
const txHash = await executeBatch(
|
|
8270
8347
|
{
|
|
8271
|
-
walletClient,
|
|
8272
|
-
publicClient,
|
|
8273
|
-
environmentConfig,
|
|
8348
|
+
walletClient: wallet,
|
|
8349
|
+
publicClient: pub,
|
|
8350
|
+
environmentConfig: envConfig,
|
|
8274
8351
|
executions,
|
|
8275
8352
|
pendingMessage: "Submitting credit purchase..."
|
|
8276
8353
|
},
|
|
@@ -8364,6 +8441,15 @@ function createBillingModule(config) {
|
|
|
8364
8441
|
};
|
|
8365
8442
|
}
|
|
8366
8443
|
);
|
|
8444
|
+
},
|
|
8445
|
+
async getPaymentMethods() {
|
|
8446
|
+
return billingApi.getPaymentMethods();
|
|
8447
|
+
},
|
|
8448
|
+
async purchaseCredits(amountCents, paymentMethodId) {
|
|
8449
|
+
return billingApi.purchaseCredits(amountCents, paymentMethodId);
|
|
8450
|
+
},
|
|
8451
|
+
hasBaseSupport() {
|
|
8452
|
+
return !!baseUsdcCreditsAddress && !!baseRPCURL;
|
|
8367
8453
|
}
|
|
8368
8454
|
};
|
|
8369
8455
|
return module;
|
|
@@ -9336,6 +9422,7 @@ var JwtProvider = class {
|
|
|
9336
9422
|
export {
|
|
9337
9423
|
AttestClient,
|
|
9338
9424
|
AuthRequiredError,
|
|
9425
|
+
BASE_SEPOLIA_CHAIN_ID,
|
|
9339
9426
|
BUILD_STATUS,
|
|
9340
9427
|
BadRequestError,
|
|
9341
9428
|
BillingApiClient,
|