@layr-labs/ecloud-cli 0.2.0 → 0.2.2-dev
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/commands/auth/whoami.js +16 -3
- package/dist/commands/auth/whoami.js.map +1 -1
- package/dist/commands/billing/cancel.js +44 -5
- package/dist/commands/billing/cancel.js.map +1 -1
- package/dist/commands/billing/status.js +44 -5
- package/dist/commands/billing/status.js.map +1 -1
- package/dist/commands/billing/subscribe.js +44 -5
- package/dist/commands/billing/subscribe.js.map +1 -1
- package/dist/commands/compute/app/create.js +16 -3
- package/dist/commands/compute/app/create.js.map +1 -1
- package/dist/commands/compute/app/deploy.js +120 -25
- package/dist/commands/compute/app/deploy.js.map +1 -1
- package/dist/commands/compute/app/info.js +124 -35
- package/dist/commands/compute/app/info.js.map +1 -1
- package/dist/commands/compute/app/list.js +78 -17
- package/dist/commands/compute/app/list.js.map +1 -1
- package/dist/commands/compute/app/logs.js +69 -28
- package/dist/commands/compute/app/logs.js.map +1 -1
- package/dist/commands/compute/app/profile/set.js +109 -40
- package/dist/commands/compute/app/profile/set.js.map +1 -1
- package/dist/commands/compute/app/releases.js +82 -120
- package/dist/commands/compute/app/releases.js.map +1 -1
- package/dist/commands/compute/app/start.js +77 -35
- package/dist/commands/compute/app/start.js.map +1 -1
- package/dist/commands/compute/app/stop.js +77 -35
- package/dist/commands/compute/app/stop.js.map +1 -1
- package/dist/commands/compute/app/terminate.js +77 -35
- package/dist/commands/compute/app/terminate.js.map +1 -1
- package/dist/commands/compute/app/upgrade.js +117 -39
- package/dist/commands/compute/app/upgrade.js.map +1 -1
- package/dist/commands/compute/build/info.js +56 -16
- package/dist/commands/compute/build/info.js.map +1 -1
- package/dist/commands/compute/build/list.js +72 -67
- package/dist/commands/compute/build/list.js.map +1 -1
- package/dist/commands/compute/build/logs.js +55 -13
- package/dist/commands/compute/build/logs.js.map +1 -1
- package/dist/commands/compute/build/status.js +55 -13
- package/dist/commands/compute/build/status.js.map +1 -1
- package/dist/commands/compute/build/submit.js +68 -9
- package/dist/commands/compute/build/submit.js.map +1 -1
- package/dist/commands/compute/build/verify.js +55 -13
- package/dist/commands/compute/build/verify.js.map +1 -1
- package/dist/commands/compute/environment/set.js +20 -7
- package/dist/commands/compute/environment/set.js.map +1 -1
- package/dist/commands/compute/undelegate.js +46 -10
- package/dist/commands/compute/undelegate.js.map +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/commands/compute/app/profile/set.ts
|
|
4
4
|
import { Command, Args, Flags as Flags2 } from "@oclif/core";
|
|
5
|
-
import { getEnvironmentConfig as
|
|
5
|
+
import { getEnvironmentConfig as getEnvironmentConfig4 } from "@layr-labs/ecloud-sdk";
|
|
6
6
|
|
|
7
7
|
// src/flags.ts
|
|
8
8
|
import { Flags } from "@oclif/core";
|
|
@@ -14,9 +14,9 @@ import fs3 from "fs";
|
|
|
14
14
|
import path3 from "path";
|
|
15
15
|
import os3 from "os";
|
|
16
16
|
import { isAddress as isAddress2 } from "viem";
|
|
17
|
-
import { privateKeyToAccount as
|
|
17
|
+
import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
|
|
18
18
|
import {
|
|
19
|
-
getEnvironmentConfig,
|
|
19
|
+
getEnvironmentConfig as getEnvironmentConfig2,
|
|
20
20
|
getAvailableEnvironments,
|
|
21
21
|
isEnvironmentAvailable,
|
|
22
22
|
getAllAppsByDeveloper as getAllAppsByDeveloper2,
|
|
@@ -33,12 +33,43 @@ import {
|
|
|
33
33
|
|
|
34
34
|
// src/utils/appResolver.ts
|
|
35
35
|
import { isAddress } from "viem";
|
|
36
|
-
import { privateKeyToAccount } from "viem/accounts";
|
|
36
|
+
import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
|
|
37
37
|
import {
|
|
38
38
|
UserApiClient,
|
|
39
39
|
getAllAppsByDeveloper
|
|
40
40
|
} from "@layr-labs/ecloud-sdk";
|
|
41
41
|
|
|
42
|
+
// src/utils/viemClients.ts
|
|
43
|
+
import {
|
|
44
|
+
createPublicClient,
|
|
45
|
+
http
|
|
46
|
+
} from "viem";
|
|
47
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
48
|
+
import {
|
|
49
|
+
getEnvironmentConfig,
|
|
50
|
+
addHexPrefix,
|
|
51
|
+
createViemClients as sdkCreateViemClients,
|
|
52
|
+
getChainFromID
|
|
53
|
+
} from "@layr-labs/ecloud-sdk";
|
|
54
|
+
function createViemClients(options) {
|
|
55
|
+
const privateKey = addHexPrefix(options.privateKey);
|
|
56
|
+
const environmentConfig = getEnvironmentConfig(options.environment);
|
|
57
|
+
const rpcUrl = options.rpcUrl || environmentConfig.defaultRPCURL;
|
|
58
|
+
const chain = getChainFromID(environmentConfig.chainID);
|
|
59
|
+
const { publicClient, walletClient } = sdkCreateViemClients({
|
|
60
|
+
privateKey,
|
|
61
|
+
rpcUrl,
|
|
62
|
+
chainId: environmentConfig.chainID
|
|
63
|
+
});
|
|
64
|
+
const account = privateKeyToAccount(privateKey);
|
|
65
|
+
return {
|
|
66
|
+
publicClient,
|
|
67
|
+
walletClient,
|
|
68
|
+
chain,
|
|
69
|
+
address: account.address
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
42
73
|
// src/utils/globalConfig.ts
|
|
43
74
|
import * as fs from "fs";
|
|
44
75
|
import * as path from "path";
|
|
@@ -254,7 +285,7 @@ function listApps(environment) {
|
|
|
254
285
|
|
|
255
286
|
// src/utils/version.ts
|
|
256
287
|
function getCliVersion() {
|
|
257
|
-
return true ? "0.2.
|
|
288
|
+
return true ? "0.2.2-dev" : "0.0.0";
|
|
258
289
|
}
|
|
259
290
|
function getClientId() {
|
|
260
291
|
return `ecloud-cli/v${getCliVersion()}`;
|
|
@@ -401,9 +432,14 @@ var AppResolver = class {
|
|
|
401
432
|
return;
|
|
402
433
|
}
|
|
403
434
|
try {
|
|
404
|
-
const
|
|
435
|
+
const { publicClient, walletClient } = createViemClients({
|
|
436
|
+
privateKey: this.privateKey,
|
|
437
|
+
rpcUrl: this.rpcUrl,
|
|
438
|
+
environment: this.environment
|
|
439
|
+
});
|
|
440
|
+
const account = privateKeyToAccount2(this.privateKey);
|
|
405
441
|
const { apps } = await getAllAppsByDeveloper(
|
|
406
|
-
|
|
442
|
+
publicClient,
|
|
407
443
|
this.environmentConfig,
|
|
408
444
|
account.address
|
|
409
445
|
);
|
|
@@ -414,9 +450,9 @@ var AppResolver = class {
|
|
|
414
450
|
}
|
|
415
451
|
const userApiClient = new UserApiClient(
|
|
416
452
|
this.environmentConfig,
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
getClientId()
|
|
453
|
+
walletClient,
|
|
454
|
+
publicClient,
|
|
455
|
+
{ clientId: getClientId() }
|
|
420
456
|
);
|
|
421
457
|
const appInfos = await getAppInfosChunked(userApiClient, apps);
|
|
422
458
|
const profiles = {};
|
|
@@ -439,7 +475,7 @@ function createAppResolver(environment, environmentConfig, privateKey, rpcUrl) {
|
|
|
439
475
|
}
|
|
440
476
|
|
|
441
477
|
// src/utils/prompts.ts
|
|
442
|
-
function
|
|
478
|
+
function addHexPrefix2(value) {
|
|
443
479
|
if (value.startsWith("0x")) {
|
|
444
480
|
return value;
|
|
445
481
|
}
|
|
@@ -503,7 +539,7 @@ async function getOrPromptAppID(appIDOrOptions, environment) {
|
|
|
503
539
|
};
|
|
504
540
|
}
|
|
505
541
|
if (options.appID) {
|
|
506
|
-
const normalized = typeof options.appID === "string" ?
|
|
542
|
+
const normalized = typeof options.appID === "string" ? addHexPrefix2(options.appID) : options.appID;
|
|
507
543
|
if (isAddress2(normalized)) {
|
|
508
544
|
return normalized;
|
|
509
545
|
}
|
|
@@ -519,7 +555,7 @@ async function getOrPromptAppID(appIDOrOptions, environment) {
|
|
|
519
555
|
const apps = listApps(options.environment);
|
|
520
556
|
const foundAppID = apps[options.appID];
|
|
521
557
|
if (foundAppID) {
|
|
522
|
-
return
|
|
558
|
+
return addHexPrefix2(foundAppID);
|
|
523
559
|
}
|
|
524
560
|
throw new Error(
|
|
525
561
|
`App name '${options.appID}' not found in environment '${options.environment}'`
|
|
@@ -530,18 +566,23 @@ async function getOrPromptAppID(appIDOrOptions, environment) {
|
|
|
530
566
|
async function getAppIDInteractive(options) {
|
|
531
567
|
const action = options.action || "view";
|
|
532
568
|
const environment = options.environment || "sepolia";
|
|
533
|
-
const environmentConfig =
|
|
569
|
+
const environmentConfig = getEnvironmentConfig2(environment);
|
|
534
570
|
if (!options.privateKey || !options.rpcUrl) {
|
|
535
571
|
return getAppIDInteractiveFromRegistry(environment, action);
|
|
536
572
|
}
|
|
537
573
|
console.log(`
|
|
538
574
|
Select an app to ${action}:
|
|
539
575
|
`);
|
|
540
|
-
const privateKeyHex =
|
|
541
|
-
const account =
|
|
576
|
+
const privateKeyHex = addHexPrefix2(options.privateKey);
|
|
577
|
+
const account = privateKeyToAccount3(privateKeyHex);
|
|
542
578
|
const developerAddr = account.address;
|
|
579
|
+
const { publicClient, walletClient } = createViemClients({
|
|
580
|
+
privateKey: options.privateKey,
|
|
581
|
+
rpcUrl: options.rpcUrl,
|
|
582
|
+
environment
|
|
583
|
+
});
|
|
543
584
|
const { apps, appConfigs } = await getAllAppsByDeveloper2(
|
|
544
|
-
|
|
585
|
+
publicClient,
|
|
545
586
|
environmentConfig,
|
|
546
587
|
developerAddr
|
|
547
588
|
);
|
|
@@ -554,9 +595,9 @@ Select an app to ${action}:
|
|
|
554
595
|
try {
|
|
555
596
|
const userApiClient = new UserApiClient2(
|
|
556
597
|
environmentConfig,
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
getClientId()
|
|
598
|
+
walletClient,
|
|
599
|
+
publicClient,
|
|
600
|
+
{ clientId: getClientId() }
|
|
560
601
|
);
|
|
561
602
|
const appInfos = await getAppInfosChunked(userApiClient, apps);
|
|
562
603
|
const freshProfiles = {};
|
|
@@ -680,14 +721,14 @@ async function getAppIDInteractiveFromRegistry(environment, action) {
|
|
|
680
721
|
if (!value) {
|
|
681
722
|
return "App ID or name cannot be empty";
|
|
682
723
|
}
|
|
683
|
-
const normalized2 =
|
|
724
|
+
const normalized2 = addHexPrefix2(value);
|
|
684
725
|
if (isAddress2(normalized2)) {
|
|
685
726
|
return true;
|
|
686
727
|
}
|
|
687
728
|
return "Invalid app ID address";
|
|
688
729
|
}
|
|
689
730
|
});
|
|
690
|
-
const normalized =
|
|
731
|
+
const normalized = addHexPrefix2(appIDInput);
|
|
691
732
|
if (isAddress2(normalized)) {
|
|
692
733
|
return normalized;
|
|
693
734
|
}
|
|
@@ -723,7 +764,7 @@ Select an app to ${action}:`);
|
|
|
723
764
|
if (!value) {
|
|
724
765
|
return "App ID or name cannot be empty";
|
|
725
766
|
}
|
|
726
|
-
const normalized2 =
|
|
767
|
+
const normalized2 = addHexPrefix2(value);
|
|
727
768
|
if (isAddress2(normalized2)) {
|
|
728
769
|
return true;
|
|
729
770
|
}
|
|
@@ -733,17 +774,17 @@ Select an app to ${action}:`);
|
|
|
733
774
|
return "Invalid app ID or name not found";
|
|
734
775
|
}
|
|
735
776
|
});
|
|
736
|
-
const normalized =
|
|
777
|
+
const normalized = addHexPrefix2(appIDInput);
|
|
737
778
|
if (isAddress2(normalized)) {
|
|
738
779
|
return normalized;
|
|
739
780
|
}
|
|
740
781
|
const foundAppID = allApps[appIDInput];
|
|
741
782
|
if (foundAppID) {
|
|
742
|
-
return
|
|
783
|
+
return addHexPrefix2(foundAppID);
|
|
743
784
|
}
|
|
744
785
|
throw new Error(`Failed to resolve app ID from input: ${appIDInput}`);
|
|
745
786
|
}
|
|
746
|
-
return
|
|
787
|
+
return addHexPrefix2(selected);
|
|
747
788
|
}
|
|
748
789
|
async function getPrivateKeyInteractive(privateKey) {
|
|
749
790
|
if (privateKey) {
|
|
@@ -775,7 +816,7 @@ async function getPrivateKeyInteractive(privateKey) {
|
|
|
775
816
|
async function getEnvironmentInteractive(environment) {
|
|
776
817
|
if (environment) {
|
|
777
818
|
try {
|
|
778
|
-
|
|
819
|
+
getEnvironmentConfig2(environment);
|
|
779
820
|
if (!isEnvironmentAvailable(environment)) {
|
|
780
821
|
throw new Error(`Environment ${environment} is not available in this build`);
|
|
781
822
|
}
|
|
@@ -788,7 +829,7 @@ async function getEnvironmentInteractive(environment) {
|
|
|
788
829
|
const configDefaultEnv = getDefaultEnvironment();
|
|
789
830
|
if (configDefaultEnv && availableEnvs.includes(configDefaultEnv)) {
|
|
790
831
|
try {
|
|
791
|
-
|
|
832
|
+
getEnvironmentConfig2(configDefaultEnv);
|
|
792
833
|
defaultEnv = configDefaultEnv;
|
|
793
834
|
} catch {
|
|
794
835
|
}
|
|
@@ -926,12 +967,14 @@ async function getAppProfileInteractive(defaultName = "", allowRetry = true) {
|
|
|
926
967
|
const description = await getAppDescriptionInteractive();
|
|
927
968
|
const xURL = await getAppXURLInteractive();
|
|
928
969
|
const imagePath = await getAppImageInteractive();
|
|
970
|
+
const { image, imageName } = imagePathToBlob(imagePath);
|
|
929
971
|
const profile = {
|
|
930
972
|
name,
|
|
931
973
|
website,
|
|
932
974
|
description,
|
|
933
975
|
xURL,
|
|
934
|
-
|
|
976
|
+
image,
|
|
977
|
+
imageName
|
|
935
978
|
};
|
|
936
979
|
console.log("\n" + formatProfileForDisplay(profile));
|
|
937
980
|
const confirmed = await inquirerConfirm({
|
|
@@ -1066,12 +1109,25 @@ function formatProfileForDisplay(profile) {
|
|
|
1066
1109
|
output += ` X URL: ${profile.xURL}
|
|
1067
1110
|
`;
|
|
1068
1111
|
}
|
|
1069
|
-
if (profile.
|
|
1070
|
-
output += ` Image: ${profile.
|
|
1112
|
+
if (profile.imageName) {
|
|
1113
|
+
output += ` Image: ${profile.imageName}
|
|
1071
1114
|
`;
|
|
1072
1115
|
}
|
|
1073
1116
|
return output;
|
|
1074
1117
|
}
|
|
1118
|
+
function imagePathToBlob(imagePath) {
|
|
1119
|
+
if (!imagePath) {
|
|
1120
|
+
return { image: void 0, imageName: void 0 };
|
|
1121
|
+
}
|
|
1122
|
+
try {
|
|
1123
|
+
const fileBuffer = fs3.readFileSync(imagePath);
|
|
1124
|
+
const imageName = path3.basename(imagePath);
|
|
1125
|
+
return { image: new Blob([fileBuffer]), imageName };
|
|
1126
|
+
} catch (err) {
|
|
1127
|
+
console.error(`Failed to read image file: ${err}`);
|
|
1128
|
+
return { image: void 0, imageName: void 0 };
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1075
1131
|
|
|
1076
1132
|
// src/flags.ts
|
|
1077
1133
|
var commonFlags = {
|
|
@@ -1110,14 +1166,14 @@ import {
|
|
|
1110
1166
|
createComputeModule,
|
|
1111
1167
|
createBillingModule,
|
|
1112
1168
|
createBuildModule,
|
|
1113
|
-
getEnvironmentConfig as
|
|
1169
|
+
getEnvironmentConfig as getEnvironmentConfig3,
|
|
1114
1170
|
requirePrivateKey,
|
|
1115
1171
|
getPrivateKeyWithSource
|
|
1116
1172
|
} from "@layr-labs/ecloud-sdk";
|
|
1117
1173
|
async function createComputeClient(flags) {
|
|
1118
1174
|
flags = await validateCommonFlags(flags);
|
|
1119
1175
|
const environment = flags.environment;
|
|
1120
|
-
const environmentConfig =
|
|
1176
|
+
const environmentConfig = getEnvironmentConfig3(environment);
|
|
1121
1177
|
const rpcUrl = flags["rpc-url"] || environmentConfig.defaultRPCURL;
|
|
1122
1178
|
const { key: privateKey, source } = await requirePrivateKey({
|
|
1123
1179
|
privateKey: flags["private-key"]
|
|
@@ -1125,10 +1181,15 @@ async function createComputeClient(flags) {
|
|
|
1125
1181
|
if (flags.verbose) {
|
|
1126
1182
|
console.log(`Using private key from: ${source}`);
|
|
1127
1183
|
}
|
|
1128
|
-
|
|
1129
|
-
verbose: flags.verbose,
|
|
1184
|
+
const { walletClient, publicClient } = createViemClients({
|
|
1130
1185
|
privateKey,
|
|
1131
1186
|
rpcUrl,
|
|
1187
|
+
environment
|
|
1188
|
+
});
|
|
1189
|
+
return createComputeModule({
|
|
1190
|
+
verbose: flags.verbose,
|
|
1191
|
+
walletClient,
|
|
1192
|
+
publicClient,
|
|
1132
1193
|
environment,
|
|
1133
1194
|
clientId: getClientId(),
|
|
1134
1195
|
skipTelemetry: true
|
|
@@ -1234,7 +1295,7 @@ var ProfileSet = class _ProfileSet extends Command {
|
|
|
1234
1295
|
const { args, flags } = await this.parse(_ProfileSet);
|
|
1235
1296
|
const compute = await createComputeClient(flags);
|
|
1236
1297
|
const environment = flags.environment;
|
|
1237
|
-
const environmentConfig =
|
|
1298
|
+
const environmentConfig = getEnvironmentConfig4(environment);
|
|
1238
1299
|
const rpcUrl = flags["rpc-url"] || environmentConfig.defaultRPCURL;
|
|
1239
1300
|
const privateKey = flags["private-key"];
|
|
1240
1301
|
const resolver = createAppResolver(environment, environmentConfig, privateKey, rpcUrl);
|
|
@@ -1249,23 +1310,31 @@ var ProfileSet = class _ProfileSet extends Command {
|
|
|
1249
1310
|
Setting profile for app: ${chalk.cyan(appId)}`);
|
|
1250
1311
|
let profile;
|
|
1251
1312
|
if (flags.name) {
|
|
1252
|
-
|
|
1313
|
+
const validationError = validateAppProfile({
|
|
1253
1314
|
name: flags.name,
|
|
1254
1315
|
website: flags.website,
|
|
1255
1316
|
description: flags.description,
|
|
1256
1317
|
xURL: flags["x-url"],
|
|
1257
1318
|
imagePath: flags.image
|
|
1258
|
-
};
|
|
1259
|
-
const validationError = validateAppProfile(profile);
|
|
1319
|
+
});
|
|
1260
1320
|
if (validationError) {
|
|
1261
1321
|
this.error(validationError);
|
|
1262
1322
|
}
|
|
1323
|
+
const { image, imageName } = imagePathToBlob(flags.image);
|
|
1324
|
+
profile = {
|
|
1325
|
+
name: flags.name,
|
|
1326
|
+
website: flags.website,
|
|
1327
|
+
description: flags.description,
|
|
1328
|
+
xURL: flags["x-url"],
|
|
1329
|
+
image,
|
|
1330
|
+
imageName
|
|
1331
|
+
};
|
|
1263
1332
|
this.log("\n\u{1F4CB} Profile Summary:");
|
|
1264
1333
|
this.log(` Name: ${profile.name}`);
|
|
1265
1334
|
if (profile.website) this.log(` Website: ${profile.website}`);
|
|
1266
1335
|
if (profile.description) this.log(` Description: ${profile.description}`);
|
|
1267
1336
|
if (profile.xURL) this.log(` X URL: ${profile.xURL}`);
|
|
1268
|
-
if (profile.
|
|
1337
|
+
if (profile.imageName) this.log(` Image: ${profile.imageName}`);
|
|
1269
1338
|
} else {
|
|
1270
1339
|
this.log("\nEnter profile information:");
|
|
1271
1340
|
profile = await getAppProfileInteractive("", true);
|