Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
add new_with_hinted_class_hash method for contract class (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiagoPittella authored Jul 11, 2023
1 parent 7d9b7a6 commit 0a73bb2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/services/api/contract_classes/deprecated_contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ impl ContractClass {
})
}

pub fn new_with_hinted_class_hash(
hinted_class_hash: Felt252,
program: Program,
entry_points_by_type: HashMap<EntryPointType, Vec<ContractEntryPoint>>,
abi: Option<AbiType>,
) -> Result<Self, ContractClassError> {
for entry_points in entry_points_by_type.values() {
for i in 1..entry_points.len() {
if entry_points[i - 1].selector() > entry_points[i].selector() {
return Err(ContractClassError::EntrypointError(entry_points.clone()));
}
}
}

Ok(ContractClass {
hinted_class_hash,
program,
entry_points_by_type,
abi,
})
}

/// Parses a [`ContractClass`] from a compiled Cairo 0 program's JSON
/// at the given file path.
pub fn from_path<F>(path: F) -> Result<Self, ProgramError>
Expand Down

0 comments on commit 0a73bb2

Please # to comment.