@layr-labs/ecloud-cli 0.0.1-dev-rfc.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/README.md +195 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +5 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/dist/commands/app/create.js +29 -0
- package/dist/commands/app/create.js.map +1 -0
- package/dist/commands/app/deploy.js +142 -0
- package/dist/commands/app/deploy.js.map +1 -0
- package/dist/commands/app/logs.js +108 -0
- package/dist/commands/app/logs.js.map +1 -0
- package/dist/commands/app/start.js +121 -0
- package/dist/commands/app/start.js.map +1 -0
- package/dist/commands/app/stop.js +121 -0
- package/dist/commands/app/stop.js.map +1 -0
- package/dist/commands/app/terminate.js +128 -0
- package/dist/commands/app/terminate.js.map +1 -0
- package/dist/commands/app/upgrade.js +142 -0
- package/dist/commands/app/upgrade.js.map +1 -0
- package/dist/commands/auth/generate.js +101 -0
- package/dist/commands/auth/generate.js.map +1 -0
- package/dist/commands/auth/login.js +150 -0
- package/dist/commands/auth/login.js.map +1 -0
- package/dist/commands/auth/logout.js +64 -0
- package/dist/commands/auth/logout.js.map +1 -0
- package/dist/commands/auth/migrate.js +129 -0
- package/dist/commands/auth/migrate.js.map +1 -0
- package/dist/commands/auth/whoami.js +87 -0
- package/dist/commands/auth/whoami.js.map +1 -0
- package/dist/commands/billing/cancel.js +132 -0
- package/dist/commands/billing/cancel.js.map +1 -0
- package/dist/commands/billing/status.js +175 -0
- package/dist/commands/billing/status.js.map +1 -0
- package/dist/commands/billing/subscribe.js +157 -0
- package/dist/commands/billing/subscribe.js.map +1 -0
- package/dist/keys/mainnet-alpha/prod/kms-encryption-public-key.pem +14 -0
- package/dist/keys/mainnet-alpha/prod/kms-signing-public-key.pem +4 -0
- package/dist/keys/sepolia/dev/kms-encryption-public-key.pem +14 -0
- package/dist/keys/sepolia/dev/kms-signing-public-key.pem +4 -0
- package/dist/keys/sepolia/prod/kms-encryption-public-key.pem +14 -0
- package/dist/keys/sepolia/prod/kms-signing-public-key.pem +4 -0
- package/dist/templates/Dockerfile.layered.tmpl +58 -0
- package/dist/templates/compute-source-env.sh.tmpl +110 -0
- package/package.json +53 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/auth/login.ts
|
|
4
|
+
import { Command } from "@oclif/core";
|
|
5
|
+
import { confirm, select } from "@inquirer/prompts";
|
|
6
|
+
import {
|
|
7
|
+
storePrivateKey,
|
|
8
|
+
keyExists,
|
|
9
|
+
getHiddenInput,
|
|
10
|
+
validatePrivateKey,
|
|
11
|
+
getAddressFromPrivateKey,
|
|
12
|
+
displayWarning,
|
|
13
|
+
getLegacyKeys,
|
|
14
|
+
getLegacyPrivateKey,
|
|
15
|
+
deleteLegacyPrivateKey
|
|
16
|
+
} from "@layr-labs/ecloud-sdk";
|
|
17
|
+
var AuthLogin = class extends Command {
|
|
18
|
+
static description = "Store your private key in OS keyring";
|
|
19
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
20
|
+
async run() {
|
|
21
|
+
const exists = await keyExists();
|
|
22
|
+
if (exists) {
|
|
23
|
+
displayWarning([
|
|
24
|
+
"WARNING: A private key for ecloud already exists!",
|
|
25
|
+
"Replacing it will cause PERMANENT DATA LOSS if not backed up.",
|
|
26
|
+
"The previous key will be lost forever."
|
|
27
|
+
]);
|
|
28
|
+
const confirmReplace = await confirm({
|
|
29
|
+
message: "Replace existing key?",
|
|
30
|
+
default: false
|
|
31
|
+
});
|
|
32
|
+
if (!confirmReplace) {
|
|
33
|
+
this.log("\nLogin cancelled.");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const legacyKeys = await getLegacyKeys();
|
|
38
|
+
let privateKey = null;
|
|
39
|
+
let selectedKey = null;
|
|
40
|
+
if (legacyKeys.length > 0) {
|
|
41
|
+
this.log("\nFound legacy keys from eigenx-cli:");
|
|
42
|
+
this.log("");
|
|
43
|
+
for (const key of legacyKeys) {
|
|
44
|
+
this.log(` Address: ${key.address}`);
|
|
45
|
+
this.log(` Environment: ${key.environment}`);
|
|
46
|
+
this.log(` Source: ${key.source}`);
|
|
47
|
+
this.log("");
|
|
48
|
+
}
|
|
49
|
+
const importLegacy = await confirm({
|
|
50
|
+
message: "Would you like to import one of these legacy keys?",
|
|
51
|
+
default: false
|
|
52
|
+
});
|
|
53
|
+
if (importLegacy) {
|
|
54
|
+
const choices = legacyKeys.map((key) => ({
|
|
55
|
+
name: `${key.address} (${key.environment} - ${key.source})`,
|
|
56
|
+
value: key
|
|
57
|
+
}));
|
|
58
|
+
selectedKey = await select({
|
|
59
|
+
message: "Select a key to import:",
|
|
60
|
+
choices
|
|
61
|
+
});
|
|
62
|
+
privateKey = await getLegacyPrivateKey(
|
|
63
|
+
selectedKey.environment,
|
|
64
|
+
selectedKey.source
|
|
65
|
+
);
|
|
66
|
+
if (!privateKey) {
|
|
67
|
+
this.error(
|
|
68
|
+
`Failed to retrieve legacy key for ${selectedKey.environment}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
this.log(
|
|
72
|
+
`
|
|
73
|
+
Importing key from ${selectedKey.source}:${selectedKey.environment}`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (!privateKey) {
|
|
78
|
+
privateKey = await getHiddenInput("Enter your private key:");
|
|
79
|
+
privateKey = privateKey.trim();
|
|
80
|
+
}
|
|
81
|
+
if (!validatePrivateKey(privateKey)) {
|
|
82
|
+
this.error("Invalid private key format. Please check and try again.");
|
|
83
|
+
}
|
|
84
|
+
const address = getAddressFromPrivateKey(privateKey);
|
|
85
|
+
this.log(`
|
|
86
|
+
Address: ${address}`);
|
|
87
|
+
const confirmStore = await confirm({
|
|
88
|
+
message: "Store this key in OS keyring?",
|
|
89
|
+
default: true
|
|
90
|
+
});
|
|
91
|
+
if (!confirmStore) {
|
|
92
|
+
this.log("\nLogin cancelled.");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
await storePrivateKey(privateKey);
|
|
97
|
+
this.log("\n\u2713 Private key stored in OS keyring");
|
|
98
|
+
this.log(`\u2713 Address: ${address}`);
|
|
99
|
+
this.log(
|
|
100
|
+
"\nNote: This key will be used for all environments (mainnet, sepolia, etc.)"
|
|
101
|
+
);
|
|
102
|
+
this.log("You can now use ecloud commands without --private-key flag.");
|
|
103
|
+
if (selectedKey) {
|
|
104
|
+
this.log("");
|
|
105
|
+
const confirmDelete = await confirm({
|
|
106
|
+
message: `Delete the legacy key from ${selectedKey.source}:${selectedKey.environment}?`,
|
|
107
|
+
default: false
|
|
108
|
+
});
|
|
109
|
+
if (confirmDelete) {
|
|
110
|
+
const deleted = await deleteLegacyPrivateKey(
|
|
111
|
+
selectedKey.environment,
|
|
112
|
+
selectedKey.source
|
|
113
|
+
);
|
|
114
|
+
if (deleted) {
|
|
115
|
+
this.log(
|
|
116
|
+
`
|
|
117
|
+
\u2713 Legacy key deleted from ${selectedKey.source}:${selectedKey.environment}`
|
|
118
|
+
);
|
|
119
|
+
this.log(
|
|
120
|
+
"\nNote: The key is now only stored in ecloud. You can still use it with"
|
|
121
|
+
);
|
|
122
|
+
this.log(
|
|
123
|
+
"eigenx-cli by providing --private-key flag or EIGENX_PRIVATE_KEY env var."
|
|
124
|
+
);
|
|
125
|
+
} else {
|
|
126
|
+
this.log(
|
|
127
|
+
`
|
|
128
|
+
\u26A0\uFE0F Failed to delete legacy key from ${selectedKey.source}:${selectedKey.environment}`
|
|
129
|
+
);
|
|
130
|
+
this.log("The key may have already been removed.");
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
this.log(
|
|
134
|
+
`
|
|
135
|
+
Legacy key kept in ${selectedKey.source}:${selectedKey.environment}`
|
|
136
|
+
);
|
|
137
|
+
this.log(
|
|
138
|
+
"You can delete it later using 'eigenx auth logout' if needed."
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
this.error(`Failed to store key: ${err.message}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
export {
|
|
148
|
+
AuthLogin as default
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/auth/login.ts"],"sourcesContent":["/**\n * Auth Login Command\n *\n * Store an existing private key in OS keyring\n */\n\nimport { Command } from \"@oclif/core\";\nimport { confirm, select } from \"@inquirer/prompts\";\nimport {\n storePrivateKey,\n keyExists,\n getHiddenInput,\n validatePrivateKey,\n getAddressFromPrivateKey,\n displayWarning,\n getLegacyKeys,\n getLegacyPrivateKey,\n deleteLegacyPrivateKey,\n type LegacyKey,\n} from \"@layr-labs/ecloud-sdk\";\n\nexport default class AuthLogin extends Command {\n static description = \"Store your private key in OS keyring\";\n\n static examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n async run(): Promise<void> {\n // Check if key already exists\n const exists = await keyExists();\n\n if (exists) {\n displayWarning([\n \"WARNING: A private key for ecloud already exists!\",\n \"Replacing it will cause PERMANENT DATA LOSS if not backed up.\",\n \"The previous key will be lost forever.\",\n ]);\n\n const confirmReplace = await confirm({\n message: \"Replace existing key?\",\n default: false,\n });\n\n if (!confirmReplace) {\n this.log(\"\\nLogin cancelled.\");\n return;\n }\n }\n\n // Check for legacy keys from eigenx-cli\n const legacyKeys = await getLegacyKeys();\n let privateKey: string | null = null;\n let selectedKey: LegacyKey | null = null;\n\n if (legacyKeys.length > 0) {\n this.log(\"\\nFound legacy keys from eigenx-cli:\");\n this.log(\"\");\n\n // Display legacy keys\n for (const key of legacyKeys) {\n this.log(` Address: ${key.address}`);\n this.log(` Environment: ${key.environment}`);\n this.log(` Source: ${key.source}`);\n this.log(\"\");\n }\n\n const importLegacy = await confirm({\n message: \"Would you like to import one of these legacy keys?\",\n default: false,\n });\n\n if (importLegacy) {\n // Create choices for selection\n const choices = legacyKeys.map((key) => ({\n name: `${key.address} (${key.environment} - ${key.source})`,\n value: key,\n }));\n\n selectedKey = await select<LegacyKey>({\n message: \"Select a key to import:\",\n choices,\n });\n\n // Retrieve the actual private key\n privateKey = await getLegacyPrivateKey(\n selectedKey.environment,\n selectedKey.source\n );\n\n if (!privateKey) {\n this.error(\n `Failed to retrieve legacy key for ${selectedKey.environment}`\n );\n }\n\n this.log(\n `\\nImporting key from ${selectedKey.source}:${selectedKey.environment}`\n );\n }\n }\n\n // If no legacy key was selected, prompt for private key input\n if (!privateKey) {\n privateKey = await getHiddenInput(\"Enter your private key:\");\n\n privateKey = privateKey.trim();\n }\n\n if (!validatePrivateKey(privateKey)) {\n this.error(\"Invalid private key format. Please check and try again.\");\n }\n\n // Derive address for confirmation\n const address = getAddressFromPrivateKey(privateKey);\n\n this.log(`\\nAddress: ${address}`);\n\n const confirmStore = await confirm({\n message: \"Store this key in OS keyring?\",\n default: true,\n });\n\n if (!confirmStore) {\n this.log(\"\\nLogin cancelled.\");\n return;\n }\n\n // Store in keyring\n try {\n await storePrivateKey(privateKey);\n this.log(\"\\n✓ Private key stored in OS keyring\");\n this.log(`✓ Address: ${address}`);\n this.log(\n \"\\nNote: This key will be used for all environments (mainnet, sepolia, etc.)\"\n );\n this.log(\"You can now use ecloud commands without --private-key flag.\");\n\n // Ask if user wants to delete the legacy key (only if save was successful)\n if (selectedKey) {\n this.log(\"\");\n const confirmDelete = await confirm({\n message: `Delete the legacy key from ${selectedKey.source}:${selectedKey.environment}?`,\n default: false,\n });\n\n if (confirmDelete) {\n const deleted = await deleteLegacyPrivateKey(\n selectedKey.environment,\n selectedKey.source\n );\n\n if (deleted) {\n this.log(\n `\\n✓ Legacy key deleted from ${selectedKey.source}:${selectedKey.environment}`\n );\n this.log(\n \"\\nNote: The key is now only stored in ecloud. You can still use it with\"\n );\n this.log(\n \"eigenx-cli by providing --private-key flag or EIGENX_PRIVATE_KEY env var.\"\n );\n } else {\n this.log(\n `\\n⚠️ Failed to delete legacy key from ${selectedKey.source}:${selectedKey.environment}`\n );\n this.log(\"The key may have already been removed.\");\n }\n } else {\n this.log(\n `\\nLegacy key kept in ${selectedKey.source}:${selectedKey.environment}`\n );\n this.log(\n \"You can delete it later using 'eigenx auth logout' if needed.\"\n );\n }\n }\n } catch (err: any) {\n this.error(`Failed to store key: ${err.message}`);\n }\n }\n}\n"],"mappings":";;;AAMA,SAAS,eAAe;AACxB,SAAS,SAAS,cAAc;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,IAAqB,YAArB,cAAuC,QAAQ;AAAA,EAC7C,OAAO,cAAc;AAAA,EAErB,OAAO,WAAW,CAAC,qCAAqC;AAAA,EAExD,MAAM,MAAqB;AAEzB,UAAM,SAAS,MAAM,UAAU;AAE/B,QAAI,QAAQ;AACV,qBAAe;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAED,YAAM,iBAAiB,MAAM,QAAQ;AAAA,QACnC,SAAS;AAAA,QACT,SAAS;AAAA,MACX,CAAC;AAED,UAAI,CAAC,gBAAgB;AACnB,aAAK,IAAI,oBAAoB;AAC7B;AAAA,MACF;AAAA,IACF;AAGA,UAAM,aAAa,MAAM,cAAc;AACvC,QAAI,aAA4B;AAChC,QAAI,cAAgC;AAEpC,QAAI,WAAW,SAAS,GAAG;AACzB,WAAK,IAAI,sCAAsC;AAC/C,WAAK,IAAI,EAAE;AAGX,iBAAW,OAAO,YAAY;AAC5B,aAAK,IAAI,cAAc,IAAI,OAAO,EAAE;AACpC,aAAK,IAAI,kBAAkB,IAAI,WAAW,EAAE;AAC5C,aAAK,IAAI,aAAa,IAAI,MAAM,EAAE;AAClC,aAAK,IAAI,EAAE;AAAA,MACb;AAEA,YAAM,eAAe,MAAM,QAA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,YAAY,WAAW;AAAA,UACpF,SAAS;AAAA,QACX,CAAC;AAED,YAAI,eAAe;AACjB,gBAAM,UAAU,MAAM;AAAA,YACpB,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAEA,cAAI,SAAS;AACX,iBAAK;AAAA,cACH;AAAA,iCAA+B,YAAY,MAAM,IAAI,YAAY,WAAW;AAAA,YAC9E;AACA,iBAAK;AAAA,cACH;AAAA,YACF;AACA,iBAAK;AAAA,cACH;AAAA,YACF;AAAA,UACF,OAAO;AACL,iBAAK;AAAA,cACH;AAAA,iDAA0C,YAAY,MAAM,IAAI,YAAY,WAAW;AAAA,YACzF;AACA,iBAAK,IAAI,wCAAwC;AAAA,UACnD;AAAA,QACF,OAAO;AACL,eAAK;AAAA,YACH;AAAA,qBAAwB,YAAY,MAAM,IAAI,YAAY,WAAW;AAAA,UACvE;AACA,eAAK;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,KAAU;AACjB,WAAK,MAAM,wBAAwB,IAAI,OAAO,EAAE;AAAA,IAClD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/auth/logout.ts
|
|
4
|
+
import { Command, Flags } from "@oclif/core";
|
|
5
|
+
import { confirm } from "@inquirer/prompts";
|
|
6
|
+
import {
|
|
7
|
+
deletePrivateKey,
|
|
8
|
+
getPrivateKey,
|
|
9
|
+
getAddressFromPrivateKey
|
|
10
|
+
} from "@layr-labs/ecloud-sdk";
|
|
11
|
+
var AuthLogout = class _AuthLogout extends Command {
|
|
12
|
+
static description = "Remove private key from OS keyring";
|
|
13
|
+
static examples = [
|
|
14
|
+
"<%= config.bin %> <%= command.id %>",
|
|
15
|
+
"<%= config.bin %> <%= command.id %> --force"
|
|
16
|
+
];
|
|
17
|
+
static flags = {
|
|
18
|
+
force: Flags.boolean({
|
|
19
|
+
description: "Skip confirmation prompt",
|
|
20
|
+
default: false
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
async run() {
|
|
24
|
+
const { flags } = await this.parse(_AuthLogout);
|
|
25
|
+
const privateKey = await getPrivateKey();
|
|
26
|
+
if (!privateKey) {
|
|
27
|
+
this.log("No key found in keyring");
|
|
28
|
+
this.log("\nNothing to remove.");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const address = getAddressFromPrivateKey(privateKey);
|
|
32
|
+
this.log("Found stored key:");
|
|
33
|
+
this.log(` Address: ${address}`);
|
|
34
|
+
this.log("");
|
|
35
|
+
if (!flags.force) {
|
|
36
|
+
const confirmed = await confirm({
|
|
37
|
+
message: "Remove private key from keyring?",
|
|
38
|
+
default: false
|
|
39
|
+
});
|
|
40
|
+
if (!confirmed) {
|
|
41
|
+
this.log("Logout cancelled");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const deleted = await deletePrivateKey();
|
|
47
|
+
if (deleted) {
|
|
48
|
+
this.log("\n\u2713 Successfully removed key from keyring");
|
|
49
|
+
this.log(
|
|
50
|
+
"\nYou will need to provide --private-key flag for future commands,"
|
|
51
|
+
);
|
|
52
|
+
this.log("or run 'ecloud auth login' to store a key again.");
|
|
53
|
+
} else {
|
|
54
|
+
this.log("\nFailed to remove key (it may have already been removed)");
|
|
55
|
+
}
|
|
56
|
+
} catch (err) {
|
|
57
|
+
this.error(`Failed to remove key: ${err.message}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
AuthLogout as default
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/auth/logout.ts"],"sourcesContent":["/**\n * Auth Logout Command\n *\n * Remove private key from OS keyring\n */\n\nimport { Command, Flags } from \"@oclif/core\";\nimport { confirm } from \"@inquirer/prompts\";\nimport {\n deletePrivateKey,\n getPrivateKey,\n getAddressFromPrivateKey,\n} from \"@layr-labs/ecloud-sdk\";\n\nexport default class AuthLogout extends Command {\n static description = \"Remove private key from OS keyring\";\n\n static examples = [\n \"<%= config.bin %> <%= command.id %>\",\n \"<%= config.bin %> <%= command.id %> --force\",\n ];\n\n static flags = {\n force: Flags.boolean({\n description: \"Skip confirmation prompt\",\n default: false,\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(AuthLogout);\n\n // Check if key exists\n const privateKey = await getPrivateKey();\n\n if (!privateKey) {\n this.log(\"No key found in keyring\");\n this.log(\"\\nNothing to remove.\");\n return;\n }\n\n // Show address\n const address = getAddressFromPrivateKey(privateKey);\n this.log(\"Found stored key:\");\n this.log(` Address: ${address}`);\n this.log(\"\");\n\n // Confirm unless forced\n if (!flags.force) {\n const confirmed = await confirm({\n message: \"Remove private key from keyring?\",\n default: false,\n });\n\n if (!confirmed) {\n this.log(\"Logout cancelled\");\n return;\n }\n }\n\n // Remove from keyring\n try {\n const deleted = await deletePrivateKey();\n\n if (deleted) {\n this.log(\"\\n✓ Successfully removed key from keyring\");\n this.log(\n \"\\nYou will need to provide --private-key flag for future commands,\"\n );\n this.log(\"or run 'ecloud auth login' to store a key again.\");\n } else {\n this.log(\"\\nFailed to remove key (it may have already been removed)\");\n }\n } catch (err: any) {\n this.error(`Failed to remove key: ${err.message}`);\n }\n }\n}\n"],"mappings":";;;AAMA,SAAS,SAAS,aAAa;AAC/B,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,IAAqB,aAArB,MAAqB,oBAAmB,QAAQ;AAAA,EAC9C,OAAO,cAAc;AAAA,EAErB,OAAO,WAAW;AAAA,IAChB;AAAA,IACA;AAAA,EACF;AAAA,EAEA,OAAO,QAAQ;AAAA,IACb,OAAO,MAAM,QAAQ;AAAA,MACnB,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,MAAqB;AACzB,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,MAAM,WAAU;AAG7C,UAAM,aAAa,MAAM,cAAc;AAEvC,QAAI,CAAC,YAAY;AACf,WAAK,IAAI,yBAAyB;AAClC,WAAK,IAAI,sBAAsB;AAC/B;AAAA,IACF;AAGA,UAAM,UAAU,yBAAyB,UAAU;AACnD,SAAK,IAAI,mBAAmB;AAC5B,SAAK,IAAI,cAAc,OAAO,EAAE;AAChC,SAAK,IAAI,EAAE;AAGX,QAAI,CAAC,MAAM,OAAO;AAChB,YAAM,YAAY,MAAM,QAAQ;AAAA,QAC9B,SAAS;AAAA,QACT,SAAS;AAAA,MACX,CAAC;AAED,UAAI,CAAC,WAAW;AACd,aAAK,IAAI,kBAAkB;AAC3B;AAAA,MACF;AAAA,IACF;AAGA,QAAI;AACF,YAAM,UAAU,MAAM,iBAAiB;AAEvC,UAAI,SAAS;AACX,aAAK,IAAI,gDAA2C;AACpD,aAAK;AAAA,UACH;AAAA,QACF;AACA,aAAK,IAAI,kDAAkD;AAAA,MAC7D,OAAO;AACL,aAAK,IAAI,2DAA2D;AAAA,MACtE;AAAA,IACF,SAAS,KAAU;AACjB,WAAK,MAAM,yBAAyB,IAAI,OAAO,EAAE;AAAA,IACnD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/auth/migrate.ts
|
|
4
|
+
import { Command } from "@oclif/core";
|
|
5
|
+
import { confirm, select } from "@inquirer/prompts";
|
|
6
|
+
import {
|
|
7
|
+
storePrivateKey,
|
|
8
|
+
keyExists,
|
|
9
|
+
getAddressFromPrivateKey,
|
|
10
|
+
displayWarning,
|
|
11
|
+
getLegacyKeys,
|
|
12
|
+
getLegacyPrivateKey,
|
|
13
|
+
deleteLegacyPrivateKey
|
|
14
|
+
} from "@layr-labs/ecloud-sdk";
|
|
15
|
+
var AuthMigrate = class extends Command {
|
|
16
|
+
static description = "Migrate a private key from eigenx-cli to ecloud";
|
|
17
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
18
|
+
async run() {
|
|
19
|
+
const legacyKeys = await getLegacyKeys();
|
|
20
|
+
if (legacyKeys.length === 0) {
|
|
21
|
+
this.log("No legacy keys found from eigenx-cli.");
|
|
22
|
+
this.log("");
|
|
23
|
+
this.log("To manually add a key to ecloud, use:");
|
|
24
|
+
this.log(" ecloud auth login");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.log("\nFound legacy keys from eigenx-cli:");
|
|
28
|
+
this.log("");
|
|
29
|
+
for (const key of legacyKeys) {
|
|
30
|
+
this.log(` Address: ${key.address}`);
|
|
31
|
+
this.log(` Environment: ${key.environment}`);
|
|
32
|
+
this.log(` Source: ${key.source}`);
|
|
33
|
+
this.log("");
|
|
34
|
+
}
|
|
35
|
+
const choices = legacyKeys.map((key) => ({
|
|
36
|
+
name: `${key.address} (${key.environment} - ${key.source})`,
|
|
37
|
+
value: key
|
|
38
|
+
}));
|
|
39
|
+
const selectedKey = await select({
|
|
40
|
+
message: "Select a key to migrate:",
|
|
41
|
+
choices
|
|
42
|
+
});
|
|
43
|
+
const privateKey = await getLegacyPrivateKey(
|
|
44
|
+
selectedKey.environment,
|
|
45
|
+
selectedKey.source
|
|
46
|
+
);
|
|
47
|
+
if (!privateKey) {
|
|
48
|
+
this.error(
|
|
49
|
+
`Failed to retrieve legacy key for ${selectedKey.environment}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
const address = getAddressFromPrivateKey(privateKey);
|
|
53
|
+
this.log(`
|
|
54
|
+
Migrating key: ${address}`);
|
|
55
|
+
this.log(`From: ${selectedKey.source}:${selectedKey.environment}`);
|
|
56
|
+
const exists = await keyExists();
|
|
57
|
+
if (exists) {
|
|
58
|
+
this.log("");
|
|
59
|
+
displayWarning([
|
|
60
|
+
"WARNING: A private key for ecloud already exists!",
|
|
61
|
+
"Replacing it will cause PERMANENT DATA LOSS if not backed up.",
|
|
62
|
+
"The previous key will be lost forever."
|
|
63
|
+
]);
|
|
64
|
+
const confirmReplace = await confirm({
|
|
65
|
+
message: "Replace existing ecloud key?",
|
|
66
|
+
default: false
|
|
67
|
+
});
|
|
68
|
+
if (!confirmReplace) {
|
|
69
|
+
this.log("\nMigration cancelled.");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await storePrivateKey(privateKey);
|
|
75
|
+
this.log("\n\u2713 Private key migrated to ecloud keyring");
|
|
76
|
+
this.log(`\u2713 Address: ${address}`);
|
|
77
|
+
this.log(
|
|
78
|
+
"\nNote: This key will be used for all environments (mainnet, sepolia, etc.)"
|
|
79
|
+
);
|
|
80
|
+
this.log("");
|
|
81
|
+
const confirmDelete = await confirm({
|
|
82
|
+
message: `Delete the legacy key from ${selectedKey.source}:${selectedKey.environment}?`,
|
|
83
|
+
default: false
|
|
84
|
+
});
|
|
85
|
+
if (confirmDelete) {
|
|
86
|
+
const deleted = await deleteLegacyPrivateKey(
|
|
87
|
+
selectedKey.environment,
|
|
88
|
+
selectedKey.source
|
|
89
|
+
);
|
|
90
|
+
if (deleted) {
|
|
91
|
+
this.log(
|
|
92
|
+
`
|
|
93
|
+
\u2713 Legacy key deleted from ${selectedKey.source}:${selectedKey.environment}`
|
|
94
|
+
);
|
|
95
|
+
this.log(
|
|
96
|
+
"\nNote: The key is now only stored in ecloud. You can still use it with"
|
|
97
|
+
);
|
|
98
|
+
this.log(
|
|
99
|
+
"eigenx-cli by providing --private-key flag or EIGENX_PRIVATE_KEY env var."
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
this.log(
|
|
103
|
+
`
|
|
104
|
+
\u26A0\uFE0F Failed to delete legacy key from ${selectedKey.source}:${selectedKey.environment}`
|
|
105
|
+
);
|
|
106
|
+
this.log("The key may have already been removed.");
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
this.log(
|
|
110
|
+
`
|
|
111
|
+
Legacy key kept in ${selectedKey.source}:${selectedKey.environment}`
|
|
112
|
+
);
|
|
113
|
+
this.log(
|
|
114
|
+
"You can delete it later using 'eigenx auth logout' if needed."
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
this.log("");
|
|
118
|
+
this.log(
|
|
119
|
+
"Migration complete! You can now use ecloud commands without --private-key flag."
|
|
120
|
+
);
|
|
121
|
+
} catch (err) {
|
|
122
|
+
this.error(`Failed to migrate key: ${err.message}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
export {
|
|
127
|
+
AuthMigrate as default
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/auth/migrate.ts"],"sourcesContent":["/**\n * Auth Migrate Command\n *\n * Migrate a legacy eigenx-cli key to ecloud\n */\n\nimport { Command } from \"@oclif/core\";\nimport { confirm, select } from \"@inquirer/prompts\";\nimport {\n storePrivateKey,\n keyExists,\n getAddressFromPrivateKey,\n displayWarning,\n getLegacyKeys,\n getLegacyPrivateKey,\n deleteLegacyPrivateKey,\n type LegacyKey,\n} from \"@layr-labs/ecloud-sdk\";\n\nexport default class AuthMigrate extends Command {\n static description = \"Migrate a private key from eigenx-cli to ecloud\";\n\n static examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n async run(): Promise<void> {\n const legacyKeys = await getLegacyKeys();\n\n if (legacyKeys.length === 0) {\n this.log(\"No legacy keys found from eigenx-cli.\");\n this.log(\"\");\n this.log(\"To manually add a key to ecloud, use:\");\n this.log(\" ecloud auth login\");\n return;\n }\n\n // Display found legacy keys\n this.log(\"\\nFound legacy keys from eigenx-cli:\");\n this.log(\"\");\n\n for (const key of legacyKeys) {\n this.log(` Address: ${key.address}`);\n this.log(` Environment: ${key.environment}`);\n this.log(` Source: ${key.source}`);\n this.log(\"\");\n }\n\n // Create choices for selection\n const choices = legacyKeys.map((key) => ({\n name: `${key.address} (${key.environment} - ${key.source})`,\n value: key,\n }));\n\n const selectedKey = await select<LegacyKey>({\n message: \"Select a key to migrate:\",\n choices,\n });\n\n // Retrieve the actual private key\n const privateKey = await getLegacyPrivateKey(\n selectedKey.environment,\n selectedKey.source\n );\n\n if (!privateKey) {\n this.error(\n `Failed to retrieve legacy key for ${selectedKey.environment}`\n );\n }\n\n // Derive address for display\n const address = getAddressFromPrivateKey(privateKey);\n this.log(`\\nMigrating key: ${address}`);\n this.log(`From: ${selectedKey.source}:${selectedKey.environment}`);\n\n // Check if ecloud key already exists\n const exists = await keyExists();\n\n if (exists) {\n this.log(\"\");\n displayWarning([\n \"WARNING: A private key for ecloud already exists!\",\n \"Replacing it will cause PERMANENT DATA LOSS if not backed up.\",\n \"The previous key will be lost forever.\",\n ]);\n\n const confirmReplace = await confirm({\n message: \"Replace existing ecloud key?\",\n default: false,\n });\n\n if (!confirmReplace) {\n this.log(\"\\nMigration cancelled.\");\n return;\n }\n }\n\n // Store in ecloud keyring\n try {\n await storePrivateKey(privateKey);\n this.log(\"\\n✓ Private key migrated to ecloud keyring\");\n this.log(`✓ Address: ${address}`);\n this.log(\n \"\\nNote: This key will be used for all environments (mainnet, sepolia, etc.)\"\n );\n\n // Ask if user wants to delete the legacy key (only if save was successful)\n this.log(\"\");\n const confirmDelete = await confirm({\n message: `Delete the legacy key from ${selectedKey.source}:${selectedKey.environment}?`,\n default: false,\n });\n\n if (confirmDelete) {\n const deleted = await deleteLegacyPrivateKey(\n selectedKey.environment,\n selectedKey.source\n );\n\n if (deleted) {\n this.log(\n `\\n✓ Legacy key deleted from ${selectedKey.source}:${selectedKey.environment}`\n );\n this.log(\n \"\\nNote: The key is now only stored in ecloud. You can still use it with\"\n );\n this.log(\n \"eigenx-cli by providing --private-key flag or EIGENX_PRIVATE_KEY env var.\"\n );\n } else {\n this.log(\n `\\n⚠️ Failed to delete legacy key from ${selectedKey.source}:${selectedKey.environment}`\n );\n this.log(\"The key may have already been removed.\");\n }\n } else {\n this.log(\n `\\nLegacy key kept in ${selectedKey.source}:${selectedKey.environment}`\n );\n this.log(\n \"You can delete it later using 'eigenx auth logout' if needed.\"\n );\n }\n\n this.log(\"\");\n this.log(\n \"Migration complete! You can now use ecloud commands without --private-key flag.\"\n );\n } catch (err: any) {\n this.error(`Failed to migrate key: ${err.message}`);\n }\n }\n}\n"],"mappings":";;;AAMA,SAAS,eAAe;AACxB,SAAS,SAAS,cAAc;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,IAAqB,cAArB,cAAyC,QAAQ;AAAA,EAC/C,OAAO,cAAc;AAAA,EAErB,OAAO,WAAW,CAAC,qCAAqC;AAAA,EAExD,MAAM,MAAqB;AACzB,UAAM,aAAa,MAAM,cAAc;AAEvC,QAAI,WAAW,WAAW,GAAG;AAC3B,WAAK,IAAI,uCAAuC;AAChD,WAAK,IAAI,EAAE;AACX,WAAK,IAAI,uCAAuC;AAChD,WAAK,IAAI,qBAAqB;AAC9B;AAAA,IACF;AAGA,SAAK,IAAI,sCAAsC;AAC/C,SAAK,IAAI,EAAE;AAEX,eAAW,OAAO,YAAY;AAC5B,WAAK,IAAI,cAAc,IAAI,OAAO,EAAE;AACpC,WAAK,IAAI,kBAAkB,IAAI,WAAW,EAAE;AAC5C,WAAK,IAAI,aAAa,IAAI,MAAM,EAAE;AAClC,WAAK,IAAI,EAAE;AAAA,IACb;AAGA,UAAM,UAAU,WAAW,IAAI,CAAC,SAAS;AAAA,MACvC,MAAM,GAAG,IAAI,OAAO,KAAK,IAAI,WAAW,MAAM,IAAI,MAAM;AAAA,MACxD,OAAO;AAAA,IACT,EAAE;AAEF,UAAM,cAAc,MAAM,OAAkB;AAAA,MAC1C,SAAS;AAAA,MACT;AAAA,IACF,CAAC;AAGD,UAAM,aAAa,MAAM;AAAA,MACvB,YAAY;AAAA,M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ACL,aAAK;AAAA,UACH;AAAA,qBAAwB,YAAY,MAAM,IAAI,YAAY,WAAW;AAAA,QACvE;AACA,aAAK;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAEA,WAAK,IAAI,EAAE;AACX,WAAK;AAAA,QACH;AAAA,MACF;AAAA,IACF,SAAS,KAAU;AACjB,WAAK,MAAM,0BAA0B,IAAI,OAAO,EAAE;AAAA,IACpD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/auth/whoami.ts
|
|
4
|
+
import { Command } from "@oclif/core";
|
|
5
|
+
import {
|
|
6
|
+
getPrivateKeyWithSource,
|
|
7
|
+
getAddressFromPrivateKey
|
|
8
|
+
} from "@layr-labs/ecloud-sdk";
|
|
9
|
+
|
|
10
|
+
// src/flags.ts
|
|
11
|
+
import {
|
|
12
|
+
getEnvironmentInteractive,
|
|
13
|
+
getPrivateKeyInteractive,
|
|
14
|
+
getAvailableEnvironments
|
|
15
|
+
} from "@layr-labs/ecloud-sdk";
|
|
16
|
+
import { Flags } from "@oclif/core";
|
|
17
|
+
var getEnvironmentOptions = () => {
|
|
18
|
+
try {
|
|
19
|
+
return getAvailableEnvironments();
|
|
20
|
+
} catch {
|
|
21
|
+
return ["sepolia", "sepolia-dev", "mainnet-alpha"];
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var commonFlags = {
|
|
25
|
+
environment: Flags.string({
|
|
26
|
+
required: false,
|
|
27
|
+
description: "Deployment environment to use",
|
|
28
|
+
options: getEnvironmentOptions(),
|
|
29
|
+
env: "ECLOUD_ENV"
|
|
30
|
+
}),
|
|
31
|
+
"private-key": Flags.string({
|
|
32
|
+
required: false,
|
|
33
|
+
description: "Private key for signing transactions",
|
|
34
|
+
env: "ECLOUD_PRIVATE_KEY"
|
|
35
|
+
}),
|
|
36
|
+
"rpc-url": Flags.string({
|
|
37
|
+
required: false,
|
|
38
|
+
description: "RPC URL to connect to blockchain",
|
|
39
|
+
env: "ECLOUD_RPC_URL"
|
|
40
|
+
}),
|
|
41
|
+
verbose: Flags.boolean({
|
|
42
|
+
required: false,
|
|
43
|
+
description: "Enable verbose logging (default: false)",
|
|
44
|
+
default: false
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/commands/auth/whoami.ts
|
|
49
|
+
var AuthWhoami = class _AuthWhoami extends Command {
|
|
50
|
+
static description = "Show current authentication status and address";
|
|
51
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
52
|
+
static flags = {
|
|
53
|
+
"private-key": {
|
|
54
|
+
...commonFlags["private-key"],
|
|
55
|
+
required: false
|
|
56
|
+
// Make optional for whoami
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
async run() {
|
|
60
|
+
const { flags } = await this.parse(_AuthWhoami);
|
|
61
|
+
const result = await getPrivateKeyWithSource({
|
|
62
|
+
privateKey: flags["private-key"]
|
|
63
|
+
});
|
|
64
|
+
if (!result) {
|
|
65
|
+
this.log("Not authenticated");
|
|
66
|
+
this.log("");
|
|
67
|
+
this.log("To authenticate, use one of:");
|
|
68
|
+
this.log(" ecloud auth login # Store key in keyring");
|
|
69
|
+
this.log(
|
|
70
|
+
" export ECLOUD_PRIVATE_KEY=0x... # Use environment variable"
|
|
71
|
+
);
|
|
72
|
+
this.log(" ecloud <command> --private-key 0x... # Use flag");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const address = getAddressFromPrivateKey(result.key);
|
|
76
|
+
this.log(`Address: ${address}`);
|
|
77
|
+
this.log(`Source: ${result.source}`);
|
|
78
|
+
this.log("");
|
|
79
|
+
this.log(
|
|
80
|
+
"Note: This key is used for all environments (mainnet, sepolia, etc.)"
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
AuthWhoami as default
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/auth/whoami.ts","../../../src/flags.ts"],"sourcesContent":["/**\n * Auth Whoami Command\n *\n * Show current authentication status and address\n */\n\nimport { Command } from \"@oclif/core\";\nimport {\n getPrivateKeyWithSource,\n getAddressFromPrivateKey,\n getPrivateKey,\n} from \"@layr-labs/ecloud-sdk\";\nimport { commonFlags } from \"../../flags\";\n\nexport default class AuthWhoami extends Command {\n static description = \"Show current authentication status and address\";\n\n static examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n static flags = {\n \"private-key\": {\n ...commonFlags[\"private-key\"],\n required: false, // Make optional for whoami\n },\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(AuthWhoami);\n\n // Try to get private key from any source\n const result = await getPrivateKeyWithSource({\n privateKey: flags[\"private-key\"],\n });\n\n if (!result) {\n this.log(\"Not authenticated\");\n this.log(\"\");\n this.log(\"To authenticate, use one of:\");\n this.log(\" ecloud auth login # Store key in keyring\");\n this.log(\n \" export ECLOUD_PRIVATE_KEY=0x... # Use environment variable\"\n );\n this.log(\" ecloud <command> --private-key 0x... # Use flag\");\n return;\n }\n\n // Get address from private key\n const address = getAddressFromPrivateKey(result.key);\n\n // Display authentication info\n this.log(`Address: ${address}`);\n this.log(`Source: ${result.source}`);\n this.log(\"\");\n this.log(\n \"Note: This key is used for all environments (mainnet, sepolia, etc.)\"\n );\n }\n}\n","import {\n getEnvironmentInteractive,\n getPrivateKeyInteractive,\n getAvailableEnvironments,\n} from \"@layr-labs/ecloud-sdk\";\nimport { Flags } from \"@oclif/core\";\n\nexport type CommonFlags = {\n verbose: boolean;\n environment?: string;\n \"private-key\"?: string;\n \"rpc-url\"?: string;\n};\n\n// Get available environments dynamically from SDK based on build type\nconst getEnvironmentOptions = (): string[] => {\n try {\n return getAvailableEnvironments();\n } catch {\n // Fallback to all environments if SDK not available\n return [\"sepolia\", \"sepolia-dev\", \"mainnet-alpha\"];\n }\n};\n\nexport const commonFlags = {\n environment: Flags.string({\n required: false,\n description: \"Deployment environment to use\",\n options: getEnvironmentOptions(),\n env: \"ECLOUD_ENV\",\n }),\n \"private-key\": Flags.string({\n required: false,\n description: \"Private key for signing transactions\",\n env: \"ECLOUD_PRIVATE_KEY\",\n }),\n \"rpc-url\": Flags.string({\n required: false,\n description: \"RPC URL to connect to blockchain\",\n env: \"ECLOUD_RPC_URL\",\n }),\n verbose: Flags.boolean({\n required: false,\n description: \"Enable verbose logging (default: false)\",\n default: false,\n }),\n};\n\n// Validate or prompt for required common flags\nexport async function validateCommonFlags(flags: CommonFlags) {\n flags[\"environment\"] = await getEnvironmentInteractive(flags[\"environment\"]);\n flags[\"private-key\"] = await getPrivateKeyInteractive(flags[\"private-key\"]);\n\n return flags;\n}\n"],"mappings":";;;AAMA,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;;;ACXP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AAUtB,IAAM,wBAAwB,MAAgB;AAC5C,MAAI;AACF,WAAO,yBAAyB;AAAA,EAClC,QAAQ;AAEN,WAAO,CAAC,WAAW,eAAe,eAAe;AAAA,EACnD;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,aAAa,MAAM,OAAO;AAAA,IACxB,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS,sBAAsB;AAAA,IAC/B,KAAK;AAAA,EACP,CAAC;AAAA,EACD,eAAe,MAAM,OAAO;AAAA,IAC1B,UAAU;AAAA,IACV,aAAa;AAAA,IACb,KAAK;AAAA,EACP,CAAC;AAAA,EACD,WAAW,MAAM,OAAO;AAAA,IACtB,UAAU;AAAA,IACV,aAAa;AAAA,IACb,KAAK;AAAA,EACP,CAAC;AAAA,EACD,SAAS,MAAM,QAAQ;AAAA,IACrB,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS;AAAA,EACX,CAAC;AACH;;;ADhCA,IAAqB,aAArB,MAAqB,oBAAmB,QAAQ;AAAA,EAC9C,OAAO,cAAc;AAAA,EAErB,OAAO,WAAW,CAAC,qCAAqC;AAAA,EAExD,OAAO,QAAQ;AAAA,IACb,eAAe;AAAA,MACb,GAAG,YAAY,aAAa;AAAA,MAC5B,UAAU;AAAA;AAAA,IACZ;AAAA,EACF;AAAA,EAEA,MAAM,MAAqB;AACzB,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,MAAM,WAAU;AAG7C,UAAM,SAAS,MAAM,wBAAwB;AAAA,MAC3C,YAAY,MAAM,aAAa;AAAA,IACjC,CAAC;AAED,QAAI,CAAC,QAAQ;AACX,WAAK,IAAI,mBAAmB;AAC5B,WAAK,IAAI,EAAE;AACX,WAAK,IAAI,8BAA8B;AACvC,WAAK,IAAI,+DAA+D;AACxE,WAAK;AAAA,QACH;AAAA,MACF;AACA,WAAK,IAAI,mDAAmD;AAC5D;AAAA,IACF;AAGA,UAAM,UAAU,yBAAyB,OAAO,GAAG;AAGnD,SAAK,IAAI,YAAY,OAAO,EAAE;AAC9B,SAAK,IAAI,YAAY,OAAO,MAAM,EAAE;AACpC,SAAK,IAAI,EAAE;AACX,SAAK;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/billing/cancel.ts
|
|
4
|
+
import { Command, Flags as Flags2 } from "@oclif/core";
|
|
5
|
+
import { isSubscriptionActive } from "@layr-labs/ecloud-sdk";
|
|
6
|
+
|
|
7
|
+
// src/client.ts
|
|
8
|
+
import {
|
|
9
|
+
createAppModule,
|
|
10
|
+
createBillingModule,
|
|
11
|
+
getPrivateKeyInteractive as getPrivateKeyInteractive2,
|
|
12
|
+
getEnvironmentConfig,
|
|
13
|
+
requirePrivateKey,
|
|
14
|
+
getPrivateKeyWithSource
|
|
15
|
+
} from "@layr-labs/ecloud-sdk";
|
|
16
|
+
|
|
17
|
+
// src/flags.ts
|
|
18
|
+
import {
|
|
19
|
+
getEnvironmentInteractive,
|
|
20
|
+
getPrivateKeyInteractive,
|
|
21
|
+
getAvailableEnvironments
|
|
22
|
+
} from "@layr-labs/ecloud-sdk";
|
|
23
|
+
import { Flags } from "@oclif/core";
|
|
24
|
+
var getEnvironmentOptions = () => {
|
|
25
|
+
try {
|
|
26
|
+
return getAvailableEnvironments();
|
|
27
|
+
} catch {
|
|
28
|
+
return ["sepolia", "sepolia-dev", "mainnet-alpha"];
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var commonFlags = {
|
|
32
|
+
environment: Flags.string({
|
|
33
|
+
required: false,
|
|
34
|
+
description: "Deployment environment to use",
|
|
35
|
+
options: getEnvironmentOptions(),
|
|
36
|
+
env: "ECLOUD_ENV"
|
|
37
|
+
}),
|
|
38
|
+
"private-key": Flags.string({
|
|
39
|
+
required: false,
|
|
40
|
+
description: "Private key for signing transactions",
|
|
41
|
+
env: "ECLOUD_PRIVATE_KEY"
|
|
42
|
+
}),
|
|
43
|
+
"rpc-url": Flags.string({
|
|
44
|
+
required: false,
|
|
45
|
+
description: "RPC URL to connect to blockchain",
|
|
46
|
+
env: "ECLOUD_RPC_URL"
|
|
47
|
+
}),
|
|
48
|
+
verbose: Flags.boolean({
|
|
49
|
+
required: false,
|
|
50
|
+
description: "Enable verbose logging (default: false)",
|
|
51
|
+
default: false
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/client.ts
|
|
56
|
+
async function createBillingClient(flags) {
|
|
57
|
+
const result = await getPrivateKeyWithSource({
|
|
58
|
+
privateKey: flags["private-key"]
|
|
59
|
+
});
|
|
60
|
+
const privateKey = await getPrivateKeyInteractive2(result?.key);
|
|
61
|
+
return createBillingModule({
|
|
62
|
+
verbose: flags.verbose ?? false,
|
|
63
|
+
privateKey
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/commands/billing/cancel.ts
|
|
68
|
+
import chalk from "chalk";
|
|
69
|
+
import { confirm } from "@inquirer/prompts";
|
|
70
|
+
var BillingCancel = class _BillingCancel extends Command {
|
|
71
|
+
static description = "Cancel subscription";
|
|
72
|
+
static flags = {
|
|
73
|
+
"private-key": commonFlags["private-key"],
|
|
74
|
+
verbose: commonFlags.verbose,
|
|
75
|
+
product: Flags2.string({
|
|
76
|
+
required: false,
|
|
77
|
+
description: "Product ID",
|
|
78
|
+
default: "compute",
|
|
79
|
+
options: ["compute"],
|
|
80
|
+
env: "ECLOUD_PRODUCT_ID"
|
|
81
|
+
}),
|
|
82
|
+
force: Flags2.boolean({
|
|
83
|
+
char: "f",
|
|
84
|
+
description: "Skip confirmation prompt",
|
|
85
|
+
default: false
|
|
86
|
+
})
|
|
87
|
+
};
|
|
88
|
+
async run() {
|
|
89
|
+
const { flags } = await this.parse(_BillingCancel);
|
|
90
|
+
const billing = await createBillingClient(flags);
|
|
91
|
+
this.log(`
|
|
92
|
+
Checking subscription status for ${flags.product}...`);
|
|
93
|
+
const status = await billing.getStatus({
|
|
94
|
+
productId: flags.product
|
|
95
|
+
});
|
|
96
|
+
if (!isSubscriptionActive(status.subscriptionStatus)) {
|
|
97
|
+
this.log(
|
|
98
|
+
`
|
|
99
|
+
${chalk.gray("You don't have an active subscription to cancel.")}`
|
|
100
|
+
);
|
|
101
|
+
this.log(chalk.gray(`Current status: ${status.subscriptionStatus}`));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!flags.force) {
|
|
105
|
+
const confirmed = await confirm({
|
|
106
|
+
message: `${chalk.yellow("Warning:")} This will cancel your ${flags.product} subscription. Continue?`
|
|
107
|
+
});
|
|
108
|
+
if (!confirmed) {
|
|
109
|
+
this.log(chalk.gray("\nCancellation aborted."));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
this.log(`
|
|
114
|
+
Canceling subscription for ${flags.product}...`);
|
|
115
|
+
const result = await billing.cancel({
|
|
116
|
+
productId: flags.product
|
|
117
|
+
});
|
|
118
|
+
if (result.type === "canceled") {
|
|
119
|
+
this.log(`
|
|
120
|
+
${chalk.green("\u2713")} Subscription canceled successfully.`);
|
|
121
|
+
} else {
|
|
122
|
+
this.log(
|
|
123
|
+
`
|
|
124
|
+
${chalk.gray("Subscription status changed. Current status:")} ${result.status}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
export {
|
|
130
|
+
BillingCancel as default
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=cancel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/billing/cancel.ts","../../../src/client.ts","../../../src/flags.ts"],"sourcesContent":["import { Command, Flags } from \"@oclif/core\";\nimport { isSubscriptionActive } from \"@layr-labs/ecloud-sdk\";\nimport { createBillingClient } from \"../../client\";\nimport { commonFlags } from \"../../flags\";\nimport chalk from \"chalk\";\nimport { confirm } from \"@inquirer/prompts\";\n\nexport default class BillingCancel extends Command {\n static description = \"Cancel subscription\";\n\n static flags = {\n \"private-key\": commonFlags[\"private-key\"],\n verbose: commonFlags.verbose,\n product: Flags.string({\n required: false,\n description: \"Product ID\",\n default: \"compute\",\n options: [\"compute\"],\n env: \"ECLOUD_PRODUCT_ID\",\n }),\n force: Flags.boolean({\n char: \"f\",\n description: \"Skip confirmation prompt\",\n default: false,\n }),\n };\n\n async run() {\n const { flags } = await this.parse(BillingCancel);\n const billing = await createBillingClient(flags);\n\n // Check subscription status first\n this.log(`\\nChecking subscription status for ${flags.product}...`);\n const status = await billing.getStatus({\n productId: flags.product as \"compute\",\n });\n\n // Check if there's an active subscription to cancel\n if (!isSubscriptionActive(status.subscriptionStatus)) {\n this.log(\n `\\n${chalk.gray(\"You don't have an active subscription to cancel.\")}`,\n );\n this.log(chalk.gray(`Current status: ${status.subscriptionStatus}`));\n return;\n }\n\n // Confirm cancellation unless --force flag is used\n if (!flags.force) {\n const confirmed = await confirm({\n message: `${chalk.yellow(\"Warning:\")} This will cancel your ${flags.product} subscription. Continue?`,\n });\n if (!confirmed) {\n this.log(chalk.gray(\"\\nCancellation aborted.\"));\n return;\n }\n }\n\n this.log(`\\nCanceling subscription for ${flags.product}...`);\n\n const result = await billing.cancel({\n productId: flags.product as \"compute\",\n });\n\n // Handle response (defensive - should always be canceled at this point)\n if (result.type === \"canceled\") {\n this.log(`\\n${chalk.green(\"✓\")} Subscription canceled successfully.`);\n } else {\n this.log(\n `\\n${chalk.gray(\"Subscription status changed. Current status:\")} ${result.status}`,\n );\n }\n }\n}\n","import {\n createAppModule,\n createBillingModule,\n getPrivateKeyInteractive,\n getEnvironmentConfig,\n requirePrivateKey,\n getPrivateKeyWithSource,\n} from \"@layr-labs/ecloud-sdk\";\nimport { CommonFlags, validateCommonFlags } from \"./flags\";\nimport { Hex } from \"viem\";\n\nexport async function createAppClient(flags: CommonFlags) {\n flags = await validateCommonFlags(flags);\n\n const environment = flags.environment!;\n const environmentConfig = getEnvironmentConfig(environment);\n const rpcUrl = flags[\"rpc-url\"] || environmentConfig.defaultRPCURL;\n const { key: privateKey, source } = await requirePrivateKey({\n privateKey: flags[\"private-key\"],\n });\n\n if (flags.verbose) {\n console.log(`Using private key from: ${source}`);\n }\n\n return createAppModule({\n verbose: flags.verbose,\n privateKey,\n rpcUrl,\n environment,\n });\n}\n\nexport async function createBillingClient(flags: {\n \"private-key\"?: string;\n verbose?: boolean;\n}) {\n const result = await getPrivateKeyWithSource({\n privateKey: flags[\"private-key\"],\n });\n const privateKey = await getPrivateKeyInteractive(result?.key);\n\n return createBillingModule({\n verbose: flags.verbose ?? false,\n privateKey: privateKey as Hex,\n });\n}\n","import {\n getEnvironmentInteractive,\n getPrivateKeyInteractive,\n getAvailableEnvironments,\n} from \"@layr-labs/ecloud-sdk\";\nimport { Flags } from \"@oclif/core\";\n\nexport type CommonFlags = {\n verbose: boolean;\n environment?: string;\n \"private-key\"?: string;\n \"rpc-url\"?: string;\n};\n\n// Get available environments dynamically from SDK based on build type\nconst getEnvironmentOptions = (): string[] => {\n try {\n return getAvailableEnvironments();\n } catch {\n // Fallback to all environments if SDK not available\n return [\"sepolia\", \"sepolia-dev\", \"mainnet-alpha\"];\n }\n};\n\nexport const commonFlags = {\n environment: Flags.string({\n required: false,\n description: \"Deployment environment to use\",\n options: getEnvironmentOptions(),\n env: \"ECLOUD_ENV\",\n }),\n \"private-key\": Flags.string({\n required: false,\n description: \"Private key for signing transactions\",\n env: \"ECLOUD_PRIVATE_KEY\",\n }),\n \"rpc-url\": Flags.string({\n required: false,\n description: \"RPC URL to connect to blockchain\",\n env: \"ECLOUD_RPC_URL\",\n }),\n verbose: Flags.boolean({\n required: false,\n description: \"Enable verbose logging (default: false)\",\n default: false,\n }),\n};\n\n// Validate or prompt for required common flags\nexport async function validateCommonFlags(flags: CommonFlags) {\n flags[\"environment\"] = await getEnvironmentInteractive(flags[\"environment\"]);\n flags[\"private-key\"] = await getPrivateKeyInteractive(flags[\"private-key\"]);\n\n return flags;\n}\n"],"mappings":";;;AAAA,SAAS,SAAS,SAAAA,cAAa;AAC/B,SAAS,4BAA4B;;;ACDrC;AAAA,EACE;AAAA,EACA;AAAA,EACA,4BAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACPP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AAUtB,IAAM,wBAAwB,MAAgB;AAC5C,MAAI;AACF,WAAO,yBAAyB;AAAA,EAClC,QAAQ;AAEN,WAAO,CAAC,WAAW,eAAe,eAAe;AAAA,EACnD;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,aAAa,MAAM,OAAO;AAAA,IACxB,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS,sBAAsB;AAAA,IAC/B,KAAK;AAAA,EACP,CAAC;AAAA,EACD,eAAe,MAAM,OAAO;AAAA,IAC1B,UAAU;AAAA,IACV,aAAa;AAAA,IACb,KAAK;AA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