rustblockchaintendermintcosmos-sdk

the trait `QueryResponses` is not implemented for `QueryMsg`


I am trying to compile a contract the schema.rs has this error. I was trying to compile the code using cargo build --release --target wasm32-unknown-unknown. We are trying to create a mulit sig contract using cosm wasm. I was following the tutorial for cosmwasm academy. Code along was good. But trying this and I am frustrated. Please help. And if possible do check your discords.

error: can't compile schema generator for the `wasm32` arch

error\[E0277\]: the trait bound `QueryMsg: QueryResponses` is not satisfied
\--\> src/bin/schema.rs:5:5
|
5 | /     write_api! {
6 | |         instantiate: InstantiateMsg,
7 | |         execute: ExecuteMsg,
8 | |         query: QueryMsg,
9 | |     }
| |\____\_^ the trait `QueryResponses` is not implemented for `QueryMsg`
|
= note: this error originates in the macro `write_api` (in Nightly builds, run with -Z macro-backtrace for more info)

schema.rs


fn main() {
write_api! {
instantiate: InstantiateMsg,
execute: ExecuteMsg,
query: QueryMsg,
}
}

msg.rs

use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Addr, Coin};

#[cw_serde]
pub struct InstantiateMsg {
    pub minimum_approvals: i32,
    pub signers: Vec<Addr>,
}

#[cw_serde]
pub enum ExecuteMsg {
    Approve {},
    Revoke {},
    Execute { to: Addr, funds: Coin },
}

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    // GetCount returns the current count as a json-encoded number
    #[returns(Valueresp)]
    GetCurrentSignatures {},
}


#[cw_serde]
pub struct Valueresp {
    pub count: i32,
}

Solution

  • You have to run the command with providing --lib flag and it should work.