genlayer 0.31.0 → 0.32.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/CLAUDE.md +55 -0
  3. package/README.md +121 -8
  4. package/dist/index.js +7161 -3706
  5. package/docs/delegator-guide.md +203 -0
  6. package/docs/validator-guide.md +291 -0
  7. package/package.json +2 -2
  8. package/src/commands/account/create.ts +29 -0
  9. package/src/commands/account/export.ts +106 -0
  10. package/src/commands/account/import.ts +135 -0
  11. package/src/commands/account/index.ts +126 -0
  12. package/src/commands/account/list.ts +34 -0
  13. package/src/commands/account/lock.ts +39 -0
  14. package/src/commands/account/remove.ts +30 -0
  15. package/src/commands/account/send.ts +156 -0
  16. package/src/commands/account/show.ts +74 -0
  17. package/src/commands/account/unlock.ts +51 -0
  18. package/src/commands/account/use.ts +21 -0
  19. package/src/commands/network/index.ts +18 -3
  20. package/src/commands/network/setNetwork.ts +43 -26
  21. package/src/commands/staking/StakingAction.ts +157 -0
  22. package/src/commands/staking/delegatorClaim.ts +41 -0
  23. package/src/commands/staking/delegatorExit.ts +50 -0
  24. package/src/commands/staking/delegatorJoin.ts +44 -0
  25. package/src/commands/staking/index.ts +251 -0
  26. package/src/commands/staking/setIdentity.ts +66 -0
  27. package/src/commands/staking/setOperator.ts +40 -0
  28. package/src/commands/staking/stakingInfo.ts +300 -0
  29. package/src/commands/staking/validatorClaim.ts +38 -0
  30. package/src/commands/staking/validatorDeposit.ts +35 -0
  31. package/src/commands/staking/validatorExit.ts +44 -0
  32. package/src/commands/staking/validatorJoin.ts +47 -0
  33. package/src/commands/staking/validatorPrime.ts +35 -0
  34. package/src/commands/staking/wizard.ts +802 -0
  35. package/src/index.ts +4 -2
  36. package/src/lib/actions/BaseAction.ts +114 -55
  37. package/src/lib/config/ConfigFileManager.ts +143 -0
  38. package/src/lib/config/KeychainManager.ts +23 -7
  39. package/tests/actions/create.test.ts +41 -21
  40. package/tests/actions/deploy.test.ts +7 -0
  41. package/tests/actions/lock.test.ts +33 -13
  42. package/tests/actions/setNetwork.test.ts +18 -57
  43. package/tests/actions/staking.test.ts +323 -0
  44. package/tests/actions/unlock.test.ts +51 -33
  45. package/tests/commands/account.test.ts +146 -0
  46. package/tests/commands/network.test.ts +10 -10
  47. package/tests/commands/staking.test.ts +333 -0
  48. package/tests/index.test.ts +6 -2
  49. package/tests/libs/baseAction.test.ts +71 -42
  50. package/tests/libs/configFileManager.test.ts +8 -1
  51. package/tests/libs/keychainManager.test.ts +56 -16
  52. package/src/commands/keygen/create.ts +0 -23
  53. package/src/commands/keygen/index.ts +0 -39
  54. package/src/commands/keygen/lock.ts +0 -31
  55. package/src/commands/keygen/unlock.ts +0 -41
  56. package/src/lib/interfaces/KeystoreData.ts +0 -5
  57. package/tests/commands/keygen.test.ts +0 -123
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.32.1 (2025-12-04)
4
+
5
+ ## 0.32.0 (2025-12-03)
6
+
7
+ ### Features
8
+
9
+ * Implements staking functionality ([#266](https://github.com/yeagerai/genlayer-cli/issues/266)) ([36e4180](https://github.com/yeagerai/genlayer-cli/commit/36e4180c6093f380d1f552e9051345812e6bd024))
10
+
3
11
  ## 0.31.0 (2025-09-03)
4
12
 
5
13
  ### Features
package/CLAUDE.md ADDED
@@ -0,0 +1,55 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Build & Development
6
+
7
+ ```bash
8
+ npm install # Install dependencies
9
+ npm run dev # Watch mode development build (uses esbuild)
10
+ npm run build # Production build
11
+ node dist/index.js # Run CLI from source
12
+ ```
13
+
14
+ ## Testing
15
+
16
+ ```bash
17
+ npm test # Run all tests (vitest)
18
+ npm run test:watch # Watch mode
19
+ npm run test:coverage # Coverage report
20
+ npx vitest tests/commands/deploy.test.ts # Single test file
21
+ npx vitest -t "test name pattern" # Run specific test by name
22
+ ```
23
+
24
+ ## Architecture
25
+
26
+ ### Entry Point & Command Structure
27
+ - `src/index.ts` - Main entry, initializes Commander program and registers all command groups
28
+ - Commands organized in `src/commands/<domain>/index.ts` - each exports `initialize*Commands(program)` function
29
+ - Command domains: general (init/up/stop), account, contracts, config, localnet, update, scaffold, network, transactions, staking
30
+
31
+ ### Core Classes
32
+ - `BaseAction` (`src/lib/actions/BaseAction.ts`) - Base class for all CLI actions. Provides:
33
+ - GenLayer client initialization via `genlayer-js` SDK
34
+ - Keystore management (encrypted wallet with password)
35
+ - Spinner/logging utilities (ora, chalk)
36
+ - User prompts (inquirer)
37
+ - `ConfigFileManager` (`src/lib/config/ConfigFileManager.ts`) - Manages `~/.genlayer/genlayer-config.json`
38
+ - `KeychainManager` (`src/lib/config/KeychainManager.ts`) - System keychain integration via keytar
39
+
40
+ ### Pattern for Adding Commands
41
+ 1. Create action class extending `BaseAction` in `src/commands/<domain>/<action>.ts`
42
+ 2. Export action options interface
43
+ 3. Register in domain's `index.ts` via Commander
44
+ 4. Add tests in `tests/commands/<domain>.test.ts` and `tests/actions/<action>.test.ts`
45
+
46
+ ### External Dependencies
47
+ - `commander` - CLI framework
48
+ - `genlayer-js` - GenLayer SDK for blockchain interactions
49
+ - `ethers` - Wallet/keystore encryption
50
+ - `dockerode` - Docker management for localnet
51
+ - `viem` - Ethereum utilities
52
+
53
+ ### Path Aliases
54
+ - `@/*` → `./src/*`
55
+ - `@@/tests/*` → `./tests/*`
package/README.md CHANGED
@@ -203,21 +203,30 @@ EXAMPLES:
203
203
  ##### Schema
204
204
  - `schema` - Retrieves the contract schema
205
205
 
206
- #### Keypair Management
206
+ #### Account Management
207
207
 
208
- Generate and manage keypairs.
208
+ View and manage your account.
209
209
 
210
210
  ```bash
211
211
  USAGE:
212
- genlayer keygen create [options]
212
+ genlayer account Show account info (address, balance, network, status)
213
+ genlayer account create [options] Create a new account
214
+ genlayer account send <to> <amount> Send GEN to an address
215
+ genlayer account unlock Unlock account (cache key in OS keychain)
216
+ genlayer account lock Lock account (remove key from OS keychain)
213
217
 
214
- OPTIONS:
215
- --output <path> Path to save the keypair (default: "./keypair.json")
216
- --overwrite Overwrite the existing file if it already exists (default: false)
218
+ OPTIONS (create):
219
+ --output <path> Path to save the keystore (default: "./keypair.json")
220
+ --overwrite Overwrite existing file (default: false)
217
221
 
218
222
  EXAMPLES:
219
- genlayer keygen create
220
- genlayer keygen create --output ./my_key.json --overwrite
223
+ genlayer account
224
+ genlayer account create
225
+ genlayer account create --output ./my_key.json --overwrite
226
+ genlayer account send 0x123...abc 10gen
227
+ genlayer account send 0x123...abc 0.5gen
228
+ genlayer account unlock
229
+ genlayer account lock
221
230
  ```
222
231
 
223
232
  #### Update Resources
@@ -284,6 +293,105 @@ EXAMPLES:
284
293
  genlayer localnet validators create-random --count 3 --providers openai --models gpt-4 gpt-4o
285
294
  ```
286
295
 
296
+ #### Staking Operations
297
+
298
+ Manage staking for validators and delegators on testnet-asimov. Staking is not available on localnet/studio.
299
+
300
+ ```bash
301
+ USAGE:
302
+ genlayer staking <command> [options]
303
+
304
+ COMMANDS:
305
+ validator-join [options] Join as a validator by staking tokens
306
+ validator-deposit [options] Make an additional deposit as a validator
307
+ validator-exit [options] Exit as a validator by withdrawing shares
308
+ validator-claim [options] Claim validator withdrawals after unbonding period
309
+ delegator-join [options] Join as a delegator by staking with a validator
310
+ delegator-exit [options] Exit as a delegator by withdrawing shares
311
+ delegator-claim [options] Claim delegator withdrawals after unbonding period
312
+ validator-info [options] Get information about a validator
313
+ delegation-info [options] Get delegation info for a delegator with a validator
314
+ epoch-info [options] Get epoch info with timing estimates
315
+ active-validators [options] List all active validators
316
+
317
+ COMMON OPTIONS (all commands):
318
+ --network <network> Network to use (localnet, testnet-asimov)
319
+ --rpc <rpcUrl> RPC URL override
320
+ --staking-address <address> Staking contract address override
321
+
322
+ OPTIONS (validator-join):
323
+ --amount <amount> Amount to stake (in wei or with 'gen' suffix)
324
+ --operator <address> Operator address (defaults to signer)
325
+
326
+ OPTIONS (delegator-join):
327
+ --validator <address> Validator address to delegate to
328
+ --amount <amount> Amount to stake (in wei or with 'gen' suffix)
329
+
330
+ OPTIONS (exit commands):
331
+ --shares <shares> Number of shares to withdraw
332
+ --validator <address> Validator address (for delegator commands)
333
+
334
+ EXAMPLES:
335
+ # Get epoch info (uses --network to specify testnet-asimov)
336
+ genlayer staking epoch-info --network testnet-asimov
337
+
338
+ # Or set network globally first
339
+ genlayer network testnet-asimov
340
+
341
+ # Join as validator with 42000 GEN
342
+ genlayer staking validator-join --amount 42000gen
343
+
344
+ # Join as delegator with 42 GEN
345
+ genlayer staking delegator-join --validator 0x... --amount 42gen
346
+
347
+ # Check validator info
348
+ genlayer staking validator-info --validator 0x...
349
+ # Output:
350
+ # {
351
+ # validator: '0xa8f1BF1e5e709593b4468d7ac5DC315Ea3CAe130',
352
+ # vStake: '0.01 GEN',
353
+ # vShares: '10000000000000000',
354
+ # dStake: '0 GEN',
355
+ # dShares: '0',
356
+ # vDeposit: '0 GEN',
357
+ # vWithdrawal: '0 GEN',
358
+ # epoch: '0',
359
+ # live: true,
360
+ # banned: 'Not banned'
361
+ # }
362
+
363
+ # Get current epoch info (includes timing estimates)
364
+ genlayer staking epoch-info
365
+ # Output:
366
+ # {
367
+ # currentEpoch: '2',
368
+ # epochStarted: '2025-11-28T09:57:49.000Z',
369
+ # epochEnded: 'Not ended',
370
+ # nextEpochEstimate: '2025-11-29T09:57:49.000Z',
371
+ # timeUntilNextEpoch: '19h 56m',
372
+ # minEpochDuration: '24h 0m',
373
+ # validatorMinStake: '0.01 GEN',
374
+ # delegatorMinStake: '42 GEN',
375
+ # activeValidatorsCount: '6'
376
+ # }
377
+
378
+ # List active validators
379
+ genlayer staking active-validators
380
+ # Output:
381
+ # {
382
+ # count: 6,
383
+ # validators: [
384
+ # '0xa8f1BF1e5e709593b4468d7ac5DC315Ea3CAe130',
385
+ # '0xe9246A020cbb4fC6C46e60677981879c9219e8B9',
386
+ # ...
387
+ # ]
388
+ # }
389
+
390
+ # Exit and claim
391
+ genlayer staking validator-exit --shares 100
392
+ genlayer staking validator-claim
393
+ ```
394
+
287
395
  ### Running the CLI from the repository
288
396
 
289
397
  First, install the dependencies and start the build process
@@ -301,6 +409,11 @@ Then in another window execute the CLI commands like so:
301
409
  node dist/index.js init
302
410
  ```
303
411
 
412
+ ## Guides
413
+
414
+ - [Validator Guide](docs/validator-guide.md) - How to become a validator on GenLayer testnet
415
+ - [Delegator Guide](docs/delegator-guide.md) - How to delegate GEN to a validator
416
+
304
417
  ## Documentation
305
418
 
306
419
  For detailed information on how to use GenLayer CLI, please refer to our [documentation](https://docs.genlayer.com/).