paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

Transfer to beneficiary after `transfer_on_hold` #14767

Closed juangirini closed 1 year ago

juangirini commented 1 year ago

The order of balance transfers from the contract's accounts during termination is changed so that balance on hold is transferred to the origin before the contract's free balance is transferred to the beneficiary. This way we let the contract's account be reaped when the account is emptied.

The struct Charge is updated so that the bool terminated becomes status which is a new ContractStatus enum.

/// The beneficiary of a contract termination.
type BeneficiaryOf<T> = AccountIdOf<T>;

/// The status of a contract.
///
/// In case of termination the beneficiary is indicated.
#[derive(RuntimeDebugNoBound, Clone, PartialEq, Eq)]
pub enum ContractStatus<T: Config> {
    Alive,
    Terminated(BeneficiaryOf<T>),
}
juangirini commented 1 year ago

bot merge