Trait State

Source
pub trait State: StateView {
    // Required methods
    fn add_public_key(
        &mut self,
        account_id: AccountId,
        public_key: PublicKey,
    ) -> Result<()>;
    fn remove_public_key(
        &mut self,
        account_id: AccountId,
        public_key: PublicKey,
    ) -> Result<()>;
    fn commit_nonce(
        &mut self,
        account_id: AccountId,
        nonce: Nonce,
    ) -> Result<()>;
    fn internal_add_balance(
        &mut self,
        owner_id: AccountId,
        tokens: impl IntoIterator<Item = (TokenId, u128)>,
    ) -> Result<()>;
    fn internal_sub_balance(
        &mut self,
        owner_id: &AccountIdRef,
        tokens: impl IntoIterator<Item = (TokenId, u128)>,
    ) -> Result<()>;
    fn ft_withdraw(
        &mut self,
        owner_id: &AccountIdRef,
        withdraw: FtWithdraw,
    ) -> Result<()>;
    fn nft_withdraw(
        &mut self,
        owner_id: &AccountIdRef,
        withdraw: NftWithdraw,
    ) -> Result<()>;
    fn mt_withdraw(
        &mut self,
        owner_id: &AccountIdRef,
        withdraw: MtWithdraw,
    ) -> Result<()>;
    fn native_withdraw(
        &mut self,
        owner_id: &AccountIdRef,
        withdraw: NativeWithdraw,
    ) -> Result<()>;
    fn storage_deposit(
        &mut self,
        owner_id: &AccountIdRef,
        storage_deposit: StorageDeposit,
    ) -> Result<()>;
    fn set_auth_by_predecessor_id(
        &mut self,
        account_id: AccountId,
        enable: bool,
    ) -> Result<bool>;

    // Provided method
    fn internal_apply_deltas(
        &mut self,
        owner_id: &AccountIdRef,
        tokens: impl IntoIterator<Item = (TokenId, i128)>,
    ) -> Result<()> { ... }
}

Required Methods§

Source

fn add_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> Result<()>

Source

fn remove_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> Result<()>

Source

fn commit_nonce(&mut self, account_id: AccountId, nonce: Nonce) -> Result<()>

Source

fn internal_add_balance( &mut self, owner_id: AccountId, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source

fn internal_sub_balance( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source

fn ft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: FtWithdraw, ) -> Result<()>

Source

fn nft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NftWithdraw, ) -> Result<()>

Source

fn mt_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: MtWithdraw, ) -> Result<()>

Source

fn native_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NativeWithdraw, ) -> Result<()>

Source

fn storage_deposit( &mut self, owner_id: &AccountIdRef, storage_deposit: StorageDeposit, ) -> Result<()>

Source

fn set_auth_by_predecessor_id( &mut self, account_id: AccountId, enable: bool, ) -> Result<bool>

Sets whether authentication by PREDECESSOR_ID is enabled. Returns whether authentication by PREDECESSOR_ID was enabled before.

Provided Methods§

Source

fn internal_apply_deltas( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, i128)>, ) -> Result<()>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: State + ?Sized> State for &mut T

Source§

fn add_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> Result<()>

Source§

fn remove_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> Result<()>

Source§

fn commit_nonce(&mut self, account_id: AccountId, nonce: Nonce) -> Result<()>

Source§

fn internal_add_balance( &mut self, owner_id: AccountId, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source§

fn internal_sub_balance( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source§

fn internal_apply_deltas( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, i128)>, ) -> Result<()>

Source§

fn ft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: FtWithdraw, ) -> Result<()>

Source§

fn nft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NftWithdraw, ) -> Result<()>

Source§

fn mt_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: MtWithdraw, ) -> Result<()>

Source§

fn native_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NativeWithdraw, ) -> Result<()>

Source§

fn storage_deposit( &mut self, owner_id: &AccountIdRef, storage_deposit: StorageDeposit, ) -> Result<()>

Source§

fn set_auth_by_predecessor_id( &mut self, account_id: AccountId, enable: bool, ) -> Result<bool>

Source§

impl<T: State + ?Sized> State for Box<T>

Source§

fn add_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> Result<()>

Source§

fn remove_public_key( &mut self, account_id: AccountId, public_key: PublicKey, ) -> Result<()>

Source§

fn commit_nonce(&mut self, account_id: AccountId, nonce: Nonce) -> Result<()>

Source§

fn internal_add_balance( &mut self, owner_id: AccountId, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source§

fn internal_sub_balance( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, u128)>, ) -> Result<()>

Source§

fn internal_apply_deltas( &mut self, owner_id: &AccountIdRef, tokens: impl IntoIterator<Item = (TokenId, i128)>, ) -> Result<()>

Source§

fn ft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: FtWithdraw, ) -> Result<()>

Source§

fn nft_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NftWithdraw, ) -> Result<()>

Source§

fn mt_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: MtWithdraw, ) -> Result<()>

Source§

fn native_withdraw( &mut self, owner_id: &AccountIdRef, withdraw: NativeWithdraw, ) -> Result<()>

Source§

fn storage_deposit( &mut self, owner_id: &AccountIdRef, storage_deposit: StorageDeposit, ) -> Result<()>

Source§

fn set_auth_by_predecessor_id( &mut self, account_id: AccountId, enable: bool, ) -> Result<bool>

Implementors§

Source§

impl<S> State for Deltas<S>
where S: State,

Source§

impl<W> State for CachedState<W>
where W: StateView,