Skip to content

Commit

Permalink
add btsg-ft-factory to cw-orch setup
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 e836dd1 commit 65091bd
Show file tree
Hide file tree
Showing 19 changed files with 252 additions and 153 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 cw_payroll_factory::contract::{execute, instantiate, query, reply};
use cw_payroll_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;
132 changes: 0 additions & 132 deletions scripts/src/dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,135 +29,3 @@ impl<Chain: CwEnv> DaoDao<Chain> {
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(())
}
}
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> DaoExternalFantokenFactory<Chain> {
pub fn new(chain: Chain) -> DaoExternalFantokenFactory<Chain> {
DaoExternalFantokenFactory::<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(())
}
}
6 changes: 3 additions & 3 deletions scripts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
fn main() {}

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

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

0 comments on commit 65091bd

Please sign in to comment.