@jpool/bond-cli 1.5.2 → 1.6.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.
Files changed (3) hide show
  1. package/README.md +380 -112
  2. package/dist/cli.js +6412 -176
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,234 +1,502 @@
1
1
  # JBond CLI
2
2
 
3
- A command-line interface for interacting with the JBond Solana program, which manages validator bond collateral.
3
+ Command-line interface for interacting with the JBond Solana program, which manages validator bond collateral.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # From repository root
9
+ pnpm install
10
+
11
+ # Run CLI
12
+ pnpm jbond --help
13
+ ```
14
+
15
+ ## Environment Setup
16
+
17
+ Set environment variables for convenience:
18
+
19
+ ```bash
20
+ export JBOND_BOND=performance # Your bond name (required for most commands)
21
+ export CLUSTER=mainnet-beta # Solana cluster: mainnet-beta, devnet, testnet, or custom RPC URL
22
+ export SOLANA_KEYPAIR=~/.config/solana/id.json # Optional: custom keypair path
23
+ ```
24
+
25
+ ## Global Options
26
+
27
+ All commands support these options:
28
+
29
+ - `-c, --cluster <cluster>` - Solana cluster (mainnet-beta, devnet, testnet) or custom RPC URL (default: `mainnet-beta`)
30
+ - `-k, --keypair <path>` - Path to Solana keypair file
31
+ - `-b, --bond <name>` - Bond name (or set `JBOND_BOND` env var)
32
+ - `-t, --bond-type <type>` - Bond type: `standard` or `crowdfunding` (default: `standard`)
4
33
 
5
34
  ## Commands
6
35
 
7
- ### Initialize Global State
36
+ ### Global State
37
+
38
+ #### Initialize Global State
8
39
 
9
- Initialize Bond Global State and set reserve address.
40
+ Initialize the JBond program's global state (one-time, authority only).
10
41
 
11
42
  ```bash
12
- pnpm jbond initialize -k <KEYPAIR_PATH> -r <RESERVE_ADDRESS>
43
+ pnpm jbond init [options]
13
44
 
14
45
  Options:
15
- -k, --keypair <KEYPAIR_PATH> Path to keypair file (default: ~/.config/solana/id.json)
16
- -r, --reserve <RESERVE_ADDRESS> Reserve address
17
- -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
46
+ -a, --authority <pubkey> Authority (defaults to signer)
18
47
 
19
48
  Example:
20
- pnpm jbond initialize -r 61mS9nEir6jx6cvte6NzQpyrFk3Fj4krMNLuHhi4tjJz -c mainnet-beta
49
+ pnpm jbond init -a 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
21
50
  ```
22
51
 
23
- **Note**: This command should only be run once by the program authority.
52
+ **Note**: This command should only be run once by the program authority during initial deployment.
53
+
54
+ ---
55
+
56
+ ### Bond Management
24
57
 
25
- ### Register Validator
58
+ #### Initialize Bond
26
59
 
27
- Register a new validator and deposit initial collateral.
60
+ Initialize a new bond project.
28
61
 
29
62
  ```bash
30
- pnpm jbond register-validator <vote-account> <amount> -k <path>
63
+ pnpm jbond bond init <name> [options]
31
64
 
32
65
  Arguments:
33
- vote-account Vote account public key
34
- amount Initial collateral amount in SOL
66
+ name Bond name
35
67
 
36
68
  Options:
37
- -k, --keypair <KEYPAIR_PATH> Path to keypair file (default: ~/.config/solana/id.json)
38
- -w, Optional withdraw authority
39
- -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
69
+ -r, --reserve <address> Reserve vault address (defaults to signer)
70
+ -c, --collateral <type> Collateral type: native | token:<mint> | stakeAccount (default: native)
71
+ -a, --authority <pubkey> Withdraw authority (defaults to signer)
72
+
73
+ Examples:
74
+ # Initialize bond with native SOL collateral
75
+ pnpm jbond bond init performance -r 61mS9nEir6jx6cvte6NzQpyrFk3Fj4krMNLuHhi4tjJz
76
+
77
+ # Initialize with SPL token collateral
78
+ pnpm jbond bond init performance -r <reserve> -c token:7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn
79
+ ```
80
+
81
+ #### Update Bond Configuration
82
+
83
+ Update bond configuration (authority only).
84
+
85
+ ```bash
86
+ pnpm jbond bond config [options]
87
+
88
+ Options:
89
+ -r, --reserve <address> New reserve vault address
90
+ -a, --authority <pubkey> New withdraw authority
91
+
92
+ Example:
93
+ pnpm jbond bond config -r 61mS9nEir6jx6cvte6NzQpyrFk3Fj4krMNLuHhi4tjJz
94
+ ```
95
+
96
+ #### Bond Info
97
+
98
+ Display information about a bond.
99
+
100
+ ```bash
101
+ pnpm jbond bond info
40
102
 
41
103
  Example:
42
- pnpm jbond register-validator 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu 1.1 -k ~/.config/solana/id.json -c mainnet-beta
104
+ pnpm jbond bond info -b performance
43
105
  ```
44
106
 
45
- **Requirements**:
107
+ **Displays:**
46
108
 
47
- - Minimum collateral amount is determined by the program (typically 1 SOL)
48
- - The keypair must have sufficient SOL for collateral + transaction fees
109
+ - Bond name and type
110
+ - Reserve vault address
111
+ - Withdraw authority
112
+ - Collateral type
113
+ - Total validators
49
114
 
50
- ### Top Up Collateral
115
+ #### List Bonds
51
116
 
52
- Add additional collateral to an existing validator bond.
117
+ List all bonds for the current bond type.
53
118
 
54
119
  ```bash
55
- pnpm jbond topup-collateral <vote-account> <amount> -k <path>
120
+ pnpm jbond bond list
56
121
 
57
- Arguments:
58
- vote-account Vote account public key
59
- amount Amount to add in SOL
122
+ Example:
123
+ pnpm jbond bond list -t standard
124
+ ```
60
125
 
61
- Options:
62
- -k, --keypair <KEYPAIR_PATH> Path to keypair file (default: ~/.config/solana/id.json)
63
- -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
126
+ #### Collateral Type Info
127
+
128
+ Display collateral type information for the bond.
129
+
130
+ ```bash
131
+ pnpm jbond bond collateral-type
64
132
 
65
133
  Example:
66
- pnpm jbond topup-collateral 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu 50 -c mainnet-beta
134
+ pnpm jbond bond collateral-type -b performance
67
135
  ```
68
136
 
69
- ### Withdraw Collateral
137
+ ---
138
+
139
+ ### Validator Operations
70
140
 
71
- Withdraw collateral from validator bond account.
141
+ #### Register Validator
142
+
143
+ Register a new validator and create bond account.
72
144
 
73
145
  ```bash
74
- pnpm jbond withdraw-collateral <vote-account> <destination> <amount> [options]
146
+ pnpm jbond validator register <vote-account>
75
147
 
76
148
  Arguments:
77
- vote-account Vote account public key
78
- destination Destination address for withdrawn funds
79
- amount Amount to withdraw in SOL
80
-
81
- Options:
82
- -k, --keypair <path> Path to keypair file (default: ~/.config/solana/id.json)
83
- -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
149
+ vote-account Vote account public key
84
150
 
85
151
  Example:
86
- pnpm jbond withdraw-collateral 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu 3K2coMGaZhrSkyF52wUBUXBeRBRpGLnmB3znzLRKjgiP 25 -c mainnet-beta
152
+ pnpm jbond validator register GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD
87
153
  ```
88
154
 
89
- **Requirements**:
155
+ **Requirements:**
90
156
 
91
- Only the validator identity or withdrawal authority can execute withdrawals. The validator bond account must have sufficient collateral
157
+ - Bond must be initialized first
158
+ - Signer will be set as validator identity
159
+ - `JBOND_BOND` environment variable or `-b` flag required
92
160
 
93
- ### Claim Compensation
161
+ #### Top Up Collateral
94
162
 
95
- Claim compensation from a validator's collateral to the reserve (authority only).
163
+ Add collateral to an existing validator bond account.
96
164
 
97
165
  ```bash
98
- pnpm jbond claim-compensation <vote-account> <amount> -k <path>
166
+ pnpm jbond validator topup <vote-account> <amount>
99
167
 
100
168
  Arguments:
101
- vote-account Vote account public key
102
- amount Amount to claim in SOL
103
-
104
- Options:
105
- -k, --keypair <KEYPAIR_PATH> Path to keypair file (default: ~/.config/solana/id.json)
106
- -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
169
+ vote-account Vote account public key
170
+ amount Amount to add in SOL
107
171
 
108
172
  Example:
109
- pnpm jbond claim-compensation GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 10 -k <path> -c mainnet-beta
173
+ pnpm jbond validator topup GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 50
110
174
  ```
111
175
 
112
- **Note**: Only the program authority can execute withdrawals.
176
+ #### Withdraw Collateral
113
177
 
114
- ### Update Global Config
178
+ Withdraw collateral from a validator bond account.
115
179
 
180
+ ```bash
181
+ pnpm jbond validator withdraw <vote-account> <amount> <destination>
182
+
183
+ Arguments:
184
+ vote-account Vote account public key
185
+ amount Amount to withdraw in SOL
186
+ destination Destination address for withdrawn funds
187
+
188
+ Example:
189
+ pnpm jbond validator withdraw GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 25 3K2coMGaZhrSkyF52wUBUXBeRBRpGLnmB3znzLRKjgiP
116
190
  ```
117
- pnpm jbond configure [options]
118
191
 
119
- Options:
120
- -k, --keypair <KEYPAIR_PATH> Path to keypair file (default: ~/.config/solana/id.json)
121
- -a, --new-authority <PUBKEY> New authority public key
122
- -r, --new-reserve <PUBKEY> New reserve address
123
- -c, --cluster <CLUSTER_NAME> Solana cluster (devnet or mainnet-beta)
192
+ **Requirements:**
124
193
 
125
- Examples:
194
+ - Only validator identity or withdrawal authority can execute
195
+ - Bond account must have sufficient collateral
196
+ - Session must not be active (or must be finished)
197
+
198
+ #### Claim Compensation
199
+
200
+ Claim collateral from validator to reserve (authority only).
201
+
202
+ ```bash
203
+ pnpm jbond validator claim <vote-account> <amount>
204
+
205
+ Arguments:
206
+ vote-account Vote account public key
207
+ amount Amount to claim in SOL
126
208
 
127
- pnpm jbond configure -a 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin -c mainnet-beta
128
- pnpm jbond configure -r 61mS9nEir6jx6cvte6NzQpyrFk3Fj4krMNLuHhi4tjJz -c mainnet-beta
129
- pnpm jbond configure \
130
- -a 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin\
131
- -r 61mS9nEir6jx6cvte6NzQpyrFk3Fj4krMNLuHhi4tjJz\
132
- -c mainnet-beta
209
+ Example:
210
+ pnpm jbond validator claim GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 10
133
211
  ```
134
212
 
135
- ### Validator Info
213
+ **Note**: Only the bond authority can execute compensation claims.
214
+
215
+ #### Validator Info
136
216
 
137
217
  Display information about a validator bond account.
138
218
 
139
219
  ```bash
140
- pnpm jbond validator-info <vote-account> [options]
220
+ pnpm jbond validator info <vote-account>
141
221
 
142
222
  Arguments:
143
- vote-account Vote account public key
144
-
145
- Options:
146
- -k, --keypair <KEYPAIR_PATH> Path to keypair file (default: ~/.config/solana/id.json)
147
- -v, --validator <pubkey> Validator public key,
148
- -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
223
+ vote-account Vote account public key
149
224
 
150
225
  Example:
151
- pnpm jbond validator-info GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD -k <path> -c mainnet-beta
226
+ pnpm jbond validator info GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD
152
227
  ```
153
228
 
154
- **Displays**:
229
+ **Displays:**
155
230
 
156
231
  - Validator identity
157
232
  - Vote account
233
+ - Bond name and type
234
+ - Collateral amount
158
235
  - Withdrawal authority
159
- - Active status
236
+ - Session status
160
237
  - Creation timestamp
161
238
 
162
- ### Global state Info
239
+ #### Set Withdrawal Authority
240
+
241
+ Set or update the withdrawal authority for a validator bond account.
242
+
243
+ ```bash
244
+ pnpm jbond validator set-authority <vote-account> [options]
245
+
246
+ Arguments:
247
+ vote-account Vote account public key
248
+
249
+ Options:
250
+ -a, --authority <pubkey> New withdrawal authority (omit to remove authority)
251
+
252
+ Examples:
253
+ # Set a withdrawal authority
254
+ pnpm jbond validator set-authority GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD -a 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
255
+
256
+ # Remove withdrawal authority (revert to identity-only)
257
+ pnpm jbond validator set-authority GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD
258
+ ```
259
+
260
+ **Requirements:**
261
+
262
+ - Only the validator identity can set or update the withdrawal authority
263
+ - When set, only that authority (or validator identity) can withdraw collateral
163
264
 
164
- Display information about the global state.
265
+ #### Transaction History
266
+
267
+ View transaction history for a validator bond account.
165
268
 
166
269
  ```bash
167
- pnpm jbond state [options]
270
+ pnpm jbond validator history <vote-account> [options]
271
+
272
+ Arguments:
273
+ vote-account Vote account public key
168
274
 
169
275
  Options:
170
- -k, --keypair <KEYPAIR_PATH> Path to keypair file (default: ~/.config/solana/id.json)
171
- -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
276
+ -l, --limit <number> Number of transactions to fetch (default: 10)
172
277
 
173
278
  Example:
174
- pnpm jbond state -k <path> -c mainnet-beta
279
+ pnpm jbond validator history GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD -l 20
175
280
  ```
176
281
 
177
- **Displays**:
282
+ **Displays:**
283
+
284
+ - Transaction signatures
285
+ - Timestamps
286
+ - Transaction types (register, topup, withdraw, etc.)
287
+ - Amounts
288
+
289
+ ---
178
290
 
179
- - Authority public key
180
- - Total number of validators
181
- - Current epoch
291
+ ### Session Management
292
+
293
+ #### Start Session
294
+
295
+ Start a new time-locked bond session.
296
+
297
+ ```bash
298
+ pnpm jbond session start <duration>
299
+
300
+ Arguments:
301
+ duration Session duration in seconds
302
+
303
+ Example:
304
+ pnpm jbond session start 86400 # 1 day
305
+ ```
306
+
307
+ **Common durations:**
308
+
309
+ - 1 hour: `3600`
310
+ - 1 day: `86400`
311
+ - 1 week: `604800`
312
+ - 30 days: `2592000`
313
+
314
+ **Purpose:**
315
+
316
+ - Time-locks collateral withdrawals
317
+ - Demonstrates validator commitment
318
+ - Enhances security for delegators
319
+
320
+ #### Finish Session
321
+
322
+ Finish the active bond session.
323
+
324
+ ```bash
325
+ pnpm jbond session finish
326
+
327
+ Example:
328
+ pnpm jbond session finish -b performance
329
+ ```
330
+
331
+ **Requirements:**
332
+
333
+ - Session must be active
334
+ - Session duration must have elapsed
335
+ - Only validator identity can finish session
336
+
337
+ ---
182
338
 
183
339
  ## Usage Examples
184
340
 
185
- ### Complete Validator Registration Flow
341
+ ### Complete Workflow
186
342
 
187
343
  ```bash
188
- # 1. Check current global state
189
- pnpm jbond global-state-info -c mainnet-beta
344
+ # 1. Set environment
345
+ export JBOND_BOND=performance
346
+ export CLUSTER=mainnet-beta
347
+
348
+ # 2. Initialize bond (first time only)
349
+ pnpm jbond bond init performance -r 61mS9nEir6jx6cvte6NzQpyrFk3Fj4krMNLuHhi4tjJz
350
+
351
+ # 3. Register as validator
352
+ pnpm jbond validator register GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD
190
353
 
191
- # 2. Register as a validator with 100 SOL collateral
192
- pnpm jbond register-validator GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 100 -c mainnet-beta
354
+ # 4. Add collateral
355
+ pnpm jbond validator topup GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 100
193
356
 
194
- # 3. Verify registration
195
- pnpm jbond validator-info GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD -c mainnet-beta
357
+ # 5. Check bond info
358
+ pnpm jbond validator info GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD
196
359
 
197
- # 4. Top up with additional 50 SOL
198
- pnpm jbond topup-collateral GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 50 -c mainnet-beta
360
+ # 6. Start session (optional)
361
+ pnpm jbond session start 86400
362
+
363
+ # 7. View transaction history
364
+ pnpm jbond validator history GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD -l 20
199
365
  ```
200
366
 
201
367
  ### Authority Operations
202
368
 
203
369
  ```bash
204
- # As authority, withdraw compensation from underperforming validator
205
- pnpm jbond claim-compensation GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 5 -c mainnet-beta
370
+ # Update bond configuration
371
+ pnpm jbond bond config -r <new-reserve>
372
+
373
+ # Claim compensation from underperforming validator
374
+ pnpm jbond validator claim GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 5
375
+
376
+ # Check bond statistics
377
+ pnpm jbond bond info
378
+ ```
379
+
380
+ ### Multiple Clusters
381
+
382
+ ```bash
383
+ # Devnet operations
384
+ pnpm jbond validator info GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD -c devnet
206
385
 
207
- # Check pool statistics
208
- pnpm jbond global-state-info -c mainnet-beta
386
+ # Custom RPC endpoint
387
+ pnpm jbond validator info GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD -c https://api.mainnet-beta.solana.com
209
388
  ```
210
389
 
390
+ ---
391
+
211
392
  ## Error Handling
212
393
 
213
- Common errors and solutions:
394
+ ### Common Errors
395
+
396
+ #### `Bond is required. Use -b <name>`
397
+
398
+ Set the `JBOND_BOND` environment variable or use the `-b` flag:
214
399
 
215
- ### `Failed to load keypair`
400
+ ```bash
401
+ export JBOND_BOND=performance
402
+ # or
403
+ pnpm jbond validator info <vote> -b performance
404
+ ```
405
+
406
+ #### `Failed to load keypair`
216
407
 
217
408
  - Ensure the keypair file exists at the specified path
218
409
  - Check file permissions
219
410
  - Verify the keypair file is in valid JSON format
411
+ - Try specifying the path explicitly with `-k`
412
+
413
+ #### `Validator bond account not found`
414
+
415
+ - Ensure the validator is registered first
416
+ - Verify the vote account address is correct
417
+ - Check that you're using the correct cluster
220
418
 
221
- ### `InsufficientCollateral`
419
+ #### `Invalid amount: must be positive number`
222
420
 
223
- - The collateral amount is below the minimum requirement
224
- - Check the program's minimum collateral requirement
421
+ - Ensure the amount is a valid positive number
422
+ - Don't include units (SOL) in the amount
225
423
 
226
- ### `Unauthorized`
424
+ #### `Unauthorized`
227
425
 
228
- - Only the authority can withdraw compensations
426
+ - Only the authority can claim compensation
427
+ - Only the validator identity can set withdrawal authority
229
428
  - Ensure you're using the correct authority keypair
230
429
 
231
- ### `Account already in use`
430
+ #### `Account already in use`
232
431
 
233
432
  - The validator is already registered
234
- - Use `topup-collateral` to add more funds instead
433
+ - Use `topup` to add more collateral instead
434
+
435
+ ---
436
+
437
+ ## Bond Types
438
+
439
+ ### Standard Bond
440
+
441
+ Individual validator operations with full control over collateral.
442
+
443
+ ```bash
444
+ pnpm jbond bond init performance -r <reserve> -t standard
445
+ ```
446
+
447
+ ### Crowdfunding Bond
448
+
449
+ Community-backed validator bonds with shared collateral.
450
+
451
+ ```bash
452
+ pnpm jbond bond init performance -r <reserve> -t crowdfunding
453
+ ```
454
+
455
+ ---
456
+
457
+ ## Collateral Types
458
+
459
+ ### Native SOL
460
+
461
+ Direct SOL deposits (default).
462
+
463
+ ```bash
464
+ pnpm jbond bond init performance -r <reserve> -c native
465
+ ```
466
+
467
+ ### SPL Token
468
+
469
+ Custom token collateral.
470
+
471
+ ```bash
472
+ pnpm jbond bond init performance -r <reserve> -c token:7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn
473
+ ```
474
+
475
+ ### Stake Account
476
+
477
+ Existing stake account collateral.
478
+
479
+ ```bash
480
+ pnpm jbond bond init performance -r <reserve> -c stakeAccount
481
+ ```
482
+
483
+ ---
484
+
485
+ ## Development
486
+
487
+ ### Running from Source
488
+
489
+ ```bash
490
+ # From repository root
491
+ pnpm install
492
+ pnpm cli --help
493
+
494
+ # Run specific command
495
+ pnpm cli validator info <vote-account>
496
+ ```
497
+
498
+ ### Building
499
+
500
+ ```bash
501
+ pnpm cli build
502
+ ```