genlayer 0.30.0 → 0.32.0
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/CHANGELOG.md +12 -0
- package/CLAUDE.md +55 -0
- package/README.md +121 -8
- package/dist/index.js +8424 -2489
- package/docs/delegator-guide.md +203 -0
- package/docs/validator-guide.md +260 -0
- package/package.json +2 -2
- package/src/commands/account/create.ts +23 -0
- package/src/commands/account/import.ts +81 -0
- package/src/commands/account/index.ts +67 -0
- package/src/commands/{keygen → account}/lock.ts +6 -7
- package/src/commands/account/send.ts +150 -0
- package/src/commands/account/show.ts +60 -0
- package/src/commands/{keygen → account}/unlock.ts +12 -12
- package/src/commands/contracts/code.ts +33 -0
- package/src/commands/contracts/index.ts +10 -0
- package/src/commands/network/setNetwork.ts +5 -4
- package/src/commands/staking/StakingAction.ts +125 -0
- package/src/commands/staking/delegatorClaim.ts +41 -0
- package/src/commands/staking/delegatorExit.ts +50 -0
- package/src/commands/staking/delegatorJoin.ts +42 -0
- package/src/commands/staking/index.ts +224 -0
- package/src/commands/staking/setIdentity.ts +61 -0
- package/src/commands/staking/setOperator.ts +40 -0
- package/src/commands/staking/stakingInfo.ts +292 -0
- package/src/commands/staking/validatorClaim.ts +38 -0
- package/src/commands/staking/validatorDeposit.ts +35 -0
- package/src/commands/staking/validatorExit.ts +44 -0
- package/src/commands/staking/validatorJoin.ts +47 -0
- package/src/commands/staking/validatorPrime.ts +35 -0
- package/src/index.ts +4 -2
- package/src/lib/actions/BaseAction.ts +43 -10
- package/tests/actions/code.test.ts +87 -0
- package/tests/actions/create.test.ts +18 -18
- package/tests/actions/lock.test.ts +7 -7
- package/tests/actions/setNetwork.test.ts +18 -57
- package/tests/actions/staking.test.ts +323 -0
- package/tests/actions/unlock.test.ts +12 -12
- package/tests/commands/account.test.ts +121 -0
- package/tests/commands/code.test.ts +69 -0
- package/tests/commands/staking.test.ts +211 -0
- package/tests/index.test.ts +6 -2
- package/tests/libs/baseAction.test.ts +7 -1
- package/src/commands/keygen/create.ts +0 -23
- package/src/commands/keygen/index.ts +0 -39
- package/tests/commands/keygen.test.ts +0 -123
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.32.0 (2025-12-03)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* Implements staking functionality ([#266](https://github.com/yeagerai/genlayer-cli/issues/266)) ([36e4180](https://github.com/yeagerai/genlayer-cli/commit/36e4180c6093f380d1f552e9051345812e6bd024))
|
|
8
|
+
|
|
9
|
+
## 0.31.0 (2025-09-03)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* get contract code new cli command ([#253](https://github.com/yeagerai/genlayer-cli/issues/253)) ([d6ea30d](https://github.com/yeagerai/genlayer-cli/commit/d6ea30d96e2453fb90bd1493266d8b54c04e830b))
|
|
14
|
+
|
|
3
15
|
## 0.30.0 (2025-09-03)
|
|
4
16
|
|
|
5
17
|
### 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
|
-
####
|
|
206
|
+
#### Account Management
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
View and manage your account.
|
|
209
209
|
|
|
210
210
|
```bash
|
|
211
211
|
USAGE:
|
|
212
|
-
genlayer
|
|
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
|
|
216
|
-
--overwrite Overwrite
|
|
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
|
|
220
|
-
genlayer
|
|
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
|
+
stake-info [options] Get stake 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/).
|