diff --git a/crates/torii/libp2p/src/server/mod.rs b/crates/torii/libp2p/src/server/mod.rs index 704cff6170..7bb0508cc8 100644 --- a/crates/torii/libp2p/src/server/mod.rs +++ b/crates/torii/libp2p/src/server/mod.rs @@ -37,8 +37,8 @@ use crate::errors::Error; mod events; use crate::server::events::ServerEvent; -use crate::typed_data::{encode_type, parse_value_to_ty, PrimitiveType, TypedData}; -use crate::types::{Message, Signature}; +use crate::typed_data::{parse_value_to_ty, PrimitiveType, TypedData}; +use crate::types::Message; pub(crate) const LOG_TARGET: &str = "torii::relay::server"; @@ -414,51 +414,24 @@ async fn validate_signature( provider: &P, entity_identity: Felt, message: &TypedData, - signature: &Signature, + signature: &[Felt], ) -> Result { let message_hash = message.encode(entity_identity)?; - match signature { - Signature::Account(signature) => { - let mut calldata = vec![message_hash, Felt::from(signature.len())]; - calldata.extend(signature); - provider - .call( - FunctionCall { - contract_address: entity_identity, - entry_point_selector: get_selector_from_name("is_valid_signature").unwrap(), - calldata, - }, - BlockId::Tag(BlockTag::Pending), - ) - .await - .map_err(Error::ProviderError) - .map(|res| res[0] != Felt::ZERO) - } - Signature::Session(signature) => { - let mut calldata = vec![ - Felt::ONE, - get_selector_from_name(&encode_type(&message.primary_type, &message.types)?) - .map_err(|e| Error::InvalidMessageError(e.to_string()))?, - message_hash, - signature.len().into(), - ]; - calldata.extend(signature); - provider - .call( - FunctionCall { - contract_address: entity_identity, - entry_point_selector: get_selector_from_name("is_session_sigature_valid") - .unwrap(), - calldata, - }, - BlockId::Tag(BlockTag::Pending), - ) - .await - .map_err(Error::ProviderError) - .map(|res| res[0] != Felt::ZERO) - } - } + let mut calldata = vec![message_hash, Felt::from(signature.len())]; + calldata.extend(signature); + provider + .call( + FunctionCall { + contract_address: entity_identity, + entry_point_selector: get_selector_from_name("is_valid_signature").unwrap(), + calldata, + }, + BlockId::Tag(BlockTag::Pending), + ) + .await + .map_err(Error::ProviderError) + .map(|res| res[0] != Felt::ZERO) } fn ty_keys(ty: &Ty) -> Result, Error> { diff --git a/crates/torii/libp2p/src/tests.rs b/crates/torii/libp2p/src/tests.rs index 5dc6ae6bf0..9016f053ba 100644 --- a/crates/torii/libp2p/src/tests.rs +++ b/crates/torii/libp2p/src/tests.rs @@ -546,7 +546,7 @@ mod test { use crate::server::Relay; use crate::typed_data::{Domain, Field, SimpleField, TypedData}; - use crate::types::{Message, Signature}; + use crate::types::Message; let _ = tracing_subscriber::fmt() .with_env_filter("torii::relay::client=debug,torii::relay::server=debug") @@ -693,10 +693,7 @@ mod test { client .command_sender - .publish(Message { - message: typed_data, - signature: Signature::Account(vec![signature.r, signature.s]), - }) + .publish(Message { message: typed_data, signature: vec![signature.r, signature.s] }) .await?; sleep(std::time::Duration::from_secs(2)).await; diff --git a/crates/torii/libp2p/src/types.rs b/crates/torii/libp2p/src/types.rs index f4c3bfce15..1122f046fe 100644 --- a/crates/torii/libp2p/src/types.rs +++ b/crates/torii/libp2p/src/types.rs @@ -3,14 +3,8 @@ use starknet::core::types::Felt; use crate::typed_data::TypedData; -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum Signature { - Account(Vec), - Session(Vec), -} - #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Message { pub message: TypedData, - pub signature: Signature, + pub signature: Vec, }