Skip to content

Commit

Permalink
apply formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Oct 1, 2024
1 parent c572c3f commit b45a338
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 14 additions & 10 deletions crates/gateway-types/src/class_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ pub mod from_parts {
}
}


pub fn compute_cairo_hinted_class_hash(contract_definition: &json::CairoContractDefinition) -> Result<Felt> {
pub fn compute_cairo_hinted_class_hash(
contract_definition: &json::CairoContractDefinition<'_>,
) -> Result<Felt> {
use std::io::Write;

// It's less efficient than tweaking the formatter to emit the encoding but I
Expand All @@ -179,18 +180,21 @@ pub fn compute_cairo_hinted_class_hash(contract_definition: &json::CairoContract
Ok(truncated_keccak(<[u8; 32]>::from(hash.finalize())))
}

/// Prepares the JSON contract definition for hash calculation by removing unnecessary fields and
/// ensuring consistency in formatting.
/// Prepares the JSON contract definition for hash calculation by removing
/// unnecessary fields and ensuring consistency in formatting.
///
/// This function modifies the input `contract_definition` to ensure it is in a suitable state for
/// calculating the class hash. It removes the `debug_info` field, checks and removes "accessible_scopes"
/// and "flow_tracking_data" fields if they are empty or null, and applies a backwards compatibility
/// hack for missing `compiler_version` by adding extra space to named tuple type definitions.
/// This function modifies the input `contract_definition` to ensure it is in a
/// suitable state for calculating the class hash. It removes the `debug_info`
/// field, checks and removes "accessible_scopes" and "flow_tracking_data"
/// fields if they are empty or null, and applies a backwards compatibility hack
/// for missing `compiler_version` by adding extra space to named tuple type
/// definitions.
///
/// # Errors
///
/// This function returns an error if it fails to modify the contract definition, such as when an
/// attribute is not an object or when "accessible_scopes" is not an array type.
/// This function returns an error if it fails to modify the contract
/// definition, such as when an attribute is not an object or when
/// "accessible_scopes" is not an array type.
pub fn prepare_json_contract_definition(
contract_definition: &mut json::CairoContractDefinition<'_>,
) -> Result<(), anyhow::Error> {
Expand Down
2 changes: 0 additions & 2 deletions crates/merkle-tree/src/class.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use anyhow::Context;
use bitvec::order::Msb0;
use bitvec::prelude::BitSlice;
use pathfinder_common::hash::PoseidonHash;
use pathfinder_common::trie::TrieNode;
use pathfinder_common::{
Expand Down

0 comments on commit b45a338

Please sign in to comment.