Skip to content

Commit

Permalink
feat(sequencer): add get_state_update_with_block (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcaron authored Jul 16, 2024
1 parent b8a0003 commit bd7c629
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
18 changes: 18 additions & 0 deletions starknet-providers/src/sequencer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,24 @@ impl SequencerGatewayProvider {
.into()
}

#[deprecated(
note = "Sequencer-specific functions are deprecated. Use it via the Provider trait instead."
)]
pub async fn get_state_update_with_block(
&self,
block_identifier: BlockId,
) -> Result<StateUpdateWithBlock, ProviderError> {
let mut request_url = self.extend_feeder_gateway_url("get_state_update");
append_block_id(&mut request_url, block_identifier);
request_url
.query_pairs_mut()
.append_pair("includeBlock", "true");

self.send_get_request::<GatewayResponse<_>>(request_url)
.await?
.into()
}

#[deprecated(
note = "Sequencer-specific functions are deprecated. Use it via the Provider trait instead."
)]
Expand Down
2 changes: 1 addition & 1 deletion starknet-providers/src/sequencer/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod contract;
pub use contract::{CompressedLegacyContractClass, DeployedClass};

pub mod state_update;
pub use state_update::StateUpdate;
pub use state_update::{StateUpdate, StateUpdateWithBlock};

pub mod trace;
pub use trace::{BlockTraces, TransactionTrace};
Expand Down
10 changes: 10 additions & 0 deletions starknet-providers/src/sequencer/models/state_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ use serde_with::serde_as;
use starknet_core::{serde::unsigned_field_element::UfeHex, types::Felt};
use std::collections::HashMap;

use super::Block;

#[serde_as]
#[derive(Debug, Deserialize)]
#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
pub struct StateUpdateWithBlock {
pub state_update: StateUpdate,
pub block: Block,
}

#[serde_as]
#[derive(Debug, Deserialize)]
#[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))]
Expand Down

0 comments on commit bd7c629

Please sign in to comment.