difftreelog
fix cargo fmt
in: master
2 files changed
runtime/common/config/test_pallets.rsdiffbeforeafterboth--- a/runtime/common/config/test_pallets.rs
+++ b/runtime/common/config/test_pallets.rs
@@ -17,5 +17,5 @@
use crate::{Runtime, Event};
impl pallet_test_utils::Config for Runtime {
- type Event = Event;
+ type Event = Event;
}
test-pallets/utils/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819pub use pallet::*;2021#[frame_support::pallet]22pub mod pallet {23 use frame_support::pallet_prelude::*;24 use frame_system::pallet_prelude::*;2526 #[pallet::config]27 pub trait Config: frame_system::Config {28 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;29 }3031 #[pallet::event]32 #[pallet::generate_deposit(pub(super) fn deposit_event)]33 pub enum Event<T: Config> {34 ValueIsSet,35 ShouldRollback,36 }3738 #[pallet::pallet]39 #[pallet::generate_store(pub(super) trait Store)]40 pub struct Pallet<T>(_);4142 #[pallet::storage]43 #[pallet::getter(fn something)]44 pub type TestValue<T> = StorageValue<_, u32, ValueQuery>;4546 #[pallet::error]47 pub enum Error<T> {48 TriggerRollback49 }5051 #[pallet::call]52 impl<T: Config> Pallet<T> {53 #[pallet::weight(10_000)]54 pub fn set_test_value(origin: OriginFor<T>, value: u32) -> DispatchResult {55 ensure_signed(origin)?;5657 <TestValue<T>>::put(value);5859 Self::deposit_event(Event::ValueIsSet);6061 Ok(())62 }6364 #[pallet::weight(10_000)]65 pub fn set_test_value_and_rollback(origin: OriginFor<T>, value: u32) -> DispatchResult {66 Self::set_test_value(origin, value)?;6768 Self::deposit_event(Event::ShouldRollback);6970 Err(<Error<T>>::TriggerRollback.into())71 }72 }73}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819pub use pallet::*;2021#[frame_support::pallet]22pub mod pallet {23 use frame_support::pallet_prelude::*;24 use frame_system::pallet_prelude::*;2526 #[pallet::config]27 pub trait Config: frame_system::Config {28 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;29 }3031 #[pallet::event]32 #[pallet::generate_deposit(pub(super) fn deposit_event)]33 pub enum Event<T: Config> {34 ValueIsSet,35 ShouldRollback,36 }3738 #[pallet::pallet]39 #[pallet::generate_store(pub(super) trait Store)]40 pub struct Pallet<T>(_);4142 #[pallet::storage]43 #[pallet::getter(fn something)]44 pub type TestValue<T> = StorageValue<_, u32, ValueQuery>;4546 #[pallet::error]47 pub enum Error<T> {48 TriggerRollback,49 }5051 #[pallet::call]52 impl<T: Config> Pallet<T> {53 #[pallet::weight(10_000)]54 pub fn set_test_value(origin: OriginFor<T>, value: u32) -> DispatchResult {55 ensure_signed(origin)?;5657 <TestValue<T>>::put(value);5859 Self::deposit_event(Event::ValueIsSet);6061 Ok(())62 }6364 #[pallet::weight(10_000)]65 pub fn set_test_value_and_rollback(origin: OriginFor<T>, value: u32) -> DispatchResult {66 Self::set_test_value(origin, value)?;6768 Self::deposit_event(Event::ShouldRollback);6970 Err(<Error<T>>::TriggerRollback.into())71 }72 }73}