Skip to main content

TempoStateAccess

Trait TempoStateAccess 

Source
pub trait TempoStateAccess<M = ()> {
    type Error: Display;

    // Required methods
    fn basic(&mut self, address: Address) -> Result<AccountInfo, Self::Error>;
    fn sload(
        &mut self,
        address: Address,
        key: U256,
    ) -> Result<U256, Self::Error>;

    // Provided methods
    fn with_read_only_storage_ctx<R>(
        &mut self,
        spec: TempoHardfork,
        f: impl FnOnce() -> R,
    ) -> R
       where Self: Sized { ... }
    fn get_fee_token(
        &mut self,
        tx: impl TempoTx,
        fee_payer: Address,
        spec: TempoHardfork,
    ) -> TempoResult<Address>
       where Self: Sized { ... }
    fn is_tip20_usd(
        &mut self,
        spec: TempoHardfork,
        fee_token: Address,
    ) -> TempoResult<bool>
       where Self: Sized { ... }
    fn is_valid_fee_token(
        &mut self,
        spec: TempoHardfork,
        fee_token: Address,
    ) -> TempoResult<bool>
       where Self: Sized { ... }
    fn is_fee_token_paused(
        &mut self,
        spec: TempoHardfork,
        fee_token: Address,
    ) -> TempoResult<bool>
       where Self: Sized { ... }
    fn can_fee_payer_transfer(
        &mut self,
        fee_token: Address,
        fee_payer: Address,
        spec: TempoHardfork,
    ) -> TempoResult<bool>
       where Self: Sized { ... }
    fn get_token_balance(
        &mut self,
        token: Address,
        account: Address,
        spec: TempoHardfork,
    ) -> TempoResult<U256>
       where Self: Sized { ... }
}
Expand description

Helper trait to perform Tempo-specific operations on top of different state providers.

We provide blanket implementations for revm database, journal and reth state provider.

The generic marker is used as a workaround to avoid conflicting implementations.

Required Associated Types§

Source

type Error: Display

Error type returned by storage operations.

Required Methods§

Source

fn basic(&mut self, address: Address) -> Result<AccountInfo, Self::Error>

Returns [AccountInfo] for the given address.

Source

fn sload(&mut self, address: Address, key: U256) -> Result<U256, Self::Error>

Returns the storage value for the given address and key.

Provided Methods§

Source

fn with_read_only_storage_ctx<R>( &mut self, spec: TempoHardfork, f: impl FnOnce() -> R, ) -> R
where Self: Sized,

Returns a read-only storage provider for the given spec.

Source

fn get_fee_token( &mut self, tx: impl TempoTx, fee_payer: Address, spec: TempoHardfork, ) -> TempoResult<Address>
where Self: Sized,

Resolves user-level or transaction-level fee token preference.

Source

fn is_tip20_usd( &mut self, spec: TempoHardfork, fee_token: Address, ) -> TempoResult<bool>
where Self: Sized,

Checks if the given TIP20 token has USD currency.

IMPORTANT: Caller must ensure fee_token has a valid TIP20 prefix.

Source

fn is_valid_fee_token( &mut self, spec: TempoHardfork, fee_token: Address, ) -> TempoResult<bool>
where Self: Sized,

Checks if the given token can be used as a fee token.

Source

fn is_fee_token_paused( &mut self, spec: TempoHardfork, fee_token: Address, ) -> TempoResult<bool>
where Self: Sized,

Checks if a fee token is paused.

Source

fn can_fee_payer_transfer( &mut self, fee_token: Address, fee_payer: Address, spec: TempoHardfork, ) -> TempoResult<bool>
where Self: Sized,

Checks if the fee payer can transfer the fee token to the fee manager.

Source

fn get_token_balance( &mut self, token: Address, account: Address, spec: TempoHardfork, ) -> TempoResult<U256>
where Self: Sized,

Returns the balance of the given token for the given account.

IMPORTANT: the caller must ensure token is a valid TIP20Token address.

Implementors§

Source§

impl<DB: Database> TempoStateAccess for DB

Source§

type Error = <DB as Database>::Error

Source§

impl<T: JournalTr> TempoStateAccess<((), ())> for T

Source§

type Error = <<T as JournalTr>::Database as Database>::Error

Source§

impl<T: StateProvider> TempoStateAccess<((), (), ())> for T

Available on crate feature reth only.
Source§

type Error = ProviderError