From 288136478b029f8d65f69b8b1390b190fb6bfefa Mon Sep 17 00:00:00 2001 From: SantiagoPittella Date: Mon, 10 Jul 2023 17:59:14 -0300 Subject: [PATCH] add new_with_hinted_class_hash method for contract class --- .../deprecated_contract_class.rs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/services/api/contract_classes/deprecated_contract_class.rs b/src/services/api/contract_classes/deprecated_contract_class.rs index dcdcf3278..6af8a1ca1 100644 --- a/src/services/api/contract_classes/deprecated_contract_class.rs +++ b/src/services/api/contract_classes/deprecated_contract_class.rs @@ -106,6 +106,28 @@ impl ContractClass { }) } + pub fn new_with_hinted_class_hash( + hinted_class_hash: Felt252, + program: Program, + entry_points_by_type: HashMap>, + abi: Option, + ) -> Result { + 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(path: F) -> Result