Skip to content

Commit

Permalink
update transaction type
Browse files Browse the repository at this point in the history
  • Loading branch information
ybensacq committed May 22, 2024
1 parent 0fb79ec commit f6705a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
6 changes: 3 additions & 3 deletions crates/katana/core/src/hooker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::sequencer::KatanaSequencer;
use async_trait::async_trait;
use katana_executor::ExecutorFactory;
use starknet::accounts::Call;
use starknet::core::types::{BroadcastedInvokeTransactionV3, FieldElement};
use starknet::core::types::{BroadcastedInvokeTransaction, FieldElement};
use std::sync::Arc;
use tracing::{error, info};

Expand Down Expand Up @@ -44,7 +44,7 @@ pub trait KatanaHooker<EF: ExecutorFactory> {
/// # Arguments
///
/// * `transaction` - The invoke transaction to be verified.
async fn verify_invoke_tx_before_pool(&self, transaction: BroadcastedInvokeTransactionV3)
async fn verify_invoke_tx_before_pool(&self, transaction: BroadcastedInvokeTransaction)
-> bool;

/// Runs code right before a message to starknet
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<EF: ExecutorFactory + 'static + Send + Sync> KatanaHooker<EF> for DefaultKa

async fn verify_invoke_tx_before_pool(
&self,
transaction: BroadcastedInvokeTransactionV3,
transaction: BroadcastedInvokeTransaction,
) -> bool {
info!("HOOKER: verify_invoke_tx_before_pool called with transaction: {:?}", transaction);
true
Expand Down
13 changes: 3 additions & 10 deletions crates/katana/rpc/rpc/src/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,16 +677,9 @@ impl<EF: ExecutorFactory> StarknetApiServer for StarknetApi<EF> {
) -> RpcResult<InvokeTxResult> {

if let Some(hooker) = &self.inner.sequencer.hooker {
let tx_clone = invoke_transaction.0.clone();
match tx_clone {
BroadcastedInvokeTransaction::V3(tx) => {
if !hooker.read().await.verify_invoke_tx_before_pool(tx).await {
return Err(StarknetApiError::SolisAssetFault.into());
}
},
BroadcastedInvokeTransaction::V1(_tx) => {
return Err(StarknetApiError::UnsupportedTransactionVersion.into());
}
let tx = invoke_transaction.0.clone();
if !hooker.read().await.verify_invoke_tx_before_pool(tx).await {
return Err(StarknetApiError::SolisAssetFault.into());
}
}
self.on_io_blocking_task(move |this| {
Expand Down

0 comments on commit f6705a4

Please sign in to comment.