use crate::{
events::EventsDecoder,
metadata::{
Metadata,
MetadataError,
},
};
use codec::{
Decode,
Encode,
};
use sp_core::storage::StorageKey;
pub mod balances;
pub mod contracts;
pub mod sudo;
pub mod system;
pub trait Store<T>: Encode {
const MODULE: &'static str;
const FIELD: &'static str;
type Returns: Decode;
fn prefix(metadata: &Metadata) -> Result<StorageKey, MetadataError>;
fn key(&self, metadata: &Metadata) -> Result<StorageKey, MetadataError>;
fn default(&self, metadata: &Metadata) -> Result<Self::Returns, MetadataError> {
Ok(metadata
.module(Self::MODULE)?
.storage(Self::FIELD)?
.default()?)
}
}
pub trait Call<T>: Encode {
const MODULE: &'static str;
const FUNCTION: &'static str;
fn events_decoder(_decoder: &mut EventsDecoder<T>) {}
}
pub trait Event<T>: Decode {
const MODULE: &'static str;
const EVENT: &'static str;
}