@layr-labs/ecloud-cli 0.4.0-dev.1 → 0.4.0-dev.3
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 -0
- package/bin/dev.js +0 -0
- package/dist/commands/auth/generate.js +0 -0
- package/dist/commands/auth/login.js +0 -0
- package/dist/commands/auth/logout.js +0 -0
- package/dist/commands/auth/migrate.js +0 -0
- package/dist/commands/auth/whoami.js +1 -0
- package/dist/commands/auth/whoami.js.map +1 -1
- package/dist/commands/billing/__tests__/status.test.js +89 -22
- package/dist/commands/billing/__tests__/status.test.js.map +1 -1
- package/dist/commands/billing/__tests__/subscribe.test.js +88 -20
- package/dist/commands/billing/__tests__/subscribe.test.js.map +1 -1
- package/dist/commands/billing/__tests__/top-up.test.js +139 -201
- package/dist/commands/billing/__tests__/top-up.test.js.map +1 -1
- package/dist/commands/billing/cancel.js +88 -19
- package/dist/commands/billing/cancel.js.map +1 -1
- package/dist/commands/billing/status.js +89 -21
- package/dist/commands/billing/status.js.map +1 -1
- package/dist/commands/billing/subscribe.js +88 -19
- package/dist/commands/billing/subscribe.js.map +1 -1
- package/dist/commands/billing/top-up.js +102 -91
- package/dist/commands/billing/top-up.js.map +1 -1
- package/dist/commands/compute/app/configure/tls.js +0 -0
- package/dist/commands/compute/app/create.js +1 -0
- package/dist/commands/compute/app/create.js.map +1 -1
- package/dist/commands/compute/app/deploy.js +38 -24
- package/dist/commands/compute/app/deploy.js.map +1 -1
- package/dist/commands/compute/app/info.js +2 -1
- package/dist/commands/compute/app/info.js.map +1 -1
- package/dist/commands/compute/app/list.js +2 -1
- package/dist/commands/compute/app/list.js.map +1 -1
- package/dist/commands/compute/app/logs.js +5 -8
- package/dist/commands/compute/app/logs.js.map +1 -1
- package/dist/commands/compute/app/profile/set.js +5 -8
- package/dist/commands/compute/app/profile/set.js.map +1 -1
- package/dist/commands/compute/app/releases.js +2 -1
- package/dist/commands/compute/app/releases.js.map +1 -1
- package/dist/commands/compute/app/start.js +5 -8
- package/dist/commands/compute/app/start.js.map +1 -1
- package/dist/commands/compute/app/stop.js +5 -8
- package/dist/commands/compute/app/stop.js.map +1 -1
- package/dist/commands/compute/app/terminate.js +5 -8
- package/dist/commands/compute/app/terminate.js.map +1 -1
- package/dist/commands/compute/app/upgrade.js +36 -14
- package/dist/commands/compute/app/upgrade.js.map +1 -1
- package/dist/commands/compute/build/info.js +9 -12
- package/dist/commands/compute/build/info.js.map +1 -1
- package/dist/commands/compute/build/list.js +9 -12
- package/dist/commands/compute/build/list.js.map +1 -1
- package/dist/commands/compute/build/logs.js +9 -12
- package/dist/commands/compute/build/logs.js.map +1 -1
- package/dist/commands/compute/build/status.js +9 -12
- package/dist/commands/compute/build/status.js.map +1 -1
- package/dist/commands/compute/build/submit.js +32 -10
- package/dist/commands/compute/build/submit.js.map +1 -1
- package/dist/commands/compute/build/verify.js +9 -12
- package/dist/commands/compute/build/verify.js.map +1 -1
- package/dist/commands/compute/environment/list.js +0 -0
- package/dist/commands/compute/environment/set.js +1 -0
- package/dist/commands/compute/environment/set.js.map +1 -1
- package/dist/commands/compute/environment/show.js +0 -0
- package/dist/commands/compute/undelegate.js +5 -8
- package/dist/commands/compute/undelegate.js.map +1 -1
- package/dist/commands/telemetry/disable.js +0 -0
- package/dist/commands/telemetry/enable.js +0 -0
- package/dist/commands/telemetry/status.js +0 -0
- package/dist/commands/upgrade.js +0 -0
- package/dist/commands/version.js +0 -0
- package/package.json +15 -14
- package/LICENSE +0 -7
|
@@ -10,9 +10,7 @@ import {
|
|
|
10
10
|
createBillingModule,
|
|
11
11
|
createBuildModule,
|
|
12
12
|
getEnvironmentConfig as getEnvironmentConfig3,
|
|
13
|
-
requirePrivateKey
|
|
14
|
-
getPrivateKeyWithSource,
|
|
15
|
-
addHexPrefix as addHexPrefix2
|
|
13
|
+
requirePrivateKey
|
|
16
14
|
} from "@layr-labs/ecloud-sdk";
|
|
17
15
|
|
|
18
16
|
// src/flags.ts
|
|
@@ -63,6 +61,24 @@ import {
|
|
|
63
61
|
createViemClients as sdkCreateViemClients,
|
|
64
62
|
getChainFromID
|
|
65
63
|
} from "@layr-labs/ecloud-sdk";
|
|
64
|
+
function createViemClients(options) {
|
|
65
|
+
const privateKey = addHexPrefix(options.privateKey);
|
|
66
|
+
const environmentConfig = getEnvironmentConfig(options.environment);
|
|
67
|
+
const rpcUrl = options.rpcUrl || environmentConfig.defaultRPCURL;
|
|
68
|
+
const chain = getChainFromID(environmentConfig.chainID);
|
|
69
|
+
const { publicClient, walletClient } = sdkCreateViemClients({
|
|
70
|
+
privateKey,
|
|
71
|
+
rpcUrl,
|
|
72
|
+
chainId: environmentConfig.chainID
|
|
73
|
+
});
|
|
74
|
+
const account = privateKeyToAccount(privateKey);
|
|
75
|
+
return {
|
|
76
|
+
publicClient,
|
|
77
|
+
walletClient,
|
|
78
|
+
chain,
|
|
79
|
+
address: account.address
|
|
80
|
+
};
|
|
81
|
+
}
|
|
66
82
|
|
|
67
83
|
// src/utils/globalConfig.ts
|
|
68
84
|
import * as fs from "fs";
|
|
@@ -149,6 +165,7 @@ var CONFIG_DIR = path2.join(os2.homedir(), ".eigenx");
|
|
|
149
165
|
var APPS_DIR = path2.join(CONFIG_DIR, "apps");
|
|
150
166
|
|
|
151
167
|
// src/utils/prompts.ts
|
|
168
|
+
import { execSync } from "child_process";
|
|
152
169
|
async function getPrivateKeyInteractive(privateKey) {
|
|
153
170
|
if (privateKey) {
|
|
154
171
|
if (!validatePrivateKeyFormat(privateKey)) {
|
|
@@ -156,8 +173,8 @@ async function getPrivateKeyInteractive(privateKey) {
|
|
|
156
173
|
}
|
|
157
174
|
return privateKey;
|
|
158
175
|
}
|
|
159
|
-
const { getPrivateKeyWithSource
|
|
160
|
-
const result = await
|
|
176
|
+
const { getPrivateKeyWithSource } = await import("@layr-labs/ecloud-sdk");
|
|
177
|
+
const result = await getPrivateKeyWithSource({ privateKey: void 0 });
|
|
161
178
|
if (result) {
|
|
162
179
|
return result.key;
|
|
163
180
|
}
|
|
@@ -176,6 +193,50 @@ async function getPrivateKeyInteractive(privateKey) {
|
|
|
176
193
|
});
|
|
177
194
|
return key.trim();
|
|
178
195
|
}
|
|
196
|
+
async function getEnvironmentInteractive(environment) {
|
|
197
|
+
if (environment) {
|
|
198
|
+
try {
|
|
199
|
+
getEnvironmentConfig2(environment);
|
|
200
|
+
if (!isEnvironmentAvailable(environment)) {
|
|
201
|
+
throw new Error(`Environment ${environment} is not available in this build`);
|
|
202
|
+
}
|
|
203
|
+
return environment;
|
|
204
|
+
} catch {
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const availableEnvs = getAvailableEnvironments();
|
|
208
|
+
let defaultEnv;
|
|
209
|
+
const configDefaultEnv = getDefaultEnvironment();
|
|
210
|
+
if (configDefaultEnv && availableEnvs.includes(configDefaultEnv)) {
|
|
211
|
+
try {
|
|
212
|
+
getEnvironmentConfig2(configDefaultEnv);
|
|
213
|
+
defaultEnv = configDefaultEnv;
|
|
214
|
+
} catch {
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const choices = [];
|
|
218
|
+
if (availableEnvs.includes("sepolia")) {
|
|
219
|
+
choices.push({ name: "sepolia - Ethereum Sepolia testnet", value: "sepolia" });
|
|
220
|
+
}
|
|
221
|
+
if (availableEnvs.includes("sepolia-dev")) {
|
|
222
|
+
choices.push({ name: "sepolia-dev - Ethereum Sepolia testnet (dev)", value: "sepolia-dev" });
|
|
223
|
+
}
|
|
224
|
+
if (availableEnvs.includes("mainnet-alpha")) {
|
|
225
|
+
choices.push({
|
|
226
|
+
name: "mainnet-alpha - Ethereum mainnet (\u26A0\uFE0F uses real funds)",
|
|
227
|
+
value: "mainnet-alpha"
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
if (choices.length === 0) {
|
|
231
|
+
throw new Error("No environments available in this build");
|
|
232
|
+
}
|
|
233
|
+
const env = await select({
|
|
234
|
+
message: "Select environment:",
|
|
235
|
+
choices,
|
|
236
|
+
default: defaultEnv
|
|
237
|
+
});
|
|
238
|
+
return env;
|
|
239
|
+
}
|
|
179
240
|
var MAX_IMAGE_SIZE = 4 * 1024 * 1024;
|
|
180
241
|
|
|
181
242
|
// src/flags.ts
|
|
@@ -202,29 +263,37 @@ var commonFlags = {
|
|
|
202
263
|
default: false
|
|
203
264
|
})
|
|
204
265
|
};
|
|
266
|
+
async function validateCommonFlags(flags, options) {
|
|
267
|
+
flags["environment"] = await getEnvironmentInteractive(flags["environment"]);
|
|
268
|
+
if (options?.requirePrivateKey !== false) {
|
|
269
|
+
flags["private-key"] = await getPrivateKeyInteractive(flags["private-key"]);
|
|
270
|
+
}
|
|
271
|
+
return flags;
|
|
272
|
+
}
|
|
205
273
|
|
|
206
274
|
// src/client.ts
|
|
207
|
-
import { createWalletClient, custom } from "viem";
|
|
208
|
-
import { privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
|
|
209
275
|
async function createBillingClient(flags) {
|
|
210
|
-
|
|
276
|
+
flags = await validateCommonFlags(flags);
|
|
277
|
+
const environment = flags.environment;
|
|
278
|
+
const environmentConfig = getEnvironmentConfig3(environment);
|
|
279
|
+
const rpcUrl = flags["rpc-url"] || environmentConfig.billingRPCURL || environmentConfig.defaultRPCURL;
|
|
280
|
+
const { key: privateKey, source } = await requirePrivateKey({
|
|
211
281
|
privateKey: flags["private-key"]
|
|
212
282
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
})
|
|
283
|
+
if (flags.verbose) {
|
|
284
|
+
console.log(`Using private key from: ${source}`);
|
|
285
|
+
}
|
|
286
|
+
const { walletClient, publicClient } = createViemClients({
|
|
287
|
+
privateKey,
|
|
288
|
+
rpcUrl,
|
|
289
|
+
environment
|
|
222
290
|
});
|
|
223
291
|
return createBillingModule({
|
|
224
|
-
verbose: flags.verbose
|
|
292
|
+
verbose: flags.verbose,
|
|
225
293
|
walletClient,
|
|
294
|
+
publicClient,
|
|
295
|
+
environment,
|
|
226
296
|
skipTelemetry: true
|
|
227
|
-
// CLI already has telemetry, skip SDK telemetry
|
|
228
297
|
});
|
|
229
298
|
}
|
|
230
299
|
|