mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 02:21:04 +00:00
Migrate generic-asset, identity and im-online to decl_error (#4473)
* Migrate generic-asset, identity and im-online to decl_error * Update democracy tests * Update nicks test
This commit is contained in:
committed by
Shawn Tabrizi
parent
f6cbf4421f
commit
2c2e0d772d
@@ -89,7 +89,7 @@ use sp_staking::{
|
||||
offence::{ReportOffence, Offence, Kind},
|
||||
};
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, print, Parameter, debug,
|
||||
decl_module, decl_event, decl_storage, print, Parameter, debug, decl_error,
|
||||
traits::Get,
|
||||
};
|
||||
use frame_system::{self as system, ensure_none};
|
||||
@@ -243,9 +243,20 @@ decl_storage! {
|
||||
}
|
||||
}
|
||||
|
||||
decl_error! {
|
||||
/// Error for the im-online module.
|
||||
pub enum Error for Module<T: Trait> {
|
||||
/// Non existent public key.
|
||||
InvalidKey,
|
||||
/// Duplicated heartbeat.
|
||||
DuplicatedHeartbeat,
|
||||
}
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
type Error = Error<T>;
|
||||
|
||||
fn deposit_event() = default;
|
||||
|
||||
fn heartbeat(
|
||||
@@ -274,9 +285,9 @@ decl_module! {
|
||||
&network_state
|
||||
);
|
||||
} else if exists {
|
||||
Err("Duplicated heartbeat.")?
|
||||
Err(Error::<T>::DuplicatedHeartbeat)?
|
||||
} else {
|
||||
Err("Non existent public key.")?
|
||||
Err(Error::<T>::InvalidKey)?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user