Skip to content

Commit

Permalink
Remove cw20 feature flag (#574)
Browse files Browse the repository at this point in the history
* Revert "Add feature flag for cw20 support in dao-core. (#571)"

This reverts commit 9afa125.

* Add documentation about dao-core treasury management.
  • Loading branch information
0xekez authored Dec 17, 2022
1 parent 457dfea commit b4a0b60
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 97 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ jobs:
env:
RUST_BACKTRACE: 1

- name: Run tests w/o default features
uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: unit-test
args: --locked --no-default-features
env:
RUST_BACKTRACE: 1

- name: Compile WASM contract
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -76,13 +67,6 @@ jobs:
command: clippy
args: --all-targets -- -D warnings

- name: Run cargo clippy w/o default features
uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: clippy
args: --all-targets --no-default-features -- -D warnings

- name: Generate Schema
run: ./scripts/schema.sh

Expand Down
3 changes: 0 additions & 3 deletions contracts/dao-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ crate-type = ["cdylib", "rlib"]
[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# enables cw20 treasury management
cw20 = []
# use library feature to disable all instantiate/execute/query exports
library = []
default = ["cw20"]

[dependencies]
cosmwasm-std = { workspace = true, features = ["ibc3"] }
Expand Down
8 changes: 0 additions & 8 deletions contracts/dao-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,3 @@ pub enum ExecuteMsg {
// ...
}
```

### Disabling cw20 support

There is an effort on CosmWasm chains to depreciate the cw20 standard
in favor of native tokens [generated by the TokenFactory
module](https://hackmd.io/@reecepbcups/cw20-to-tokenfactory). By
default, this contract has cw20 support. It may be disabled by
disabling default features (ex. `cargo build --no-default-features`).
20 changes: 3 additions & 17 deletions contracts/dao-core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ use dao_interface::{voting, ModuleInstantiateCallback, ModuleInstantiateInfo};

use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InitialItem, InstantiateMsg, MigrateMsg, QueryMsg};
#[cfg(feature = "cw20")]
use crate::query::Cw20BalanceResponse;
use crate::query::{
AdminNominationResponse, DaoURIResponse, DumpStateResponse, GetItemResponse, PauseInfoResponse,
SubDao,
AdminNominationResponse, Cw20BalanceResponse, DaoURIResponse, DumpStateResponse,
GetItemResponse, PauseInfoResponse, SubDao,
};
#[cfg(feature = "cw20")]
use crate::state::CW20_LIST;
use crate::state::{
Config, ProposalModule, ProposalModuleStatus, ACTIVE_PROPOSAL_MODULE_COUNT, ADMIN, CONFIG,
CW721_LIST, ITEMS, NOMINATED_ADMIN, PAUSED, PROPOSAL_MODULES, SUBDAO_LIST,
CW20_LIST, CW721_LIST, ITEMS, NOMINATED_ADMIN, PAUSED, PROPOSAL_MODULES, SUBDAO_LIST,
TOTAL_PROPOSAL_MODULE_COUNT, VOTING_MODULE,
};

Expand All @@ -47,7 +43,6 @@ pub fn instantiate(
name: msg.name,
description: msg.description,
image_url: msg.image_url,
#[cfg(feature = "cw20")]
automatically_add_cw20s: msg.automatically_add_cw20s,
automatically_add_cw721s: msg.automatically_add_cw721s,
dao_uri: msg.dao_uri,
Expand Down Expand Up @@ -114,15 +109,13 @@ pub fn execute(
execute_proposal_hook(deps.as_ref(), info.sender, msgs)
}
ExecuteMsg::Pause { duration } => execute_pause(deps, env, info.sender, duration),
#[cfg(feature = "cw20")]
ExecuteMsg::Receive(_) => execute_receive_cw20(deps, info.sender),
ExecuteMsg::ReceiveNft(_) => execute_receive_cw721(deps, info.sender),
ExecuteMsg::RemoveItem { key } => execute_remove_item(deps, env, info.sender, key),
ExecuteMsg::SetItem { key, value } => execute_set_item(deps, env, info.sender, key, value),
ExecuteMsg::UpdateConfig { config } => {
execute_update_config(deps, env, info.sender, config)
}
#[cfg(feature = "cw20")]
ExecuteMsg::UpdateCw20List { to_add, to_remove } => {
execute_update_cw20_list(deps, env, info.sender, to_add, to_remove)
}
Expand Down Expand Up @@ -404,7 +397,6 @@ fn do_update_addr_list(
Ok(())
}

#[cfg(feature = "cw20")]
pub fn execute_update_cw20_list(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -512,7 +504,6 @@ pub fn execute_update_sub_daos_list(
.add_attribute("sender", sender))
}

#[cfg(feature = "cw20")]
pub fn execute_receive_cw20(deps: DepsMut, sender: Addr) -> Result<Response, ContractError> {
let config = CONFIG.load(deps.storage)?;
if !config.automatically_add_cw20s {
Expand Down Expand Up @@ -543,9 +534,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
QueryMsg::Admin {} => query_admin(deps),
QueryMsg::AdminNomination {} => query_admin_nomination(deps),
QueryMsg::Config {} => query_config(deps),
#[cfg(feature = "cw20")]
QueryMsg::Cw20TokenList { start_after, limit } => query_cw20_list(deps, start_after, limit),
#[cfg(feature = "cw20")]
QueryMsg::Cw20Balances { start_after, limit } => {
query_cw20_balances(deps, env, start_after, limit)
}
Expand Down Expand Up @@ -738,7 +727,6 @@ pub fn query_list_items(
)?)
}

#[cfg(feature = "cw20")]
pub fn query_cw20_list(
deps: Deps,
start_after: Option<String>,
Expand Down Expand Up @@ -771,7 +759,6 @@ pub fn query_cw721_list(
)?)
}

#[cfg(feature = "cw20")]
pub fn query_cw20_balances(
deps: Deps,
env: Env,
Expand Down Expand Up @@ -879,7 +866,6 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, Co
name: v1_config.name,
description: v1_config.description,
image_url: v1_config.image_url,
#[cfg(feature = "cw20")]
automatically_add_cw20s: v1_config.automatically_add_cw20s,
automatically_add_cw721s: v1_config.automatically_add_cw721s,
dao_uri,
Expand Down
5 changes: 0 additions & 5 deletions contracts/dao-core/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pub struct InstantiateMsg {

/// If true the contract will automatically add received cw20
/// tokens to its treasury.
#[cfg(feature = "cw20")]
pub automatically_add_cw20s: bool,
/// If true the contract will automatically add received cw721
/// tokens to its treasury.
Expand Down Expand Up @@ -67,7 +66,6 @@ pub enum ExecuteMsg {
/// Executed when the contract receives a cw20 token. Depending on
/// the contract's configuration the contract will automatically
/// add the token to its treasury.
#[cfg(feature = "cw20")]
Receive(cw20::Cw20ReceiveMsg),
/// Executed when the contract receives a cw721 token. Depending
/// on the contract's configuration the contract will
Expand Down Expand Up @@ -104,7 +102,6 @@ pub enum ExecuteMsg {
/// governance contract config with the provided config.
UpdateConfig { config: Config },
/// Updates the list of cw20 tokens this contract has registered.
#[cfg(feature = "cw20")]
UpdateCw20List {
to_add: Vec<String>,
to_remove: Vec<String>,
Expand Down Expand Up @@ -148,15 +145,13 @@ pub enum QueryMsg {
Config {},
/// Gets the token balance for each cw20 registered with the
/// contract.
#[cfg(feature = "cw20")]
#[returns(crate::query::Cw20BalanceResponse)]
Cw20Balances {
start_after: Option<String>,
limit: Option<u32>,
},
/// Lists the addresses of the cw20 tokens in this contract's
/// treasury.
#[cfg(feature = "cw20")]
#[returns(Vec<cosmwasm_std::Addr>)]
Cw20TokenList {
start_after: Option<String>,
Expand Down
5 changes: 2 additions & 3 deletions contracts/dao-core/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Addr;
use cosmwasm_std::{Addr, Uint128};
use cw2::ContractVersion;
use cw_utils::Expiration;

Expand Down Expand Up @@ -45,12 +45,11 @@ pub struct GetItemResponse {

/// Returned by the `Cw20Balances` query.
#[cw_serde]
#[cfg(feature = "cw20")]
pub struct Cw20BalanceResponse {
/// The address of the token.
pub addr: Addr,
/// The contract's balance.
pub balance: cosmwasm_std::Uint128,
pub balance: Uint128,
}

/// Returned by the `AdminNomination` query.
Expand Down
6 changes: 2 additions & 4 deletions contracts/dao-core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub struct Config {
pub image_url: Option<String>,
/// If true the contract will automatically add received cw20
/// tokens to its treasury.
#[cfg(feature = "cw20")]
pub automatically_add_cw20s: bool,
/// If true the contract will automatically add received cw721
/// tokens to its treasury.
Expand All @@ -25,8 +24,8 @@ pub struct Config {
pub dao_uri: Option<String>,
}

/// Top level type describing a proposal module.
#[cw_serde]
/// Top level type describing a proposal module.
pub struct ProposalModule {
/// The address of the proposal module.
pub address: Addr,
Expand All @@ -37,8 +36,8 @@ pub struct ProposalModule {
pub status: ProposalModuleStatus,
}

/// The status of a proposal module.
#[cw_serde]
/// The status of a proposal module.
pub enum ProposalModuleStatus {
Enabled,
Disabled,
Expand Down Expand Up @@ -87,7 +86,6 @@ pub const ITEMS: Map<String, String> = Map::new("items");

/// Set of cw20 tokens that have been registered with this contract's
/// treasury.
#[cfg(feature = "cw20")]
pub const CW20_LIST: Map<Addr, Empty> = Map::new("cw20s");
/// Set of cw721 tokens that have been registered with this contract's
/// treasury.
Expand Down
Loading

0 comments on commit b4a0b60

Please sign in to comment.