spherenet-admin 0.2.0

Command-line tool for SphereNet governance and network administration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
//! CLI command definitions
//!
//! CLAP structs and enums defining the CLI interface.

use clap::{Parser, Subcommand};

/// Default RPC_URL
pub const RPC_URL: &str = "https://api.testnet.sphere.net";

#[derive(Parser)]
#[command(name = "spherenet-admin")]
#[command(about = "SphereNet administration CLI", long_about = None)]
pub struct Cli {
    /// RPC URL to connect to
    #[arg(long, global = true, default_value = RPC_URL)]
    pub url: String,

    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Validator whitelist commands
    #[command(name = "vw")]
    ValidatorWhitelist {
        #[command(subcommand)]
        action: ValidatorWhitelistAction,
    },
    /// Program whitelist commands
    #[command(name = "pw")]
    ProgramWhitelist {
        #[command(subcommand)]
        action: ProgramWhitelistAction,
    },
    /// Monetary policy commands
    #[command(name = "mp")]
    MonetaryPolicy {
        #[command(subcommand)]
        action: MonetaryPolicyAction,
    },
    /// Program deployment commands
    Program {
        #[command(subcommand)]
        action: ProgramAction,
    },
    /// Multisig vault management commands
    Multisig {
        #[command(subcommand)]
        action: MultisigAction,
    },
    /// Request an airdrop for an account
    Airdrop {
        /// Account pubkey to receive the airdrop
        #[arg(long)]
        pubkey: String,
        /// Amount in SOL to airdrop
        #[arg(long, default_value = "1.0")]
        amount: f64,
    },
    /// Transfer SOL from one account to another
    Transfer {
        /// Destination account pubkey
        #[arg(long)]
        destination: String,
        /// Amount in SOL to transfer
        #[arg(long)]
        amount: f64,
        /// Single-sig: path to source keypair (mutually exclusive with --multisig)
        #[arg(long, conflicts_with = "multisig")]
        from: Option<String>,
        /// Multi-sig: multisig PDA address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
}

#[derive(Subcommand)]
pub enum ValidatorWhitelistAction {
    /// Show validator whitelist account (authority and entries)
    Show,
    /// Add a validator to the whitelist
    Add {
        vote_account: String,
        #[arg(long)]
        start_epoch: Option<u64>,
        #[arg(long)]
        end_epoch: Option<u64>,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Remove a validator from the whitelist
    Remove {
        vote_account: String,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Update a validator's start epoch
    UpdateStartEpoch {
        vote_account: String,
        #[arg(long)]
        epoch: u64,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Update a validator's end epoch
    UpdateEndEpoch {
        vote_account: String,
        #[arg(long)]
        epoch: u64,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Propose a new authority
    ProposeAuthority {
        new_authority: String,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Accept pending authority transfer
    AcceptAuthority {
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Cancel pending authority transfer
    CancelAuthority {
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
}

#[derive(Subcommand)]
pub enum ProgramWhitelistAction {
    /// Show program whitelist account (authority + deployers)
    Show,
    /// Whitelist a deployer authority (who can deploy/upgrade programs)
    Add {
        program_authority: String,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Remove a deployer authority from the whitelist
    Remove {
        program_authority: String,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Propose a new authority
    ProposeAuthority {
        new_authority: String,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Accept pending authority transfer
    AcceptAuthority {
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Cancel pending authority transfer
    CancelAuthority {
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
}

#[derive(Subcommand)]
pub enum ProgramAction {
    /// Deploy a program to SphereNet
    Deploy {
        /// Path to the program .so file
        #[arg(long)]
        program_so: String,

        /// Path to the program keypair (the program ID will be derived from this)
        #[arg(long)]
        program_keypair: String,

        /// Path to upgrade authority keypair (must sign deployment)
        #[arg(long)]
        upgrade_authority: String,

        /// Payer keypair path (defaults to solana config default keypair)
        #[arg(long)]
        payer: String,

        /// Maximum program data length (optional, defaults to program size)
        #[arg(long)]
        max_data_len: Option<usize>,
    },
    /// Upgrade an existing program on SphereNet
    Upgrade {
        /// Program ID of the existing program to upgrade
        #[arg(long)]
        program_id: String,

        /// Path to the new program .so file
        #[arg(long)]
        program_so: String,

        /// Single-sig: path to upgrade authority keypair (mutually exclusive with --vault)
        #[arg(long, conflicts_with = "multisig")]
        upgrade_authority: Option<String>,

        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,

        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,

        /// Payer keypair path
        #[arg(long)]
        payer: String,

        /// Spill account (where excess buffer rent is returned, defaults to payer)
        #[arg(long)]
        spill: Option<String>,
    },
    /// Extend a program's data account to accommodate larger programs
    Extend {
        /// Program ID of the program to extend
        #[arg(long)]
        program_id: String,

        /// Number of additional bytes to add
        #[arg(long)]
        bytes: u32,

        /// Single-sig: path to upgrade authority keypair (mutually exclusive with --multisig)
        #[arg(long, conflicts_with = "multisig")]
        upgrade_authority: Option<String>,

        /// Multi-sig: multisig address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,

        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,

        /// Payer keypair path
        #[arg(long)]
        payer: String,
    },
}

#[derive(Subcommand)]
pub enum MultisigAction {
    /// Initialize Squads program config (one-time setup)
    ProgramConfigInit {
        /// Pubkey that will control the program config
        #[arg(long)]
        authority: String,

        /// Pubkey where multisig creation fees are sent
        #[arg(long)]
        treasury: String,

        /// Fee in lamports charged for creating a multisig
        #[arg(long, default_value = "0")]
        creation_fee: u64,

        /// Path to INITIALIZER keypair (hardcoded in program)
        #[arg(long)]
        initializer: String,
    },
    /// Create a new multisig vault
    Create {
        /// Comma-separated list of member pubkeys
        #[arg(long)]
        members: String,

        /// Number of approvals required (e.g., 2 for 2-of-3)
        #[arg(long)]
        threshold: u16,

        /// Path to create key keypair (unique ID for this multisig)
        #[arg(long)]
        create_key: String,

        /// Path to payer keypair
        #[arg(long)]
        payer: String,

        /// Optional: time lock delay in seconds
        #[arg(long)]
        time_lock: Option<u32>,

        /// Optional: description/memo
        #[arg(long)]
        memo: Option<String>,
    },
    /// Show multisig vault information (fetches on-chain data)
    Show {
        /// Path to create key keypair used during vault creation (mutually exclusive with --multisig)
        #[arg(long, conflicts_with = "multisig")]
        create_key: Option<String>,

        /// Multisig PDA address (mutually exclusive with --create-key)
        #[arg(long, conflicts_with = "create_key")]
        multisig: Option<String>,
    },
    /// Approve a multisig proposal
    Approve {
        /// Multisig PDA address
        #[arg(long)]
        multisig: String,

        /// Transaction index of the proposal to approve
        #[arg(long)]
        transaction_index: u64,

        /// Path to member keypair who is approving
        #[arg(long)]
        member: String,
    },
    /// Execute an approved multisig proposal
    Execute {
        /// Multisig PDA address
        #[arg(long)]
        multisig: String,

        /// Transaction index of the proposal to execute
        #[arg(long)]
        transaction_index: u64,

        /// Path to member keypair who is executing
        #[arg(long)]
        member: String,
    },
}

#[derive(Subcommand)]
pub enum MonetaryPolicyAction {
    /// Show monetary policy account details
    Show,
    /// Create the monetary policy account
    Create {
        /// Single-sig: path to authority keypair (who will control the policy)
        #[arg(long = "authority", alias = "auth")]
        authority: String,
        /// Path to payer keypair (who pays for account creation)
        #[arg(long)]
        payer: String,
    },
    /// Show authority account
    Auth,
    /// Propose a new authority
    ProposeAuthority {
        new_authority: String,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Accept pending authority transfer
    AcceptAuthority {
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Cancel pending authority transfer
    CancelAuthority {
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Update inflation rate (in basis points)
    UpdateInflationRate {
        /// New inflation rate in basis points (0-2000 bips = 0-20%)
        new_rate_bips: u64,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Update lamports per signature (transaction fee)
    UpdateLamportsPerSignature {
        /// New lamports per signature (1-10,000,000 lamports)
        new_lamports_per_signature: u64,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
    /// Update burn percent
    UpdateBurnPercent {
        /// New burn percent (0-100%)
        new_percent: u8,
        /// Single-sig: path to authority keypair (mutually exclusive with --multisig)
        #[arg(long = "authority", alias = "auth", conflicts_with = "multisig")]
        authority: Option<String>,
        /// Multi-sig: vault address (requires --multisig-authority)
        #[arg(long, requires = "multisig_authority")]
        multisig: Option<String>,
        /// Multi-sig: path to signer keypair that pays for proposal creation
        #[arg(long, requires = "multisig")]
        multisig_authority: Option<String>,
    },
}