@layr-labs/ecloud-sdk 0.2.0-dev → 0.2.0-dev.1
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 +19 -0
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +3 -2
- package/dist/billing.d.ts +3 -2
- package/dist/billing.js +2 -2
- package/dist/{chunk-34DXGQ35.js → chunk-FY7UU55U.js} +2 -2
- package/dist/chunk-FY7UU55U.js.map +1 -0
- package/dist/chunk-GB4GM4C2.js +434 -0
- package/dist/chunk-GB4GM4C2.js.map +1 -0
- package/dist/{chunk-HLH3AMQF.js → chunk-O7EU5JL7.js} +328 -123
- package/dist/chunk-O7EU5JL7.js.map +1 -0
- package/dist/{compute-B_ibIORD.d.cts → compute-CF2HOXed.d.ts} +101 -15
- package/dist/{compute-gpepEsn3.d.ts → compute-CbmjA8kJ.d.cts} +101 -15
- package/dist/compute.cjs +772 -62
- 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 +2 -2
- package/dist/{index-D-SUX3IG.d.ts → index-D2QufVB9.d.cts} +130 -6
- package/dist/{index-D-SUX3IG.d.cts → index-D2QufVB9.d.ts} +130 -6
- package/dist/index.cjs +646 -438
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -166
- package/dist/index.d.ts +52 -166
- package/dist/index.js +17 -243
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/chunk-34DXGQ35.js.map +0 -1
- package/dist/chunk-HLH3AMQF.js.map +0 -1
- package/dist/chunk-LINGJMAS.js +0 -180
- package/dist/chunk-LINGJMAS.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -131,6 +131,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
131
131
|
|
|
132
132
|
// src/client/modules/compute/app/index.ts
|
|
133
133
|
var import_viem9 = require("viem");
|
|
134
|
+
var import_accounts5 = require("viem/accounts");
|
|
134
135
|
|
|
135
136
|
// src/client/common/config/environment.ts
|
|
136
137
|
var SEPOLIA_CHAIN_ID = 11155111;
|
|
@@ -271,6 +272,7 @@ async function buildDockerImage(buildContext, dockerfilePath, tag, logger) {
|
|
|
271
272
|
tag,
|
|
272
273
|
"-f",
|
|
273
274
|
dockerfilePath,
|
|
275
|
+
"--load",
|
|
274
276
|
"--progress=plain",
|
|
275
277
|
buildContext
|
|
276
278
|
];
|
|
@@ -396,7 +398,7 @@ async function pullDockerImage(docker, imageTag, platform2 = "linux/amd64", logg
|
|
|
396
398
|
var child_process2 = __toESM(require("child_process"), 1);
|
|
397
399
|
var import_child_process = require("child_process");
|
|
398
400
|
var import_util2 = require("util");
|
|
399
|
-
var
|
|
401
|
+
var execFileAsync = (0, import_util2.promisify)(import_child_process.execFile);
|
|
400
402
|
async function pushDockerImage(docker, imageRef, logger) {
|
|
401
403
|
logger?.info?.(`Pushing image ${imageRef}...`);
|
|
402
404
|
return new Promise((resolve2, reject) => {
|
|
@@ -437,9 +439,9 @@ async function pushDockerImage(docker, imageRef, logger) {
|
|
|
437
439
|
if (!output.includes("digest:") && !output.includes("pushed") && !output.includes("Pushed")) {
|
|
438
440
|
logger?.debug?.("No clear success indicator in push output, verifying...");
|
|
439
441
|
}
|
|
440
|
-
logger?.info?.("Image push completed successfully");
|
|
441
442
|
try {
|
|
442
443
|
await verifyImageExists(imageRef, logger);
|
|
444
|
+
logger?.info?.("Image push completed successfully");
|
|
443
445
|
resolve2();
|
|
444
446
|
} catch (error) {
|
|
445
447
|
reject(error);
|
|
@@ -463,7 +465,7 @@ async function verifyImageExists(imageRef, logger) {
|
|
|
463
465
|
let retries = 5;
|
|
464
466
|
while (retries > 0) {
|
|
465
467
|
try {
|
|
466
|
-
await
|
|
468
|
+
await execFileAsync("docker", ["manifest", "inspect", imageRef], {
|
|
467
469
|
maxBuffer: 10 * 1024 * 1024,
|
|
468
470
|
timeout: 1e4
|
|
469
471
|
// 10 second timeout
|
|
@@ -937,10 +939,10 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
|
|
|
937
939
|
// src/client/common/registry/digest.ts
|
|
938
940
|
var child_process3 = __toESM(require("child_process"), 1);
|
|
939
941
|
var import_util3 = require("util");
|
|
940
|
-
var
|
|
942
|
+
var execFileAsync2 = (0, import_util3.promisify)(child_process3.execFile);
|
|
941
943
|
async function getImageDigestAndName(imageRef) {
|
|
942
944
|
try {
|
|
943
|
-
const { stdout } = await
|
|
945
|
+
const { stdout } = await execFileAsync2(
|
|
944
946
|
"docker",
|
|
945
947
|
["manifest", "inspect", imageRef],
|
|
946
948
|
{ maxBuffer: 10 * 1024 * 1024 }
|
|
@@ -980,7 +982,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
|
|
|
980
982
|
}
|
|
981
983
|
async function extractDigestFromSinglePlatform(manifest, imageRef) {
|
|
982
984
|
try {
|
|
983
|
-
const { stdout } = await
|
|
985
|
+
const { stdout } = await execFileAsync2("docker", ["inspect", imageRef], {
|
|
984
986
|
maxBuffer: 10 * 1024 * 1024
|
|
985
987
|
});
|
|
986
988
|
const inspectData = JSON.parse(stdout);
|
|
@@ -1297,7 +1299,10 @@ async function createReleaseFromImageDigest(options, logger) {
|
|
|
1297
1299
|
publicEnv["EIGEN_MACHINE_TYPE_PUBLIC"] = instanceType;
|
|
1298
1300
|
logger.info(`Instance type: ${instanceType}`);
|
|
1299
1301
|
logger.info("Encrypting environment variables...");
|
|
1300
|
-
const { encryptionKey } = getKMSKeysForEnvironment(
|
|
1302
|
+
const { encryptionKey } = getKMSKeysForEnvironment(
|
|
1303
|
+
environmentConfig.name,
|
|
1304
|
+
environmentConfig.build
|
|
1305
|
+
);
|
|
1301
1306
|
const protectedHeaders = getAppProtectedHeaders(appId);
|
|
1302
1307
|
const privateEnvBytes = Buffer.from(JSON.stringify(privateEnv));
|
|
1303
1308
|
const encryptedEnvStr = await encryptRSAOAEPAndAES256GCM(
|
|
@@ -2372,27 +2377,55 @@ var ERC7702Delegator_default = [
|
|
|
2372
2377
|
];
|
|
2373
2378
|
|
|
2374
2379
|
// src/client/common/contract/eip7702.ts
|
|
2380
|
+
var EXECUTE_BATCH_MODE = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
2381
|
+
var GAS_LIMIT_BUFFER_PERCENTAGE = 20n;
|
|
2382
|
+
var GAS_PRICE_BUFFER_PERCENTAGE = 100n;
|
|
2383
|
+
function encodeExecuteBatchData(executions) {
|
|
2384
|
+
const encodedExecutions = (0, import_viem.encodeAbiParameters)(
|
|
2385
|
+
[
|
|
2386
|
+
{
|
|
2387
|
+
type: "tuple[]",
|
|
2388
|
+
components: [
|
|
2389
|
+
{ name: "target", type: "address" },
|
|
2390
|
+
{ name: "value", type: "uint256" },
|
|
2391
|
+
{ name: "callData", type: "bytes" }
|
|
2392
|
+
]
|
|
2393
|
+
}
|
|
2394
|
+
],
|
|
2395
|
+
[executions]
|
|
2396
|
+
);
|
|
2397
|
+
return (0, import_viem.encodeFunctionData)({
|
|
2398
|
+
abi: ERC7702Delegator_default,
|
|
2399
|
+
functionName: "execute",
|
|
2400
|
+
args: [EXECUTE_BATCH_MODE, encodedExecutions]
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2375
2403
|
async function estimateBatchGas(options) {
|
|
2376
|
-
const { publicClient, executions } = options;
|
|
2377
|
-
const
|
|
2378
|
-
const
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2404
|
+
const { publicClient, account, executions } = options;
|
|
2405
|
+
const executeBatchData = encodeExecuteBatchData(executions);
|
|
2406
|
+
const [gasTipCap, block, estimatedGas] = await Promise.all([
|
|
2407
|
+
publicClient.estimateMaxPriorityFeePerGas(),
|
|
2408
|
+
publicClient.getBlock(),
|
|
2409
|
+
publicClient.estimateGas({
|
|
2410
|
+
account,
|
|
2411
|
+
to: account,
|
|
2412
|
+
data: executeBatchData
|
|
2413
|
+
})
|
|
2414
|
+
]);
|
|
2415
|
+
const baseFee = block.baseFeePerGas ?? 0n;
|
|
2416
|
+
const maxFeePerGas = (baseFee + gasTipCap) * (100n + GAS_PRICE_BUFFER_PERCENTAGE) / 100n;
|
|
2417
|
+
const gasLimit = estimatedGas * (100n + GAS_LIMIT_BUFFER_PERCENTAGE) / 100n;
|
|
2384
2418
|
const maxCostWei = gasLimit * maxFeePerGas;
|
|
2385
|
-
const maxCostEth = formatETH(maxCostWei);
|
|
2386
2419
|
return {
|
|
2387
2420
|
gasLimit,
|
|
2388
2421
|
maxFeePerGas,
|
|
2389
|
-
maxPriorityFeePerGas,
|
|
2422
|
+
maxPriorityFeePerGas: gasTipCap,
|
|
2390
2423
|
maxCostWei,
|
|
2391
|
-
maxCostEth
|
|
2424
|
+
maxCostEth: formatETH(maxCostWei)
|
|
2392
2425
|
};
|
|
2393
2426
|
}
|
|
2394
2427
|
async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
|
|
2395
|
-
const code = await publicClient.
|
|
2428
|
+
const code = await publicClient.getCode({ address: account });
|
|
2396
2429
|
if (!code) {
|
|
2397
2430
|
return false;
|
|
2398
2431
|
}
|
|
@@ -2409,36 +2442,7 @@ async function executeBatch(options, logger) {
|
|
|
2409
2442
|
if (!chain) {
|
|
2410
2443
|
throw new Error("Wallet client must have a chain");
|
|
2411
2444
|
}
|
|
2412
|
-
const
|
|
2413
|
-
[
|
|
2414
|
-
{
|
|
2415
|
-
type: "tuple[]",
|
|
2416
|
-
components: [
|
|
2417
|
-
{ name: "target", type: "address" },
|
|
2418
|
-
{ name: "value", type: "uint256" },
|
|
2419
|
-
{ name: "callData", type: "bytes" }
|
|
2420
|
-
]
|
|
2421
|
-
}
|
|
2422
|
-
],
|
|
2423
|
-
[executions]
|
|
2424
|
-
);
|
|
2425
|
-
const executeBatchMode = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
2426
|
-
let executeBatchData;
|
|
2427
|
-
try {
|
|
2428
|
-
executeBatchData = (0, import_viem.encodeFunctionData)({
|
|
2429
|
-
abi: ERC7702Delegator_default,
|
|
2430
|
-
functionName: "execute",
|
|
2431
|
-
args: [executeBatchMode, encodedExecutions]
|
|
2432
|
-
});
|
|
2433
|
-
} catch {
|
|
2434
|
-
const functionSignature = "execute(bytes32,bytes)";
|
|
2435
|
-
const selector = (0, import_viem.keccak256)((0, import_viem.toBytes)(functionSignature)).slice(0, 10);
|
|
2436
|
-
const encodedParams = (0, import_viem.encodeAbiParameters)(
|
|
2437
|
-
[{ type: "bytes32" }, { type: "bytes" }],
|
|
2438
|
-
[executeBatchMode, encodedExecutions]
|
|
2439
|
-
);
|
|
2440
|
-
executeBatchData = (0, import_viem.concat)([selector, encodedParams]);
|
|
2441
|
-
}
|
|
2445
|
+
const executeBatchData = encodeExecuteBatchData(executions);
|
|
2442
2446
|
const isDelegated2 = await checkERC7702Delegation(
|
|
2443
2447
|
publicClient,
|
|
2444
2448
|
account.address,
|
|
@@ -2608,7 +2612,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
|
2608
2612
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
2609
2613
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
2610
2614
|
function getDefaultClientId() {
|
|
2611
|
-
const version = true ? "0.2.0-dev" : "0.0.0";
|
|
2615
|
+
const version = true ? "0.2.0-dev.1" : "0.0.0";
|
|
2612
2616
|
return `ecloud-sdk/v${version}`;
|
|
2613
2617
|
}
|
|
2614
2618
|
var UserApiClient = class {
|
|
@@ -4573,20 +4577,20 @@ async function prepareDeployBatch(options, logger) {
|
|
|
4573
4577
|
environmentConfig
|
|
4574
4578
|
};
|
|
4575
4579
|
}
|
|
4576
|
-
async function executeDeployBatch(
|
|
4580
|
+
async function executeDeployBatch(data, context, gas, logger) {
|
|
4577
4581
|
const pendingMessage = "Deploying new app...";
|
|
4578
4582
|
const txHash = await executeBatch(
|
|
4579
4583
|
{
|
|
4580
|
-
walletClient:
|
|
4581
|
-
publicClient:
|
|
4582
|
-
environmentConfig:
|
|
4583
|
-
executions:
|
|
4584
|
+
walletClient: context.walletClient,
|
|
4585
|
+
publicClient: context.publicClient,
|
|
4586
|
+
environmentConfig: context.environmentConfig,
|
|
4587
|
+
executions: data.executions,
|
|
4584
4588
|
pendingMessage,
|
|
4585
4589
|
gas
|
|
4586
4590
|
},
|
|
4587
4591
|
logger
|
|
4588
4592
|
);
|
|
4589
|
-
return { appId:
|
|
4593
|
+
return { appId: data.appId, txHash };
|
|
4590
4594
|
}
|
|
4591
4595
|
async function deployApp(options, logger) {
|
|
4592
4596
|
const prepared = await prepareDeployBatch(
|
|
@@ -4600,7 +4604,17 @@ async function deployApp(options, logger) {
|
|
|
4600
4604
|
},
|
|
4601
4605
|
logger
|
|
4602
4606
|
);
|
|
4603
|
-
|
|
4607
|
+
const data = {
|
|
4608
|
+
appId: prepared.appId,
|
|
4609
|
+
salt: prepared.salt,
|
|
4610
|
+
executions: prepared.executions
|
|
4611
|
+
};
|
|
4612
|
+
const context = {
|
|
4613
|
+
walletClient: prepared.walletClient,
|
|
4614
|
+
publicClient: prepared.publicClient,
|
|
4615
|
+
environmentConfig: prepared.environmentConfig
|
|
4616
|
+
};
|
|
4617
|
+
return executeDeployBatch(data, context, options.gas, logger);
|
|
4604
4618
|
}
|
|
4605
4619
|
async function prepareUpgradeBatch(options) {
|
|
4606
4620
|
const {
|
|
@@ -4696,14 +4710,14 @@ async function prepareUpgradeBatch(options) {
|
|
|
4696
4710
|
environmentConfig
|
|
4697
4711
|
};
|
|
4698
4712
|
}
|
|
4699
|
-
async function executeUpgradeBatch(
|
|
4700
|
-
const pendingMessage = `Upgrading app ${
|
|
4713
|
+
async function executeUpgradeBatch(data, context, gas, logger) {
|
|
4714
|
+
const pendingMessage = `Upgrading app ${data.appId}...`;
|
|
4701
4715
|
const txHash = await executeBatch(
|
|
4702
4716
|
{
|
|
4703
|
-
walletClient:
|
|
4704
|
-
publicClient:
|
|
4705
|
-
environmentConfig:
|
|
4706
|
-
executions:
|
|
4717
|
+
walletClient: context.walletClient,
|
|
4718
|
+
publicClient: context.publicClient,
|
|
4719
|
+
environmentConfig: context.environmentConfig,
|
|
4720
|
+
executions: data.executions,
|
|
4707
4721
|
pendingMessage,
|
|
4708
4722
|
gas
|
|
4709
4723
|
},
|
|
@@ -4721,7 +4735,16 @@ async function upgradeApp(options, logger) {
|
|
|
4721
4735
|
publicLogs: options.publicLogs,
|
|
4722
4736
|
needsPermissionChange: options.needsPermissionChange
|
|
4723
4737
|
});
|
|
4724
|
-
|
|
4738
|
+
const data = {
|
|
4739
|
+
appId: prepared.appId,
|
|
4740
|
+
executions: prepared.executions
|
|
4741
|
+
};
|
|
4742
|
+
const context = {
|
|
4743
|
+
walletClient: prepared.walletClient,
|
|
4744
|
+
publicClient: prepared.publicClient,
|
|
4745
|
+
environmentConfig: prepared.environmentConfig
|
|
4746
|
+
};
|
|
4747
|
+
return executeUpgradeBatch(data, context, options.gas, logger);
|
|
4725
4748
|
}
|
|
4726
4749
|
async function sendAndWaitForTransaction(options, logger) {
|
|
4727
4750
|
const {
|
|
@@ -5700,7 +5723,9 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
|
|
|
5700
5723
|
validateAppName(options.appName);
|
|
5701
5724
|
validateLogVisibility(options.logVisibility);
|
|
5702
5725
|
if (!/^sha256:[0-9a-f]{64}$/i.test(options.imageDigest)) {
|
|
5703
|
-
throw new Error(
|
|
5726
|
+
throw new Error(
|
|
5727
|
+
`imageDigest must be in format sha256:<64 hex>, got: ${options.imageDigest}`
|
|
5728
|
+
);
|
|
5704
5729
|
}
|
|
5705
5730
|
const { publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5706
5731
|
validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
@@ -5753,19 +5778,19 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
|
|
|
5753
5778
|
logger.debug("Estimating gas...");
|
|
5754
5779
|
const gasEstimate = await estimateBatchGas({
|
|
5755
5780
|
publicClient: batch.publicClient,
|
|
5756
|
-
|
|
5781
|
+
account: batch.walletClient.account.address,
|
|
5757
5782
|
executions: batch.executions
|
|
5758
5783
|
});
|
|
5784
|
+
const data = {
|
|
5785
|
+
appId: batch.appId,
|
|
5786
|
+
salt: batch.salt,
|
|
5787
|
+
executions: batch.executions
|
|
5788
|
+
};
|
|
5759
5789
|
return {
|
|
5760
5790
|
prepared: {
|
|
5761
|
-
|
|
5791
|
+
data,
|
|
5762
5792
|
appName: options.appName,
|
|
5763
|
-
imageRef: options.imageRef
|
|
5764
|
-
preflightCtx: {
|
|
5765
|
-
privateKey: preflightCtx.privateKey,
|
|
5766
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
5767
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
5768
|
-
}
|
|
5793
|
+
imageRef: options.imageRef
|
|
5769
5794
|
},
|
|
5770
5795
|
gasEstimate
|
|
5771
5796
|
};
|
|
@@ -5992,26 +6017,27 @@ async function prepareDeploy(options, logger = defaultLogger) {
|
|
|
5992
6017
|
logger.debug("Estimating gas...");
|
|
5993
6018
|
const gasEstimate = await estimateBatchGas({
|
|
5994
6019
|
publicClient: batch.publicClient,
|
|
5995
|
-
|
|
6020
|
+
account: batch.walletClient.account.address,
|
|
5996
6021
|
executions: batch.executions
|
|
5997
6022
|
});
|
|
6023
|
+
const data = {
|
|
6024
|
+
appId: batch.appId,
|
|
6025
|
+
salt: batch.salt,
|
|
6026
|
+
executions: batch.executions
|
|
6027
|
+
};
|
|
5998
6028
|
return {
|
|
5999
6029
|
prepared: {
|
|
6000
|
-
|
|
6030
|
+
data,
|
|
6001
6031
|
appName,
|
|
6002
|
-
imageRef: finalImageRef
|
|
6003
|
-
preflightCtx: {
|
|
6004
|
-
privateKey: preflightCtx.privateKey,
|
|
6005
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
6006
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
6007
|
-
}
|
|
6032
|
+
imageRef: finalImageRef
|
|
6008
6033
|
},
|
|
6009
6034
|
gasEstimate
|
|
6010
6035
|
};
|
|
6011
6036
|
}
|
|
6012
6037
|
);
|
|
6013
6038
|
}
|
|
6014
|
-
async function executeDeploy(
|
|
6039
|
+
async function executeDeploy(options) {
|
|
6040
|
+
const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
|
|
6015
6041
|
return withSDKTelemetry(
|
|
6016
6042
|
{
|
|
6017
6043
|
functionName: "executeDeploy",
|
|
@@ -6019,7 +6045,7 @@ async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetr
|
|
|
6019
6045
|
},
|
|
6020
6046
|
async () => {
|
|
6021
6047
|
logger.info("Deploying on-chain...");
|
|
6022
|
-
const { appId, txHash } = await executeDeployBatch(prepared.
|
|
6048
|
+
const { appId, txHash } = await executeDeployBatch(prepared.data, context, gas, logger);
|
|
6023
6049
|
return {
|
|
6024
6050
|
appId,
|
|
6025
6051
|
txHash,
|
|
@@ -6138,19 +6164,18 @@ async function prepareUpgradeFromVerifiableBuild(options, logger = defaultLogger
|
|
|
6138
6164
|
logger.debug("Estimating gas...");
|
|
6139
6165
|
const gasEstimate = await estimateBatchGas({
|
|
6140
6166
|
publicClient: batch.publicClient,
|
|
6141
|
-
|
|
6167
|
+
account: batch.walletClient.account.address,
|
|
6142
6168
|
executions: batch.executions
|
|
6143
6169
|
});
|
|
6170
|
+
const data = {
|
|
6171
|
+
appId: batch.appId,
|
|
6172
|
+
executions: batch.executions
|
|
6173
|
+
};
|
|
6144
6174
|
return {
|
|
6145
6175
|
prepared: {
|
|
6146
|
-
|
|
6176
|
+
data,
|
|
6147
6177
|
appId: appID,
|
|
6148
|
-
imageRef: options.imageRef
|
|
6149
|
-
preflightCtx: {
|
|
6150
|
-
privateKey: preflightCtx.privateKey,
|
|
6151
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
6152
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
6153
|
-
}
|
|
6178
|
+
imageRef: options.imageRef
|
|
6154
6179
|
},
|
|
6155
6180
|
gasEstimate
|
|
6156
6181
|
};
|
|
@@ -6319,26 +6344,26 @@ async function prepareUpgrade(options, logger = defaultLogger) {
|
|
|
6319
6344
|
logger.debug("Estimating gas...");
|
|
6320
6345
|
const gasEstimate = await estimateBatchGas({
|
|
6321
6346
|
publicClient: batch.publicClient,
|
|
6322
|
-
|
|
6347
|
+
account: batch.walletClient.account.address,
|
|
6323
6348
|
executions: batch.executions
|
|
6324
6349
|
});
|
|
6350
|
+
const data = {
|
|
6351
|
+
appId: batch.appId,
|
|
6352
|
+
executions: batch.executions
|
|
6353
|
+
};
|
|
6325
6354
|
return {
|
|
6326
6355
|
prepared: {
|
|
6327
|
-
|
|
6356
|
+
data,
|
|
6328
6357
|
appId: appID,
|
|
6329
|
-
imageRef: finalImageRef
|
|
6330
|
-
preflightCtx: {
|
|
6331
|
-
privateKey: preflightCtx.privateKey,
|
|
6332
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
6333
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
6334
|
-
}
|
|
6358
|
+
imageRef: finalImageRef
|
|
6335
6359
|
},
|
|
6336
6360
|
gasEstimate
|
|
6337
6361
|
};
|
|
6338
6362
|
}
|
|
6339
6363
|
);
|
|
6340
6364
|
}
|
|
6341
|
-
async function executeUpgrade(
|
|
6365
|
+
async function executeUpgrade(options) {
|
|
6366
|
+
const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
|
|
6342
6367
|
return withSDKTelemetry(
|
|
6343
6368
|
{
|
|
6344
6369
|
functionName: "executeUpgrade",
|
|
@@ -6346,7 +6371,7 @@ async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemet
|
|
|
6346
6371
|
},
|
|
6347
6372
|
async () => {
|
|
6348
6373
|
logger.info("Upgrading on-chain...");
|
|
6349
|
-
const txHash = await executeUpgradeBatch(prepared.
|
|
6374
|
+
const txHash = await executeUpgradeBatch(prepared.data, context, gas, logger);
|
|
6350
6375
|
return {
|
|
6351
6376
|
appId: prepared.appId,
|
|
6352
6377
|
imageRef: prepared.imageRef,
|
|
@@ -6477,8 +6502,8 @@ var path5 = __toESM(require("path"), 1);
|
|
|
6477
6502
|
var os3 = __toESM(require("os"), 1);
|
|
6478
6503
|
var import_child_process2 = require("child_process");
|
|
6479
6504
|
var import_util4 = require("util");
|
|
6480
|
-
var
|
|
6481
|
-
var
|
|
6505
|
+
var execAsync = (0, import_util4.promisify)(import_child_process2.exec);
|
|
6506
|
+
var execFileAsync3 = (0, import_util4.promisify)(import_child_process2.execFile);
|
|
6482
6507
|
async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
|
|
6483
6508
|
if (!repoURL) {
|
|
6484
6509
|
throw new Error("repoURL is required");
|
|
@@ -6487,13 +6512,13 @@ async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
|
|
|
6487
6512
|
Cloning repo: ${repoURL} \u2192 ${targetDir}
|
|
6488
6513
|
`);
|
|
6489
6514
|
try {
|
|
6490
|
-
await
|
|
6515
|
+
await execAsync(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
|
|
6491
6516
|
maxBuffer: 10 * 1024 * 1024
|
|
6492
6517
|
});
|
|
6493
|
-
await
|
|
6518
|
+
await execFileAsync3("git", ["-C", targetDir, "checkout", "--quiet", ref], {
|
|
6494
6519
|
maxBuffer: 10 * 1024 * 1024
|
|
6495
6520
|
});
|
|
6496
|
-
await
|
|
6521
|
+
await execFileAsync3(
|
|
6497
6522
|
"git",
|
|
6498
6523
|
["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
|
|
6499
6524
|
{ maxBuffer: 10 * 1024 * 1024 }
|
|
@@ -6538,14 +6563,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
|
|
|
6538
6563
|
}
|
|
6539
6564
|
async function cloneSparse(repoURL, ref, subPath, tempDir) {
|
|
6540
6565
|
try {
|
|
6541
|
-
await
|
|
6542
|
-
await
|
|
6543
|
-
await
|
|
6566
|
+
await execFileAsync3("git", ["init", tempDir]);
|
|
6567
|
+
await execFileAsync3("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
|
|
6568
|
+
await execFileAsync3("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
|
|
6544
6569
|
const sparseCheckoutPath = path5.join(tempDir, ".git/info/sparse-checkout");
|
|
6545
6570
|
fs5.writeFileSync(sparseCheckoutPath, `${subPath}
|
|
6546
6571
|
`);
|
|
6547
|
-
await
|
|
6548
|
-
await
|
|
6572
|
+
await execFileAsync3("git", ["-C", tempDir, "fetch", "origin", ref]);
|
|
6573
|
+
await execFileAsync3("git", ["-C", tempDir, "checkout", ref]);
|
|
6549
6574
|
} catch (error) {
|
|
6550
6575
|
throw new Error(`Failed to clone sparse repository: ${error.message}`);
|
|
6551
6576
|
}
|
|
@@ -7120,6 +7145,187 @@ function createAppModule(ctx) {
|
|
|
7120
7145
|
imageRef: result.imageRef
|
|
7121
7146
|
};
|
|
7122
7147
|
},
|
|
7148
|
+
// Granular deploy control
|
|
7149
|
+
async prepareDeploy(opts) {
|
|
7150
|
+
return prepareDeploy(
|
|
7151
|
+
{
|
|
7152
|
+
privateKey,
|
|
7153
|
+
rpcUrl: ctx.rpcUrl,
|
|
7154
|
+
environment: ctx.environment,
|
|
7155
|
+
appName: opts.name,
|
|
7156
|
+
instanceType: opts.instanceType,
|
|
7157
|
+
dockerfilePath: opts.dockerfile,
|
|
7158
|
+
envFilePath: opts.envFile,
|
|
7159
|
+
imageRef: opts.imageRef,
|
|
7160
|
+
logVisibility: opts.logVisibility,
|
|
7161
|
+
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
7162
|
+
skipTelemetry
|
|
7163
|
+
},
|
|
7164
|
+
logger
|
|
7165
|
+
);
|
|
7166
|
+
},
|
|
7167
|
+
async prepareDeployFromVerifiableBuild(opts) {
|
|
7168
|
+
return prepareDeployFromVerifiableBuild(
|
|
7169
|
+
{
|
|
7170
|
+
privateKey,
|
|
7171
|
+
rpcUrl: ctx.rpcUrl,
|
|
7172
|
+
environment: ctx.environment,
|
|
7173
|
+
appName: opts.name,
|
|
7174
|
+
instanceType: opts.instanceType,
|
|
7175
|
+
envFilePath: opts.envFile,
|
|
7176
|
+
imageRef: opts.imageRef,
|
|
7177
|
+
imageDigest: opts.imageDigest,
|
|
7178
|
+
logVisibility: opts.logVisibility,
|
|
7179
|
+
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
7180
|
+
skipTelemetry
|
|
7181
|
+
},
|
|
7182
|
+
logger
|
|
7183
|
+
);
|
|
7184
|
+
},
|
|
7185
|
+
async executeDeploy(prepared, gas) {
|
|
7186
|
+
const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
|
|
7187
|
+
const chain = getChainFromID(environment.chainID);
|
|
7188
|
+
const publicClient = (0, import_viem9.createPublicClient)({
|
|
7189
|
+
chain,
|
|
7190
|
+
transport: (0, import_viem9.http)(ctx.rpcUrl)
|
|
7191
|
+
});
|
|
7192
|
+
const walletClient = (0, import_viem9.createWalletClient)({
|
|
7193
|
+
account,
|
|
7194
|
+
chain,
|
|
7195
|
+
transport: (0, import_viem9.http)(ctx.rpcUrl)
|
|
7196
|
+
});
|
|
7197
|
+
const result = await executeDeploy({
|
|
7198
|
+
prepared,
|
|
7199
|
+
context: {
|
|
7200
|
+
walletClient,
|
|
7201
|
+
publicClient,
|
|
7202
|
+
environmentConfig: environment
|
|
7203
|
+
},
|
|
7204
|
+
gas,
|
|
7205
|
+
logger,
|
|
7206
|
+
skipTelemetry
|
|
7207
|
+
});
|
|
7208
|
+
return {
|
|
7209
|
+
appId: result.appId,
|
|
7210
|
+
txHash: result.txHash,
|
|
7211
|
+
appName: result.appName,
|
|
7212
|
+
imageRef: result.imageRef
|
|
7213
|
+
};
|
|
7214
|
+
},
|
|
7215
|
+
async watchDeployment(appId) {
|
|
7216
|
+
return watchDeployment(
|
|
7217
|
+
appId,
|
|
7218
|
+
privateKey,
|
|
7219
|
+
ctx.rpcUrl,
|
|
7220
|
+
ctx.environment,
|
|
7221
|
+
logger,
|
|
7222
|
+
ctx.clientId,
|
|
7223
|
+
skipTelemetry
|
|
7224
|
+
);
|
|
7225
|
+
},
|
|
7226
|
+
// Granular upgrade control
|
|
7227
|
+
async prepareUpgrade(appId, opts) {
|
|
7228
|
+
return prepareUpgrade(
|
|
7229
|
+
{
|
|
7230
|
+
appId,
|
|
7231
|
+
privateKey,
|
|
7232
|
+
rpcUrl: ctx.rpcUrl,
|
|
7233
|
+
environment: ctx.environment,
|
|
7234
|
+
instanceType: opts.instanceType,
|
|
7235
|
+
dockerfilePath: opts.dockerfile,
|
|
7236
|
+
envFilePath: opts.envFile,
|
|
7237
|
+
imageRef: opts.imageRef,
|
|
7238
|
+
logVisibility: opts.logVisibility,
|
|
7239
|
+
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
7240
|
+
skipTelemetry
|
|
7241
|
+
},
|
|
7242
|
+
logger
|
|
7243
|
+
);
|
|
7244
|
+
},
|
|
7245
|
+
async prepareUpgradeFromVerifiableBuild(appId, opts) {
|
|
7246
|
+
return prepareUpgradeFromVerifiableBuild(
|
|
7247
|
+
{
|
|
7248
|
+
appId,
|
|
7249
|
+
privateKey,
|
|
7250
|
+
rpcUrl: ctx.rpcUrl,
|
|
7251
|
+
environment: ctx.environment,
|
|
7252
|
+
instanceType: opts.instanceType,
|
|
7253
|
+
envFilePath: opts.envFile,
|
|
7254
|
+
imageRef: opts.imageRef,
|
|
7255
|
+
imageDigest: opts.imageDigest,
|
|
7256
|
+
logVisibility: opts.logVisibility,
|
|
7257
|
+
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
7258
|
+
skipTelemetry
|
|
7259
|
+
},
|
|
7260
|
+
logger
|
|
7261
|
+
);
|
|
7262
|
+
},
|
|
7263
|
+
async executeUpgrade(prepared, gas) {
|
|
7264
|
+
const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
|
|
7265
|
+
const chain = getChainFromID(environment.chainID);
|
|
7266
|
+
const publicClient = (0, import_viem9.createPublicClient)({
|
|
7267
|
+
chain,
|
|
7268
|
+
transport: (0, import_viem9.http)(ctx.rpcUrl)
|
|
7269
|
+
});
|
|
7270
|
+
const walletClient = (0, import_viem9.createWalletClient)({
|
|
7271
|
+
account,
|
|
7272
|
+
chain,
|
|
7273
|
+
transport: (0, import_viem9.http)(ctx.rpcUrl)
|
|
7274
|
+
});
|
|
7275
|
+
const result = await executeUpgrade({
|
|
7276
|
+
prepared,
|
|
7277
|
+
context: {
|
|
7278
|
+
walletClient,
|
|
7279
|
+
publicClient,
|
|
7280
|
+
environmentConfig: environment
|
|
7281
|
+
},
|
|
7282
|
+
gas,
|
|
7283
|
+
logger,
|
|
7284
|
+
skipTelemetry
|
|
7285
|
+
});
|
|
7286
|
+
return {
|
|
7287
|
+
appId: result.appId,
|
|
7288
|
+
txHash: result.txHash,
|
|
7289
|
+
imageRef: result.imageRef
|
|
7290
|
+
};
|
|
7291
|
+
},
|
|
7292
|
+
async watchUpgrade(appId) {
|
|
7293
|
+
return watchUpgrade(
|
|
7294
|
+
appId,
|
|
7295
|
+
privateKey,
|
|
7296
|
+
ctx.rpcUrl,
|
|
7297
|
+
ctx.environment,
|
|
7298
|
+
logger,
|
|
7299
|
+
ctx.clientId,
|
|
7300
|
+
skipTelemetry
|
|
7301
|
+
);
|
|
7302
|
+
},
|
|
7303
|
+
// Profile management
|
|
7304
|
+
async setProfile(appId, profile) {
|
|
7305
|
+
return withSDKTelemetry(
|
|
7306
|
+
{
|
|
7307
|
+
functionName: "setProfile",
|
|
7308
|
+
skipTelemetry,
|
|
7309
|
+
properties: { environment: ctx.environment }
|
|
7310
|
+
},
|
|
7311
|
+
async () => {
|
|
7312
|
+
const userApiClient = new UserApiClient(
|
|
7313
|
+
environment,
|
|
7314
|
+
privateKey,
|
|
7315
|
+
ctx.rpcUrl,
|
|
7316
|
+
ctx.clientId
|
|
7317
|
+
);
|
|
7318
|
+
return userApiClient.uploadAppProfile(
|
|
7319
|
+
appId,
|
|
7320
|
+
profile.name,
|
|
7321
|
+
profile.website,
|
|
7322
|
+
profile.description,
|
|
7323
|
+
profile.xURL,
|
|
7324
|
+
profile.imagePath
|
|
7325
|
+
);
|
|
7326
|
+
}
|
|
7327
|
+
);
|
|
7328
|
+
},
|
|
7123
7329
|
async logs(opts) {
|
|
7124
7330
|
return logs(
|
|
7125
7331
|
{
|
|
@@ -7270,10 +7476,10 @@ function createComputeModule(config) {
|
|
|
7270
7476
|
|
|
7271
7477
|
// src/client/common/utils/billingapi.ts
|
|
7272
7478
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
7273
|
-
var
|
|
7479
|
+
var import_accounts6 = require("viem/accounts");
|
|
7274
7480
|
var BillingApiClient = class {
|
|
7275
7481
|
constructor(config, privateKey) {
|
|
7276
|
-
this.account = (0,
|
|
7482
|
+
this.account = (0, import_accounts6.privateKeyToAccount)(privateKey);
|
|
7277
7483
|
this.config = config;
|
|
7278
7484
|
}
|
|
7279
7485
|
async createSubscription(productId = "compute") {
|
|
@@ -7341,90 +7547,331 @@ Please check:
|
|
|
7341
7547
|
}
|
|
7342
7548
|
};
|
|
7343
7549
|
|
|
7344
|
-
// src/client/
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7550
|
+
// src/client/common/auth/keyring.ts
|
|
7551
|
+
var import_keyring = require("@napi-rs/keyring");
|
|
7552
|
+
var import_accounts7 = require("viem/accounts");
|
|
7553
|
+
var SERVICE_NAME = "ecloud";
|
|
7554
|
+
var ACCOUNT_NAME = "key";
|
|
7555
|
+
var EIGENX_SERVICE_NAME = "eigenx-cli";
|
|
7556
|
+
var EIGENX_DEV_SERVICE_NAME = "eigenx-cli-dev";
|
|
7557
|
+
var EIGENX_ACCOUNT_PREFIX = "eigenx-";
|
|
7558
|
+
var GO_KEYRING_BASE64_PREFIX = "go-keyring-base64:";
|
|
7559
|
+
var GO_KEYRING_ENCODED_PREFIX = "go-keyring-encoded:";
|
|
7560
|
+
async function storePrivateKey(privateKey) {
|
|
7561
|
+
const normalizedKey = normalizePrivateKey(privateKey);
|
|
7562
|
+
const isValid = validatePrivateKey2(normalizedKey);
|
|
7563
|
+
if (!isValid) {
|
|
7564
|
+
throw new Error("Invalid private key format");
|
|
7565
|
+
}
|
|
7566
|
+
const entry = new import_keyring.AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);
|
|
7567
|
+
try {
|
|
7568
|
+
await entry.setPassword(normalizedKey);
|
|
7569
|
+
} catch (err) {
|
|
7570
|
+
throw new Error(
|
|
7571
|
+
`Failed to store key in OS keyring: ${err?.message ?? err}. Ensure keyring service is available.`
|
|
7572
|
+
);
|
|
7573
|
+
}
|
|
7574
|
+
}
|
|
7575
|
+
async function getPrivateKey() {
|
|
7576
|
+
const entry = new import_keyring.AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);
|
|
7577
|
+
try {
|
|
7578
|
+
const key = await entry.getPassword();
|
|
7579
|
+
if (key && validatePrivateKey2(key)) {
|
|
7580
|
+
return key;
|
|
7581
|
+
}
|
|
7582
|
+
} catch {
|
|
7583
|
+
}
|
|
7584
|
+
return null;
|
|
7585
|
+
}
|
|
7586
|
+
async function deletePrivateKey() {
|
|
7587
|
+
const entry = new import_keyring.AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);
|
|
7588
|
+
try {
|
|
7589
|
+
await entry.deletePassword();
|
|
7590
|
+
return true;
|
|
7591
|
+
} catch {
|
|
7592
|
+
console.warn("No key found in keyring");
|
|
7593
|
+
return false;
|
|
7594
|
+
}
|
|
7595
|
+
}
|
|
7596
|
+
async function listStoredKeys() {
|
|
7597
|
+
const keys = [];
|
|
7598
|
+
const creds = (0, import_keyring.findCredentials)(SERVICE_NAME);
|
|
7599
|
+
for (const cred of creds) {
|
|
7600
|
+
if (cred.account === ACCOUNT_NAME) {
|
|
7601
|
+
try {
|
|
7602
|
+
const address = getAddressFromPrivateKey(cred.password);
|
|
7603
|
+
keys.push({ address });
|
|
7604
|
+
} catch (err) {
|
|
7605
|
+
console.warn(`Warning: Invalid key found, skipping: ${err}`);
|
|
7606
|
+
}
|
|
7607
|
+
}
|
|
7608
|
+
}
|
|
7609
|
+
return keys;
|
|
7610
|
+
}
|
|
7611
|
+
async function keyExists() {
|
|
7612
|
+
const key = await getPrivateKey();
|
|
7613
|
+
return key !== null;
|
|
7614
|
+
}
|
|
7615
|
+
async function getLegacyKeys() {
|
|
7616
|
+
const keys = [];
|
|
7617
|
+
try {
|
|
7618
|
+
const eigenxCreds = (0, import_keyring.findCredentials)(EIGENX_SERVICE_NAME);
|
|
7619
|
+
for (const cred of eigenxCreds) {
|
|
7620
|
+
const accountName = cred.account;
|
|
7621
|
+
if (!accountName.startsWith(EIGENX_ACCOUNT_PREFIX)) {
|
|
7622
|
+
continue;
|
|
7623
|
+
}
|
|
7624
|
+
const environment = accountName.substring(EIGENX_ACCOUNT_PREFIX.length);
|
|
7625
|
+
try {
|
|
7626
|
+
const decodedKey = decodeGoKeyringValue(cred.password);
|
|
7627
|
+
const address = getAddressFromPrivateKey(decodedKey);
|
|
7628
|
+
keys.push({ environment, address, source: "eigenx" });
|
|
7629
|
+
} catch (err) {
|
|
7630
|
+
console.warn(
|
|
7631
|
+
`Warning: Invalid key found for ${environment} (eigenx-cli), skipping: ${err}`
|
|
7632
|
+
);
|
|
7633
|
+
}
|
|
7634
|
+
}
|
|
7635
|
+
} catch {
|
|
7636
|
+
}
|
|
7637
|
+
try {
|
|
7638
|
+
const eigenxDevCreds = (0, import_keyring.findCredentials)(EIGENX_DEV_SERVICE_NAME);
|
|
7639
|
+
for (const cred of eigenxDevCreds) {
|
|
7640
|
+
const accountName = cred.account;
|
|
7641
|
+
if (!accountName.startsWith(EIGENX_ACCOUNT_PREFIX)) {
|
|
7642
|
+
continue;
|
|
7643
|
+
}
|
|
7644
|
+
const environment = accountName.substring(EIGENX_ACCOUNT_PREFIX.length);
|
|
7645
|
+
try {
|
|
7646
|
+
const decodedKey = decodeGoKeyringValue(cred.password);
|
|
7647
|
+
const address = getAddressFromPrivateKey(decodedKey);
|
|
7648
|
+
keys.push({ environment, address, source: "eigenx-dev" });
|
|
7649
|
+
} catch (err) {
|
|
7650
|
+
console.warn(
|
|
7651
|
+
`Warning: Invalid key found for ${environment} (eigenx-dev), skipping: ${err}`
|
|
7652
|
+
);
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
} catch {
|
|
7656
|
+
}
|
|
7657
|
+
return keys;
|
|
7658
|
+
}
|
|
7659
|
+
async function getLegacyPrivateKey(environment, source) {
|
|
7660
|
+
const serviceName = source === "eigenx" ? EIGENX_SERVICE_NAME : EIGENX_DEV_SERVICE_NAME;
|
|
7661
|
+
const accountName = EIGENX_ACCOUNT_PREFIX + environment;
|
|
7662
|
+
const entry = new import_keyring.AsyncEntry(serviceName, accountName);
|
|
7663
|
+
try {
|
|
7664
|
+
const rawKey = await entry.getPassword();
|
|
7665
|
+
if (rawKey) {
|
|
7666
|
+
const decodedKey = decodeGoKeyringValue(rawKey);
|
|
7667
|
+
if (validatePrivateKey2(decodedKey)) {
|
|
7668
|
+
return decodedKey;
|
|
7669
|
+
}
|
|
7670
|
+
}
|
|
7671
|
+
} catch {
|
|
7672
|
+
}
|
|
7673
|
+
return null;
|
|
7674
|
+
}
|
|
7675
|
+
async function deleteLegacyPrivateKey(environment, source) {
|
|
7676
|
+
const serviceName = source === "eigenx" ? EIGENX_SERVICE_NAME : EIGENX_DEV_SERVICE_NAME;
|
|
7677
|
+
const accountName = EIGENX_ACCOUNT_PREFIX + environment;
|
|
7678
|
+
const entry = new import_keyring.AsyncEntry(serviceName, accountName);
|
|
7679
|
+
try {
|
|
7680
|
+
await entry.deletePassword();
|
|
7681
|
+
return true;
|
|
7682
|
+
} catch {
|
|
7683
|
+
console.warn(`No key found for ${environment} in ${source}`);
|
|
7684
|
+
return false;
|
|
7685
|
+
}
|
|
7686
|
+
}
|
|
7687
|
+
function validatePrivateKey2(privateKey) {
|
|
7688
|
+
try {
|
|
7689
|
+
getAddressFromPrivateKey(privateKey);
|
|
7690
|
+
return true;
|
|
7691
|
+
} catch {
|
|
7692
|
+
return false;
|
|
7693
|
+
}
|
|
7694
|
+
}
|
|
7695
|
+
function getAddressFromPrivateKey(privateKey) {
|
|
7696
|
+
const normalized = normalizePrivateKey(privateKey);
|
|
7697
|
+
return (0, import_accounts7.privateKeyToAddress)(normalized);
|
|
7698
|
+
}
|
|
7699
|
+
function decodeGoKeyringValue(rawValue) {
|
|
7700
|
+
if (rawValue.startsWith(GO_KEYRING_BASE64_PREFIX)) {
|
|
7701
|
+
const encoded = rawValue.substring(GO_KEYRING_BASE64_PREFIX.length);
|
|
7702
|
+
try {
|
|
7703
|
+
const decoded = Buffer.from(encoded, "base64").toString("utf8");
|
|
7704
|
+
return decoded;
|
|
7705
|
+
} catch (err) {
|
|
7706
|
+
console.warn(`Warning: Failed to decode go-keyring base64 value: ${err}`);
|
|
7707
|
+
return rawValue;
|
|
7708
|
+
}
|
|
7709
|
+
}
|
|
7710
|
+
if (rawValue.startsWith(GO_KEYRING_ENCODED_PREFIX)) {
|
|
7711
|
+
const encoded = rawValue.substring(GO_KEYRING_ENCODED_PREFIX.length);
|
|
7712
|
+
try {
|
|
7713
|
+
const decoded = Buffer.from(encoded, "hex").toString("utf8");
|
|
7714
|
+
return decoded;
|
|
7715
|
+
} catch (err) {
|
|
7716
|
+
console.warn(`Warning: Failed to decode go-keyring hex value: ${err}`);
|
|
7717
|
+
return rawValue;
|
|
7718
|
+
}
|
|
7719
|
+
}
|
|
7720
|
+
return rawValue;
|
|
7721
|
+
}
|
|
7722
|
+
function normalizePrivateKey(privateKey) {
|
|
7723
|
+
if (!privateKey.startsWith("0x")) {
|
|
7724
|
+
return `0x${privateKey}`;
|
|
7725
|
+
}
|
|
7726
|
+
return privateKey;
|
|
7727
|
+
}
|
|
7728
|
+
|
|
7729
|
+
// src/client/common/auth/resolver.ts
|
|
7730
|
+
async function getPrivateKeyWithSource(options) {
|
|
7731
|
+
if (options.privateKey) {
|
|
7732
|
+
if (!validatePrivateKey2(options.privateKey)) {
|
|
7733
|
+
throw new Error(
|
|
7734
|
+
"Invalid private key format provided via command flag. Please check and try again."
|
|
7735
|
+
);
|
|
7736
|
+
}
|
|
7737
|
+
return {
|
|
7738
|
+
key: options.privateKey,
|
|
7739
|
+
source: "command flag"
|
|
7740
|
+
};
|
|
7741
|
+
}
|
|
7742
|
+
const envKey = process.env.ECLOUD_PRIVATE_KEY;
|
|
7743
|
+
if (envKey) {
|
|
7744
|
+
if (!validatePrivateKey2(envKey)) {
|
|
7745
|
+
throw new Error(
|
|
7746
|
+
"Invalid private key format provided via environment variable. Please check and try again."
|
|
7747
|
+
);
|
|
7748
|
+
}
|
|
7749
|
+
return {
|
|
7750
|
+
key: envKey,
|
|
7751
|
+
source: "environment variable (ECLOUD_PRIVATE_KEY)"
|
|
7752
|
+
};
|
|
7753
|
+
}
|
|
7754
|
+
const keyringKey = await getPrivateKey();
|
|
7755
|
+
if (keyringKey) {
|
|
7756
|
+
return {
|
|
7757
|
+
key: keyringKey,
|
|
7758
|
+
source: "stored credentials"
|
|
7759
|
+
};
|
|
7760
|
+
}
|
|
7761
|
+
return null;
|
|
7762
|
+
}
|
|
7763
|
+
async function requirePrivateKey(options) {
|
|
7764
|
+
const result = await getPrivateKeyWithSource({
|
|
7765
|
+
privateKey: options.privateKey
|
|
7766
|
+
});
|
|
7767
|
+
if (!result) {
|
|
7768
|
+
throw new Error(
|
|
7769
|
+
`Private key required. Please provide it via:
|
|
7770
|
+
\u2022 Keyring: ecloud auth login
|
|
7771
|
+
\u2022 Flag: --private-key YOUR_KEY
|
|
7772
|
+
\u2022 Environment: export ECLOUD_PRIVATE_KEY=YOUR_KEY`
|
|
7773
|
+
);
|
|
7774
|
+
}
|
|
7775
|
+
return result;
|
|
7776
|
+
}
|
|
7777
|
+
|
|
7778
|
+
// src/client/common/auth/generate.ts
|
|
7779
|
+
var import_accounts8 = require("viem/accounts");
|
|
7780
|
+
function generateNewPrivateKey() {
|
|
7781
|
+
const privateKey = (0, import_accounts8.generatePrivateKey)();
|
|
7782
|
+
const address = (0, import_accounts8.privateKeyToAddress)(privateKey);
|
|
7783
|
+
return {
|
|
7784
|
+
privateKey,
|
|
7785
|
+
address
|
|
7786
|
+
};
|
|
7787
|
+
}
|
|
7788
|
+
|
|
7789
|
+
// src/client/modules/billing/index.ts
|
|
7790
|
+
function createBillingModule(config) {
|
|
7791
|
+
const { verbose = false, skipTelemetry = false } = config;
|
|
7792
|
+
const privateKey = addHexPrefix(config.privateKey);
|
|
7793
|
+
const address = getAddressFromPrivateKey(privateKey);
|
|
7794
|
+
const logger = getLogger(verbose);
|
|
7795
|
+
const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
|
|
7796
|
+
const billingApi = new BillingApiClient(billingEnvConfig, privateKey);
|
|
7797
|
+
return {
|
|
7798
|
+
address,
|
|
7799
|
+
async subscribe(opts) {
|
|
7800
|
+
return withSDKTelemetry(
|
|
7801
|
+
{
|
|
7802
|
+
functionName: "subscribe",
|
|
7803
|
+
skipTelemetry,
|
|
7804
|
+
// Skip if called from CLI
|
|
7805
|
+
properties: { productId: opts?.productId || "compute" }
|
|
7806
|
+
},
|
|
7807
|
+
async () => {
|
|
7808
|
+
const productId = opts?.productId || "compute";
|
|
7809
|
+
logger.debug(`Checking existing subscription for ${productId}...`);
|
|
7810
|
+
const currentStatus = await billingApi.getSubscription(productId);
|
|
7811
|
+
if (isSubscriptionActive(currentStatus.subscriptionStatus)) {
|
|
7812
|
+
logger.debug(`Subscription already active: ${currentStatus.subscriptionStatus}`);
|
|
7813
|
+
return {
|
|
7814
|
+
type: "already_active",
|
|
7815
|
+
status: currentStatus.subscriptionStatus
|
|
7816
|
+
};
|
|
7817
|
+
}
|
|
7818
|
+
if (currentStatus.subscriptionStatus === "past_due" || currentStatus.subscriptionStatus === "unpaid") {
|
|
7819
|
+
logger.debug(`Subscription has payment issue: ${currentStatus.subscriptionStatus}`);
|
|
7820
|
+
return {
|
|
7821
|
+
type: "payment_issue",
|
|
7822
|
+
status: currentStatus.subscriptionStatus,
|
|
7823
|
+
portalUrl: currentStatus.portalUrl
|
|
7824
|
+
};
|
|
7825
|
+
}
|
|
7826
|
+
logger.debug(`Creating subscription for ${productId}...`);
|
|
7827
|
+
const result = await billingApi.createSubscription(productId);
|
|
7828
|
+
logger.debug(`Checkout URL: ${result.checkoutUrl}`);
|
|
7829
|
+
return {
|
|
7830
|
+
type: "checkout_created",
|
|
7831
|
+
checkoutUrl: result.checkoutUrl
|
|
7832
|
+
};
|
|
7833
|
+
}
|
|
7834
|
+
);
|
|
7835
|
+
},
|
|
7836
|
+
async getStatus(opts) {
|
|
7837
|
+
return withSDKTelemetry(
|
|
7838
|
+
{
|
|
7839
|
+
functionName: "getStatus",
|
|
7840
|
+
skipTelemetry,
|
|
7841
|
+
// Skip if called from CLI
|
|
7842
|
+
properties: { productId: opts?.productId || "compute" }
|
|
7843
|
+
},
|
|
7844
|
+
async () => {
|
|
7845
|
+
const productId = opts?.productId || "compute";
|
|
7846
|
+
logger.debug(`Fetching subscription status for ${productId}...`);
|
|
7847
|
+
const result = await billingApi.getSubscription(productId);
|
|
7848
|
+
logger.debug(`Subscription status: ${result.subscriptionStatus}`);
|
|
7849
|
+
return result;
|
|
7850
|
+
}
|
|
7851
|
+
);
|
|
7852
|
+
},
|
|
7853
|
+
async cancel(opts) {
|
|
7854
|
+
return withSDKTelemetry(
|
|
7855
|
+
{
|
|
7856
|
+
functionName: "cancel",
|
|
7857
|
+
skipTelemetry,
|
|
7858
|
+
// Skip if called from CLI
|
|
7859
|
+
properties: { productId: opts?.productId || "compute" }
|
|
7860
|
+
},
|
|
7861
|
+
async () => {
|
|
7862
|
+
const productId = opts?.productId || "compute";
|
|
7863
|
+
logger.debug(`Checking subscription status for ${productId}...`);
|
|
7864
|
+
const currentStatus = await billingApi.getSubscription(productId);
|
|
7865
|
+
if (!isSubscriptionActive(currentStatus.subscriptionStatus)) {
|
|
7866
|
+
logger.debug(`No active subscription to cancel: ${currentStatus.subscriptionStatus}`);
|
|
7867
|
+
return {
|
|
7868
|
+
type: "no_active_subscription",
|
|
7869
|
+
status: currentStatus.subscriptionStatus
|
|
7870
|
+
};
|
|
7871
|
+
}
|
|
7872
|
+
logger.debug(`Canceling subscription for ${productId}...`);
|
|
7873
|
+
await billingApi.cancelSubscription(productId);
|
|
7874
|
+
logger.debug(`Subscription canceled successfully`);
|
|
7428
7875
|
return {
|
|
7429
7876
|
type: "canceled"
|
|
7430
7877
|
};
|
|
@@ -7436,13 +7883,13 @@ function createBillingModule(config) {
|
|
|
7436
7883
|
|
|
7437
7884
|
// src/client/common/utils/buildapi.ts
|
|
7438
7885
|
var import_axios3 = __toESM(require("axios"), 1);
|
|
7439
|
-
var
|
|
7886
|
+
var import_accounts9 = require("viem/accounts");
|
|
7440
7887
|
var BuildApiClient = class {
|
|
7441
7888
|
constructor(options) {
|
|
7442
7889
|
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
7443
7890
|
this.clientId = options.clientId;
|
|
7444
7891
|
if (options.privateKey) {
|
|
7445
|
-
this.account = (0,
|
|
7892
|
+
this.account = (0, import_accounts9.privateKeyToAccount)(options.privateKey);
|
|
7446
7893
|
}
|
|
7447
7894
|
}
|
|
7448
7895
|
async submitBuild(payload) {
|
|
@@ -7788,245 +8235,6 @@ function transformVerifyResult(raw) {
|
|
|
7788
8235
|
};
|
|
7789
8236
|
}
|
|
7790
8237
|
|
|
7791
|
-
// src/client/common/auth/keyring.ts
|
|
7792
|
-
var import_keyring = require("@napi-rs/keyring");
|
|
7793
|
-
var import_accounts7 = require("viem/accounts");
|
|
7794
|
-
var SERVICE_NAME = "ecloud";
|
|
7795
|
-
var ACCOUNT_NAME = "key";
|
|
7796
|
-
var EIGENX_SERVICE_NAME = "eigenx-cli";
|
|
7797
|
-
var EIGENX_DEV_SERVICE_NAME = "eigenx-cli-dev";
|
|
7798
|
-
var EIGENX_ACCOUNT_PREFIX = "eigenx-";
|
|
7799
|
-
var GO_KEYRING_BASE64_PREFIX = "go-keyring-base64:";
|
|
7800
|
-
var GO_KEYRING_ENCODED_PREFIX = "go-keyring-encoded:";
|
|
7801
|
-
async function storePrivateKey(privateKey) {
|
|
7802
|
-
const normalizedKey = normalizePrivateKey(privateKey);
|
|
7803
|
-
const isValid = validatePrivateKey2(normalizedKey);
|
|
7804
|
-
if (!isValid) {
|
|
7805
|
-
throw new Error("Invalid private key format");
|
|
7806
|
-
}
|
|
7807
|
-
const entry = new import_keyring.AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);
|
|
7808
|
-
try {
|
|
7809
|
-
await entry.setPassword(normalizedKey);
|
|
7810
|
-
} catch (err) {
|
|
7811
|
-
throw new Error(
|
|
7812
|
-
`Failed to store key in OS keyring: ${err?.message ?? err}. Ensure keyring service is available.`
|
|
7813
|
-
);
|
|
7814
|
-
}
|
|
7815
|
-
}
|
|
7816
|
-
async function getPrivateKey() {
|
|
7817
|
-
const entry = new import_keyring.AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);
|
|
7818
|
-
try {
|
|
7819
|
-
const key = await entry.getPassword();
|
|
7820
|
-
if (key && validatePrivateKey2(key)) {
|
|
7821
|
-
return key;
|
|
7822
|
-
}
|
|
7823
|
-
} catch {
|
|
7824
|
-
}
|
|
7825
|
-
return null;
|
|
7826
|
-
}
|
|
7827
|
-
async function deletePrivateKey() {
|
|
7828
|
-
const entry = new import_keyring.AsyncEntry(SERVICE_NAME, ACCOUNT_NAME);
|
|
7829
|
-
try {
|
|
7830
|
-
await entry.deletePassword();
|
|
7831
|
-
return true;
|
|
7832
|
-
} catch {
|
|
7833
|
-
console.warn("No key found in keyring");
|
|
7834
|
-
return false;
|
|
7835
|
-
}
|
|
7836
|
-
}
|
|
7837
|
-
async function listStoredKeys() {
|
|
7838
|
-
const keys = [];
|
|
7839
|
-
const creds = (0, import_keyring.findCredentials)(SERVICE_NAME);
|
|
7840
|
-
for (const cred of creds) {
|
|
7841
|
-
if (cred.account === ACCOUNT_NAME) {
|
|
7842
|
-
try {
|
|
7843
|
-
const address = getAddressFromPrivateKey(cred.password);
|
|
7844
|
-
keys.push({ address });
|
|
7845
|
-
} catch (err) {
|
|
7846
|
-
console.warn(`Warning: Invalid key found, skipping: ${err}`);
|
|
7847
|
-
}
|
|
7848
|
-
}
|
|
7849
|
-
}
|
|
7850
|
-
return keys;
|
|
7851
|
-
}
|
|
7852
|
-
async function keyExists() {
|
|
7853
|
-
const key = await getPrivateKey();
|
|
7854
|
-
return key !== null;
|
|
7855
|
-
}
|
|
7856
|
-
async function getLegacyKeys() {
|
|
7857
|
-
const keys = [];
|
|
7858
|
-
try {
|
|
7859
|
-
const eigenxCreds = (0, import_keyring.findCredentials)(EIGENX_SERVICE_NAME);
|
|
7860
|
-
for (const cred of eigenxCreds) {
|
|
7861
|
-
const accountName = cred.account;
|
|
7862
|
-
if (!accountName.startsWith(EIGENX_ACCOUNT_PREFIX)) {
|
|
7863
|
-
continue;
|
|
7864
|
-
}
|
|
7865
|
-
const environment = accountName.substring(EIGENX_ACCOUNT_PREFIX.length);
|
|
7866
|
-
try {
|
|
7867
|
-
const decodedKey = decodeGoKeyringValue(cred.password);
|
|
7868
|
-
const address = getAddressFromPrivateKey(decodedKey);
|
|
7869
|
-
keys.push({ environment, address, source: "eigenx" });
|
|
7870
|
-
} catch (err) {
|
|
7871
|
-
console.warn(
|
|
7872
|
-
`Warning: Invalid key found for ${environment} (eigenx-cli), skipping: ${err}`
|
|
7873
|
-
);
|
|
7874
|
-
}
|
|
7875
|
-
}
|
|
7876
|
-
} catch {
|
|
7877
|
-
}
|
|
7878
|
-
try {
|
|
7879
|
-
const eigenxDevCreds = (0, import_keyring.findCredentials)(EIGENX_DEV_SERVICE_NAME);
|
|
7880
|
-
for (const cred of eigenxDevCreds) {
|
|
7881
|
-
const accountName = cred.account;
|
|
7882
|
-
if (!accountName.startsWith(EIGENX_ACCOUNT_PREFIX)) {
|
|
7883
|
-
continue;
|
|
7884
|
-
}
|
|
7885
|
-
const environment = accountName.substring(EIGENX_ACCOUNT_PREFIX.length);
|
|
7886
|
-
try {
|
|
7887
|
-
const decodedKey = decodeGoKeyringValue(cred.password);
|
|
7888
|
-
const address = getAddressFromPrivateKey(decodedKey);
|
|
7889
|
-
keys.push({ environment, address, source: "eigenx-dev" });
|
|
7890
|
-
} catch (err) {
|
|
7891
|
-
console.warn(
|
|
7892
|
-
`Warning: Invalid key found for ${environment} (eigenx-dev), skipping: ${err}`
|
|
7893
|
-
);
|
|
7894
|
-
}
|
|
7895
|
-
}
|
|
7896
|
-
} catch {
|
|
7897
|
-
}
|
|
7898
|
-
return keys;
|
|
7899
|
-
}
|
|
7900
|
-
async function getLegacyPrivateKey(environment, source) {
|
|
7901
|
-
const serviceName = source === "eigenx" ? EIGENX_SERVICE_NAME : EIGENX_DEV_SERVICE_NAME;
|
|
7902
|
-
const accountName = EIGENX_ACCOUNT_PREFIX + environment;
|
|
7903
|
-
const entry = new import_keyring.AsyncEntry(serviceName, accountName);
|
|
7904
|
-
try {
|
|
7905
|
-
const rawKey = await entry.getPassword();
|
|
7906
|
-
if (rawKey) {
|
|
7907
|
-
const decodedKey = decodeGoKeyringValue(rawKey);
|
|
7908
|
-
if (validatePrivateKey2(decodedKey)) {
|
|
7909
|
-
return decodedKey;
|
|
7910
|
-
}
|
|
7911
|
-
}
|
|
7912
|
-
} catch {
|
|
7913
|
-
}
|
|
7914
|
-
return null;
|
|
7915
|
-
}
|
|
7916
|
-
async function deleteLegacyPrivateKey(environment, source) {
|
|
7917
|
-
const serviceName = source === "eigenx" ? EIGENX_SERVICE_NAME : EIGENX_DEV_SERVICE_NAME;
|
|
7918
|
-
const accountName = EIGENX_ACCOUNT_PREFIX + environment;
|
|
7919
|
-
const entry = new import_keyring.AsyncEntry(serviceName, accountName);
|
|
7920
|
-
try {
|
|
7921
|
-
await entry.deletePassword();
|
|
7922
|
-
return true;
|
|
7923
|
-
} catch {
|
|
7924
|
-
console.warn(`No key found for ${environment} in ${source}`);
|
|
7925
|
-
return false;
|
|
7926
|
-
}
|
|
7927
|
-
}
|
|
7928
|
-
function validatePrivateKey2(privateKey) {
|
|
7929
|
-
try {
|
|
7930
|
-
getAddressFromPrivateKey(privateKey);
|
|
7931
|
-
return true;
|
|
7932
|
-
} catch {
|
|
7933
|
-
return false;
|
|
7934
|
-
}
|
|
7935
|
-
}
|
|
7936
|
-
function getAddressFromPrivateKey(privateKey) {
|
|
7937
|
-
const normalized = normalizePrivateKey(privateKey);
|
|
7938
|
-
return (0, import_accounts7.privateKeyToAddress)(normalized);
|
|
7939
|
-
}
|
|
7940
|
-
function decodeGoKeyringValue(rawValue) {
|
|
7941
|
-
if (rawValue.startsWith(GO_KEYRING_BASE64_PREFIX)) {
|
|
7942
|
-
const encoded = rawValue.substring(GO_KEYRING_BASE64_PREFIX.length);
|
|
7943
|
-
try {
|
|
7944
|
-
const decoded = Buffer.from(encoded, "base64").toString("utf8");
|
|
7945
|
-
return decoded;
|
|
7946
|
-
} catch (err) {
|
|
7947
|
-
console.warn(`Warning: Failed to decode go-keyring base64 value: ${err}`);
|
|
7948
|
-
return rawValue;
|
|
7949
|
-
}
|
|
7950
|
-
}
|
|
7951
|
-
if (rawValue.startsWith(GO_KEYRING_ENCODED_PREFIX)) {
|
|
7952
|
-
const encoded = rawValue.substring(GO_KEYRING_ENCODED_PREFIX.length);
|
|
7953
|
-
try {
|
|
7954
|
-
const decoded = Buffer.from(encoded, "hex").toString("utf8");
|
|
7955
|
-
return decoded;
|
|
7956
|
-
} catch (err) {
|
|
7957
|
-
console.warn(`Warning: Failed to decode go-keyring hex value: ${err}`);
|
|
7958
|
-
return rawValue;
|
|
7959
|
-
}
|
|
7960
|
-
}
|
|
7961
|
-
return rawValue;
|
|
7962
|
-
}
|
|
7963
|
-
function normalizePrivateKey(privateKey) {
|
|
7964
|
-
if (!privateKey.startsWith("0x")) {
|
|
7965
|
-
return `0x${privateKey}`;
|
|
7966
|
-
}
|
|
7967
|
-
return privateKey;
|
|
7968
|
-
}
|
|
7969
|
-
|
|
7970
|
-
// src/client/common/auth/resolver.ts
|
|
7971
|
-
async function getPrivateKeyWithSource(options) {
|
|
7972
|
-
if (options.privateKey) {
|
|
7973
|
-
if (!validatePrivateKey2(options.privateKey)) {
|
|
7974
|
-
throw new Error(
|
|
7975
|
-
"Invalid private key format provided via command flag. Please check and try again."
|
|
7976
|
-
);
|
|
7977
|
-
}
|
|
7978
|
-
return {
|
|
7979
|
-
key: options.privateKey,
|
|
7980
|
-
source: "command flag"
|
|
7981
|
-
};
|
|
7982
|
-
}
|
|
7983
|
-
const envKey = process.env.ECLOUD_PRIVATE_KEY;
|
|
7984
|
-
if (envKey) {
|
|
7985
|
-
if (!validatePrivateKey2(envKey)) {
|
|
7986
|
-
throw new Error(
|
|
7987
|
-
"Invalid private key format provided via environment variable. Please check and try again."
|
|
7988
|
-
);
|
|
7989
|
-
}
|
|
7990
|
-
return {
|
|
7991
|
-
key: envKey,
|
|
7992
|
-
source: "environment variable (ECLOUD_PRIVATE_KEY)"
|
|
7993
|
-
};
|
|
7994
|
-
}
|
|
7995
|
-
const keyringKey = await getPrivateKey();
|
|
7996
|
-
if (keyringKey) {
|
|
7997
|
-
return {
|
|
7998
|
-
key: keyringKey,
|
|
7999
|
-
source: "stored credentials"
|
|
8000
|
-
};
|
|
8001
|
-
}
|
|
8002
|
-
return null;
|
|
8003
|
-
}
|
|
8004
|
-
async function requirePrivateKey(options) {
|
|
8005
|
-
const result = await getPrivateKeyWithSource({
|
|
8006
|
-
privateKey: options.privateKey
|
|
8007
|
-
});
|
|
8008
|
-
if (!result) {
|
|
8009
|
-
throw new Error(
|
|
8010
|
-
`Private key required. Please provide it via:
|
|
8011
|
-
\u2022 Keyring: ecloud auth login
|
|
8012
|
-
\u2022 Flag: --private-key YOUR_KEY
|
|
8013
|
-
\u2022 Environment: export ECLOUD_PRIVATE_KEY=YOUR_KEY`
|
|
8014
|
-
);
|
|
8015
|
-
}
|
|
8016
|
-
return result;
|
|
8017
|
-
}
|
|
8018
|
-
|
|
8019
|
-
// src/client/common/auth/generate.ts
|
|
8020
|
-
var import_accounts8 = require("viem/accounts");
|
|
8021
|
-
function generateNewPrivateKey() {
|
|
8022
|
-
const privateKey = (0, import_accounts8.generatePrivateKey)();
|
|
8023
|
-
const address = (0, import_accounts8.privateKeyToAddress)(privateKey);
|
|
8024
|
-
return {
|
|
8025
|
-
privateKey,
|
|
8026
|
-
address
|
|
8027
|
-
};
|
|
8028
|
-
}
|
|
8029
|
-
|
|
8030
8238
|
// src/client/common/utils/instance.ts
|
|
8031
8239
|
async function getCurrentInstanceType(preflightCtx, appID, logger, clientId) {
|
|
8032
8240
|
try {
|