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,41 +0,0 @@
1
- import {StakingAction, StakingConfig} from "./StakingAction";
2
- import type {Address} from "genlayer-js/types";
3
-
4
- export interface DelegatorClaimOptions extends StakingConfig {
5
- validator: string;
6
- delegator?: string;
7
- }
8
-
9
- export class DelegatorClaimAction extends StakingAction {
10
- constructor() {
11
- super();
12
- }
13
-
14
- async execute(options: DelegatorClaimOptions): Promise<void> {
15
- this.startSpinner("Claiming delegator withdrawals...");
16
-
17
- try {
18
- const client = await this.getStakingClient(options);
19
- const delegatorAddress = options.delegator || (await this.getSignerAddress());
20
-
21
- this.setSpinnerText(`Claiming for delegator ${delegatorAddress} from validator ${options.validator}...`);
22
-
23
- const result = await client.delegatorClaim({
24
- validator: options.validator as Address,
25
- delegator: delegatorAddress as Address,
26
- });
27
-
28
- const output = {
29
- transactionHash: result.transactionHash,
30
- delegator: delegatorAddress,
31
- validator: options.validator,
32
- blockNumber: result.blockNumber.toString(),
33
- gasUsed: result.gasUsed.toString(),
34
- };
35
-
36
- this.succeedSpinner("Claim successful!", output);
37
- } catch (error: any) {
38
- this.failSpinner("Failed to claim", error.message || error);
39
- }
40
- }
41
- }
@@ -1,56 +0,0 @@
1
- import {StakingAction, StakingConfig} from "./StakingAction";
2
- import type {Address} from "genlayer-js/types";
3
-
4
- export interface DelegatorExitOptions extends StakingConfig {
5
- validator: string;
6
- shares: string;
7
- }
8
-
9
- export class DelegatorExitAction extends StakingAction {
10
- constructor() {
11
- super();
12
- }
13
-
14
- async execute(options: DelegatorExitOptions): Promise<void> {
15
- this.startSpinner("Initiating delegator exit...");
16
-
17
- try {
18
- let shares: bigint;
19
- try {
20
- shares = BigInt(options.shares);
21
- if (shares <= 0n) throw new Error("must be positive");
22
- } catch {
23
- this.failSpinner(`Invalid shares value: "${options.shares}". Must be a positive whole number.`);
24
- return;
25
- }
26
-
27
- const client = await this.getStakingClient(options);
28
-
29
- this.setSpinnerText(`Exiting ${shares} shares from validator ${options.validator}...`);
30
-
31
- const result = await client.delegatorExit({
32
- validator: options.validator as Address,
33
- shares,
34
- });
35
-
36
- // Check epoch to determine note
37
- const epochInfo = await client.getEpochInfo();
38
- const isEpochZero = epochInfo.currentEpoch === 0n;
39
-
40
- const output = {
41
- transactionHash: result.transactionHash,
42
- validator: options.validator,
43
- sharesWithdrawn: shares.toString(),
44
- blockNumber: result.blockNumber.toString(),
45
- gasUsed: result.gasUsed.toString(),
46
- note: isEpochZero
47
- ? "Epoch 0: Withdrawal claimable immediately"
48
- : "Withdrawal will be claimable after the unbonding period",
49
- };
50
-
51
- this.succeedSpinner("Exit initiated successfully!", output);
52
- } catch (error: any) {
53
- this.failSpinner("Failed to exit", error.message || error);
54
- }
55
- }
56
- }
@@ -1,44 +0,0 @@
1
- import {StakingAction, StakingConfig} from "./StakingAction";
2
- import type {Address} from "genlayer-js/types";
3
- import chalk from "chalk";
4
-
5
- export interface DelegatorJoinOptions extends StakingConfig {
6
- validator: string;
7
- amount: string;
8
- }
9
-
10
- export class DelegatorJoinAction extends StakingAction {
11
- constructor() {
12
- super();
13
- }
14
-
15
- async execute(options: DelegatorJoinOptions): Promise<void> {
16
- this.startSpinner("Joining as delegator...");
17
-
18
- try {
19
- const client = await this.getStakingClient(options);
20
- const amount = this.parseAmount(options.amount);
21
-
22
- this.setSpinnerText(`Delegating ${this.formatAmount(amount)} to validator ${options.validator}...`);
23
-
24
- const result = await client.delegatorJoin({
25
- validator: options.validator as Address,
26
- amount,
27
- });
28
-
29
- const output = {
30
- transactionHash: result.transactionHash,
31
- validator: result.validator,
32
- amount: result.amount,
33
- delegator: result.delegator,
34
- blockNumber: result.blockNumber.toString(),
35
- gasUsed: result.gasUsed.toString(),
36
- };
37
-
38
- this.succeedSpinner("Successfully joined as delegator!", output);
39
- console.log(chalk.dim(`\nTo view your delegation: genlayer staking delegation-info --validator ${options.validator}`));
40
- } catch (error: any) {
41
- this.failSpinner("Failed to join as delegator", error.message || error);
42
- }
43
- }
44
- }
@@ -1,357 +0,0 @@
1
- import {Command} from "commander";
2
- import {ValidatorJoinAction, ValidatorJoinOptions} from "./validatorJoin";
3
- import {ValidatorDepositAction, ValidatorDepositOptions} from "./validatorDeposit";
4
- import {ValidatorExitAction, ValidatorExitOptions} from "./validatorExit";
5
- import {ValidatorClaimAction, ValidatorClaimOptions} from "./validatorClaim";
6
- import {ValidatorPrimeAction, ValidatorPrimeOptions} from "./validatorPrime";
7
- import {SetOperatorAction, SetOperatorOptions} from "./setOperator";
8
- import {SetIdentityAction, SetIdentityOptions} from "./setIdentity";
9
- import {DelegatorJoinAction, DelegatorJoinOptions} from "./delegatorJoin";
10
- import {DelegatorExitAction, DelegatorExitOptions} from "./delegatorExit";
11
- import {DelegatorClaimAction, DelegatorClaimOptions} from "./delegatorClaim";
12
- import {StakingInfoAction, StakingInfoOptions} from "./stakingInfo";
13
- import {ValidatorHistoryAction, ValidatorHistoryOptions} from "./validatorHistory";
14
- import {ValidatorWizardAction, WizardOptions} from "./wizard";
15
-
16
- export function initializeStakingCommands(program: Command) {
17
- const staking = program.command("staking").description("Staking operations for validators and delegators");
18
-
19
- // Wizard command (main entry point for new validators)
20
- staking
21
- .command("wizard")
22
- .description("Interactive wizard to become a validator")
23
- .option("--account <name>", "Account to use (skip selection)")
24
- .option("--network <network>", "Network to use (skip selection)")
25
- .option("--skip-identity", "Skip identity setup step")
26
- .option("--rpc <rpcUrl>", "RPC URL for the network")
27
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
28
- .action(async (options: WizardOptions) => {
29
- const wizard = new ValidatorWizardAction();
30
- await wizard.execute(options);
31
- });
32
-
33
- // Validator commands
34
- staking
35
- .command("validator-join")
36
- .description("Join as a validator by staking tokens")
37
- .requiredOption("--amount <amount>", "Amount to stake (in wei or with 'eth'/'gen' suffix, e.g., '42000gen')")
38
- .option("--operator <address>", "Operator address (defaults to signer)")
39
- .option("--account <name>", "Account to use")
40
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
41
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
42
- .option("--rpc <rpcUrl>", "RPC URL for the network")
43
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
44
- .action(async (options: ValidatorJoinOptions) => {
45
- const action = new ValidatorJoinAction();
46
- await action.execute(options);
47
- });
48
-
49
- staking
50
- .command("validator-deposit [validator]")
51
- .description("Make an additional deposit to a validator wallet")
52
- .option("--validator <address>", "Validator wallet contract address (deprecated, use positional arg)")
53
- .requiredOption("--amount <amount>", "Amount to deposit (in wei or with 'eth'/'gen' suffix)")
54
- .option("--account <name>", "Account to use (must be validator owner)")
55
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
56
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
57
- .option("--rpc <rpcUrl>", "RPC URL for the network")
58
- .action(async (validatorArg: string | undefined, options: ValidatorDepositOptions) => {
59
- const validator = validatorArg || options.validator;
60
- if (!validator) {
61
- console.error("Error: validator address is required");
62
- process.exit(1);
63
- }
64
- const action = new ValidatorDepositAction();
65
- await action.execute({...options, validator});
66
- });
67
-
68
- staking
69
- .command("validator-exit [validator]")
70
- .description("Exit as a validator by withdrawing shares")
71
- .option("--validator <address>", "Validator wallet contract address (deprecated, use positional arg)")
72
- .requiredOption("--shares <shares>", "Number of shares to withdraw")
73
- .option("--account <name>", "Account to use (must be validator owner)")
74
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
75
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
76
- .option("--rpc <rpcUrl>", "RPC URL for the network")
77
- .action(async (validatorArg: string | undefined, options: ValidatorExitOptions) => {
78
- const validator = validatorArg || options.validator;
79
- if (!validator) {
80
- console.error("Error: validator address is required");
81
- process.exit(1);
82
- }
83
- const action = new ValidatorExitAction();
84
- await action.execute({...options, validator});
85
- });
86
-
87
- staking
88
- .command("validator-claim [validator]")
89
- .description("Claim validator withdrawals after unbonding period")
90
- .option("--validator <address>", "Validator wallet contract address (deprecated, use positional arg)")
91
- .option("--account <name>", "Account to use")
92
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
93
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
94
- .option("--rpc <rpcUrl>", "RPC URL for the network")
95
- .action(async (validatorArg: string | undefined, options: ValidatorClaimOptions) => {
96
- const validator = validatorArg || options.validator;
97
- if (!validator) {
98
- console.error("Error: validator address is required");
99
- process.exit(1);
100
- }
101
- const action = new ValidatorClaimAction();
102
- await action.execute({...options, validator});
103
- });
104
-
105
- staking
106
- .command("validator-prime [validator]")
107
- .description("Prime a validator to prepare their stake record for the next epoch")
108
- .option("--validator <address>", "Validator address to prime (deprecated, use positional arg)")
109
- .option("--account <name>", "Account to use")
110
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
111
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
112
- .option("--rpc <rpcUrl>", "RPC URL for the network")
113
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
114
- .action(async (validatorArg: string | undefined, options: ValidatorPrimeOptions) => {
115
- const validator = validatorArg || options.validator;
116
- if (!validator) {
117
- console.error("Error: validator address is required");
118
- process.exit(1);
119
- }
120
- const action = new ValidatorPrimeAction();
121
- await action.execute({...options, validator});
122
- });
123
-
124
- staking
125
- .command("prime-all")
126
- .description("Prime all validators that need priming")
127
- .option("--account <name>", "Account to use (pays gas)")
128
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
129
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
130
- .option("--rpc <rpcUrl>", "RPC URL for the network")
131
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
132
- .action(async (options: StakingConfig) => {
133
- const action = new ValidatorPrimeAction();
134
- await action.primeAll(options);
135
- });
136
-
137
- staking
138
- .command("set-operator [validator] [operator]")
139
- .description("Change the operator address for a validator wallet")
140
- .option("--validator <address>", "Validator wallet address (deprecated, use positional arg)")
141
- .option("--operator <address>", "New operator address (deprecated, use positional arg)")
142
- .option("--account <name>", "Account to use (must be validator owner)")
143
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
144
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
145
- .option("--rpc <rpcUrl>", "RPC URL for the network")
146
- .action(async (validatorArg: string | undefined, operatorArg: string | undefined, options: SetOperatorOptions) => {
147
- const validator = validatorArg || options.validator;
148
- const operator = operatorArg || options.operator;
149
- if (!validator || !operator) {
150
- console.error("Error: validator and operator addresses are required");
151
- process.exit(1);
152
- }
153
- const action = new SetOperatorAction();
154
- await action.execute({...options, validator, operator});
155
- });
156
-
157
- staking
158
- .command("set-identity [validator]")
159
- .description("Set validator identity metadata (moniker, website, socials, etc.)")
160
- .option("--validator <address>", "Validator wallet address (deprecated, use positional arg)")
161
- .requiredOption("--moniker <name>", "Validator display name")
162
- .option("--logo-uri <uri>", "Logo URI")
163
- .option("--website <url>", "Website URL")
164
- .option("--description <text>", "Description")
165
- .option("--email <email>", "Contact email")
166
- .option("--twitter <handle>", "Twitter handle")
167
- .option("--telegram <handle>", "Telegram handle")
168
- .option("--github <handle>", "GitHub handle")
169
- .option("--extra-cid <cid>", "Extra data as IPFS CID or hex bytes (0x...)")
170
- .option("--account <name>", "Account to use (must be validator operator)")
171
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
172
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
173
- .option("--rpc <rpcUrl>", "RPC URL for the network")
174
- .action(async (validatorArg: string | undefined, options: SetIdentityOptions) => {
175
- const validator = validatorArg || options.validator;
176
- if (!validator) {
177
- console.error("Error: validator address is required");
178
- process.exit(1);
179
- }
180
- const action = new SetIdentityAction();
181
- await action.execute({...options, validator});
182
- });
183
-
184
- // Delegator commands
185
- staking
186
- .command("delegator-join [validator]")
187
- .description("Join as a delegator by staking with a validator")
188
- .option("--validator <address>", "Validator address to delegate to (deprecated, use positional arg)")
189
- .requiredOption("--amount <amount>", "Amount to stake (in wei or with 'eth'/'gen' suffix)")
190
- .option("--account <name>", "Account to use")
191
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
192
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
193
- .option("--rpc <rpcUrl>", "RPC URL for the network")
194
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
195
- .action(async (validatorArg: string | undefined, options: DelegatorJoinOptions) => {
196
- const validator = validatorArg || options.validator;
197
- if (!validator) {
198
- console.error("Error: validator address is required");
199
- process.exit(1);
200
- }
201
- const action = new DelegatorJoinAction();
202
- await action.execute({...options, validator});
203
- });
204
-
205
- staking
206
- .command("delegator-exit [validator]")
207
- .description("Exit as a delegator by withdrawing shares from a validator")
208
- .option("--validator <address>", "Validator address to exit from (deprecated, use positional arg)")
209
- .requiredOption("--shares <shares>", "Number of shares to withdraw")
210
- .option("--account <name>", "Account to use")
211
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
212
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
213
- .option("--rpc <rpcUrl>", "RPC URL for the network")
214
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
215
- .action(async (validatorArg: string | undefined, options: DelegatorExitOptions) => {
216
- const validator = validatorArg || options.validator;
217
- if (!validator) {
218
- console.error("Error: validator address is required");
219
- process.exit(1);
220
- }
221
- const action = new DelegatorExitAction();
222
- await action.execute({...options, validator});
223
- });
224
-
225
- staking
226
- .command("delegator-claim [validator]")
227
- .description("Claim delegator withdrawals after unbonding period")
228
- .option("--validator <address>", "Validator address (deprecated, use positional arg)")
229
- .option("--delegator <address>", "Delegator address (defaults to signer)")
230
- .option("--account <name>", "Account to use")
231
- .option("--password <password>", "Password to unlock account (skips interactive prompt)")
232
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
233
- .option("--rpc <rpcUrl>", "RPC URL for the network")
234
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
235
- .action(async (validatorArg: string | undefined, options: DelegatorClaimOptions) => {
236
- const validator = validatorArg || options.validator;
237
- if (!validator) {
238
- console.error("Error: validator address is required");
239
- process.exit(1);
240
- }
241
- const action = new DelegatorClaimAction();
242
- await action.execute({...options, validator});
243
- });
244
-
245
- // Info commands
246
- staking
247
- .command("validator-info [validator]")
248
- .description("Get information about a validator")
249
- .option("--validator <address>", "Validator address (deprecated, use positional arg)")
250
- .option("--account <name>", "Account to use (for default validator address)")
251
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
252
- .option("--rpc <rpcUrl>", "RPC URL for the network")
253
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
254
- .option("--debug", "Show raw unfiltered pending deposits/withdrawals")
255
- .action(async (validatorArg: string | undefined, options: StakingInfoOptions) => {
256
- const validator = validatorArg || options.validator;
257
- const action = new StakingInfoAction();
258
- await action.getValidatorInfo({...options, validator});
259
- });
260
-
261
- staking
262
- .command("delegation-info [validator]")
263
- .description("Get delegation info for a delegator with a validator")
264
- .option("--validator <address>", "Validator address (deprecated, use positional arg)")
265
- .option("--delegator <address>", "Delegator address (defaults to signer)")
266
- .option("--account <name>", "Account to use (for default delegator address)")
267
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
268
- .option("--rpc <rpcUrl>", "RPC URL for the network")
269
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
270
- .action(async (validatorArg: string | undefined, options: StakingInfoOptions & {delegator?: string}) => {
271
- const validator = validatorArg || options.validator;
272
- if (!validator) {
273
- console.error("Error: validator address is required");
274
- process.exit(1);
275
- }
276
- const action = new StakingInfoAction();
277
- await action.getStakeInfo({...options, validator});
278
- });
279
-
280
- staking
281
- .command("epoch-info")
282
- .description("Get current epoch and staking parameters")
283
- .option("--epoch <number>", "Show data for specific epoch (current or previous only)")
284
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
285
- .option("--rpc <rpcUrl>", "RPC URL for the network")
286
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
287
- .action(async (options: StakingInfoOptions & {epoch?: string}) => {
288
- const action = new StakingInfoAction();
289
- await action.getEpochInfo(options);
290
- });
291
-
292
- staking
293
- .command("active-validators")
294
- .description("List all active validators")
295
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
296
- .option("--rpc <rpcUrl>", "RPC URL for the network")
297
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
298
- .action(async (options: StakingInfoOptions) => {
299
- const action = new StakingInfoAction();
300
- await action.listActiveValidators(options);
301
- });
302
-
303
- staking
304
- .command("quarantined-validators")
305
- .description("List all quarantined validators")
306
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
307
- .option("--rpc <rpcUrl>", "RPC URL for the network")
308
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
309
- .action(async (options: StakingInfoOptions) => {
310
- const action = new StakingInfoAction();
311
- await action.listQuarantinedValidators(options);
312
- });
313
-
314
- staking
315
- .command("banned-validators")
316
- .description("List all banned validators")
317
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
318
- .option("--rpc <rpcUrl>", "RPC URL for the network")
319
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
320
- .action(async (options: StakingInfoOptions) => {
321
- const action = new StakingInfoAction();
322
- await action.listBannedValidators(options);
323
- });
324
-
325
- staking
326
- .command("validators")
327
- .description("Show validator set with stake, status, and voting power")
328
- .option("--all", "Include banned validators")
329
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
330
- .option("--rpc <rpcUrl>", "RPC URL for the network")
331
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
332
- .action(async (options: StakingInfoOptions & {all?: boolean}) => {
333
- const action = new StakingInfoAction();
334
- await action.listValidators(options);
335
- });
336
-
337
- staking
338
- .command("validator-history [validator]")
339
- .description("Show slash and reward history for a validator (default: last 10 epochs)")
340
- .option("--validator <address>", "Validator address (deprecated, use positional arg)")
341
- .option("--epochs <count>", "Number of recent epochs to fetch (default: 10)")
342
- .option("--from-epoch <epoch>", "Start from this epoch number")
343
- .option("--from-block <block>", "Start from this block number (advanced)")
344
- .option("--all", "Fetch complete history from genesis (slow)")
345
- .option("--limit <count>", "Maximum number of events to show (default: 50)")
346
- .option("--account <name>", "Account to use (for default validator address)")
347
- .option("--network <network>", "Network to use (localnet, testnet-asimov)")
348
- .option("--rpc <rpcUrl>", "RPC URL for the network")
349
- .option("--staking-address <address>", "Staking contract address (overrides chain config)")
350
- .action(async (validatorArg: string | undefined, options: ValidatorHistoryOptions) => {
351
- const validator = validatorArg || options.validator;
352
- const action = new ValidatorHistoryAction();
353
- await action.execute({...options, validator});
354
- });
355
-
356
- return program;
357
- }
@@ -1,78 +0,0 @@
1
- import {StakingAction, StakingConfig} from "./StakingAction";
2
- import type {Address} from "genlayer-js/types";
3
- import {abi} from "genlayer-js";
4
- import {toHex} from "viem";
5
-
6
- export interface SetIdentityOptions extends StakingConfig {
7
- validator: string;
8
- moniker: string;
9
- logoUri?: string;
10
- website?: string;
11
- description?: string;
12
- email?: string;
13
- twitter?: string;
14
- telegram?: string;
15
- github?: string;
16
- extraCid?: string;
17
- }
18
-
19
- export class SetIdentityAction extends StakingAction {
20
- constructor() {
21
- super();
22
- }
23
-
24
- async execute(options: SetIdentityOptions): Promise<void> {
25
- this.startSpinner("Setting validator identity...");
26
-
27
- try {
28
- const validatorWallet = options.validator as Address;
29
- const {walletClient, publicClient} = await this.getViemClients(options);
30
-
31
- this.setSpinnerText(`Setting identity for ${validatorWallet}...`);
32
-
33
- // Convert extraCid string to bytes (hex)
34
- const extraCidBytes = options.extraCid ? toHex(new TextEncoder().encode(options.extraCid)) : "0x";
35
-
36
- const hash = await walletClient.writeContract({
37
- address: validatorWallet,
38
- abi: abi.VALIDATOR_WALLET_ABI,
39
- functionName: "setIdentity",
40
- args: [
41
- options.moniker,
42
- options.logoUri || "",
43
- options.website || "",
44
- options.description || "",
45
- options.email || "",
46
- options.twitter || "",
47
- options.telegram || "",
48
- options.github || "",
49
- extraCidBytes,
50
- ],
51
- });
52
-
53
- const receipt = await publicClient.waitForTransactionReceipt({hash});
54
-
55
- const output: Record<string, any> = {
56
- transactionHash: receipt.transactionHash,
57
- validator: validatorWallet,
58
- moniker: options.moniker,
59
- blockNumber: receipt.blockNumber.toString(),
60
- gasUsed: receipt.gasUsed.toString(),
61
- };
62
-
63
- // Add optional fields that were set
64
- if (options.logoUri) output.logoUri = options.logoUri;
65
- if (options.website) output.website = options.website;
66
- if (options.description) output.description = options.description;
67
- if (options.email) output.email = options.email;
68
- if (options.twitter) output.twitter = options.twitter;
69
- if (options.telegram) output.telegram = options.telegram;
70
- if (options.github) output.github = options.github;
71
- if (options.extraCid) output.extraCid = options.extraCid;
72
-
73
- this.succeedSpinner("Validator identity set!", output);
74
- } catch (error: any) {
75
- this.failSpinner("Failed to set identity", error.message || error);
76
- }
77
- }
78
- }
@@ -1,46 +0,0 @@
1
- import {StakingAction, StakingConfig} from "./StakingAction";
2
- import type {Address} from "genlayer-js/types";
3
- import {abi} from "genlayer-js";
4
-
5
- export interface SetOperatorOptions extends StakingConfig {
6
- validator: string;
7
- operator: string;
8
- }
9
-
10
- export class SetOperatorAction extends StakingAction {
11
- constructor() {
12
- super();
13
- }
14
-
15
- async execute(options: SetOperatorOptions): Promise<void> {
16
- this.startSpinner("Setting operator...");
17
-
18
- try {
19
- const validatorWallet = options.validator as Address;
20
- const {walletClient, publicClient} = await this.getViemClients(options);
21
-
22
- this.setSpinnerText(`Setting operator to ${options.operator}...`);
23
-
24
- const hash = await walletClient.writeContract({
25
- address: validatorWallet,
26
- abi: abi.VALIDATOR_WALLET_ABI,
27
- functionName: "setOperator",
28
- args: [options.operator as Address],
29
- });
30
-
31
- const receipt = await publicClient.waitForTransactionReceipt({hash});
32
-
33
- const output = {
34
- transactionHash: receipt.transactionHash,
35
- validator: validatorWallet,
36
- newOperator: options.operator,
37
- blockNumber: receipt.blockNumber.toString(),
38
- gasUsed: receipt.gasUsed.toString(),
39
- };
40
-
41
- this.succeedSpinner("Operator updated!", output);
42
- } catch (error: any) {
43
- this.failSpinner("Failed to set operator", error.message || error);
44
- }
45
- }
46
- }