genlayer 0.34.0 → 0.34.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/dist/index.js +13 -3
- package/package.json +11 -2
- package/.eslintignore +0 -2
- package/.github/workflows/cli-docs.yml +0 -121
- package/.github/workflows/publish-beta.yml +0 -41
- package/.github/workflows/publish.yml +0 -43
- package/.github/workflows/validate-code.yml +0 -47
- package/.prettierignore +0 -19
- package/.prettierrc +0 -12
- package/.release-it.json +0 -64
- package/CHANGELOG.md +0 -425
- package/CLAUDE.md +0 -55
- package/CONTRIBUTING.md +0 -117
- package/docker-compose.yml +0 -154
- package/docs/delegator-guide.md +0 -203
- package/docs/validator-guide.md +0 -329
- package/esbuild.config.dev.js +0 -17
- package/esbuild.config.js +0 -22
- package/esbuild.config.prod.js +0 -17
- package/eslint.config.js +0 -60
- package/renovate.json +0 -22
- package/src/commands/account/create.ts +0 -30
- package/src/commands/account/export.ts +0 -106
- package/src/commands/account/import.ts +0 -135
- package/src/commands/account/index.ts +0 -129
- package/src/commands/account/list.ts +0 -34
- package/src/commands/account/lock.ts +0 -39
- package/src/commands/account/remove.ts +0 -30
- package/src/commands/account/send.ts +0 -162
- package/src/commands/account/show.ts +0 -74
- package/src/commands/account/unlock.ts +0 -56
- package/src/commands/account/use.ts +0 -21
- package/src/commands/config/getSetReset.ts +0 -51
- package/src/commands/config/index.ts +0 -30
- package/src/commands/contracts/call.ts +0 -39
- package/src/commands/contracts/code.ts +0 -33
- package/src/commands/contracts/deploy.ts +0 -157
- package/src/commands/contracts/index.ts +0 -86
- package/src/commands/contracts/schema.ts +0 -31
- package/src/commands/contracts/write.ts +0 -49
- package/src/commands/general/index.ts +0 -45
- package/src/commands/general/init.ts +0 -179
- package/src/commands/general/start.ts +0 -116
- package/src/commands/general/stop.ts +0 -26
- package/src/commands/localnet/index.ts +0 -100
- package/src/commands/localnet/validators.ts +0 -269
- package/src/commands/network/index.ts +0 -29
- package/src/commands/network/setNetwork.ts +0 -77
- package/src/commands/scaffold/index.ts +0 -16
- package/src/commands/scaffold/new.ts +0 -34
- package/src/commands/staking/StakingAction.ts +0 -279
- package/src/commands/staking/delegatorClaim.ts +0 -41
- package/src/commands/staking/delegatorExit.ts +0 -56
- package/src/commands/staking/delegatorJoin.ts +0 -44
- package/src/commands/staking/index.ts +0 -357
- package/src/commands/staking/setIdentity.ts +0 -78
- package/src/commands/staking/setOperator.ts +0 -46
- package/src/commands/staking/stakingInfo.ts +0 -584
- package/src/commands/staking/validatorClaim.ts +0 -43
- package/src/commands/staking/validatorDeposit.ts +0 -48
- package/src/commands/staking/validatorExit.ts +0 -63
- package/src/commands/staking/validatorHistory.ts +0 -298
- package/src/commands/staking/validatorJoin.ts +0 -47
- package/src/commands/staking/validatorPrime.ts +0 -73
- package/src/commands/staking/wizard.ts +0 -809
- package/src/commands/transactions/appeal.ts +0 -39
- package/src/commands/transactions/index.ts +0 -39
- package/src/commands/transactions/receipt.ts +0 -90
- package/src/commands/update/index.ts +0 -25
- package/src/commands/update/ollama.ts +0 -103
- package/src/lib/actions/BaseAction.ts +0 -299
- package/src/lib/clients/jsonRpcClient.ts +0 -41
- package/src/lib/clients/system.ts +0 -73
- package/src/lib/config/ConfigFileManager.ts +0 -194
- package/src/lib/config/KeychainManager.ts +0 -89
- package/src/lib/config/simulator.ts +0 -68
- package/src/lib/config/text.ts +0 -2
- package/src/lib/errors/missingRequirement.ts +0 -9
- package/src/lib/errors/versionRequired.ts +0 -9
- package/src/lib/interfaces/ISimulatorService.ts +0 -37
- package/src/lib/services/simulator.ts +0 -351
- package/src/types/node-fetch.d.ts +0 -1
- package/tests/actions/appeal.test.ts +0 -99
- package/tests/actions/call.test.ts +0 -94
- package/tests/actions/code.test.ts +0 -87
- package/tests/actions/create.test.ts +0 -65
- package/tests/actions/deploy.test.ts +0 -420
- package/tests/actions/getSetReset.test.ts +0 -88
- package/tests/actions/init.test.ts +0 -467
- package/tests/actions/lock.test.ts +0 -86
- package/tests/actions/new.test.ts +0 -80
- package/tests/actions/ollama.test.ts +0 -193
- package/tests/actions/receipt.test.ts +0 -261
- package/tests/actions/schema.test.ts +0 -94
- package/tests/actions/setNetwork.test.ts +0 -160
- package/tests/actions/staking.test.ts +0 -279
- package/tests/actions/start.test.ts +0 -235
- package/tests/actions/stop.test.ts +0 -77
- package/tests/actions/unlock.test.ts +0 -139
- package/tests/actions/validators.test.ts +0 -750
- package/tests/actions/write.test.ts +0 -102
- package/tests/commands/account.test.ts +0 -146
- package/tests/commands/appeal.test.ts +0 -58
- package/tests/commands/call.test.ts +0 -78
- package/tests/commands/code.test.ts +0 -69
- package/tests/commands/config.test.ts +0 -54
- package/tests/commands/deploy.test.ts +0 -83
- package/tests/commands/init.test.ts +0 -101
- package/tests/commands/localnet.test.ts +0 -131
- package/tests/commands/network.test.ts +0 -60
- package/tests/commands/new.test.ts +0 -68
- package/tests/commands/receipt.test.ts +0 -142
- package/tests/commands/schema.test.ts +0 -67
- package/tests/commands/staking.test.ts +0 -329
- package/tests/commands/stop.test.ts +0 -27
- package/tests/commands/up.test.ts +0 -105
- package/tests/commands/update.test.ts +0 -45
- package/tests/commands/write.test.ts +0 -76
- package/tests/index.test.ts +0 -56
- package/tests/libs/baseAction.test.ts +0 -516
- package/tests/libs/configFileManager.test.ts +0 -117
- package/tests/libs/jsonRpcClient.test.ts +0 -59
- package/tests/libs/keychainManager.test.ts +0 -156
- package/tests/libs/system.test.ts +0 -148
- package/tests/services/simulator.test.ts +0 -705
- package/tests/utils.ts +0 -13
- package/tsconfig.json +0 -120
- package/vitest.config.ts +0 -12
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import util from "node:util";
|
|
2
|
-
import {ChildProcess, exec} from "child_process";
|
|
3
|
-
import open from "open";
|
|
4
|
-
|
|
5
|
-
import {RunningPlatform, AVAILABLE_PLATFORMS} from "../config/simulator";
|
|
6
|
-
import {MissingRequirementError} from "../errors/missingRequirement";
|
|
7
|
-
|
|
8
|
-
export async function checkCommand(command: string, toolName: string): Promise<void> {
|
|
9
|
-
try {
|
|
10
|
-
await util.promisify(exec)(command);
|
|
11
|
-
}catch (error:any) {
|
|
12
|
-
if (error.stderr) {
|
|
13
|
-
throw new MissingRequirementError(toolName);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type ExecuteCommandResult = {
|
|
19
|
-
stdout: string;
|
|
20
|
-
stderr: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type ExecuteCommandByPlatformInput = {
|
|
24
|
-
[key in RunningPlatform]: string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export async function executeCommand(
|
|
28
|
-
cmdsByPlatform: ExecuteCommandByPlatformInput,
|
|
29
|
-
toolName?: string,
|
|
30
|
-
): Promise<ExecuteCommandResult> {
|
|
31
|
-
const runningPlatform = getPlatform();
|
|
32
|
-
const command = cmdsByPlatform[runningPlatform];
|
|
33
|
-
try {
|
|
34
|
-
return await util.promisify(exec)(command);
|
|
35
|
-
} catch (error: any) {
|
|
36
|
-
throw new Error(`Error executing ${toolName || command}: ${error.message}.`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function getPlatform(): RunningPlatform {
|
|
41
|
-
const currentPlatform = process.platform as RunningPlatform;
|
|
42
|
-
if (!AVAILABLE_PLATFORMS.includes(currentPlatform)) {
|
|
43
|
-
throw new Error(`Unsupported platform: ${currentPlatform}.`);
|
|
44
|
-
}
|
|
45
|
-
return currentPlatform;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function openUrl(url: string): Promise<ChildProcess> {
|
|
49
|
-
return open(url);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export async function getVersion(toolName: string): Promise<string> {
|
|
53
|
-
try {
|
|
54
|
-
const toolResponse = await util.promisify(exec)(`${toolName} --version`);
|
|
55
|
-
|
|
56
|
-
if (toolResponse.stderr) {
|
|
57
|
-
throw new Error(toolResponse.stderr);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
const versionMatch = toolResponse.stdout.match(/(\d+\.\d+\.\d+)/);
|
|
62
|
-
if (versionMatch) {
|
|
63
|
-
return versionMatch[1];
|
|
64
|
-
}
|
|
65
|
-
} catch (err) {
|
|
66
|
-
throw new Error(`Could not parse ${toolName} version.`);
|
|
67
|
-
}
|
|
68
|
-
} catch (error) {
|
|
69
|
-
throw new Error(`Error getting ${toolName} version.`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return "";
|
|
73
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import os from "os";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
|
|
5
|
-
export interface AccountInfo {
|
|
6
|
-
name: string;
|
|
7
|
-
address: string;
|
|
8
|
-
path: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ConfigFileManager {
|
|
12
|
-
private folderPath: string;
|
|
13
|
-
private configFilePath: string;
|
|
14
|
-
private keystoresPath: string;
|
|
15
|
-
|
|
16
|
-
constructor(baseFolder: string = ".genlayer/", configFileName: string = "genlayer-config.json") {
|
|
17
|
-
this.folderPath = path.resolve(os.homedir(), baseFolder);
|
|
18
|
-
this.configFilePath = path.resolve(this.folderPath, configFileName);
|
|
19
|
-
this.keystoresPath = path.resolve(this.folderPath, "keystores");
|
|
20
|
-
this.ensureFolderExists();
|
|
21
|
-
this.ensureKeystoresDirExists();
|
|
22
|
-
this.ensureConfigFileExists();
|
|
23
|
-
this.migrateOldConfig();
|
|
24
|
-
this.migrateKeystoreFormats();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private ensureFolderExists(): void {
|
|
28
|
-
if (!fs.existsSync(this.folderPath)) {
|
|
29
|
-
fs.mkdirSync(this.folderPath, { recursive: true });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private ensureKeystoresDirExists(): void {
|
|
34
|
-
if (!fs.existsSync(this.keystoresPath)) {
|
|
35
|
-
fs.mkdirSync(this.keystoresPath, { recursive: true });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private ensureConfigFileExists(): void {
|
|
40
|
-
if (!fs.existsSync(this.configFilePath)) {
|
|
41
|
-
fs.writeFileSync(this.configFilePath, JSON.stringify({}, null, 2));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private migrateOldConfig(): void {
|
|
46
|
-
const config = this.getConfig();
|
|
47
|
-
if (config.keyPairPath && !config.activeAccount) {
|
|
48
|
-
const oldPath = config.keyPairPath;
|
|
49
|
-
if (fs.existsSync(oldPath)) {
|
|
50
|
-
const newPath = this.getKeystorePath("default");
|
|
51
|
-
// Read old keystore and convert format if needed
|
|
52
|
-
const content = fs.readFileSync(oldPath, "utf-8");
|
|
53
|
-
const web3Content = this.convertToWeb3Format(content);
|
|
54
|
-
fs.writeFileSync(newPath, web3Content);
|
|
55
|
-
delete config.keyPairPath;
|
|
56
|
-
config.activeAccount = "default";
|
|
57
|
-
fs.writeFileSync(this.configFilePath, JSON.stringify(config, null, 2));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private migrateKeystoreFormats(): void {
|
|
63
|
-
if (!fs.existsSync(this.keystoresPath)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const files = fs.readdirSync(this.keystoresPath);
|
|
67
|
-
if (!Array.isArray(files)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
for (const file of files) {
|
|
71
|
-
if (!file.endsWith(".json")) continue;
|
|
72
|
-
const filePath = path.resolve(this.keystoresPath, file);
|
|
73
|
-
try {
|
|
74
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
75
|
-
const parsed = JSON.parse(content);
|
|
76
|
-
// Check if it's old GenLayer format (has 'encrypted' string field)
|
|
77
|
-
if (parsed.encrypted && typeof parsed.encrypted === "string") {
|
|
78
|
-
const web3Content = this.convertToWeb3Format(content);
|
|
79
|
-
fs.writeFileSync(filePath, web3Content);
|
|
80
|
-
}
|
|
81
|
-
// If it has 'crypto' field, it's already web3 format - skip
|
|
82
|
-
} catch {
|
|
83
|
-
// Skip files that can't be parsed
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private convertToWeb3Format(content: string): string {
|
|
89
|
-
try {
|
|
90
|
-
const parsed = JSON.parse(content);
|
|
91
|
-
// If it's GenLayer wrapper format (has 'encrypted' string field)
|
|
92
|
-
if (parsed.encrypted && typeof parsed.encrypted === "string") {
|
|
93
|
-
// The 'encrypted' field contains the actual web3 keystore JSON
|
|
94
|
-
return parsed.encrypted;
|
|
95
|
-
}
|
|
96
|
-
// Already web3 format or unknown - return as-is
|
|
97
|
-
return content;
|
|
98
|
-
} catch {
|
|
99
|
-
return content;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
getFolderPath(): string {
|
|
104
|
-
return this.folderPath;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
getFilePath(fileName: string): string {
|
|
108
|
-
return path.resolve(this.folderPath, fileName);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
getConfig(): Record<string, any> {
|
|
112
|
-
const configContent = fs.readFileSync(this.configFilePath, "utf-8");
|
|
113
|
-
return JSON.parse(configContent);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
getConfigByKey(key: string): any {
|
|
117
|
-
const config = this.getConfig();
|
|
118
|
-
return config[key] !== undefined ? config[key] : null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
writeConfig(key: string, value: any): void {
|
|
122
|
-
const config = this.getConfig();
|
|
123
|
-
config[key] = value;
|
|
124
|
-
fs.writeFileSync(this.configFilePath, JSON.stringify(config, null, 2));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
removeConfig(key: string): void {
|
|
128
|
-
const config = this.getConfig();
|
|
129
|
-
delete config[key];
|
|
130
|
-
fs.writeFileSync(this.configFilePath, JSON.stringify(config, null, 2));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
getKeystoresPath(): string {
|
|
134
|
-
return this.keystoresPath;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
getKeystorePath(name: string): string {
|
|
138
|
-
return path.resolve(this.keystoresPath, `${name}.json`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
accountExists(name: string): boolean {
|
|
142
|
-
return fs.existsSync(this.getKeystorePath(name));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
getActiveAccount(): string | null {
|
|
146
|
-
return this.getConfigByKey("activeAccount");
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
setActiveAccount(name: string): void {
|
|
150
|
-
if (!this.accountExists(name)) {
|
|
151
|
-
throw new Error(`Account '${name}' does not exist`);
|
|
152
|
-
}
|
|
153
|
-
this.writeConfig("activeAccount", name);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
listAccounts(): AccountInfo[] {
|
|
157
|
-
if (!fs.existsSync(this.keystoresPath)) {
|
|
158
|
-
return [];
|
|
159
|
-
}
|
|
160
|
-
const files = fs.readdirSync(this.keystoresPath);
|
|
161
|
-
const accounts: AccountInfo[] = [];
|
|
162
|
-
|
|
163
|
-
for (const file of files) {
|
|
164
|
-
if (!file.endsWith(".json")) continue;
|
|
165
|
-
const name = file.replace(".json", "");
|
|
166
|
-
const filePath = this.getKeystorePath(name);
|
|
167
|
-
try {
|
|
168
|
-
const content = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
169
|
-
const addr = content.address || "unknown";
|
|
170
|
-
accounts.push({
|
|
171
|
-
name,
|
|
172
|
-
address: addr.startsWith("0x") ? addr : `0x${addr}`,
|
|
173
|
-
path: filePath,
|
|
174
|
-
});
|
|
175
|
-
} catch {
|
|
176
|
-
// Skip invalid files
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return accounts;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
removeAccount(name: string): void {
|
|
183
|
-
const keystorePath = this.getKeystorePath(name);
|
|
184
|
-
if (!fs.existsSync(keystorePath)) {
|
|
185
|
-
throw new Error(`Account '${name}' does not exist`);
|
|
186
|
-
}
|
|
187
|
-
fs.unlinkSync(keystorePath);
|
|
188
|
-
|
|
189
|
-
// If this was the active account, clear it
|
|
190
|
-
if (this.getActiveAccount() === name) {
|
|
191
|
-
this.removeConfig("activeAccount");
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
type Keytar = typeof import('keytar').default;
|
|
2
|
-
|
|
3
|
-
let keytarModule: Keytar | null = null;
|
|
4
|
-
let keytarLoadAttempted = false;
|
|
5
|
-
|
|
6
|
-
async function getKeytar(): Promise<Keytar | null> {
|
|
7
|
-
if (keytarLoadAttempted) return keytarModule;
|
|
8
|
-
keytarLoadAttempted = true;
|
|
9
|
-
try {
|
|
10
|
-
const mod = await import('keytar');
|
|
11
|
-
keytarModule = mod.default ?? mod;
|
|
12
|
-
return keytarModule;
|
|
13
|
-
} catch {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class KeychainManager {
|
|
19
|
-
private static readonly SERVICE = 'genlayer-cli';
|
|
20
|
-
|
|
21
|
-
constructor() {}
|
|
22
|
-
|
|
23
|
-
private getKeychainAccount(accountName: string): string {
|
|
24
|
-
return `account:${accountName}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async isKeychainAvailable(): Promise<boolean> {
|
|
28
|
-
try {
|
|
29
|
-
const keytar = await getKeytar();
|
|
30
|
-
if (!keytar) return false;
|
|
31
|
-
await keytar.findCredentials('test-service');
|
|
32
|
-
return true;
|
|
33
|
-
} catch {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async storePrivateKey(accountName: string, privateKey: string): Promise<void> {
|
|
39
|
-
const keytar = await getKeytar();
|
|
40
|
-
if (!keytar) throw new Error('Keychain not available. Install libsecret-1-dev on Linux.');
|
|
41
|
-
try {
|
|
42
|
-
return await keytar.setPassword(KeychainManager.SERVICE, this.getKeychainAccount(accountName), privateKey);
|
|
43
|
-
} catch (error: any) {
|
|
44
|
-
if (error?.message?.includes('org.freedesktop.secrets')) {
|
|
45
|
-
throw new Error('Keychain service not running. Install and start gnome-keyring or another secrets service.');
|
|
46
|
-
}
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async getPrivateKey(accountName: string): Promise<string | null> {
|
|
52
|
-
const keytar = await getKeytar();
|
|
53
|
-
if (!keytar) return null;
|
|
54
|
-
try {
|
|
55
|
-
return await keytar.getPassword(KeychainManager.SERVICE, this.getKeychainAccount(accountName));
|
|
56
|
-
} catch {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async removePrivateKey(accountName: string): Promise<boolean> {
|
|
62
|
-
const keytar = await getKeytar();
|
|
63
|
-
if (!keytar) return false;
|
|
64
|
-
try {
|
|
65
|
-
return await keytar.deletePassword(KeychainManager.SERVICE, this.getKeychainAccount(accountName));
|
|
66
|
-
} catch {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async listUnlockedAccounts(): Promise<string[]> {
|
|
72
|
-
const keytar = await getKeytar();
|
|
73
|
-
if (!keytar) return [];
|
|
74
|
-
try {
|
|
75
|
-
const credentials = await keytar.findCredentials(KeychainManager.SERVICE);
|
|
76
|
-
return credentials
|
|
77
|
-
.map(c => c.account)
|
|
78
|
-
.filter(a => a.startsWith('account:'))
|
|
79
|
-
.map(a => a.replace('account:', ''));
|
|
80
|
-
} catch {
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async isAccountUnlocked(accountName: string): Promise<boolean> {
|
|
86
|
-
const key = await this.getPrivateKey(accountName);
|
|
87
|
-
return key !== null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export const localnetCompatibleVersion = "v0.65.0";
|
|
2
|
-
export const DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
|
|
3
|
-
export const CONTAINERS_NAME_PREFIX = "/genlayer-";
|
|
4
|
-
export const IMAGES_NAME_PREFIX = "yeagerai";
|
|
5
|
-
export const DEFAULT_RUN_SIMULATOR_COMMAND = (location: string, profiles: string) => ({
|
|
6
|
-
darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose -p genlayer ${profiles} up"'`,
|
|
7
|
-
win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose -p genlayer ${profiles} up && pause"`,
|
|
8
|
-
linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose -p genlayer ${profiles} up -d '`,
|
|
9
|
-
});
|
|
10
|
-
export const DEFAULT_RUN_DOCKER_COMMAND = {
|
|
11
|
-
darwin: "open -a Docker",
|
|
12
|
-
win32: 'start "" "C:\\Program Files\\Docker\\Docker\\Docker Desktop.exe"',
|
|
13
|
-
linux: "sudo systemctl start docker",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const VERSION_REQUIREMENTS = {
|
|
17
|
-
docker: "25.0.0",
|
|
18
|
-
node: "18.0.0",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const AVAILABLE_PLATFORMS = ["darwin", "win32", "linux"] as const;
|
|
22
|
-
export type RunningPlatform = (typeof AVAILABLE_PLATFORMS)[number];
|
|
23
|
-
export const STARTING_TIMEOUT_WAIT_CYLCE = 2000;
|
|
24
|
-
export const STARTING_TIMEOUT_ATTEMPTS = 120;
|
|
25
|
-
|
|
26
|
-
export type AiProviders = "ollama" | "openai" | "heuristai" | "geminiai" | "xai";
|
|
27
|
-
export type AiProvidersEnvVars = "ollama" | "OPENAIKEY" | "HEURISTAIAPIKEY" | "GEMINI_API_KEY" | "XAI_API_KEY";
|
|
28
|
-
export type AiProvidersConfigType = {
|
|
29
|
-
[key in AiProviders]: {name: string; hint: string; envVar?: AiProvidersEnvVars; cliOptionValue: string};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const AI_PROVIDERS_CONFIG: AiProvidersConfigType = {
|
|
33
|
-
ollama: {
|
|
34
|
-
name: "Ollama",
|
|
35
|
-
hint: "(By default, this will download and run a local instance of Llama 3)",
|
|
36
|
-
cliOptionValue: "ollama",
|
|
37
|
-
},
|
|
38
|
-
openai: {
|
|
39
|
-
name: "OpenAI",
|
|
40
|
-
hint: "(You will need to provide an OpenAI API key)",
|
|
41
|
-
envVar: "OPENAIKEY",
|
|
42
|
-
cliOptionValue: "openai",
|
|
43
|
-
},
|
|
44
|
-
heuristai: {
|
|
45
|
-
name: "Heurist",
|
|
46
|
-
hint: '(You will need to provide an API key. Get free API credits at https://dev-api-form.heurist.ai/ with referral code: "genlayer")',
|
|
47
|
-
envVar: "HEURISTAIAPIKEY",
|
|
48
|
-
cliOptionValue: "heuristai",
|
|
49
|
-
},
|
|
50
|
-
geminiai: {
|
|
51
|
-
name: "Gemini",
|
|
52
|
-
hint: '(You will need to provide an API key.)',
|
|
53
|
-
envVar: "GEMINI_API_KEY",
|
|
54
|
-
cliOptionValue: "geminiai",
|
|
55
|
-
},
|
|
56
|
-
xai: {
|
|
57
|
-
name: "XAI",
|
|
58
|
-
hint: '(You will need to provide an API key)',
|
|
59
|
-
envVar: "XAI_API_KEY",
|
|
60
|
-
cliOptionValue: "xai",
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const GENLAYER_REQUIRED_CONTAINERS = [
|
|
65
|
-
"genlayer-jsonrpc",
|
|
66
|
-
"genlayer-webrequest",
|
|
67
|
-
"genlayer-postgres"
|
|
68
|
-
]
|
package/src/lib/config/text.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export const CLI_DESCRIPTION =
|
|
2
|
-
"GenLayer CLI is a development environment for the GenLayer ecosystem. It allows developers to interact with the protocol by creating accounts, sending transactions, and working with Intelligent Contracts by testing, debugging, and deploying them.";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export class MissingRequirementError extends Error {
|
|
2
|
-
requirement: string;
|
|
3
|
-
|
|
4
|
-
constructor(requirement: string) {
|
|
5
|
-
super(`${requirement} is not installed. Please install ${requirement}.`);
|
|
6
|
-
this.name = "MissingRequirement";
|
|
7
|
-
this.requirement = requirement;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export class VersionRequiredError extends Error {
|
|
2
|
-
tool: string;
|
|
3
|
-
|
|
4
|
-
constructor(tool: string, requiredVersion: string) {
|
|
5
|
-
super(`${tool} version ${requiredVersion} or higher is required. Please update ${tool}.`);
|
|
6
|
-
this.name = "VersionRequired";
|
|
7
|
-
this.tool = tool;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {AiProviders} from "../config/simulator";
|
|
2
|
-
|
|
3
|
-
export interface ISimulatorService {
|
|
4
|
-
setComposeOptions(headless: boolean, disableOllama?: boolean): void;
|
|
5
|
-
getComposeOptions(): string;
|
|
6
|
-
checkInstallRequirements(): Promise<Record<string, boolean>>;
|
|
7
|
-
checkVersionRequirements(): Promise<Record<string, string>>;
|
|
8
|
-
runSimulator(): Promise<{stdout: string; stderr: string}>;
|
|
9
|
-
waitForSimulatorToBeReady(retries?: number): Promise<WaitForSimulatorToBeReadyResultType>;
|
|
10
|
-
createRandomValidators(numValidators: number, llmProviders: AiProviders[]): Promise<any>;
|
|
11
|
-
deleteAllValidators(): Promise<any>;
|
|
12
|
-
getAiProvidersOptions(withHint: boolean, excludeProviders?: AiProviders[]): Array<{name: string; value: string}>;
|
|
13
|
-
getFrontendUrl(): string;
|
|
14
|
-
openFrontend(): Promise<boolean>;
|
|
15
|
-
stopDockerContainers(): Promise<void>;
|
|
16
|
-
resetDockerContainers(): Promise<void>;
|
|
17
|
-
resetDockerImages(): Promise<void>;
|
|
18
|
-
resetDockerVolumes(): Promise<void>;
|
|
19
|
-
checkCliVersion(): Promise<void>;
|
|
20
|
-
cleanDatabase(): Promise<boolean>;
|
|
21
|
-
addConfigToEnvFile(newConfig: Record<string, string>): void;
|
|
22
|
-
normalizeLocalnetVersion(version: string): string;
|
|
23
|
-
compareVersions(version1: string, version2: string): number;
|
|
24
|
-
isLocalnetRunning(): Promise<boolean>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export type WaitForSimulatorToBeReadyResultType = {
|
|
29
|
-
initialized: boolean;
|
|
30
|
-
errorCode?: "TIMEOUT" | "ERROR";
|
|
31
|
-
errorMessage?: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type InitializeDatabaseResultType = {
|
|
35
|
-
createResponse: any;
|
|
36
|
-
tablesResponse: any;
|
|
37
|
-
};
|