mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
5b7512e2e4
* Basic account composition. * Add try_mutate_exists * De-duplicate * Refactor away the UpdateBalanceOutcome * Expunge final UpdateBalanceOutcome refs * Refactor transfer * Refactor reservable currency stuff. * Test with the alternative setup. * Fixes * Test with both setups. * Fixes * Fix * Fix macros * Make indices opt-in * Remove CreationFee, and make indices opt-in. * Fix construct_runtime * Fix last few bits * Fix tests * Update trait impls * Don't hardcode the system event * Make tests build and fix some stuff. * Pointlessly bump runtime version * Fix benchmark * Another fix * Whitespace * Make indices module economically safe * Migrations for indices. * Fix * Whilespace * Trim defunct migrations * Remove unused storage item * More contains_key fixes * Docs. * Bump runtime * Remove unneeded code * Fix test * Fix test * Update frame/balances/src/lib.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Fix ED logic * Repatriate reserved logic * Typo * Fix typo * Update frame/system/src/lib.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Update frame/system/src/lib.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Last few fixes * Another fix * Build fix Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Jaco Greeff <jacogr@gmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
81 lines
2.3 KiB
Rust
81 lines
2.3 KiB
Rust
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
|
// This file is part of Substrate.
|
|
|
|
// Substrate is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Substrate is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
use frame_support::codec::{Encode, Decode, EncodeLike};
|
|
|
|
pub trait Trait: 'static + Eq + Clone {
|
|
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
|
|
+ From<RawOrigin<Self::AccountId>>;
|
|
|
|
type BlockNumber: Decode + Encode + EncodeLike + Clone + Default;
|
|
type Hash;
|
|
type AccountId: Encode + EncodeLike + Decode;
|
|
type Event: From<Event<Self>>;
|
|
type ModuleToIndex: frame_support::traits::ModuleToIndex;
|
|
}
|
|
|
|
frame_support::decl_module! {
|
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
|
}
|
|
|
|
impl<T: Trait> Module<T> {
|
|
pub fn deposit_event(_event: impl Into<T::Event>) {}
|
|
}
|
|
|
|
frame_support::decl_event!(
|
|
pub enum Event<T> where BlockNumber = <T as Trait>::BlockNumber {
|
|
ExtrinsicSuccess,
|
|
ExtrinsicFailed,
|
|
Ignore(BlockNumber),
|
|
}
|
|
);
|
|
|
|
frame_support::decl_error! {
|
|
pub enum Error for Module<T: Trait> {
|
|
/// Test error documentation
|
|
TestError,
|
|
/// Error documentation
|
|
/// with multiple lines
|
|
AnotherError
|
|
}
|
|
}
|
|
|
|
/// Origin for the system module.
|
|
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug)]
|
|
pub enum RawOrigin<AccountId> {
|
|
Root,
|
|
Signed(AccountId),
|
|
None,
|
|
}
|
|
|
|
impl<AccountId> From<Option<AccountId>> for RawOrigin<AccountId> {
|
|
fn from(s: Option<AccountId>) -> RawOrigin<AccountId> {
|
|
match s {
|
|
Some(who) => RawOrigin::Signed(who),
|
|
None => RawOrigin::None,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub type Origin<T> = RawOrigin<<T as Trait>::AccountId>;
|
|
|
|
#[allow(dead_code)]
|
|
pub fn ensure_root<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<(), &'static str>
|
|
where OuterOrigin: Into<Result<RawOrigin<AccountId>, OuterOrigin>>
|
|
{
|
|
o.into().map(|_| ()).map_err(|_| "bad origin: expected to be a root origin")
|
|
}
|