JsonRpcClient

Struct JsonRpcClient 

Source
pub struct JsonRpcClient<T> { /* private fields */ }
Expand description

A generic JSON-RPC client with any transport.

A “transport” is any implementation that can send JSON-RPC requests and receive responses. This most commonly happens over a network via HTTP connections, as with HttpTransport.

Implementations§

Source§

impl<T> JsonRpcClient<T>

Source

pub const fn new(transport: T) -> Self

Constructs a new JsonRpcClient from a transport.

Trait Implementations§

Source§

impl<T: Clone> Clone for JsonRpcClient<T>

Source§

fn clone(&self) -> JsonRpcClient<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for JsonRpcClient<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Provider for JsonRpcClient<T>
where T: 'static + JsonRpcTransport + Sync + Send,

Source§

fn spec_version<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the version of the Starknet JSON-RPC specification being used

Source§

fn starknet_version<'life0, 'async_trait, B>( &'life0 self, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<String, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Returns the version of the Starknet being used.

Source§

fn get_block_with_tx_hashes<'life0, 'async_trait, B>( &'life0 self, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<MaybePreConfirmedBlockWithTxHashes, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get block information with transaction hashes given the block id

Source§

fn get_block_with_txs<'life0, 'async_trait, B>( &'life0 self, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<MaybePreConfirmedBlockWithTxs, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get block information with full transactions given the block id

Source§

fn get_block_with_receipts<'life0, 'async_trait, B>( &'life0 self, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<MaybePreConfirmedBlockWithReceipts, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get block information with full transactions and receipts given the block id

Source§

fn get_state_update<'life0, 'async_trait, B>( &'life0 self, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<MaybePreConfirmedStateUpdate, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the information about the result of executing the requested block

Source§

fn get_storage_at<'life0, 'async_trait, A, K, B>( &'life0 self, contract_address: A, key: K, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<FeltPrimitive, ProviderError>> + Send + 'async_trait>>
where A: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, K: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the value of the storage at the given address and key

Source§

fn get_messages_status<'life0, 'async_trait>( &'life0 self, transaction_hash: Hash256, ) -> Pin<Box<dyn Future<Output = Result<Vec<MessageStatus>, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Given an l1 tx hash, returns the associated l1_handler tx hashes and statuses for all L1 -> L2 messages sent by the l1 transaction, ordered by the l1 tx sending order

Source§

fn get_transaction_status<'life0, 'async_trait, H>( &'life0 self, transaction_hash: H, ) -> Pin<Box<dyn Future<Output = Result<TransactionStatus, ProviderError>> + Send + 'async_trait>>
where H: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Gets the transaction status (possibly reflecting that the tx is still in the mempool, or dropped from it)

Source§

fn get_transaction_by_hash<'life0, 'async_trait, H>( &'life0 self, transaction_hash: H, ) -> Pin<Box<dyn Future<Output = Result<Transaction, ProviderError>> + Send + 'async_trait>>
where H: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the details and status of a submitted transaction

Source§

fn get_transaction_by_block_id_and_index<'life0, 'async_trait, B>( &'life0 self, block_id: B, index: u64, ) -> Pin<Box<dyn Future<Output = Result<Transaction, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the details of a transaction by a given block id and index

Source§

fn get_transaction_receipt<'life0, 'async_trait, H>( &'life0 self, transaction_hash: H, ) -> Pin<Box<dyn Future<Output = Result<TransactionReceiptWithBlockInfo, ProviderError>> + Send + 'async_trait>>
where H: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the details of a transaction by a given block number and index

Source§

fn get_class<'life0, 'async_trait, B, H>( &'life0 self, block_id: B, class_hash: H, ) -> Pin<Box<dyn Future<Output = Result<ContractClass, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, H: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the contract class definition in the given block associated with the given hash

Source§

fn get_class_hash_at<'life0, 'async_trait, B, A>( &'life0 self, block_id: B, contract_address: A, ) -> Pin<Box<dyn Future<Output = Result<FeltPrimitive, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, A: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the contract class hash in the given block for the contract deployed at the given address

Source§

fn get_class_at<'life0, 'async_trait, B, A>( &'life0 self, block_id: B, contract_address: A, ) -> Pin<Box<dyn Future<Output = Result<ContractClass, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, A: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the contract class definition in the given block at the given address

Source§

fn get_block_transaction_count<'life0, 'async_trait, B>( &'life0 self, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<u64, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the number of transactions in a block given a block id

Source§

fn call<'life0, 'async_trait, R, B>( &'life0 self, request: R, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<Vec<FeltPrimitive>, ProviderError>> + Send + 'async_trait>>
where R: AsRef<FunctionCall> + Send + Sync + 'async_trait, B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Call a starknet function without creating a Starknet transaction

Source§

fn estimate_fee<'life0, 'async_trait, R, S, B>( &'life0 self, request: R, simulation_flags: S, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<Vec<FeeEstimate>, ProviderError>> + Send + 'async_trait>>
where R: AsRef<[BroadcastedTransaction]> + Send + Sync + 'async_trait, S: AsRef<[SimulationFlagForEstimateFee]> + Send + Sync + 'async_trait, B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Estimate the fee for a given Starknet transaction

Source§

fn estimate_message_fee<'life0, 'async_trait, M, B>( &'life0 self, message: M, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<MessageFeeEstimate, ProviderError>> + Send + 'async_trait>>
where M: AsRef<MsgFromL1> + Send + Sync + 'async_trait, B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Estimate the L2 fee of a message sent on L1

Source§

fn block_number<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the most recent accepted block number

Source§

fn block_hash_and_number<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<BlockHashAndNumber, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the most recent accepted block hash and number

Source§

fn chain_id<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<FeltPrimitive, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the currently configured Starknet chain id

Source§

fn syncing<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<SyncStatusType, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns an object about the sync status, or false if the node is not synching

Source§

fn get_events<'life0, 'async_trait>( &'life0 self, filter: EventFilter, continuation_token: Option<String>, chunk_size: u64, ) -> Pin<Box<dyn Future<Output = Result<EventsPage, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns all events matching the given filter

Source§

fn get_nonce<'life0, 'async_trait, B, A>( &'life0 self, block_id: B, contract_address: A, ) -> Pin<Box<dyn Future<Output = Result<FeltPrimitive, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, A: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the nonce associated with the given address in the given block

Source§

fn get_storage_proof<'life0, 'async_trait, B, H, A, K>( &'life0 self, block_id: B, class_hashes: H, contract_addresses: A, contracts_storage_keys: K, ) -> Pin<Box<dyn Future<Output = Result<StorageProof, ProviderError>> + Send + 'async_trait>>
where B: AsRef<ConfirmedBlockId> + Send + Sync + 'async_trait, H: AsRef<[FeltPrimitive]> + Send + Sync + 'async_trait, A: AsRef<[FeltPrimitive]> + Send + Sync + 'async_trait, K: AsRef<[ContractStorageKeys]> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get merkle paths in one of the state tries: global state, classes, individual contract. A single request can query for any mix of the three types of storage proofs (classes, contracts, and storage).

Source§

fn add_invoke_transaction<'life0, 'async_trait, I>( &'life0 self, invoke_transaction: I, ) -> Pin<Box<dyn Future<Output = Result<InvokeTransactionResult, ProviderError>> + Send + 'async_trait>>
where I: AsRef<BroadcastedInvokeTransaction> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Submit a new transaction to be added to the chain

Source§

fn add_declare_transaction<'life0, 'async_trait, D>( &'life0 self, declare_transaction: D, ) -> Pin<Box<dyn Future<Output = Result<DeclareTransactionResult, ProviderError>> + Send + 'async_trait>>
where D: AsRef<BroadcastedDeclareTransaction> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Submit a new transaction to be added to the chain

Source§

fn add_deploy_account_transaction<'life0, 'async_trait, D>( &'life0 self, deploy_account_transaction: D, ) -> Pin<Box<dyn Future<Output = Result<DeployAccountTransactionResult, ProviderError>> + Send + 'async_trait>>
where D: AsRef<BroadcastedDeployAccountTransaction> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Submit a new deploy account transaction

Source§

fn trace_transaction<'life0, 'async_trait, H>( &'life0 self, transaction_hash: H, ) -> Pin<Box<dyn Future<Output = Result<TransactionTrace, ProviderError>> + Send + 'async_trait>>
where H: AsRef<FeltPrimitive> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

For a given executed transaction, return the trace of its execution, including internal calls

Source§

fn simulate_transactions<'life0, 'async_trait, B, TX, S>( &'life0 self, block_id: B, transactions: TX, simulation_flags: S, ) -> Pin<Box<dyn Future<Output = Result<Vec<SimulatedTransaction>, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, TX: AsRef<[BroadcastedTransaction]> + Send + Sync + 'async_trait, S: AsRef<[SimulationFlag]> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Simulate a given sequence of transactions on the requested state, and generate the execution traces. Note that some of the transactions may revert, in which case no error is thrown, but revert details can be seen on the returned trace object. . Note that some of the transactions may revert, this will be reflected by the revert_error property in the trace. Other types of failures (e.g. unexpected error or failure in the validation phase) will result in TRANSACTION_EXECUTION_ERROR.

Source§

fn trace_block_transactions<'life0, 'async_trait, B>( &'life0 self, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<Vec<TransactionTraceWithHash>, ProviderError>> + Send + 'async_trait>>
where B: AsRef<ConfirmedBlockId> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Retrieve traces for all transactions in the given block.

Source§

fn batch_requests<'life0, 'async_trait, R>( &'life0 self, requests: R, ) -> Pin<Box<dyn Future<Output = Result<Vec<ProviderResponseData>, ProviderError>> + Send + 'async_trait>>
where R: AsRef<[ProviderRequestData]> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Sends multiple requests in parallel. The function call fails if any of the requests fails. Implementations must guarantee that responses follow the exact order as the requests.
Source§

fn estimate_fee_single<'life0, 'async_trait, R, S, B>( &'life0 self, request: R, simulation_flags: S, block_id: B, ) -> Pin<Box<dyn Future<Output = Result<FeeEstimate, ProviderError>> + Send + 'async_trait>>
where R: AsRef<BroadcastedTransaction> + Send + Sync + 'async_trait, S: AsRef<[SimulationFlagForEstimateFee]> + Send + Sync + 'async_trait, B: AsRef<BlockId> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Same as estimate_fee, but only with one estimate.
Source§

fn simulate_transaction<'life0, 'async_trait, B, T, S>( &'life0 self, block_id: B, transaction: T, simulation_flags: S, ) -> Pin<Box<dyn Future<Output = Result<SimulatedTransaction, ProviderError>> + Send + 'async_trait>>
where B: AsRef<BlockId> + Send + Sync + 'async_trait, T: AsRef<BroadcastedTransaction> + Send + Sync + 'async_trait, S: AsRef<[SimulationFlag]> + Send + Sync + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Same as simulate_transactions, but only with one simulation.

Auto Trait Implementations§

§

impl<T> Freeze for JsonRpcClient<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for JsonRpcClient<T>
where T: RefUnwindSafe,

§

impl<T> Send for JsonRpcClient<T>
where T: Send,

§

impl<T> Sync for JsonRpcClient<T>
where T: Sync,

§

impl<T> Unpin for JsonRpcClient<T>
where T: Unpin,

§

impl<T> UnwindSafe for JsonRpcClient<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more