Deprecate Instruction::new (#15695)
This commit is contained in:
parent
d6ea2f392b
commit
b53cb8eb2d
|
@ -110,7 +110,7 @@ pub fn create_account(
|
||||||
AccountMeta::new(*from_pubkey, true),
|
AccountMeta::new(*from_pubkey, true),
|
||||||
AccountMeta::new(*to_pubkey, true),
|
AccountMeta::new(*to_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::CreateAccount {
|
&SystemInstruction::CreateAccount {
|
||||||
lamports,
|
lamports,
|
||||||
|
|
|
@ -95,7 +95,7 @@ pub fn transfer(from_account: Pubkey, to_account: Pubkey, lamports: u64) -> Inst
|
||||||
AccountMeta::new(from_pubkey, true),
|
AccountMeta::new(from_pubkey, true),
|
||||||
AccountMeta::new(to_pubkey, false),
|
AccountMeta::new(to_pubkey, false),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
test_program::id(),
|
test_program::id(),
|
||||||
&SystemInstruction::Transfer { lamports },
|
&SystemInstruction::Transfer { lamports },
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -114,7 +114,7 @@ pub fn multisig(data_account: Pubkey, signers: &[Pubkey]) -> Instruction {
|
||||||
account_metas.push(AccountMeta::new_readonly(pubkey, true));
|
account_metas.push(AccountMeta::new_readonly(pubkey, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
test_program::id(),
|
test_program::id(),
|
||||||
&TestInstruction::Multisig,
|
&TestInstruction::Multisig,
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -138,7 +138,7 @@ pub fn advance_nonce_account(
|
||||||
if let Some(pubkey) = authorized_pubkey {
|
if let Some(pubkey) = authorized_pubkey {
|
||||||
account_metas.push(AccountMeta::new_readonly*nonce_authority, true));
|
account_metas.push(AccountMeta::new_readonly*nonce_authority, true));
|
||||||
}
|
}
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
test_program::id(),
|
test_program::id(),
|
||||||
&TestInstruction::AdvanceNonceAccount,
|
&TestInstruction::AdvanceNonceAccount,
|
||||||
account_metas,
|
account_metas,
|
||||||
|
|
|
@ -645,7 +645,7 @@ fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box<dyn error::Error>> {
|
||||||
("verify", Some(matches)) => {
|
("verify", Some(matches)) => {
|
||||||
let keypair = get_keypair_from_matches(matches, config, &mut wallet_manager)?;
|
let keypair = get_keypair_from_matches(matches, config, &mut wallet_manager)?;
|
||||||
let simple_message = Message::new(
|
let simple_message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
Pubkey::default(),
|
Pubkey::default(),
|
||||||
&0,
|
&0,
|
||||||
vec![AccountMeta::new(keypair.pubkey(), true)],
|
vec![AccountMeta::new(keypair.pubkey(), true)],
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn invoker_process_instruction(
|
||||||
let account_info_iter = &mut accounts.iter();
|
let account_info_iter = &mut accounts.iter();
|
||||||
let invoked_program_info = next_account_info(account_info_iter)?;
|
let invoked_program_info = next_account_info(account_info_iter)?;
|
||||||
invoke(
|
invoke(
|
||||||
&Instruction::new(*invoked_program_info.key, &[0], vec![]),
|
&Instruction::new_with_bincode(*invoked_program_info.key, &[0], vec![]),
|
||||||
&[invoked_program_info.clone()],
|
&[invoked_program_info.clone()],
|
||||||
)?;
|
)?;
|
||||||
msg!("Processing invoker instruction after CPI");
|
msg!("Processing invoker instruction after CPI");
|
||||||
|
@ -58,7 +58,7 @@ async fn cpi() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut test_state = program_test.start_with_context().await;
|
let mut test_state = program_test.start_with_context().await;
|
||||||
let instructions = vec![Instruction::new(
|
let instructions = vec![Instruction::new_with_bincode(
|
||||||
invoker_program_id,
|
invoker_program_id,
|
||||||
&[0],
|
&[0],
|
||||||
vec![AccountMeta::new_readonly(invoked_program_id, false)],
|
vec![AccountMeta::new_readonly(invoked_program_id, false)],
|
||||||
|
|
|
@ -92,7 +92,7 @@ async fn run_fuzz_instructions(
|
||||||
program_id,
|
program_id,
|
||||||
);
|
);
|
||||||
instructions.push(instruction);
|
instructions.push(instruction);
|
||||||
instructions.push(Instruction::new(*program_id, &[0], vec![]));
|
instructions.push(Instruction::new_with_bincode(*program_id, &[0], vec![]));
|
||||||
signer_keypairs.push(keypair);
|
signer_keypairs.push(keypair);
|
||||||
}
|
}
|
||||||
// Process transaction on test network
|
// Process transaction on test network
|
||||||
|
|
|
@ -58,7 +58,7 @@ async fn clock_sysvar_updated_from_warp() {
|
||||||
|
|
||||||
let mut context = program_test.start_with_context().await;
|
let mut context = program_test.start_with_context().await;
|
||||||
let expected_slot = 5_000_000;
|
let expected_slot = 5_000_000;
|
||||||
let instruction = Instruction::new(
|
let instruction = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&expected_slot,
|
&expected_slot,
|
||||||
vec![AccountMeta::new_readonly(clock::id(), false)],
|
vec![AccountMeta::new_readonly(clock::id(), false)],
|
||||||
|
@ -83,7 +83,7 @@ async fn clock_sysvar_updated_from_warp() {
|
||||||
|
|
||||||
// Warp to success!
|
// Warp to success!
|
||||||
context.warp_to_slot(expected_slot).unwrap();
|
context.warp_to_slot(expected_slot).unwrap();
|
||||||
let instruction = Instruction::new(
|
let instruction = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&expected_slot,
|
&expected_slot,
|
||||||
vec![AccountMeta::new_readonly(clock::id(), false)],
|
vec![AccountMeta::new_readonly(clock::id(), false)],
|
||||||
|
|
|
@ -175,7 +175,7 @@ fn bench_program_execute_noop(bencher: &mut Bencher) {
|
||||||
let mint_pubkey = mint_keypair.pubkey();
|
let mint_pubkey = mint_keypair.pubkey();
|
||||||
let account_metas = vec![AccountMeta::new(mint_pubkey, true)];
|
let account_metas = vec![AccountMeta::new(mint_pubkey, true)];
|
||||||
|
|
||||||
let instruction = Instruction::new(invoke_program_id, &[u8::MAX, 0, 0, 0], account_metas);
|
let instruction = Instruction::new_with_bincode(invoke_program_id, &[u8::MAX, 0, 0, 0], account_metas);
|
||||||
let message = Message::new(&[instruction], Some(&mint_pubkey));
|
let message = Message::new(&[instruction], Some(&mint_pubkey));
|
||||||
|
|
||||||
bank_client
|
bank_client
|
||||||
|
|
|
@ -17,7 +17,7 @@ fn process_instruction(
|
||||||
) -> ProgramResult {
|
) -> ProgramResult {
|
||||||
if instruction_data.len() == 32 {
|
if instruction_data.len() == 32 {
|
||||||
let key = Pubkey::new_from_array(instruction_data.try_into().unwrap());
|
let key = Pubkey::new_from_array(instruction_data.try_into().unwrap());
|
||||||
let ix = Instruction::new(key, &[2], vec![]);
|
let ix = Instruction::new_with_bincode(key, &[2], vec![]);
|
||||||
let mut lamports = accounts[0].lamports();
|
let mut lamports = accounts[0].lamports();
|
||||||
let owner = &accounts[0].owner;
|
let owner = &accounts[0].owner;
|
||||||
let mut data = accounts[0].try_borrow_mut_data()?;
|
let mut data = accounts[0].try_borrow_mut_data()?;
|
||||||
|
@ -36,7 +36,7 @@ fn process_instruction(
|
||||||
} else {
|
} else {
|
||||||
match instruction_data[0] {
|
match instruction_data[0] {
|
||||||
1 => {
|
1 => {
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
*program_id,
|
*program_id,
|
||||||
&accounts[1].key.to_bytes(),
|
&accounts[1].key.to_bytes(),
|
||||||
vec![AccountMeta::new_readonly(*program_id, false)],
|
vec![AccountMeta::new_readonly(*program_id, false)],
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn process_instruction(
|
||||||
AccountMeta::new(*target.key, false),
|
AccountMeta::new(*target.key, false),
|
||||||
AccountMeta::new(*me.key, false),
|
AccountMeta::new(*me.key, false),
|
||||||
];
|
];
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::Transfer { lamports: 1 },
|
&SystemInstruction::Transfer { lamports: 1 },
|
||||||
account_metas,
|
account_metas,
|
||||||
|
|
|
@ -465,7 +465,7 @@ fn test_program_bpf_sanity() {
|
||||||
AccountMeta::new(stake_history::id(), false),
|
AccountMeta::new(stake_history::id(), false),
|
||||||
AccountMeta::new(rent::id(), false),
|
AccountMeta::new(rent::id(), false),
|
||||||
];
|
];
|
||||||
let instruction = Instruction::new(program_id, &1u8, account_metas);
|
let instruction = Instruction::new_with_bytes(program_id, &[1], account_metas);
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
if program.1 {
|
if program.1 {
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
@ -510,7 +510,7 @@ fn test_program_bpf_loader_deprecated() {
|
||||||
program,
|
program,
|
||||||
);
|
);
|
||||||
let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)];
|
let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)];
|
||||||
let instruction = Instruction::new(program_id, &1u8, account_metas);
|
let instruction = Instruction::new_with_bytes(program_id, &[1], account_metas);
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
|
@ -558,42 +558,42 @@ fn test_program_bpf_duplicate_accounts() {
|
||||||
];
|
];
|
||||||
|
|
||||||
bank.store_account(&pubkey, &account);
|
bank.store_account(&pubkey, &account);
|
||||||
let instruction = Instruction::new(program_id, &1u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[1], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
|
let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
assert_eq!(data[0], 1);
|
assert_eq!(data[0], 1);
|
||||||
|
|
||||||
bank.store_account(&pubkey, &account);
|
bank.store_account(&pubkey, &account);
|
||||||
let instruction = Instruction::new(program_id, &2u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[2], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
|
let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
assert_eq!(data[0], 2);
|
assert_eq!(data[0], 2);
|
||||||
|
|
||||||
bank.store_account(&pubkey, &account);
|
bank.store_account(&pubkey, &account);
|
||||||
let instruction = Instruction::new(program_id, &3u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[3], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
|
let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
assert_eq!(data[0], 3);
|
assert_eq!(data[0], 3);
|
||||||
|
|
||||||
bank.store_account(&pubkey, &account);
|
bank.store_account(&pubkey, &account);
|
||||||
let instruction = Instruction::new(program_id, &4u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[4], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let lamports = bank_client.get_balance(&pubkey).unwrap();
|
let lamports = bank_client.get_balance(&pubkey).unwrap();
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
assert_eq!(lamports, 11);
|
assert_eq!(lamports, 11);
|
||||||
|
|
||||||
bank.store_account(&pubkey, &account);
|
bank.store_account(&pubkey, &account);
|
||||||
let instruction = Instruction::new(program_id, &5u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[5], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let lamports = bank_client.get_balance(&pubkey).unwrap();
|
let lamports = bank_client.get_balance(&pubkey).unwrap();
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
assert_eq!(lamports, 12);
|
assert_eq!(lamports, 12);
|
||||||
|
|
||||||
bank.store_account(&pubkey, &account);
|
bank.store_account(&pubkey, &account);
|
||||||
let instruction = Instruction::new(program_id, &6u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[6], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let lamports = bank_client.get_balance(&pubkey).unwrap();
|
let lamports = bank_client.get_balance(&pubkey).unwrap();
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
@ -630,32 +630,32 @@ fn test_program_bpf_error_handling() {
|
||||||
let program_id = load_bpf_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
let program_id = load_bpf_program(&bank_client, &bpf_loader::id(), &mint_keypair, program);
|
||||||
let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)];
|
let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)];
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &1u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[1], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &2u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[2], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
TransactionError::InstructionError(0, InstructionError::InvalidAccountData)
|
TransactionError::InstructionError(0, InstructionError::InvalidAccountData)
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &3u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[3], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
TransactionError::InstructionError(0, InstructionError::Custom(0))
|
TransactionError::InstructionError(0, InstructionError::Custom(0))
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &4u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[4], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
TransactionError::InstructionError(0, InstructionError::Custom(42))
|
TransactionError::InstructionError(0, InstructionError::Custom(42))
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &5u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[5], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let result = result.unwrap_err().unwrap();
|
let result = result.unwrap_err().unwrap();
|
||||||
if TransactionError::InstructionError(0, InstructionError::InvalidInstructionData) != result
|
if TransactionError::InstructionError(0, InstructionError::InvalidInstructionData) != result
|
||||||
|
@ -666,7 +666,7 @@ fn test_program_bpf_error_handling() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &6u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[6], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let result = result.unwrap_err().unwrap();
|
let result = result.unwrap_err().unwrap();
|
||||||
if TransactionError::InstructionError(0, InstructionError::InvalidInstructionData) != result
|
if TransactionError::InstructionError(0, InstructionError::InvalidInstructionData) != result
|
||||||
|
@ -677,7 +677,7 @@ fn test_program_bpf_error_handling() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &7u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[7], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
let result = result.unwrap_err().unwrap();
|
let result = result.unwrap_err().unwrap();
|
||||||
if TransactionError::InstructionError(0, InstructionError::InvalidInstructionData) != result
|
if TransactionError::InstructionError(0, InstructionError::InvalidInstructionData) != result
|
||||||
|
@ -688,14 +688,14 @@ fn test_program_bpf_error_handling() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &8u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[8], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
TransactionError::InstructionError(0, InstructionError::InvalidInstructionData)
|
TransactionError::InstructionError(0, InstructionError::InvalidInstructionData)
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(program_id, &9u8, account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_id, &[9], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
|
@ -800,12 +800,12 @@ fn test_program_bpf_invoke_sanity() {
|
||||||
|
|
||||||
// success cases
|
// success cases
|
||||||
|
|
||||||
let instruction = Instruction::new(
|
let instruction = Instruction::new_with_bytes(
|
||||||
invoke_program_id,
|
invoke_program_id,
|
||||||
&[TEST_SUCCESS, bump_seed1, bump_seed2, bump_seed3],
|
&[TEST_SUCCESS, bump_seed1, bump_seed2, bump_seed3],
|
||||||
account_metas.clone(),
|
account_metas.clone(),
|
||||||
);
|
);
|
||||||
let noop_instruction = Instruction::new(noop_program_id, &(), vec![]);
|
let noop_instruction = Instruction::new_with_bytes(noop_program_id, &[], vec![]);
|
||||||
let message = Message::new(&[instruction, noop_instruction], Some(&mint_pubkey));
|
let message = Message::new(&[instruction, noop_instruction], Some(&mint_pubkey));
|
||||||
let tx = Transaction::new(
|
let tx = Transaction::new(
|
||||||
&[
|
&[
|
||||||
|
@ -880,7 +880,7 @@ fn test_program_bpf_invoke_sanity() {
|
||||||
&from_keypair,
|
&from_keypair,
|
||||||
];
|
];
|
||||||
let instruction =
|
let instruction =
|
||||||
Instruction::new(invoke_program_id, instruction_data, account_metas.clone());
|
Instruction::new_with_bytes(invoke_program_id, instruction_data, account_metas.clone());
|
||||||
let message = Message::new(&[instruction], Some(&mint_pubkey));
|
let message = Message::new(&[instruction], Some(&mint_pubkey));
|
||||||
let tx = Transaction::new(&signers, message.clone(), bank.last_blockhash());
|
let tx = Transaction::new(&signers, message.clone(), bank.last_blockhash());
|
||||||
let (result, inner_instructions) = process_transaction_and_record_inner(&bank, tx);
|
let (result, inner_instructions) = process_transaction_and_record_inner(&bank, tx);
|
||||||
|
@ -981,7 +981,7 @@ fn test_program_bpf_invoke_sanity() {
|
||||||
let account = Account::new(84, 0, &solana_sdk::system_program::id());
|
let account = Account::new(84, 0, &solana_sdk::system_program::id());
|
||||||
bank.store_account(&from_keypair.pubkey(), &account);
|
bank.store_account(&from_keypair.pubkey(), &account);
|
||||||
bank.store_account(&derived_key1, &Account::default());
|
bank.store_account(&derived_key1, &Account::default());
|
||||||
let instruction = Instruction::new(
|
let instruction = Instruction::new_with_bytes(
|
||||||
invoke_program_id,
|
invoke_program_id,
|
||||||
&[
|
&[
|
||||||
TEST_ALLOC_ACCESS_VIOLATION,
|
TEST_ALLOC_ACCESS_VIOLATION,
|
||||||
|
@ -1057,7 +1057,7 @@ fn test_program_bpf_program_id_spoofing() {
|
||||||
AccountMeta::new(to_pubkey, false),
|
AccountMeta::new(to_pubkey, false),
|
||||||
];
|
];
|
||||||
|
|
||||||
let instruction = Instruction::new(malicious_swap_pubkey, &(), account_metas.clone());
|
let instruction = Instruction::new_with_bytes(malicious_swap_pubkey, &[], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
|
@ -1097,7 +1097,7 @@ fn test_program_bpf_caller_has_access_to_cpi_program() {
|
||||||
AccountMeta::new_readonly(caller_pubkey, false),
|
AccountMeta::new_readonly(caller_pubkey, false),
|
||||||
AccountMeta::new_readonly(caller2_pubkey, false),
|
AccountMeta::new_readonly(caller2_pubkey, false),
|
||||||
];
|
];
|
||||||
let instruction = Instruction::new(caller_pubkey, &[1_u8], account_metas.clone());
|
let instruction = Instruction::new_with_bytes(caller_pubkey, &[1], account_metas.clone());
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
|
@ -1137,7 +1137,7 @@ fn test_program_bpf_ro_modify() {
|
||||||
AccountMeta::new(test_keypair.pubkey(), true),
|
AccountMeta::new(test_keypair.pubkey(), true),
|
||||||
];
|
];
|
||||||
|
|
||||||
let instruction = Instruction::new(program_pubkey, &[1_u8], account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_pubkey, &[1], account_metas.clone());
|
||||||
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
||||||
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
|
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1145,7 +1145,7 @@ fn test_program_bpf_ro_modify() {
|
||||||
TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete)
|
TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete)
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(program_pubkey, &[3_u8], account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_pubkey, &[3], account_metas.clone());
|
||||||
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
||||||
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
|
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1153,7 +1153,7 @@ fn test_program_bpf_ro_modify() {
|
||||||
TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete)
|
TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete)
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(program_pubkey, &[4_u8], account_metas.clone());
|
let instruction = Instruction::new_with_bytes(program_pubkey, &[4], account_metas.clone());
|
||||||
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
||||||
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
|
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1187,7 +1187,7 @@ fn test_program_bpf_call_depth() {
|
||||||
"solana_bpf_rust_call_depth",
|
"solana_bpf_rust_call_depth",
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(
|
let instruction = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&(BpfComputeBudget::default().max_call_depth - 1),
|
&(BpfComputeBudget::default().max_call_depth - 1),
|
||||||
vec![],
|
vec![],
|
||||||
|
@ -1195,7 +1195,7 @@ fn test_program_bpf_call_depth() {
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
||||||
let instruction = Instruction::new(
|
let instruction = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&BpfComputeBudget::default().max_call_depth,
|
&BpfComputeBudget::default().max_call_depth,
|
||||||
vec![],
|
vec![],
|
||||||
|
@ -1279,9 +1279,9 @@ fn test_program_bpf_instruction_introspection() {
|
||||||
solana_sdk::sysvar::instructions::id(),
|
solana_sdk::sysvar::instructions::id(),
|
||||||
false,
|
false,
|
||||||
)];
|
)];
|
||||||
let instruction0 = Instruction::new(program_id, &[0u8, 0u8], account_metas.clone());
|
let instruction0 = Instruction::new_with_bytes(program_id, &[0u8, 0u8], account_metas.clone());
|
||||||
let instruction1 = Instruction::new(program_id, &[0u8, 1u8], account_metas.clone());
|
let instruction1 = Instruction::new_with_bytes(program_id, &[0u8, 1u8], account_metas.clone());
|
||||||
let instruction2 = Instruction::new(program_id, &[0u8, 2u8], account_metas);
|
let instruction2 = Instruction::new_with_bytes(program_id, &[0u8, 2u8], account_metas);
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[instruction0, instruction1, instruction2],
|
&[instruction0, instruction1, instruction2],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
|
@ -1294,7 +1294,7 @@ fn test_program_bpf_instruction_introspection() {
|
||||||
solana_sdk::sysvar::instructions::id(),
|
solana_sdk::sysvar::instructions::id(),
|
||||||
false,
|
false,
|
||||||
)];
|
)];
|
||||||
let instruction = Instruction::new(program_id, &0u8, account_metas);
|
let instruction = Instruction::new_with_bytes(program_id, &[0], account_metas);
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
|
@ -1302,7 +1302,7 @@ fn test_program_bpf_instruction_introspection() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// No accounts, should error
|
// No accounts, should error
|
||||||
let instruction = Instruction::new(program_id, &0u8, vec![]);
|
let instruction = Instruction::new_with_bytes(program_id, &[0], vec![]);
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1369,7 +1369,7 @@ fn test_program_bpf_test_use_latest_executor() {
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[
|
&[
|
||||||
loader_instruction::finalize(&program_keypair.pubkey(), &bpf_loader::id()),
|
loader_instruction::finalize(&program_keypair.pubkey(), &bpf_loader::id()),
|
||||||
Instruction::new(panic_id, &0u8, vec![]),
|
Instruction::new_with_bytes(panic_id, &[0], vec![]),
|
||||||
],
|
],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
);
|
);
|
||||||
|
@ -1401,7 +1401,7 @@ fn test_program_bpf_test_use_latest_executor() {
|
||||||
|
|
||||||
// Call the noop program, should get noop not panic
|
// Call the noop program, should get noop not panic
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(program_keypair.pubkey(), &0u8, vec![])],
|
&[Instruction::new_with_bytes(program_keypair.pubkey(), &[0], vec![])],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
);
|
);
|
||||||
assert!(bank_client
|
assert!(bank_client
|
||||||
|
@ -1491,7 +1491,7 @@ fn test_program_bpf_test_use_latest_executor2() {
|
||||||
|
|
||||||
// invoke program, verify not found
|
// invoke program, verify not found
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(program_keypair.pubkey(), &0u8, vec![])],
|
&[Instruction::new_with_bytes(program_keypair.pubkey(), &[0], vec![])],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1526,7 +1526,7 @@ fn test_program_bpf_test_use_latest_executor2() {
|
||||||
|
|
||||||
// Call the program, should get noop, not panic
|
// Call the program, should get noop, not panic
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(program_keypair.pubkey(), &0u8, vec![])],
|
&[Instruction::new_with_bytes(program_keypair.pubkey(), &[0], vec![])],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
);
|
);
|
||||||
assert!(bank_client
|
assert!(bank_client
|
||||||
|
@ -1563,7 +1563,7 @@ fn test_program_bpf_upgrade() {
|
||||||
"solana_bpf_rust_upgradeable",
|
"solana_bpf_rust_upgradeable",
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut instruction = Instruction::new(
|
let mut instruction = Instruction::new_with_bytes(
|
||||||
program_id,
|
program_id,
|
||||||
&[0],
|
&[0],
|
||||||
vec![
|
vec![
|
||||||
|
@ -1659,7 +1659,7 @@ fn test_program_bpf_upgrade_and_invoke_in_same_tx() {
|
||||||
"solana_bpf_rust_noop",
|
"solana_bpf_rust_noop",
|
||||||
);
|
);
|
||||||
|
|
||||||
let invoke_instruction = Instruction::new(
|
let invoke_instruction = Instruction::new_with_bytes(
|
||||||
program_id,
|
program_id,
|
||||||
&[0],
|
&[0],
|
||||||
vec![
|
vec![
|
||||||
|
@ -1747,7 +1747,7 @@ fn test_program_bpf_invoke_upgradeable_via_cpi() {
|
||||||
"solana_bpf_rust_upgradeable",
|
"solana_bpf_rust_upgradeable",
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut instruction = Instruction::new(
|
let mut instruction = Instruction::new_with_bytes(
|
||||||
invoke_and_return,
|
invoke_and_return,
|
||||||
&[0],
|
&[0],
|
||||||
vec![
|
vec![
|
||||||
|
@ -1848,7 +1848,7 @@ fn test_program_bpf_disguised_as_bpf_loader() {
|
||||||
program,
|
program,
|
||||||
);
|
);
|
||||||
let account_metas = vec![AccountMeta::new_readonly(program_id, false)];
|
let account_metas = vec![AccountMeta::new_readonly(program_id, false)];
|
||||||
let instruction = Instruction::new(bpf_loader_deprecated::id(), &1u8, account_metas);
|
let instruction = Instruction::new_with_bytes(bpf_loader_deprecated::id(), &[1], account_metas);
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().unwrap(),
|
result.unwrap_err().unwrap(),
|
||||||
|
@ -1894,7 +1894,7 @@ fn test_program_bpf_upgrade_via_cpi() {
|
||||||
"solana_bpf_rust_upgradeable",
|
"solana_bpf_rust_upgradeable",
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut instruction = Instruction::new(
|
let mut instruction = Instruction::new_with_bytes(
|
||||||
invoke_and_return,
|
invoke_and_return,
|
||||||
&[0],
|
&[0],
|
||||||
vec![
|
vec![
|
||||||
|
@ -1992,7 +1992,7 @@ fn test_program_bpf_upgrade_self_via_cpi() {
|
||||||
"solana_bpf_rust_invoke_and_return",
|
"solana_bpf_rust_invoke_and_return",
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut invoke_instruction = Instruction::new(
|
let mut invoke_instruction = Instruction::new_with_bytes(
|
||||||
program_id,
|
program_id,
|
||||||
&[0],
|
&[0],
|
||||||
vec![
|
vec![
|
||||||
|
@ -2104,9 +2104,9 @@ fn test_program_upgradeable_locks() {
|
||||||
let invoke_tx = Transaction::new(
|
let invoke_tx = Transaction::new(
|
||||||
&[payer_keypair],
|
&[payer_keypair],
|
||||||
Message::new(
|
Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bytes(
|
||||||
program_keypair.pubkey(),
|
program_keypair.pubkey(),
|
||||||
&[0u8; 0],
|
&[0; 0],
|
||||||
vec![],
|
vec![],
|
||||||
)],
|
)],
|
||||||
Some(&payer_keypair.pubkey()),
|
Some(&payer_keypair.pubkey()),
|
||||||
|
@ -2208,7 +2208,7 @@ fn test_program_bpf_syscall_feature_activation() {
|
||||||
&mint_keypair,
|
&mint_keypair,
|
||||||
"solana_bpf_rust_noop",
|
"solana_bpf_rust_noop",
|
||||||
);
|
);
|
||||||
let instruction = Instruction::new(program_id, &0u8, vec![]);
|
let instruction = Instruction::new_with_bytes(program_id, &[0], vec![]);
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
||||||
|
@ -2217,7 +2217,7 @@ fn test_program_bpf_syscall_feature_activation() {
|
||||||
|
|
||||||
let bank = Arc::new(bank);
|
let bank = Arc::new(bank);
|
||||||
let bank_client = BankClient::new_shared(&bank);
|
let bank_client = BankClient::new_shared(&bank);
|
||||||
let instruction = Instruction::new(program_id, &1u8, vec![]);
|
let instruction = Instruction::new_with_bytes(program_id, &[1], vec![]);
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
println!("result: {:?}", result);
|
println!("result: {:?}", result);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
|
@ -1654,7 +1654,7 @@ mod tests {
|
||||||
bank.clear_signatures();
|
bank.clear_signatures();
|
||||||
bank.store_account(&buffer_address, &buffer_account);
|
bank.store_account(&buffer_address, &buffer_account);
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
bpf_loader_upgradeable::id(),
|
bpf_loader_upgradeable::id(),
|
||||||
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
|
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
|
||||||
max_data_len: elf.len(),
|
max_data_len: elf.len(),
|
||||||
|
@ -1713,7 +1713,7 @@ mod tests {
|
||||||
bank.store_account(&program_keypair.pubkey(), &program_account);
|
bank.store_account(&program_keypair.pubkey(), &program_account);
|
||||||
bank.store_account(&programdata_address, &programdata_account);
|
bank.store_account(&programdata_address, &programdata_account);
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
bpf_loader_upgradeable::id(),
|
bpf_loader_upgradeable::id(),
|
||||||
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
|
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
|
||||||
max_data_len: elf.len(),
|
max_data_len: elf.len(),
|
||||||
|
@ -1744,7 +1744,7 @@ mod tests {
|
||||||
bank.store_account(&program_keypair.pubkey(), &program_account);
|
bank.store_account(&program_keypair.pubkey(), &program_account);
|
||||||
bank.store_account(&programdata_address, &programdata_account);
|
bank.store_account(&programdata_address, &programdata_account);
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
bpf_loader_upgradeable::id(),
|
bpf_loader_upgradeable::id(),
|
||||||
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
|
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
|
||||||
max_data_len: elf.len(),
|
max_data_len: elf.len(),
|
||||||
|
|
|
@ -1793,7 +1793,7 @@ mod tests {
|
||||||
assert_eq!(pubkey, *translated_pubkey);
|
assert_eq!(pubkey, *translated_pubkey);
|
||||||
|
|
||||||
// Instruction
|
// Instruction
|
||||||
let instruction = Instruction::new(
|
let instruction = Instruction::new_with_bincode(
|
||||||
solana_sdk::pubkey::new_rand(),
|
solana_sdk::pubkey::new_rand(),
|
||||||
&"foobar",
|
&"foobar",
|
||||||
vec![AccountMeta::new(solana_sdk::pubkey::new_rand(), false)],
|
vec![AccountMeta::new(solana_sdk::pubkey::new_rand(), false)],
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn initialize_account(contract: &Pubkey, expr: BudgetExpr) -> Instruction {
|
||||||
keys.push(AccountMeta::new(payment.to, false));
|
keys.push(AccountMeta::new(payment.to, false));
|
||||||
}
|
}
|
||||||
keys.push(AccountMeta::new(*contract, false));
|
keys.push(AccountMeta::new(*contract, false));
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&BudgetInstruction::InitializeAccount(Box::new(expr)),
|
&BudgetInstruction::InitializeAccount(Box::new(expr)),
|
||||||
keys,
|
keys,
|
||||||
|
@ -136,7 +136,7 @@ pub fn apply_timestamp(
|
||||||
if from != to {
|
if from != to {
|
||||||
account_metas.push(AccountMeta::new(*to, false));
|
account_metas.push(AccountMeta::new(*to, false));
|
||||||
}
|
}
|
||||||
Instruction::new(id(), &BudgetInstruction::ApplyTimestamp(dt), account_metas)
|
Instruction::new_with_bincode(id(), &BudgetInstruction::ApplyTimestamp(dt), account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_signature(from: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruction {
|
pub fn apply_signature(from: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruction {
|
||||||
|
@ -147,7 +147,7 @@ pub fn apply_signature(from: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruc
|
||||||
if from != to {
|
if from != to {
|
||||||
account_metas.push(AccountMeta::new(*to, false));
|
account_metas.push(AccountMeta::new(*to, false));
|
||||||
}
|
}
|
||||||
Instruction::new(id(), &BudgetInstruction::ApplySignature, account_metas)
|
Instruction::new_with_bincode(id(), &BudgetInstruction::ApplySignature, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Apply account data to a contract waiting on an AccountData witness.
|
/// Apply account data to a contract waiting on an AccountData witness.
|
||||||
|
@ -157,7 +157,7 @@ pub fn apply_account_data(witness_pubkey: &Pubkey, contract: &Pubkey, to: &Pubke
|
||||||
AccountMeta::new(*contract, false),
|
AccountMeta::new(*contract, false),
|
||||||
AccountMeta::new(*to, false),
|
AccountMeta::new(*to, false),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &BudgetInstruction::ApplyAccountData, account_metas)
|
Instruction::new_with_bincode(id(), &BudgetInstruction::ApplyAccountData, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -9,7 +9,7 @@ use solana_sdk::{
|
||||||
fn initialize_account<T: ConfigState>(config_pubkey: &Pubkey) -> Instruction {
|
fn initialize_account<T: ConfigState>(config_pubkey: &Pubkey) -> Instruction {
|
||||||
let account_metas = vec![AccountMeta::new(*config_pubkey, true)];
|
let account_metas = vec![AccountMeta::new(*config_pubkey, true)];
|
||||||
let account_data = (ConfigKeys { keys: vec![] }, T::default());
|
let account_data = (ConfigKeys { keys: vec![] }, T::default());
|
||||||
Instruction::new(id(), &account_data, account_metas)
|
Instruction::new_with_bincode(id(), &account_data, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new, empty configuration account
|
/// Create a new, empty configuration account
|
||||||
|
@ -46,5 +46,5 @@ pub fn store<T: ConfigState>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let account_data = (ConfigKeys { keys }, data);
|
let account_data = (ConfigKeys { keys }, data);
|
||||||
Instruction::new(id(), &account_data, account_metas)
|
Instruction::new_with_bincode(id(), &account_data, account_metas)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub fn account_request(owner: &Pubkey, new: &Pubkey) -> Instruction {
|
||||||
AccountMeta::new(*owner, true),
|
AccountMeta::new(*owner, true),
|
||||||
AccountMeta::new(*new, false),
|
AccountMeta::new(*new, false),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &ExchangeInstruction::AccountRequest, account_metas)
|
Instruction::new_with_bincode(id(), &ExchangeInstruction::AccountRequest, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn transfer_request(
|
pub fn transfer_request(
|
||||||
|
@ -74,7 +74,7 @@ pub fn transfer_request(
|
||||||
AccountMeta::new(*to, false),
|
AccountMeta::new(*to, false),
|
||||||
AccountMeta::new(*from, false),
|
AccountMeta::new(*from, false),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&ExchangeInstruction::TransferRequest(token, tokens),
|
&ExchangeInstruction::TransferRequest(token, tokens),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -95,7 +95,7 @@ pub fn trade_request(
|
||||||
AccountMeta::new(*trade, false),
|
AccountMeta::new(*trade, false),
|
||||||
AccountMeta::new(*src_account, false),
|
AccountMeta::new(*src_account, false),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&ExchangeInstruction::OrderRequest(OrderRequestInfo {
|
&ExchangeInstruction::OrderRequest(OrderRequestInfo {
|
||||||
side,
|
side,
|
||||||
|
@ -112,7 +112,7 @@ pub fn order_cancellation(owner: &Pubkey, order: &Pubkey) -> Instruction {
|
||||||
AccountMeta::new(*owner, true),
|
AccountMeta::new(*owner, true),
|
||||||
AccountMeta::new(*order, false),
|
AccountMeta::new(*order, false),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &ExchangeInstruction::OrderCancellation, account_metas)
|
Instruction::new_with_bincode(id(), &ExchangeInstruction::OrderCancellation, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn swap_request(
|
pub fn swap_request(
|
||||||
|
@ -127,5 +127,5 @@ pub fn swap_request(
|
||||||
AccountMeta::new(*from_trade, false),
|
AccountMeta::new(*from_trade, false),
|
||||||
AccountMeta::new(*profit_account, false),
|
AccountMeta::new(*profit_account, false),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &ExchangeInstruction::SwapRequest, account_metas)
|
Instruction::new_with_bincode(id(), &ExchangeInstruction::SwapRequest, account_metas)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl<T> DecodeError<T> for OwnableError {
|
||||||
|
|
||||||
fn initialize_account(account_pubkey: &Pubkey, owner_pubkey: &Pubkey) -> Instruction {
|
fn initialize_account(account_pubkey: &Pubkey, owner_pubkey: &Pubkey) -> Instruction {
|
||||||
let keys = vec![AccountMeta::new(*account_pubkey, false)];
|
let keys = vec![AccountMeta::new(*account_pubkey, false)];
|
||||||
Instruction::new(crate::id(), &owner_pubkey, keys)
|
Instruction::new_with_bincode(crate::id(), &owner_pubkey, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_account(
|
pub fn create_account(
|
||||||
|
@ -48,5 +48,5 @@ pub fn set_owner(account_pubkey: &Pubkey, old_pubkey: &Pubkey, new_pubkey: &Pubk
|
||||||
AccountMeta::new(*account_pubkey, false),
|
AccountMeta::new(*account_pubkey, false),
|
||||||
AccountMeta::new(*old_pubkey, true),
|
AccountMeta::new(*old_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(crate::id(), &new_pubkey, keys)
|
Instruction::new_with_bincode(crate::id(), &new_pubkey, keys)
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ pub struct AuthorizeWithSeedArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(stake_pubkey: &Pubkey, authorized: &Authorized, lockup: &Lockup) -> Instruction {
|
fn initialize(stake_pubkey: &Pubkey, authorized: &Authorized, lockup: &Lockup) -> Instruction {
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&StakeInstruction::Initialize(*authorized, *lockup),
|
&StakeInstruction::Initialize(*authorized, *lockup),
|
||||||
vec![
|
vec![
|
||||||
|
@ -248,7 +248,7 @@ fn _split(
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(id(), &StakeInstruction::Split(lamports), account_metas)
|
Instruction::new_with_bincode(id(), &StakeInstruction::Split(lamports), account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split(
|
pub fn split(
|
||||||
|
@ -314,7 +314,7 @@ pub fn merge(
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
vec![Instruction::new(
|
vec![Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&StakeInstruction::Merge,
|
&StakeInstruction::Merge,
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -382,7 +382,7 @@ pub fn authorize(
|
||||||
account_metas.push(AccountMeta::new_readonly(*custodian_pubkey, true));
|
account_metas.push(AccountMeta::new_readonly(*custodian_pubkey, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&StakeInstruction::Authorize(*new_authorized_pubkey, stake_authorize),
|
&StakeInstruction::Authorize(*new_authorized_pubkey, stake_authorize),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -415,7 +415,7 @@ pub fn authorize_with_seed(
|
||||||
authority_owner: *authority_owner,
|
authority_owner: *authority_owner,
|
||||||
};
|
};
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&StakeInstruction::AuthorizeWithSeed(args),
|
&StakeInstruction::AuthorizeWithSeed(args),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -435,7 +435,7 @@ pub fn delegate_stake(
|
||||||
AccountMeta::new_readonly(crate::config::id(), false),
|
AccountMeta::new_readonly(crate::config::id(), false),
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &StakeInstruction::DelegateStake, account_metas)
|
Instruction::new_with_bincode(id(), &StakeInstruction::DelegateStake, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn withdraw(
|
pub fn withdraw(
|
||||||
|
@ -457,7 +457,7 @@ pub fn withdraw(
|
||||||
account_metas.push(AccountMeta::new_readonly(*custodian_pubkey, true));
|
account_metas.push(AccountMeta::new_readonly(*custodian_pubkey, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction::new(id(), &StakeInstruction::Withdraw(lamports), account_metas)
|
Instruction::new_with_bincode(id(), &StakeInstruction::Withdraw(lamports), account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deactivate_stake(stake_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> Instruction {
|
pub fn deactivate_stake(stake_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> Instruction {
|
||||||
|
@ -466,7 +466,7 @@ pub fn deactivate_stake(stake_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> In
|
||||||
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &StakeInstruction::Deactivate, account_metas)
|
Instruction::new_with_bincode(id(), &StakeInstruction::Deactivate, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_lockup(
|
pub fn set_lockup(
|
||||||
|
@ -478,7 +478,7 @@ pub fn set_lockup(
|
||||||
AccountMeta::new(*stake_pubkey, false),
|
AccountMeta::new(*stake_pubkey, false),
|
||||||
AccountMeta::new_readonly(*custodian_pubkey, true),
|
AccountMeta::new_readonly(*custodian_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &StakeInstruction::SetLockup(*lockup), account_metas)
|
Instruction::new_with_bincode(id(), &StakeInstruction::SetLockup(*lockup), account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_instruction(
|
pub fn process_instruction(
|
||||||
|
|
|
@ -75,7 +75,7 @@ fn initialize_account(
|
||||||
total_lamports: u64,
|
total_lamports: u64,
|
||||||
) -> Instruction {
|
) -> Instruction {
|
||||||
let keys = vec![AccountMeta::new(*contract_pubkey, false)];
|
let keys = vec![AccountMeta::new(*contract_pubkey, false)];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&VestInstruction::InitializeAccount {
|
&VestInstruction::InitializeAccount {
|
||||||
terminator_pubkey: *terminator_pubkey,
|
terminator_pubkey: *terminator_pubkey,
|
||||||
|
@ -116,7 +116,7 @@ pub fn set_terminator(contract: &Pubkey, old_pubkey: &Pubkey, new_pubkey: &Pubke
|
||||||
AccountMeta::new(*contract, false),
|
AccountMeta::new(*contract, false),
|
||||||
AccountMeta::new(*old_pubkey, true),
|
AccountMeta::new(*old_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&VestInstruction::SetTerminator(*new_pubkey),
|
&VestInstruction::SetTerminator(*new_pubkey),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -128,7 +128,7 @@ pub fn set_payee(contract: &Pubkey, old_pubkey: &Pubkey, new_pubkey: &Pubkey) ->
|
||||||
AccountMeta::new(*contract, false),
|
AccountMeta::new(*contract, false),
|
||||||
AccountMeta::new(*old_pubkey, true),
|
AccountMeta::new(*old_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &VestInstruction::SetPayee(*new_pubkey), account_metas)
|
Instruction::new_with_bincode(id(), &VestInstruction::SetPayee(*new_pubkey), account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn redeem_tokens(contract: &Pubkey, date_pubkey: &Pubkey, to: &Pubkey) -> Instruction {
|
pub fn redeem_tokens(contract: &Pubkey, date_pubkey: &Pubkey, to: &Pubkey) -> Instruction {
|
||||||
|
@ -137,7 +137,7 @@ pub fn redeem_tokens(contract: &Pubkey, date_pubkey: &Pubkey, to: &Pubkey) -> In
|
||||||
AccountMeta::new_readonly(*date_pubkey, false),
|
AccountMeta::new_readonly(*date_pubkey, false),
|
||||||
AccountMeta::new(*to, false),
|
AccountMeta::new(*to, false),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &VestInstruction::RedeemTokens, account_metas)
|
Instruction::new_with_bincode(id(), &VestInstruction::RedeemTokens, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn terminate(contract: &Pubkey, from: &Pubkey, to: &Pubkey) -> Instruction {
|
pub fn terminate(contract: &Pubkey, from: &Pubkey, to: &Pubkey) -> Instruction {
|
||||||
|
@ -148,7 +148,7 @@ pub fn terminate(contract: &Pubkey, from: &Pubkey, to: &Pubkey) -> Instruction {
|
||||||
if from != to {
|
if from != to {
|
||||||
account_metas.push(AccountMeta::new(*to, false));
|
account_metas.push(AccountMeta::new(*to, false));
|
||||||
}
|
}
|
||||||
Instruction::new(id(), &VestInstruction::Terminate, account_metas)
|
Instruction::new_with_bincode(id(), &VestInstruction::Terminate, account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn renege(contract: &Pubkey, from: &Pubkey, to: &Pubkey, lamports: u64) -> Instruction {
|
pub fn renege(contract: &Pubkey, from: &Pubkey, to: &Pubkey, lamports: u64) -> Instruction {
|
||||||
|
@ -159,7 +159,7 @@ pub fn renege(contract: &Pubkey, from: &Pubkey, to: &Pubkey, lamports: u64) -> I
|
||||||
if from != to {
|
if from != to {
|
||||||
account_metas.push(AccountMeta::new(*to, false));
|
account_metas.push(AccountMeta::new(*to, false));
|
||||||
}
|
}
|
||||||
Instruction::new(id(), &VestInstruction::Renege(lamports), account_metas)
|
Instruction::new_with_bincode(id(), &VestInstruction::Renege(lamports), account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vest_all(contract: &Pubkey, from: &Pubkey) -> Instruction {
|
pub fn vest_all(contract: &Pubkey, from: &Pubkey) -> Instruction {
|
||||||
|
@ -167,5 +167,5 @@ pub fn vest_all(contract: &Pubkey, from: &Pubkey) -> Instruction {
|
||||||
AccountMeta::new(*contract, false),
|
AccountMeta::new(*contract, false),
|
||||||
AccountMeta::new(*from, true),
|
AccountMeta::new(*from, true),
|
||||||
];
|
];
|
||||||
Instruction::new(id(), &VestInstruction::VestAll, account_metas)
|
Instruction::new_with_bincode(id(), &VestInstruction::VestAll, account_metas)
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ fn initialize_account(vote_pubkey: &Pubkey, vote_init: &VoteInit) -> Instruction
|
||||||
AccountMeta::new_readonly(vote_init.node_pubkey, true),
|
AccountMeta::new_readonly(vote_init.node_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&VoteInstruction::InitializeAccount(*vote_init),
|
&VoteInstruction::InitializeAccount(*vote_init),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -175,7 +175,7 @@ pub fn authorize(
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&VoteInstruction::Authorize(*new_authorized_pubkey, vote_authorize),
|
&VoteInstruction::Authorize(*new_authorized_pubkey, vote_authorize),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -193,7 +193,7 @@ pub fn update_validator_identity(
|
||||||
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
|
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&VoteInstruction::UpdateValidatorIdentity,
|
&VoteInstruction::UpdateValidatorIdentity,
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -210,7 +210,7 @@ pub fn update_commission(
|
||||||
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
|
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&VoteInstruction::UpdateCommission(commission),
|
&VoteInstruction::UpdateCommission(commission),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -225,7 +225,7 @@ pub fn vote(vote_pubkey: &Pubkey, authorized_voter_pubkey: &Pubkey, vote: Vote)
|
||||||
AccountMeta::new_readonly(*authorized_voter_pubkey, true),
|
AccountMeta::new_readonly(*authorized_voter_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(id(), &VoteInstruction::Vote(vote), account_metas)
|
Instruction::new_with_bincode(id(), &VoteInstruction::Vote(vote), account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vote_switch(
|
pub fn vote_switch(
|
||||||
|
@ -241,7 +241,7 @@ pub fn vote_switch(
|
||||||
AccountMeta::new_readonly(*authorized_voter_pubkey, true),
|
AccountMeta::new_readonly(*authorized_voter_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&VoteInstruction::VoteSwitch(vote, proof_hash),
|
&VoteInstruction::VoteSwitch(vote, proof_hash),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -260,7 +260,7 @@ pub fn withdraw(
|
||||||
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
|
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(id(), &VoteInstruction::Withdraw(lamports), account_metas)
|
Instruction::new_with_bincode(id(), &VoteInstruction::Withdraw(lamports), account_metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify_rent_exemption(
|
fn verify_rent_exemption(
|
||||||
|
|
|
@ -5386,8 +5386,11 @@ pub(crate) mod tests {
|
||||||
AccountMeta::new(keypair2.pubkey(), true),
|
AccountMeta::new(keypair2.pubkey(), true),
|
||||||
AccountMeta::new_readonly(read_only_keypair.pubkey(), false),
|
AccountMeta::new_readonly(read_only_keypair.pubkey(), false),
|
||||||
];
|
];
|
||||||
let deduct_instruction =
|
let deduct_instruction = Instruction::new_with_bincode(
|
||||||
Instruction::new(mock_program_id, &MockInstruction::Deduction, account_metas);
|
mock_program_id,
|
||||||
|
&MockInstruction::Deduction,
|
||||||
|
account_metas,
|
||||||
|
);
|
||||||
Transaction::new_signed_with_payer(
|
Transaction::new_signed_with_payer(
|
||||||
&[deduct_instruction],
|
&[deduct_instruction],
|
||||||
Some(&payer.pubkey()),
|
Some(&payer.pubkey()),
|
||||||
|
@ -9788,7 +9791,7 @@ pub(crate) mod tests {
|
||||||
AccountMeta::new(to_pubkey, false),
|
AccountMeta::new(to_pubkey, false),
|
||||||
AccountMeta::new(dup_pubkey, false),
|
AccountMeta::new(dup_pubkey, false),
|
||||||
];
|
];
|
||||||
let instruction = Instruction::new(mock_program_id, &10, account_metas);
|
let instruction = Instruction::new_with_bincode(mock_program_id, &10, account_metas);
|
||||||
let tx = Transaction::new_signed_with_payer(
|
let tx = Transaction::new_signed_with_payer(
|
||||||
&[instruction],
|
&[instruction],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
|
@ -9834,7 +9837,7 @@ pub(crate) mod tests {
|
||||||
AccountMeta::new(dup_pubkey, false),
|
AccountMeta::new(dup_pubkey, false),
|
||||||
AccountMeta::new(mock_program_id, false),
|
AccountMeta::new(mock_program_id, false),
|
||||||
];
|
];
|
||||||
let instruction = Instruction::new(mock_program_id, &10, account_metas);
|
let instruction = Instruction::new_with_bincode(mock_program_id, &10, account_metas);
|
||||||
let tx = Transaction::new_signed_with_payer(
|
let tx = Transaction::new_signed_with_payer(
|
||||||
&[instruction],
|
&[instruction],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
|
@ -9860,7 +9863,8 @@ pub(crate) mod tests {
|
||||||
AccountMeta::new(to_pubkey, false),
|
AccountMeta::new(to_pubkey, false),
|
||||||
];
|
];
|
||||||
|
|
||||||
let instruction = Instruction::new(solana_vote_program::id(), &10, account_metas);
|
let instruction =
|
||||||
|
Instruction::new_with_bincode(solana_vote_program::id(), &10, account_metas);
|
||||||
let mut tx = Transaction::new_signed_with_payer(
|
let mut tx = Transaction::new_signed_with_payer(
|
||||||
&[instruction],
|
&[instruction],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
|
@ -9930,7 +9934,8 @@ pub(crate) mod tests {
|
||||||
mock_ok_vote_processor,
|
mock_ok_vote_processor,
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(solana_vote_program::id(), &10, account_metas);
|
let instruction =
|
||||||
|
Instruction::new_with_bincode(solana_vote_program::id(), &10, account_metas);
|
||||||
let mut tx = Transaction::new_signed_with_payer(
|
let mut tx = Transaction::new_signed_with_payer(
|
||||||
&[instruction],
|
&[instruction],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
|
@ -9963,7 +9968,8 @@ pub(crate) mod tests {
|
||||||
mock_ok_vote_processor,
|
mock_ok_vote_processor,
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(solana_vote_program::id(), &10, account_metas);
|
let instruction =
|
||||||
|
Instruction::new_with_bincode(solana_vote_program::id(), &10, account_metas);
|
||||||
let mut tx = Transaction::new_signed_with_payer(
|
let mut tx = Transaction::new_signed_with_payer(
|
||||||
&[instruction],
|
&[instruction],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
|
@ -10020,7 +10026,8 @@ pub(crate) mod tests {
|
||||||
mock_ok_vote_processor,
|
mock_ok_vote_processor,
|
||||||
);
|
);
|
||||||
|
|
||||||
let instruction = Instruction::new(solana_vote_program::id(), &10, account_metas);
|
let instruction =
|
||||||
|
Instruction::new_with_bincode(solana_vote_program::id(), &10, account_metas);
|
||||||
let mut tx = Transaction::new_signed_with_payer(
|
let mut tx = Transaction::new_signed_with_payer(
|
||||||
&[instruction],
|
&[instruction],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
|
@ -10267,7 +10274,7 @@ pub(crate) mod tests {
|
||||||
program2_account.executable = true;
|
program2_account.executable = true;
|
||||||
bank.store_account(&program2_pubkey, &program2_account);
|
bank.store_account(&program2_pubkey, &program2_account);
|
||||||
|
|
||||||
let instruction = Instruction::new(program2_pubkey, &10, vec![]);
|
let instruction = Instruction::new_with_bincode(program2_pubkey, &10, vec![]);
|
||||||
let tx = Transaction::new_signed_with_payer(
|
let tx = Transaction::new_signed_with_payer(
|
||||||
&[instruction.clone(), instruction],
|
&[instruction.clone(), instruction],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
|
@ -11515,7 +11522,11 @@ pub(crate) mod tests {
|
||||||
let bank = Bank::new(&genesis_config);
|
let bank = Bank::new(&genesis_config);
|
||||||
|
|
||||||
let tx = Transaction::new_signed_with_payer(
|
let tx = Transaction::new_signed_with_payer(
|
||||||
&[Instruction::new(native_loader::id(), &(), vec![])],
|
&[Instruction::new_with_bincode(
|
||||||
|
native_loader::id(),
|
||||||
|
&(),
|
||||||
|
vec![],
|
||||||
|
)],
|
||||||
Some(&mint_keypair.pubkey()),
|
Some(&mint_keypair.pubkey()),
|
||||||
&[&mint_keypair],
|
&[&mint_keypair],
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
|
@ -11544,7 +11555,7 @@ pub(crate) mod tests {
|
||||||
0,
|
0,
|
||||||
&native_loader::id(),
|
&native_loader::id(),
|
||||||
),
|
),
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
native_loader::id(),
|
native_loader::id(),
|
||||||
&(),
|
&(),
|
||||||
vec![AccountMeta::new(to_keypair.pubkey(), false)],
|
vec![AccountMeta::new(to_keypair.pubkey(), false)],
|
||||||
|
@ -11571,7 +11582,7 @@ pub(crate) mod tests {
|
||||||
100,
|
100,
|
||||||
&native_loader::id(),
|
&native_loader::id(),
|
||||||
),
|
),
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
native_loader::id(),
|
native_loader::id(),
|
||||||
&(),
|
&(),
|
||||||
vec![AccountMeta::new(to_keypair.pubkey(), false)],
|
vec![AccountMeta::new(to_keypair.pubkey(), false)],
|
||||||
|
|
|
@ -199,5 +199,5 @@ pub fn create_invoke_instruction<T: Serialize>(
|
||||||
data: &T,
|
data: &T,
|
||||||
) -> Instruction {
|
) -> Instruction {
|
||||||
let account_metas = vec![AccountMeta::new(from_pubkey, true)];
|
let account_metas = vec![AccountMeta::new(from_pubkey, true)];
|
||||||
Instruction::new(program_id, data, account_metas)
|
Instruction::new_with_bincode(program_id, data, account_metas)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1170,7 +1170,11 @@ mod tests {
|
||||||
AccountMeta::new(keys[owned_index], false),
|
AccountMeta::new(keys[owned_index], false),
|
||||||
];
|
];
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(program_ids[owned_index], &[0_u8], metas)],
|
&[Instruction::new_with_bytes(
|
||||||
|
program_ids[owned_index],
|
||||||
|
&[0],
|
||||||
|
metas,
|
||||||
|
)],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1701,7 +1705,7 @@ mod tests {
|
||||||
AccountMeta::new_readonly(to_pubkey, false),
|
AccountMeta::new_readonly(to_pubkey, false),
|
||||||
];
|
];
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
mock_system_program_id,
|
mock_system_program_id,
|
||||||
&MockSystemInstruction::Correct,
|
&MockSystemInstruction::Correct,
|
||||||
account_metas.clone(),
|
account_metas.clone(),
|
||||||
|
@ -1727,7 +1731,7 @@ mod tests {
|
||||||
assert_eq!(accounts[1].borrow().lamports, 0);
|
assert_eq!(accounts[1].borrow().lamports, 0);
|
||||||
|
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
mock_system_program_id,
|
mock_system_program_id,
|
||||||
&MockSystemInstruction::AttemptCredit { lamports: 50 },
|
&MockSystemInstruction::AttemptCredit { lamports: 50 },
|
||||||
account_metas.clone(),
|
account_metas.clone(),
|
||||||
|
@ -1757,7 +1761,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
mock_system_program_id,
|
mock_system_program_id,
|
||||||
&MockSystemInstruction::AttemptDataChange { data: 50 },
|
&MockSystemInstruction::AttemptDataChange { data: 50 },
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -1872,7 +1876,7 @@ mod tests {
|
||||||
|
|
||||||
// Try to borrow mut the same account
|
// Try to borrow mut the same account
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
mock_program_id,
|
mock_program_id,
|
||||||
&MockSystemInstruction::BorrowFail,
|
&MockSystemInstruction::BorrowFail,
|
||||||
account_metas.clone(),
|
account_metas.clone(),
|
||||||
|
@ -1902,7 +1906,7 @@ mod tests {
|
||||||
|
|
||||||
// Try to borrow mut the same account in a safe way
|
// Try to borrow mut the same account in a safe way
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
mock_program_id,
|
mock_program_id,
|
||||||
&MockSystemInstruction::MultiBorrowMut,
|
&MockSystemInstruction::MultiBorrowMut,
|
||||||
account_metas.clone(),
|
account_metas.clone(),
|
||||||
|
@ -1926,7 +1930,7 @@ mod tests {
|
||||||
|
|
||||||
// Do work on the same account but at different location in keyed_accounts[]
|
// Do work on the same account but at different location in keyed_accounts[]
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
mock_program_id,
|
mock_program_id,
|
||||||
&MockSystemInstruction::DoWork {
|
&MockSystemInstruction::DoWork {
|
||||||
lamports: 10,
|
lamports: 10,
|
||||||
|
@ -2041,7 +2045,7 @@ mod tests {
|
||||||
|
|
||||||
// not owned account modified by the caller (before the invoke)
|
// not owned account modified by the caller (before the invoke)
|
||||||
accounts[0].borrow_mut().data[0] = 1;
|
accounts[0].borrow_mut().data[0] = 1;
|
||||||
let instruction = Instruction::new(
|
let instruction = Instruction::new_with_bincode(
|
||||||
callee_program_id,
|
callee_program_id,
|
||||||
&MockInstruction::NoopSuccess,
|
&MockInstruction::NoopSuccess,
|
||||||
metas.clone(),
|
metas.clone(),
|
||||||
|
@ -2079,7 +2083,8 @@ mod tests {
|
||||||
];
|
];
|
||||||
|
|
||||||
for case in cases {
|
for case in cases {
|
||||||
let instruction = Instruction::new(callee_program_id, &case.0, metas.clone());
|
let instruction =
|
||||||
|
Instruction::new_with_bincode(callee_program_id, &case.0, metas.clone());
|
||||||
let message = Message::new(&[instruction], None);
|
let message = Message::new(&[instruction], None);
|
||||||
let caller_privileges = message
|
let caller_privileges = message
|
||||||
.account_keys
|
.account_keys
|
||||||
|
|
|
@ -1353,7 +1353,7 @@ mod tests {
|
||||||
AccountMeta::new(alice_pubkey, false),
|
AccountMeta::new(alice_pubkey, false),
|
||||||
AccountMeta::new(mallory_pubkey, true),
|
AccountMeta::new(mallory_pubkey, true),
|
||||||
];
|
];
|
||||||
let malicious_instruction = Instruction::new(
|
let malicious_instruction = Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::Transfer { lamports: 10 },
|
&SystemInstruction::Transfer { lamports: 10 },
|
||||||
account_metas,
|
account_metas,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use test::Bencher;
|
||||||
|
|
||||||
fn make_instructions() -> Vec<Instruction> {
|
fn make_instructions() -> Vec<Instruction> {
|
||||||
let meta = AccountMeta::new(pubkey::new_rand(), false);
|
let meta = AccountMeta::new(pubkey::new_rand(), false);
|
||||||
let inst = Instruction::new(pubkey::new_rand(), &[0; 10], vec![meta; 4]);
|
let inst = Instruction::new_with_bincode(pubkey::new_rand(), &[0; 10], vec![meta; 4]);
|
||||||
vec![inst; 4]
|
vec![inst; 4]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ pub fn create_buffer(
|
||||||
UpgradeableLoaderState::buffer_len(program_len)? as u64,
|
UpgradeableLoaderState::buffer_len(program_len)? as u64,
|
||||||
&id(),
|
&id(),
|
||||||
),
|
),
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&UpgradeableLoaderInstruction::InitializeBuffer,
|
&UpgradeableLoaderInstruction::InitializeBuffer,
|
||||||
vec![
|
vec![
|
||||||
|
@ -118,7 +118,7 @@ pub fn write(
|
||||||
offset: u32,
|
offset: u32,
|
||||||
bytes: Vec<u8>,
|
bytes: Vec<u8>,
|
||||||
) -> Instruction {
|
) -> Instruction {
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&UpgradeableLoaderInstruction::Write { offset, bytes },
|
&UpgradeableLoaderInstruction::Write { offset, bytes },
|
||||||
vec![
|
vec![
|
||||||
|
@ -148,7 +148,7 @@ pub fn deploy_with_max_program_len(
|
||||||
UpgradeableLoaderState::program_len()? as u64,
|
UpgradeableLoaderState::program_len()? as u64,
|
||||||
&id(),
|
&id(),
|
||||||
),
|
),
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&UpgradeableLoaderInstruction::DeployWithMaxDataLen { max_data_len },
|
&UpgradeableLoaderInstruction::DeployWithMaxDataLen { max_data_len },
|
||||||
vec![
|
vec![
|
||||||
|
@ -173,7 +173,7 @@ pub fn upgrade(
|
||||||
spill_address: &Pubkey,
|
spill_address: &Pubkey,
|
||||||
) -> Instruction {
|
) -> Instruction {
|
||||||
let (programdata_address, _) = Pubkey::find_program_address(&[program_address.as_ref()], &id());
|
let (programdata_address, _) = Pubkey::find_program_address(&[program_address.as_ref()], &id());
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&UpgradeableLoaderInstruction::Upgrade,
|
&UpgradeableLoaderInstruction::Upgrade,
|
||||||
vec![
|
vec![
|
||||||
|
@ -198,7 +198,7 @@ pub fn set_buffer_authority(
|
||||||
current_authority_address: &Pubkey,
|
current_authority_address: &Pubkey,
|
||||||
new_authority_address: &Pubkey,
|
new_authority_address: &Pubkey,
|
||||||
) -> Instruction {
|
) -> Instruction {
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
id(),
|
id(),
|
||||||
&UpgradeableLoaderInstruction::SetAuthority,
|
&UpgradeableLoaderInstruction::SetAuthority,
|
||||||
vec![
|
vec![
|
||||||
|
@ -224,7 +224,7 @@ pub fn set_upgrade_authority(
|
||||||
if let Some(address) = new_authority_address {
|
if let Some(address) = new_authority_address {
|
||||||
metas.push(AccountMeta::new_readonly(*address, false));
|
metas.push(AccountMeta::new_readonly(*address, false));
|
||||||
}
|
}
|
||||||
Instruction::new(id(), &UpgradeableLoaderInstruction::SetAuthority, metas)
|
Instruction::new_with_bincode(id(), &UpgradeableLoaderInstruction::SetAuthority, metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -211,6 +211,10 @@ pub struct Instruction {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Instruction {
|
impl Instruction {
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.6.0",
|
||||||
|
note = "Please use another `Instruction constructor instead"
|
||||||
|
)]
|
||||||
pub fn new<T: Serialize>(program_id: Pubkey, data: &T, accounts: Vec<AccountMeta>) -> Self {
|
pub fn new<T: Serialize>(program_id: Pubkey, data: &T, accounts: Vec<AccountMeta>) -> Self {
|
||||||
Self::new_with_bincode(program_id, data, accounts)
|
Self::new_with_bincode(program_id, data, accounts)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub fn write(
|
||||||
bytes: Vec<u8>,
|
bytes: Vec<u8>,
|
||||||
) -> Instruction {
|
) -> Instruction {
|
||||||
let account_metas = vec![AccountMeta::new(*account_pubkey, true)];
|
let account_metas = vec![AccountMeta::new(*account_pubkey, true)];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
*program_id,
|
*program_id,
|
||||||
&LoaderInstruction::Write { offset, bytes },
|
&LoaderInstruction::Write { offset, bytes },
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -49,5 +49,5 @@ pub fn finalize(account_pubkey: &Pubkey, program_id: &Pubkey) -> Instruction {
|
||||||
AccountMeta::new(*account_pubkey, true),
|
AccountMeta::new(*account_pubkey, true),
|
||||||
AccountMeta::new_readonly(rent::id(), false),
|
AccountMeta::new_readonly(rent::id(), false),
|
||||||
];
|
];
|
||||||
Instruction::new(*program_id, &LoaderInstruction::Finalize, account_metas)
|
Instruction::new_with_bincode(*program_id, &LoaderInstruction::Finalize, account_metas)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use crate::account_info::AccountInfo;
|
use crate::account_info::AccountInfo;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[deprecated(since = "1.4.14", note = "use `msg` macro instead")]
|
#[deprecated(since = "1.4.14", note = "Please use `msg` macro instead")]
|
||||||
macro_rules! info {
|
macro_rules! info {
|
||||||
($msg:expr) => {
|
($msg:expr) => {
|
||||||
$crate::log::sol_log($msg)
|
$crate::log::sol_log($msg)
|
||||||
|
|
|
@ -446,8 +446,8 @@ mod tests {
|
||||||
fn test_message_unique_program_ids() {
|
fn test_message_unique_program_ids() {
|
||||||
let program_id0 = Pubkey::default();
|
let program_id0 = Pubkey::default();
|
||||||
let program_ids = get_program_ids(&[
|
let program_ids = get_program_ids(&[
|
||||||
Instruction::new(program_id0, &0, vec![]),
|
Instruction::new_with_bincode(program_id0, &0, vec![]),
|
||||||
Instruction::new(program_id0, &0, vec![]),
|
Instruction::new_with_bincode(program_id0, &0, vec![]),
|
||||||
]);
|
]);
|
||||||
assert_eq!(program_ids, vec![program_id0]);
|
assert_eq!(program_ids, vec![program_id0]);
|
||||||
}
|
}
|
||||||
|
@ -457,9 +457,9 @@ mod tests {
|
||||||
let program_id0 = Pubkey::default();
|
let program_id0 = Pubkey::default();
|
||||||
let program_id1 = Pubkey::new_unique();
|
let program_id1 = Pubkey::new_unique();
|
||||||
let program_ids = get_program_ids(&[
|
let program_ids = get_program_ids(&[
|
||||||
Instruction::new(program_id0, &0, vec![]),
|
Instruction::new_with_bincode(program_id0, &0, vec![]),
|
||||||
Instruction::new(program_id1, &0, vec![]),
|
Instruction::new_with_bincode(program_id1, &0, vec![]),
|
||||||
Instruction::new(program_id0, &0, vec![]),
|
Instruction::new_with_bincode(program_id0, &0, vec![]),
|
||||||
]);
|
]);
|
||||||
assert_eq!(program_ids, vec![program_id0, program_id1]);
|
assert_eq!(program_ids, vec![program_id0, program_id1]);
|
||||||
}
|
}
|
||||||
|
@ -469,9 +469,9 @@ mod tests {
|
||||||
let program_id0 = Pubkey::new_unique();
|
let program_id0 = Pubkey::new_unique();
|
||||||
let program_id1 = Pubkey::default(); // Key less than program_id0
|
let program_id1 = Pubkey::default(); // Key less than program_id0
|
||||||
let program_ids = get_program_ids(&[
|
let program_ids = get_program_ids(&[
|
||||||
Instruction::new(program_id0, &0, vec![]),
|
Instruction::new_with_bincode(program_id0, &0, vec![]),
|
||||||
Instruction::new(program_id1, &0, vec![]),
|
Instruction::new_with_bincode(program_id1, &0, vec![]),
|
||||||
Instruction::new(program_id0, &0, vec![]),
|
Instruction::new_with_bincode(program_id0, &0, vec![]),
|
||||||
]);
|
]);
|
||||||
assert_eq!(program_ids, vec![program_id0, program_id1]);
|
assert_eq!(program_ids, vec![program_id0, program_id1]);
|
||||||
}
|
}
|
||||||
|
@ -482,8 +482,8 @@ mod tests {
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -495,7 +495,7 @@ mod tests {
|
||||||
let program_id = Pubkey::default();
|
let program_id = Pubkey::default();
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&0,
|
&0,
|
||||||
vec![AccountMeta::new(id0, true)],
|
vec![AccountMeta::new(id0, true)],
|
||||||
|
@ -510,7 +510,7 @@ mod tests {
|
||||||
let program_id = Pubkey::default();
|
let program_id = Pubkey::default();
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[Instruction::new(
|
&[Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&0,
|
&0,
|
||||||
vec![AccountMeta::new(id0, false)],
|
vec![AccountMeta::new(id0, false)],
|
||||||
|
@ -526,8 +526,8 @@ mod tests {
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -540,8 +540,12 @@ mod tests {
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new_readonly(id0, true)]),
|
Instruction::new_with_bincode(
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
program_id,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id0, true)],
|
||||||
|
),
|
||||||
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -556,8 +560,12 @@ mod tests {
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new_readonly(id0, false)]),
|
Instruction::new_with_bincode(
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
program_id,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id0, false)],
|
||||||
|
),
|
||||||
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -573,8 +581,8 @@ mod tests {
|
||||||
let id1 = Pubkey::default(); // Key less than id0
|
let id1 = Pubkey::default(); // Key less than id0
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id1, false)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id1, false)]),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -588,9 +596,9 @@ mod tests {
|
||||||
let id1 = Pubkey::new_unique();
|
let id1 = Pubkey::new_unique();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id1, false)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id1, false)]),
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -604,8 +612,8 @@ mod tests {
|
||||||
let id1 = Pubkey::new_unique();
|
let id1 = Pubkey::new_unique();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id1, true)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id1, true)]),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -617,11 +625,11 @@ mod tests {
|
||||||
fn test_message_signed_keys_len() {
|
fn test_message_signed_keys_len() {
|
||||||
let program_id = Pubkey::default();
|
let program_id = Pubkey::default();
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, false)]);
|
let ix = Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, false)]);
|
||||||
let message = Message::new(&[ix], None);
|
let message = Message::new(&[ix], None);
|
||||||
assert_eq!(message.header.num_required_signatures, 0);
|
assert_eq!(message.header.num_required_signatures, 0);
|
||||||
|
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
let ix = Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
||||||
let message = Message::new(&[ix], Some(&id0));
|
let message = Message::new(&[ix], Some(&id0));
|
||||||
assert_eq!(message.header.num_required_signatures, 1);
|
assert_eq!(message.header.num_required_signatures, 1);
|
||||||
}
|
}
|
||||||
|
@ -635,10 +643,18 @@ mod tests {
|
||||||
let id3 = Pubkey::new_unique();
|
let id3 = Pubkey::new_unique();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new_readonly(id0, false)]),
|
Instruction::new_with_bincode(
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new_readonly(id1, true)]),
|
program_id,
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id2, false)]),
|
&0,
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id3, true)]),
|
vec![AccountMeta::new_readonly(id0, false)],
|
||||||
|
),
|
||||||
|
Instruction::new_with_bincode(
|
||||||
|
program_id,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id1, true)],
|
||||||
|
),
|
||||||
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id2, false)]),
|
||||||
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id3, true)]),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -656,9 +672,9 @@ mod tests {
|
||||||
let id1 = Pubkey::new_unique();
|
let id1 = Pubkey::new_unique();
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id0, &0, vec![AccountMeta::new(id0, false)]),
|
Instruction::new_with_bincode(program_id0, &0, vec![AccountMeta::new(id0, false)]),
|
||||||
Instruction::new(program_id1, &0, vec![AccountMeta::new(id1, true)]),
|
Instruction::new_with_bincode(program_id1, &0, vec![AccountMeta::new(id1, true)]),
|
||||||
Instruction::new(program_id0, &0, vec![AccountMeta::new(id1, false)]),
|
Instruction::new_with_bincode(program_id0, &0, vec![AccountMeta::new(id1, false)]),
|
||||||
],
|
],
|
||||||
Some(&id1),
|
Some(&id1),
|
||||||
);
|
);
|
||||||
|
@ -682,15 +698,15 @@ mod tests {
|
||||||
let payer = Pubkey::new_unique();
|
let payer = Pubkey::new_unique();
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
|
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, false)]);
|
let ix = Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, false)]);
|
||||||
let message = Message::new(&[ix], Some(&payer));
|
let message = Message::new(&[ix], Some(&payer));
|
||||||
assert_eq!(message.header.num_required_signatures, 1);
|
assert_eq!(message.header.num_required_signatures, 1);
|
||||||
|
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
let ix = Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
||||||
let message = Message::new(&[ix], Some(&payer));
|
let message = Message::new(&[ix], Some(&payer));
|
||||||
assert_eq!(message.header.num_required_signatures, 2);
|
assert_eq!(message.header.num_required_signatures, 2);
|
||||||
|
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&0,
|
&0,
|
||||||
vec![AccountMeta::new(payer, true), AccountMeta::new(id0, true)],
|
vec![AccountMeta::new(payer, true), AccountMeta::new(id0, true)],
|
||||||
|
@ -706,8 +722,16 @@ mod tests {
|
||||||
let id1 = Pubkey::new_unique();
|
let id1 = Pubkey::new_unique();
|
||||||
let keys = get_keys(
|
let keys = get_keys(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new_readonly(id0, false)]),
|
Instruction::new_with_bincode(
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new_readonly(id1, true)]),
|
program_id,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id0, false)],
|
||||||
|
),
|
||||||
|
Instruction::new_with_bincode(
|
||||||
|
program_id,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id1, true)],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -724,8 +748,8 @@ mod tests {
|
||||||
let id = Pubkey::new_unique();
|
let id = Pubkey::new_unique();
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id0, &0, vec![AccountMeta::new(id, false)]),
|
Instruction::new_with_bincode(program_id0, &0, vec![AccountMeta::new(id, false)]),
|
||||||
Instruction::new(program_id1, &0, vec![AccountMeta::new(id, true)]),
|
Instruction::new_with_bincode(program_id1, &0, vec![AccountMeta::new(id, true)]),
|
||||||
],
|
],
|
||||||
Some(&id),
|
Some(&id),
|
||||||
);
|
);
|
||||||
|
@ -770,10 +794,18 @@ mod tests {
|
||||||
let id3 = Pubkey::new_unique();
|
let id3 = Pubkey::new_unique();
|
||||||
let message = Message::new(
|
let message = Message::new(
|
||||||
&[
|
&[
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, false)]),
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new(id1, true)]),
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id1, true)]),
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new_readonly(id2, false)]),
|
Instruction::new_with_bincode(
|
||||||
Instruction::new(program_id, &0, vec![AccountMeta::new_readonly(id3, true)]),
|
program_id,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id2, false)],
|
||||||
|
),
|
||||||
|
Instruction::new_with_bincode(
|
||||||
|
program_id,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id3, true)],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
Some(&id1),
|
Some(&id1),
|
||||||
);
|
);
|
||||||
|
@ -793,10 +825,18 @@ mod tests {
|
||||||
let id2 = Pubkey::new_unique();
|
let id2 = Pubkey::new_unique();
|
||||||
let id3 = Pubkey::new_unique();
|
let id3 = Pubkey::new_unique();
|
||||||
let instructions = vec![
|
let instructions = vec![
|
||||||
Instruction::new(program_id0, &0, vec![AccountMeta::new(id0, false)]),
|
Instruction::new_with_bincode(program_id0, &0, vec![AccountMeta::new(id0, false)]),
|
||||||
Instruction::new(program_id0, &0, vec![AccountMeta::new(id1, true)]),
|
Instruction::new_with_bincode(program_id0, &0, vec![AccountMeta::new(id1, true)]),
|
||||||
Instruction::new(program_id1, &0, vec![AccountMeta::new_readonly(id2, false)]),
|
Instruction::new_with_bincode(
|
||||||
Instruction::new(program_id1, &0, vec![AccountMeta::new_readonly(id3, true)]),
|
program_id1,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id2, false)],
|
||||||
|
),
|
||||||
|
Instruction::new_with_bincode(
|
||||||
|
program_id1,
|
||||||
|
&0,
|
||||||
|
vec![AccountMeta::new_readonly(id3, true)],
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
let message = Message::new(&instructions, Some(&id1));
|
let message = Message::new(&instructions, Some(&id1));
|
||||||
|
|
|
@ -230,7 +230,7 @@ pub fn create_account(
|
||||||
AccountMeta::new(*from_pubkey, true),
|
AccountMeta::new(*from_pubkey, true),
|
||||||
AccountMeta::new(*to_pubkey, true),
|
AccountMeta::new(*to_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::CreateAccount {
|
&SystemInstruction::CreateAccount {
|
||||||
lamports,
|
lamports,
|
||||||
|
@ -258,7 +258,7 @@ pub fn create_account_with_seed(
|
||||||
AccountMeta::new_readonly(*base, true),
|
AccountMeta::new_readonly(*base, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::CreateAccountWithSeed {
|
&SystemInstruction::CreateAccountWithSeed {
|
||||||
base: *base,
|
base: *base,
|
||||||
|
@ -273,7 +273,7 @@ pub fn create_account_with_seed(
|
||||||
|
|
||||||
pub fn assign(pubkey: &Pubkey, owner: &Pubkey) -> Instruction {
|
pub fn assign(pubkey: &Pubkey, owner: &Pubkey) -> Instruction {
|
||||||
let account_metas = vec![AccountMeta::new(*pubkey, true)];
|
let account_metas = vec![AccountMeta::new(*pubkey, true)];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::Assign { owner: *owner },
|
&SystemInstruction::Assign { owner: *owner },
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -290,7 +290,7 @@ pub fn assign_with_seed(
|
||||||
AccountMeta::new(*address, false),
|
AccountMeta::new(*address, false),
|
||||||
AccountMeta::new_readonly(*base, true),
|
AccountMeta::new_readonly(*base, true),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::AssignWithSeed {
|
&SystemInstruction::AssignWithSeed {
|
||||||
base: *base,
|
base: *base,
|
||||||
|
@ -306,7 +306,7 @@ pub fn transfer(from_pubkey: &Pubkey, to_pubkey: &Pubkey, lamports: u64) -> Inst
|
||||||
AccountMeta::new(*from_pubkey, true),
|
AccountMeta::new(*from_pubkey, true),
|
||||||
AccountMeta::new(*to_pubkey, false),
|
AccountMeta::new(*to_pubkey, false),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::Transfer { lamports },
|
&SystemInstruction::Transfer { lamports },
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -326,7 +326,7 @@ pub fn transfer_with_seed(
|
||||||
AccountMeta::new_readonly(*from_base, true),
|
AccountMeta::new_readonly(*from_base, true),
|
||||||
AccountMeta::new(*to_pubkey, false),
|
AccountMeta::new(*to_pubkey, false),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::TransferWithSeed {
|
&SystemInstruction::TransferWithSeed {
|
||||||
lamports,
|
lamports,
|
||||||
|
@ -339,7 +339,7 @@ pub fn transfer_with_seed(
|
||||||
|
|
||||||
pub fn allocate(pubkey: &Pubkey, space: u64) -> Instruction {
|
pub fn allocate(pubkey: &Pubkey, space: u64) -> Instruction {
|
||||||
let account_metas = vec![AccountMeta::new(*pubkey, true)];
|
let account_metas = vec![AccountMeta::new(*pubkey, true)];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::Allocate { space },
|
&SystemInstruction::Allocate { space },
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -357,7 +357,7 @@ pub fn allocate_with_seed(
|
||||||
AccountMeta::new(*address, false),
|
AccountMeta::new(*address, false),
|
||||||
AccountMeta::new_readonly(*base, true),
|
AccountMeta::new_readonly(*base, true),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::AllocateWithSeed {
|
&SystemInstruction::AllocateWithSeed {
|
||||||
base: *base,
|
base: *base,
|
||||||
|
@ -395,7 +395,7 @@ pub fn create_nonce_account_with_seed(
|
||||||
nonce::State::size() as u64,
|
nonce::State::size() as u64,
|
||||||
&system_program::id(),
|
&system_program::id(),
|
||||||
),
|
),
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::InitializeNonceAccount(*authority),
|
&SystemInstruction::InitializeNonceAccount(*authority),
|
||||||
vec![
|
vec![
|
||||||
|
@ -421,7 +421,7 @@ pub fn create_nonce_account(
|
||||||
nonce::State::size() as u64,
|
nonce::State::size() as u64,
|
||||||
&system_program::id(),
|
&system_program::id(),
|
||||||
),
|
),
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::InitializeNonceAccount(*authority),
|
&SystemInstruction::InitializeNonceAccount(*authority),
|
||||||
vec![
|
vec![
|
||||||
|
@ -439,7 +439,7 @@ pub fn advance_nonce_account(nonce_pubkey: &Pubkey, authorized_pubkey: &Pubkey)
|
||||||
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::AdvanceNonceAccount,
|
&SystemInstruction::AdvanceNonceAccount,
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -459,7 +459,7 @@ pub fn withdraw_nonce_account(
|
||||||
AccountMeta::new_readonly(rent::id(), false),
|
AccountMeta::new_readonly(rent::id(), false),
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::WithdrawNonceAccount(lamports),
|
&SystemInstruction::WithdrawNonceAccount(lamports),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
@ -475,7 +475,7 @@ pub fn authorize_nonce_account(
|
||||||
AccountMeta::new(*nonce_pubkey, false),
|
AccountMeta::new(*nonce_pubkey, false),
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
Instruction::new(
|
Instruction::new_with_bincode(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
&SystemInstruction::AuthorizeNonceAccount(*new_authority),
|
&SystemInstruction::AuthorizeNonceAccount(*new_authority),
|
||||||
account_metas,
|
account_metas,
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
pub use solana_program::log::*;
|
pub use solana_program::log::*;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[deprecated(since = "1.4.3", note = "solana_program::log::info instead")]
|
#[deprecated(
|
||||||
|
since = "1.4.3",
|
||||||
|
note = "Please use `solana_program::log::info` instead"
|
||||||
|
)]
|
||||||
macro_rules! info {
|
macro_rules! info {
|
||||||
($msg:expr) => {
|
($msg:expr) => {
|
||||||
$crate::log::sol_log($msg)
|
$crate::log::sol_log($msg)
|
||||||
|
|
|
@ -519,7 +519,7 @@ mod tests {
|
||||||
let key = Keypair::new();
|
let key = Keypair::new();
|
||||||
let id0 = Pubkey::default();
|
let id0 = Pubkey::default();
|
||||||
let program_id = solana_sdk::pubkey::new_rand();
|
let program_id = solana_sdk::pubkey::new_rand();
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&0,
|
&0,
|
||||||
vec![
|
vec![
|
||||||
|
@ -596,7 +596,8 @@ mod tests {
|
||||||
AccountMeta::new(keypair.pubkey(), true),
|
AccountMeta::new(keypair.pubkey(), true),
|
||||||
AccountMeta::new(to, false),
|
AccountMeta::new(to, false),
|
||||||
];
|
];
|
||||||
let instruction = Instruction::new(program_id, &(1u8, 2u8, 3u8), account_metas);
|
let instruction =
|
||||||
|
Instruction::new_with_bincode(program_id, &(1u8, 2u8, 3u8), account_metas);
|
||||||
let message = Message::new(&[instruction], Some(&keypair.pubkey()));
|
let message = Message::new(&[instruction], Some(&keypair.pubkey()));
|
||||||
Transaction::new(&[&keypair], message, Hash::default())
|
Transaction::new(&[&keypair], message, Hash::default())
|
||||||
}
|
}
|
||||||
|
@ -693,7 +694,7 @@ mod tests {
|
||||||
fn test_partial_sign_mismatched_key() {
|
fn test_partial_sign_mismatched_key() {
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let fee_payer = solana_sdk::pubkey::new_rand();
|
let fee_payer = solana_sdk::pubkey::new_rand();
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
Pubkey::default(),
|
Pubkey::default(),
|
||||||
&0,
|
&0,
|
||||||
vec![AccountMeta::new(fee_payer, true)],
|
vec![AccountMeta::new(fee_payer, true)],
|
||||||
|
@ -707,7 +708,7 @@ mod tests {
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let keypair1 = Keypair::new();
|
let keypair1 = Keypair::new();
|
||||||
let keypair2 = Keypair::new();
|
let keypair2 = Keypair::new();
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
Pubkey::default(),
|
Pubkey::default(),
|
||||||
&0,
|
&0,
|
||||||
vec![
|
vec![
|
||||||
|
@ -737,7 +738,7 @@ mod tests {
|
||||||
let program_id = Pubkey::default();
|
let program_id = Pubkey::default();
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let id0 = keypair0.pubkey();
|
let id0 = keypair0.pubkey();
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
let ix = Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
||||||
let message = Message::new(&[ix], Some(&id0));
|
let message = Message::new(&[ix], Some(&id0));
|
||||||
Transaction::new_unsigned(message).sign(&Vec::<&Keypair>::new(), Hash::default());
|
Transaction::new_unsigned(message).sign(&Vec::<&Keypair>::new(), Hash::default());
|
||||||
}
|
}
|
||||||
|
@ -748,7 +749,8 @@ mod tests {
|
||||||
let program_id = Pubkey::default();
|
let program_id = Pubkey::default();
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let wrong_id = Pubkey::default();
|
let wrong_id = Pubkey::default();
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(wrong_id, true)]);
|
let ix =
|
||||||
|
Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(wrong_id, true)]);
|
||||||
let message = Message::new(&[ix], Some(&wrong_id));
|
let message = Message::new(&[ix], Some(&wrong_id));
|
||||||
Transaction::new_unsigned(message).sign(&[&keypair0], Hash::default());
|
Transaction::new_unsigned(message).sign(&[&keypair0], Hash::default());
|
||||||
}
|
}
|
||||||
|
@ -758,7 +760,7 @@ mod tests {
|
||||||
let program_id = Pubkey::default();
|
let program_id = Pubkey::default();
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let id0 = keypair0.pubkey();
|
let id0 = keypair0.pubkey();
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
let ix = Instruction::new_with_bincode(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
||||||
let message = Message::new(&[ix], Some(&id0));
|
let message = Message::new(&[ix], Some(&id0));
|
||||||
let mut tx = Transaction::new_unsigned(message);
|
let mut tx = Transaction::new_unsigned(message);
|
||||||
tx.sign(&[&keypair0], Hash::default());
|
tx.sign(&[&keypair0], Hash::default());
|
||||||
|
@ -775,7 +777,7 @@ mod tests {
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let id0 = keypair0.pubkey();
|
let id0 = keypair0.pubkey();
|
||||||
let id1 = solana_sdk::pubkey::new_rand();
|
let id1 = solana_sdk::pubkey::new_rand();
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&0,
|
&0,
|
||||||
vec![
|
vec![
|
||||||
|
@ -803,7 +805,7 @@ mod tests {
|
||||||
let presigner_keypair = Keypair::new();
|
let presigner_keypair = Keypair::new();
|
||||||
let presigner_pubkey = presigner_keypair.pubkey();
|
let presigner_pubkey = presigner_keypair.pubkey();
|
||||||
|
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&0,
|
&0,
|
||||||
vec![
|
vec![
|
||||||
|
@ -826,7 +828,7 @@ mod tests {
|
||||||
|
|
||||||
// Wrong key should error, not panic
|
// Wrong key should error, not panic
|
||||||
let another_pubkey = solana_sdk::pubkey::new_rand();
|
let another_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
let ix = Instruction::new(
|
let ix = Instruction::new_with_bincode(
|
||||||
program_id,
|
program_id,
|
||||||
&0,
|
&0,
|
||||||
vec![
|
vec![
|
||||||
|
|
Loading…
Reference in New Issue