Skip to content

Commit

Permalink
chore: define try from snapi executable transaction for account tx (#526
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ArniStarkware authored Aug 20, 2024
1 parent d0ce811 commit 1487474
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,29 @@ pub enum AccountTransaction {
Invoke(InvokeTransaction),
}

impl TryFrom<starknet_api::executable_transaction::Transaction> for AccountTransaction {
type Error = TransactionExecutionError;

fn try_from(
executable_transaction: starknet_api::executable_transaction::Transaction,
) -> Result<Self, Self::Error> {
match executable_transaction {
starknet_api::executable_transaction::Transaction::Declare(declare_tx) => {
Ok(Self::Declare(declare_tx.try_into()?))
}
starknet_api::executable_transaction::Transaction::DeployAccount(deploy_account_tx) => {
Ok(Self::DeployAccount(DeployAccountTransaction {
tx: deploy_account_tx,
only_query: false,
}))
}
starknet_api::executable_transaction::Transaction::Invoke(invoke_tx) => {
Ok(Self::Invoke(InvokeTransaction { tx: invoke_tx, only_query: false }))
}
}
}
}

impl HasRelatedFeeType for AccountTransaction {
fn version(&self) -> TransactionVersion {
match self {
Expand Down

0 comments on commit 1487474

Please sign in to comment.