@@ -169,7 +169,7 @@ pub enum ProgramCliCommand {
169169 use_lamports_unit : bool ,
170170 bypass_warning : bool ,
171171 } ,
172- ExtendProgram {
172+ ExtendProgramChecked {
173173 program_pubkey : Pubkey ,
174174 additional_bytes : u32 ,
175175 } ,
@@ -1018,7 +1018,7 @@ pub fn parse_program_subcommand(
10181018 ) ?;
10191019
10201020 CliCommandInfo {
1021- command : CliCommand :: Program ( ProgramCliCommand :: ExtendProgram {
1021+ command : CliCommand :: Program ( ProgramCliCommand :: ExtendProgramChecked {
10221022 program_pubkey,
10231023 additional_bytes,
10241024 } ) ,
@@ -1231,7 +1231,7 @@ pub fn process_program_subcommand(
12311231 * use_lamports_unit,
12321232 * bypass_warning,
12331233 ) ,
1234- ProgramCliCommand :: ExtendProgram {
1234+ ProgramCliCommand :: ExtendProgramChecked {
12351235 program_pubkey,
12361236 additional_bytes,
12371237 } => process_extend_program ( & rpc_client, config, * program_pubkey, * additional_bytes) ,
@@ -2411,21 +2411,28 @@ fn process_extend_program(
24112411 _ => Err ( format ! ( "Program {program_pubkey} is closed" ) ) ,
24122412 } ?;
24132413
2414- match upgrade_authority_address {
2415- None => Err ( format ! ( "Program {program_pubkey} is not upgradeable" ) ) ,
2416- _ => Ok ( ( ) ) ,
2417- } ?;
2414+ let upgrade_authority_address = upgrade_authority_address
2415+ . ok_or_else ( || format ! ( "Program {program_pubkey} is not upgradeable" ) ) ?;
24182416
24192417 let blockhash = rpc_client. get_latest_blockhash ( ) ?;
2420-
2421- let mut tx = Transaction :: new_unsigned ( Message :: new (
2422- & [ loader_v3_instruction:: extend_program (
2423- & program_pubkey,
2424- Some ( & payer_pubkey) ,
2425- additional_bytes,
2426- ) ] ,
2427- Some ( & payer_pubkey) ,
2428- ) ) ;
2418+ let feature_set = fetch_feature_set ( rpc_client) ?;
2419+
2420+ let instruction =
2421+ if feature_set. is_active ( & agave_feature_set:: enable_extend_program_checked:: id ( ) ) {
2422+ loader_v3_instruction:: extend_program_checked (
2423+ & program_pubkey,
2424+ & upgrade_authority_address,
2425+ Some ( & payer_pubkey) ,
2426+ additional_bytes,
2427+ )
2428+ } else {
2429+ loader_v3_instruction:: extend_program (
2430+ & program_pubkey,
2431+ Some ( & payer_pubkey) ,
2432+ additional_bytes,
2433+ )
2434+ } ;
2435+ let mut tx = Transaction :: new_unsigned ( Message :: new ( & [ instruction] , Some ( & payer_pubkey) ) ) ;
24292436
24302437 tx. try_sign ( & [ config. signers [ 0 ] ] , blockhash) ?;
24312438 let result = rpc_client. send_and_confirm_transaction_with_spinner_and_config (
@@ -4406,7 +4413,7 @@ mod tests {
44064413 assert_eq ! (
44074414 parse_command( & test_command, & default_signer, & mut None ) . unwrap( ) ,
44084415 CliCommandInfo {
4409- command: CliCommand :: Program ( ProgramCliCommand :: ExtendProgram {
4416+ command: CliCommand :: Program ( ProgramCliCommand :: ExtendProgramChecked {
44104417 program_pubkey,
44114418 additional_bytes
44124419 } ) ,
0 commit comments