Skip to content

Commit

Permalink
Fix WASM build
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Sep 15, 2023
1 parent 2ea443d commit d485616
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 70 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions contracts/voting/dao-voting-token-staked/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ use cw_utils::{
maybe_addr, must_pay, parse_reply_execute_data, parse_reply_instantiate_data, Duration,
};
use dao_hooks::stake::{stake_hook_msgs, unstake_hook_msgs};
use dao_interface::state::ModuleInstantiateCallback;
use dao_interface::voting::{
IsActiveResponse, TotalPowerAtHeightResponse, VotingPowerAtHeightResponse,
use dao_interface::{
state::ModuleInstantiateCallback,
token::{FactoryCallback, InitialBalance, NewTokenInfo},
voting::{IsActiveResponse, TotalPowerAtHeightResponse, VotingPowerAtHeightResponse},
};
use dao_voting::{
duration::validate_duration,
Expand All @@ -29,8 +30,8 @@ use dao_voting::{

use crate::error::ContractError;
use crate::msg::{
DenomResponse, ExecuteMsg, FactoryCallback, GetHooksResponse, InitialBalance, InstantiateMsg,
ListStakersResponse, MigrateMsg, NewTokenInfo, QueryMsg, StakerBalanceResponse, TokenInfo,
DenomResponse, ExecuteMsg, GetHooksResponse, InstantiateMsg, ListStakersResponse, MigrateMsg,
QueryMsg, StakerBalanceResponse, TokenInfo,
};
use crate::state::{
Config, ACTIVE_THRESHOLD, CLAIMS, CONFIG, DAO, DENOM, HOOKS, MAX_CLAIMS, STAKED_BALANCES,
Expand Down
45 changes: 1 addition & 44 deletions contracts/voting/dao-voting-token-staked/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Binary, Uint128};
use cw_tokenfactory_issuer::msg::DenomUnit;
use cw_utils::Duration;
use dao_dao_macros::{active_query, token_query, voting_module_query};
use dao_interface::token::{InitialBalance, NewTokenInfo};
use dao_voting::threshold::{ActiveThreshold, ActiveThresholdResponse};

#[cw_serde]
pub struct InitialBalance {
pub amount: Uint128,
pub address: String,
}

#[cw_serde]
pub struct NewDenomMetadata {
/// The name of the token (e.g. "Cat Coin")
pub name: String,
/// The description of the token
pub description: String,
/// The ticker symbol of the token (e.g. "CAT")
pub symbol: String,
/// The unit commonly used in communication (e.g. "cat")
pub display: String,
/// Used define additional units of the token (e.g. "tiger")
/// These must have an exponent larger than 0.
pub additional_denom_units: Option<Vec<DenomUnit>>,
}

#[cw_serde]
pub struct NewTokenInfo {
/// The code id of the cw-tokenfactory-issuer contract
pub token_issuer_code_id: u64,
/// The subdenom of the token to create, will also be used as an alias
/// for the denom. The Token Factory denom will have the format of
/// factory/{contract_address}/{subdenom}
pub subdenom: String,
/// Optional metadata for the token, this can additionally be set later.
pub metadata: Option<NewDenomMetadata>,
/// The initial balances to set for the token, cannot be empty.
pub initial_balances: Vec<InitialBalance>,
/// Optional balance to mint for the DAO.
pub initial_dao_balance: Option<Uint128>,
}

#[cw_serde]
pub enum TokenInfo {
/// Uses an existing Token Factory token and creates a new issuer contract.
Expand Down Expand Up @@ -138,9 +101,3 @@ pub struct DenomResponse {
pub struct GetHooksResponse {
pub hooks: Vec<String>,
}

#[cw_serde]
pub struct FactoryCallback {
pub denom: String,
pub token_contract: Option<String>,
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use cosmwasm_std::{to_binary, Addr, Coin, Decimal, Uint128, WasmMsg};
use cw_tokenfactory_issuer::msg::DenomUnit;
use cw_utils::Duration;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_interface::{
state::{Admin, ModuleInstantiateInfo},
token::{InitialBalance, NewDenomMetadata, NewTokenInfo},
};
use dao_testing::test_tube::dao_dao_core::DaoCore;
use dao_voting::{
pre_propose::PreProposeInfo,
Expand All @@ -11,7 +14,7 @@ use osmosis_std::types::cosmos::bank::v1beta1::QueryBalanceRequest;
use osmosis_test_tube::{Account, OsmosisTestApp};

use crate::{
msg::{ExecuteMsg, InitialBalance, InstantiateMsg, NewDenomMetadata, NewTokenInfo, TokenInfo},
msg::{ExecuteMsg, InstantiateMsg, TokenInfo},
tests::test_tube::test_env::TokenVotingContract,
ContractError,
};
Expand Down Expand Up @@ -349,16 +352,14 @@ fn test_factory() {
contract_addr: custom_factory.unwrap().contract_addr.to_string(),
msg: to_binary(
&dao_test_custom_factory::msg::ExecuteMsg::TokenFactoryFactory(
dao_test_custom_factory::NewTokenInfo {
NewTokenInfo {
token_issuer_code_id: tf_issuer.code_id,
subdenom: DENOM.to_string(),
metadata: None,
initial_balances: vec![
dao_test_custom_factory::InitialBalance {
address: accounts[0].address(),
amount: Uint128::new(100),
},
],
initial_balances: vec![InitialBalance {
address: accounts[0].address(),
amount: Uint128::new(100),
}],
initial_dao_balance: None,
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![allow(dead_code)]

use crate::{
msg::{ExecuteMsg, InitialBalance, InstantiateMsg, NewTokenInfo, QueryMsg, TokenInfo},
msg::{ExecuteMsg, InstantiateMsg, QueryMsg, TokenInfo},
ContractError,
};

Expand All @@ -13,6 +13,7 @@ use cw_utils::Duration;
use dao_interface::{
msg::QueryMsg as DaoQueryMsg,
state::{Admin, ModuleInstantiateInfo, ProposalModule},
token::{InitialBalance, NewDenomMetadata, NewTokenInfo},
voting::{IsActiveResponse, VotingPowerAtHeightResponse},
};
use dao_voting::{
Expand Down Expand Up @@ -136,7 +137,7 @@ impl TestEnvBuilder {
token_info: TokenInfo::New(NewTokenInfo {
token_issuer_code_id: issuer_id,
subdenom: DENOM.to_string(),
metadata: Some(crate::msg::NewDenomMetadata {
metadata: Some(NewDenomMetadata {
description: "Awesome token, get it meow!".to_string(),
additional_denom_units: Some(vec![DenomUnit {
denom: "cat".to_string(),
Expand Down Expand Up @@ -208,7 +209,7 @@ impl TestEnvBuilder {
token_info: TokenInfo::New(NewTokenInfo {
token_issuer_code_id: issuer_id,
subdenom: DENOM.to_string(),
metadata: Some(crate::msg::NewDenomMetadata {
metadata: Some(NewDenomMetadata {
description: "Awesome token, get it meow!".to_string(),
additional_denom_units: Some(vec![DenomUnit {
denom: "cat".to_string(),
Expand Down
1 change: 1 addition & 0 deletions packages/dao-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cw20 = { workspace = true }
cw721 = { workspace = true }
cw-hooks = { workspace = true }
cw-utils = { workspace = true }
osmosis-std = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
1 change: 1 addition & 0 deletions packages/dao-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pub mod msg;
pub mod proposal;
pub mod query;
pub mod state;
pub mod token;
pub mod voting;
49 changes: 49 additions & 0 deletions packages/dao-interface/src/token.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Uint128;

// These are Cosmos Proto types used for Denom Metadata.
// We re-export them here for convenience.
pub use osmosis_std::types::cosmos::bank::v1beta1::{DenomUnit, Metadata};

#[cw_serde]
pub struct InitialBalance {
pub amount: Uint128,
pub address: String,
}

#[cw_serde]
pub struct NewDenomMetadata {
/// The name of the token (e.g. "Cat Coin")
pub name: String,
/// The description of the token
pub description: String,
/// The ticker symbol of the token (e.g. "CAT")
pub symbol: String,
/// The unit commonly used in communication (e.g. "cat")
pub display: String,
/// Used define additional units of the token (e.g. "tiger")
/// These must have an exponent larger than 0.
pub additional_denom_units: Option<Vec<DenomUnit>>,
}

#[cw_serde]
pub struct NewTokenInfo {
/// The code id of the cw-tokenfactory-issuer contract
pub token_issuer_code_id: u64,
/// The subdenom of the token to create, will also be used as an alias
/// for the denom. The Token Factory denom will have the format of
/// factory/{contract_address}/{subdenom}
pub subdenom: String,
/// Optional metadata for the token, this can additionally be set later.
pub metadata: Option<NewDenomMetadata>,
/// The initial balances to set for the token, cannot be empty.
pub initial_balances: Vec<InitialBalance>,
/// Optional balance to mint for the DAO.
pub initial_dao_balance: Option<Uint128>,
}

#[cw_serde]
pub struct FactoryCallback {
pub denom: String,
pub token_contract: Option<String>,
}
2 changes: 0 additions & 2 deletions test-contracts/dao-test-custom-factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ cw-utils = { workspace = true }
thiserror = { workspace = true }
dao-dao-macros = { workspace = true }
dao-interface = { workspace = true }
dao-voting-cw721-staked = { workspace = true, features = ["library"] }
dao-voting-token-staked = { workspace = true, features = ["library"] }
vending-factory = { workspace = true, features = ["library"] }
vending-minter = { workspace = true, features = ["library"] }
cw-tokenfactory-issuer = { workspace = true, features = ["library"] }
Expand Down
7 changes: 4 additions & 3 deletions test-contracts/dao-test-custom-factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use cw_tokenfactory_issuer::msg::{
ExecuteMsg as IssuerExecuteMsg, InstantiateMsg as IssuerInstantiateMsg,
};
use cw_utils::parse_reply_instantiate_data;
use dao_voting_token_staked::msg::{
FactoryCallback, InitialBalance, NewTokenInfo, QueryMsg as TokenVotingQueryMsg,
use dao_interface::{
token::{FactoryCallback, InitialBalance, NewTokenInfo},
voting::Query as VotingModuleQueryMsg,
};

use crate::{
Expand Down Expand Up @@ -69,7 +70,7 @@ pub fn execute_token_factory_factory(
// Query for DAO
let dao: Addr = deps
.querier
.query_wasm_smart(info.sender, &TokenVotingQueryMsg::Dao {})?;
.query_wasm_smart(info.sender, &VotingModuleQueryMsg::Dao {})?;

// Save DAO and TOKEN_INFO for use in replies
DAO.save(deps.storage, &dao)?;
Expand Down
1 change: 0 additions & 1 deletion test-contracts/dao-test-custom-factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ mod error;
pub mod msg;

pub use crate::error::ContractError;
pub use dao_voting_token_staked::msg::{InitialBalance, NewTokenInfo};
2 changes: 1 addition & 1 deletion test-contracts/dao-test-custom-factory/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::WasmMsg;
use dao_voting_token_staked::msg::NewTokenInfo;
use dao_interface::token::NewTokenInfo;

#[cw_serde]
pub struct InstantiateMsg {}
Expand Down

0 comments on commit d485616

Please sign in to comment.