Skip to content

Commit

Permalink
set conversion of blocktag latest to sn pending (#816)
Browse files Browse the repository at this point in the history
* set conversion of blocktag latest to sn pending

* transform pending blocks into pending blocks

* clean up
  • Loading branch information
Eikix authored Mar 4, 2024
1 parent b16c70c commit 2ab07e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/eth_provider/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,10 @@ where
match tag {
BlockNumberOrTag::Earliest => Ok(U64::ZERO),
BlockNumberOrTag::Number(number) => Ok(U64::from(number)),
BlockNumberOrTag::Latest | BlockNumberOrTag::Finalized | BlockNumberOrTag::Safe => {
self.block_number().await
}
BlockNumberOrTag::Pending => todo!("pending block number not implemented"),
BlockNumberOrTag::Latest
| BlockNumberOrTag::Finalized
| BlockNumberOrTag::Safe
| BlockNumberOrTag::Pending => self.block_number().await,
}
}
}
8 changes: 5 additions & 3 deletions src/models/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ impl From<EthBlockNumberOrTag> for StarknetBlockId {
fn from(block_number_or_tag: EthBlockNumberOrTag) -> Self {
let block_number_or_tag = block_number_or_tag.into();
match block_number_or_tag {
BlockNumberOrTag::Safe | BlockNumberOrTag::Latest | BlockNumberOrTag::Finalized => {
Self::Tag(BlockTag::Latest)
BlockNumberOrTag::Latest | BlockNumberOrTag::Pending => {
// We set to pending because in Starknet, a pending block is an unsealed block,
// With a centralized sequencer, the latest block is the pending block being filled.
Self::Tag(BlockTag::Pending)
}
BlockNumberOrTag::Safe | BlockNumberOrTag::Finalized => Self::Tag(BlockTag::Latest),
BlockNumberOrTag::Earliest => Self::Number(0),
BlockNumberOrTag::Pending => Self::Tag(BlockTag::Pending),
BlockNumberOrTag::Number(number) => Self::Number(number),
}
}
Expand Down

0 comments on commit 2ab07e6

Please sign in to comment.