Skip to content

Commit

Permalink
Add more payable flags + distribution contracts to external
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed Jul 23, 2024
1 parent 6c3bfc1 commit cf63b3f
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 41 deletions.
6 changes: 5 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions contracts/distribution/cw-fund-distributor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dao-voting-cw20-staked = { workspace = true }
cw20-stake = { workspace = true, features = ["library"] }
dao-interface = { workspace = true }
cw-paginate-storage = { workspace = true }
cw-orch.workspace = true

[dev-dependencies]
dao-dao-core = { workspace = true, features = ["library"] }
Expand Down
10 changes: 8 additions & 2 deletions contracts/distribution/cw-fund-distributor/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ pub struct InstantiateMsg {
}

#[cw_serde]
#[derive(cw_orch::ExecuteFns)]
pub enum ExecuteMsg {
Receive(cw20::Cw20ReceiveMsg),
#[cw_orch(payable)]
FundNative {},
ClaimCW20 { tokens: Vec<String> },
ClaimNatives { denoms: Vec<String> },
ClaimCW20 {
tokens: Vec<String>,
},
ClaimNatives {
denoms: Vec<String>,
},
ClaimAll {},
}

Expand Down
10 changes: 8 additions & 2 deletions contracts/distribution/dao-rewards-distributor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[package]
name = "dao-rewards-distributor"
authors = ["Ben2x4 <[email protected]>", "ekez <[email protected]>", "Jake Hartnell <[email protected]>", "bekauz <[email protected]>"]
authors = [
"Ben2x4 <[email protected]>",
"ekez <[email protected]>",
"Jake Hartnell <[email protected]>",
"bekauz <[email protected]>",
]
description = "Distributes rewards based on DAO membership."
edition = { workspace = true }
license = { workspace = true }
Expand All @@ -21,7 +26,7 @@ cosmwasm-schema = { workspace = true }
cw2 = { workspace = true }
cw4 = { workspace = true }
cw20 = { workspace = true }
cw20-base = { workspace = true, features = ["library"] }
cw20-base = { workspace = true, features = ["library"] }
cw-controllers = { workspace = true }
cw-ownable = { workspace = true }
cw-storage-plus = { workspace = true }
Expand All @@ -30,6 +35,7 @@ dao-hooks = { workspace = true }
dao-interface = { workspace = true }
dao-voting = { workspace = true }
thiserror = { workspace = true }
cw-orch.workspace = true

[dev-dependencies]
cw-multi-test = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion contracts/distribution/dao-rewards-distributor/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct InstantiateMsg {

#[cw_ownable_execute]
#[cw_serde]
#[derive(cw_orch::ExecuteFns)]
pub enum ExecuteMsg {
/// Called when a member is added or removed
/// to a cw4-groups or cw721-roles contract.
Expand Down Expand Up @@ -49,6 +50,7 @@ pub enum ExecuteMsg {
/// Used to fund this contract with cw20 tokens.
Receive(Cw20ReceiveMsg),
/// Used to fund this contract with native tokens.
#[cw_orch(payable)]
Fund(FundMsg),
/// Claims rewards for the sender.
Claim { id: u64 },
Expand Down Expand Up @@ -86,7 +88,7 @@ pub enum ReceiveCw20Msg {
}

#[cw_serde]
#[derive(QueryResponses)]
#[derive(QueryResponses, cw_orch::QueryFns)]
pub enum QueryMsg {
/// Returns contract version info
#[returns(InfoResponse)]
Expand Down
2 changes: 2 additions & 0 deletions contracts/external/cw-admin-factory/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct InstantiateMsg {
pub enum ExecuteMsg {
/// Instantiates the target contract with the provided instantiate message,
/// code ID, and label and updates the contract's admin to be itself.
#[cw_orch(payable)]
InstantiateContractWithSelfAdmin {
instantiate_msg: Binary,
code_id: u64,
Expand All @@ -21,6 +22,7 @@ pub enum ExecuteMsg {
/// Instantiates the target contract with the provided instantiate message,
/// code ID, label, and salt, via instantiate2 to give a predictable
/// address, and updates the contract's admin to be itself.
#[cw_orch(payable)]
Instantiate2ContractWithSelfAdmin {
instantiate_msg: Binary,
code_id: u64,
Expand Down
1 change: 1 addition & 0 deletions contracts/external/cw-payroll-factory/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub enum ExecuteMsg {
/// Instantiates a new vesting contract that is funded by a cw20 token.
Receive(Cw20ReceiveMsg),
/// Instantiates a new vesting contract that is funded by a native token.
#[cw_orch(payable)]
InstantiateNativePayrollContract {
instantiate_msg: PayrollInstantiateMsg,
label: String,
Expand Down
1 change: 1 addition & 0 deletions contracts/external/cw-token-swap/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub enum ExecuteMsg {
/// Used to provide cw20 tokens to satisfy a funds promise.
Receive(cw20::Cw20ReceiveMsg),
/// Provides native tokens to satisfy a funds promise.
#[cw_orch(payable)]
Fund {},
/// Withdraws provided funds. Only allowed if the other
/// counterparty has yet to provide their promised funds.
Expand Down
60 changes: 31 additions & 29 deletions packages/cw-orch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,36 @@ wasm_test = []

[dependencies]
cosmwasm-std.workspace = true
cw-orch = { version = "0.22.2" }
cw20-stake = { version = "2.4.2", path = "../../contracts/staking/cw20-stake" }
cw20-stake-external-rewards = { version = "2.4.2", path = "../../contracts/staking/cw20-stake-external-rewards" }
cw20-stake-reward-distributor = { version = "2.4.2", path = "../../contracts/staking/cw20-stake-reward-distributor" }
cw-orch.workspace = true
cw20-stake.workspace = true
cw20-stake-external-rewards = { path = "../../contracts/staking/cw20-stake-external-rewards" }
cw20-stake-reward-distributor = { path = "../../contracts/staking/cw20-stake-reward-distributor" }
cw721-base.workspace = true
cw721-roles = { path = "../../contracts/external/cw721-roles", version = "2.4.2" }
cw-admin-factory = { path = "../../contracts/external/cw-admin-factory", version = "2.5.0" }
cw-vesting = { version = "2.4.2", path = "../../contracts/external/cw-vesting" }
cw-payroll-factory = { version = "2.4.2", path = "../../contracts/external/cw-payroll-factory" }
cw-token-swap = { version = "2.4.2", path = "../../contracts/external/cw-token-swap" }
cw-tokenfactory-issuer = { version = "2.4.2", path = "../../contracts/external/cw-tokenfactory-issuer" }
dao-migrator = { version = "2.4.2", path = "../../contracts/external/dao-migrator" }
dao-dao-core = { version = "2.4.2", path = "../../contracts/dao-dao-core" }
dao-interface = { version = "2.4.2", path = "../dao-interface" }
dao-pre-propose-approval-single = { version = "2.4.2", path = "../../contracts/pre-propose/dao-pre-propose-approval-single" }
dao-pre-propose-approver = { version = "2.4.2", path = "../../contracts/pre-propose/dao-pre-propose-approver" }
dao-pre-propose-multiple = { version = "2.4.2", path = "../../contracts/pre-propose/dao-pre-propose-multiple" }
dao-pre-propose-single = { version = "2.4.2", path = "../../contracts/pre-propose/dao-pre-propose-single" }
dao-proposal-condorcet = { version = "2.4.2", path = "../../contracts/proposal/dao-proposal-condorcet" }
dao-proposal-hook-counter = { version = "2.4.2", path = "../../contracts/test/dao-proposal-hook-counter" }
dao-proposal-multiple = { version = "2.4.2", path = "../../contracts/proposal/dao-proposal-multiple" }
dao-proposal-single = { version = "2.4.2", path = "../../contracts/proposal/dao-proposal-single" }
dao-proposal-sudo = { version = "2.4.2", path = "../../contracts/test/dao-proposal-sudo" }
dao-test-custom-factory = { version = "2.4.2", path = "../../contracts/test/dao-test-custom-factory" }
dao-voting-cw20-balance = { version = "2.4.2", path = "../../contracts/test/dao-voting-cw20-balance" }
dao-voting-cw20-staked = { version = "2.4.2", path = "../../contracts/voting/dao-voting-cw20-staked" }
dao-voting-cw4 = { version = "2.4.2", path = "../../contracts/voting/dao-voting-cw4" }
dao-voting-cw721-roles = { version = "2.4.2", path = "../../contracts/voting/dao-voting-cw721-roles" }
dao-voting-cw721-staked = { version = "2.4.2", path = "../../contracts/voting/dao-voting-cw721-staked" }
dao-voting-token-staked = { version = "2.4.2", path = "../../contracts/voting/dao-voting-token-staked" }
cw721-roles.workspace = true
cw-admin-factory.workspace = true
cw-vesting.workspace = true
cw-payroll-factory.workspace = true
cw-token-swap = { path = "../../contracts/external/cw-token-swap" }
cw-tokenfactory-issuer.workspace = true
dao-migrator = { path = "../../contracts/external/dao-migrator" }
dao-dao-core.workspace = true
dao-interface.workspace = true
dao-pre-propose-approval-single.workspace = true
dao-pre-propose-approver.workspace = true
dao-pre-propose-multiple.workspace = true
dao-pre-propose-single.workspace = true
dao-proposal-condorcet.workspace = true
dao-proposal-hook-counter.workspace = true
dao-proposal-multiple.workspace = true
dao-proposal-single.workspace = true
dao-proposal-sudo.workspace = true
dao-test-custom-factory.workspace = true
dao-voting-cw20-balance.workspace = true
dao-voting-cw20-staked.workspace = true
dao-voting-cw4.workspace = true
dao-voting-cw721-roles.workspace = true
dao-voting-cw721-staked.workspace = true
dao-voting-token-staked.workspace = true
dao-rewards-distributor.workspace = true
cw-fund-distributor.workspace = true
serde.workspace = true
20 changes: 20 additions & 0 deletions packages/cw-orch/src/distribution/cw_fund_distributor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use cw_orch::{interface, prelude::*};

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

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

impl<Chain> Uploadable for CwFundDistributor<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("cw_fund_distributor")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
fn wrapper() -> Box<dyn MockContract<Empty>> {
Box::new(ContractWrapper::new_with_empty(execute, instantiate, query))
}
}
20 changes: 20 additions & 0 deletions packages/cw-orch/src/distribution/dao_rewards_distributor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use cw_orch::{interface, prelude::*};

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

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

impl<Chain> Uploadable for DaoRewardsDistributor<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("dao_rewards_distributor")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
fn wrapper() -> Box<dyn MockContract<Empty>> {
Box::new(ContractWrapper::new_with_empty(execute, instantiate, query))
}
}
5 changes: 5 additions & 0 deletions packages/cw-orch/src/distribution/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod cw_fund_distributor;
mod dao_rewards_distributor;

pub use cw_fund_distributor::CwFundDistributor;
pub use dao_rewards_distributor::DaoRewardsDistributor;
2 changes: 1 addition & 1 deletion packages/cw-orch/src/external/admin_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<Chain> Uploadable for DaoExternalAdminFactory<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("dao_admin_factory")
.find_wasm_path("cw_admin_factory")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch/src/external/cw721_roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<Chain> Uploadable for DaoExternalCw721Roles<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("dao_cw721_roles")
.find_wasm_path("cw721_roles")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch/src/external/cw_vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<Chain> Uploadable for DaoExternalCwVesting<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("dao_cw_vesting")
.find_wasm_path("cw_vesting")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch/src/external/payroll_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<Chain> Uploadable for DaoExternalPayrollFactory<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("dao_payroll_factory")
.find_wasm_path("cw_payroll_factory")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch/src/external/token_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<Chain> Uploadable for DaoExternalTokenSwap<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("dao_tokenswap")
.find_wasm_path("cw_token_swap")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
Expand Down
2 changes: 1 addition & 1 deletion packages/cw-orch/src/external/tokenfactory_issuer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<Chain> Uploadable for DaoExternalTokenfactoryIssuer<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("dao_tokenfactory_issuer")
.find_wasm_path("cw_tokenfactory_issuer")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
Expand Down
4 changes: 4 additions & 0 deletions packages/cw-orch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[cfg(not(target_arch = "wasm32"))]
mod core;
#[cfg(not(target_arch = "wasm32"))]
mod distribution;
#[cfg(not(target_arch = "wasm32"))]
mod external;
#[cfg(not(target_arch = "wasm32"))]
mod pre_propose;
Expand All @@ -16,6 +18,8 @@ mod voting;
#[cfg(not(target_arch = "wasm32"))]
pub use core::*;
#[cfg(not(target_arch = "wasm32"))]
pub use distribution::*;
#[cfg(not(target_arch = "wasm32"))]
pub use external::*;
#[cfg(not(target_arch = "wasm32"))]
pub use pre_propose::*;
Expand Down
1 change: 1 addition & 0 deletions packages/dao-pre-propose-base/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct InstantiateMsg<InstantiateExt> {
pub enum ExecuteMsg<ProposalMessage, ExecuteExt> {
/// Creates a new proposal in the pre-propose module. MSG will be
/// serialized and used as the proposal creation message.
#[cw_orch(payable)]
Propose { msg: ProposalMessage },

/// Updates the configuration of this module. This will completely
Expand Down

0 comments on commit cf63b3f

Please sign in to comment.