Struct sputnikvm::AccountState
source · pub struct AccountState<A: AccountPatch> { /* private fields */ }
Expand description
A struct that manages the current account state for one EVM.
Implementations
sourceimpl<A: AccountPatch> AccountState<A>
impl<A: AccountPatch> AccountState<A>
sourcepub fn used_addresses(&self) -> Set<Address>
pub fn used_addresses(&self) -> Set<Address>
Returns all fetched or modified addresses.
sourcepub fn accounts(&self) -> Values<'_, Address, AccountChange>
pub fn accounts(&self) -> Values<'_, Address, AccountChange>
Returns all accounts right now in this account state.
sourcepub fn require(&self, address: Address) -> Result<(), RequireError>
pub fn require(&self, address: Address) -> Result<(), RequireError>
Returns Ok(()) if a full account is in this account
state. Otherwise raise a RequireError
.
sourcepub fn require_code(&self, address: Address) -> Result<(), RequireError>
pub fn require_code(&self, address: Address) -> Result<(), RequireError>
Returns Ok(()) if either a full account or a partial code
account is in this account state. Otherwise raise a
RequireError
.
sourcepub fn require_storage(
&self,
address: Address,
index: U256
) -> Result<(), RequireError>
pub fn require_storage(
&self,
address: Address,
index: U256
) -> Result<(), RequireError>
Returns Ok(()) if the storage exists in the VM. Otherwise
raise a RequireError
.
sourcepub fn commit(
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>
pub fn commit(
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>
Commit an account commitment into this account state.
sourcepub fn exists(&self, address: Address) -> Result<bool, RequireError>
pub fn exists(&self, address: Address) -> Result<bool, RequireError>
Test whether an account at given address is considered existing.
sourcepub fn code(&self, address: Address) -> Result<Rc<Vec<u8>>, RequireError>
pub fn code(&self, address: Address) -> Result<Rc<Vec<u8>>, RequireError>
Find code by its address in this account state. If the search
failed, returns a RequireError
.
sourcepub fn code_opt_nonexist(
&self,
address: Address
) -> Result<Option<Rc<Vec<u8>>>, RequireError>
pub fn code_opt_nonexist(
&self,
address: Address
) -> Result<Option<Rc<Vec<u8>>>, RequireError>
Find code of account that may not exist. If search
failed, returns a RequireError
sourcepub fn nonce(&self, address: Address) -> Result<U256, RequireError>
pub fn nonce(&self, address: Address) -> Result<U256, RequireError>
Find nonce by its address in this account state. If the search
failed, returns a RequireError
.
sourcepub fn balance(&self, address: Address) -> Result<U256, RequireError>
pub fn balance(&self, address: Address) -> Result<U256, RequireError>
Find balance by its address in this account state. If the
search failed, returns a RequireError
.
sourcepub fn storage_read(
&self,
address: Address,
index: U256
) -> Result<M256, RequireError>
pub fn storage_read(
&self,
address: Address,
index: U256
) -> Result<M256, RequireError>
Read a value from an account storage.
sourcepub fn storage_read_orig(
&self,
address: Address,
index: U256
) -> Result<M256, RequireError>
pub fn storage_read_orig(
&self,
address: Address,
index: U256
) -> Result<M256, RequireError>
Read an original (pre-execution) value from an account storage
sourcepub fn storage_write(
&mut self,
address: Address,
index: U256,
value: M256
) -> Result<(), RequireError>
pub fn storage_write(
&mut self,
address: Address,
index: U256,
value: M256
) -> Result<(), RequireError>
Write a value from an account storage. The account will be created if it is nonexist.
sourcepub fn create(
&mut self,
address: Address,
topup: U256
) -> Result<(), RequireError>
pub fn create(
&mut self,
address: Address,
topup: U256
) -> Result<(), RequireError>
Create a new account (that should not yet have existed before).
sourcepub fn code_deposit(&mut self, address: Address, new_code: Rc<Vec<u8>>)
pub fn code_deposit(&mut self, address: Address, new_code: Rc<Vec<u8>>)
Deposit code in to a created account. Only usable in a newly created account.
sourcepub fn increase_balance(&mut self, address: Address, topup: U256)
pub fn increase_balance(&mut self, address: Address, topup: U256)
Increase the balance of an account. The account will be created if it is nonexist in the beginning.
sourcepub fn decrease_balance(&mut self, address: Address, withdraw: U256)
pub fn decrease_balance(&mut self, address: Address, withdraw: U256)
Decrease the balance of an account. The account will be created if it is nonexist in the beginning.