Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Sep 16, 2024
1 parent 965b04a commit 3b49bc9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 33 deletions.
12 changes: 2 additions & 10 deletions crates/katana/executor/src/implementation/blockifier/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ impl<S: StateDb> ContractClassProvider for CachedState<S> {
return Ok(None);
};

if hash.0 == Felt::ZERO {
Ok(None)
} else {
Ok(Some(hash.0))
}
if hash.0 == Felt::ZERO { Ok(None) } else { Ok(Some(hash.0)) }
}
fn sierra_class(
&self,
Expand All @@ -157,11 +153,7 @@ impl<S: StateDb> StateProvider for CachedState<S> {
return Ok(None);
};

if hash.0 == Felt::ZERO {
Ok(None)
} else {
Ok(Some(hash.0))
}
if hash.0 == Felt::ZERO { Ok(None) } else { Ok(Some(hash.0)) }
}

fn nonce(
Expand Down
6 changes: 1 addition & 5 deletions crates/katana/executor/tests/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ fn test_executor_with_valid_blocks_impl<EF: ExecutorFactory>(

// ensure that all transactions succeeded, if not panic with the error message and tx index
let has_failed = transactions.iter().enumerate().find_map(|(i, (_, res))| {
if let ExecutionResult::Failed { error } = res {
Some((i, error))
} else {
None
}
if let ExecutionResult::Failed { error } = res { Some((i, error)) } else { None }
});

if let Some((pos, error)) = has_failed {
Expand Down
17 changes: 9 additions & 8 deletions crates/katana/primitives/src/genesis/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,10 +1215,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]
Expand Down Expand Up @@ -1262,9 +1264,8 @@ mod tests {
.expect("failed to load genesis file");

let res = Genesis::try_from(json);
assert!(res
.unwrap_err()
.to_string()
.contains(&format!("Class name '{name}' already exists")))
assert!(
res.unwrap_err().to_string().contains(&format!("Class name '{name}' already exists"))
)
}
}
14 changes: 7 additions & 7 deletions crates/katana/primitives/src/utils/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn compute_deploy_account_v1_tx_hash(

compute_hash_on_elements(&[
PREFIX_DEPLOY_ACCOUNT,
if is_query { QUERY_VERSION_OFFSET + Felt::ONE } else { Felt::ONE }, /* version */
if is_query { QUERY_VERSION_OFFSET + Felt::ONE } else { Felt::ONE }, // version
sender_address,
Felt::ZERO, // entry_point_selector
compute_hash_on_elements(&calldata_to_hash),
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn compute_deploy_account_v3_tx_hash(
) -> Felt {
poseidon_hash_many(&[
PREFIX_DEPLOY_ACCOUNT,
if is_query { QUERY_VERSION_OFFSET + Felt::THREE } else { Felt::THREE }, /* version */
if is_query { QUERY_VERSION_OFFSET + Felt::THREE } else { Felt::THREE }, // version
contract_address,
hash_fee_fields(tip, l1_gas_bounds, l2_gas_bounds),
poseidon_hash_many(paymaster_data),
Expand All @@ -110,7 +110,7 @@ pub fn compute_declare_v1_tx_hash(
) -> Felt {
compute_hash_on_elements(&[
PREFIX_DECLARE,
if is_query { QUERY_VERSION_OFFSET + Felt::ONE } else { Felt::ONE }, /* version */
if is_query { QUERY_VERSION_OFFSET + Felt::ONE } else { Felt::ONE }, // version
sender_address,
Felt::ZERO, // entry_point_selector
compute_hash_on_elements(&[class_hash]),
Expand All @@ -132,7 +132,7 @@ pub fn compute_declare_v2_tx_hash(
) -> Felt {
compute_hash_on_elements(&[
PREFIX_DECLARE,
if is_query { QUERY_VERSION_OFFSET + Felt::TWO } else { Felt::TWO }, /* version */
if is_query { QUERY_VERSION_OFFSET + Felt::TWO } else { Felt::TWO }, // version
sender_address,
Felt::ZERO, // entry_point_selector
compute_hash_on_elements(&[class_hash]),
Expand Down Expand Up @@ -162,7 +162,7 @@ pub fn compute_declare_v3_tx_hash(
) -> Felt {
poseidon_hash_many(&[
PREFIX_DECLARE,
if is_query { QUERY_VERSION_OFFSET + Felt::THREE } else { Felt::THREE }, /* version */
if is_query { QUERY_VERSION_OFFSET + Felt::THREE } else { Felt::THREE }, // version
sender_address,
hash_fee_fields(tip, l1_gas_bounds, l2_gas_bounds),
poseidon_hash_many(paymaster_data),
Expand All @@ -186,7 +186,7 @@ pub fn compute_invoke_v1_tx_hash(
) -> Felt {
compute_hash_on_elements(&[
PREFIX_INVOKE,
if is_query { QUERY_VERSION_OFFSET + Felt::ONE } else { Felt::ONE }, /* version */
if is_query { QUERY_VERSION_OFFSET + Felt::ONE } else { Felt::ONE }, // version
sender_address,
Felt::ZERO, // entry_point_selector
compute_hash_on_elements(calldata),
Expand Down Expand Up @@ -214,7 +214,7 @@ pub fn compute_invoke_v3_tx_hash(
) -> Felt {
poseidon_hash_many(&[
PREFIX_INVOKE,
if is_query { QUERY_VERSION_OFFSET + Felt::THREE } else { Felt::THREE }, /* version */
if is_query { QUERY_VERSION_OFFSET + Felt::THREE } else { Felt::THREE }, // version
sender_address,
hash_fee_fields(tip, l1_gas_bounds, l2_gas_bounds),
poseidon_hash_many(paymaster_data),
Expand Down
2 changes: 1 addition & 1 deletion crates/katana/rpc/rpc-api/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait DevApi {

#[method(name = "setStorageAt")]
async fn set_storage_at(&self, contract_address: Felt, key: Felt, value: Felt)
-> RpcResult<()>;
-> RpcResult<()>;

#[method(name = "predeployedAccounts")]
async fn predeployed_accounts(&self) -> RpcResult<Vec<Account>>;
Expand Down
2 changes: 1 addition & 1 deletion crates/katana/rpc/rpc-api/src/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub trait StarknetApi {
/// Get the contract class definition in the given block associated with the given hash.
#[method(name = "getClass")]
async fn get_class(&self, block_id: BlockIdOrTag, class_hash: Felt)
-> RpcResult<ContractClass>;
-> RpcResult<ContractClass>;

/// Get the contract class hash in the given block for the contract deployed at the given
/// address.
Expand Down
2 changes: 1 addition & 1 deletion crates/katana/storage/provider/src/traits/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait StateProvider: ContractClassProvider + Send + Sync + std::fmt::Debug {

/// Returns the class hash of a contract.
fn class_hash_of_contract(&self, address: ContractAddress)
-> ProviderResult<Option<ClassHash>>;
-> ProviderResult<Option<ClassHash>>;
}

/// A type which can create [`StateProvider`] for states at a particular block.
Expand Down

0 comments on commit 3b49bc9

Please sign in to comment.