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.
Files changed (128) hide show
  1. package/dist/index.js +13 -3
  2. package/package.json +11 -2
  3. package/.eslintignore +0 -2
  4. package/.github/workflows/cli-docs.yml +0 -121
  5. package/.github/workflows/publish-beta.yml +0 -41
  6. package/.github/workflows/publish.yml +0 -43
  7. package/.github/workflows/validate-code.yml +0 -47
  8. package/.prettierignore +0 -19
  9. package/.prettierrc +0 -12
  10. package/.release-it.json +0 -64
  11. package/CHANGELOG.md +0 -425
  12. package/CLAUDE.md +0 -55
  13. package/CONTRIBUTING.md +0 -117
  14. package/docker-compose.yml +0 -154
  15. package/docs/delegator-guide.md +0 -203
  16. package/docs/validator-guide.md +0 -329
  17. package/esbuild.config.dev.js +0 -17
  18. package/esbuild.config.js +0 -22
  19. package/esbuild.config.prod.js +0 -17
  20. package/eslint.config.js +0 -60
  21. package/renovate.json +0 -22
  22. package/src/commands/account/create.ts +0 -30
  23. package/src/commands/account/export.ts +0 -106
  24. package/src/commands/account/import.ts +0 -135
  25. package/src/commands/account/index.ts +0 -129
  26. package/src/commands/account/list.ts +0 -34
  27. package/src/commands/account/lock.ts +0 -39
  28. package/src/commands/account/remove.ts +0 -30
  29. package/src/commands/account/send.ts +0 -162
  30. package/src/commands/account/show.ts +0 -74
  31. package/src/commands/account/unlock.ts +0 -56
  32. package/src/commands/account/use.ts +0 -21
  33. package/src/commands/config/getSetReset.ts +0 -51
  34. package/src/commands/config/index.ts +0 -30
  35. package/src/commands/contracts/call.ts +0 -39
  36. package/src/commands/contracts/code.ts +0 -33
  37. package/src/commands/contracts/deploy.ts +0 -157
  38. package/src/commands/contracts/index.ts +0 -86
  39. package/src/commands/contracts/schema.ts +0 -31
  40. package/src/commands/contracts/write.ts +0 -49
  41. package/src/commands/general/index.ts +0 -45
  42. package/src/commands/general/init.ts +0 -179
  43. package/src/commands/general/start.ts +0 -116
  44. package/src/commands/general/stop.ts +0 -26
  45. package/src/commands/localnet/index.ts +0 -100
  46. package/src/commands/localnet/validators.ts +0 -269
  47. package/src/commands/network/index.ts +0 -29
  48. package/src/commands/network/setNetwork.ts +0 -77
  49. package/src/commands/scaffold/index.ts +0 -16
  50. package/src/commands/scaffold/new.ts +0 -34
  51. package/src/commands/staking/StakingAction.ts +0 -279
  52. package/src/commands/staking/delegatorClaim.ts +0 -41
  53. package/src/commands/staking/delegatorExit.ts +0 -56
  54. package/src/commands/staking/delegatorJoin.ts +0 -44
  55. package/src/commands/staking/index.ts +0 -357
  56. package/src/commands/staking/setIdentity.ts +0 -78
  57. package/src/commands/staking/setOperator.ts +0 -46
  58. package/src/commands/staking/stakingInfo.ts +0 -584
  59. package/src/commands/staking/validatorClaim.ts +0 -43
  60. package/src/commands/staking/validatorDeposit.ts +0 -48
  61. package/src/commands/staking/validatorExit.ts +0 -63
  62. package/src/commands/staking/validatorHistory.ts +0 -298
  63. package/src/commands/staking/validatorJoin.ts +0 -47
  64. package/src/commands/staking/validatorPrime.ts +0 -73
  65. package/src/commands/staking/wizard.ts +0 -809
  66. package/src/commands/transactions/appeal.ts +0 -39
  67. package/src/commands/transactions/index.ts +0 -39
  68. package/src/commands/transactions/receipt.ts +0 -90
  69. package/src/commands/update/index.ts +0 -25
  70. package/src/commands/update/ollama.ts +0 -103
  71. package/src/lib/actions/BaseAction.ts +0 -299
  72. package/src/lib/clients/jsonRpcClient.ts +0 -41
  73. package/src/lib/clients/system.ts +0 -73
  74. package/src/lib/config/ConfigFileManager.ts +0 -194
  75. package/src/lib/config/KeychainManager.ts +0 -89
  76. package/src/lib/config/simulator.ts +0 -68
  77. package/src/lib/config/text.ts +0 -2
  78. package/src/lib/errors/missingRequirement.ts +0 -9
  79. package/src/lib/errors/versionRequired.ts +0 -9
  80. package/src/lib/interfaces/ISimulatorService.ts +0 -37
  81. package/src/lib/services/simulator.ts +0 -351
  82. package/src/types/node-fetch.d.ts +0 -1
  83. package/tests/actions/appeal.test.ts +0 -99
  84. package/tests/actions/call.test.ts +0 -94
  85. package/tests/actions/code.test.ts +0 -87
  86. package/tests/actions/create.test.ts +0 -65
  87. package/tests/actions/deploy.test.ts +0 -420
  88. package/tests/actions/getSetReset.test.ts +0 -88
  89. package/tests/actions/init.test.ts +0 -467
  90. package/tests/actions/lock.test.ts +0 -86
  91. package/tests/actions/new.test.ts +0 -80
  92. package/tests/actions/ollama.test.ts +0 -193
  93. package/tests/actions/receipt.test.ts +0 -261
  94. package/tests/actions/schema.test.ts +0 -94
  95. package/tests/actions/setNetwork.test.ts +0 -160
  96. package/tests/actions/staking.test.ts +0 -279
  97. package/tests/actions/start.test.ts +0 -235
  98. package/tests/actions/stop.test.ts +0 -77
  99. package/tests/actions/unlock.test.ts +0 -139
  100. package/tests/actions/validators.test.ts +0 -750
  101. package/tests/actions/write.test.ts +0 -102
  102. package/tests/commands/account.test.ts +0 -146
  103. package/tests/commands/appeal.test.ts +0 -58
  104. package/tests/commands/call.test.ts +0 -78
  105. package/tests/commands/code.test.ts +0 -69
  106. package/tests/commands/config.test.ts +0 -54
  107. package/tests/commands/deploy.test.ts +0 -83
  108. package/tests/commands/init.test.ts +0 -101
  109. package/tests/commands/localnet.test.ts +0 -131
  110. package/tests/commands/network.test.ts +0 -60
  111. package/tests/commands/new.test.ts +0 -68
  112. package/tests/commands/receipt.test.ts +0 -142
  113. package/tests/commands/schema.test.ts +0 -67
  114. package/tests/commands/staking.test.ts +0 -329
  115. package/tests/commands/stop.test.ts +0 -27
  116. package/tests/commands/up.test.ts +0 -105
  117. package/tests/commands/update.test.ts +0 -45
  118. package/tests/commands/write.test.ts +0 -76
  119. package/tests/index.test.ts +0 -56
  120. package/tests/libs/baseAction.test.ts +0 -516
  121. package/tests/libs/configFileManager.test.ts +0 -117
  122. package/tests/libs/jsonRpcClient.test.ts +0 -59
  123. package/tests/libs/keychainManager.test.ts +0 -156
  124. package/tests/libs/system.test.ts +0 -148
  125. package/tests/services/simulator.test.ts +0 -705
  126. package/tests/utils.ts +0 -13
  127. package/tsconfig.json +0 -120
  128. package/vitest.config.ts +0 -12
@@ -1,77 +0,0 @@
1
- import { describe, test, vi, beforeEach, afterEach, expect } from "vitest";
2
- import { StopAction } from "../../src/commands/general/stop";
3
- import { SimulatorService } from "../../src/lib/services/simulator";
4
- import { ISimulatorService } from "../../src/lib/interfaces/ISimulatorService";
5
- import chalk from "chalk";
6
-
7
- import inquirer from "inquirer";
8
-
9
- vi.mock("../../src/lib/services/simulator");
10
- vi.mock("inquirer");
11
-
12
- describe("StopAction", () => {
13
- let stopAction: StopAction;
14
- let mockSimulatorService: ISimulatorService;
15
-
16
- beforeEach(() => {
17
- vi.clearAllMocks();
18
-
19
- mockSimulatorService = {
20
- stopDockerContainers: vi.fn(),
21
- } as unknown as ISimulatorService;
22
-
23
- SimulatorService.prototype.stopDockerContainers = mockSimulatorService.stopDockerContainers;
24
-
25
- stopAction = new StopAction();
26
- (stopAction as any).simulatorService = mockSimulatorService;
27
-
28
- vi.spyOn(stopAction as any, "startSpinner").mockImplementation(() => {});
29
- vi.spyOn(stopAction as any, "succeedSpinner").mockImplementation(() => {});
30
- vi.spyOn(stopAction as any, "failSpinner").mockImplementation(() => {});
31
- });
32
-
33
- afterEach(() => {
34
- vi.restoreAllMocks();
35
- });
36
-
37
- test("should stop containers if user confirms", async () => {
38
- vi.mocked(inquirer.prompt).mockResolvedValue({ confirmAction: true });
39
-
40
- await stopAction.stop();
41
-
42
- expect(inquirer.prompt).toHaveBeenCalledWith([
43
- {
44
- type: "confirm",
45
- name: "confirmAction",
46
- message: chalk.yellow("Are you sure you want to stop all running GenLayer containers? This will halt all active processes."),
47
- default: true,
48
- },
49
- ]);
50
- expect(mockSimulatorService.stopDockerContainers).toHaveBeenCalled();
51
- expect(stopAction["succeedSpinner"]).toHaveBeenCalledWith(
52
- "All running GenLayer containers have been successfully stopped."
53
- );
54
- });
55
-
56
- test("should abort if user cancels", async () => {
57
- vi.mocked(inquirer.prompt).mockResolvedValue({ confirmAction: false });
58
-
59
- await stopAction.stop();
60
-
61
- expect(inquirer.prompt).toHaveBeenCalled();
62
- expect(mockSimulatorService.stopDockerContainers).not.toHaveBeenCalled();
63
- });
64
-
65
- test("should handle errors and call failSpinner", async () => {
66
- vi.mocked(inquirer.prompt).mockResolvedValue({ confirmAction: true });
67
- const error = new Error("Test Error");
68
- mockSimulatorService.stopDockerContainers = vi.fn().mockRejectedValue(error);
69
-
70
- await stopAction.stop();
71
-
72
- expect(stopAction["failSpinner"]).toHaveBeenCalledWith(
73
- "An error occurred while stopping the containers.",
74
- error
75
- );
76
- });
77
- });
@@ -1,139 +0,0 @@
1
- import {describe, test, vi, beforeEach, afterEach, expect} from "vitest";
2
- import {UnlockAccountAction} from "../../src/commands/account/unlock";
3
- import {readFileSync, existsSync, mkdirSync, writeFileSync, readdirSync, unlinkSync, copyFileSync} from "fs";
4
- import {ethers} from "ethers";
5
- import inquirer from "inquirer";
6
- import os from "os";
7
-
8
- vi.mock("fs");
9
- vi.mock("ethers");
10
- vi.mock("inquirer");
11
- vi.mock("os");
12
-
13
- describe("UnlockAccountAction", () => {
14
- let unlockAction: UnlockAccountAction;
15
- // Standard web3 keystore format
16
- const mockKeystoreData = {
17
- address: "1234567890123456789012345678901234567890",
18
- crypto: {
19
- cipher: "aes-128-ctr",
20
- ciphertext: "test",
21
- cipherparams: {iv: "test"},
22
- kdf: "scrypt",
23
- kdfparams: {},
24
- mac: "test"
25
- },
26
- version: 3
27
- };
28
- const mockWallet = {
29
- privateKey: "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
30
- };
31
- const mockKeystorePath = "/mocked/home/.genlayer/keystores/default.json";
32
-
33
- beforeEach(() => {
34
- vi.clearAllMocks();
35
- // Setup mocks before creating the action (needed for constructor)
36
- vi.mocked(os.homedir).mockReturnValue("/mocked/home");
37
- vi.mocked(existsSync).mockReturnValue(true);
38
- vi.mocked(readFileSync).mockReturnValue(JSON.stringify({activeAccount: "default"}));
39
-
40
- unlockAction = new UnlockAccountAction();
41
-
42
- // Mock the BaseAction methods
43
- vi.spyOn(unlockAction as any, "startSpinner").mockImplementation(() => {});
44
- vi.spyOn(unlockAction as any, "setSpinnerText").mockImplementation(() => {});
45
- vi.spyOn(unlockAction as any, "stopSpinner").mockImplementation(() => {});
46
- vi.spyOn(unlockAction as any, "succeedSpinner").mockImplementation(() => {});
47
- vi.spyOn(unlockAction as any, "failSpinner").mockImplementation(() => {});
48
- vi.spyOn(unlockAction as any, "promptPassword").mockResolvedValue("test-password");
49
- vi.spyOn(unlockAction as any, "getKeystorePath").mockReturnValue(mockKeystorePath);
50
- vi.spyOn(unlockAction as any, "resolveAccountName").mockReturnValue("default");
51
- vi.spyOn(unlockAction as any, "isValidKeystoreFormat").mockReturnValue(true);
52
-
53
- // Mock keychainManager
54
- vi.spyOn(unlockAction["keychainManager"], "isKeychainAvailable").mockResolvedValue(true);
55
- vi.spyOn(unlockAction["keychainManager"], "storePrivateKey").mockResolvedValue();
56
-
57
- // Mock fs and ethers
58
- vi.mocked(existsSync).mockReturnValue(true);
59
- vi.mocked(readFileSync).mockReturnValue(JSON.stringify(mockKeystoreData));
60
- vi.mocked(ethers.Wallet.fromEncryptedJson).mockResolvedValue(mockWallet as any);
61
- });
62
-
63
- afterEach(() => {
64
- vi.restoreAllMocks();
65
- });
66
-
67
- test("successfully unlocks wallet when all conditions are met", async () => {
68
- await unlockAction.execute();
69
-
70
- expect(unlockAction["startSpinner"]).toHaveBeenCalledWith("Checking keychain availability...");
71
- expect(unlockAction["keychainManager"].isKeychainAvailable).toHaveBeenCalled();
72
- expect(unlockAction["setSpinnerText"]).toHaveBeenCalledWith("Checking for account 'default'...");
73
- expect(unlockAction["getKeystorePath"]).toHaveBeenCalledWith("default");
74
- expect(existsSync).toHaveBeenCalledWith(mockKeystorePath);
75
- expect(unlockAction["stopSpinner"]).toHaveBeenCalled();
76
- expect(unlockAction["promptPassword"]).toHaveBeenCalledWith("Enter password to unlock 'default':");
77
- expect(readFileSync).toHaveBeenCalledWith(mockKeystorePath, "utf-8");
78
- expect(ethers.Wallet.fromEncryptedJson).toHaveBeenCalledWith(JSON.stringify(mockKeystoreData), "test-password");
79
- expect(unlockAction["keychainManager"].storePrivateKey).toHaveBeenCalledWith("default", mockWallet.privateKey);
80
- expect(unlockAction["succeedSpinner"]).toHaveBeenCalledWith("Account 'default' unlocked! Private key cached in OS keychain.");
81
- });
82
-
83
- test("fails when keychain is not available", async () => {
84
- vi.spyOn(unlockAction["keychainManager"], "isKeychainAvailable").mockResolvedValue(false);
85
-
86
- await unlockAction.execute();
87
-
88
- expect(unlockAction["failSpinner"]).toHaveBeenCalledWith("OS keychain is not available. This command requires a supported keychain (e.g. macOS Keychain, Windows Credential Manager, or GNOME Keyring).");
89
- expect(unlockAction["promptPassword"]).not.toHaveBeenCalled();
90
- expect(unlockAction["keychainManager"].storePrivateKey).not.toHaveBeenCalled();
91
- });
92
-
93
- test("fails when keystore file does not exist", async () => {
94
- vi.mocked(existsSync).mockReturnValue(false);
95
-
96
- await unlockAction.execute();
97
-
98
- expect(unlockAction["failSpinner"]).toHaveBeenCalledWith("Account 'default' not found. Run 'genlayer account create --name default' first.");
99
- expect(unlockAction["promptPassword"]).not.toHaveBeenCalled();
100
- });
101
-
102
- test("fails when keystore format is invalid", async () => {
103
- vi.spyOn(unlockAction as any, "isValidKeystoreFormat").mockReturnValue(false);
104
-
105
- await unlockAction.execute();
106
-
107
- expect(unlockAction["failSpinner"]).toHaveBeenCalledWith("Invalid keystore format.");
108
- expect(unlockAction["promptPassword"]).not.toHaveBeenCalled();
109
- });
110
-
111
- test("handles error during wallet decryption", async () => {
112
- const mockError = new Error("Decryption failed");
113
- vi.mocked(ethers.Wallet.fromEncryptedJson).mockRejectedValue(mockError);
114
-
115
- await unlockAction.execute();
116
-
117
- expect(unlockAction["failSpinner"]).toHaveBeenCalledWith("Failed to unlock account.", mockError);
118
- expect(unlockAction["keychainManager"].storePrivateKey).not.toHaveBeenCalled();
119
- });
120
-
121
- test("handles error during key storage", async () => {
122
- const mockError = new Error("Storage failed");
123
- vi.spyOn(unlockAction["keychainManager"], "storePrivateKey").mockRejectedValue(mockError);
124
-
125
- await unlockAction.execute();
126
-
127
- expect(unlockAction["failSpinner"]).toHaveBeenCalledWith("Failed to unlock account.", mockError);
128
- });
129
-
130
- test("uses account option when provided", async () => {
131
- vi.spyOn(unlockAction as any, "resolveAccountName").mockReturnValue("validator");
132
- vi.spyOn(unlockAction as any, "getKeystorePath").mockReturnValue("/mocked/home/.genlayer/keystores/validator.json");
133
-
134
- await unlockAction.execute({account: "validator"});
135
-
136
- expect(unlockAction["accountOverride"]).toBe("validator");
137
- expect(unlockAction["setSpinnerText"]).toHaveBeenCalledWith("Checking for account 'validator'...");
138
- });
139
- });