Created
November 28, 2022 18:27
-
-
Save CyberHoward/4d5cfb10af276fff78ca1648a603bd51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct Deployment<'a, Chain: BootEnvironment> { | |
pub chain: &'a Chain, | |
pub version: Version, | |
pub ans_host: AnsHost<Chain>, | |
pub version_control: VersionControl<Chain>, | |
pub os_factory: OSFactory<Chain>, | |
pub module_factory: ModuleFactory<Chain>, | |
pub ibc_client: IbcClient<Chain>, | |
} | |
impl<'a, Chain: BootEnvironment> Deployment<'a, Chain> { | |
pub fn new(chain: &'a Chain, version: Version) -> Self { | |
let (ans_host, os_factory, version_control, module_factory, ibc_client) = | |
get_native_contracts(chain); | |
Self { | |
chain, | |
ans_host, | |
version_control, | |
ibc_client, | |
os_factory, | |
module_factory, | |
version, | |
} | |
} | |
pub fn deploy(&mut self) -> Result<(), BootError> { | |
let sender = &self.chain.sender(); | |
// ########### Upload ############## | |
self.ans_host.upload()?; | |
self.version_control.upload()?; | |
self.os_factory.upload()?; | |
self.module_factory.upload()?; | |
let mut os_core = OS::new(self.chain, None); | |
os_core.upload()?; | |
// ########### Instantiate ############## | |
self.ans_host.instantiate( | |
&abstract_os::ans_host::InstantiateMsg {}, | |
Some(sender), | |
None, | |
)?; | |
self.version_control.instantiate( | |
&abstract_os::version_control::InstantiateMsg {}, | |
Some(sender), | |
None, | |
)?; | |
self.module_factory.instantiate( | |
&abstract_os::module_factory::InstantiateMsg { | |
version_control_address: self.version_control.address()?.into_string(), | |
ans_host_address: self.ans_host.address()?.into_string(), | |
}, | |
Some(sender), | |
None, | |
)?; | |
self.os_factory.instantiate( | |
&abstract_os::os_factory::InstantiateMsg { | |
version_control_address: self.version_control.address()?.into_string(), | |
ans_host_address: self.ans_host.address()?.into_string(), | |
module_factory_address: self.module_factory.address()?.into_string(), | |
}, | |
Some(sender), | |
None, | |
)?; | |
// Set Factory | |
self.version_control.execute( | |
&abstract_os::version_control::ExecuteMsg::SetFactory { | |
new_factory: self.os_factory.address()?.into_string(), | |
}, | |
None, | |
)?; | |
// ########### upload modules and token ############## | |
self.version_control | |
.register_core(&os_core, &self.version.to_string())?; | |
self.version_control.register_native(self)?; | |
Ok(()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment