pub trait Deposit<T: Config>: Sealed {
const SUPPORTS_PGAS: bool;
// Required methods
fn init_contract(contract: &T::AccountId) -> DispatchResult;
fn destroy_contract(contract: &T::AccountId) -> DispatchResult;
fn charge_and_hold(
reason: HoldReason,
src: Funds<'_, T::AccountId>,
to: &T::AccountId,
amount: BalanceOf<T>,
) -> DispatchResult;
fn refund_on_hold(
reason: HoldReason,
from: &T::AccountId,
dst: Funds<'_, T::AccountId>,
amount: BalanceOf<T>,
) -> DispatchResult;
fn total_on_hold(reason: HoldReason, who: &T::AccountId) -> BalanceOf<T>;
fn refund_all(
from: &T::AccountId,
dst: Funds<'_, T::AccountId>,
) -> Result<BalanceOf<T>, DispatchError>;
fn migrate_native_to_pgas(
reason: HoldReason,
contract: &T::AccountId,
amount: BalanceOf<T>,
) -> DispatchResult;
}Expand description
Payment backend used to charge storage deposits.
Required Associated Constants§
Sourceconst SUPPORTS_PGAS: bool
const SUPPORTS_PGAS: bool
Whether this backend supports PGAS.
When false, the v4 multi-block migration’s PGAS-related phases (steps 1 and 2)
are no-ops, since there is no PGAS asset to migrate native deposits over to.
Required Methods§
Sourcefn init_contract(contract: &T::AccountId) -> DispatchResult
fn init_contract(contract: &T::AccountId) -> DispatchResult
Mint each backend’s existential deposit into contract.
Used by [crate::exec] when bringing a new contract account into existence.
Sourcefn destroy_contract(contract: &T::AccountId) -> DispatchResult
fn destroy_contract(contract: &T::AccountId) -> DispatchResult
Tear down the per-backend balance state that Self::init_contract set up.
Used by [crate::exec::Stack::do_terminate] when destroying a contract.
Sourcefn charge_and_hold(
reason: HoldReason,
src: Funds<'_, T::AccountId>,
to: &T::AccountId,
amount: BalanceOf<T>,
) -> DispatchResult
fn charge_and_hold( reason: HoldReason, src: Funds<'_, T::AccountId>, to: &T::AccountId, amount: BalanceOf<T>, ) -> DispatchResult
Charge amount from src to to and place it on hold under reason.
§Parameters
reason: hold reason to place the charge under.src: source of the charge. See [Funds].to: account on which the hold is placed.amount: amount to charge.
Sourcefn refund_on_hold(
reason: HoldReason,
from: &T::AccountId,
dst: Funds<'_, T::AccountId>,
amount: BalanceOf<T>,
) -> DispatchResult
fn refund_on_hold( reason: HoldReason, from: &T::AccountId, dst: Funds<'_, T::AccountId>, amount: BalanceOf<T>, ) -> DispatchResult
Refund amount of held funds from contract from.
§Parameters
reason: hold reason the funds were placed under.from: contract whose hold is being released.dst: destination of the refund. See [Funds]. Also the attribution key used to cap the native portion via [NativeDepositOf].amount: amount to refund.
Sourcefn total_on_hold(reason: HoldReason, who: &T::AccountId) -> BalanceOf<T>
fn total_on_hold(reason: HoldReason, who: &T::AccountId) -> BalanceOf<T>
Total amount held for who under reason.
§Parameters
reason: hold reason to query.who: account whose held balance is returned.
Sourcefn refund_all(
from: &T::AccountId,
dst: Funds<'_, T::AccountId>,
) -> Result<BalanceOf<T>, DispatchError>
fn refund_all( from: &T::AccountId, dst: Funds<'_, T::AccountId>, ) -> Result<BalanceOf<T>, DispatchError>
Refund every storage-deposit fund held on from to dst, ignoring the per-contributor
caps that govern partial refunds. Used at contract termination.
Returns the total amount released, so the storage meter can finalise its deposit accounting.
§Parameters
from: contract whose hold is being released.dst: destination of the refund. See [Funds].
Sourcefn migrate_native_to_pgas(
reason: HoldReason,
contract: &T::AccountId,
amount: BalanceOf<T>,
) -> DispatchResult
fn migrate_native_to_pgas( reason: HoldReason, contract: &T::AccountId, amount: BalanceOf<T>, ) -> DispatchResult
Burn the native currency held on contract under reason and replace it with the same
amount of PGAS, minted into contract and placed on hold under the same reason.
Only used by the v4 multi-block migration (see crate::migrations::v4) to move
pre-existing native storage deposits over to PGAS. Not part of the regular charge/refund
flow.
§Parameters
reason: hold reason whose balance is being migrated.contract: account holding the funds to migrate.amount: amount to migrate from native to PGAS.
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: Config> Deposit<T> for ()
Default backend: every storage deposit charge goes through the native currency.
impl<T: Config> Deposit<T> for ()
Default backend: every storage deposit charge goes through the native currency.
Source§fn init_contract(to: &T::AccountId) -> DispatchResult
fn init_contract(to: &T::AccountId) -> DispatchResult
The native ED is freshly minted and immediately
deactivated so that
active issuance, and therefore opengov conviction, inflation accounting, etc., is
undisturbed by contract creation. The contract holds a system consumer for as long as it
exists, so this minted ED is not extractable: the account cannot be reaped.