@layr-labs/ecloud-cli 0.4.0-dev.1 → 0.4.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +2 -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
|
@@ -21,6 +21,24 @@ import {
|
|
|
21
21
|
createViemClients as sdkCreateViemClients,
|
|
22
22
|
getChainFromID
|
|
23
23
|
} from "@layr-labs/ecloud-sdk";
|
|
24
|
+
function createViemClients(options) {
|
|
25
|
+
const privateKey = addHexPrefix(options.privateKey);
|
|
26
|
+
const environmentConfig = getEnvironmentConfig(options.environment);
|
|
27
|
+
const rpcUrl = options.rpcUrl || environmentConfig.defaultRPCURL;
|
|
28
|
+
const chain = getChainFromID(environmentConfig.chainID);
|
|
29
|
+
const { publicClient, walletClient } = sdkCreateViemClients({
|
|
30
|
+
privateKey,
|
|
31
|
+
rpcUrl,
|
|
32
|
+
chainId: environmentConfig.chainID
|
|
33
|
+
});
|
|
34
|
+
const account = privateKeyToAccount(privateKey);
|
|
35
|
+
return {
|
|
36
|
+
publicClient,
|
|
37
|
+
walletClient,
|
|
38
|
+
chain,
|
|
39
|
+
address: account.address
|
|
40
|
+
};
|
|
41
|
+
}
|
|
24
42
|
var init_viemClients = __esm({
|
|
25
43
|
"src/utils/viemClients.ts"() {
|
|
26
44
|
"use strict";
|
|
@@ -170,6 +188,7 @@ import {
|
|
|
170
188
|
extractAppNameFromImage,
|
|
171
189
|
UserApiClient as UserApiClient2
|
|
172
190
|
} from "@layr-labs/ecloud-sdk";
|
|
191
|
+
import { execSync } from "child_process";
|
|
173
192
|
async function getPrivateKeyInteractive(privateKey) {
|
|
174
193
|
if (privateKey) {
|
|
175
194
|
if (!validatePrivateKeyFormat(privateKey)) {
|
|
@@ -177,8 +196,8 @@ async function getPrivateKeyInteractive(privateKey) {
|
|
|
177
196
|
}
|
|
178
197
|
return privateKey;
|
|
179
198
|
}
|
|
180
|
-
const { getPrivateKeyWithSource
|
|
181
|
-
const result = await
|
|
199
|
+
const { getPrivateKeyWithSource } = await import("@layr-labs/ecloud-sdk");
|
|
200
|
+
const result = await getPrivateKeyWithSource({ privateKey: void 0 });
|
|
182
201
|
if (result) {
|
|
183
202
|
return result.key;
|
|
184
203
|
}
|
|
@@ -197,6 +216,50 @@ async function getPrivateKeyInteractive(privateKey) {
|
|
|
197
216
|
});
|
|
198
217
|
return key.trim();
|
|
199
218
|
}
|
|
219
|
+
async function getEnvironmentInteractive(environment) {
|
|
220
|
+
if (environment) {
|
|
221
|
+
try {
|
|
222
|
+
getEnvironmentConfig2(environment);
|
|
223
|
+
if (!isEnvironmentAvailable(environment)) {
|
|
224
|
+
throw new Error(`Environment ${environment} is not available in this build`);
|
|
225
|
+
}
|
|
226
|
+
return environment;
|
|
227
|
+
} catch {
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const availableEnvs = getAvailableEnvironments();
|
|
231
|
+
let defaultEnv;
|
|
232
|
+
const configDefaultEnv = getDefaultEnvironment();
|
|
233
|
+
if (configDefaultEnv && availableEnvs.includes(configDefaultEnv)) {
|
|
234
|
+
try {
|
|
235
|
+
getEnvironmentConfig2(configDefaultEnv);
|
|
236
|
+
defaultEnv = configDefaultEnv;
|
|
237
|
+
} catch {
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const choices = [];
|
|
241
|
+
if (availableEnvs.includes("sepolia")) {
|
|
242
|
+
choices.push({ name: "sepolia - Ethereum Sepolia testnet", value: "sepolia" });
|
|
243
|
+
}
|
|
244
|
+
if (availableEnvs.includes("sepolia-dev")) {
|
|
245
|
+
choices.push({ name: "sepolia-dev - Ethereum Sepolia testnet (dev)", value: "sepolia-dev" });
|
|
246
|
+
}
|
|
247
|
+
if (availableEnvs.includes("mainnet-alpha")) {
|
|
248
|
+
choices.push({
|
|
249
|
+
name: "mainnet-alpha - Ethereum mainnet (\u26A0\uFE0F uses real funds)",
|
|
250
|
+
value: "mainnet-alpha"
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
if (choices.length === 0) {
|
|
254
|
+
throw new Error("No environments available in this build");
|
|
255
|
+
}
|
|
256
|
+
const env = await select({
|
|
257
|
+
message: "Select environment:",
|
|
258
|
+
choices,
|
|
259
|
+
default: defaultEnv
|
|
260
|
+
});
|
|
261
|
+
return env;
|
|
262
|
+
}
|
|
200
263
|
var MAX_IMAGE_SIZE;
|
|
201
264
|
var init_prompts = __esm({
|
|
202
265
|
"src/utils/prompts.ts"() {
|
|
@@ -213,6 +276,13 @@ var init_prompts = __esm({
|
|
|
213
276
|
// src/flags.ts
|
|
214
277
|
import { Flags } from "@oclif/core";
|
|
215
278
|
import { getBuildType as getBuildType2 } from "@layr-labs/ecloud-sdk";
|
|
279
|
+
async function validateCommonFlags(flags, options) {
|
|
280
|
+
flags["environment"] = await getEnvironmentInteractive(flags["environment"]);
|
|
281
|
+
if (options?.requirePrivateKey !== false) {
|
|
282
|
+
flags["private-key"] = await getPrivateKeyInteractive(flags["private-key"]);
|
|
283
|
+
}
|
|
284
|
+
return flags;
|
|
285
|
+
}
|
|
216
286
|
var commonFlags;
|
|
217
287
|
var init_flags = __esm({
|
|
218
288
|
"src/flags.ts"() {
|
|
@@ -251,38 +321,36 @@ import {
|
|
|
251
321
|
createBillingModule,
|
|
252
322
|
createBuildModule,
|
|
253
323
|
getEnvironmentConfig as getEnvironmentConfig3,
|
|
254
|
-
requirePrivateKey
|
|
255
|
-
getPrivateKeyWithSource,
|
|
256
|
-
addHexPrefix as addHexPrefix2
|
|
324
|
+
requirePrivateKey
|
|
257
325
|
} from "@layr-labs/ecloud-sdk";
|
|
258
|
-
import { createWalletClient, custom } from "viem";
|
|
259
|
-
import { privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
|
|
260
326
|
async function createBillingClient(flags) {
|
|
261
|
-
|
|
327
|
+
flags = await validateCommonFlags(flags);
|
|
328
|
+
const environment = flags.environment;
|
|
329
|
+
const environmentConfig = getEnvironmentConfig3(environment);
|
|
330
|
+
const rpcUrl = flags["rpc-url"] || environmentConfig.billingRPCURL || environmentConfig.defaultRPCURL;
|
|
331
|
+
const { key: privateKey, source } = await requirePrivateKey({
|
|
262
332
|
privateKey: flags["private-key"]
|
|
263
333
|
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
})
|
|
334
|
+
if (flags.verbose) {
|
|
335
|
+
console.log(`Using private key from: ${source}`);
|
|
336
|
+
}
|
|
337
|
+
const { walletClient, publicClient } = createViemClients({
|
|
338
|
+
privateKey,
|
|
339
|
+
rpcUrl,
|
|
340
|
+
environment
|
|
273
341
|
});
|
|
274
342
|
return createBillingModule({
|
|
275
|
-
verbose: flags.verbose
|
|
343
|
+
verbose: flags.verbose,
|
|
276
344
|
walletClient,
|
|
345
|
+
publicClient,
|
|
346
|
+
environment,
|
|
277
347
|
skipTelemetry: true
|
|
278
|
-
// CLI already has telemetry, skip SDK telemetry
|
|
279
348
|
});
|
|
280
349
|
}
|
|
281
350
|
var init_client = __esm({
|
|
282
351
|
"src/client.ts"() {
|
|
283
352
|
"use strict";
|
|
284
353
|
init_flags();
|
|
285
|
-
init_prompts();
|
|
286
354
|
init_version();
|
|
287
355
|
init_viemClients();
|
|
288
356
|
}
|
|
@@ -369,8 +437,7 @@ var init_status = __esm({
|
|
|
369
437
|
BillingStatus = class _BillingStatus extends Command {
|
|
370
438
|
static description = "Show subscription status";
|
|
371
439
|
static flags = {
|
|
372
|
-
|
|
373
|
-
verbose: commonFlags.verbose,
|
|
440
|
+
...commonFlags,
|
|
374
441
|
product: Flags2.string({
|
|
375
442
|
required: false,
|
|
376
443
|
description: "Product ID",
|