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

add new_with_hinted_class_hash method for contract class #806

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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