use sov_modules_api::{CallResponse, Context, Error, Module, ModuleInfo, StateValue, WorkingSet}; pub mod first_test_module { use super::*; #[derive(ModuleInfo)] pub struct FirstTestStruct { #[address] pub address: C::Address, #[state] pub state_in_first_struct: StateValue, } impl FirstTestStruct { pub fn get_state_value(&self, working_set: &mut WorkingSet) -> u8 { self.state_in_first_struct.get(working_set).unwrap() } } impl Module for FirstTestStruct { type Context = C; type Config = (); type CallMessage = u8; fn genesis( &self, _config: &Self::Config, working_set: &mut WorkingSet, ) -> Result<(), Error> { self.state_in_first_struct.set(&1, working_set); Ok(()) } fn call( &self, msg: Self::CallMessage, _context: &Self::Context, working_set: &mut WorkingSet, ) -> Result { self.state_in_first_struct.set(&msg, working_set); Ok(CallResponse::default()) } } } pub mod second_test_module { use super::*; #[derive(ModuleInfo)] pub struct SecondTestStruct { #[address] pub address: C::Address, #[state] pub state_in_second_struct: StateValue, } impl SecondTestStruct { pub fn get_state_value(&self, working_set: &mut WorkingSet) -> u8 { self.state_in_second_struct.get(working_set).unwrap() } } impl Module for SecondTestStruct { type Context = Ctx; type Config = (); type CallMessage = u8; fn genesis( &self, _config: &Self::Config, working_set: &mut WorkingSet, ) -> Result<(), Error> { self.state_in_second_struct.set(&2, working_set); Ok(()) } fn call( &self, msg: Self::CallMessage, _context: &Self::Context, working_set: &mut WorkingSet, ) -> Result { self.state_in_second_struct.set(&msg, working_set); Ok(CallResponse::default()) } } } pub mod third_test_module { use super::*; pub trait ModuleThreeStorable: borsh::BorshSerialize + borsh::BorshDeserialize + core::fmt::Debug + Default { } impl ModuleThreeStorable for u32 {} #[derive(ModuleInfo)] pub struct ThirdTestStruct { #[address] pub address: Ctx::Address, #[state] pub state_in_third_struct: StateValue, } impl ThirdTestStruct { pub fn get_state_value( &self, working_set: &mut WorkingSet, ) -> Option { self.state_in_third_struct.get(working_set) } } impl Module for ThirdTestStruct { type Context = Ctx; type Config = (); type CallMessage = OtherGeneric; fn genesis( &self, _config: &Self::Config, working_set: &mut WorkingSet, ) -> Result<(), Error> { self.state_in_third_struct .set(&Default::default(), working_set); Ok(()) } fn call( &self, msg: Self::CallMessage, _context: &Self::Context, working_set: &mut WorkingSet, ) -> Result { self.state_in_third_struct.set(&msg, working_set); Ok(CallResponse::default()) } } }