我正在尝试编译一个合约,但 schema.rs 有此错误。 我试图使用 Cargo build --release --target wasm32-unknown-unknown 来编译代码。 我们正在尝试使用 cosm wasm 创建多重签名合约。我正在关注 cosmwasm 学院的教程。代码很好。但尝试这个,我很沮丧。请帮忙。如果可能的话,请检查您的不和谐之处。
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,
}
您必须在提供
--lib
标志的情况下运行命令,它应该可以工作。