Trait StateProvider
pub trait StateProvider:
BlockHashReader
+ AccountReader
+ StateRootProvider
+ StorageRootProvider
+ StateProofProvider
+ Send
+ Sync {
// Required methods
fn storage(
&self,
account: Address,
storage_key: FixedBytes<32>,
) -> Result<Option<Uint<256, 4>>, ProviderError>;
fn bytecode_by_hash(
&self,
code_hash: FixedBytes<32>,
) -> Result<Option<Bytecode>, ProviderError>;
// Provided methods
fn account_code(
&self,
addr: Address,
) -> Result<Option<Bytecode>, ProviderError> { ... }
fn account_balance(
&self,
addr: Address,
) -> Result<Option<Uint<256, 4>>, ProviderError> { ... }
fn account_nonce(&self, addr: Address) -> Result<Option<u64>, ProviderError> { ... }
}
Expand description
An abstraction for a type that provides state data.
Required Methods§
fn storage(
&self,
account: Address,
storage_key: FixedBytes<32>,
) -> Result<Option<Uint<256, 4>>, ProviderError>
fn storage( &self, account: Address, storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
Get storage of given account.
fn bytecode_by_hash(
&self,
code_hash: FixedBytes<32>,
) -> Result<Option<Bytecode>, ProviderError>
fn bytecode_by_hash( &self, code_hash: FixedBytes<32>, ) -> Result<Option<Bytecode>, ProviderError>
Get account code by its hash
Provided Methods§
fn account_code(&self, addr: Address) -> Result<Option<Bytecode>, ProviderError>
fn account_code(&self, addr: Address) -> Result<Option<Bytecode>, ProviderError>
Get account code by its address.
Returns None
if the account doesn’t exist or account is not a contract
fn account_balance(
&self,
addr: Address,
) -> Result<Option<Uint<256, 4>>, ProviderError>
fn account_balance( &self, addr: Address, ) -> Result<Option<Uint<256, 4>>, ProviderError>
Get account balance by its address.
Returns None
if the account doesn’t exist
fn account_nonce(&self, addr: Address) -> Result<Option<u64>, ProviderError>
fn account_nonce(&self, addr: Address) -> Result<Option<u64>, ProviderError>
Get account nonce by its address.
Returns None
if the account doesn’t exist
Implementations on Foreign Types§
§impl StateProvider for StateProviderTest
impl StateProvider for StateProviderTest
fn storage( &self, account: Address, storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn bytecode_by_hash( &self, code_hash: FixedBytes<32>, ) -> Result<Option<Bytecode>, ProviderError>
§impl<'a, N> StateProvider for MemoryOverlayStateProviderRef<'a, N>where
N: NodePrimitives,
impl<'a, N> StateProvider for MemoryOverlayStateProviderRef<'a, N>where
N: NodePrimitives,
fn storage( &self, address: Address, storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn bytecode_by_hash( &self, code_hash: FixedBytes<32>, ) -> Result<Option<Bytecode>, ProviderError>
§impl<'a, T> StateProvider for &'a Twhere
T: 'a + StateProvider + ?Sized,
&'a T: BlockHashReader + AccountReader + StateRootProvider + StorageRootProvider + StateProofProvider + Send + Sync,
impl<'a, T> StateProvider for &'a Twhere
T: 'a + StateProvider + ?Sized,
&'a T: BlockHashReader + AccountReader + StateRootProvider + StorageRootProvider + StateProofProvider + Send + Sync,
fn storage( &self, account: Address, storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn bytecode_by_hash( &self, code_hash: FixedBytes<32>, ) -> Result<Option<Bytecode>, ProviderError>
fn account_code(&self, addr: Address) -> Result<Option<Bytecode>, ProviderError>
fn account_balance( &self, addr: Address, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn account_nonce(&self, addr: Address) -> Result<Option<u64>, ProviderError>
§impl<N> StateProvider for MemoryOverlayStateProvider<N>where
N: NodePrimitives,
impl<N> StateProvider for MemoryOverlayStateProvider<N>where
N: NodePrimitives,
fn storage( &self, address: Address, storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn bytecode_by_hash( &self, code_hash: FixedBytes<32>, ) -> Result<Option<Bytecode>, ProviderError>
§impl<T> StateProvider for Box<T>where
T: StateProvider + ?Sized,
Box<T>: BlockHashReader + AccountReader + StateRootProvider + StorageRootProvider + StateProofProvider + Send + Sync,
impl<T> StateProvider for Box<T>where
T: StateProvider + ?Sized,
Box<T>: BlockHashReader + AccountReader + StateRootProvider + StorageRootProvider + StateProofProvider + Send + Sync,
fn storage( &self, account: Address, storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn bytecode_by_hash( &self, code_hash: FixedBytes<32>, ) -> Result<Option<Bytecode>, ProviderError>
fn account_code(&self, addr: Address) -> Result<Option<Bytecode>, ProviderError>
fn account_balance( &self, addr: Address, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn account_nonce(&self, addr: Address) -> Result<Option<u64>, ProviderError>
§impl<T> StateProvider for Arc<T>where
T: StateProvider + ?Sized,
Arc<T>: BlockHashReader + AccountReader + StateRootProvider + StorageRootProvider + StateProofProvider + Send + Sync,
impl<T> StateProvider for Arc<T>where
T: StateProvider + ?Sized,
Arc<T>: BlockHashReader + AccountReader + StateRootProvider + StorageRootProvider + StateProofProvider + Send + Sync,
fn storage( &self, account: Address, storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn bytecode_by_hash( &self, code_hash: FixedBytes<32>, ) -> Result<Option<Bytecode>, ProviderError>
fn account_code(&self, addr: Address) -> Result<Option<Bytecode>, ProviderError>
fn account_balance( &self, addr: Address, ) -> Result<Option<Uint<256, 4>>, ProviderError>
fn account_nonce(&self, addr: Address) -> Result<Option<u64>, ProviderError>
Implementors§
impl StateProvider for MockEthProvider
Available on crate feature
test-utils
only.impl StateProvider for NoopProvider
Available on crate feature
test-utils
only.