-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy_app.rs
72 lines (53 loc) · 2.06 KB
/
deploy_app.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::env;
use abstract_boot::version_control::VersionControl;
use abstract_os::app;
use abstract_os::app::BaseQueryMsg;
use boot_core::networks;
use boot_core::prelude::{instantiate_daemon_env, ContractInstance};
use cosmwasm_std::Addr;
use semver::Version;
use interfaces::template::TemplateApp;
use template_app::contract::{MODULE_NAME, MODULE_NAMESPACE};
// use template_app::msg::ConfigResponse;
// To deploy the app we need to get the memory and then register it
// We can then deploy a test OS that uses that new app
const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn deploy_app() -> anyhow::Result<()> {
let network = networks::UNI_5;
// Setup the environment
let (_, _sender, chain) = instantiate_daemon_env(network)?;
// Load Abstract Version Control
let version_control_address: String =
env::var("VERSION_CONTROL_ADDRESS").expect("VERSION_CONTROL_ADDRESS must be set");
let version_control = VersionControl::load(
&chain,
&Addr::unchecked(version_control_address),
);
// Upload and register your module
let app_name = format!("{}:{}", MODULE_NAMESPACE, MODULE_NAME);
let mut app = TemplateApp::new(&app_name, &chain);
let app_version = Version::parse(APP_VERSION)?;
version_control.upload_and_register_module(&mut app.as_instance_mut(), &app_version)?;
// Example queries
// app.query_base(BaseQueryMsg::Admin {})?;
// let app_config: ConfigResponse = app.query_app(TemplateQueryMsg::Config {})?;
// TODO: Attach to an OS
Ok(())
}
fn main() {
dotenv().ok();
env_logger::init();
use dotenv::dotenv;
if let Err(ref err) = deploy_app() {
log::error!("{}", err);
err.chain()
.skip(1)
.for_each(|cause| log::error!("because: {}", cause));
// The backtrace is not always generated. Try to run this example
// with `$env:RUST_BACKTRACE=1`.
// if let Some(backtrace) = e.backtrace() {
// log::debug!("backtrace: {:?}", backtrace);
// }
::std::process::exit(1);
}
}