Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
dev: Get the block status from the actual block in get_block_with_tx_…
Browse files Browse the repository at this point in the history
…hashes (#1402)
  • Loading branch information
azurwastaken authored Jan 25, 2024
1 parent 30980a4 commit 0d0e846
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,4 @@
- feat: add a `genesis_loader` for the node and mocking
- feat: add `madara_tsukuyomi` as a submodule
- branding: use new logo in the README
- dev: Get the block status from the actual block in get_block_with_tx_hashes
16 changes: 14 additions & 2 deletions crates/client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,24 @@ where
} else {
starknet_block.transactions_hashes::<H>(chain_id.0.into()).map(FieldElement::from).collect()
};
let block_status = match self.backend.messaging().last_synced_l1_block_with_event() {
Ok(l1_block) => {
if l1_block.block_number >= starknet_block.header().block_number {
BlockStatus::AcceptedOnL1
} else {
BlockStatus::AcceptedOnL2
}
}
Err(e) => {
error!("Failed to get last synced l1 block, error: {e}");
Err(StarknetRpcApiError::InternalServerError)?
}
};

let parent_blockhash = starknet_block.header().parent_block_hash;
let block_with_tx_hashes = BlockWithTxHashes {
transactions: transaction_hashes,
// TODO: Status hardcoded, get status from block
status: BlockStatus::AcceptedOnL2,
status: block_status,
block_hash: block_hash.into(),
parent_hash: Felt252Wrapper::from(parent_blockhash).into(),
block_number: starknet_block.header().block_number,
Expand Down

0 comments on commit 0d0e846

Please sign in to comment.