Deprecate Instruction::new (#15695)

This commit is contained in:
Jack May
2021-03-03 21:46:48 -08:00
committed by GitHub
parent d6ea2f392b
commit b53cb8eb2d
32 changed files with 272 additions and 207 deletions

View File

@ -175,7 +175,7 @@ fn bench_program_execute_noop(bencher: &mut Bencher) {
let mint_pubkey = mint_keypair.pubkey();
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));
bank_client

View File

@ -17,7 +17,7 @@ fn process_instruction(
) -> ProgramResult {
if instruction_data.len() == 32 {
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 owner = &accounts[0].owner;
let mut data = accounts[0].try_borrow_mut_data()?;
@ -36,7 +36,7 @@ fn process_instruction(
} else {
match instruction_data[0] {
1 => {
let ix = Instruction::new(
let ix = Instruction::new_with_bincode(
*program_id,
&accounts[1].key.to_bytes(),
vec![AccountMeta::new_readonly(*program_id, false)],

View File

@ -36,7 +36,7 @@ fn process_instruction(
AccountMeta::new(*target.key, false),
AccountMeta::new(*me.key, false),
];
let ix = Instruction::new(
let ix = Instruction::new_with_bincode(
system_program::id(),
&SystemInstruction::Transfer { lamports: 1 },
account_metas,

View File

@ -465,7 +465,7 @@ fn test_program_bpf_sanity() {
AccountMeta::new(stake_history::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);
if program.1 {
assert!(result.is_ok());
@ -510,7 +510,7 @@ fn test_program_bpf_loader_deprecated() {
program,
);
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);
assert!(result.is_ok());
}
@ -558,42 +558,42 @@ fn test_program_bpf_duplicate_accounts() {
];
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 data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
assert!(result.is_ok());
assert_eq!(data[0], 1);
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 data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
assert!(result.is_ok());
assert_eq!(data[0], 2);
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 data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
assert!(result.is_ok());
assert_eq!(data[0], 3);
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 lamports = bank_client.get_balance(&pubkey).unwrap();
assert!(result.is_ok());
assert_eq!(lamports, 11);
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 lamports = bank_client.get_balance(&pubkey).unwrap();
assert!(result.is_ok());
assert_eq!(lamports, 12);
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 lamports = bank_client.get_balance(&pubkey).unwrap();
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 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);
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);
assert_eq!(
result.unwrap_err().unwrap(),
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);
assert_eq!(
result.unwrap_err().unwrap(),
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);
assert_eq!(
result.unwrap_err().unwrap(),
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 = result.unwrap_err().unwrap();
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 = result.unwrap_err().unwrap();
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 = result.unwrap_err().unwrap();
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);
assert_eq!(
result.unwrap_err().unwrap(),
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);
assert_eq!(
result.unwrap_err().unwrap(),
@ -800,12 +800,12 @@ fn test_program_bpf_invoke_sanity() {
// success cases
let instruction = Instruction::new(
let instruction = Instruction::new_with_bytes(
invoke_program_id,
&[TEST_SUCCESS, bump_seed1, bump_seed2, bump_seed3],
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 tx = Transaction::new(
&[
@ -880,7 +880,7 @@ fn test_program_bpf_invoke_sanity() {
&from_keypair,
];
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 tx = Transaction::new(&signers, message.clone(), bank.last_blockhash());
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());
bank.store_account(&from_keypair.pubkey(), &account);
bank.store_account(&derived_key1, &Account::default());
let instruction = Instruction::new(
let instruction = Instruction::new_with_bytes(
invoke_program_id,
&[
TEST_ALLOC_ACCESS_VIOLATION,
@ -1057,7 +1057,7 @@ fn test_program_bpf_program_id_spoofing() {
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);
assert_eq!(
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(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);
assert_eq!(
result.unwrap_err().unwrap(),
@ -1137,7 +1137,7 @@ fn test_program_bpf_ro_modify() {
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 result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
assert_eq!(
@ -1145,7 +1145,7 @@ fn test_program_bpf_ro_modify() {
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 result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
assert_eq!(
@ -1153,7 +1153,7 @@ fn test_program_bpf_ro_modify() {
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 result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
assert_eq!(
@ -1187,7 +1187,7 @@ fn test_program_bpf_call_depth() {
"solana_bpf_rust_call_depth",
);
let instruction = Instruction::new(
let instruction = Instruction::new_with_bincode(
program_id,
&(BpfComputeBudget::default().max_call_depth - 1),
vec![],
@ -1195,7 +1195,7 @@ fn test_program_bpf_call_depth() {
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
assert!(result.is_ok());
let instruction = Instruction::new(
let instruction = Instruction::new_with_bincode(
program_id,
&BpfComputeBudget::default().max_call_depth,
vec![],
@ -1279,9 +1279,9 @@ fn test_program_bpf_instruction_introspection() {
solana_sdk::sysvar::instructions::id(),
false,
)];
let instruction0 = Instruction::new(program_id, &[0u8, 0u8], account_metas.clone());
let instruction1 = Instruction::new(program_id, &[0u8, 1u8], account_metas.clone());
let instruction2 = Instruction::new(program_id, &[0u8, 2u8], account_metas);
let instruction0 = Instruction::new_with_bytes(program_id, &[0u8, 0u8], account_metas.clone());
let instruction1 = Instruction::new_with_bytes(program_id, &[0u8, 1u8], account_metas.clone());
let instruction2 = Instruction::new_with_bytes(program_id, &[0u8, 2u8], account_metas);
let message = Message::new(
&[instruction0, instruction1, instruction2],
Some(&mint_keypair.pubkey()),
@ -1294,7 +1294,7 @@ fn test_program_bpf_instruction_introspection() {
solana_sdk::sysvar::instructions::id(),
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);
assert_eq!(
result.unwrap_err().unwrap(),
@ -1302,7 +1302,7 @@ fn test_program_bpf_instruction_introspection() {
);
// 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);
assert!(result.is_err());
assert_eq!(
@ -1369,7 +1369,7 @@ fn test_program_bpf_test_use_latest_executor() {
let message = Message::new(
&[
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()),
);
@ -1401,7 +1401,7 @@ fn test_program_bpf_test_use_latest_executor() {
// Call the noop program, should get noop not panic
let message = Message::new(
&[Instruction::new(program_keypair.pubkey(), &0u8, vec![])],
&[Instruction::new_with_bytes(program_keypair.pubkey(), &[0], vec![])],
Some(&mint_keypair.pubkey()),
);
assert!(bank_client
@ -1491,7 +1491,7 @@ fn test_program_bpf_test_use_latest_executor2() {
// invoke program, verify not found
let message = Message::new(
&[Instruction::new(program_keypair.pubkey(), &0u8, vec![])],
&[Instruction::new_with_bytes(program_keypair.pubkey(), &[0], vec![])],
Some(&mint_keypair.pubkey()),
);
assert_eq!(
@ -1526,7 +1526,7 @@ fn test_program_bpf_test_use_latest_executor2() {
// Call the program, should get noop, not panic
let message = Message::new(
&[Instruction::new(program_keypair.pubkey(), &0u8, vec![])],
&[Instruction::new_with_bytes(program_keypair.pubkey(), &[0], vec![])],
Some(&mint_keypair.pubkey()),
);
assert!(bank_client
@ -1563,7 +1563,7 @@ fn test_program_bpf_upgrade() {
"solana_bpf_rust_upgradeable",
);
let mut instruction = Instruction::new(
let mut instruction = Instruction::new_with_bytes(
program_id,
&[0],
vec![
@ -1659,7 +1659,7 @@ fn test_program_bpf_upgrade_and_invoke_in_same_tx() {
"solana_bpf_rust_noop",
);
let invoke_instruction = Instruction::new(
let invoke_instruction = Instruction::new_with_bytes(
program_id,
&[0],
vec![
@ -1747,7 +1747,7 @@ fn test_program_bpf_invoke_upgradeable_via_cpi() {
"solana_bpf_rust_upgradeable",
);
let mut instruction = Instruction::new(
let mut instruction = Instruction::new_with_bytes(
invoke_and_return,
&[0],
vec![
@ -1848,7 +1848,7 @@ fn test_program_bpf_disguised_as_bpf_loader() {
program,
);
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);
assert_eq!(
result.unwrap_err().unwrap(),
@ -1894,7 +1894,7 @@ fn test_program_bpf_upgrade_via_cpi() {
"solana_bpf_rust_upgradeable",
);
let mut instruction = Instruction::new(
let mut instruction = Instruction::new_with_bytes(
invoke_and_return,
&[0],
vec![
@ -1992,7 +1992,7 @@ fn test_program_bpf_upgrade_self_via_cpi() {
"solana_bpf_rust_invoke_and_return",
);
let mut invoke_instruction = Instruction::new(
let mut invoke_instruction = Instruction::new_with_bytes(
program_id,
&[0],
vec![
@ -2104,9 +2104,9 @@ fn test_program_upgradeable_locks() {
let invoke_tx = Transaction::new(
&[payer_keypair],
Message::new(
&[Instruction::new(
&[Instruction::new_with_bytes(
program_keypair.pubkey(),
&[0u8; 0],
&[0; 0],
vec![],
)],
Some(&payer_keypair.pubkey()),
@ -2208,7 +2208,7 @@ fn test_program_bpf_syscall_feature_activation() {
&mint_keypair,
"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);
assert!(result.is_ok());
@ -2217,7 +2217,7 @@ fn test_program_bpf_syscall_feature_activation() {
let bank = Arc::new(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);
println!("result: {:?}", result);
assert!(result.is_ok());

View File

@ -1654,7 +1654,7 @@ mod tests {
bank.clear_signatures();
bank.store_account(&buffer_address, &buffer_account);
let message = Message::new(
&[Instruction::new(
&[Instruction::new_with_bincode(
bpf_loader_upgradeable::id(),
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
max_data_len: elf.len(),
@ -1713,7 +1713,7 @@ mod tests {
bank.store_account(&program_keypair.pubkey(), &program_account);
bank.store_account(&programdata_address, &programdata_account);
let message = Message::new(
&[Instruction::new(
&[Instruction::new_with_bincode(
bpf_loader_upgradeable::id(),
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
max_data_len: elf.len(),
@ -1744,7 +1744,7 @@ mod tests {
bank.store_account(&program_keypair.pubkey(), &program_account);
bank.store_account(&programdata_address, &programdata_account);
let message = Message::new(
&[Instruction::new(
&[Instruction::new_with_bincode(
bpf_loader_upgradeable::id(),
&UpgradeableLoaderInstruction::DeployWithMaxDataLen {
max_data_len: elf.len(),

View File

@ -1793,7 +1793,7 @@ mod tests {
assert_eq!(pubkey, *translated_pubkey);
// Instruction
let instruction = Instruction::new(
let instruction = Instruction::new_with_bincode(
solana_sdk::pubkey::new_rand(),
&"foobar",
vec![AccountMeta::new(solana_sdk::pubkey::new_rand(), false)],

View File

@ -47,7 +47,7 @@ fn initialize_account(contract: &Pubkey, expr: BudgetExpr) -> Instruction {
keys.push(AccountMeta::new(payment.to, false));
}
keys.push(AccountMeta::new(*contract, false));
Instruction::new(
Instruction::new_with_bincode(
id(),
&BudgetInstruction::InitializeAccount(Box::new(expr)),
keys,
@ -136,7 +136,7 @@ pub fn apply_timestamp(
if from != to {
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 {
@ -147,7 +147,7 @@ pub fn apply_signature(from: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruc
if from != to {
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.
@ -157,7 +157,7 @@ pub fn apply_account_data(witness_pubkey: &Pubkey, contract: &Pubkey, to: &Pubke
AccountMeta::new(*contract, false),
AccountMeta::new(*to, false),
];
Instruction::new(id(), &BudgetInstruction::ApplyAccountData, account_metas)
Instruction::new_with_bincode(id(), &BudgetInstruction::ApplyAccountData, account_metas)
}
#[cfg(test)]

View File

@ -9,7 +9,7 @@ use solana_sdk::{
fn initialize_account<T: ConfigState>(config_pubkey: &Pubkey) -> Instruction {
let account_metas = vec![AccountMeta::new(*config_pubkey, true)];
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
@ -46,5 +46,5 @@ pub fn store<T: ConfigState>(
}
}
let account_data = (ConfigKeys { keys }, data);
Instruction::new(id(), &account_data, account_metas)
Instruction::new_with_bincode(id(), &account_data, account_metas)
}

View File

@ -59,7 +59,7 @@ pub fn account_request(owner: &Pubkey, new: &Pubkey) -> Instruction {
AccountMeta::new(*owner, true),
AccountMeta::new(*new, false),
];
Instruction::new(id(), &ExchangeInstruction::AccountRequest, account_metas)
Instruction::new_with_bincode(id(), &ExchangeInstruction::AccountRequest, account_metas)
}
pub fn transfer_request(
@ -74,7 +74,7 @@ pub fn transfer_request(
AccountMeta::new(*to, false),
AccountMeta::new(*from, false),
];
Instruction::new(
Instruction::new_with_bincode(
id(),
&ExchangeInstruction::TransferRequest(token, tokens),
account_metas,
@ -95,7 +95,7 @@ pub fn trade_request(
AccountMeta::new(*trade, false),
AccountMeta::new(*src_account, false),
];
Instruction::new(
Instruction::new_with_bincode(
id(),
&ExchangeInstruction::OrderRequest(OrderRequestInfo {
side,
@ -112,7 +112,7 @@ pub fn order_cancellation(owner: &Pubkey, order: &Pubkey) -> Instruction {
AccountMeta::new(*owner, true),
AccountMeta::new(*order, false),
];
Instruction::new(id(), &ExchangeInstruction::OrderCancellation, account_metas)
Instruction::new_with_bincode(id(), &ExchangeInstruction::OrderCancellation, account_metas)
}
pub fn swap_request(
@ -127,5 +127,5 @@ pub fn swap_request(
AccountMeta::new(*from_trade, false),
AccountMeta::new(*profit_account, false),
];
Instruction::new(id(), &ExchangeInstruction::SwapRequest, account_metas)
Instruction::new_with_bincode(id(), &ExchangeInstruction::SwapRequest, account_metas)
}

View File

@ -21,7 +21,7 @@ impl<T> DecodeError<T> for OwnableError {
fn initialize_account(account_pubkey: &Pubkey, owner_pubkey: &Pubkey) -> Instruction {
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(
@ -48,5 +48,5 @@ pub fn set_owner(account_pubkey: &Pubkey, old_pubkey: &Pubkey, new_pubkey: &Pubk
AccountMeta::new(*account_pubkey, false),
AccountMeta::new(*old_pubkey, true),
];
Instruction::new(crate::id(), &new_pubkey, keys)
Instruction::new_with_bincode(crate::id(), &new_pubkey, keys)
}

View File

@ -184,7 +184,7 @@ pub struct AuthorizeWithSeedArgs {
}
fn initialize(stake_pubkey: &Pubkey, authorized: &Authorized, lockup: &Lockup) -> Instruction {
Instruction::new(
Instruction::new_with_bincode(
id(),
&StakeInstruction::Initialize(*authorized, *lockup),
vec![
@ -248,7 +248,7 @@ fn _split(
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(
@ -314,7 +314,7 @@ pub fn merge(
AccountMeta::new_readonly(*authorized_pubkey, true),
];
vec![Instruction::new(
vec![Instruction::new_with_bincode(
id(),
&StakeInstruction::Merge,
account_metas,
@ -382,7 +382,7 @@ pub fn authorize(
account_metas.push(AccountMeta::new_readonly(*custodian_pubkey, true));
}
Instruction::new(
Instruction::new_with_bincode(
id(),
&StakeInstruction::Authorize(*new_authorized_pubkey, stake_authorize),
account_metas,
@ -415,7 +415,7 @@ pub fn authorize_with_seed(
authority_owner: *authority_owner,
};
Instruction::new(
Instruction::new_with_bincode(
id(),
&StakeInstruction::AuthorizeWithSeed(args),
account_metas,
@ -435,7 +435,7 @@ pub fn delegate_stake(
AccountMeta::new_readonly(crate::config::id(), false),
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(
@ -457,7 +457,7 @@ pub fn withdraw(
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 {
@ -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(*authorized_pubkey, true),
];
Instruction::new(id(), &StakeInstruction::Deactivate, account_metas)
Instruction::new_with_bincode(id(), &StakeInstruction::Deactivate, account_metas)
}
pub fn set_lockup(
@ -478,7 +478,7 @@ pub fn set_lockup(
AccountMeta::new(*stake_pubkey, false),
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(

View File

@ -75,7 +75,7 @@ fn initialize_account(
total_lamports: u64,
) -> Instruction {
let keys = vec![AccountMeta::new(*contract_pubkey, false)];
Instruction::new(
Instruction::new_with_bincode(
id(),
&VestInstruction::InitializeAccount {
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(*old_pubkey, true),
];
Instruction::new(
Instruction::new_with_bincode(
id(),
&VestInstruction::SetTerminator(*new_pubkey),
account_metas,
@ -128,7 +128,7 @@ pub fn set_payee(contract: &Pubkey, old_pubkey: &Pubkey, new_pubkey: &Pubkey) ->
AccountMeta::new(*contract, false),
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 {
@ -137,7 +137,7 @@ pub fn redeem_tokens(contract: &Pubkey, date_pubkey: &Pubkey, to: &Pubkey) -> In
AccountMeta::new_readonly(*date_pubkey, 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 {
@ -148,7 +148,7 @@ pub fn terminate(contract: &Pubkey, from: &Pubkey, to: &Pubkey) -> Instruction {
if from != to {
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 {
@ -159,7 +159,7 @@ pub fn renege(contract: &Pubkey, from: &Pubkey, to: &Pubkey, lamports: u64) -> I
if from != to {
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 {
@ -167,5 +167,5 @@ pub fn vest_all(contract: &Pubkey, from: &Pubkey) -> Instruction {
AccountMeta::new(*contract, false),
AccountMeta::new(*from, true),
];
Instruction::new(id(), &VestInstruction::VestAll, account_metas)
Instruction::new_with_bincode(id(), &VestInstruction::VestAll, account_metas)
}

View File

@ -121,7 +121,7 @@ fn initialize_account(vote_pubkey: &Pubkey, vote_init: &VoteInit) -> Instruction
AccountMeta::new_readonly(vote_init.node_pubkey, true),
];
Instruction::new(
Instruction::new_with_bincode(
id(),
&VoteInstruction::InitializeAccount(*vote_init),
account_metas,
@ -175,7 +175,7 @@ pub fn authorize(
AccountMeta::new_readonly(*authorized_pubkey, true),
];
Instruction::new(
Instruction::new_with_bincode(
id(),
&VoteInstruction::Authorize(*new_authorized_pubkey, vote_authorize),
account_metas,
@ -193,7 +193,7 @@ pub fn update_validator_identity(
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
];
Instruction::new(
Instruction::new_with_bincode(
id(),
&VoteInstruction::UpdateValidatorIdentity,
account_metas,
@ -210,7 +210,7 @@ pub fn update_commission(
AccountMeta::new_readonly(*authorized_withdrawer_pubkey, true),
];
Instruction::new(
Instruction::new_with_bincode(
id(),
&VoteInstruction::UpdateCommission(commission),
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),
];
Instruction::new(id(), &VoteInstruction::Vote(vote), account_metas)
Instruction::new_with_bincode(id(), &VoteInstruction::Vote(vote), account_metas)
}
pub fn vote_switch(
@ -241,7 +241,7 @@ pub fn vote_switch(
AccountMeta::new_readonly(*authorized_voter_pubkey, true),
];
Instruction::new(
Instruction::new_with_bincode(
id(),
&VoteInstruction::VoteSwitch(vote, proof_hash),
account_metas,
@ -260,7 +260,7 @@ pub fn withdraw(
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(