Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

external cw-orch suites #4

Merged
1,124 changes: 1,077 additions & 47 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"contracts/voting/*",
"packages/*",
"ci/*",
"scripts"
]
resolver = "2"

Expand Down Expand Up @@ -87,13 +88,15 @@ tokio = "=1.38.1"
# optional owner.
cw-ownable = "0.5"

btsg-ft-factory = { path = "./contracts/external/btsg-ft-factory", version = "2.5.0" }
cw-admin-factory = { path = "./contracts/external/cw-admin-factory", version = "2.5.0" }
cw-denom = { path = "./packages/cw-denom", version = "2.5.0" }
cw-fund-distributor = { path = "./contracts/distribution/cw-fund-distributor", version = "2.5.0" }
cw-hooks = { path = "./packages/cw-hooks", version = "2.5.0" }
cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.5.0" }
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.5.0" }
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.5.0" }
cw-token-swap = { path = "./contracts/external/cw-token-swap", version = "2.5.0" }
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.5.0", default-features = false }
cw-tokenfactory-types = { path = "./packages/cw-tokenfactory-types", version = "2.5.0", default-features = false }
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.5.0" }
Expand All @@ -106,6 +109,7 @@ dao-dao-core = { path = "./contracts/dao-dao-core", version = "2.5.0" }
dao-dao-macros = { path = "./packages/dao-dao-macros", version = "2.5.0" }
dao-hooks = { path = "./packages/dao-hooks", version = "2.5.0" }
dao-interface = { path = "./packages/dao-interface", version = "2.5.0" }
dao-migrator = { path = "./contracts/external/dao-migrator", version = "2.5.0" }
dao-pre-propose-approval-single = { path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.5.0" }
dao-pre-propose-approver = { path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.5.0" }
dao-pre-propose-base = { path = "./packages/dao-pre-propose-base", version = "2.5.0" }
Expand Down
3 changes: 2 additions & 1 deletion contracts/external/btsg-ft-factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ library = []
[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
cw-orch = { workspace = true }
cw-storage-plus = { workspace = true }
dao-interface = { workspace = true }
osmosis-std-derive = { workspace = true }
prost = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion contracts/external/btsg-ft-factory/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use dao_interface::token::InitialBalance;
pub struct InstantiateMsg {}

#[cw_serde]
#[derive(cw_orch::ExecuteFns)]
pub enum ExecuteMsg {
/// Issues a new fantoken.
Issue(NewFanToken),
Expand Down Expand Up @@ -36,7 +37,7 @@ pub struct NewFanToken {
}

#[cw_serde]
#[derive(QueryResponses)]
#[derive(QueryResponses, cw_orch::QueryFns)]
pub enum QueryMsg {}

#[cw_serde]
Expand Down
1 change: 1 addition & 0 deletions packages/cw-orch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ default = []
wasm_test = []

[dependencies]
btsg-ft-factory = { path = "../../contracts/external/btsg-ft-factory" }
cosmwasm-std.workspace = true
cw-orch.workspace = true
cw20-stake.workspace = true
Expand Down
20 changes: 20 additions & 0 deletions packages/cw-orch/src/external/btsg_ft_factory.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use cw_orch::{interface, prelude::*};

use btsg_ft_factory::contract::{execute, instantiate, query, reply};
use btsg_ft_factory::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

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

impl<Chain> Uploadable for DaoExternalFantokenFactory<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("btsg_ft_factory")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
fn wrapper() -> Box<dyn MockContract<Empty>> {
Box::new(ContractWrapper::new_with_empty(execute, instantiate, query).with_reply(reply))
}
}
2 changes: 2 additions & 0 deletions packages/cw-orch/src/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod migrator;
mod payroll_factory;
mod token_swap;
mod tokenfactory_issuer;
mod btsg_ft_factory;

pub use admin_factory::DaoExternalAdminFactory;
pub use cw721_roles::DaoExternalCw721Roles;
Expand All @@ -13,3 +14,4 @@ pub use migrator::DaoExternalMigrator;
pub use payroll_factory::DaoExternalPayrollFactory;
pub use token_swap::DaoExternalTokenSwap;
pub use tokenfactory_issuer::DaoExternalTokenfactoryIssuer;
pub use btsg_ft_factory::DaoExternalFantokenFactory;
29 changes: 29 additions & 0 deletions scripts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "scripts"
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[dependencies]
cw-orch = { workspace = true, features = ["daemon"] }
dao-cw-orch = { path = "../packages/cw-orch", version = "2.5.0" }
# scripts specific
dotenv = { version = "0.15.0" }
pretty_env_logger = { version = "0.5.0" }

# cw-orch enabled DAO DAO deps
[dev-dependencies]
dao-interface-master = { package = "dao-interface", git = "https://github.com/DA0-DA0/dao-contracts", branch = "main" }
dao-proposal-sudo = { workspace = true, features = ["library"] }
dao-proposal-single = { workspace = true, features = ["library"] }
dao-interface = { workspace = true }
dao-voting = { workspace = true }
cw-payroll-factory = { workspace = true }
cw-token-swap = { workspace = true }
cw-admin-factory = { workspace = true }
cw-tokenfactory-issuer = { workspace = true }
cw-vesting = { workspace = true }
cw721-roles = { workspace = true }
dao-migrator = { workspace = true }
btsg-ft-factory = { workspace = true }
27 changes: 27 additions & 0 deletions scripts/src/dao.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use cw_orch::prelude::*;
use dao_cw_orch::{DaoDaoCore, DaoProposalSingle, DaoProposalSudo};

// minimal dao
pub struct DaoDao<Chain> {
pub dao_core: DaoDaoCore<Chain>,
pub dao_proposal_single: DaoProposalSingle<Chain>,
pub dao_proposal_sudo: DaoProposalSudo<Chain>,
}

impl<Chain: CwEnv> DaoDao<Chain> {
pub fn new(chain: Chain) -> DaoDao<Chain> {
DaoDao::<Chain> {
dao_core: DaoDaoCore::new("dao_dao_core", chain.clone()),
dao_proposal_single: DaoProposalSingle::new("dao_proposal_single", chain.clone()),
dao_proposal_sudo: DaoProposalSudo::new("dao_proposal_sudo", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.dao_core.upload()?;
self.dao_proposal_single.upload()?;
self.dao_proposal_sudo.upload()?;

Ok(())
}
}
152 changes: 152 additions & 0 deletions scripts/src/external.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
use cw_orch::prelude::*;
use dao_cw_orch::*;

// admin factory
pub struct AdminFactorySuite<Chain> {
pub factory: DaoExternalAdminFactory<Chain>,
}
impl<Chain: CwEnv> AdminFactorySuite<Chain> {
pub fn new(chain: Chain) -> AdminFactorySuite<Chain> {
AdminFactorySuite::<Chain> {
factory: DaoExternalAdminFactory::new("cw_admin_factory", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.factory.upload()?;

Ok(())
}
}

// bitsong fantoken factory
pub struct FantokenFactorySuite<Chain> {
pub factory: DaoExternalFantokenFactory<Chain>,
}

impl<Chain: CwEnv> FantokenFactorySuite<Chain> {
pub fn new(chain: Chain) -> FantokenFactorySuite<Chain> {
FantokenFactorySuite::<Chain> {
factory: DaoExternalFantokenFactory::new("btsg_ft_factory", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.factory.upload()?;

Ok(())
}
}

// payroll factory
pub struct PayrollSuite<Chain> {
pub payroll: DaoExternalPayrollFactory<Chain>,
pub vesting: DaoExternalCwVesting<Chain>,
}
impl<Chain: CwEnv> PayrollSuite<Chain> {
pub fn new(chain: Chain) -> PayrollSuite<Chain> {
PayrollSuite::<Chain> {
payroll: DaoExternalPayrollFactory::new("cw_payroll", chain.clone()),
vesting: DaoExternalCwVesting::new("cw_vesting", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.payroll.upload()?;
self.vesting.upload()?;
Ok(())
}
}

// cw tokenswap
pub struct TokenSwapSuite<Chain> {
pub tokenswap: DaoExternalTokenSwap<Chain>,
}
impl<Chain: CwEnv> TokenSwapSuite<Chain> {
pub fn new(chain: Chain) -> TokenSwapSuite<Chain> {
TokenSwapSuite::<Chain> {
tokenswap: DaoExternalTokenSwap::new("cw_tokenswap", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.tokenswap.upload()?;

Ok(())
}
}

// cw-tokenfactory issuer
pub struct TokenFactorySuite<Chain> {
pub tokenfactory: DaoExternalTokenfactoryIssuer<Chain>,
}
impl<Chain: CwEnv> TokenFactorySuite<Chain> {
pub fn new(chain: Chain) -> TokenFactorySuite<Chain> {
TokenFactorySuite::<Chain> {
tokenfactory: DaoExternalTokenfactoryIssuer::new("cw_tokenfactory", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.tokenfactory.upload()?;

Ok(())
}
}

// cw-vesting
pub struct VestingSuite<Chain> {
pub vesting: DaoExternalCwVesting<Chain>,
}

impl<Chain: CwEnv> VestingSuite<Chain> {
pub fn new(chain: Chain) -> VestingSuite<Chain> {
VestingSuite::<Chain> {
vesting: DaoExternalCwVesting::new("dao_dao_core", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.vesting.upload()?;

Ok(())
}
}

// cw721 roles
pub struct Cw721RolesSuite<Chain> {
pub roles: DaoExternalCw721Roles<Chain>,
}

impl<Chain: CwEnv> Cw721RolesSuite<Chain> {
pub fn new(chain: Chain) -> Cw721RolesSuite<Chain> {
Cw721RolesSuite::<Chain> {
roles: DaoExternalCw721Roles::new("cw721_roles", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.roles.upload()?;

Ok(())
}
}

// migrator
pub struct DaoMigrationSuite<Chain> {
pub migrator: DaoExternalMigrator<Chain>,
}

impl<Chain: CwEnv> DaoMigrationSuite<Chain> {
pub fn new(chain: Chain) -> DaoMigrationSuite<Chain> {
DaoMigrationSuite::<Chain> {
migrator: DaoExternalMigrator::new("dao_migrator", chain.clone()),
}
}

pub fn upload(&self) -> Result<(), CwOrchError> {
self.migrator.upload()?;

Ok(())
}
}
10 changes: 10 additions & 0 deletions scripts/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[allow(clippy::collapsible_if)]
fn main() {}

mod dao;
mod external;
pub use dao::*;
pub use external::*;

#[cfg(test)]
mod tests;
Loading
Loading