diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs index af884f2a37..9341807f78 100644 --- a/crates/dojo-lang/src/plugin.rs +++ b/crates/dojo-lang/src/plugin.rs @@ -70,11 +70,7 @@ impl GeneratedFileAuxData for DojoAuxData { self } fn eq(&self, other: &dyn GeneratedFileAuxData) -> bool { - if let Some(other) = other.as_any().downcast_ref::() { - self == other - } else { - false - } + if let Some(other) = other.as_any().downcast_ref::() { self == other } else { false } } } @@ -92,11 +88,7 @@ impl GeneratedFileAuxData for ComputedValuesAuxData { self } fn eq(&self, other: &dyn GeneratedFileAuxData) -> bool { - if let Some(other) = other.as_any().downcast_ref::() { - self == other - } else { - false - } + if let Some(other) = other.as_any().downcast_ref::() { self == other } else { false } } } diff --git a/crates/dojo-world/src/migration/class.rs b/crates/dojo-world/src/migration/class.rs index b06cfc3d89..dfcb98acb5 100644 --- a/crates/dojo-world/src/migration/class.rs +++ b/crates/dojo-world/src/migration/class.rs @@ -16,11 +16,7 @@ pub struct ClassDiff { impl StateDiff for ClassDiff { fn is_same(&self) -> bool { - if let Some(remote) = self.remote { - self.local == remote - } else { - false - } + if let Some(remote) = self.remote { self.local == remote } else { false } } } diff --git a/crates/dojo-world/src/migration/contract.rs b/crates/dojo-world/src/migration/contract.rs index 6a1f099b2b..ee8fc2dae7 100644 --- a/crates/dojo-world/src/migration/contract.rs +++ b/crates/dojo-world/src/migration/contract.rs @@ -18,11 +18,7 @@ pub struct ContractDiff { impl StateDiff for ContractDiff { fn is_same(&self) -> bool { - if let Some(remote) = self.remote { - self.local == remote - } else { - false - } + if let Some(remote) = self.remote { self.local == remote } else { false } } } diff --git a/crates/katana/core/src/sequencer.rs b/crates/katana/core/src/sequencer.rs index 37b9fe1d7a..790be10c69 100644 --- a/crates/katana/core/src/sequencer.rs +++ b/crates/katana/core/src/sequencer.rs @@ -286,13 +286,10 @@ impl KatanaSequencer { let tx @ Some(_) = tx else { return Ok(self.pending_executor().as_ref().and_then(|exec| { - exec.read().transactions().iter().find_map(|tx| { - if tx.0.hash == *hash { - Some(tx.0.clone()) - } else { - None - } - }) + exec.read() + .transactions() + .iter() + .find_map(|tx| if tx.0.hash == *hash { Some(tx.0.clone()) } else { None }) })); }; diff --git a/crates/katana/executor/src/implementation/blockifier/state.rs b/crates/katana/executor/src/implementation/blockifier/state.rs index 35418afcad..074e52dad2 100644 --- a/crates/katana/executor/src/implementation/blockifier/state.rs +++ b/crates/katana/executor/src/implementation/blockifier/state.rs @@ -169,11 +169,7 @@ impl StateProvider for CachedState { }; let hash = hash.0.into(); - if hash == FieldElement::ZERO { - Ok(None) - } else { - Ok(Some(hash)) - } + if hash == FieldElement::ZERO { Ok(None) } else { Ok(Some(hash)) } } fn nonce( diff --git a/crates/katana/executor/src/implementation/sir/state.rs b/crates/katana/executor/src/implementation/sir/state.rs index 0c41fa23e3..74bd309692 100644 --- a/crates/katana/executor/src/implementation/sir/state.rs +++ b/crates/katana/executor/src/implementation/sir/state.rs @@ -553,10 +553,9 @@ mod tests { ClassHash::default(), "class hash of nonexistant contract should default to zero" ); - assert!(actual_compiled_hash - .unwrap_err() - .to_string() - .contains("No compiled class hash found")); + assert!( + actual_compiled_hash.unwrap_err().to_string().contains("No compiled class hash found") + ); assert!(actual_compiled_class.unwrap_err().to_string().contains("No compiled class found")); let sp: Box = Box::new(cached_state); diff --git a/crates/katana/primitives/src/genesis/json.rs b/crates/katana/primitives/src/genesis/json.rs index 039f7cfbb1..ffa9f59a9e 100644 --- a/crates/katana/primitives/src/genesis/json.rs +++ b/crates/katana/primitives/src/genesis/json.rs @@ -1088,10 +1088,12 @@ mod tests { fn genesis_from_json_with_unresolved_paths() { let file = File::open("./src/genesis/test-genesis.json").unwrap(); let json: GenesisJson = serde_json::from_reader(file).unwrap(); - assert!(Genesis::try_from(json) - .unwrap_err() - .to_string() - .contains("Unresolved class artifact path")); + assert!( + Genesis::try_from(json) + .unwrap_err() + .to_string() + .contains("Unresolved class artifact path") + ); } #[test] diff --git a/crates/katana/rpc/rpc-api/src/torii.rs b/crates/katana/rpc/rpc-api/src/torii.rs index 3308806004..272497041a 100644 --- a/crates/katana/rpc/rpc-api/src/torii.rs +++ b/crates/katana/rpc/rpc-api/src/torii.rs @@ -7,5 +7,5 @@ use katana_rpc_types::transaction::{TransactionsPage, TransactionsPageCursor}; pub trait ToriiApi { #[method(name = "getTransactions")] async fn get_transactions(&self, cursor: TransactionsPageCursor) - -> RpcResult; + -> RpcResult; } diff --git a/crates/katana/storage/db/src/mdbx/cursor.rs b/crates/katana/storage/db/src/mdbx/cursor.rs index e08ca8499a..9cac3876e3 100644 --- a/crates/katana/storage/db/src/mdbx/cursor.rs +++ b/crates/katana/storage/db/src/mdbx/cursor.rs @@ -304,11 +304,7 @@ impl Walker<'_, RW, T> { impl std::iter::Iterator for Walker<'_, K, T> { type Item = Result, DatabaseError>; fn next(&mut self) -> Option { - if let value @ Some(_) = self.start.take() { - value - } else { - self.cursor.next().transpose() - } + if let value @ Some(_) = self.start.take() { value } else { self.cursor.next().transpose() } } } diff --git a/crates/katana/storage/provider/src/providers/db/state.rs b/crates/katana/storage/provider/src/providers/db/state.rs index e72f3ddffc..381e60063c 100644 --- a/crates/katana/storage/provider/src/providers/db/state.rs +++ b/crates/katana/storage/provider/src/providers/db/state.rs @@ -183,11 +183,7 @@ impl HistoricalStateProvider { // then that means there is no change happening before the pinned block number. let pos = { if let Some(pos) = block_list.last().and_then(|num| { - if block_number >= *num { - Some(block_list.len() - 1) - } else { - None - } + if block_number >= *num { Some(block_list.len() - 1) } else { None } }) { Some(pos) } else { diff --git a/crates/katana/storage/provider/src/traits/contract.rs b/crates/katana/storage/provider/src/traits/contract.rs index b0a09d61aa..7ff77f1999 100644 --- a/crates/katana/storage/provider/src/traits/contract.rs +++ b/crates/katana/storage/provider/src/traits/contract.rs @@ -40,5 +40,5 @@ pub trait ContractClassWriter: Send + Sync { /// Retrieves the Sierra class definition of a contract class given its class hash. fn set_sierra_class(&self, hash: ClassHash, sierra: FlattenedSierraClass) - -> ProviderResult<()>; + -> ProviderResult<()>; } diff --git a/crates/katana/storage/provider/src/traits/state.rs b/crates/katana/storage/provider/src/traits/state.rs index c18d4f72d1..3ec9aade09 100644 --- a/crates/katana/storage/provider/src/traits/state.rs +++ b/crates/katana/storage/provider/src/traits/state.rs @@ -26,7 +26,7 @@ pub trait StateProvider: ContractClassProvider + Send + Sync { /// Returns the class hash of a contract. fn class_hash_of_contract(&self, address: ContractAddress) - -> ProviderResult>; + -> ProviderResult>; } /// A type which can create [`StateProvider`] for states at a particular block. diff --git a/crates/sozo/ops/src/migration/migration_test.rs b/crates/sozo/ops/src/migration/migration_test.rs index 3e9cce677c..5bff89e52c 100644 --- a/crates/sozo/ops/src/migration/migration_test.rs +++ b/crates/sozo/ops/src/migration/migration_test.rs @@ -90,14 +90,16 @@ async fn migrate_with_small_fee_multiplier_will_fail() { ExecutionEncoding::New, ); - assert!(execute_strategy( - &ws, - &migration, - &account, - Some(TxConfig { fee_estimate_multiplier: Some(0.2f64), wait: false, receipt: false }), - ) - .await - .is_err()); + assert!( + execute_strategy( + &ws, + &migration, + &account, + Some(TxConfig { fee_estimate_multiplier: Some(0.2f64), wait: false, receipt: false }), + ) + .await + .is_err() + ); sequencer.stop().unwrap(); } diff --git a/crates/sozo/ops/src/tests/call.rs b/crates/sozo/ops/src/tests/call.rs index 8938a6e8b6..331215c03f 100644 --- a/crates/sozo/ops/src/tests/call.rs +++ b/crates/sozo/ops/src/tests/call.rs @@ -23,15 +23,17 @@ async fn call_with_bad_address() { let provider = sequencer.provider(); let world_reader = WorldContractReader::new(world.address, provider); - assert!(call::call( - world_reader, - "0xBadCoffeeBadCode".to_string(), - ENTRYPOINT.to_string(), - vec![FieldElement::ZERO, FieldElement::ZERO], - None - ) - .await - .is_err()); + assert!( + call::call( + world_reader, + "0xBadCoffeeBadCode".to_string(), + ENTRYPOINT.to_string(), + vec![FieldElement::ZERO, FieldElement::ZERO], + None + ) + .await + .is_err() + ); } #[tokio::test] @@ -43,15 +45,17 @@ async fn call_with_bad_name() { let provider = sequencer.provider(); let world_reader = WorldContractReader::new(world.address, provider); - assert!(call::call( - world_reader, - "BadName".to_string(), - ENTRYPOINT.to_string(), - vec![FieldElement::ZERO, FieldElement::ZERO], - None - ) - .await - .is_err()); + assert!( + call::call( + world_reader, + "BadName".to_string(), + ENTRYPOINT.to_string(), + vec![FieldElement::ZERO, FieldElement::ZERO], + None + ) + .await + .is_err() + ); } #[tokio::test] @@ -63,15 +67,17 @@ async fn call_with_bad_entrypoint() { let provider = sequencer.provider(); let world_reader = WorldContractReader::new(world.address, provider); - assert!(call::call( - world_reader, - CONTRACT_NAME.to_string(), - "BadEntryPoint".to_string(), - vec![FieldElement::ZERO, FieldElement::ZERO], - None - ) - .await - .is_err()); + assert!( + call::call( + world_reader, + CONTRACT_NAME.to_string(), + "BadEntryPoint".to_string(), + vec![FieldElement::ZERO, FieldElement::ZERO], + None + ) + .await + .is_err() + ); } #[tokio::test] @@ -83,15 +89,11 @@ async fn call_with_bad_calldata() { let provider = sequencer.provider(); let world_reader = WorldContractReader::new(world.address, provider); - assert!(call::call( - world_reader, - CONTRACT_NAME.to_string(), - ENTRYPOINT.to_string(), - vec![], - None - ) - .await - .is_err()); + assert!( + call::call(world_reader, CONTRACT_NAME.to_string(), ENTRYPOINT.to_string(), vec![], None) + .await + .is_err() + ); } #[tokio::test] @@ -103,15 +105,17 @@ async fn call_with_contract_name() { let provider = sequencer.provider(); let world_reader = WorldContractReader::new(world.address, provider); - assert!(call::call( - world_reader, - CONTRACT_NAME.to_string(), - ENTRYPOINT.to_string(), - vec![FieldElement::ZERO, FieldElement::ZERO], - None, - ) - .await - .is_ok()); + assert!( + call::call( + world_reader, + CONTRACT_NAME.to_string(), + ENTRYPOINT.to_string(), + vec![FieldElement::ZERO, FieldElement::ZERO], + None, + ) + .await + .is_ok() + ); } #[tokio::test] @@ -129,13 +133,15 @@ async fn call_with_contract_address() { .await .unwrap(); - assert!(call::call( - world_reader, - format!("{:#x}", contract_address), - ENTRYPOINT.to_string(), - vec![FieldElement::ZERO, FieldElement::ZERO], - None, - ) - .await - .is_ok()); + assert!( + call::call( + world_reader, + format!("{:#x}", contract_address), + ENTRYPOINT.to_string(), + vec![FieldElement::ZERO, FieldElement::ZERO], + None, + ) + .await + .is_ok() + ); } diff --git a/crates/torii/client/src/client/storage.rs b/crates/torii/client/src/client/storage.rs index caa00dee5c..48541a2314 100644 --- a/crates/torii/client/src/client/storage.rs +++ b/crates/torii/client/src/client/storage.rs @@ -264,8 +264,10 @@ mod tests { ); assert!(actual_values == expected_values); assert!(storage.storage.read().len() == model.packed_size as usize); - assert!(actual_storage_addresses - .into_iter() - .all(|address| expected_storage_addresses.contains(&address))); + assert!( + actual_storage_addresses + .into_iter() + .all(|address| expected_storage_addresses.contains(&address)) + ); } } diff --git a/crates/torii/client/src/client/subscription.rs b/crates/torii/client/src/client/subscription.rs index b167e6a614..ac21707104 100644 --- a/crates/torii/client/src/client/subscription.rs +++ b/crates/torii/client/src/client/subscription.rs @@ -192,11 +192,7 @@ impl SubscriptionService { let storage_entries = diff.storage_diffs.into_iter().find_map(|d| { let expected = self.world_metadata.read().world_address; let current = d.address; - if current == expected { - Some(d.storage_entries) - } else { - None - } + if current == expected { Some(d.storage_entries) } else { None } }); let Some(entries) = storage_entries else { diff --git a/crates/torii/graphql/src/object/entity.rs b/crates/torii/graphql/src/object/entity.rs index 209fd28141..dd73c9c6fd 100644 --- a/crates/torii/graphql/src/object/entity.rs +++ b/crates/torii/graphql/src/object/entity.rs @@ -63,10 +63,8 @@ impl ResolvableObject for EntityObject { } fn subscriptions(&self) -> Option> { - Some(vec![SubscriptionField::new( - "entityUpdated", - TypeRef::named_nn(self.type_name()), - |ctx| { + Some(vec![ + SubscriptionField::new("entityUpdated", TypeRef::named_nn(self.type_name()), |ctx| { SubscriptionFieldFuture::new(async move { let id = match ctx.args.get("id") { Some(id) => Some(id.string()?.to_string()), @@ -83,9 +81,9 @@ impl ResolvableObject for EntityObject { } })) }) - }, - ) - .argument(InputValue::new("id", TypeRef::named(TypeRef::ID)))]) + }) + .argument(InputValue::new("id", TypeRef::named(TypeRef::ID))), + ]) } } diff --git a/crates/torii/graphql/src/object/event.rs b/crates/torii/graphql/src/object/event.rs index 975d98afe9..f0063f76c1 100644 --- a/crates/torii/graphql/src/object/event.rs +++ b/crates/torii/graphql/src/object/event.rs @@ -44,17 +44,15 @@ impl ResolvableObject for EventObject { } fn subscriptions(&self) -> Option> { - Some(vec![SubscriptionField::new( - "eventEmitted", - TypeRef::named_nn(self.type_name()), - |ctx| { + Some(vec![ + SubscriptionField::new("eventEmitted", TypeRef::named_nn(self.type_name()), |ctx| { SubscriptionFieldFuture::new(async move { let input_keys = parse_keys_argument(&ctx)?; Ok(EventObject::subscription_stream(input_keys)) }) - }, - ) - .argument(InputValue::new("keys", TypeRef::named_list(TypeRef::STRING)))]) + }) + .argument(InputValue::new("keys", TypeRef::named_list(TypeRef::STRING))), + ]) } } diff --git a/crates/torii/graphql/src/object/event_message.rs b/crates/torii/graphql/src/object/event_message.rs index 7f3b1c9765..fcc3c77369 100644 --- a/crates/torii/graphql/src/object/event_message.rs +++ b/crates/torii/graphql/src/object/event_message.rs @@ -63,29 +63,31 @@ impl ResolvableObject for EventMessageObject { } fn subscriptions(&self) -> Option> { - Some(vec![SubscriptionField::new( - "eventMessageUpdated", - TypeRef::named_nn(self.type_name()), - |ctx| { - SubscriptionFieldFuture::new(async move { - let id = match ctx.args.get("id") { - Some(id) => Some(id.string()?.to_string()), - None => None, - }; - // if id is None, then subscribe to all entities - // if id is Some, then subscribe to only the entity with that id - Ok(SimpleBroker::::subscribe().filter_map(move |entity: Entity| { - if id.is_none() || id == Some(entity.id.clone()) { - Some(Ok(Value::Object(EventMessageObject::value_mapping(entity)))) - } else { - // id != entity.id , then don't send anything, still listening - None - } - })) - }) - }, - ) - .argument(InputValue::new("id", TypeRef::named(TypeRef::ID)))]) + Some(vec![ + SubscriptionField::new( + "eventMessageUpdated", + TypeRef::named_nn(self.type_name()), + |ctx| { + SubscriptionFieldFuture::new(async move { + let id = match ctx.args.get("id") { + Some(id) => Some(id.string()?.to_string()), + None => None, + }; + // if id is None, then subscribe to all entities + // if id is Some, then subscribe to only the entity with that id + Ok(SimpleBroker::::subscribe().filter_map(move |entity: Entity| { + if id.is_none() || id == Some(entity.id.clone()) { + Some(Ok(Value::Object(EventMessageObject::value_mapping(entity)))) + } else { + // id != entity.id , then don't send anything, still listening + None + } + })) + }) + }, + ) + .argument(InputValue::new("id", TypeRef::named(TypeRef::ID))), + ]) } } diff --git a/crates/torii/graphql/src/object/model.rs b/crates/torii/graphql/src/object/model.rs index 4b326b0207..a9ecb13607 100644 --- a/crates/torii/graphql/src/object/model.rs +++ b/crates/torii/graphql/src/object/model.rs @@ -74,10 +74,8 @@ impl ResolvableObject for ModelObject { } fn subscriptions(&self) -> Option> { - Some(vec![SubscriptionField::new( - "modelRegistered", - TypeRef::named_nn(self.type_name()), - |ctx| { + Some(vec![ + SubscriptionField::new("modelRegistered", TypeRef::named_nn(self.type_name()), |ctx| { { SubscriptionFieldFuture::new(async move { let id = match ctx.args.get("id") { @@ -96,9 +94,9 @@ impl ResolvableObject for ModelObject { })) }) } - }, - ) - .argument(InputValue::new("id", TypeRef::named(TypeRef::ID)))]) + }) + .argument(InputValue::new("id", TypeRef::named(TypeRef::ID))), + ]) } } diff --git a/crates/torii/libp2p/src/typed_data.rs b/crates/torii/libp2p/src/typed_data.rs index 19226b32fc..4dec9753e9 100644 --- a/crates/torii/libp2p/src/typed_data.rs +++ b/crates/torii/libp2p/src/typed_data.rs @@ -150,11 +150,7 @@ pub fn encode_type(name: &str, types: &IndexMap>) -> Result>() .join(",");