Introduce VestingCurrency trait (#4257)

* Introduce `VestingCurrency` trait

* Return error if account already has vesting schedule
This commit is contained in:
Shawn Tabrizi
2019-12-01 20:52:00 +01:00
committed by Gavin Wood
parent bd4f1fc54b
commit 40f6d05a4c
2 changed files with 68 additions and 14 deletions
+23
View File
@@ -602,6 +602,29 @@ pub trait LockableCurrency<AccountId>: Currency<AccountId> {
);
}
/// A currency whose accounts can have balances which vest over time.
pub trait VestingCurrency<AccountId>: Currency<AccountId> {
/// The quantity used to denote time; usually just a `BlockNumber`.
type Moment;
/// Get the amount that is currently being vested and cannot be transferred out of this account.
fn vesting_balance(who: &AccountId) -> Self::Balance;
/// Adds a vesting schedule to a given account.
///
/// If there already exists a vesting schedule for the given account, an `Err` is returned
/// and nothing is updated.
fn add_vesting_schedule(
who: &AccountId,
locked: Self::Balance,
per_block: Self::Balance,
starting_block: Self::Moment,
) -> result::Result<(), &'static str>;
/// Remove a vesting schedule for a given account.
fn remove_vesting_schedule(who: &AccountId);
}
bitmask! {
/// Reasons for moving funds out of an account.
#[derive(Encode, Decode)]