Skip to content

Commit

Permalink
add external contract cw-orch suites
Browse files Browse the repository at this point in the history
  • Loading branch information
hard-nett authored and Jake Hartnell committed Aug 14, 2024
1 parent 2478f28 commit 9cea2d1
Show file tree
Hide file tree
Showing 16 changed files with 2,727 additions and 145 deletions.
2,257 changes: 2,112 additions & 145 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 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
34 changes: 34 additions & 0 deletions scripts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[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 = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }

# 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 = { git = "https://github.com/Kayanski/dao-contracts", branch = "development", features = [
"library",
] }
dao-proposal-single = { git = "https://github.com/Kayanski/dao-contracts", branch = "development", features = [
"library",
] }

dao-interface = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
dao-voting = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
cw-payroll-factory = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
cw-token-swap = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
cw-admin-factory = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
cw-tokenfactory-issuer = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
cw-vesting = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
cw721-roles = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
dao-migrator = { git = "https://github.com/hard-nett/dao-contracts", branch = "feat/external-cw-orch" }
163 changes: 163 additions & 0 deletions scripts/src/dao.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
use cw_orch::prelude::*;
use dao_cw_orch::{
DaoDaoCore, DaoExternalAdminFactory, DaoExternalCw721Roles, DaoExternalCwVesting,
DaoExternalMigrator, DaoExternalPayrollFactory, DaoExternalTokenSwap,
DaoExternalTokenfactoryIssuer, 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(())
}
}

// 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(())
}
}

// 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(())
}
}
Loading

0 comments on commit 9cea2d1

Please sign in to comment.