pub trait StorageDepositCollector<AccountId, Key, RuntimeHoldReason> {
    type Currency: MutateHold<AccountId, Reason = RuntimeHoldReason>;
    type Reason: Into<RuntimeHoldReason> + Clone;

    // Required methods
    fn reason() -> Self::Reason;
    fn deposit(
        key: &Key
    ) -> Result<Deposit<AccountId, <Self::Currency as Inspect<AccountId>>::Balance>, DispatchError>;
    fn deposit_amount(
        key: &Key
    ) -> <Self::Currency as Inspect<AccountId>>::Balance;
    fn get_hashed_key(key: &Key) -> Result<Vec<u8>, DispatchError>;
    fn store_deposit(
        key: &Key,
        deposit: Deposit<AccountId, <Self::Currency as Inspect<AccountId>>::Balance>
    ) -> Result<(), DispatchError>;

    // Provided methods
    fn free_deposit(
        deposit: Deposit<AccountId, <Self::Currency as Inspect<AccountId>>::Balance>
    ) -> Result<<Self::Currency as Inspect<AccountId>>::Balance, DispatchError> { ... }
    fn create_deposit(
        who: AccountId,
        amount: <Self::Currency as Inspect<AccountId>>::Balance
    ) -> Result<Deposit<AccountId, <Self::Currency as Inspect<AccountId>>::Balance>, DispatchError> { ... }
    fn change_deposit_owner<DepositBalanceMigrationManager>(
        key: &Key,
        new_owner: AccountId
    ) -> Result<(), DispatchError>
       where DepositBalanceMigrationManager: BalanceMigrationManager<AccountId, <Self::Currency as Inspect<AccountId>>::Balance> { ... }
    fn update_deposit<DepositBalanceMigrationManager>(
        key: &Key
    ) -> Result<(), DispatchError>
       where DepositBalanceMigrationManager: BalanceMigrationManager<AccountId, <Self::Currency as Inspect<AccountId>>::Balance> { ... }
}

Required Associated Types§

source

type Currency: MutateHold<AccountId, Reason = RuntimeHoldReason>

source

type Reason: Into<RuntimeHoldReason> + Clone

Required Methods§

source

fn reason() -> Self::Reason

Returns the hold reason for deposits taken by the deposit collector;

source

fn deposit( key: &Key ) -> Result<Deposit<AccountId, <Self::Currency as Inspect<AccountId>>::Balance>, DispatchError>

Returns the deposit of the storage entry that is stored behind the key.

source

fn deposit_amount(key: &Key) -> <Self::Currency as Inspect<AccountId>>::Balance

Returns the deposit amount that should be reserved for the storage entry behind the key.

This value can differ from the actual deposit that is reserved at the time, since the deposit can be changed.

source

fn get_hashed_key(key: &Key) -> Result<Vec<u8>, DispatchError>

Get the storage key used to fetch a value corresponding to a specific key.

source

fn store_deposit( key: &Key, deposit: Deposit<AccountId, <Self::Currency as Inspect<AccountId>>::Balance> ) -> Result<(), DispatchError>

Store the new deposit information in the storage entry behind the key.

Provided Methods§

source

fn free_deposit( deposit: Deposit<AccountId, <Self::Currency as Inspect<AccountId>>::Balance> ) -> Result<<Self::Currency as Inspect<AccountId>>::Balance, DispatchError>

Release the deposit.

source

fn create_deposit( who: AccountId, amount: <Self::Currency as Inspect<AccountId>>::Balance ) -> Result<Deposit<AccountId, <Self::Currency as Inspect<AccountId>>::Balance>, DispatchError>

Creates a new deposit for user.

Errors

Can fail if the user has not enough balance.

source

fn change_deposit_owner<DepositBalanceMigrationManager>( key: &Key, new_owner: AccountId ) -> Result<(), DispatchError>where DepositBalanceMigrationManager: BalanceMigrationManager<AccountId, <Self::Currency as Inspect<AccountId>>::Balance>,

Change the deposit owner.

The deposit balance of the current owner will be freed, while the deposit balance of the new owner will get reserved. The deposit amount will not change even if the required byte and item fees were updated.

source

fn update_deposit<DepositBalanceMigrationManager>( key: &Key ) -> Result<(), DispatchError>where DepositBalanceMigrationManager: BalanceMigrationManager<AccountId, <Self::Currency as Inspect<AccountId>>::Balance>,

Update the deposit amount.

In case the required deposit per item and byte changed, this function updates the deposit amount. It either frees parts of the reserved balance in case the deposit was lowered or reserves more balance when the deposit was raised.

Implementors§