Fetches the safe head hash from the oracle.
(
oracle: &O,
agreed_l2_output_root: B256,
)
| 61 | impl SafeHeadFetcher { |
| 62 | /// Fetches the safe head hash from the oracle. |
| 63 | pub async fn fetch<O>( |
| 64 | oracle: &O, |
| 65 | agreed_l2_output_root: B256, |
| 66 | ) -> Result<B256, OracleProviderError> |
| 67 | where |
| 68 | O: PreimageOracleClient + Send, |
| 69 | { |
| 70 | let preimage = oracle |
| 71 | .get(PreimageKey::new_keccak256(*agreed_l2_output_root)) |
| 72 | .await |
| 73 | .map_err(OracleProviderError::Preimage)?; |
| 74 | OutputRoot::decode(&preimage) |
| 75 | .map(|root| root.block_hash) |
| 76 | .ok_or(OracleProviderError::InvalidOutputRootPreimage) |
| 77 | } |
| 78 | } |