@@ -3,7 +3,7 @@ use std::str::FromStr;
3
3
use anyhow:: { anyhow, Result } ;
4
4
use jito_bytemuck:: { AccountDeserialize , Discriminator } ;
5
5
use jito_restaking_client:: instructions:: {
6
- InitializeConfigBuilder , InitializeNcnBuilder , InitializeOperatorBuilder ,
6
+ InitializeConfigBuilder , InitializeNcnBuilder , InitializeOperatorBuilder , SetConfigAdminBuilder ,
7
7
} ;
8
8
use jito_restaking_core:: { config:: Config , ncn:: Ncn , operator:: Operator } ;
9
9
use log:: { debug, info} ;
@@ -51,6 +51,9 @@ impl RestakingCliHandler {
51
51
RestakingCommands :: Config {
52
52
action : ConfigActions :: Get ,
53
53
} => self . get_config ( ) . await ,
54
+ RestakingCommands :: Config {
55
+ action : ConfigActions :: SetAdmin { new_admin } ,
56
+ } => self . set_config_admin ( new_admin) . await ,
54
57
RestakingCommands :: Ncn {
55
58
action : NcnActions :: Initialize ,
56
59
} => self . initialize_ncn ( ) . await ,
@@ -288,4 +291,39 @@ impl RestakingCliHandler {
288
291
fn get_rpc_client ( & self ) -> RpcClient {
289
292
RpcClient :: new_with_commitment ( self . cli_config . rpc_url . clone ( ) , self . cli_config . commitment )
290
293
}
294
+
295
+ async fn set_config_admin ( & self , new_admin : Pubkey ) -> Result < ( ) > {
296
+ let keypair = self
297
+ . cli_config
298
+ . keypair
299
+ . as_ref ( )
300
+ . ok_or_else ( || anyhow ! ( "No keypair" ) ) ?;
301
+ let rpc_client = self . get_rpc_client ( ) ;
302
+
303
+ let config_address = Config :: find_program_address ( & self . restaking_program_id ) . 0 ;
304
+ let mut ix_builder = SetConfigAdminBuilder :: new ( ) ;
305
+ ix_builder
306
+ . config ( config_address)
307
+ . old_admin ( keypair. pubkey ( ) )
308
+ . new_admin ( new_admin) ;
309
+
310
+ let blockhash = rpc_client. get_latest_blockhash ( ) . await ?;
311
+ let tx = Transaction :: new_signed_with_payer (
312
+ & [ ix_builder. instruction ( ) ] ,
313
+ Some ( & keypair. pubkey ( ) ) ,
314
+ & [ keypair] ,
315
+ blockhash,
316
+ ) ;
317
+ info ! (
318
+ "Setting restaking config admin parameters: {:?}" ,
319
+ ix_builder
320
+ ) ;
321
+ info ! (
322
+ "Setting restaking config admin transaction: {:?}" ,
323
+ tx. get_signature( )
324
+ ) ;
325
+ rpc_client. send_and_confirm_transaction ( & tx) . await ?;
326
+ info ! ( "Transaction confirmed: {:?}" , tx. get_signature( ) ) ;
327
+ Ok ( ( ) )
328
+ }
291
329
}
0 commit comments