diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 212cd7994e..86977cc598 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -4,7 +4,7 @@ pub mod genesis_block; pub mod hash; pub mod instruction; pub mod loader_instruction; -mod message; +pub mod message; pub mod native_loader; pub mod native_program; pub mod packet; diff --git a/sdk/src/transaction.rs b/sdk/src/transaction.rs index f600153023..0c0e07edd3 100644 --- a/sdk/src/transaction.rs +++ b/sdk/src/transaction.rs @@ -88,16 +88,25 @@ impl Transaction { Self::new_unsigned_message(message) } + pub fn new( + from_keypairs: &[&T], + message: Message, + recent_blockhash: Hash, + ) -> Transaction { + let mut tx = Self::new_unsigned_message(message); + tx.sign(from_keypairs, recent_blockhash); + tx + } + pub fn new_signed_instructions( from_keypairs: &[&T], instructions: Vec, recent_blockhash: Hash, fee: u64, ) -> Transaction { - let mut tx = Self::new(instructions); - tx.fee = fee; - tx.sign(from_keypairs, recent_blockhash); - tx + let mut message = Message::new(instructions); + message.fee = fee; + Self::new(from_keypairs, message, recent_blockhash) } pub fn new_signed( @@ -113,11 +122,7 @@ impl Transaction { account_metas.push(AccountMeta::new(*pubkey, false)); } let instruction = Instruction::new(*program_id, data, account_metas); - let mut transaction = Self::new(vec![instruction]); - transaction.fee = fee; - transaction.recent_blockhash = recent_blockhash; - transaction.sign(&[from_keypair], recent_blockhash); - transaction + Self::new_signed_instructions(&[from_keypair], vec![instruction], recent_blockhash, fee) } /// Create a signed transaction