11use std:: { path:: PathBuf , str:: FromStr } ;
22
33use anchor_lang:: { system_program, AccountDeserialize , InstructionData , ToAccountMetas } ;
4+ use bs58;
45use clap:: { Parser , Subcommand } ;
56use jito_priority_fee_distribution:: state:: { ClaimStatus , Config , PriorityFeeDistributionAccount } ;
67use jito_priority_fee_distribution_sdk:: {
@@ -9,10 +10,14 @@ use jito_priority_fee_distribution_sdk::{
910use solana_client:: { rpc_client:: RpcClient , rpc_config:: RpcSendTransactionConfig } ;
1011use solana_sdk:: {
1112 compute_budget:: ComputeBudgetInstruction ,
13+
1214 instruction:: Instruction ,
15+
1316 pubkey:: Pubkey ,
14- signer:: { keypair:: read_keypair_file, Signer } ,
17+
18+ signer:: { { keypair:: read_keypair_file, Signer } ,
1519 transaction:: Transaction ,
20+ , Signer } ,
1621} ;
1722
1823#[ derive( Parser ) ]
@@ -156,6 +161,17 @@ enum Commands {
156161 #[ arg( long) ]
157162 lamports : u64 ,
158163 } ,
164+
165+ /// Update the merkle root upload config account
166+ UpdateMerkleRootUploadConfig {
167+ /// Authority pubkey
168+ #[ arg( long) ]
169+ authority : String ,
170+
171+ /// Original authority pubkey
172+ #[ arg( long) ]
173+ original_authority : String ,
174+ } ,
159175}
160176
161177fn main ( ) -> anyhow:: Result < ( ) > {
@@ -276,11 +292,11 @@ fn main() -> anyhow::Result<()> {
276292 bump,
277293 go_live_epoch,
278294 } => {
279- let authority_pubkey = Pubkey :: from_str ( & authority ) ? ;
295+ let authority_pubkey = authority_keypair . pubkey ( ) ;
280296 let expired_funds_account_pubkey = Pubkey :: from_str ( & expired_funds_account) ?;
281297
282298 let config = Config {
283- authority : authority_pubkey ,
299+ authority : Pubkey :: from_str ( & authority ) ? ,
284300 expired_funds_account : expired_funds_account_pubkey,
285301 num_epochs_valid,
286302 max_validator_commission_bps,
@@ -305,7 +321,12 @@ fn main() -> anyhow::Result<()> {
305321
306322 let serialized_data = instruction. data ;
307323 let base58_data = bs58:: encode ( serialized_data) . into_string ( ) ;
308- println ! ( "Base58 Serialized Data: {}" , base58_data) ;
324+ println ! ( "Base58 Serialized Data: {}" , base58_data) ; * /
325+ let mut transaction =
326+ solana_sdk:: transaction:: Transaction :: new_with_payer ( & [ instruction] , None ) ;
327+ transaction. sign ( & [ & authority_keypair] , client. get_latest_blockhash ( ) ?) ;
328+ let signature = client. send_and_confirm_transaction_with_spinner ( & transaction) ?;
329+ println ! ( "Transaction Signature: {}" , signature) ;
309330 }
310331
311332 Commands :: Initialize {
@@ -414,6 +435,56 @@ fn main() -> anyhow::Result<()> {
414435 println ! ( " Bump: {}" , config. bump) ;
415436 }
416437
438+ Commands :: UpdateMerkleRootUploadConfig {
439+ authority,
440+ original_authority,
441+ } => {
442+ let authority_pubkey = Pubkey :: from_str ( & authority) ?;
443+ let original_authority_pubkey = Pubkey :: from_str ( & original_authority) ?;
444+
445+ let ( config_pda, _) = derive_config_account_address ( & program_id) ;
446+ let ( merkle_root_upload_config, _) =
447+ Pubkey :: find_program_address ( & [ b"ROOT_UPLOAD_CONFIG" ] , & program_id) ;
448+
449+ let instruction = Instruction {
450+ program_id,
451+ data : jito_priority_fee_distribution:: instruction:: UpdateMerkleRootUploadConfig {
452+ authority : authority_pubkey,
453+ original_authority : original_authority_pubkey,
454+ }
455+ . data ( ) ,
456+ accounts : jito_priority_fee_distribution:: accounts:: UpdateMerkleRootUploadConfig {
457+ config : config_pda,
458+ merkle_root_upload_config,
459+ authority : authority_pubkey,
460+ system_program : solana_sdk:: system_program:: ID ,
461+ }
462+ . to_account_metas ( None ) ,
463+ } ;
464+
465+ let serialized_data = instruction. data ;
466+ let base58_data = bs58:: encode ( serialized_data) . into_string ( ) ;
467+ println ! ( "Base58 Serialized Data: {}" , base58_data) ;
468+
469+ println ! ( "\n Accounts:" ) ;
470+ for ( i, account_meta) in instruction. accounts . iter ( ) . enumerate ( ) {
471+ let writable_status = if account_meta. is_writable {
472+ "writable"
473+ } else {
474+ "readonly"
475+ } ;
476+ let signer_status = if account_meta. is_signer {
477+ "signer"
478+ } else {
479+ "non-signer"
480+ } ;
481+ println ! (
482+ " {}: {} ({}, {})" ,
483+ i, account_meta. pubkey, writable_status, signer_status
484+ ) ;
485+ }
486+ }
487+
417488 Commands :: TransferPriorityFeeTips {
418489 keypair_path,
419490 vote_account,
0 commit comments