use super::{DappContractBase, DappRegistryContractRef};
use crate::access::Ownable;
use odra::prelude::*;
use odra::ContractRef;
#[odra::module]
pub struct MockDappContract {
ownable: SubModule<Ownable>,
dapp: SubModule<DappContractBase>
}
#[odra::module]
impl MockDappContract {
pub fn init(&mut self, registry: Address) {
let owner = self.env().caller();
self.ownable.init(owner);
self.dapp.set_dapp_registry(®istry);
}
pub fn set_dapp_registry(&mut self, registry: &Address) {
self.ownable.assert_owner(&self.env().caller());
self.dapp.set_dapp_registry(registry);
}
delegate! {
to self.dapp {
fn get_dapp_registry(&self) -> Address;
}
to self.ownable {
fn get_owner(&self) -> Address;
}
}
pub fn register(&mut self, dapp_contract: &Address) {
self.dapp.register(*dapp_contract);
}
pub fn register_address(&self) -> Address {
self.dapp.register_address()
}
pub fn register_in_dapp(
&mut self,
registry: &Address,
dapp_contract: &Address,
is_registrar: bool
) {
DappRegistryContractRef::new(self.env(), *registry)
.add_dapp_contract(dapp_contract, is_registrar);
}
}