Created
August 30, 2022 14:43
-
-
Save CyberHoward/73e5b8ca071829cf7784275cdec60053 to your computer and use it in GitHub Desktop.
Example of a deployment script used by Abstract.
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
/// One of the scripts that deploys my contracts | |
/// Just look at the readability compared to a bash script! | |
pub async fn script() -> anyhow::Result<()> { | |
let (config, sender) = &get_configuration().await?; | |
let (memory, os_factory, version_control, module_factory) = | |
get_native_contracts(config, sender)?; | |
let (manager, proxy) = get_core_contracts(config, sender, None)?; | |
let (liquidity_interface, subscription) = get_add_ons(config, sender)?; | |
let (dex_api, staking_api) = get_apis(config, sender)?; | |
let idea_token = Idea::new("abstract:idea", sender, config)?; | |
// ########### upload memory ############## | |
memory.upload("memory").await?; | |
// ########### upload native ############## | |
version_control.upload("version_control").await?; | |
os_factory.upload("os_factory").await?; | |
module_factory.upload("module_factory").await?; | |
// ########### upload core ############## | |
manager.upload("manager").await?; | |
proxy.upload("proxy").await?; | |
// ########### upload modules and token ############## | |
liquidity_interface.upload("liquidity_interface").await?; | |
subscription.upload("subscription").await?; | |
idea_token.upload("abstract_token").await?; | |
// ########### Instantiate ############## | |
memory | |
.init( | |
memory::InstantiateMsg {}, | |
Some(sender.pub_addr_str()?), | |
None, | |
) | |
.await?; | |
version_control | |
.init( | |
version_control::InstantiateMsg {}, | |
Some(sender.pub_addr_str()?), | |
None, | |
) | |
.await?; | |
module_factory | |
.init( | |
module_factory::InstantiateMsg { | |
version_control_address: version_control.instance().get_address()?, | |
memory_address: memory.instance().get_address()?, | |
}, | |
Some(sender.pub_addr_str()?), | |
None, | |
) | |
.await?; | |
os_factory | |
.init( | |
os_factory::InstantiateMsg { | |
version_control_address: version_control.instance().get_address()?, | |
memory_address: memory.instance().get_address()?, | |
module_factory_address: module_factory.instance().get_address()?, | |
}, | |
Some(sender.pub_addr_str()?), | |
None, | |
) | |
.await?; | |
// Set Factory | |
version_control | |
.exec( | |
&version_control::ExecuteMsg::SetFactory { | |
new_factory: os_factory.instance().get_address()?, | |
}, | |
None, | |
) | |
.await?; | |
// ########### upload api and instantiate ############## | |
dex_api.upload("dex").await?; | |
staking_api.upload("tendermint_staking").await?; | |
let api_init_msg = ApiInstantiateMsg { | |
memory_address: memory.instance().get_address()?, | |
version_control_address: version_control.instance().get_address()?, | |
}; | |
dex_api.init(api_init_msg.clone(), None, None).await?; | |
staking_api.init(api_init_msg.clone(), None, None).await?; | |
// Updates code-ids and apis on version control | |
version_control.check_code_ids().await?; | |
version_control.check_apis().await?; | |
// Update memory addresses | |
memory.update_all().await?; | |
let governance_details = GovernanceDetails::Monarchy { | |
monarch: sender.pub_addr_str()?, | |
}; | |
// Create the first os | |
os_factory | |
.create_default_os(governance_details.clone()) | |
.await?; | |
idea_token | |
.create_new( | |
proxy.instance().get_address()?, | |
1000000000u128, | |
version_control.instance().get_address()?, | |
"IDEA", | |
) | |
.await?; | |
manager | |
.add_module( | |
&subscription.instance(), | |
Some(&Subscription::init_msg( | |
manager.instance().deployment.network.gas_denom.to_string(), | |
idea_token.instance().get_address()?, | |
memory.instance().get_address()?, | |
os_factory.instance().get_address()?, | |
version_control.instance().get_address()?, | |
)), | |
objects::module::ModuleKind::AddOn, | |
) | |
.await?; | |
os_factory | |
.set_subscription_contract(subscription.instance().get_address()?) | |
.await?; | |
os_factory.create_default_os(governance_details).await?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment