diff --git a/sdk/program/src/instruction.rs b/sdk/program/src/instruction.rs index abdc988a9b..1fd7d560dc 100644 --- a/sdk/program/src/instruction.rs +++ b/sdk/program/src/instruction.rs @@ -212,6 +212,14 @@ pub struct Instruction { impl Instruction { pub fn new(program_id: Pubkey, data: &T, accounts: Vec) -> Self { + Self::new_with_bincode(program_id, data, accounts) + } + + pub fn new_with_bincode( + program_id: Pubkey, + data: &T, + accounts: Vec, + ) -> 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) -> Self { + Self { + program_id, + data: data.to_vec(), + accounts, + } + } } pub fn checked_add(a: u64, b: u64) -> Result {