Skip to content

Commit

Permalink
RuntimeTransaction::try_create
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Oct 4, 2024
1 parent 9496f28 commit a75c91d
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion runtime-transaction/src/runtime_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ use {
pubkey::Pubkey,
signature::Signature,
simple_vote_transaction_checker::is_simple_vote_transaction,
transaction::{Result, SanitizedTransaction, SanitizedVersionedTransaction},
transaction::{
Result, SanitizedTransaction, SanitizedVersionedTransaction, VersionedTransaction,
},
},
solana_svm_transaction::{
instruction::SVMInstruction, message_address_table_lookup::SVMMessageAddressTableLookup,
Expand Down Expand Up @@ -116,6 +118,31 @@ impl RuntimeTransaction<SanitizedVersionedTransaction> {
}

impl RuntimeTransaction<SanitizedTransaction> {
/// Create a new `RuntimeTransaction<SanitizedTransaction>` from an
/// unsanitized `VersionedTransaction`.
pub fn try_create(
tx: VersionedTransaction,
message_hash: Option<Hash>,
is_simple_vote_tx: Option<bool>,
address_loader: impl AddressLoader,
reserved_account_keys: &HashSet<Pubkey>,
) -> Result<Self> {
let statically_loaded_runtime_tx =
RuntimeTransaction::<SanitizedVersionedTransaction>::try_from(
SanitizedVersionedTransaction::try_from(tx)?,
message_hash,
is_simple_vote_tx,
)?;
Self::try_from(
statically_loaded_runtime_tx,
address_loader,
reserved_account_keys,
)
}

/// Create a new `RuntimeTransaction<SanitizedTransaction>` from a
/// `RuntimeTransaction<SanitizedVersionedTransaction>` that already has
/// static metadata loaded.
pub fn try_from(
statically_loaded_runtime_tx: RuntimeTransaction<SanitizedVersionedTransaction>,
address_loader: impl AddressLoader,
Expand Down

0 comments on commit a75c91d

Please sign in to comment.