Struct starknet_devnet_core::starknet::Starknet
source · pub struct Starknet {
pub transactions: StarknetTransactions,
pub config: StarknetConfig,
pub pending_block_timestamp_shift: i64,
pub next_block_timestamp: Option<u64>,
/* private fields */
}
Fields§
§transactions: StarknetTransactions
§config: StarknetConfig
§pending_block_timestamp_shift: i64
§next_block_timestamp: Option<u64>
Implementations§
source§impl Starknet
impl Starknet
sourcepub async fn configure_messaging(
&mut self,
rpc_url: &str,
contract_address: Option<&str>
) -> DevnetResult<String>
pub async fn configure_messaging( &mut self, rpc_url: &str, contract_address: Option<&str> ) -> DevnetResult<String>
Configures the messaging from the given L1 node parameters. Calling this function multiple time will overwrite the previous configuration, if any.
§Arguments
rpc_url
- The L1 node RPC URL.contract_address
- The messaging contract address deployed on L1 node.
sourcepub fn get_ethereum_url(&self) -> Option<String>
pub fn get_ethereum_url(&self) -> Option<String>
Retrieves the ethereum node URL, if configured.
sourcepub fn set_latest_local_block(&self) -> Option<String>
pub fn set_latest_local_block(&self) -> Option<String>
Sets the latest local block processed by messaging.
sourcepub async fn collect_messages_to_l1(&mut self) -> DevnetResult<Vec<MessageToL1>>
pub async fn collect_messages_to_l1(&mut self) -> DevnetResult<Vec<MessageToL1>>
Collects all messages found between the current messaging latest block and the Latest Starknet block, including both blocks. This function register the messages in two fashions:
- Add each message to the
l2_to_l1_messages_to_flush
. - Increment the counter for the hash of each message into
l2_to_l1_messages_hashes
.
Returns all the messages currently collected and not flushed.
sourcepub async fn send_messages_to_l1(&mut self) -> DevnetResult<Vec<MessageToL1>>
pub async fn send_messages_to_l1(&mut self) -> DevnetResult<Vec<MessageToL1>>
Sends (flush) all the messages in l2_to_l1_messages_to_flush
to L1 node.
Returns the list of sent messages.
sourcepub async fn consume_l2_to_l1_message(
&mut self,
message: &MessageToL1
) -> DevnetResult<Hash256>
pub async fn consume_l2_to_l1_message( &mut self, message: &MessageToL1 ) -> DevnetResult<Hash256>
Consumes a MessageToL1
that is registered in l2_to_l1_messages
.
If the count related to the message is hash is already 0, an error is returned,
the message’s hash otherwise.
§Arguments
message
- The message to consume.
sourcepub async fn fetch_messages_to_l2(&mut self) -> DevnetResult<Vec<MessageToL2>>
pub async fn fetch_messages_to_l2(&mut self) -> DevnetResult<Vec<MessageToL2>>
Fetches all messages from L1 and converts the ethereum log into MessageToL2
.
sourcepub async fn execute_messages_to_l2(
&mut self,
messages: &[MessageToL2]
) -> DevnetResult<Vec<TransactionHash>>
pub async fn execute_messages_to_l2( &mut self, messages: &[MessageToL2] ) -> DevnetResult<Vec<TransactionHash>>
Executes all given MessageToL2
in a L1HandlerTransaction
.
§Arguments
messages
- Messages to execute.
source§impl Starknet
impl Starknet
pub fn re_execute(&mut self, events: Vec<DumpEvent>) -> DevnetResult<()>
pub fn handle_dump_event(&mut self, event: DumpEvent) -> DevnetResult<()>
sourcepub fn dump_event(&self, event: DumpEvent) -> DevnetResult<()>
pub fn dump_event(&self, event: DumpEvent) -> DevnetResult<()>
attach starknet event to end of existing file
pub fn dump_events(&self) -> DevnetResult<()>
sourcepub fn dump_events_custom_path(
&self,
custom_path: Option<String>
) -> DevnetResult<()>
pub fn dump_events_custom_path( &self, custom_path: Option<String> ) -> DevnetResult<()>
save starknet events to file
pub fn load_events(&self) -> DevnetResult<Vec<DumpEvent>>
pub fn load_events_custom_path( &self, custom_path: Option<String> ) -> DevnetResult<Vec<DumpEvent>>
source§impl Starknet
impl Starknet
pub fn new(config: &StarknetConfig) -> DevnetResult<Self>
pub fn restart(&mut self) -> DevnetResult<()>
pub fn get_predeployed_accounts(&self) -> Vec<Account>
pub fn get_class_hash_at( &self, block_id: &BlockId, contract_address: ContractAddress ) -> DevnetResult<ClassHash>
pub fn get_class( &self, block_id: &BlockId, class_hash: ClassHash ) -> DevnetResult<ContractClass>
pub fn get_class_at( &self, block_id: &BlockId, contract_address: ContractAddress ) -> DevnetResult<ContractClass>
pub fn call( &self, block_id: &BlockId, contract_address: Felt, entrypoint_selector: Felt, calldata: Vec<Felt> ) -> DevnetResult<Vec<Felt>>
pub fn estimate_fee( &self, block_id: &BlockId, transactions: &[BroadcastedTransaction], simulation_flags: &[SimulationFlag] ) -> DevnetResult<Vec<FeeEstimateWrapper>>
pub fn estimate_message_fee( &self, block_id: &BlockId, message: MsgFromL1 ) -> DevnetResult<FeeEstimateWrapper>
pub fn add_declare_transaction_v1( &mut self, declare_transaction: BroadcastedDeclareTransactionV1 ) -> DevnetResult<(TransactionHash, ClassHash)>
pub fn add_declare_transaction_v2( &mut self, declare_transaction: BroadcastedDeclareTransactionV2 ) -> DevnetResult<(TransactionHash, ClassHash)>
pub fn add_declare_transaction_v3( &mut self, declare_transaction: BroadcastedDeclareTransactionV3 ) -> DevnetResult<(TransactionHash, ClassHash)>
pub fn add_deploy_account_transaction_v1( &mut self, deploy_account_transaction: BroadcastedDeployAccountTransactionV1 ) -> DevnetResult<(TransactionHash, ContractAddress)>
pub fn add_deploy_account_transaction_v3( &mut self, deploy_account_transaction: BroadcastedDeployAccountTransactionV3 ) -> DevnetResult<(TransactionHash, ContractAddress)>
pub fn add_invoke_transaction_v1( &mut self, invoke_transaction: BroadcastedInvokeTransactionV1 ) -> DevnetResult<TransactionHash>
pub fn add_invoke_transaction_v3( &mut self, invoke_transaction: BroadcastedInvokeTransactionV3 ) -> DevnetResult<TransactionHash>
pub fn add_l1_handler_transaction( &mut self, l1_handler_transaction: L1HandlerTransaction ) -> DevnetResult<TransactionHash>
sourcepub async fn mint(
&mut self,
address: ContractAddress,
amount: u128,
erc20_address: ContractAddress
) -> DevnetResult<Felt>
pub async fn mint( &mut self, address: ContractAddress, amount: u128, erc20_address: ContractAddress ) -> DevnetResult<Felt>
Creates an invoke tx for minting, using the chargeable account.
pub fn block_state_update( &self, block_id: &BlockId ) -> DevnetResult<StateUpdate>
pub fn get_block_txs_count(&self, block_id: &BlockId) -> DevnetResult<u64>
pub fn contract_nonce_at_block( &self, block_id: &BlockId, contract_address: ContractAddress ) -> DevnetResult<Felt>
pub fn contract_storage_at_block( &self, block_id: &BlockId, contract_address: ContractAddress, storage_key: PatriciaKey ) -> DevnetResult<Felt>
pub fn get_block(&self, block_id: &BlockId) -> DevnetResult<StarknetBlock>
pub fn get_block_with_transactions( &self, block_id: &BlockId ) -> DevnetResult<Block>
pub fn get_block_with_receipts(&self, block_id: BlockId) -> DevnetResult<Block>
pub fn get_transaction_by_block_id_and_index( &self, block_id: &BlockId, index: u64 ) -> DevnetResult<&Transaction>
pub fn get_latest_block(&self) -> DevnetResult<StarknetBlock>
pub fn get_transaction_by_hash( &self, transaction_hash: Felt ) -> DevnetResult<&Transaction>
pub fn get_events( &self, from_block: Option<BlockId>, to_block: Option<BlockId>, address: Option<ContractAddress>, keys: Option<Vec<Vec<Felt>>>, skip: usize, limit: Option<usize> ) -> DevnetResult<(Vec<EmittedEvent>, bool)>
pub fn get_transaction_receipt_by_hash( &self, transaction_hash: &TransactionHash ) -> DevnetResult<TransactionReceipt>
pub fn get_transaction_trace_by_hash( &self, transaction_hash: TransactionHash ) -> DevnetResult<TransactionTrace>
pub fn get_transaction_traces_from_block( &self, block_id: &BlockId ) -> DevnetResult<Vec<BlockTransactionTrace>>
pub fn get_transaction_execution_and_finality_status( &self, transaction_hash: TransactionHash ) -> DevnetResult<(TransactionExecutionStatus, TransactionFinalityStatus)>
pub fn simulate_transactions( &mut self, block_id: &BlockId, transactions: &[BroadcastedTransaction], simulation_flags: Vec<SimulationFlag> ) -> DevnetResult<Vec<SimulatedTransaction>>
sourcepub fn create_block(&mut self) -> DevnetResult<(), Error>
pub fn create_block(&mut self) -> DevnetResult<(), Error>
create new block from pending one
pub fn create_block_dump_event( &mut self, dump_event: Option<DumpEvent> ) -> DevnetResult<(), Error>
pub fn set_time( &mut self, timestamp: u64, create_block: bool ) -> DevnetResult<(), Error>
pub fn increase_time(&mut self, time_shift: u64) -> DevnetResult<(), Error>
pub fn set_block_timestamp_shift(&mut self, timestamp: i64)
pub fn set_next_block_timestamp(&mut self, timestamp: u64)
pub fn get_unix_timestamp_as_seconds() -> u64
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Starknet
impl Send for Starknet
impl Sync for Starknet
impl Unpin for Starknet
impl !UnwindSafe for Starknet
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T0, T1, E, TRewriter> SemanticRewriter<(T0, T1), E> for TRewriterwhere
TRewriter: SemanticRewriter<T0, E> + SemanticRewriter<T1, E>,
impl<T0, T1, E, TRewriter> SemanticRewriter<(T0, T1), E> for TRewriterwhere
TRewriter: SemanticRewriter<T0, E> + SemanticRewriter<T1, E>,
§impl<T, E, TRewriter> SemanticRewriter<Box<T>, E> for TRewriterwhere
T: Clone,
TRewriter: SemanticRewriter<T, E>,
impl<T, E, TRewriter> SemanticRewriter<Box<T>, E> for TRewriterwhere
T: Clone,
TRewriter: SemanticRewriter<T, E>,
§impl<T, E, TRewriter> SemanticRewriter<Option<T>, E> for TRewriterwhere
TRewriter: SemanticRewriter<T, E>,
impl<T, E, TRewriter> SemanticRewriter<Option<T>, E> for TRewriterwhere
TRewriter: SemanticRewriter<T, E>,
§impl<T, E, TRewriter, E2> SemanticRewriter<Result<T, E2>, E> for TRewriterwhere
TRewriter: SemanticRewriter<T, E>,
impl<T, E, TRewriter, E2> SemanticRewriter<Result<T, E2>, E> for TRewriterwhere
TRewriter: SemanticRewriter<T, E>,
§impl<T, E, TRewriter> SemanticRewriter<Vec<T>, E> for TRewriterwhere
TRewriter: SemanticRewriter<T, E>,
impl<T, E, TRewriter> SemanticRewriter<Vec<T>, E> for TRewriterwhere
TRewriter: SemanticRewriter<T, E>,
§impl<T, E, TRewriter> SemanticRewriter<VecDeque<T>, E> for TRewriterwhere
TRewriter: SemanticRewriter<T, E>,
impl<T, E, TRewriter> SemanticRewriter<VecDeque<T>, E> for TRewriterwhere
TRewriter: SemanticRewriter<T, E>,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.