chore: dont panic on unsupported tag (#2578)

This commit is contained in:
Matthias Seitz
2023-05-05 17:05:46 +02:00
committed by GitHub
parent b40ce6f7f7
commit a00ba2ad7b
2 changed files with 7 additions and 6 deletions

View File

@ -92,4 +92,9 @@ pub enum ProviderError {
/// Unable to compute state root on top of historical block
#[error("Unable to compute state root on top of historical block")]
StateRootNotAvailableForHistoricalBlock,
#[error("Safe tag currently unsupported")]
SafeTagUnsupported,
#[error("Finalized tag currently unsupported")]
FinalizedTagUnsupported,
}

View File

@ -115,12 +115,8 @@ pub trait StateProviderFactory: Send + Sync {
) -> Result<StateProviderBox<'_>> {
match number_or_tag {
BlockNumberOrTag::Latest => self.latest(),
BlockNumberOrTag::Finalized => {
todo!()
}
BlockNumberOrTag::Safe => {
todo!()
}
BlockNumberOrTag::Finalized => Err(ProviderError::FinalizedTagUnsupported.into()),
BlockNumberOrTag::Safe => Err(ProviderError::SafeTagUnsupported.into()),
BlockNumberOrTag::Earliest => self.history_by_block_number(0),
BlockNumberOrTag::Pending => self.pending(),
BlockNumberOrTag::Number(num) => self.history_by_block_number(num),