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

Commit 0a73bb2

Browse files
add new_with_hinted_class_hash method for contract class (#806)
1 parent 7d9b7a6 commit 0a73bb2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/services/api/contract_classes/deprecated_contract_class.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,28 @@ impl ContractClass {
106106
})
107107
}
108108

109+
pub fn new_with_hinted_class_hash(
110+
hinted_class_hash: Felt252,
111+
program: Program,
112+
entry_points_by_type: HashMap<EntryPointType, Vec<ContractEntryPoint>>,
113+
abi: Option<AbiType>,
114+
) -> Result<Self, ContractClassError> {
115+
for entry_points in entry_points_by_type.values() {
116+
for i in 1..entry_points.len() {
117+
if entry_points[i - 1].selector() > entry_points[i].selector() {
118+
return Err(ContractClassError::EntrypointError(entry_points.clone()));
119+
}
120+
}
121+
}
122+
123+
Ok(ContractClass {
124+
hinted_class_hash,
125+
program,
126+
entry_points_by_type,
127+
abi,
128+
})
129+
}
130+
109131
/// Parses a [`ContractClass`] from a compiled Cairo 0 program's JSON
110132
/// at the given file path.
111133
pub fn from_path<F>(path: F) -> Result<Self, ProgramError>

0 commit comments

Comments
 (0)