Skip to content

Commit

Permalink
RuntimeTransaction::try_from_sanitized_transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Sep 30, 2024
1 parent 489f483 commit 8ddddf4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions runtime-transaction/src/runtime_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,34 @@ impl RuntimeTransaction<SanitizedVersionedTransaction> {
}

impl RuntimeTransaction<SanitizedTransaction> {
pub fn try_from_sanitized_transaction(transaction: SanitizedTransaction) -> Result<Self> {
let message_hash = *transaction.message_hash();
let is_simple_vote_tx = transaction.is_simple_vote_transaction();
let precompile_signature_details =
get_precompile_signature_details(transaction.program_instructions_iter());
let signature_details = TransactionSignatureDetails::new(
transaction.signatures().len() as u64,
precompile_signature_details.num_secp256k1_instruction_signatures,
precompile_signature_details.num_ed25519_instruction_signatures,
);
let compute_budget_instruction_details =
ComputeBudgetInstructionDetails::try_from(transaction.program_instructions_iter())?;

let mut tx = Self {
transaction,
meta: TransactionMeta {
message_hash,
is_simple_vote_tx,
signature_details,
compute_budget_instruction_details,
},
};

tx.load_dynamic_metadata()?;

Ok(tx)
}

pub fn try_from(
statically_loaded_runtime_tx: RuntimeTransaction<SanitizedVersionedTransaction>,
address_loader: impl AddressLoader,
Expand Down

0 comments on commit 8ddddf4

Please sign in to comment.