Skip to content

Instantly share code, notes, and snippets.

@mattrutherford
Created November 22, 2019 10:35
Show Gist options
  • Save mattrutherford/8b0395a1e061c4b5f0fdbd39aea70382 to your computer and use it in GitHub Desktop.
Save mattrutherford/8b0395a1e061c4b5f0fdbd39aea70382 to your computer and use it in GitHub Desktop.
Macro expanded lib.rs from pallete::balances
#![feature(prelude_import)]
#![doc = " # Balances Module"]
#![doc = ""]
#![doc = " The Balances module provides functionality for handling accounts and balances."]
#![doc = ""]
#![doc = " - [`balances::Trait`](./trait.Trait.html)"]
#![doc = " - [`Call`](./enum.Call.html)"]
#![doc = " - [`Module`](./struct.Module.html)"]
#![doc = ""]
#![doc = " ## Overview"]
#![doc = ""]
#![doc = " The Balances module provides functions for:"]
#![doc = ""]
#![doc = " - Getting and setting free balances."]
#![doc = " - Retrieving total, reserved and unreserved balances."]
#![doc = " - Repatriating a reserved balance to a beneficiary account that exists."]
#![doc = " - Transferring a balance between accounts (when not reserved)."]
#![doc = " - Slashing an account balance."]
#![doc = " - Account creation and removal."]
#![doc = " - Managing total issuance."]
#![doc = " - Setting and managing locks."]
#![doc = ""]
#![doc = " ### Terminology"]
#![doc = ""]
#![doc = " - **Existential Deposit:** The minimum balance required to create or keep an account open. This prevents"]
#![doc = " \"dust accounts\" from filling storage."]
#![doc = " - **Total Issuance:** The total number of units in existence in a system."]
#![doc = " - **Reaping an account:** The act of removing an account by resetting its nonce. Happens after its balance is set"]
#![doc = " to zero."]
#![doc = " - **Free Balance:** The portion of a balance that is not reserved. The free balance is the only"]
#![doc = " balance that matters for most operations. When this balance falls below the existential"]
#![doc = " deposit, most functionality of the account is removed. When both it and the reserved balance"]
#![doc = " are deleted, then the account is said to be dead."]
#![doc = ""]
#![doc = " No account should ever have a free balance that is strictly between 0 and the existential"]
#![doc = " deposit (exclusive). If this ever happens, it indicates either a bug in this module or an"]
#![doc = " erroneous raw mutation of storage."]
#![doc = ""]
#![doc = " - **Reserved Balance:** Reserved balance still belongs to the account holder, but is suspended."]
#![doc = " Reserved balance can still be slashed, but only after all the free balance has been slashed."]
#![doc = " If the reserved balance falls below the existential deposit, it and any related functionality"]
#![doc = " will be deleted. When both it and the free balance are deleted, then the account is said to"]
#![doc = " be dead."]
#![doc = ""]
#![doc = " No account should ever have a reserved balance that is strictly between 0 and the existential"]
#![doc = " deposit (exclusive). If this ever happens, it indicates either a bug in this module or an"]
#![doc = " erroneous raw mutation of storage."]
#![doc = ""]
#![doc = " - **Imbalance:** A condition when some funds were credited or debited without equal and opposite accounting"]
#![doc = " (i.e. a difference between total issuance and account balances). Functions that result in an imbalance will"]
#![doc = " return an object of the `Imbalance` trait that can be managed within your runtime logic. (If an imbalance is"]
#![doc = " simply dropped, it should automatically maintain any book-keeping such as total issuance.)"]
#![doc = " - **Lock:** A freeze on a specified amount of an account\'s free balance until a specified block number. Multiple"]
#![doc = " locks always operate over the same funds, so they \"overlay\" rather than \"stack\"."]
#![doc = " - **Vesting:** Similar to a lock, this is another, but independent, liquidity restriction that reduces linearly"]
#![doc = " over time."]
#![doc = ""]
#![doc = " ### Implementations"]
#![doc = ""]
#![doc = " The Balances module provides implementations for the following traits. If these traits provide the functionality"]
#![doc = " that you need, then you can avoid coupling with the Balances module."]
#![doc = ""]
#![doc = " - [`Currency`](../palette_support/traits/trait.Currency.html): Functions for dealing with a"]
#![doc = " fungible assets system."]
#![doc = " - [`ReservableCurrency`](../palette_support/traits/trait.ReservableCurrency.html):"]
#![doc = " Functions for dealing with assets that can be reserved from an account."]
#![doc = " - [`LockableCurrency`](../palette_support/traits/trait.LockableCurrency.html): Functions for"]
#![doc = " dealing with accounts that allow liquidity restrictions."]
#![doc = " - [`Imbalance`](../palette_support/traits/trait.Imbalance.html): Functions for handling"]
#![doc = " imbalances between total issuance in the system and account balances. Must be used when a function"]
#![doc = " creates new funds (e.g. a reward) or destroys some funds (e.g. a system fee)."]
#![doc = " - [`IsDeadAccount`](../palette_system/trait.IsDeadAccount.html): Determiner to say whether a"]
#![doc = " given account is unused."]
#![doc = ""]
#![doc = " ## Interface"]
#![doc = ""]
#![doc = " ### Dispatchable Functions"]
#![doc = ""]
#![doc = " - `transfer` - Transfer some liquid free balance to another account."]
#![doc = " - `set_balance` - Set the balances of a given account. The origin of this call must be root."]
#![doc = ""]
#![doc = " ### Public Functions"]
#![doc = ""]
#![doc = " - `vesting_balance` - Get the amount that is currently being vested and cannot be transferred out of this account."]
#![doc = ""]
#![doc = " ## Usage"]
#![doc = ""]
#![doc = " The following examples show how to use the Balances module in your custom module."]
#![doc = ""]
#![doc = " ### Examples from the SRML"]
#![doc = ""]
#![doc = " The Contract module uses the `Currency` trait to handle gas payment, and its types inherit from `Currency`:"]
#![doc = ""]
#![doc = " ```"]
#![doc = " use support::traits::Currency;"]
#![doc = " # pub trait Trait: system::Trait {"]
#![doc = " # \ttype Currency: Currency<Self::AccountId>;"]
#![doc = " # }"]
#![doc = ""]
#![doc = " pub type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;"]
#![doc = " pub type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;"]
#![doc = ""]
#![doc = " # fn main() {}"]
#![doc = " ```"]
#![doc = ""]
#![doc = " The Staking module uses the `LockableCurrency` trait to lock a stash account\'s funds:"]
#![doc = ""]
#![doc = " ```"]
#![doc = " use support::traits::{WithdrawReasons, LockableCurrency};"]
#![doc = " use sr_primitives::traits::Bounded;"]
#![doc = " pub trait Trait: system::Trait {"]
#![doc = " \ttype Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;"]
#![doc = " }"]
#![doc = " # struct StakingLedger<T: Trait> {"]
#![doc = " # \tstash: <T as system::Trait>::AccountId,"]
#![doc = " # \ttotal: <<T as Trait>::Currency as support::traits::Currency<<T as system::Trait>::AccountId>>::Balance,"]
#![doc = " # \tphantom: std::marker::PhantomData<T>,"]
#![doc = " # }"]
#![doc = " # const STAKING_ID: [u8; 8] = *b\"staking \";"]
#![doc = ""]
#![doc = " fn update_ledger<T: Trait>("]
#![doc = " \tcontroller: &T::AccountId,"]
#![doc = " \tledger: &StakingLedger<T>"]
#![doc = " ) {"]
#![doc = " \tT::Currency::set_lock("]
#![doc = " \t\tSTAKING_ID,"]
#![doc = " \t\t&ledger.stash,"]
#![doc = " \t\tledger.total,"]
#![doc = " \t\tT::BlockNumber::max_value(),"]
#![doc = " \t\tWithdrawReasons::all()"]
#![doc = " \t);"]
#![doc = " \t// <Ledger<T>>::insert(controller, ledger); // Commented out as we don\'t have access to Staking\'s storage here."]
#![doc = " }"]
#![doc = " # fn main() {}"]
#![doc = " ```"]
#![doc = ""]
#![doc = " ## Genesis config"]
#![doc = ""]
#![doc = " The Balances module depends on the [`GenesisConfig`](./struct.GenesisConfig.html)."]
#![doc = ""]
#![doc = " ## Assumptions"]
#![doc = ""]
#![doc = " * Total issued balanced of all accounts should be less than `Trait::Balance::max_value()`."]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
pub use self::imbalances::{NegativeImbalance, PositiveImbalance};
use codec::{Codec, Decode, Encode};
use rstd::prelude::*;
use rstd::{cmp, fmt::Debug, mem, result};
use sr_primitives::{
traits::{
Bounded, CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Member, Saturating,
SimpleArithmetic, StaticLookup, Zero,
},
weights::SimpleDispatchInfo,
RuntimeDebug,
};
use support::{
decl_event, decl_module, decl_storage,
dispatch::Result,
traits::{
Currency, ExistenceRequirement, Get, Imbalance, LockIdentifier, LockableCurrency,
OnFreeBalanceZero, OnUnbalanced, ReservableCurrency, SignedImbalance, TryDrop,
UpdateBalanceOutcome, WithdrawReason, WithdrawReasons,
},
Parameter, StorageValue,
};
use system::{ensure_root, ensure_signed, IsDeadAccount, OnNewAccount};
pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
#[doc = " The balance of an account."]
type Balance: Parameter
+ Member
+ SimpleArithmetic
+ Codec
+ Default
+ Copy
+ MaybeSerializeDeserialize
+ Debug
+ From<Self::BlockNumber>;
#[doc = " A function that is invoked when the free-balance has fallen below the existential deposit and"]
#[doc = " has been reduced to zero."]
#[doc = ""]
#[doc = " Gives a chance to clean up resources associated with the given account."]
type OnFreeBalanceZero: OnFreeBalanceZero<Self::AccountId>;
#[doc = " Handler for when a new account is created."]
type OnNewAccount: OnNewAccount<Self::AccountId>;
#[doc = " The minimum amount required to keep an account open."]
type ExistentialDeposit: Get<Self::Balance>;
#[doc = " The fee required to make a transfer."]
type TransferFee: Get<Self::Balance>;
#[doc = " The fee required to create an account."]
type CreationFee: Get<Self::Balance>;
}
pub trait Trait<I: Instance = DefaultInstance>: system::Trait {
#[doc = " The balance of an account."]
type Balance: Parameter
+ Member
+ SimpleArithmetic
+ Codec
+ Default
+ Copy
+ MaybeSerializeDeserialize
+ Debug
+ From<Self::BlockNumber>;
#[doc = " A function that is invoked when the free-balance has fallen below the existential deposit and"]
#[doc = " has been reduced to zero."]
#[doc = ""]
#[doc = " Gives a chance to clean up resources associated with the given account."]
type OnFreeBalanceZero: OnFreeBalanceZero<Self::AccountId>;
#[doc = " Handler for when a new account is created."]
type OnNewAccount: OnNewAccount<Self::AccountId>;
#[doc = " Handler for the unbalanced reduction when taking fees associated with balance"]
#[doc = " transfer (which may also include account creation)."]
type TransferPayment: OnUnbalanced<NegativeImbalance<Self, I>>;
#[doc = " Handler for the unbalanced reduction when removing a dust account."]
type DustRemoval: OnUnbalanced<NegativeImbalance<Self, I>>;
#[doc = " The overarching event type."]
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
#[doc = " The minimum amount required to keep an account open."]
type ExistentialDeposit: Get<Self::Balance>;
#[doc = " The fee required to make a transfer."]
type TransferFee: Get<Self::Balance>;
#[doc = " The fee required to create an account."]
type CreationFee: Get<Self::Balance>;
}
impl<T: Trait<I>, I: Instance> Subtrait<I> for T {
type Balance = T::Balance;
type OnFreeBalanceZero = T::OnFreeBalanceZero;
type OnNewAccount = T::OnNewAccount;
type ExistentialDeposit = T::ExistentialDeposit;
type TransferFee = T::TransferFee;
type CreationFee = T::CreationFee;
}
#[doc = " [`RawEvent`] specialized for the configuration [`Trait`]"]
#[doc = ""]
#[doc = " [`RawEvent`]: enum.RawEvent.html"]
#[doc = " [`Trait`]: trait.Trait.html"]
pub type Event<T, I = DefaultInstance> =
RawEvent<<T as system::Trait>::AccountId, <T as Trait<I>>::Balance, I>;
#[doc = " Events for this module."]
#[doc = ""]
pub enum RawEvent<AccountId, Balance, I> {
#[doc = r" A new account was created."]
NewAccount(AccountId, Balance),
#[doc = r" An account was reaped."]
ReapedAccount(AccountId),
#[doc = r" Transfer succeeded (from, to, value, fees)."]
Transfer(AccountId, AccountId, Balance, Balance),
#[doc(hidden)]
#[codec(skip)]
PhantomData(::palette_support::rstd::marker::PhantomData<I>),
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<AccountId: ::core::clone::Clone, Balance: ::core::clone::Clone, I: ::core::clone::Clone>
::core::clone::Clone for RawEvent<AccountId, Balance, I>
{
#[inline]
fn clone(&self) -> RawEvent<AccountId, Balance, I> {
match (&*self,) {
(&RawEvent::NewAccount(ref __self_0, ref __self_1),) => RawEvent::NewAccount(
::core::clone::Clone::clone(&(*__self_0)),
::core::clone::Clone::clone(&(*__self_1)),
),
(&RawEvent::ReapedAccount(ref __self_0),) => {
RawEvent::ReapedAccount(::core::clone::Clone::clone(&(*__self_0)))
}
(&RawEvent::Transfer(ref __self_0, ref __self_1, ref __self_2, ref __self_3),) => {
RawEvent::Transfer(
::core::clone::Clone::clone(&(*__self_0)),
::core::clone::Clone::clone(&(*__self_1)),
::core::clone::Clone::clone(&(*__self_2)),
::core::clone::Clone::clone(&(*__self_3)),
)
}
(&RawEvent::PhantomData(ref __self_0),) => {
RawEvent::PhantomData(::core::clone::Clone::clone(&(*__self_0)))
}
}
}
}
impl<AccountId, Balance, I> ::core::marker::StructuralPartialEq
for RawEvent<AccountId, Balance, I>
{
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<
AccountId: ::core::cmp::PartialEq,
Balance: ::core::cmp::PartialEq,
I: ::core::cmp::PartialEq,
> ::core::cmp::PartialEq for RawEvent<AccountId, Balance, I>
{
#[inline]
fn eq(&self, other: &RawEvent<AccountId, Balance, I>) -> bool {
{
let __self_vi = unsafe { ::core::intrinsics::discriminant_value(&*self) } as isize;
let __arg_1_vi = unsafe { ::core::intrinsics::discriminant_value(&*other) } as isize;
if true && __self_vi == __arg_1_vi {
match (&*self, &*other) {
(
&RawEvent::NewAccount(ref __self_0, ref __self_1),
&RawEvent::NewAccount(ref __arg_1_0, ref __arg_1_1),
) => (*__self_0) == (*__arg_1_0) && (*__self_1) == (*__arg_1_1),
(
&RawEvent::ReapedAccount(ref __self_0),
&RawEvent::ReapedAccount(ref __arg_1_0),
) => (*__self_0) == (*__arg_1_0),
(
&RawEvent::Transfer(ref __self_0, ref __self_1, ref __self_2, ref __self_3),
&RawEvent::Transfer(
ref __arg_1_0,
ref __arg_1_1,
ref __arg_1_2,
ref __arg_1_3,
),
) => {
(*__self_0) == (*__arg_1_0)
&& (*__self_1) == (*__arg_1_1)
&& (*__self_2) == (*__arg_1_2)
&& (*__self_3) == (*__arg_1_3)
}
(
&RawEvent::PhantomData(ref __self_0),
&RawEvent::PhantomData(ref __arg_1_0),
) => (*__self_0) == (*__arg_1_0),
_ => unsafe { ::core::intrinsics::unreachable() },
}
} else {
false
}
}
}
#[inline]
fn ne(&self, other: &RawEvent<AccountId, Balance, I>) -> bool {
{
let __self_vi = unsafe { ::core::intrinsics::discriminant_value(&*self) } as isize;
let __arg_1_vi = unsafe { ::core::intrinsics::discriminant_value(&*other) } as isize;
if true && __self_vi == __arg_1_vi {
match (&*self, &*other) {
(
&RawEvent::NewAccount(ref __self_0, ref __self_1),
&RawEvent::NewAccount(ref __arg_1_0, ref __arg_1_1),
) => (*__self_0) != (*__arg_1_0) || (*__self_1) != (*__arg_1_1),
(
&RawEvent::ReapedAccount(ref __self_0),
&RawEvent::ReapedAccount(ref __arg_1_0),
) => (*__self_0) != (*__arg_1_0),
(
&RawEvent::Transfer(ref __self_0, ref __self_1, ref __self_2, ref __self_3),
&RawEvent::Transfer(
ref __arg_1_0,
ref __arg_1_1,
ref __arg_1_2,
ref __arg_1_3,
),
) => {
(*__self_0) != (*__arg_1_0)
|| (*__self_1) != (*__arg_1_1)
|| (*__self_2) != (*__arg_1_2)
|| (*__self_3) != (*__arg_1_3)
}
(
&RawEvent::PhantomData(ref __self_0),
&RawEvent::PhantomData(ref __arg_1_0),
) => (*__self_0) != (*__arg_1_0),
_ => unsafe { ::core::intrinsics::unreachable() },
}
} else {
true
}
}
}
}
impl<AccountId, Balance, I> ::core::marker::StructuralEq for RawEvent<AccountId, Balance, I> {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<AccountId: ::core::cmp::Eq, Balance: ::core::cmp::Eq, I: ::core::cmp::Eq> ::core::cmp::Eq
for RawEvent<AccountId, Balance, I>
{
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{
let _: ::core::cmp::AssertParamIsEq<AccountId>;
let _: ::core::cmp::AssertParamIsEq<Balance>;
let _: ::core::cmp::AssertParamIsEq<AccountId>;
let _: ::core::cmp::AssertParamIsEq<AccountId>;
let _: ::core::cmp::AssertParamIsEq<AccountId>;
let _: ::core::cmp::AssertParamIsEq<Balance>;
let _: ::core::cmp::AssertParamIsEq<Balance>;
let _: ::core::cmp::AssertParamIsEq<::palette_support::rstd::marker::PhantomData<I>>;
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl<AccountId, Balance, I> _parity_scale_codec::Encode for RawEvent<AccountId, Balance, I>
where
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
{
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {
match *self {
RawEvent::NewAccount(ref aa, ref ba) => {
dest.push_byte(0usize as u8);
dest.push(aa);
dest.push(ba);
}
RawEvent::ReapedAccount(ref aa) => {
dest.push_byte(1usize as u8);
dest.push(aa);
}
RawEvent::Transfer(ref aa, ref ba, ref ca, ref da) => {
dest.push_byte(2usize as u8);
dest.push(aa);
dest.push(ba);
dest.push(ca);
dest.push(da);
}
_ => (),
}
}
}
impl<AccountId, Balance, I> _parity_scale_codec::EncodeLike for RawEvent<AccountId, Balance, I>
where
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
AccountId: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
{
}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl<AccountId, Balance, I> _parity_scale_codec::Decode for RawEvent<AccountId, Balance, I>
where
AccountId: _parity_scale_codec::Decode,
AccountId: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
AccountId: _parity_scale_codec::Decode,
AccountId: _parity_scale_codec::Decode,
AccountId: _parity_scale_codec::Decode,
AccountId: _parity_scale_codec::Decode,
AccountId: _parity_scale_codec::Decode,
AccountId: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
{
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
match input.read_byte()? {
x if x == 0usize as u8 => Ok(RawEvent::NewAccount(
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field RawEvent :: NewAccount.0".into())
}
Ok(a) => a,
}
},
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field RawEvent :: NewAccount.1".into())
}
Ok(a) => a,
}
},
)),
x if x == 1usize as u8 => Ok(RawEvent::ReapedAccount({
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field RawEvent :: ReapedAccount.0".into())
}
Ok(a) => a,
}
})),
x if x == 2usize as u8 => Ok(RawEvent::Transfer(
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field RawEvent :: Transfer.0".into())
}
Ok(a) => a,
}
},
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field RawEvent :: Transfer.1".into())
}
Ok(a) => a,
}
},
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field RawEvent :: Transfer.2".into())
}
Ok(a) => a,
}
},
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field RawEvent :: Transfer.3".into())
}
Ok(a) => a,
}
},
)),
x => Err("No such variant in enum RawEvent".into()),
}
}
}
};
impl<AccountId, Balance, I> core::fmt::Debug for RawEvent<AccountId, Balance, I>
where
AccountId: core::fmt::Debug,
Balance: core::fmt::Debug,
I: core::fmt::Debug,
{
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
Self::NewAccount(ref a0, ref a1) => fmt
.debug_tuple("RawEvent::NewAccount")
.field(a0)
.field(a1)
.finish(),
Self::ReapedAccount(ref a0) => fmt
.debug_tuple("RawEvent::ReapedAccount")
.field(a0)
.finish(),
Self::Transfer(ref a0, ref a1, ref a2, ref a3) => fmt
.debug_tuple("RawEvent::Transfer")
.field(a0)
.field(a1)
.field(a2)
.field(a3)
.finish(),
Self::PhantomData(ref a0) => {
fmt.debug_tuple("RawEvent::PhantomData").field(a0).finish()
}
_ => Ok(()),
}
}
}
impl<AccountId, Balance, I> From<RawEvent<AccountId, Balance, I>> for () {
fn from(_: RawEvent<AccountId, Balance, I>) -> () {
()
}
}
impl<AccountId, Balance, I> RawEvent<AccountId, Balance, I> {
#[allow(dead_code)]
pub fn metadata() -> &'static [::palette_support::event::EventMetadata] {
&[
::palette_support::event::EventMetadata {
name: ::palette_support::event::DecodeDifferent::Encode("NewAccount"),
arguments: ::palette_support::event::DecodeDifferent::Encode(&[
"AccountId",
"Balance",
]),
documentation: ::palette_support::event::DecodeDifferent::Encode(&[
r" A new account was created.",
]),
},
::palette_support::event::EventMetadata {
name: ::palette_support::event::DecodeDifferent::Encode("ReapedAccount"),
arguments: ::palette_support::event::DecodeDifferent::Encode(&["AccountId"]),
documentation: ::palette_support::event::DecodeDifferent::Encode(&[
r" An account was reaped.",
]),
},
::palette_support::event::EventMetadata {
name: ::palette_support::event::DecodeDifferent::Encode("Transfer"),
arguments: ::palette_support::event::DecodeDifferent::Encode(&[
"AccountId",
"AccountId",
"Balance",
"Balance",
]),
documentation: ::palette_support::event::DecodeDifferent::Encode(&[
r" Transfer succeeded (from, to, value, fees).",
]),
},
]
}
}
#[doc = " Struct to encode the vesting schedule of an individual account."]
pub struct VestingSchedule<Balance, BlockNumber> {
#[doc = " Locked amount at genesis."]
pub locked: Balance,
#[doc = " Amount that gets unlocked every block after `starting_block`."]
pub per_block: Balance,
#[doc = " Starting block for unlocking(vesting)."]
pub starting_block: BlockNumber,
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl<Balance, BlockNumber> _parity_scale_codec::Encode for VestingSchedule<Balance, BlockNumber>
where
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
BlockNumber: _parity_scale_codec::Encode,
BlockNumber: _parity_scale_codec::Encode,
{
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {
dest.push(&self.locked);
dest.push(&self.per_block);
dest.push(&self.starting_block);
}
}
impl<Balance, BlockNumber> _parity_scale_codec::EncodeLike for VestingSchedule<Balance, BlockNumber>
where
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
BlockNumber: _parity_scale_codec::Encode,
BlockNumber: _parity_scale_codec::Encode,
{
}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl<Balance, BlockNumber> _parity_scale_codec::Decode for VestingSchedule<Balance, BlockNumber>
where
Balance: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
BlockNumber: _parity_scale_codec::Decode,
BlockNumber: _parity_scale_codec::Decode,
{
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(VestingSchedule {
locked: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => return Err("Error decoding field VestingSchedule.locked".into()),
Ok(a) => a,
}
},
per_block: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field VestingSchedule.per_block".into())
}
Ok(a) => a,
}
},
starting_block: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field VestingSchedule.starting_block".into())
}
Ok(a) => a,
}
},
})
}
}
};
#[automatically_derived]
#[allow(unused_qualifications)]
impl<Balance: ::core::marker::Copy, BlockNumber: ::core::marker::Copy> ::core::marker::Copy
for VestingSchedule<Balance, BlockNumber>
{
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<Balance: ::core::clone::Clone, BlockNumber: ::core::clone::Clone> ::core::clone::Clone
for VestingSchedule<Balance, BlockNumber>
{
#[inline]
fn clone(&self) -> VestingSchedule<Balance, BlockNumber> {
match *self {
VestingSchedule {
locked: ref __self_0_0,
per_block: ref __self_0_1,
starting_block: ref __self_0_2,
} => VestingSchedule {
locked: ::core::clone::Clone::clone(&(*__self_0_0)),
per_block: ::core::clone::Clone::clone(&(*__self_0_1)),
starting_block: ::core::clone::Clone::clone(&(*__self_0_2)),
},
}
}
}
impl<Balance, BlockNumber> ::core::marker::StructuralPartialEq
for VestingSchedule<Balance, BlockNumber>
{
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<Balance: ::core::cmp::PartialEq, BlockNumber: ::core::cmp::PartialEq> ::core::cmp::PartialEq
for VestingSchedule<Balance, BlockNumber>
{
#[inline]
fn eq(&self, other: &VestingSchedule<Balance, BlockNumber>) -> bool {
match *other {
VestingSchedule {
locked: ref __self_1_0,
per_block: ref __self_1_1,
starting_block: ref __self_1_2,
} => match *self {
VestingSchedule {
locked: ref __self_0_0,
per_block: ref __self_0_1,
starting_block: ref __self_0_2,
} => {
(*__self_0_0) == (*__self_1_0)
&& (*__self_0_1) == (*__self_1_1)
&& (*__self_0_2) == (*__self_1_2)
}
},
}
}
#[inline]
fn ne(&self, other: &VestingSchedule<Balance, BlockNumber>) -> bool {
match *other {
VestingSchedule {
locked: ref __self_1_0,
per_block: ref __self_1_1,
starting_block: ref __self_1_2,
} => match *self {
VestingSchedule {
locked: ref __self_0_0,
per_block: ref __self_0_1,
starting_block: ref __self_0_2,
} => {
(*__self_0_0) != (*__self_1_0)
|| (*__self_0_1) != (*__self_1_1)
|| (*__self_0_2) != (*__self_1_2)
}
},
}
}
}
impl<Balance, BlockNumber> ::core::marker::StructuralEq for VestingSchedule<Balance, BlockNumber> {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<Balance: ::core::cmp::Eq, BlockNumber: ::core::cmp::Eq> ::core::cmp::Eq
for VestingSchedule<Balance, BlockNumber>
{
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{
let _: ::core::cmp::AssertParamIsEq<Balance>;
let _: ::core::cmp::AssertParamIsEq<Balance>;
let _: ::core::cmp::AssertParamIsEq<BlockNumber>;
}
}
}
impl<Balance, BlockNumber> core::fmt::Debug for VestingSchedule<Balance, BlockNumber>
where
Balance: core::fmt::Debug,
BlockNumber: core::fmt::Debug,
{
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_struct("VestingSchedule")
.field("locked", &self.locked)
.field("per_block", &self.per_block)
.field("starting_block", &self.starting_block)
.finish()
}
}
impl<Balance: SimpleArithmetic + Copy, BlockNumber: SimpleArithmetic + Copy>
VestingSchedule<Balance, BlockNumber>
{
#[doc = " Amount locked at block `n`."]
pub fn locked_at(&self, n: BlockNumber) -> Balance
where
Balance: From<BlockNumber>,
{
let vested_block_count = n.saturating_sub(self.starting_block);
if let Some(x) = Balance::from(vested_block_count).checked_mul(&self.per_block) {
self.locked.max(x) - x
} else {
Zero::zero()
}
}
}
pub struct BalanceLock<Balance, BlockNumber> {
pub id: LockIdentifier,
pub amount: Balance,
pub until: BlockNumber,
pub reasons: WithdrawReasons,
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl<Balance, BlockNumber> _parity_scale_codec::Encode for BalanceLock<Balance, BlockNumber>
where
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
BlockNumber: _parity_scale_codec::Encode,
BlockNumber: _parity_scale_codec::Encode,
{
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {
dest.push(&self.id);
dest.push(&self.amount);
dest.push(&self.until);
dest.push(&self.reasons);
}
}
impl<Balance, BlockNumber> _parity_scale_codec::EncodeLike for BalanceLock<Balance, BlockNumber>
where
Balance: _parity_scale_codec::Encode,
Balance: _parity_scale_codec::Encode,
BlockNumber: _parity_scale_codec::Encode,
BlockNumber: _parity_scale_codec::Encode,
{
}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl<Balance, BlockNumber> _parity_scale_codec::Decode for BalanceLock<Balance, BlockNumber>
where
Balance: _parity_scale_codec::Decode,
Balance: _parity_scale_codec::Decode,
BlockNumber: _parity_scale_codec::Decode,
BlockNumber: _parity_scale_codec::Decode,
{
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(BalanceLock {
id: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => return Err("Error decoding field BalanceLock.id".into()),
Ok(a) => a,
}
},
amount: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => return Err("Error decoding field BalanceLock.amount".into()),
Ok(a) => a,
}
},
until: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => return Err("Error decoding field BalanceLock.until".into()),
Ok(a) => a,
}
},
reasons: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => return Err("Error decoding field BalanceLock.reasons".into()),
Ok(a) => a,
}
},
})
}
}
};
#[automatically_derived]
#[allow(unused_qualifications)]
impl<Balance: ::core::clone::Clone, BlockNumber: ::core::clone::Clone> ::core::clone::Clone
for BalanceLock<Balance, BlockNumber>
{
#[inline]
fn clone(&self) -> BalanceLock<Balance, BlockNumber> {
match *self {
BalanceLock {
id: ref __self_0_0,
amount: ref __self_0_1,
until: ref __self_0_2,
reasons: ref __self_0_3,
} => BalanceLock {
id: ::core::clone::Clone::clone(&(*__self_0_0)),
amount: ::core::clone::Clone::clone(&(*__self_0_1)),
until: ::core::clone::Clone::clone(&(*__self_0_2)),
reasons: ::core::clone::Clone::clone(&(*__self_0_3)),
},
}
}
}
impl<Balance, BlockNumber> ::core::marker::StructuralPartialEq
for BalanceLock<Balance, BlockNumber>
{
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<Balance: ::core::cmp::PartialEq, BlockNumber: ::core::cmp::PartialEq> ::core::cmp::PartialEq
for BalanceLock<Balance, BlockNumber>
{
#[inline]
fn eq(&self, other: &BalanceLock<Balance, BlockNumber>) -> bool {
match *other {
BalanceLock {
id: ref __self_1_0,
amount: ref __self_1_1,
until: ref __self_1_2,
reasons: ref __self_1_3,
} => match *self {
BalanceLock {
id: ref __self_0_0,
amount: ref __self_0_1,
until: ref __self_0_2,
reasons: ref __self_0_3,
} => {
(*__self_0_0) == (*__self_1_0)
&& (*__self_0_1) == (*__self_1_1)
&& (*__self_0_2) == (*__self_1_2)
&& (*__self_0_3) == (*__self_1_3)
}
},
}
}
#[inline]
fn ne(&self, other: &BalanceLock<Balance, BlockNumber>) -> bool {
match *other {
BalanceLock {
id: ref __self_1_0,
amount: ref __self_1_1,
until: ref __self_1_2,
reasons: ref __self_1_3,
} => match *self {
BalanceLock {
id: ref __self_0_0,
amount: ref __self_0_1,
until: ref __self_0_2,
reasons: ref __self_0_3,
} => {
(*__self_0_0) != (*__self_1_0)
|| (*__self_0_1) != (*__self_1_1)
|| (*__self_0_2) != (*__self_1_2)
|| (*__self_0_3) != (*__self_1_3)
}
},
}
}
}
impl<Balance, BlockNumber> ::core::marker::StructuralEq for BalanceLock<Balance, BlockNumber> {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<Balance: ::core::cmp::Eq, BlockNumber: ::core::cmp::Eq> ::core::cmp::Eq
for BalanceLock<Balance, BlockNumber>
{
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{
let _: ::core::cmp::AssertParamIsEq<LockIdentifier>;
let _: ::core::cmp::AssertParamIsEq<Balance>;
let _: ::core::cmp::AssertParamIsEq<BlockNumber>;
let _: ::core::cmp::AssertParamIsEq<WithdrawReasons>;
}
}
}
impl<Balance, BlockNumber> core::fmt::Debug for BalanceLock<Balance, BlockNumber>
where
Balance: core::fmt::Debug,
BlockNumber: core::fmt::Debug,
{
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_struct("BalanceLock")
.field("id", &self.id)
.field("amount", &self.amount)
.field("until", &self.until)
.field("reasons", &self.reasons)
.finish()
}
}
use self::sr_api_hidden_includes_decl_storage::hidden_include::{
StorageDoubleMap as _, StorageLinkedMap as _, StorageMap as _, StorageValue as _,
};
#[doc(hidden)]
mod sr_api_hidden_includes_decl_storage {
pub extern crate support as hidden_include;
}
trait Store {
type TotalIssuance;
type Vesting;
type FreeBalance;
type ReservedBalance;
type Locks;
}
impl<T: Trait<I> + 'static, I: Instance> Store for Module<T, I> {
type TotalIssuance = TotalIssuance<T, I>;
type Vesting = Vesting<T, I>;
type FreeBalance = FreeBalance<T, I>;
type ReservedBalance = ReservedBalance<T, I>;
type Locks = Locks<T, I>;
}
impl<T: Trait<I> + 'static, I: Instance> Module<T, I> {
#[doc = " The total units issued in the system."]
pub fn total_issuance() -> T::Balance {
< TotalIssuance < T , I > as self :: sr_api_hidden_includes_decl_storage :: hidden_include :: storage :: StorageValue < T :: Balance > > :: get ( )
}
#[doc = " Information regarding the vesting of a given account."]
pub fn vesting<
K: self::sr_api_hidden_includes_decl_storage::hidden_include::codec::EncodeLike<T::AccountId>,
>(
key: K,
) -> Option<VestingSchedule<T::Balance, T::BlockNumber>> {
< Vesting < T , I > as self :: sr_api_hidden_includes_decl_storage :: hidden_include :: storage :: StorageMap < T :: AccountId , VestingSchedule < T :: Balance , T :: BlockNumber > > > :: get ( key )
}
#[doc = " The \'free\' balance of a given account."]
#[doc = ""]
#[doc = " This is the only balance that matters in terms of most operations on tokens. It"]
#[doc = " alone is used to determine the balance when in the contract execution environment. When this"]
#[doc = " balance falls below the value of `ExistentialDeposit`, then the \'current account\' is"]
#[doc = " deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback"]
#[doc = " is invoked, giving a chance to external modules to clean up data associated with"]
#[doc = " the deleted account."]
#[doc = ""]
#[doc = " `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets"]
#[doc = " collapsed to zero if it ever becomes less than `ExistentialDeposit`."]
pub fn free_balance<
K: self::sr_api_hidden_includes_decl_storage::hidden_include::codec::EncodeLike<T::AccountId>,
>(
key: K,
) -> T::Balance {
< FreeBalance < T , I > as self :: sr_api_hidden_includes_decl_storage :: hidden_include :: storage :: StorageMap < T :: AccountId , T :: Balance > > :: get ( key )
}
#[doc = " The amount of the balance of a given account that is externally reserved; this can still get"]
#[doc = " slashed, but gets slashed last of all."]
#[doc = ""]
#[doc = " This balance is a \'reserve\' balance that other subsystems use in order to set aside tokens"]
#[doc = " that are still \'owned\' by the account holder, but which are suspendable."]
#[doc = ""]
#[doc = " When this balance falls below the value of `ExistentialDeposit`, then this \'reserve account\'"]
#[doc = " is deleted: specifically, `ReservedBalance`."]
#[doc = ""]
#[doc = " `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets"]
#[doc = " collapsed to zero if it ever becomes less than `ExistentialDeposit`.)"]
pub fn reserved_balance<
K: self::sr_api_hidden_includes_decl_storage::hidden_include::codec::EncodeLike<T::AccountId>,
>(
key: K,
) -> T::Balance {
< ReservedBalance < T , I > as self :: sr_api_hidden_includes_decl_storage :: hidden_include :: storage :: StorageMap < T :: AccountId , T :: Balance > > :: get ( key )
}
#[doc = " Any liquidity locks on some account balances."]
pub fn locks<
K: self::sr_api_hidden_includes_decl_storage::hidden_include::codec::EncodeLike<T::AccountId>,
>(
key: K,
) -> Vec<BalanceLock<T::Balance, T::BlockNumber>> {
< Locks < T , I > as self :: sr_api_hidden_includes_decl_storage :: hidden_include :: storage :: StorageMap < T :: AccountId , Vec < BalanceLock < T :: Balance , T :: BlockNumber > > > > :: get ( key )
}
}
#[doc(hidden)]
pub struct __GetByteStructTotalIssuance<T, I: Instance = DefaultInstance>(
pub self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(
T,
I,
)>,
);
#[cfg(feature = "std")]
#[allow(non_upper_case_globals)]
static __CACHE_GET_BYTE_STRUCT_TotalIssuance:
self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell<
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8>,
> = self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell::new();
#[cfg(feature = "std")]
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::metadata::DefaultByte
for __GetByteStructTotalIssuance<T, I>
{
fn default_byte(
&self,
) -> self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8> {
use self::sr_api_hidden_includes_decl_storage::hidden_include::codec::Encode;
__CACHE_GET_BYTE_STRUCT_TotalIssuance
.get_or_init(|| {
let def_val: T::Balance = Default::default();
<T::Balance as Encode>::encode(&def_val)
})
.clone()
}
}
unsafe impl<T: Trait<I>, I: Instance> Send for __GetByteStructTotalIssuance<T, I> {}
unsafe impl<T: Trait<I>, I: Instance> Sync for __GetByteStructTotalIssuance<T, I> {}
#[doc(hidden)]
pub struct __GetByteStructVesting<T, I: Instance = DefaultInstance>(
pub self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(
T,
I,
)>,
);
#[cfg(feature = "std")]
#[allow(non_upper_case_globals)]
static __CACHE_GET_BYTE_STRUCT_Vesting:
self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell<
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8>,
> = self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell::new();
#[cfg(feature = "std")]
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::metadata::DefaultByte
for __GetByteStructVesting<T, I>
{
fn default_byte(
&self,
) -> self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8> {
use self::sr_api_hidden_includes_decl_storage::hidden_include::codec::Encode;
__CACHE_GET_BYTE_STRUCT_Vesting
.get_or_init(|| {
let def_val: Option<VestingSchedule<T::Balance, T::BlockNumber>> =
Default::default();
<Option<VestingSchedule<T::Balance, T::BlockNumber>> as Encode>::encode(&def_val)
})
.clone()
}
}
unsafe impl<T: Trait<I>, I: Instance> Send for __GetByteStructVesting<T, I> {}
unsafe impl<T: Trait<I>, I: Instance> Sync for __GetByteStructVesting<T, I> {}
#[doc(hidden)]
pub struct __GetByteStructFreeBalance<T, I: Instance = DefaultInstance>(
pub self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(
T,
I,
)>,
);
#[cfg(feature = "std")]
#[allow(non_upper_case_globals)]
static __CACHE_GET_BYTE_STRUCT_FreeBalance:
self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell<
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8>,
> = self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell::new();
#[cfg(feature = "std")]
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::metadata::DefaultByte
for __GetByteStructFreeBalance<T, I>
{
fn default_byte(
&self,
) -> self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8> {
use self::sr_api_hidden_includes_decl_storage::hidden_include::codec::Encode;
__CACHE_GET_BYTE_STRUCT_FreeBalance
.get_or_init(|| {
let def_val: T::Balance = Default::default();
<T::Balance as Encode>::encode(&def_val)
})
.clone()
}
}
unsafe impl<T: Trait<I>, I: Instance> Send for __GetByteStructFreeBalance<T, I> {}
unsafe impl<T: Trait<I>, I: Instance> Sync for __GetByteStructFreeBalance<T, I> {}
#[doc(hidden)]
pub struct __GetByteStructReservedBalance<T, I: Instance = DefaultInstance>(
pub self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(
T,
I,
)>,
);
#[cfg(feature = "std")]
#[allow(non_upper_case_globals)]
static __CACHE_GET_BYTE_STRUCT_ReservedBalance:
self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell<
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8>,
> = self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell::new();
#[cfg(feature = "std")]
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::metadata::DefaultByte
for __GetByteStructReservedBalance<T, I>
{
fn default_byte(
&self,
) -> self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8> {
use self::sr_api_hidden_includes_decl_storage::hidden_include::codec::Encode;
__CACHE_GET_BYTE_STRUCT_ReservedBalance
.get_or_init(|| {
let def_val: T::Balance = Default::default();
<T::Balance as Encode>::encode(&def_val)
})
.clone()
}
}
unsafe impl<T: Trait<I>, I: Instance> Send for __GetByteStructReservedBalance<T, I> {}
unsafe impl<T: Trait<I>, I: Instance> Sync for __GetByteStructReservedBalance<T, I> {}
#[doc(hidden)]
pub struct __GetByteStructLocks<T, I: Instance = DefaultInstance>(
pub self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(
T,
I,
)>,
);
#[cfg(feature = "std")]
#[allow(non_upper_case_globals)]
static __CACHE_GET_BYTE_STRUCT_Locks:
self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell<
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8>,
> = self::sr_api_hidden_includes_decl_storage::hidden_include::once_cell::sync::OnceCell::new();
#[cfg(feature = "std")]
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::metadata::DefaultByte
for __GetByteStructLocks<T, I>
{
fn default_byte(
&self,
) -> self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::vec::Vec<u8> {
use self::sr_api_hidden_includes_decl_storage::hidden_include::codec::Encode;
__CACHE_GET_BYTE_STRUCT_Locks
.get_or_init(|| {
let def_val: Vec<BalanceLock<T::Balance, T::BlockNumber>> = Default::default();
<Vec<BalanceLock<T::Balance, T::BlockNumber>> as Encode>::encode(&def_val)
})
.clone()
}
}
unsafe impl<T: Trait<I>, I: Instance> Send for __GetByteStructLocks<T, I> {}
unsafe impl<T: Trait<I>, I: Instance> Sync for __GetByteStructLocks<T, I> {}
impl<T: Trait<I> + 'static, I: Instance> Module<T, I> {
#[doc(hidden)]
pub fn storage_metadata(
) -> self::sr_api_hidden_includes_decl_storage::hidden_include::metadata::StorageMetadata {
self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageMetadata { prefix : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( I :: PREFIX ) , entries : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( & [ self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryMetadata { name : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "TotalIssuance" ) , modifier : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryModifier :: Default , ty : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryType :: Plain ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "T::Balance" ) ) , default : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DefaultByteGetter ( & __GetByteStructTotalIssuance :: < T , I > ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: rstd :: marker :: PhantomData ) ) ) , documentation : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( & [ " The total units issued in the system." ] ) , } , self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryMetadata { name : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "Vesting" ) , modifier : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryModifier :: Optional , ty : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryType :: Map { hasher : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageHasher :: Blake2_256 , key : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "T::AccountId" ) , value : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "VestingSchedule<T::Balance, T::BlockNumber>" ) , is_linked : false , } , default : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DefaultByteGetter ( & __GetByteStructVesting :: < T , I > ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: rstd :: marker :: PhantomData ) ) ) , documentation : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( & [ " Information regarding the vesting of a given account." ] ) , } , self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryMetadata { name : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "FreeBalance" ) , modifier : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryModifier :: Default , ty : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryType :: Map { hasher : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageHasher :: Blake2_256 , key : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "T::AccountId" ) , value : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "T::Balance" ) , is_linked : false , } , default : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DefaultByteGetter ( & __GetByteStructFreeBalance :: < T , I > ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: rstd :: marker :: PhantomData ) ) ) , documentation : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( & [ " The \'free\' balance of a given account." , "" , " This is the only balance that matters in terms of most operations on tokens. It" , " alone is used to determine the balance when in the contract execution environment. When this" , " balance falls below the value of `ExistentialDeposit`, then the \'current account\' is" , " deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback" , " is invoked, giving a chance to external modules to clean up data associated with" , " the deleted account." , "" , " `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets" , " collapsed to zero if it ever becomes less than `ExistentialDeposit`." ] ) , } , self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryMetadata { name : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "ReservedBalance" ) , modifier : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryModifier :: Default , ty : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryType :: Map { hasher : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageHasher :: Blake2_256 , key : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "T::AccountId" ) , value : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "T::Balance" ) , is_linked : false , } , default : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DefaultByteGetter ( & __GetByteStructReservedBalance :: < T , I > ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: rstd :: marker :: PhantomData ) ) ) , documentation : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( & [ " The amount of the balance of a given account that is externally reserved; this can still get" , " slashed, but gets slashed last of all." , "" , " This balance is a \'reserve\' balance that other subsystems use in order to set aside tokens" , " that are still \'owned\' by the account holder, but which are suspendable." , "" , " When this balance falls below the value of `ExistentialDeposit`, then this \'reserve account\'" , " is deleted: specifically, `ReservedBalance`." , "" , " `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets" , " collapsed to zero if it ever becomes less than `ExistentialDeposit`.)" ] ) , } , self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryMetadata { name : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "Locks" ) , modifier : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryModifier :: Default , ty : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageEntryType :: Map { hasher : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: StorageHasher :: Blake2_256 , key : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "T::AccountId" ) , value : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( "Vec<BalanceLock<T::Balance, T::BlockNumber>>" ) , is_linked : false , } , default : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DefaultByteGetter ( & __GetByteStructLocks :: < T , I > ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: rstd :: marker :: PhantomData ) ) ) , documentation : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: metadata :: DecodeDifferent :: Encode ( & [ " Any liquidity locks on some account balances." ] ) , } ] [ .. ] ) , }
}
}
#[doc = r" Tag a type as an instance of a module."]
#[doc = r""]
#[doc = r" Defines storage prefixes, they must be unique."]
pub trait Instance: 'static {
#[doc = r" The prefix used by any storage entry of an instance."]
const PREFIX: &'static str;
const PREFIX_FOR_TotalIssuance: &'static str;
const PREFIX_FOR_Vesting: &'static str;
const PREFIX_FOR_FreeBalance: &'static str;
const PREFIX_FOR_ReservedBalance: &'static str;
const PREFIX_FOR_Locks: &'static str;
}
#[doc = r"Module instance"]
pub struct Instance0;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance0 {
#[inline]
fn clone(&self) -> Instance0 {
match *self {
Instance0 => Instance0,
}
}
}
impl ::core::marker::StructuralEq for Instance0 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance0 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance0 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance0 {
#[inline]
fn eq(&self, other: &Instance0) -> bool {
match *other {
Instance0 => match *self {
Instance0 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance0 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance0 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance0 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance0)
}
}
};
impl core::fmt::Debug for Instance0 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance0").finish()
}
}
impl Instance for Instance0 {
const PREFIX: &'static str = "Instance0Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance0Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance0Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance0Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance0Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance0Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance1;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance1 {
#[inline]
fn clone(&self) -> Instance1 {
match *self {
Instance1 => Instance1,
}
}
}
impl ::core::marker::StructuralEq for Instance1 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance1 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance1 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance1 {
#[inline]
fn eq(&self, other: &Instance1) -> bool {
match *other {
Instance1 => match *self {
Instance1 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance1 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance1 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance1 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance1)
}
}
};
impl core::fmt::Debug for Instance1 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance1").finish()
}
}
impl Instance for Instance1 {
const PREFIX: &'static str = "Instance1Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance1Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance1Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance1Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance1Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance1Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance2;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance2 {
#[inline]
fn clone(&self) -> Instance2 {
match *self {
Instance2 => Instance2,
}
}
}
impl ::core::marker::StructuralEq for Instance2 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance2 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance2 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance2 {
#[inline]
fn eq(&self, other: &Instance2) -> bool {
match *other {
Instance2 => match *self {
Instance2 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance2 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance2 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance2 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance2)
}
}
};
impl core::fmt::Debug for Instance2 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance2").finish()
}
}
impl Instance for Instance2 {
const PREFIX: &'static str = "Instance2Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance2Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance2Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance2Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance2Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance2Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance3;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance3 {
#[inline]
fn clone(&self) -> Instance3 {
match *self {
Instance3 => Instance3,
}
}
}
impl ::core::marker::StructuralEq for Instance3 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance3 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance3 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance3 {
#[inline]
fn eq(&self, other: &Instance3) -> bool {
match *other {
Instance3 => match *self {
Instance3 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance3 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance3 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance3 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance3)
}
}
};
impl core::fmt::Debug for Instance3 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance3").finish()
}
}
impl Instance for Instance3 {
const PREFIX: &'static str = "Instance3Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance3Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance3Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance3Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance3Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance3Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance4;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance4 {
#[inline]
fn clone(&self) -> Instance4 {
match *self {
Instance4 => Instance4,
}
}
}
impl ::core::marker::StructuralEq for Instance4 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance4 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance4 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance4 {
#[inline]
fn eq(&self, other: &Instance4) -> bool {
match *other {
Instance4 => match *self {
Instance4 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance4 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance4 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance4 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance4)
}
}
};
impl core::fmt::Debug for Instance4 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance4").finish()
}
}
impl Instance for Instance4 {
const PREFIX: &'static str = "Instance4Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance4Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance4Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance4Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance4Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance4Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance5;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance5 {
#[inline]
fn clone(&self) -> Instance5 {
match *self {
Instance5 => Instance5,
}
}
}
impl ::core::marker::StructuralEq for Instance5 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance5 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance5 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance5 {
#[inline]
fn eq(&self, other: &Instance5) -> bool {
match *other {
Instance5 => match *self {
Instance5 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance5 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance5 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance5 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance5)
}
}
};
impl core::fmt::Debug for Instance5 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance5").finish()
}
}
impl Instance for Instance5 {
const PREFIX: &'static str = "Instance5Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance5Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance5Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance5Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance5Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance5Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance6;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance6 {
#[inline]
fn clone(&self) -> Instance6 {
match *self {
Instance6 => Instance6,
}
}
}
impl ::core::marker::StructuralEq for Instance6 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance6 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance6 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance6 {
#[inline]
fn eq(&self, other: &Instance6) -> bool {
match *other {
Instance6 => match *self {
Instance6 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance6 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance6 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance6 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance6)
}
}
};
impl core::fmt::Debug for Instance6 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance6").finish()
}
}
impl Instance for Instance6 {
const PREFIX: &'static str = "Instance6Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance6Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance6Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance6Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance6Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance6Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance7;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance7 {
#[inline]
fn clone(&self) -> Instance7 {
match *self {
Instance7 => Instance7,
}
}
}
impl ::core::marker::StructuralEq for Instance7 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance7 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance7 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance7 {
#[inline]
fn eq(&self, other: &Instance7) -> bool {
match *other {
Instance7 => match *self {
Instance7 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance7 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance7 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance7 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance7)
}
}
};
impl core::fmt::Debug for Instance7 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance7").finish()
}
}
impl Instance for Instance7 {
const PREFIX: &'static str = "Instance7Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance7Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance7Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance7Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance7Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance7Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance8;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance8 {
#[inline]
fn clone(&self) -> Instance8 {
match *self {
Instance8 => Instance8,
}
}
}
impl ::core::marker::StructuralEq for Instance8 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance8 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance8 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance8 {
#[inline]
fn eq(&self, other: &Instance8) -> bool {
match *other {
Instance8 => match *self {
Instance8 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance8 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance8 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance8 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance8)
}
}
};
impl core::fmt::Debug for Instance8 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance8").finish()
}
}
impl Instance for Instance8 {
const PREFIX: &'static str = "Instance8Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance8Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance8Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance8Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance8Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance8Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance9;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance9 {
#[inline]
fn clone(&self) -> Instance9 {
match *self {
Instance9 => Instance9,
}
}
}
impl ::core::marker::StructuralEq for Instance9 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance9 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance9 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance9 {
#[inline]
fn eq(&self, other: &Instance9) -> bool {
match *other {
Instance9 => match *self {
Instance9 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance9 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance9 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance9 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance9)
}
}
};
impl core::fmt::Debug for Instance9 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance9").finish()
}
}
impl Instance for Instance9 {
const PREFIX: &'static str = "Instance9Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance9Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance9Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance9Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance9Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance9Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance10;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance10 {
#[inline]
fn clone(&self) -> Instance10 {
match *self {
Instance10 => Instance10,
}
}
}
impl ::core::marker::StructuralEq for Instance10 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance10 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance10 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance10 {
#[inline]
fn eq(&self, other: &Instance10) -> bool {
match *other {
Instance10 => match *self {
Instance10 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance10 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance10 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance10 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance10)
}
}
};
impl core::fmt::Debug for Instance10 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance10").finish()
}
}
impl Instance for Instance10 {
const PREFIX: &'static str = "Instance10Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance10Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance10Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance10Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance10Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance10Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance11;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance11 {
#[inline]
fn clone(&self) -> Instance11 {
match *self {
Instance11 => Instance11,
}
}
}
impl ::core::marker::StructuralEq for Instance11 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance11 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance11 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance11 {
#[inline]
fn eq(&self, other: &Instance11) -> bool {
match *other {
Instance11 => match *self {
Instance11 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance11 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance11 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance11 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance11)
}
}
};
impl core::fmt::Debug for Instance11 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance11").finish()
}
}
impl Instance for Instance11 {
const PREFIX: &'static str = "Instance11Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance11Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance11Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance11Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance11Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance11Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance12;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance12 {
#[inline]
fn clone(&self) -> Instance12 {
match *self {
Instance12 => Instance12,
}
}
}
impl ::core::marker::StructuralEq for Instance12 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance12 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance12 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance12 {
#[inline]
fn eq(&self, other: &Instance12) -> bool {
match *other {
Instance12 => match *self {
Instance12 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance12 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance12 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance12 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance12)
}
}
};
impl core::fmt::Debug for Instance12 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance12").finish()
}
}
impl Instance for Instance12 {
const PREFIX: &'static str = "Instance12Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance12Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance12Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance12Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance12Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance12Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance13;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance13 {
#[inline]
fn clone(&self) -> Instance13 {
match *self {
Instance13 => Instance13,
}
}
}
impl ::core::marker::StructuralEq for Instance13 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance13 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance13 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance13 {
#[inline]
fn eq(&self, other: &Instance13) -> bool {
match *other {
Instance13 => match *self {
Instance13 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance13 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance13 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance13 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance13)
}
}
};
impl core::fmt::Debug for Instance13 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance13").finish()
}
}
impl Instance for Instance13 {
const PREFIX: &'static str = "Instance13Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance13Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance13Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance13Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance13Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance13Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance14;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance14 {
#[inline]
fn clone(&self) -> Instance14 {
match *self {
Instance14 => Instance14,
}
}
}
impl ::core::marker::StructuralEq for Instance14 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance14 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance14 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance14 {
#[inline]
fn eq(&self, other: &Instance14) -> bool {
match *other {
Instance14 => match *self {
Instance14 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance14 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance14 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance14 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance14)
}
}
};
impl core::fmt::Debug for Instance14 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance14").finish()
}
}
impl Instance for Instance14 {
const PREFIX: &'static str = "Instance14Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance14Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance14Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance14Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance14Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance14Balances Locks";
}
#[doc = r"Module instance"]
pub struct Instance15;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Instance15 {
#[inline]
fn clone(&self) -> Instance15 {
match *self {
Instance15 => Instance15,
}
}
}
impl ::core::marker::StructuralEq for Instance15 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Instance15 {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for Instance15 {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Instance15 {
#[inline]
fn eq(&self, other: &Instance15) -> bool {
match *other {
Instance15 => match *self {
Instance15 => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Instance15 {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for Instance15 {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for Instance15 {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(Instance15)
}
}
};
impl core::fmt::Debug for Instance15 {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Instance15").finish()
}
}
impl Instance for Instance15 {
const PREFIX: &'static str = "Instance15Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Instance15Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Instance15Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Instance15Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Instance15Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Instance15Balances Locks";
}
#[doc = r"Default module instance"]
pub struct DefaultInstance;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for DefaultInstance {
#[inline]
fn clone(&self) -> DefaultInstance {
match *self {
DefaultInstance => DefaultInstance,
}
}
}
impl ::core::marker::StructuralEq for DefaultInstance {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for DefaultInstance {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl ::core::marker::StructuralPartialEq for DefaultInstance {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for DefaultInstance {
#[inline]
fn eq(&self, other: &DefaultInstance) -> bool {
match *other {
DefaultInstance => match *self {
DefaultInstance => true,
},
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for DefaultInstance {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {}
}
impl _parity_scale_codec::EncodeLike for DefaultInstance {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for DefaultInstance {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(DefaultInstance)
}
}
};
impl core::fmt::Debug for DefaultInstance {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("DefaultInstance").finish()
}
}
impl Instance for DefaultInstance {
const PREFIX: &'static str = "Balances";
const PREFIX_FOR_TotalIssuance: &'static str = "Balances TotalIssuance";
const PREFIX_FOR_Vesting: &'static str = "Balances Vesting";
const PREFIX_FOR_FreeBalance: &'static str = "Balances FreeBalance";
const PREFIX_FOR_ReservedBalance: &'static str = "Balances ReservedBalance";
const PREFIX_FOR_Locks: &'static str = "Balances Locks";
}
#[doc(hidden)]
pub type __InherentHiddenInstance = DefaultInstance;
#[cfg(feature = "std")]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
#[serde(bound(
serialize = "Vec < (T :: AccountId, T :: Balance) > : self :: sr_api_hidden_includes_decl_storage :: hidden_include::serde::Serialize, Vec < (T :: AccountId, T :: BlockNumber, T :: BlockNumber, T :: Balance) > : self :: sr_api_hidden_includes_decl_storage :: hidden_include::serde::Serialize, "
))]
#[serde(bound(
deserialize = "Vec < (T :: AccountId, T :: Balance) > : self :: sr_api_hidden_includes_decl_storage :: hidden_include::serde::de::DeserializeOwned, Vec < (T :: AccountId, T :: BlockNumber, T :: BlockNumber, T :: Balance) > : self :: sr_api_hidden_includes_decl_storage :: hidden_include::serde::de::DeserializeOwned, "
))]
pub struct GenesisConfig<T: Trait<I>, I: Instance = DefaultInstance> {
pub balances: Vec<(T::AccountId, T::Balance)>,
pub vesting: Vec<(T::AccountId, T::BlockNumber, T::BlockNumber, T::Balance)>,
}
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _IMPL_SERIALIZE_FOR_GenesisConfig: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate serde as _serde;
#[automatically_derived]
impl<T: Trait<I>, I: Instance> _serde::Serialize for GenesisConfig<T, I>
where
Vec<(T::AccountId, T::Balance)>:
self::sr_api_hidden_includes_decl_storage::hidden_include::serde::Serialize,
Vec<(T::AccountId, T::BlockNumber, T::BlockNumber, T::Balance)>:
self::sr_api_hidden_includes_decl_storage::hidden_include::serde::Serialize,
{
fn serialize<__S>(&self, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error>
where
__S: _serde::Serializer,
{
let mut __serde_state = match _serde::Serializer::serialize_struct(
__serializer,
"GenesisConfig",
false as usize + 1 + 1,
) {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
};
match _serde::ser::SerializeStruct::serialize_field(
&mut __serde_state,
"balances",
&self.balances,
) {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
};
match _serde::ser::SerializeStruct::serialize_field(
&mut __serde_state,
"vesting",
&self.vesting,
) {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
};
_serde::ser::SerializeStruct::end(__serde_state)
}
}
};
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _IMPL_DESERIALIZE_FOR_GenesisConfig: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate serde as _serde;
#[automatically_derived]
impl<'de, T: Trait<I>, I: Instance> _serde::Deserialize<'de> for GenesisConfig<T, I>
where
Vec<(T::AccountId, T::Balance)>:
self::sr_api_hidden_includes_decl_storage::hidden_include::serde::de::DeserializeOwned,
Vec<(T::AccountId, T::BlockNumber, T::BlockNumber, T::Balance)>:
self::sr_api_hidden_includes_decl_storage::hidden_include::serde::de::DeserializeOwned,
{
fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<Self, __D::Error>
where
__D: _serde::Deserializer<'de>,
{
#[allow(non_camel_case_types)]
enum __Field {
__field0,
__field1,
}
struct __FieldVisitor;
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
type Value = __Field;
fn expecting(
&self,
__formatter: &mut _serde::export::Formatter,
) -> _serde::export::fmt::Result {
_serde::export::Formatter::write_str(__formatter, "field identifier")
}
fn visit_u64<__E>(self, __value: u64) -> _serde::export::Result<Self::Value, __E>
where
__E: _serde::de::Error,
{
match __value {
0u64 => _serde::export::Ok(__Field::__field0),
1u64 => _serde::export::Ok(__Field::__field1),
_ => _serde::export::Err(_serde::de::Error::invalid_value(
_serde::de::Unexpected::Unsigned(__value),
&"field index 0 <= i < 2",
)),
}
}
fn visit_str<__E>(self, __value: &str) -> _serde::export::Result<Self::Value, __E>
where
__E: _serde::de::Error,
{
match __value {
"balances" => _serde::export::Ok(__Field::__field0),
"vesting" => _serde::export::Ok(__Field::__field1),
_ => _serde::export::Err(_serde::de::Error::unknown_field(__value, FIELDS)),
}
}
fn visit_bytes<__E>(
self,
__value: &[u8],
) -> _serde::export::Result<Self::Value, __E>
where
__E: _serde::de::Error,
{
match __value {
b"balances" => _serde::export::Ok(__Field::__field0),
b"vesting" => _serde::export::Ok(__Field::__field1),
_ => {
let __value = &_serde::export::from_utf8_lossy(__value);
_serde::export::Err(_serde::de::Error::unknown_field(__value, FIELDS))
}
}
}
}
impl<'de> _serde::Deserialize<'de> for __Field {
#[inline]
fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<Self, __D::Error>
where
__D: _serde::Deserializer<'de>,
{
_serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor)
}
}
struct __Visitor < 'de , T : Trait < I > , I : Instance > where Vec < ( T :: AccountId , T :: Balance ) > : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: serde :: de :: DeserializeOwned , Vec < ( T :: AccountId , T :: BlockNumber , T :: BlockNumber , T :: Balance ) > : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: serde :: de :: DeserializeOwned { marker : _serde :: export :: PhantomData < GenesisConfig < T , I > > , lifetime : _serde :: export :: PhantomData < & 'de ( ) > , }
impl < 'de , T : Trait < I > , I : Instance > _serde :: de :: Visitor < 'de > for __Visitor < 'de , T , I > where Vec < ( T :: AccountId , T :: Balance ) > : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: serde :: de :: DeserializeOwned , Vec < ( T :: AccountId , T :: BlockNumber , T :: BlockNumber , T :: Balance ) > : self :: sr_api_hidden_includes_decl_storage :: hidden_include :: serde :: de :: DeserializeOwned { type Value = GenesisConfig < T , I > ; fn expecting ( & self , __formatter : & mut _serde :: export :: Formatter ) -> _serde :: export :: fmt :: Result { _serde :: export :: Formatter :: write_str ( __formatter , "struct GenesisConfig" ) } # [ inline ] fn visit_seq < __A > ( self , mut __seq : __A ) -> _serde :: export :: Result < Self :: Value , __A :: Error > where __A : _serde :: de :: SeqAccess < 'de > { let __field0 = match match _serde :: de :: SeqAccess :: next_element :: < Vec < ( T :: AccountId , T :: Balance ) > > ( & mut __seq ) { _serde :: export :: Ok ( __val ) => __val , _serde :: export :: Err ( __err ) => { return _serde :: export :: Err ( __err ) ; } } { _serde :: export :: Some ( __value ) => __value , _serde :: export :: None => { return _serde :: export :: Err ( _serde :: de :: Error :: invalid_length ( 0usize , & "struct GenesisConfig with 2 elements" ) ) ; } } ; let __field1 = match match _serde :: de :: SeqAccess :: next_element :: < Vec < ( T :: AccountId , T :: BlockNumber , T :: BlockNumber , T :: Balance ) > > ( & mut __seq ) { _serde :: export :: Ok ( __val ) => __val , _serde :: export :: Err ( __err ) => { return _serde :: export :: Err ( __err ) ; } } { _serde :: export :: Some ( __value ) => __value , _serde :: export :: None => { return _serde :: export :: Err ( _serde :: de :: Error :: invalid_length ( 1usize , & "struct GenesisConfig with 2 elements" ) ) ; } } ; _serde :: export :: Ok ( GenesisConfig { balances : __field0 , vesting : __field1 , } ) } # [ inline ] fn visit_map < __A > ( self , mut __map : __A ) -> _serde :: export :: Result < Self :: Value , __A :: Error > where __A : _serde :: de :: MapAccess < 'de > { let mut __field0 : _serde :: export :: Option < Vec < ( T :: AccountId , T :: Balance ) > > = _serde :: export :: None ; let mut __field1 : _serde :: export :: Option < Vec < ( T :: AccountId , T :: BlockNumber , T :: BlockNumber , T :: Balance ) > > = _serde :: export :: None ; while let _serde :: export :: Some ( __key ) = match _serde :: de :: MapAccess :: next_key :: < __Field > ( & mut __map ) { _serde :: export :: Ok ( __val ) => __val , _serde :: export :: Err ( __err ) => { return _serde :: export :: Err ( __err ) ; } } { match __key { __Field :: __field0 => { if _serde :: export :: Option :: is_some ( & __field0 ) { return _serde :: export :: Err ( < __A :: Error as _serde :: de :: Error > :: duplicate_field ( "balances" ) ) ; } __field0 = _serde :: export :: Some ( match _serde :: de :: MapAccess :: next_value :: < Vec < ( T :: AccountId , T :: Balance ) > > ( & mut __map ) { _serde :: export :: Ok ( __val ) => __val , _serde :: export :: Err ( __err ) => { return _serde :: export :: Err ( __err ) ; } } ) ; } __Field :: __field1 => { if _serde :: export :: Option :: is_some ( & __field1 ) { return _serde :: export :: Err ( < __A :: Error as _serde :: de :: Error > :: duplicate_field ( "vesting" ) ) ; } __field1 = _serde :: export :: Some ( match _serde :: de :: MapAccess :: next_value :: < Vec < ( T :: AccountId , T :: BlockNumber , T :: BlockNumber , T :: Balance ) > > ( & mut __map ) { _serde :: export :: Ok ( __val ) => __val , _serde :: export :: Err ( __err ) => { return _serde :: export :: Err ( __err ) ; } } ) ; } } } let __field0 = match __field0 { _serde :: export :: Some ( __field0 ) => __field0 , _serde :: export :: None => match _serde :: private :: de :: missing_field ( "balances" ) { _serde :: export :: Ok ( __val ) => __val , _serde :: export :: Err ( __err ) => { return _serde :: export :: Err ( __err ) ; } } , } ; let __field1 = match __field1 { _serde :: export :: Some ( __field1 ) => __field1 , _serde :: export :: None => match _serde :: private :: de :: missing_field ( "vesting" ) { _serde :: export :: Ok ( __val ) => __val , _serde :: export :: Err ( __err ) => { return _serde :: export :: Err ( __err ) ; } } , } ; _serde :: export :: Ok ( GenesisConfig { balances : __field0 , vesting : __field1 , } ) } }
const FIELDS: &'static [&'static str] = &["balances", "vesting"];
_serde::Deserializer::deserialize_struct(
__deserializer,
"GenesisConfig",
FIELDS,
__Visitor {
marker: _serde::export::PhantomData::<GenesisConfig<T, I>>,
lifetime: _serde::export::PhantomData,
},
)
}
}
};
#[cfg(feature = "std")]
impl<T: Trait<I>, I: Instance> Default for GenesisConfig<T, I> {
fn default() -> Self {
GenesisConfig {
balances: Default::default(),
vesting: Default::default(),
}
}
}
#[cfg(feature = "std")]
impl<T: Trait<I>, I: Instance> GenesisConfig<T, I> {
pub fn build_storage ( & self ) -> std :: result :: Result < ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: sr_primitives :: StorageOverlay , self :: sr_api_hidden_includes_decl_storage :: hidden_include :: sr_primitives :: ChildrenStorageOverlay ) , String >{
let mut storage = (Default::default(), Default::default());
self.assimilate_storage(&mut storage)?;
Ok(storage)
}
#[doc = r" Assimilate the storage for this module into pre-existing overlays."]
pub fn assimilate_storage(
&self,
tuple_storage : & mut ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: sr_primitives :: StorageOverlay , self :: sr_api_hidden_includes_decl_storage :: hidden_include :: sr_primitives :: ChildrenStorageOverlay ),
) -> std::result::Result<(), String> {
self :: sr_api_hidden_includes_decl_storage :: hidden_include :: BasicExternalities :: execute_with_storage ( tuple_storage , | | { { let v : & T :: Balance = & ( | config : & GenesisConfig < T , I > | { config . balances . iter ( ) . fold ( Zero :: zero ( ) , | acc : T :: Balance , & ( _ , n ) | acc + n ) } ) ( self ) ; < TotalIssuance < T , I > as self :: sr_api_hidden_includes_decl_storage :: hidden_include :: storage :: StorageValue < T :: Balance > > :: put :: < & T :: Balance > ( v ) ; } { let data : & self :: sr_api_hidden_includes_decl_storage :: hidden_include :: rstd :: vec :: Vec < ( T :: AccountId , VestingSchedule < T :: Balance , T :: BlockNumber > ) > = & ( | config : & GenesisConfig < T , I > | { config . vesting . iter ( ) . filter_map ( | & ( ref who , begin , length , liquid ) | { let length = < T :: Balance as From < T :: BlockNumber > > :: from ( length ) ; config . balances . iter ( ) . find ( | & & ( ref w , _ ) | w == who ) . map ( | & ( _ , balance ) | { let locked = balance . saturating_sub ( liquid ) ; let per_block = locked / length . max ( sr_primitives :: traits :: One :: one ( ) ) ; ( who . clone ( ) , VestingSchedule { locked : locked , per_block : per_block , starting_block : begin , } ) } ) } ) . collect :: < Vec < _ > > ( ) } ) ( self ) ; data . iter ( ) . for_each ( | ( k , v ) | { < Vesting < T , I > as self :: sr_api_hidden_includes_decl_storage :: hidden_include :: storage :: StorageMap < T :: AccountId , VestingSchedule < T :: Balance , T :: BlockNumber > > > :: insert :: < & T :: AccountId , & VestingSchedule < T :: Balance , T :: BlockNumber > > ( k , v ) ; } ) ; } { let data : & self :: sr_api_hidden_includes_decl_storage :: hidden_include :: rstd :: vec :: Vec < ( T :: AccountId , T :: Balance ) > = & ( | config : & GenesisConfig < T , I > | config . balances . clone ( ) ) ( self ) ; data . iter ( ) . for_each ( | ( k , v ) | { < FreeBalance < T , I > as self :: sr_api_hidden_includes_decl_storage :: hidden_include :: storage :: StorageMap < T :: AccountId , T :: Balance > > :: insert :: < & T :: AccountId , & T :: Balance > ( k , v ) ; } ) ; } let extra_genesis_builder : fn ( & Self ) = | config : & GenesisConfig < T , I > | { for ( _ , balance ) in & config . balances { if ! ( * balance >= < T as Trait < I > > :: get ( ) ) { { { :: std :: rt :: begin_panic ( "the balance of any account should always be more than existential deposit." , & ( "palette/balances/src/lib.rs" , 377u32 , 5u32 ) ) } } } } } ; extra_genesis_builder ( self ) ; Ok ( ( ) ) } )
}
}
#[cfg(feature = "std")]
impl < T : Trait < I > , I : Instance > self :: sr_api_hidden_includes_decl_storage :: hidden_include :: sr_primitives :: BuildModuleGenesisStorage < T , I > for GenesisConfig < T , I > { fn build_module_genesis_storage ( & self , storage : & mut ( self :: sr_api_hidden_includes_decl_storage :: hidden_include :: sr_primitives :: StorageOverlay , self :: sr_api_hidden_includes_decl_storage :: hidden_include :: sr_primitives :: ChildrenStorageOverlay ) ) -> std :: result :: Result < ( ) , String > { self . assimilate_storage :: < > ( storage ) } }
#[doc = " The total units issued in the system."]
pub struct TotalIssuance<T: Trait<I>, I: Instance = DefaultInstance>(
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(T, I)>,
);
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::storage::generator::StorageValue<
T::Balance,
> for TotalIssuance<T, I>
{
type Query = T::Balance;
fn unhashed_key() -> &'static [u8] {
I::PREFIX_FOR_TotalIssuance.as_bytes()
}
fn from_optional_value_to_query(v: Option<T::Balance>) -> Self::Query {
v.unwrap_or_else(|| Default::default())
}
fn from_query_to_optional_value(v: Self::Query) -> Option<T::Balance> {
Some(v)
}
}
#[doc = " Information regarding the vesting of a given account."]
pub struct Vesting<T: Trait<I>, I: Instance = DefaultInstance>(
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(T, I)>,
);
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::storage::generator::StorageMap<
T::AccountId,
VestingSchedule<T::Balance, T::BlockNumber>,
> for Vesting<T, I>
{
type Query = Option<VestingSchedule<T::Balance, T::BlockNumber>>;
type Hasher = self::sr_api_hidden_includes_decl_storage::hidden_include::Blake2_256;
fn prefix() -> &'static [u8] {
I::PREFIX_FOR_Vesting.as_bytes()
}
fn from_optional_value_to_query(
v: Option<VestingSchedule<T::Balance, T::BlockNumber>>,
) -> Self::Query {
v.or_else(|| Default::default())
}
fn from_query_to_optional_value(
v: Self::Query,
) -> Option<VestingSchedule<T::Balance, T::BlockNumber>> {
v
}
}
#[doc = " The \'free\' balance of a given account."]
#[doc = ""]
#[doc = " This is the only balance that matters in terms of most operations on tokens. It"]
#[doc = " alone is used to determine the balance when in the contract execution environment. When this"]
#[doc = " balance falls below the value of `ExistentialDeposit`, then the \'current account\' is"]
#[doc = " deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback"]
#[doc = " is invoked, giving a chance to external modules to clean up data associated with"]
#[doc = " the deleted account."]
#[doc = ""]
#[doc = " `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets"]
#[doc = " collapsed to zero if it ever becomes less than `ExistentialDeposit`."]
pub struct FreeBalance<T: Trait<I>, I: Instance = DefaultInstance>(
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(T, I)>,
);
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::storage::generator::StorageMap<
T::AccountId,
T::Balance,
> for FreeBalance<T, I>
{
type Query = T::Balance;
type Hasher = self::sr_api_hidden_includes_decl_storage::hidden_include::Blake2_256;
fn prefix() -> &'static [u8] {
I::PREFIX_FOR_FreeBalance.as_bytes()
}
fn from_optional_value_to_query(v: Option<T::Balance>) -> Self::Query {
v.unwrap_or_else(|| Default::default())
}
fn from_query_to_optional_value(v: Self::Query) -> Option<T::Balance> {
Some(v)
}
}
#[doc = " The amount of the balance of a given account that is externally reserved; this can still get"]
#[doc = " slashed, but gets slashed last of all."]
#[doc = ""]
#[doc = " This balance is a \'reserve\' balance that other subsystems use in order to set aside tokens"]
#[doc = " that are still \'owned\' by the account holder, but which are suspendable."]
#[doc = ""]
#[doc = " When this balance falls below the value of `ExistentialDeposit`, then this \'reserve account\'"]
#[doc = " is deleted: specifically, `ReservedBalance`."]
#[doc = ""]
#[doc = " `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets"]
#[doc = " collapsed to zero if it ever becomes less than `ExistentialDeposit`.)"]
pub struct ReservedBalance<T: Trait<I>, I: Instance = DefaultInstance>(
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(T, I)>,
);
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::storage::generator::StorageMap<
T::AccountId,
T::Balance,
> for ReservedBalance<T, I>
{
type Query = T::Balance;
type Hasher = self::sr_api_hidden_includes_decl_storage::hidden_include::Blake2_256;
fn prefix() -> &'static [u8] {
I::PREFIX_FOR_ReservedBalance.as_bytes()
}
fn from_optional_value_to_query(v: Option<T::Balance>) -> Self::Query {
v.unwrap_or_else(|| Default::default())
}
fn from_query_to_optional_value(v: Self::Query) -> Option<T::Balance> {
Some(v)
}
}
#[doc = " Any liquidity locks on some account balances."]
pub struct Locks<T: Trait<I>, I: Instance = DefaultInstance>(
self::sr_api_hidden_includes_decl_storage::hidden_include::rstd::marker::PhantomData<(T, I)>,
);
impl<T: Trait<I>, I: Instance>
self::sr_api_hidden_includes_decl_storage::hidden_include::storage::generator::StorageMap<
T::AccountId,
Vec<BalanceLock<T::Balance, T::BlockNumber>>,
> for Locks<T, I>
{
type Query = Vec<BalanceLock<T::Balance, T::BlockNumber>>;
type Hasher = self::sr_api_hidden_includes_decl_storage::hidden_include::Blake2_256;
fn prefix() -> &'static [u8] {
I::PREFIX_FOR_Locks.as_bytes()
}
fn from_optional_value_to_query(
v: Option<Vec<BalanceLock<T::Balance, T::BlockNumber>>>,
) -> Self::Query {
v.unwrap_or_else(|| Default::default())
}
fn from_query_to_optional_value(
v: Self::Query,
) -> Option<Vec<BalanceLock<T::Balance, T::BlockNumber>>> {
Some(v)
}
}
pub struct Module<T: Trait<I>, I: Instance = DefaultInstance>(
::palette_support::rstd::marker::PhantomData<(T, I)>,
);
#[automatically_derived]
#[allow(unused_qualifications)]
impl<T: ::core::clone::Clone + Trait<I>, I: ::core::clone::Clone + Instance> ::core::clone::Clone
for Module<T, I>
{
#[inline]
fn clone(&self) -> Module<T, I> {
match *self {
Module(ref __self_0_0) => Module(::core::clone::Clone::clone(&(*__self_0_0))),
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<T: ::core::marker::Copy + Trait<I>, I: ::core::marker::Copy + Instance> ::core::marker::Copy
for Module<T, I>
{
}
impl<T: Trait<I>, I: Instance> ::core::marker::StructuralPartialEq for Module<T, I> {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<T: ::core::cmp::PartialEq + Trait<I>, I: ::core::cmp::PartialEq + Instance>
::core::cmp::PartialEq for Module<T, I>
{
#[inline]
fn eq(&self, other: &Module<T, I>) -> bool {
match *other {
Module(ref __self_1_0) => match *self {
Module(ref __self_0_0) => (*__self_0_0) == (*__self_1_0),
},
}
}
#[inline]
fn ne(&self, other: &Module<T, I>) -> bool {
match *other {
Module(ref __self_1_0) => match *self {
Module(ref __self_0_0) => (*__self_0_0) != (*__self_1_0),
},
}
}
}
impl<T: Trait<I>, I: Instance> ::core::marker::StructuralEq for Module<T, I> {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl<T: ::core::cmp::Eq + Trait<I>, I: ::core::cmp::Eq + Instance> ::core::cmp::Eq
for Module<T, I>
{
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{
let _: ::core::cmp::AssertParamIsEq<
::palette_support::rstd::marker::PhantomData<(T, I)>,
>;
}
}
}
impl<T: Trait<I>, I: Instance> core::fmt::Debug for Module<T, I>
where
T: core::fmt::Debug,
I: core::fmt::Debug,
{
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Module").field(&self.0).finish()
}
}
impl<T: Trait<I>, I: Instance>
::palette_support::sr_primitives::traits::OnInitialize<T::BlockNumber> for Module<T, I>
{
}
impl<T: Trait<I>, I: Instance> ::palette_support::sr_primitives::traits::OnFinalize<T::BlockNumber>
for Module<T, I>
{
}
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::WeighBlock<T::BlockNumber>
for Module<T, I>
{
}
impl<T: Trait<I>, I: Instance>
::palette_support::sr_primitives::traits::OffchainWorker<T::BlockNumber> for Module<T, I>
{
}
impl<T: Trait<I>, I: Instance> Module<T, I> {
fn deposit_event(event: impl Into<<T as Trait<I>>::Event>) {
<system::Module<T>>::deposit_event(event.into())
}
}
#[doc = " Can also be called using [`Call`]."]
#[doc = ""]
#[doc = " [`Call`]: enum.Call.html"]
impl<T: Trait<I>, I: Instance> Module<T, I> {
#[doc = r" Transfer some liquid free balance to another account."]
#[doc = r""]
#[doc = r" `transfer` will set the `FreeBalance` of the sender and receiver."]
#[doc = r" It will decrease the total issuance of the system by the `TransferFee`."]
#[doc = r" If the sender's account is below the existential deposit as a result"]
#[doc = r" of the transfer, the account will be reaped."]
#[doc = r""]
#[doc = r" The dispatch origin for this call must be `Signed` by the transactor."]
#[doc = r""]
#[doc = r" # <weight>"]
#[doc = r" - Dependent on arguments but not critical, given proper implementations for"]
#[doc = r" input config types. See related functions below."]
#[doc = r" - It contains a limited number of reads and writes internally and no complex computation."]
#[doc = r""]
#[doc = r" Related functions:"]
#[doc = r""]
#[doc = r" - `ensure_can_withdraw` is always called internally but has a bounded complexity."]
#[doc = r" - Transferring balances to accounts that did not exist before will cause"]
#[doc = r" `T::OnNewAccount::on_new_account` to be called."]
#[doc = r" - Removing enough funds from an account will trigger"]
#[doc = r" `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`."]
#[doc = r" - `transfer_keep_alive` works the same way as `transfer`, but has an additional"]
#[doc = r" check that the transfer will not kill the origin account."]
#[doc = r""]
#[doc = r" # </weight>"]
#[allow(unreachable_code)]
pub fn transfer(
origin: T::Origin,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance,
) -> ::palette_support::dispatch::DispatchResult<&'static str> {
use palette_support::rstd::if_std;
use palette_support::tracing;
let span = {
if ::tracing::dispatcher::has_been_set()
&& tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL
{
use tracing::callsite;
use tracing::callsite::Callsite;
let callsite = {
use tracing::{callsite, subscriber::Interest, Metadata, __macro_support::*};
struct MyCallsite;
static META: Metadata<'static> = {
::tracing_core::metadata::Metadata::new(
"transfer",
"pallet_balances",
tracing::Level::INFO,
Some("palette/balances/src/lib.rs"),
Some(386u32),
Some("pallet_balances"),
::tracing_core::field::FieldSet::new(
&[],
::tracing_core::callsite::Identifier(&MyCallsite),
),
::tracing::metadata::Kind::SPAN,
)
};
static INTEREST: AtomicUsize = AtomicUsize::new(0);
static REGISTRATION: Once = Once::new();
impl MyCallsite {
#[inline]
fn interest(&self) -> Interest {
match INTEREST.load(Ordering::Relaxed) {
0 => Interest::never(),
2 => Interest::always(),
_ => Interest::sometimes(),
}
}
}
impl callsite::Callsite for MyCallsite {
fn set_interest(&self, interest: Interest) {
let interest = match () {
_ if interest.is_never() => 0,
_ if interest.is_always() => 2,
_ => 1,
};
INTEREST.store(interest, Ordering::SeqCst);
}
fn metadata(&self) -> &Metadata {
&META
}
}
REGISTRATION.call_once(|| {
callsite::register(&MyCallsite);
});
&MyCallsite
};
let meta = callsite.metadata();
if {
let interest = callsite.interest();
if interest.is_never() {
false
} else if interest.is_always() {
true
} else {
let meta = callsite.metadata();
::tracing::dispatcher::get_default(|current| current.enabled(meta))
}
} {
::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) })
} else {
::tracing::Span::none()
}
} else {
::tracing::Span::none()
}
};
let _enter = span.enter();
{
{
let transactor = ensure_signed(origin)?;
let dest = T::Lookup::lookup(dest)?;
<Self as Currency<_>>::transfer(
&transactor,
&dest,
value,
ExistenceRequirement::AllowDeath,
)?;
}
Ok(())
}
}
#[doc = r" Set the balances of a given account."]
#[doc = r""]
#[doc = r" This will alter `FreeBalance` and `ReservedBalance` in storage. it will"]
#[doc = r" also decrease the total issuance of the system (`TotalIssuance`)."]
#[doc = r" If the new free or reserved balance is below the existential deposit,"]
#[doc = r" it will reset the account nonce (`system::AccountNonce`)."]
#[doc = r""]
#[doc = r" The dispatch origin for this call is `root`."]
#[doc = r""]
#[doc = r" # <weight>"]
#[doc = r" - Independent of the arguments."]
#[doc = r" - Contains a limited number of reads and writes."]
#[doc = r" # </weight>"]
#[allow(unreachable_code)]
fn set_balance(
origin: T::Origin,
who: <T::Lookup as StaticLookup>::Source,
new_free: T::Balance,
new_reserved: T::Balance,
) -> ::palette_support::dispatch::DispatchResult<&'static str> {
use palette_support::rstd::if_std;
use palette_support::tracing;
let span = {
if ::tracing::dispatcher::has_been_set()
&& tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL
{
use tracing::callsite;
use tracing::callsite::Callsite;
let callsite = {
use tracing::{callsite, subscriber::Interest, Metadata, __macro_support::*};
struct MyCallsite;
static META: Metadata<'static> = {
::tracing_core::metadata::Metadata::new(
"set_balance",
"pallet_balances",
tracing::Level::INFO,
Some("palette/balances/src/lib.rs"),
Some(386u32),
Some("pallet_balances"),
::tracing_core::field::FieldSet::new(
&[],
::tracing_core::callsite::Identifier(&MyCallsite),
),
::tracing::metadata::Kind::SPAN,
)
};
static INTEREST: AtomicUsize = AtomicUsize::new(0);
static REGISTRATION: Once = Once::new();
impl MyCallsite {
#[inline]
fn interest(&self) -> Interest {
match INTEREST.load(Ordering::Relaxed) {
0 => Interest::never(),
2 => Interest::always(),
_ => Interest::sometimes(),
}
}
}
impl callsite::Callsite for MyCallsite {
fn set_interest(&self, interest: Interest) {
let interest = match () {
_ if interest.is_never() => 0,
_ if interest.is_always() => 2,
_ => 1,
};
INTEREST.store(interest, Ordering::SeqCst);
}
fn metadata(&self) -> &Metadata {
&META
}
}
REGISTRATION.call_once(|| {
callsite::register(&MyCallsite);
});
&MyCallsite
};
let meta = callsite.metadata();
if {
let interest = callsite.interest();
if interest.is_never() {
false
} else if interest.is_always() {
true
} else {
let meta = callsite.metadata();
::tracing::dispatcher::get_default(|current| current.enabled(meta))
}
} {
::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) })
} else {
::tracing::Span::none()
}
} else {
::tracing::Span::none()
}
};
let _enter = span.enter();
{
{
ensure_root(origin)?;
let who = T::Lookup::lookup(who)?;
let current_free = <FreeBalance<T, I>>::get(&who);
if new_free > current_free {
mem::drop(PositiveImbalance::<T, I>::new(new_free - current_free));
} else if new_free < current_free {
mem::drop(NegativeImbalance::<T, I>::new(current_free - new_free));
}
Self::set_free_balance(&who, new_free);
let current_reserved = <ReservedBalance<T, I>>::get(&who);
if new_reserved > current_reserved {
mem::drop(PositiveImbalance::<T, I>::new(
new_reserved - current_reserved,
));
} else if new_reserved < current_reserved {
mem::drop(NegativeImbalance::<T, I>::new(
current_reserved - new_reserved,
));
}
Self::set_reserved_balance(&who, new_reserved);
}
Ok(())
}
}
#[doc = r" Exactly as `transfer`, except the origin must be root and the source account may be"]
#[doc = r" specified."]
#[allow(unreachable_code)]
pub fn force_transfer(
origin: T::Origin,
source: <T::Lookup as StaticLookup>::Source,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance,
) -> ::palette_support::dispatch::DispatchResult<&'static str> {
use palette_support::rstd::if_std;
use palette_support::tracing;
let span = {
if ::tracing::dispatcher::has_been_set()
&& tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL
{
use tracing::callsite;
use tracing::callsite::Callsite;
let callsite = {
use tracing::{callsite, subscriber::Interest, Metadata, __macro_support::*};
struct MyCallsite;
static META: Metadata<'static> = {
::tracing_core::metadata::Metadata::new(
"force_transfer",
"pallet_balances",
tracing::Level::INFO,
Some("palette/balances/src/lib.rs"),
Some(386u32),
Some("pallet_balances"),
::tracing_core::field::FieldSet::new(
&[],
::tracing_core::callsite::Identifier(&MyCallsite),
),
::tracing::metadata::Kind::SPAN,
)
};
static INTEREST: AtomicUsize = AtomicUsize::new(0);
static REGISTRATION: Once = Once::new();
impl MyCallsite {
#[inline]
fn interest(&self) -> Interest {
match INTEREST.load(Ordering::Relaxed) {
0 => Interest::never(),
2 => Interest::always(),
_ => Interest::sometimes(),
}
}
}
impl callsite::Callsite for MyCallsite {
fn set_interest(&self, interest: Interest) {
let interest = match () {
_ if interest.is_never() => 0,
_ if interest.is_always() => 2,
_ => 1,
};
INTEREST.store(interest, Ordering::SeqCst);
}
fn metadata(&self) -> &Metadata {
&META
}
}
REGISTRATION.call_once(|| {
callsite::register(&MyCallsite);
});
&MyCallsite
};
let meta = callsite.metadata();
if {
let interest = callsite.interest();
if interest.is_never() {
false
} else if interest.is_always() {
true
} else {
let meta = callsite.metadata();
::tracing::dispatcher::get_default(|current| current.enabled(meta))
}
} {
::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) })
} else {
::tracing::Span::none()
}
} else {
::tracing::Span::none()
}
};
let _enter = span.enter();
{
{
ensure_root(origin)?;
let source = T::Lookup::lookup(source)?;
let dest = T::Lookup::lookup(dest)?;
<Self as Currency<_>>::transfer(
&source,
&dest,
value,
ExistenceRequirement::AllowDeath,
)?;
}
Ok(())
}
}
#[doc = r" Same as the [`transfer`] call, but with a check that the transfer will not kill the"]
#[doc = r" origin account."]
#[doc = r""]
#[doc = r" 99% of the time you want [`transfer`] instead."]
#[doc = r""]
#[doc = r" [`transfer`]: struct.Module.html#method.transfer"]
#[allow(unreachable_code)]
pub fn transfer_keep_alive(
origin: T::Origin,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance,
) -> ::palette_support::dispatch::DispatchResult<&'static str> {
use palette_support::rstd::if_std;
use palette_support::tracing;
let span = {
if ::tracing::dispatcher::has_been_set()
&& tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL
{
use tracing::callsite;
use tracing::callsite::Callsite;
let callsite = {
use tracing::{callsite, subscriber::Interest, Metadata, __macro_support::*};
struct MyCallsite;
static META: Metadata<'static> = {
::tracing_core::metadata::Metadata::new(
"transfer_keep_alive",
"pallet_balances",
tracing::Level::INFO,
Some("palette/balances/src/lib.rs"),
Some(386u32),
Some("pallet_balances"),
::tracing_core::field::FieldSet::new(
&[],
::tracing_core::callsite::Identifier(&MyCallsite),
),
::tracing::metadata::Kind::SPAN,
)
};
static INTEREST: AtomicUsize = AtomicUsize::new(0);
static REGISTRATION: Once = Once::new();
impl MyCallsite {
#[inline]
fn interest(&self) -> Interest {
match INTEREST.load(Ordering::Relaxed) {
0 => Interest::never(),
2 => Interest::always(),
_ => Interest::sometimes(),
}
}
}
impl callsite::Callsite for MyCallsite {
fn set_interest(&self, interest: Interest) {
let interest = match () {
_ if interest.is_never() => 0,
_ if interest.is_always() => 2,
_ => 1,
};
INTEREST.store(interest, Ordering::SeqCst);
}
fn metadata(&self) -> &Metadata {
&META
}
}
REGISTRATION.call_once(|| {
callsite::register(&MyCallsite);
});
&MyCallsite
};
let meta = callsite.metadata();
if {
let interest = callsite.interest();
if interest.is_never() {
false
} else if interest.is_always() {
true
} else {
let meta = callsite.metadata();
::tracing::dispatcher::get_default(|current| current.enabled(meta))
}
} {
::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) })
} else {
::tracing::Span::none()
}
} else {
::tracing::Span::none()
}
};
let _enter = span.enter();
{
{
let transactor = ensure_signed(origin)?;
let dest = T::Lookup::lookup(dest)?;
<Self as Currency<_>>::transfer(
&transactor,
&dest,
value,
ExistenceRequirement::KeepAlive,
)?;
}
Ok(())
}
}
}
pub enum Call<T: Trait<I>, I: Instance = DefaultInstance> {
#[doc(hidden)]
#[codec(skip)]
__PhantomItem(
::palette_support::rstd::marker::PhantomData<(T, I)>,
::palette_support::dispatch::Never,
),
#[allow(non_camel_case_types)]
#[doc = r" Transfer some liquid free balance to another account."]
#[doc = r""]
#[doc = r" `transfer` will set the `FreeBalance` of the sender and receiver."]
#[doc = r" It will decrease the total issuance of the system by the `TransferFee`."]
#[doc = r" If the sender's account is below the existential deposit as a result"]
#[doc = r" of the transfer, the account will be reaped."]
#[doc = r""]
#[doc = r" The dispatch origin for this call must be `Signed` by the transactor."]
#[doc = r""]
#[doc = r" # <weight>"]
#[doc = r" - Dependent on arguments but not critical, given proper implementations for"]
#[doc = r" input config types. See related functions below."]
#[doc = r" - It contains a limited number of reads and writes internally and no complex computation."]
#[doc = r""]
#[doc = r" Related functions:"]
#[doc = r""]
#[doc = r" - `ensure_can_withdraw` is always called internally but has a bounded complexity."]
#[doc = r" - Transferring balances to accounts that did not exist before will cause"]
#[doc = r" `T::OnNewAccount::on_new_account` to be called."]
#[doc = r" - Removing enough funds from an account will trigger"]
#[doc = r" `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`."]
#[doc = r" - `transfer_keep_alive` works the same way as `transfer`, but has an additional"]
#[doc = r" check that the transfer will not kill the origin account."]
#[doc = r""]
#[doc = r" # </weight>"]
transfer(
<T::Lookup as StaticLookup>::Source,
#[codec(compact)] T::Balance,
),
#[allow(non_camel_case_types)]
#[doc = r" Set the balances of a given account."]
#[doc = r""]
#[doc = r" This will alter `FreeBalance` and `ReservedBalance` in storage. it will"]
#[doc = r" also decrease the total issuance of the system (`TotalIssuance`)."]
#[doc = r" If the new free or reserved balance is below the existential deposit,"]
#[doc = r" it will reset the account nonce (`system::AccountNonce`)."]
#[doc = r""]
#[doc = r" The dispatch origin for this call is `root`."]
#[doc = r""]
#[doc = r" # <weight>"]
#[doc = r" - Independent of the arguments."]
#[doc = r" - Contains a limited number of reads and writes."]
#[doc = r" # </weight>"]
set_balance(
<T::Lookup as StaticLookup>::Source,
#[codec(compact)] T::Balance,
#[codec(compact)] T::Balance,
),
#[allow(non_camel_case_types)]
#[doc = r" Exactly as `transfer`, except the origin must be root and the source account may be"]
#[doc = r" specified."]
force_transfer(
<T::Lookup as StaticLookup>::Source,
<T::Lookup as StaticLookup>::Source,
#[codec(compact)] T::Balance,
),
#[allow(non_camel_case_types)]
#[doc = r" Same as the [`transfer`] call, but with a check that the transfer will not kill the"]
#[doc = r" origin account."]
#[doc = r""]
#[doc = r" 99% of the time you want [`transfer`] instead."]
#[doc = r""]
#[doc = r" [`transfer`]: struct.Module.html#method.transfer"]
transfer_keep_alive(
<T::Lookup as StaticLookup>::Source,
#[codec(compact)] T::Balance,
),
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl<T: Trait<I>, I: Instance> _parity_scale_codec::Encode for Call<T, I>
where
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
{
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {
match *self {
Call::transfer(ref aa, ref ba) => {
dest.push_byte(0usize as u8);
dest.push(aa);
{
dest . push ( & < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: EncodeAsRef < '_ , T :: Balance > > :: from ( ba ) ) ;
}
}
Call::set_balance(ref aa, ref ba, ref ca) => {
dest.push_byte(1usize as u8);
dest.push(aa);
{
dest . push ( & < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: EncodeAsRef < '_ , T :: Balance > > :: from ( ba ) ) ;
}
{
dest . push ( & < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: EncodeAsRef < '_ , T :: Balance > > :: from ( ca ) ) ;
}
}
Call::force_transfer(ref aa, ref ba, ref ca) => {
dest.push_byte(2usize as u8);
dest.push(aa);
dest.push(ba);
{
dest . push ( & < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: EncodeAsRef < '_ , T :: Balance > > :: from ( ca ) ) ;
}
}
Call::transfer_keep_alive(ref aa, ref ba) => {
dest.push_byte(3usize as u8);
dest.push(aa);
{
dest . push ( & < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: EncodeAsRef < '_ , T :: Balance > > :: from ( ba ) ) ;
}
}
_ => (),
}
}
}
impl<T: Trait<I>, I: Instance> _parity_scale_codec::EncodeLike for Call<T, I>
where
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Encode,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
{
}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl<T: Trait<I>, I: Instance> _parity_scale_codec::Decode for Call<T, I>
where
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
<T::Lookup as StaticLookup>::Source: _parity_scale_codec::Decode,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
T::Balance: _parity_scale_codec::HasCompact,
{
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
match input.read_byte()? {
x if x == 0usize as u8 => Ok(Call::transfer(
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => return Err("Error decoding field Call :: transfer.0".into()),
Ok(a) => a,
}
},
{
let res = < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: Decode > :: decode ( input ) ;
match res {
Err(_) => return Err("Error decoding field Call :: transfer.1".into()),
Ok(a) => a.into(),
}
},
)),
x if x == 1usize as u8 => Ok(Call::set_balance(
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field Call :: set_balance.0".into())
}
Ok(a) => a,
}
},
{
let res = < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: Decode > :: decode ( input ) ;
match res {
Err(_) => {
return Err("Error decoding field Call :: set_balance.1".into())
}
Ok(a) => a.into(),
}
},
{
let res = < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: Decode > :: decode ( input ) ;
match res {
Err(_) => {
return Err("Error decoding field Call :: set_balance.2".into())
}
Ok(a) => a.into(),
}
},
)),
x if x == 2usize as u8 => Ok(Call::force_transfer(
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field Call :: force_transfer.0".into())
}
Ok(a) => a,
}
},
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err("Error decoding field Call :: force_transfer.1".into())
}
Ok(a) => a,
}
},
{
let res = < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: Decode > :: decode ( input ) ;
match res {
Err(_) => {
return Err("Error decoding field Call :: force_transfer.2".into())
}
Ok(a) => a.into(),
}
},
)),
x if x == 3usize as u8 => Ok(Call::transfer_keep_alive(
{
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => {
return Err(
"Error decoding field Call :: transfer_keep_alive.0".into()
)
}
Ok(a) => a,
}
},
{
let res = < < T :: Balance as _parity_scale_codec :: HasCompact > :: Type as _parity_scale_codec :: Decode > :: decode ( input ) ;
match res {
Err(_) => {
return Err(
"Error decoding field Call :: transfer_keep_alive.1".into()
)
}
Ok(a) => a.into(),
}
},
)),
x => Err("No such variant in enum Call".into()),
}
}
}
};
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::GetDispatchInfo for Call<T, I> {
fn get_dispatch_info(&self) -> ::palette_support::dispatch::DispatchInfo {
if let Call::transfer(ref dest, ref value) = self {
let weight = <dyn::palette_support::dispatch::WeighData<(
&<T::Lookup as StaticLookup>::Source,
&T::Balance,
)>>::weigh_data(
&SimpleDispatchInfo::FixedNormal(1_000_000), (dest, value)
);
let class = <dyn::palette_support::dispatch::ClassifyDispatch<(
&<T::Lookup as StaticLookup>::Source,
&T::Balance,
)>>::classify_dispatch(
&SimpleDispatchInfo::FixedNormal(1_000_000), (dest, value)
);
return ::palette_support::dispatch::DispatchInfo { weight, class };
}
if let Call::__PhantomItem(_, _) = self {
{
{
{
::std::rt::begin_panic_fmt(
&::core::fmt::Arguments::new_v1(
&["internal error: entered unreachable code: "],
&match (&"__PhantomItem should never be used.",) {
(arg0,) => [::core::fmt::ArgumentV1::new(
arg0,
::core::fmt::Display::fmt,
)],
},
),
&("palette/balances/src/lib.rs", 386u32, 1u32),
)
}
}
}
}
if let Call::set_balance(ref who, ref new_free, ref new_reserved) = self {
let weight = <dyn::palette_support::dispatch::WeighData<(
&<T::Lookup as StaticLookup>::Source,
&T::Balance,
&T::Balance,
)>>::weigh_data(
&SimpleDispatchInfo::FixedOperational(50_000),
(who, new_free, new_reserved),
);
let class = <dyn::palette_support::dispatch::ClassifyDispatch<(
&<T::Lookup as StaticLookup>::Source,
&T::Balance,
&T::Balance,
)>>::classify_dispatch(
&SimpleDispatchInfo::FixedOperational(50_000),
(who, new_free, new_reserved),
);
return ::palette_support::dispatch::DispatchInfo { weight, class };
}
if let Call::__PhantomItem(_, _) = self {
{
{
{
::std::rt::begin_panic_fmt(
&::core::fmt::Arguments::new_v1(
&["internal error: entered unreachable code: "],
&match (&"__PhantomItem should never be used.",) {
(arg0,) => [::core::fmt::ArgumentV1::new(
arg0,
::core::fmt::Display::fmt,
)],
},
),
&("palette/balances/src/lib.rs", 386u32, 1u32),
)
}
}
}
}
if let Call::force_transfer(ref source, ref dest, ref value) = self {
let weight = <dyn::palette_support::dispatch::WeighData<(
&<T::Lookup as StaticLookup>::Source,
&<T::Lookup as StaticLookup>::Source,
&T::Balance,
)>>::weigh_data(
&SimpleDispatchInfo::FixedNormal(1_000_000),
(source, dest, value),
);
let class = <dyn::palette_support::dispatch::ClassifyDispatch<(
&<T::Lookup as StaticLookup>::Source,
&<T::Lookup as StaticLookup>::Source,
&T::Balance,
)>>::classify_dispatch(
&SimpleDispatchInfo::FixedNormal(1_000_000),
(source, dest, value),
);
return ::palette_support::dispatch::DispatchInfo { weight, class };
}
if let Call::__PhantomItem(_, _) = self {
{
{
{
::std::rt::begin_panic_fmt(
&::core::fmt::Arguments::new_v1(
&["internal error: entered unreachable code: "],
&match (&"__PhantomItem should never be used.",) {
(arg0,) => [::core::fmt::ArgumentV1::new(
arg0,
::core::fmt::Display::fmt,
)],
},
),
&("palette/balances/src/lib.rs", 386u32, 1u32),
)
}
}
}
}
if let Call::transfer_keep_alive(ref dest, ref value) = self {
let weight = <dyn::palette_support::dispatch::WeighData<(
&<T::Lookup as StaticLookup>::Source,
&T::Balance,
)>>::weigh_data(
&SimpleDispatchInfo::FixedNormal(1_000_000), (dest, value)
);
let class = <dyn::palette_support::dispatch::ClassifyDispatch<(
&<T::Lookup as StaticLookup>::Source,
&T::Balance,
)>>::classify_dispatch(
&SimpleDispatchInfo::FixedNormal(1_000_000), (dest, value)
);
return ::palette_support::dispatch::DispatchInfo { weight, class };
}
if let Call::__PhantomItem(_, _) = self {
{
{
{
::std::rt::begin_panic_fmt(
&::core::fmt::Arguments::new_v1(
&["internal error: entered unreachable code: "],
&match (&"__PhantomItem should never be used.",) {
(arg0,) => [::core::fmt::ArgumentV1::new(
arg0,
::core::fmt::Display::fmt,
)],
},
),
&("palette/balances/src/lib.rs", 386u32, 1u32),
)
}
}
}
}
let weight = <dyn::palette_support::dispatch::WeighData<_>>::weigh_data(
&::palette_support::dispatch::SimpleDispatchInfo::default(),
(),
);
let class = <dyn::palette_support::dispatch::ClassifyDispatch<_>>::classify_dispatch(
&::palette_support::dispatch::SimpleDispatchInfo::default(),
(),
);
::palette_support::dispatch::DispatchInfo { weight, class }
}
}
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::Clone for Call<T, I> {
fn clone(&self) -> Self {
match *self {
Call::transfer(ref dest, ref value) => {
Call::transfer((*dest).clone(), (*value).clone())
}
Call::set_balance(ref who, ref new_free, ref new_reserved) => {
Call::set_balance((*who).clone(), (*new_free).clone(), (*new_reserved).clone())
}
Call::force_transfer(ref source, ref dest, ref value) => {
Call::force_transfer((*source).clone(), (*dest).clone(), (*value).clone())
}
Call::transfer_keep_alive(ref dest, ref value) => {
Call::transfer_keep_alive((*dest).clone(), (*value).clone())
}
_ => ::std::rt::begin_panic(
"internal error: entered unreachable code",
&("palette/balances/src/lib.rs", 386u32, 1u32),
),
}
}
}
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::PartialEq for Call<T, I> {
fn eq(&self, _other: &Self) -> bool {
match *self {
Call::transfer(ref dest, ref value) => {
let self_params = (dest, value);
if let Call::transfer(ref dest, ref value) = *_other {
self_params == (dest, value)
} else {
match *_other {
Call::__PhantomItem(_, _) => ::std::rt::begin_panic(
"internal error: entered unreachable code",
&("palette/balances/src/lib.rs", 386u32, 1u32),
),
_ => false,
}
}
}
Call::set_balance(ref who, ref new_free, ref new_reserved) => {
let self_params = (who, new_free, new_reserved);
if let Call::set_balance(ref who, ref new_free, ref new_reserved) = *_other {
self_params == (who, new_free, new_reserved)
} else {
match *_other {
Call::__PhantomItem(_, _) => ::std::rt::begin_panic(
"internal error: entered unreachable code",
&("palette/balances/src/lib.rs", 386u32, 1u32),
),
_ => false,
}
}
}
Call::force_transfer(ref source, ref dest, ref value) => {
let self_params = (source, dest, value);
if let Call::force_transfer(ref source, ref dest, ref value) = *_other {
self_params == (source, dest, value)
} else {
match *_other {
Call::__PhantomItem(_, _) => ::std::rt::begin_panic(
"internal error: entered unreachable code",
&("palette/balances/src/lib.rs", 386u32, 1u32),
),
_ => false,
}
}
}
Call::transfer_keep_alive(ref dest, ref value) => {
let self_params = (dest, value);
if let Call::transfer_keep_alive(ref dest, ref value) = *_other {
self_params == (dest, value)
} else {
match *_other {
Call::__PhantomItem(_, _) => ::std::rt::begin_panic(
"internal error: entered unreachable code",
&("palette/balances/src/lib.rs", 386u32, 1u32),
),
_ => false,
}
}
}
_ => ::std::rt::begin_panic(
"internal error: entered unreachable code",
&("palette/balances/src/lib.rs", 386u32, 1u32),
),
}
}
}
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::Eq for Call<T, I> {}
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::fmt::Debug for Call<T, I> {
fn fmt(
&self,
_f: &mut ::palette_support::dispatch::fmt::Formatter,
) -> ::palette_support::dispatch::result::Result<(), ::palette_support::dispatch::fmt::Error>
{
match *self {
Call::transfer(ref dest, ref value) => _f.write_fmt(::core::fmt::Arguments::new_v1(
&["", ""],
&match (&"transfer", &(dest.clone(), value.clone())) {
(arg0, arg1) => [
::core::fmt::ArgumentV1::new(arg0, ::core::fmt::Display::fmt),
::core::fmt::ArgumentV1::new(arg1, ::core::fmt::Debug::fmt),
],
},
)),
Call::set_balance(ref who, ref new_free, ref new_reserved) => {
_f.write_fmt(::core::fmt::Arguments::new_v1(
&["", ""],
&match (
&"set_balance",
&(who.clone(), new_free.clone(), new_reserved.clone()),
) {
(arg0, arg1) => [
::core::fmt::ArgumentV1::new(arg0, ::core::fmt::Display::fmt),
::core::fmt::ArgumentV1::new(arg1, ::core::fmt::Debug::fmt),
],
},
))
}
Call::force_transfer(ref source, ref dest, ref value) => {
_f.write_fmt(::core::fmt::Arguments::new_v1(
&["", ""],
&match (
&"force_transfer",
&(source.clone(), dest.clone(), value.clone()),
) {
(arg0, arg1) => [
::core::fmt::ArgumentV1::new(arg0, ::core::fmt::Display::fmt),
::core::fmt::ArgumentV1::new(arg1, ::core::fmt::Debug::fmt),
],
},
))
}
Call::transfer_keep_alive(ref dest, ref value) => {
_f.write_fmt(::core::fmt::Arguments::new_v1(
&["", ""],
&match (&"transfer_keep_alive", &(dest.clone(), value.clone())) {
(arg0, arg1) => [
::core::fmt::ArgumentV1::new(arg0, ::core::fmt::Display::fmt),
::core::fmt::ArgumentV1::new(arg1, ::core::fmt::Debug::fmt),
],
},
))
}
_ => ::std::rt::begin_panic(
"internal error: entered unreachable code",
&("palette/balances/src/lib.rs", 386u32, 1u32),
),
}
}
}
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::Dispatchable for Call<T, I> {
type Trait = T;
type Origin = T::Origin;
type Error = &'static str;
fn dispatch(
self,
_origin: Self::Origin,
) -> ::palette_support::dispatch::DispatchResult<Self::Error> {
match self {
Call::transfer(dest, value) => <Module<T, I>>::transfer(_origin, dest, value),
Call::set_balance(who, new_free, new_reserved) => {
<Module<T, I>>::set_balance(_origin, who, new_free, new_reserved)
}
Call::force_transfer(source, dest, value) => {
<Module<T, I>>::force_transfer(_origin, source, dest, value)
}
Call::transfer_keep_alive(dest, value) => {
<Module<T, I>>::transfer_keep_alive(_origin, dest, value)
}
Call::__PhantomItem(_, _) => ::std::rt::begin_panic_fmt(
&::core::fmt::Arguments::new_v1(
&["internal error: entered unreachable code: "],
&match (&"__PhantomItem should never be used.",) {
(arg0,) => [::core::fmt::ArgumentV1::new(
arg0,
::core::fmt::Display::fmt,
)],
},
),
&("palette/balances/src/lib.rs", 386u32, 1u32),
),
}
}
}
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::Callable<T> for Module<T, I> {
type Call = Call<T, I>;
}
impl<T: Trait<I>, I: Instance> Module<T, I> {
#[doc(hidden)]
pub fn dispatch<D: ::palette_support::dispatch::Dispatchable<Trait = T>>(
d: D,
origin: D::Origin,
) -> ::palette_support::dispatch::DispatchResult<D::Error> {
d.dispatch(origin)
}
}
impl<T: Trait<I>, I: Instance> Module<T, I> {
#[doc(hidden)]
pub fn call_functions() -> &'static [::palette_support::dispatch::FunctionMetadata] {
& [ :: palette_support :: dispatch :: FunctionMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "transfer" ) , arguments : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( & [ :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "dest" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "<T::Lookup as StaticLookup>::Source" ) , } , :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "value" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "Compact<T::Balance>" ) , } ] ) , documentation : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( & [ r" Transfer some liquid free balance to another account." , r"" , r" `transfer` will set the `FreeBalance` of the sender and receiver." , r" It will decrease the total issuance of the system by the `TransferFee`." , r" If the sender's account is below the existential deposit as a result" , r" of the transfer, the account will be reaped." , r"" , r" The dispatch origin for this call must be `Signed` by the transactor." , r"" , r" # <weight>" , r" - Dependent on arguments but not critical, given proper implementations for" , r" input config types. See related functions below." , r" - It contains a limited number of reads and writes internally and no complex computation." , r"" , r" Related functions:" , r"" , r" - `ensure_can_withdraw` is always called internally but has a bounded complexity." , r" - Transferring balances to accounts that did not exist before will cause" , r" `T::OnNewAccount::on_new_account` to be called." , r" - Removing enough funds from an account will trigger" , r" `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`." , r" - `transfer_keep_alive` works the same way as `transfer`, but has an additional" , r" check that the transfer will not kill the origin account." , r"" , r" # </weight>" ] ) , } , :: palette_support :: dispatch :: FunctionMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "set_balance" ) , arguments : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( & [ :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "who" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "<T::Lookup as StaticLookup>::Source" ) , } , :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "new_free" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "Compact<T::Balance>" ) , } , :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "new_reserved" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "Compact<T::Balance>" ) , } ] ) , documentation : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( & [ r" Set the balances of a given account." , r"" , r" This will alter `FreeBalance` and `ReservedBalance` in storage. it will" , r" also decrease the total issuance of the system (`TotalIssuance`)." , r" If the new free or reserved balance is below the existential deposit," , r" it will reset the account nonce (`system::AccountNonce`)." , r"" , r" The dispatch origin for this call is `root`." , r"" , r" # <weight>" , r" - Independent of the arguments." , r" - Contains a limited number of reads and writes." , r" # </weight>" ] ) , } , :: palette_support :: dispatch :: FunctionMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "force_transfer" ) , arguments : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( & [ :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "source" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "<T::Lookup as StaticLookup>::Source" ) , } , :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "dest" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "<T::Lookup as StaticLookup>::Source" ) , } , :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "value" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "Compact<T::Balance>" ) , } ] ) , documentation : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( & [ r" Exactly as `transfer`, except the origin must be root and the source account may be" , r" specified." ] ) , } , :: palette_support :: dispatch :: FunctionMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "transfer_keep_alive" ) , arguments : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( & [ :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "dest" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "<T::Lookup as StaticLookup>::Source" ) , } , :: palette_support :: dispatch :: FunctionArgumentMetadata { name : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "value" ) , ty : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( "Compact<T::Balance>" ) , } ] ) , documentation : :: palette_support :: dispatch :: DecodeDifferent :: Encode ( & [ r" Same as the [`transfer`] call, but with a check that the transfer will not kill the" , r" origin account." , r"" , r" 99% of the time you want [`transfer`] instead." , r"" , r" [`transfer`]: struct.Module.html#method.transfer" ] ) , } ]
}
}
impl<T: 'static + Trait<I>, I: Instance> Module<T, I> {
#[doc(hidden)]
pub fn module_constants_metadata(
) -> &'static [::palette_support::dispatch::ModuleConstantMetadata] {
#[allow(non_upper_case_types)]
#[allow(non_camel_case_types)]
struct ExistentialDepositDefaultByteGetter<T: Trait<I>, I: Instance>(
::palette_support::dispatch::marker::PhantomData<(T, I)>,
);
impl<T: 'static + Trait<I>, I: Instance> ::palette_support::dispatch::DefaultByte
for ExistentialDepositDefaultByteGetter<T, I>
{
fn default_byte(&self) -> ::palette_support::dispatch::Vec<u8> {
let value: T::Balance = T::ExistentialDeposit::get();
::palette_support::dispatch::Encode::encode(&value)
}
}
unsafe impl<T: 'static + Trait<I>, I: Instance> Send for ExistentialDepositDefaultByteGetter<T, I> {}
unsafe impl<T: 'static + Trait<I>, I: Instance> Sync for ExistentialDepositDefaultByteGetter<T, I> {}
#[allow(non_upper_case_types)]
#[allow(non_camel_case_types)]
struct TransferFeeDefaultByteGetter<T: Trait<I>, I: Instance>(
::palette_support::dispatch::marker::PhantomData<(T, I)>,
);
impl<T: 'static + Trait<I>, I: Instance> ::palette_support::dispatch::DefaultByte
for TransferFeeDefaultByteGetter<T, I>
{
fn default_byte(&self) -> ::palette_support::dispatch::Vec<u8> {
let value: T::Balance = T::TransferFee::get();
::palette_support::dispatch::Encode::encode(&value)
}
}
unsafe impl<T: 'static + Trait<I>, I: Instance> Send for TransferFeeDefaultByteGetter<T, I> {}
unsafe impl<T: 'static + Trait<I>, I: Instance> Sync for TransferFeeDefaultByteGetter<T, I> {}
#[allow(non_upper_case_types)]
#[allow(non_camel_case_types)]
struct CreationFeeDefaultByteGetter<T: Trait<I>, I: Instance>(
::palette_support::dispatch::marker::PhantomData<(T, I)>,
);
impl<T: 'static + Trait<I>, I: Instance> ::palette_support::dispatch::DefaultByte
for CreationFeeDefaultByteGetter<T, I>
{
fn default_byte(&self) -> ::palette_support::dispatch::Vec<u8> {
let value: T::Balance = T::CreationFee::get();
::palette_support::dispatch::Encode::encode(&value)
}
}
unsafe impl<T: 'static + Trait<I>, I: Instance> Send for CreationFeeDefaultByteGetter<T, I> {}
unsafe impl<T: 'static + Trait<I>, I: Instance> Sync for CreationFeeDefaultByteGetter<T, I> {}
&[
::palette_support::dispatch::ModuleConstantMetadata {
name: ::palette_support::dispatch::DecodeDifferent::Encode("ExistentialDeposit"),
ty: ::palette_support::dispatch::DecodeDifferent::Encode("T::Balance"),
value: ::palette_support::dispatch::DecodeDifferent::Encode(
::palette_support::dispatch::DefaultByteGetter(
&ExistentialDepositDefaultByteGetter::<T, I>(
::palette_support::dispatch::marker::PhantomData,
),
),
),
documentation: ::palette_support::dispatch::DecodeDifferent::Encode(&[
r" The minimum amount required to keep an account open.",
]),
},
::palette_support::dispatch::ModuleConstantMetadata {
name: ::palette_support::dispatch::DecodeDifferent::Encode("TransferFee"),
ty: ::palette_support::dispatch::DecodeDifferent::Encode("T::Balance"),
value: ::palette_support::dispatch::DecodeDifferent::Encode(
::palette_support::dispatch::DefaultByteGetter(
&TransferFeeDefaultByteGetter::<T, I>(
::palette_support::dispatch::marker::PhantomData,
),
),
),
documentation: ::palette_support::dispatch::DecodeDifferent::Encode(&[
r" The fee required to make a transfer.",
]),
},
::palette_support::dispatch::ModuleConstantMetadata {
name: ::palette_support::dispatch::DecodeDifferent::Encode("CreationFee"),
ty: ::palette_support::dispatch::DecodeDifferent::Encode("T::Balance"),
value: ::palette_support::dispatch::DecodeDifferent::Encode(
::palette_support::dispatch::DefaultByteGetter(
&CreationFeeDefaultByteGetter::<T, I>(
::palette_support::dispatch::marker::PhantomData,
),
),
),
documentation: ::palette_support::dispatch::DecodeDifferent::Encode(&[
r" The fee required to create an account.",
]),
},
]
}
}
impl<T: Trait<I>, I: Instance> ::palette_support::dispatch::ModuleErrorMetadata for Module<T, I> {
fn metadata() -> &'static [::palette_support::dispatch::ErrorMetadata] {
<&'static str as ::palette_support::dispatch::ModuleErrorMetadata>::metadata()
}
}
impl<T: Trait<I>, I: Instance> Module<T, I> {
#[doc = " Get the amount that is currently being vested and cannot be transferred out of this account."]
pub fn vesting_balance(who: &T::AccountId) -> T::Balance {
if let Some(v) = Self::vesting(who) {
Self::free_balance(who).min(v.locked_at(<system::Module<T>>::block_number()))
} else {
Zero::zero()
}
}
#[doc = " Set the reserved balance of an account to some new value. Will enforce `ExistentialDeposit`"]
#[doc = " law, annulling the account as needed."]
#[doc = ""]
#[doc = " Doesn\'t do any preparatory work for creating a new account, so should only be used when it"]
#[doc = " is known that the account already exists."]
#[doc = ""]
#[doc = " NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that"]
#[doc = " the caller will do this."]
fn set_reserved_balance(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome {
if balance < T::ExistentialDeposit::get() {
<ReservedBalance<T, I>>::insert(who, balance);
Self::on_reserved_too_low(who);
UpdateBalanceOutcome::AccountKilled
} else {
<ReservedBalance<T, I>>::insert(who, balance);
UpdateBalanceOutcome::Updated
}
}
#[doc = " Set the free balance of an account to some new value. Will enforce `ExistentialDeposit`"]
#[doc = " law, annulling the account as needed."]
#[doc = ""]
#[doc = " Doesn\'t do any preparatory work for creating a new account, so should only be used when it"]
#[doc = " is known that the account already exists."]
#[doc = ""]
#[doc = " NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that"]
#[doc = " the caller will do this."]
fn set_free_balance(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome {
if balance < T::ExistentialDeposit::get() {
<FreeBalance<T, I>>::insert(who, balance);
Self::on_free_too_low(who);
UpdateBalanceOutcome::AccountKilled
} else {
<FreeBalance<T, I>>::insert(who, balance);
UpdateBalanceOutcome::Updated
}
}
#[doc = " Register a new account (with existential balance)."]
#[doc = ""]
#[doc = " This just calls appropriate hooks. It doesn\'t (necessarily) make any state changes."]
fn new_account(who: &T::AccountId, balance: T::Balance) {
T::OnNewAccount::on_new_account(&who);
Self::deposit_event(RawEvent::NewAccount(who.clone(), balance.clone()));
}
#[doc = " Unregister an account."]
#[doc = ""]
#[doc = " This just removes the nonce and leaves an event."]
fn reap_account(who: &T::AccountId) {
<system::AccountNonce<T>>::remove(who);
Self::deposit_event(RawEvent::ReapedAccount(who.clone()));
}
#[doc = " Account\'s free balance has dropped below existential deposit. Kill its"]
#[doc = " free side and the account completely if its reserved size is already dead."]
#[doc = ""]
#[doc = " Will maintain total issuance."]
fn on_free_too_low(who: &T::AccountId) {
let dust = <FreeBalance<T, I>>::take(who);
<Locks<T, I>>::remove(who);
if !dust.is_zero() {
T::DustRemoval::on_unbalanced(NegativeImbalance::new(dust));
}
T::OnFreeBalanceZero::on_free_balance_zero(who);
if Self::reserved_balance(who).is_zero() {
Self::reap_account(who);
}
}
#[doc = " Account\'s reserved balance has dropped below existential deposit. Kill its"]
#[doc = " reserved side and the account completely if its free size is already dead."]
#[doc = ""]
#[doc = " Will maintain total issuance."]
fn on_reserved_too_low(who: &T::AccountId) {
let dust = <ReservedBalance<T, I>>::take(who);
if !dust.is_zero() {
T::DustRemoval::on_unbalanced(NegativeImbalance::new(dust));
}
if Self::free_balance(who).is_zero() {
Self::reap_account(who);
}
}
}
mod imbalances {
use super::{
result, DefaultInstance, Imbalance, Instance, Saturating, StorageValue, Subtrait, Trait,
TryDrop, Zero,
};
use rstd::mem;
#[doc = " Opaque, move-only struct with private fields that serves as a token denoting that"]
#[doc = " funds have been created without any equal and opposite accounting."]
#[must_use]
pub struct PositiveImbalance<T: Subtrait<I>, I: Instance = DefaultInstance>(T::Balance);
impl<T: Subtrait<I>, I: Instance> PositiveImbalance<T, I> {
#[doc = " Create a new positive imbalance from a balance."]
pub fn new(amount: T::Balance) -> Self {
PositiveImbalance(amount)
}
}
#[doc = " Opaque, move-only struct with private fields that serves as a token denoting that"]
#[doc = " funds have been destroyed without any equal and opposite accounting."]
#[must_use]
pub struct NegativeImbalance<T: Subtrait<I>, I: Instance = DefaultInstance>(T::Balance);
impl<T: Subtrait<I>, I: Instance> NegativeImbalance<T, I> {
#[doc = " Create a new negative imbalance from a balance."]
pub fn new(amount: T::Balance) -> Self {
NegativeImbalance(amount)
}
}
impl<T: Trait<I>, I: Instance> TryDrop for PositiveImbalance<T, I> {
fn try_drop(self) -> result::Result<(), Self> {
self.drop_zero()
}
}
impl<T: Trait<I>, I: Instance> Imbalance<T::Balance> for PositiveImbalance<T, I> {
type Opposite = NegativeImbalance<T, I>;
fn zero() -> Self {
Self(Zero::zero())
}
fn drop_zero(self) -> result::Result<(), Self> {
if self.0.is_zero() {
Ok(())
} else {
Err(self)
}
}
fn split(self, amount: T::Balance) -> (Self, Self) {
let first = self.0.min(amount);
let second = self.0 - first;
mem::forget(self);
(Self(first), Self(second))
}
fn merge(mut self, other: Self) -> Self {
self.0 = self.0.saturating_add(other.0);
mem::forget(other);
self
}
fn subsume(&mut self, other: Self) {
self.0 = self.0.saturating_add(other.0);
mem::forget(other);
}
fn offset(self, other: Self::Opposite) -> result::Result<Self, Self::Opposite> {
let (a, b) = (self.0, other.0);
mem::forget((self, other));
if a >= b {
Ok(Self(a - b))
} else {
Err(NegativeImbalance::new(b - a))
}
}
fn peek(&self) -> T::Balance {
self.0.clone()
}
}
impl<T: Trait<I>, I: Instance> TryDrop for NegativeImbalance<T, I> {
fn try_drop(self) -> result::Result<(), Self> {
self.drop_zero()
}
}
impl<T: Trait<I>, I: Instance> Imbalance<T::Balance> for NegativeImbalance<T, I> {
type Opposite = PositiveImbalance<T, I>;
fn zero() -> Self {
Self(Zero::zero())
}
fn drop_zero(self) -> result::Result<(), Self> {
if self.0.is_zero() {
Ok(())
} else {
Err(self)
}
}
fn split(self, amount: T::Balance) -> (Self, Self) {
let first = self.0.min(amount);
let second = self.0 - first;
mem::forget(self);
(Self(first), Self(second))
}
fn merge(mut self, other: Self) -> Self {
self.0 = self.0.saturating_add(other.0);
mem::forget(other);
self
}
fn subsume(&mut self, other: Self) {
self.0 = self.0.saturating_add(other.0);
mem::forget(other);
}
fn offset(self, other: Self::Opposite) -> result::Result<Self, Self::Opposite> {
let (a, b) = (self.0, other.0);
mem::forget((self, other));
if a >= b {
Ok(Self(a - b))
} else {
Err(PositiveImbalance::new(b - a))
}
}
fn peek(&self) -> T::Balance {
self.0.clone()
}
}
impl<T: Subtrait<I>, I: Instance> Drop for PositiveImbalance<T, I> {
#[doc = " Basic drop handler will just square up the total issuance."]
fn drop(&mut self) {
<super::TotalIssuance<super::ElevatedTrait<T, I>, I>>::mutate(|v| {
*v = v.saturating_add(self.0)
});
}
}
impl<T: Subtrait<I>, I: Instance> Drop for NegativeImbalance<T, I> {
#[doc = " Basic drop handler will just square up the total issuance."]
fn drop(&mut self) {
<super::TotalIssuance<super::ElevatedTrait<T, I>, I>>::mutate(|v| {
*v = v.saturating_sub(self.0)
});
}
}
}
struct ElevatedTrait<T: Subtrait<I>, I: Instance>(T, I);
impl<T: Subtrait<I>, I: Instance> Clone for ElevatedTrait<T, I> {
fn clone(&self) -> Self {
{
::std::rt::begin_panic(
"not yet implemented",
&("palette/balances/src/lib.rs", 789u32, 28u32),
)
}
}
}
impl<T: Subtrait<I>, I: Instance> PartialEq for ElevatedTrait<T, I> {
fn eq(&self, _: &Self) -> bool {
{
::std::rt::begin_panic(
"not yet implemented",
&("palette/balances/src/lib.rs", 792u32, 35u32),
)
}
}
}
impl<T: Subtrait<I>, I: Instance> Eq for ElevatedTrait<T, I> {}
impl<T: Subtrait<I>, I: Instance> system::Trait for ElevatedTrait<T, I> {
type Origin = T::Origin;
type Call = T::Call;
type Index = T::Index;
type BlockNumber = T::BlockNumber;
type Hash = T::Hash;
type Hashing = T::Hashing;
type AccountId = T::AccountId;
type Lookup = T::Lookup;
type Header = T::Header;
type Event = ();
type BlockHashCount = T::BlockHashCount;
type MaximumBlockWeight = T::MaximumBlockWeight;
type MaximumBlockLength = T::MaximumBlockLength;
type AvailableBlockRatio = T::AvailableBlockRatio;
type Version = T::Version;
}
impl<T: Subtrait<I>, I: Instance> Trait<I> for ElevatedTrait<T, I> {
type Balance = T::Balance;
type OnFreeBalanceZero = T::OnFreeBalanceZero;
type OnNewAccount = T::OnNewAccount;
type Event = ();
type TransferPayment = ();
type DustRemoval = ();
type ExistentialDeposit = T::ExistentialDeposit;
type TransferFee = T::TransferFee;
type CreationFee = T::CreationFee;
}
impl<T: Trait<I>, I: Instance> Currency<T::AccountId> for Module<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
type Balance = T::Balance;
type PositiveImbalance = PositiveImbalance<T, I>;
type NegativeImbalance = NegativeImbalance<T, I>;
fn total_balance(who: &T::AccountId) -> Self::Balance {
Self::free_balance(who) + Self::reserved_balance(who)
}
fn can_slash(who: &T::AccountId, value: Self::Balance) -> bool {
Self::free_balance(who) >= value
}
fn total_issuance() -> Self::Balance {
<TotalIssuance<T, I>>::get()
}
fn minimum_balance() -> Self::Balance {
T::ExistentialDeposit::get()
}
fn free_balance(who: &T::AccountId) -> Self::Balance {
<FreeBalance<T, I>>::get(who)
}
fn burn(mut amount: Self::Balance) -> Self::PositiveImbalance {
<TotalIssuance<T, I>>::mutate(|issued| {
*issued = issued.checked_sub(&amount).unwrap_or_else(|| {
amount = *issued;
Zero::zero()
});
});
PositiveImbalance::new(amount)
}
fn issue(mut amount: Self::Balance) -> Self::NegativeImbalance {
<TotalIssuance<T, I>>::mutate(|issued| {
*issued = issued.checked_add(&amount).unwrap_or_else(|| {
amount = Self::Balance::max_value() - *issued;
Self::Balance::max_value()
})
});
NegativeImbalance::new(amount)
}
fn ensure_can_withdraw(
who: &T::AccountId,
_amount: T::Balance,
reasons: WithdrawReasons,
new_balance: T::Balance,
) -> Result {
if reasons.intersects(WithdrawReason::Reserve | WithdrawReason::Transfer)
&& Self::vesting_balance(who) > new_balance
{
return Err("vesting balance too high to send value");
}
let locks = Self::locks(who);
if locks.is_empty() {
return Ok(());
}
let now = <system::Module<T>>::block_number();
if locks
.into_iter()
.all(|l| now >= l.until || new_balance >= l.amount || !l.reasons.intersects(reasons))
{
Ok(())
} else {
Err("account liquidity restrictions prevent withdrawal")
}
}
fn transfer(
transactor: &T::AccountId,
dest: &T::AccountId,
value: Self::Balance,
existence_requirement: ExistenceRequirement,
) -> Result {
let from_balance = Self::free_balance(transactor);
let to_balance = Self::free_balance(dest);
let would_create = to_balance.is_zero();
let fee = if would_create {
T::CreationFee::get()
} else {
T::TransferFee::get()
};
let liability = match value.checked_add(&fee) {
Some(l) => l,
None => return Err("got overflow after adding a fee to value"),
};
let new_from_balance = match from_balance.checked_sub(&liability) {
None => return Err("balance too low to send value"),
Some(b) => b,
};
if would_create && value < T::ExistentialDeposit::get() {
return Err("value too low to create account");
}
Self::ensure_can_withdraw(
transactor,
value,
WithdrawReason::Transfer.into(),
new_from_balance,
)?;
let new_to_balance = match to_balance.checked_add(&value) {
Some(b) => b,
None => return Err("destination balance too high to receive value"),
};
if transactor != dest {
if existence_requirement == ExistenceRequirement::KeepAlive {
if new_from_balance < Self::minimum_balance() {
return Err("transfer would kill account");
}
}
Self::set_free_balance(transactor, new_from_balance);
if !<FreeBalance<T, I>>::exists(dest) {
Self::new_account(dest, new_to_balance);
}
Self::set_free_balance(dest, new_to_balance);
T::TransferPayment::on_unbalanced(NegativeImbalance::new(fee));
Self::deposit_event(RawEvent::Transfer(
transactor.clone(),
dest.clone(),
value,
fee,
));
}
Ok(())
}
fn withdraw(
who: &T::AccountId,
value: Self::Balance,
reasons: WithdrawReasons,
liveness: ExistenceRequirement,
) -> result::Result<Self::NegativeImbalance, &'static str> {
let old_balance = Self::free_balance(who);
if let Some(new_balance) = old_balance.checked_sub(&value) {
if liveness == ExistenceRequirement::KeepAlive
&& new_balance < T::ExistentialDeposit::get()
&& old_balance >= T::ExistentialDeposit::get()
{
return Err("payment would kill account");
}
Self::ensure_can_withdraw(who, value, reasons, new_balance)?;
Self::set_free_balance(who, new_balance);
Ok(NegativeImbalance::new(value))
} else {
Err("too few free funds in account")
}
}
fn slash(who: &T::AccountId, value: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) {
let free_balance = Self::free_balance(who);
let free_slash = cmp::min(free_balance, value);
Self::set_free_balance(who, free_balance - free_slash);
let remaining_slash = value - free_slash;
if !remaining_slash.is_zero() {
let reserved_balance = Self::reserved_balance(who);
let reserved_slash = cmp::min(reserved_balance, remaining_slash);
Self::set_reserved_balance(who, reserved_balance - reserved_slash);
(
NegativeImbalance::new(free_slash + reserved_slash),
remaining_slash - reserved_slash,
)
} else {
(NegativeImbalance::new(value), Zero::zero())
}
}
fn deposit_into_existing(
who: &T::AccountId,
value: Self::Balance,
) -> result::Result<Self::PositiveImbalance, &'static str> {
if Self::total_balance(who).is_zero() {
return Err("beneficiary account must pre-exist");
}
Self::set_free_balance(who, Self::free_balance(who) + value);
Ok(PositiveImbalance::new(value))
}
fn deposit_creating(who: &T::AccountId, value: Self::Balance) -> Self::PositiveImbalance {
let (imbalance, _) = Self::make_free_balance_be(who, Self::free_balance(who) + value);
if let SignedImbalance::Positive(p) = imbalance {
p
} else {
Self::PositiveImbalance::zero()
}
}
fn make_free_balance_be(
who: &T::AccountId,
balance: Self::Balance,
) -> (
SignedImbalance<Self::Balance, Self::PositiveImbalance>,
UpdateBalanceOutcome,
) {
let original = Self::free_balance(who);
if balance < T::ExistentialDeposit::get() && original.is_zero() {
return (
SignedImbalance::Positive(Self::PositiveImbalance::zero()),
UpdateBalanceOutcome::AccountKilled,
);
}
let imbalance = if original <= balance {
SignedImbalance::Positive(PositiveImbalance::new(balance - original))
} else {
SignedImbalance::Negative(NegativeImbalance::new(original - balance))
};
let outcome = if balance < T::ExistentialDeposit::get() {
Self::set_free_balance(who, balance);
UpdateBalanceOutcome::AccountKilled
} else {
if !<FreeBalance<T, I>>::exists(who) {
Self::new_account(&who, balance);
}
Self::set_free_balance(who, balance);
UpdateBalanceOutcome::Updated
};
(imbalance, outcome)
}
}
impl<T: Trait<I>, I: Instance> ReservableCurrency<T::AccountId> for Module<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool {
Self::free_balance(who)
.checked_sub(&value)
.map_or(false, |new_balance| {
Self::ensure_can_withdraw(who, value, WithdrawReason::Reserve.into(), new_balance)
.is_ok()
})
}
fn reserved_balance(who: &T::AccountId) -> Self::Balance {
<ReservedBalance<T, I>>::get(who)
}
fn reserve(who: &T::AccountId, value: Self::Balance) -> result::Result<(), &'static str> {
let b = Self::free_balance(who);
if b < value {
return Err("not enough free funds");
}
let new_balance = b - value;
Self::ensure_can_withdraw(who, value, WithdrawReason::Reserve.into(), new_balance)?;
Self::set_reserved_balance(who, Self::reserved_balance(who) + value);
Self::set_free_balance(who, new_balance);
Ok(())
}
fn unreserve(who: &T::AccountId, value: Self::Balance) -> Self::Balance {
let b = Self::reserved_balance(who);
let actual = cmp::min(b, value);
Self::set_free_balance(who, Self::free_balance(who) + actual);
Self::set_reserved_balance(who, b - actual);
value - actual
}
fn slash_reserved(
who: &T::AccountId,
value: Self::Balance,
) -> (Self::NegativeImbalance, Self::Balance) {
let b = Self::reserved_balance(who);
let slash = cmp::min(b, value);
Self::set_reserved_balance(who, b - slash);
(NegativeImbalance::new(slash), value - slash)
}
fn repatriate_reserved(
slashed: &T::AccountId,
beneficiary: &T::AccountId,
value: Self::Balance,
) -> result::Result<Self::Balance, &'static str> {
if Self::total_balance(beneficiary).is_zero() {
return Err("beneficiary account must pre-exist");
}
let b = Self::reserved_balance(slashed);
let slash = cmp::min(b, value);
Self::set_free_balance(beneficiary, Self::free_balance(beneficiary) + slash);
Self::set_reserved_balance(slashed, b - slash);
Ok(value - slash)
}
}
impl<T: Trait<I>, I: Instance> LockableCurrency<T::AccountId> for Module<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
type Moment = T::BlockNumber;
fn set_lock(
id: LockIdentifier,
who: &T::AccountId,
amount: T::Balance,
until: T::BlockNumber,
reasons: WithdrawReasons,
) {
let now = <system::Module<T>>::block_number();
let mut new_lock = Some(BalanceLock {
id,
amount,
until,
reasons,
});
let mut locks = Self::locks(who)
.into_iter()
.filter_map(|l| {
if l.id == id {
new_lock.take()
} else if l.until > now {
Some(l)
} else {
None
}
})
.collect::<Vec<_>>();
if let Some(lock) = new_lock {
locks.push(lock)
}
<Locks<T, I>>::insert(who, locks);
}
fn extend_lock(
id: LockIdentifier,
who: &T::AccountId,
amount: T::Balance,
until: T::BlockNumber,
reasons: WithdrawReasons,
) {
let now = <system::Module<T>>::block_number();
let mut new_lock = Some(BalanceLock {
id,
amount,
until,
reasons,
});
let mut locks = Self::locks(who)
.into_iter()
.filter_map(|l| {
if l.id == id {
new_lock.take().map(|nl| BalanceLock {
id: l.id,
amount: l.amount.max(nl.amount),
until: l.until.max(nl.until),
reasons: l.reasons | nl.reasons,
})
} else if l.until > now {
Some(l)
} else {
None
}
})
.collect::<Vec<_>>();
if let Some(lock) = new_lock {
locks.push(lock)
}
<Locks<T, I>>::insert(who, locks);
}
fn remove_lock(id: LockIdentifier, who: &T::AccountId) {
let now = <system::Module<T>>::block_number();
let locks = Self::locks(who)
.into_iter()
.filter_map(|l| {
if l.until > now && l.id != id {
Some(l)
} else {
None
}
})
.collect::<Vec<_>>();
<Locks<T, I>>::insert(who, locks);
}
}
impl<T: Trait<I>, I: Instance> IsDeadAccount<T::AccountId> for Module<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
fn is_dead_account(who: &T::AccountId) -> bool {
Self::total_balance(who).is_zero()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment