Clarify Instruction::new (#15686)
Not related to local-cluster, merging
This commit is contained in:
parent
bbf7ded997
commit
4a05210d8e
|
@ -212,6 +212,14 @@ pub struct Instruction {
|
|||
|
||||
impl Instruction {
|
||||
pub fn new<T: Serialize>(program_id: Pubkey, data: &T, accounts: Vec<AccountMeta>) -> Self {
|
||||
Self::new_with_bincode(program_id, data, accounts)
|
||||
}
|
||||
|
||||
pub fn new_with_bincode<T: Serialize>(
|
||||
program_id: Pubkey,
|
||||
data: &T,
|
||||
accounts: Vec<AccountMeta>,
|
||||
) -> Self {
|
||||
let data = serialize(data).unwrap();
|
||||
Self {
|
||||
program_id,
|
||||
|
@ -232,6 +240,14 @@ impl Instruction {
|
|||
accounts,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_bytes(program_id: Pubkey, data: &[u8], accounts: Vec<AccountMeta>) -> Self {
|
||||
Self {
|
||||
program_id,
|
||||
data: data.to_vec(),
|
||||
accounts,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn checked_add(a: u64, b: u64) -> Result<u64, InstructionError> {
|
||||
|
|
Loading…
Reference in New Issue