I have one common pallet which is to be used by other pallets. For example, below is the common shared pallet:
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(test)]
mod tests;
pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
type Currency: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
}
type AccountIdOf<T> = <T as system::Trait>::AccountId;
type BalanceOf<T> = <<T as Trait>::Currency as Currency<AccountIdOf<T>>>::Balance;
type StructInfoOf<T> = StructInfo<AccountIdOf<T>, <T as system::Trait>::BlockNumber>;
#[derive(Encode, Decode, Default, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct StructInfo<AccountId, BlockNumber> {
name: Vec<u8>,
owner: AccountId,
created: BlockNumber,
}
decl_storage! {
trait Store for Module<T: Trait> as TokenStore {
pub Data get(fn data): map hasher(blake2_128_concat) u32 => Option<StructInfoOf<T>>;
pub DataCount get(fn data_count): u32;
}
}
decl_event!(
pub enum Event<T>
where
AccountId = <T as system::Trait>::AccountId,
Balance = BalanceOf<T>,
{
/// Test event
TestEvent(u32, Balance, AccountId),
}
);
decl_error! {
pub enum Error for Module<T: Trait> {
TestError
}
}
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
fn deposit_event() = default;
#[weight = 10_000]
pub fn test_dispatch_call(origin) -> DispatchResult {
let caller = ensure_signed(origin)?;
Ok(())
}
}
}
impl<T: Trait> Module<T> {
pub fn public_function(value: u32) -> BalanceOf<T> {
let value: u32 = 0;
Self::data_count()
}
}
but I am not sure how I can call Data, DataCount, test_dispatch_call, public_function from the common module.