mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-26 04:11:09 +00:00
Revise storage API.
This commit is contained in:
@@ -37,15 +37,14 @@ pub enum Function {
|
||||
impl Function {
|
||||
/// Derive `Some` value from a `u8`, or `None` if it's invalid.
|
||||
pub fn from_u8(value: u8) -> Option<Function> {
|
||||
match value {
|
||||
x if x == Function::StakingStake as u8 => Some(Function::StakingStake),
|
||||
x if x == Function::StakingUnstake as u8 => Some(Function::StakingUnstake),
|
||||
x if x == Function::StakingTransfer as u8 => Some(Function::StakingTransfer),
|
||||
x if x == Function::SessionSetKey as u8 => Some(Function::SessionSetKey),
|
||||
x if x == Function::TimestampSet as u8 => Some(Function::TimestampSet),
|
||||
x if x == Function::GovernancePropose as u8 => Some(Function::GovernancePropose),
|
||||
x if x == Function::GovernanceApprove as u8 => Some(Function::GovernanceApprove),
|
||||
_ => None,
|
||||
use self::*;
|
||||
let functions = [Function::StakingStake, Function::StakingUnstake,
|
||||
Function::StakingTransfer, Function::SessionSetKey, Function::TimestampSet,
|
||||
Function::GovernancePropose, Function::GovernanceApprove];
|
||||
if (value as usize) < functions.len() {
|
||||
Some(functions[value as usize])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,14 +38,19 @@ pub enum InternalFunction {
|
||||
impl InternalFunction {
|
||||
/// Derive `Some` value from a `u8`, or `None` if it's invalid.
|
||||
pub fn from_u8(value: u8) -> Option<InternalFunction> {
|
||||
match value {
|
||||
x if x == InternalFunction::SystemSetCode as u8 => Some(InternalFunction::SystemSetCode),
|
||||
x if x == InternalFunction::StakingSetSessionsPerEra as u8 => Some(InternalFunction::StakingSetSessionsPerEra),
|
||||
x if x == InternalFunction::StakingSetBondingDuration as u8 => Some(InternalFunction::StakingSetBondingDuration),
|
||||
x if x == InternalFunction::StakingSetValidatorCount as u8 => Some(InternalFunction::StakingSetValidatorCount),
|
||||
x if x == InternalFunction::GovernanceSetApprovalPpmRequired as u8 => Some(InternalFunction::GovernanceSetApprovalPpmRequired),
|
||||
x if x == InternalFunction::SessionSetLength as u8 => Some(InternalFunction::SessionSetLength),
|
||||
_ => None,
|
||||
use self::*;
|
||||
let functions = [
|
||||
InternalFunction::SystemSetCode,
|
||||
InternalFunction::StakingSetSessionsPerEra,
|
||||
InternalFunction::StakingSetBondingDuration,
|
||||
InternalFunction::StakingSetValidatorCount,
|
||||
InternalFunction::GovernanceSetApprovalPpmRequired,
|
||||
InternalFunction::SessionSetLength
|
||||
];
|
||||
if (value as usize) < functions.len() {
|
||||
Some(functions[value as usize])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user