Skip to content

Commit

Permalink
cw-wormhole fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayushoo07 committed Mar 14, 2024
1 parent fe8b9b3 commit 8d302d6
Show file tree
Hide file tree
Showing 15 changed files with 743 additions and 732 deletions.
13 changes: 7 additions & 6 deletions Cargo.lock

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

11 changes: 5 additions & 6 deletions contracts/test/dao-voting-cw20-balance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ library = []
[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
cw20 = { workspace = true }
cw-utils = { workspace = true }
secret-storage-plus = { workspace = true }
secret-cw2 = { workspace = true }
secret-utils = { workspace = true }
thiserror = { workspace = true }
dao-dao-macros = { workspace = true }
dao-interface = { workspace = true }
cw20-base = { workspace = true, features = ["library"] }
snip20-reference-impl = { workspace = true }

[dev-dependencies]
cw-multi-test = { workspace = true }
secret-multi-test = { workspace = true }
18 changes: 9 additions & 9 deletions contracts/test/dao-voting-cw20-balance/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, SubMsg,
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, SubMsg,
Uint128, WasmMsg,
};
use cw2::set_contract_version;
use cw_utils::parse_reply_instantiate_data;
use secret_cw2::set_contract_version;
use secret_utils::parse_reply_instantiate_data;

use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, TokenInfo};
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn instantiate(
let msg = WasmMsg::Instantiate {
admin: Some(info.sender.to_string()),
code_id,
msg: to_json_binary(&cw20_base::msg::InstantiateMsg {
msg: to_binary(&cw20_base::msg::InstantiateMsg {
name,
symbol,
decimals,
Expand Down Expand Up @@ -104,12 +104,12 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {

pub fn query_dao(deps: Deps) -> StdResult<Binary> {
let dao = DAO.load(deps.storage)?;
to_json_binary(&dao)
to_binary(&dao)
}

pub fn query_token_contract(deps: Deps) -> StdResult<Binary> {
let token = TOKEN.load(deps.storage)?;
to_json_binary(&token)
to_binary(&token)
}

pub fn query_voting_power_at_height(deps: Deps, env: Env, address: String) -> StdResult<Binary> {
Expand All @@ -121,7 +121,7 @@ pub fn query_voting_power_at_height(deps: Deps, env: Env, address: String) -> St
address: address.to_string(),
},
)?;
to_json_binary(&dao_interface::voting::VotingPowerAtHeightResponse {
to_binary(&dao_interface::voting::VotingPowerAtHeightResponse {
power: balance.balance,
height: env.block.height,
})
Expand All @@ -132,15 +132,15 @@ pub fn query_total_power_at_height(deps: Deps, env: Env) -> StdResult<Binary> {
let info: cw20::TokenInfoResponse = deps
.querier
.query_wasm_smart(token, &cw20::Cw20QueryMsg::TokenInfo {})?;
to_json_binary(&dao_interface::voting::TotalPowerAtHeightResponse {
to_binary(&dao_interface::voting::TotalPowerAtHeightResponse {
power: info.total_supply,
height: env.block.height,
})
}

pub fn query_info(deps: Deps) -> StdResult<Binary> {
let info = cw2::get_contract_version(deps.storage)?;
to_json_binary(&dao_interface::voting::InfoResponse { info })
to_binary(&dao_interface::voting::InfoResponse { info })
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
3 changes: 2 additions & 1 deletion contracts/test/dao-voting-cw20-balance/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cw20::Cw20Coin;
use cw20_base::msg::InstantiateMarketingInfo;

use dao_dao_macros::{cw20_token_query, voting_module_query};
use dao_interface::token::InitialBalance;

#[cw_serde]
pub enum TokenInfo {
Expand All @@ -17,7 +18,7 @@ pub enum TokenInfo {
name: String,
symbol: String,
decimals: u8,
initial_balances: Vec<Cw20Coin>,
initial_balances: Vec<InitialBalance>,
marketing: Option<InstantiateMarketingInfo>,
},
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/dao-voting-cw20-balance/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::Addr;
use cw_storage_plus::Item;
use secret_storage_plus::Item;

pub const DAO: Item<Addr> = Item::new("dao");
pub const TOKEN: Item<Addr> = Item::new("token");
36 changes: 18 additions & 18 deletions contracts/test/dao-voting-cw20-balance/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cosmwasm_std::{Addr, Empty, Uint128};
use cw2::ContractVersion;
use cw20::{Cw20Coin, MinterResponse, TokenInfoResponse};
use cw_multi_test::{App, Contract, ContractWrapper, Executor};
use dao_interface::voting::{InfoResponse, VotingPowerAtHeightResponse};
use secret_cw2::ContractVersion;
use snip20_reference_impl::msg::QueryAnswer;
use secret_multi_test::{App, Contract, ContractWrapper, Executor};
use dao_interface::{token::InitialBalance, voting::{InfoResponse, VotingPowerAtHeightResponse}};

use crate::msg::{InstantiateMsg, QueryMsg};

Expand All @@ -11,9 +11,9 @@ const CREATOR_ADDR: &str = "creator";

fn cw20_contract() -> Box<dyn Contract<Empty>> {
let contract = ContractWrapper::new(
cw20_base::contract::execute,
cw20_base::contract::instantiate,
cw20_base::contract::query,
snip20_reference_impl::contract::execute,
snip20_reference_impl::contract::instantiate,
snip20_reference_impl::contract::query,
);
Box::new(contract)
}
Expand Down Expand Up @@ -56,7 +56,7 @@ fn test_instantiate_zero_supply() {
name: "DAO DAO".to_string(),
symbol: "DAO".to_string(),
decimals: 6,
initial_balances: vec![Cw20Coin {
initial_balances: vec![InitialBalance {
address: CREATOR_ADDR.to_string(),
amount: Uint128::zero(),
}],
Expand Down Expand Up @@ -105,7 +105,7 @@ fn test_contract_info() {
name: "DAO DAO".to_string(),
symbol: "DAO".to_string(),
decimals: 6,
initial_balances: vec![Cw20Coin {
initial_balances: vec![InitialBalance {
address: CREATOR_ADDR.to_string(),
amount: Uint128::from(2u64),
}],
Expand Down Expand Up @@ -145,7 +145,7 @@ fn test_new_cw20() {
name: "DAO DAO".to_string(),
symbol: "DAO".to_string(),
decimals: 6,
initial_balances: vec![Cw20Coin {
initial_balances: vec![InitialBalance {
address: CREATOR_ADDR.to_string(),
amount: Uint128::from(2u64),
}],
Expand All @@ -159,27 +159,27 @@ fn test_new_cw20() {
.query_wasm_smart(voting_addr.clone(), &QueryMsg::TokenContract {})
.unwrap();

let token_info: TokenInfoResponse = app
let token_info: QueryAnswer = app
.wrap()
.query_wasm_smart(token_addr.clone(), &cw20::Cw20QueryMsg::TokenInfo {})
.unwrap();
assert_eq!(
token_info,
TokenInfoResponse {
QueryAnswer {
name: "DAO DAO".to_string(),
symbol: "DAO".to_string(),
decimals: 6,
total_supply: Uint128::from(2u64)
}
);

let minter_info: Option<MinterResponse> = app
let minter_info: Option<QueryAnswer> = app
.wrap()
.query_wasm_smart(token_addr.clone(), &cw20::Cw20QueryMsg::Minter {})
.unwrap();
assert_eq!(
minter_info,
Some(MinterResponse {
Some(QueryAnswer {
minter: DAO_ADDR.to_string(),
cap: None,
})
Expand Down Expand Up @@ -268,7 +268,7 @@ fn test_existing_cw20() {
name: "DAO DAO".to_string(),
symbol: "DAO".to_string(),
decimals: 3,
initial_balances: vec![Cw20Coin {
initial_balances: vec![InitialBalance {
address: CREATOR_ADDR.to_string(),
amount: Uint128::from(2u64),
}],
Expand Down Expand Up @@ -296,21 +296,21 @@ fn test_existing_cw20() {
.query_wasm_smart(voting_addr.clone(), &QueryMsg::TokenContract {})
.unwrap();

let token_info: TokenInfoResponse = app
let token_info: QueryAnswer = app
.wrap()
.query_wasm_smart(token_addr.clone(), &cw20::Cw20QueryMsg::TokenInfo {})
.unwrap();
assert_eq!(
token_info,
TokenInfoResponse {
QueryAnswer {
name: "DAO DAO".to_string(),
symbol: "DAO".to_string(),
decimals: 3,
total_supply: Uint128::from(2u64)
}
);

let minter_info: Option<MinterResponse> = app
let minter_info: Option<QueryAnswer> = app
.wrap()
.query_wasm_smart(token_addr.clone(), &cw20::Cw20QueryMsg::Minter {})
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::write_api;
use dao_voting_cw721_staked::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use dao_voting_snip721_staked::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
Loading

0 comments on commit 8d302d6

Please sign in to comment.