diff --git a/crates/gateway/src/lib.rs b/crates/gateway/src/lib.rs index 27ee44a2..d69c8278 100644 --- a/crates/gateway/src/lib.rs +++ b/crates/gateway/src/lib.rs @@ -1,7 +1,7 @@ pub mod errors; pub mod gateway; pub mod starknet_api_test_utils; -pub mod transaction_validator; +pub mod stateless_transaction_validator; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; diff --git a/crates/gateway/src/transaction_validator.rs b/crates/gateway/src/stateless_transaction_validator.rs similarity index 93% rename from crates/gateway/src/transaction_validator.rs rename to crates/gateway/src/stateless_transaction_validator.rs index 37ddf300..ab75f0b8 100644 --- a/crates/gateway/src/transaction_validator.rs +++ b/crates/gateway/src/stateless_transaction_validator.rs @@ -7,7 +7,7 @@ use starknet_api::transaction::Resource; use crate::errors::{TransactionValidatorError, TransactionValidatorResult}; #[cfg(test)] -#[path = "transaction_validator_test.rs"] +#[path = "stateless_transaction_validator_test.rs"] mod transaction_validator_test; #[derive(Default)] @@ -22,12 +22,12 @@ pub struct TransactionValidator { } impl TransactionValidator { - pub fn validate(&self, tx: ExternalTransaction) -> TransactionValidatorResult<()> { + pub fn validate(&self, tx: &ExternalTransaction) -> TransactionValidatorResult<()> { // TODO(Arni, 1/5/2024): Add a mechanism that validate the sender address is not blocked. // TODO(Arni, 1/5/2024): Validate transaction version. // TODO(Arni, 4/4/2024): Validate tx signature and calldata are not too long. - self.validate_fee(&tx)?; + self.validate_fee(tx)?; Ok(()) } diff --git a/crates/gateway/src/transaction_validator_test.rs b/crates/gateway/src/stateless_transaction_validator_test.rs similarity index 97% rename from crates/gateway/src/transaction_validator_test.rs rename to crates/gateway/src/stateless_transaction_validator_test.rs index 8fda0d90..bf379715 100644 --- a/crates/gateway/src/transaction_validator_test.rs +++ b/crates/gateway/src/stateless_transaction_validator_test.rs @@ -8,7 +8,7 @@ use crate::starknet_api_test_utils::{ create_external_invoke_tx_for_testing, non_zero_l1_resource_bounds_mapping, non_zero_l2_resource_bounds_mapping, zero_resource_bounds_mapping, }; -use crate::transaction_validator::{ +use crate::stateless_transaction_validator::{ TransactionValidator, TransactionValidatorConfig, TransactionValidatorError, TransactionValidatorResult, }; @@ -83,7 +83,7 @@ fn test_transaction_validator( #[case] expected_result: TransactionValidatorResult<()>, ) { let tx_validator = TransactionValidator { config }; - let result = tx_validator.validate(tx); + let result = tx_validator.validate(&tx); assert_eq!(result, expected_result); }