Skip to content

Commit

Permalink
fix(katana-provider): handle not found err as None (starkware-libs#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored Dec 19, 2023
1 parent 85e92c3 commit bc42b8e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crates/katana/storage/provider/src/providers/fork/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,18 @@ impl ContractClassProvider for SharedStateProvider {
return Ok(hash.cloned());
}

let compiled_hash = self.0.do_get_compiled_class_hash(hash)?;
self.0.compiled_class_hashes.write().insert(hash, compiled_hash);

Ok(Some(hash))
if let Some(hash) =
handle_contract_or_class_not_found_err(self.0.do_get_compiled_class_hash(hash))
.map_err(|e| {
error!(target: "forked_backend", "error while fetching compiled class hash for class hash {hash:#x}: {e}");
e
})?
{
self.0.compiled_class_hashes.write().insert(hash, hash);
Ok(Some(hash))
} else {
Ok(None)
}
}

fn class(&self, hash: ClassHash) -> Result<Option<CompiledContractClass>> {
Expand Down

0 comments on commit bc42b8e

Please sign in to comment.