Skip to content

Commit

Permalink
deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
vladjdk committed Nov 16, 2023
1 parent 5e7224c commit bc08dfe
Show file tree
Hide file tree
Showing 10 changed files with 3,030 additions and 311 deletions.
3,162 changes: 2,860 additions & 302 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/warp-funding-account/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "warp-account"
name = "warp-funding-account"
version = "0.1.0"
authors = ["Terra Money <core@terra.money>"]
edition = "2021"
Expand Down
7 changes: 6 additions & 1 deletion packages/interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
interface = ["dep:cw-orch"]

[dependencies]
cw-orch = "0.18.1"
cw-orch = {version = "0.18.1", optional = true }

warp-controller = { path = "../../contracts/warp-controller", default-features = false, version = "*", features = ["interface"]}
warp-funding-account = { path = "../../contracts/warp-funding-account", default-features = false, version = "*", features = ["interface"]}
warp-job-account = { path = "../../contracts/warp-job-account", default-features = false, version = "*", features = ["interface"] }
warp-job-account-tracker = { path = "../../contracts/warp-job-account-tracker", default-features = false, version = "*", features = ["interface"] }
warp-legacy-account = { path = "../../contracts/warp-legacy-account", default-features = false, version = "*", features = ["interface"] }
warp-resolver = { path = "../../contracts/warp-resolver", default-features = false, version = "*", features = ["interface"] }
warp-templates = { path = "../../contracts/warp-templates", default-features = false, version = "*", features = ["interface"] }

controller = { path = "../controller", default-features = false, version = "*", features = ["interface"] }
funding-account = { path = "../funding-account", default-features = false, version = "*", features = ["interface"] }
job-account = { path = "../job-account", default-features = false, version = "*", features = ["interface"] }
job-account-tracker = { path = "../job-account-tracker", default-features = false, version = "*", features = ["interface"] }
legacy-account = { path = "../legacy-account", default-features = false, version = "*", features = ["interface"] }
Expand Down
15 changes: 9 additions & 6 deletions packages/interface/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#[cfg(feature = "interface")]
mod warp_controller;
pub mod warp_controller;
#[cfg(feature = "interface")]
mod warp_job_account;
pub mod warp_job_account;
#[cfg(feature = "interface")]
mod warp_job_account_tracker;
pub mod warp_job_account_tracker;
#[cfg(feature = "interface")]
mod warp_legacy_account;
pub mod warp_legacy_account;
#[cfg(feature = "interface")]
mod warp_resolver;
pub mod warp_resolver;
#[cfg(feature = "interface")]
mod warp_templates;
pub mod warp_templates;
#[cfg(feature = "interface")]

pub mod warp_funding_account;

pub fn add(left: usize, right: usize) -> usize {
left + right
Expand Down
28 changes: 28 additions & 0 deletions packages/interface/src/warp_funding_account.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use cw_orch::{interface, prelude::*};

use warp_funding_account::contract;
pub use funding_account::{ExecuteMsg, InstantiateMsg, QueryMsg};


#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty)]
pub struct WarpFundingAccount;

impl<Chain: CwEnv> Uploadable for WarpFundingAccount<Chain> {
// Return the path to the wasm file
fn wasm(&self) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("warp_funding_account.wasm")
.unwrap()
}
// Return a CosmWasm contract wrapper
fn wrapper(&self) -> Box<dyn MockContract<Empty>> {
Box::new(
ContractWrapper::new_with_empty(
contract::execute,
contract::instantiate,
contract::query,
)
.with_migrate(contract::migrate),
)
}
}
23 changes: 23 additions & 0 deletions scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,27 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[dependencies]
dotenv = { version = "0.15.0" } # Enables loading of .env files
pretty_env_logger = { version = "0.5.0" } # Enables logging to stdout and prettifies it
cw-orch = {version = "0.18.1", features = ["daemon"] }
tokio = { version = "1.4", features = ["full"] }

cosmwasm-std = "1.1"

interface = { path = "../packages/interface", default-features = false, version = "*", features = ["interface"]}

warp-controller = { path = "../contracts/warp-controller", default-features = false, version = "*", features = ["interface"]}
warp-job-account = { path = "../contracts/warp-job-account", default-features = false, version = "*", features = ["interface"] }
warp-job-account-tracker = { path = "../contracts/warp-job-account-tracker", default-features = false, version = "*", features = ["interface"] }
warp-legacy-account = { path = "../contracts/warp-legacy-account", default-features = false, version = "*", features = ["interface"] }
warp-resolver = { path = "../contracts/warp-resolver", default-features = false, version = "*", features = ["interface"] }
warp-templates = { path = "../contracts/warp-templates", default-features = false, version = "*", features = ["interface"] }

controller = { path = "../packages/controller", default-features = false, version = "*", features = ["interface"] }
job-account = { path = "../packages/job-account", default-features = false, version = "*", features = ["interface"] }
job-account-tracker = { path = "../packages/job-account-tracker", default-features = false, version = "*", features = ["interface"] }
legacy-account = { path = "../packages/legacy-account", default-features = false, version = "*", features = ["interface"] }
resolver = { path = "../packages/resolver", default-features = false, version = "*", features = ["interface"] }
templates = { path = "../packages/templates", default-features = false, version = "*", features = ["interface"] }
87 changes: 87 additions & 0 deletions scripts/src/deploy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
use std::io::Error;
use cosmwasm_std::Uint64;
use cw_orch::anyhow;
use cw_orch::prelude::*;
use tokio::runtime::Runtime;
use controller::InstantiateMsg;
use interface::warp_controller::WarpController;
use interface::warp_funding_account::WarpFundingAccount;
use interface::warp_job_account::WarpJobAccount;
use interface::warp_job_account_tracker::WarpJobAccountTracker;
use interface::warp_legacy_account::WarpLegacyAccount;
use interface::warp_resolver::WarpResolver;
use interface::warp_templates::WarpTemplates;
// We start by creating a runtime, which is required for a sync daemon.

pub fn deploy() -> anyhow::Result<()>{
dotenv::dotenv().ok(); // Used to load the `.env` file if any
pretty_env_logger::init(); // Used to log contract and chain interactions

let rt = Runtime::new()?;
let network = networks::PHOENIX_1;
let chain = DaemonBuilder::default()
.handle(rt.handle())
.chain(network)
.build()?;

let funding_account = WarpFundingAccount::new("warp_funding_account", chain.clone());
funding_account.upload()?;

let job_account = WarpJobAccount::new("warp_job_account", chain.clone());
job_account.upload()?;

let job_account_tracker = WarpJobAccountTracker::new("warp_job_account_tracker", chain.clone());
job_account_tracker.upload()?;
job_account_tracker.instantiate(&job_account_tracker::InstantiateMsg {
admin: chain.wallet().address()?.to_string(),
warp_addr: "".to_string(),
}, Some(&Addr::unchecked(chain.wallet().address()?.to_string())), None)?;

let legacy_account = WarpLegacyAccount::new("warp_legacy_account", chain.clone())

Check failure on line 40 in scripts/src/deploy.rs

View workflow job for this annotation

GitHub Actions / Lint

expected `;`, found `legacy_account`
legacy_account.upload()?;

let resolver = WarpResolver::new("warp_resolver", chain.clone());
resolver.upload()?;
resolver.instantiate(&resolver::InstantiateMsg {}, None, None)?;

let templates = WarpTemplates::new("warp_templates", chain.clone());
templates.upload()?;
templates.instantiate(&templates::InstantiateMsg {
owner: chain.wallet().address()?.to_string(),
fee_denom: "uluna".to_string(),
fee_collector: chain.wallet().address()?.to_string(),
templates: vec![],
}, Some(&Addr::unchecked(chain.wallet().address()?.to_string())), None)?;

let controller = WarpController::new("warp_controller", chain);

controller.upload()?;
controller.instantiate(&controller::InstantiateMsg {
owner: Some(chain.wallet().address()?.to_string()),
fee_denom: "".to_string(),
fee_collector: Some(chain.wallet().address()?.to_string()),
warp_account_code_id: Uint64::from(templates.code_id()?),
minimum_reward: Default::default(),
creation_fee: Default::default(),
cancellation_fee: Default::default(),
resolver_address: resolver.address()?.to_string(),
job_account_tracker_address: job_account_tracker.address()?.to_string(),
t_max: Default::default(),
t_min: Default::default(),
a_max: Default::default(),
a_min: Default::default(),
q_max: Default::default(),
creation_fee_min: Default::default(),
creation_fee_max: Default::default(),
burn_fee_min: Default::default(),
maintenance_fee_min: Default::default(),
maintenance_fee_max: Default::default(),
duration_days_left: Default::default(),
duration_days_right: Default::default(),
queue_size_left: Default::default(),
queue_size_right: Default::default(),
burn_fee_rate: Default::default(),
}, Some(&Addr::unchecked(chain.wallet().address()?.to_string())), None)?;

Ok(())
}
4 changes: 3 additions & 1 deletion scripts/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod deploy;
mod migrate;

fn main() {
println!("Hello, world!");
let _ = deploy::deploy();
// let _ = migrate::migrate();
}
5 changes: 5 additions & 0 deletions scripts/src/migrate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use cw_orch::anyhow;

pub fn migrate() -> anyhow::Result<()>{
Ok(())
}
8 changes: 8 additions & 0 deletions ~/.cw-orchestrator/my_state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"terra2": {
"phoenix-1": {
"code_ids": {},
"default": {}
}
}
}

0 comments on commit bc08dfe

Please sign in to comment.