Skip to content

Commit fc9bd77

Browse files
committed
cw721-base: Try to use new schema
1 parent ccb105d commit fc9bd77

File tree

4 files changed

+26
-55
lines changed

4 files changed

+26
-55
lines changed

contracts/cw721-base/.cargo/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
wasm = "build --release --target wasm32-unknown-unknown"
33
wasm-debug = "build --target wasm32-unknown-unknown"
44
unit-test = "test --lib"
5-
schema = "run --example schema"
5+
schema = "run --bin schema"

contracts/cw721-base/examples/schema.rs

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use cosmwasm_schema::write_api;
2+
3+
use cw721_base::{ExecuteMsg, InstantiateMsg, QueryMsg};
4+
5+
fn main() {
6+
write_api! {
7+
instantiate: InstantiateMsg,
8+
execute: ExecuteMsg,
9+
query: QueryMsg,
10+
}
11+
}

contracts/cw721-base/src/msg.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cosmwasm_schema::cw_serde;
1+
use cosmwasm_schema::{QueryResponses, cw_serde};
22
use cosmwasm_std::Binary;
33
use cw721::Expiration;
44

@@ -72,29 +72,30 @@ pub struct MintMsg<T> {
7272
}
7373

7474
#[cw_serde]
75+
#[derive(QueryResponses)]
7576
pub enum QueryMsg<Q> {
7677
/// Return the owner of the given token, error if token does not exist
77-
/// Return type: OwnerOfResponse
78+
#[returns(cw721::msg::OwnerOfResponse)]
7879
OwnerOf {
7980
token_id: String,
8081
/// unset or false will filter out expired approvals, you must set to true to see them
8182
include_expired: Option<bool>,
8283
},
8384
/// Return operator that can access all of the owner's tokens.
84-
/// Return type: `ApprovalResponse`
85+
#[returns(cw721::msg::ApprovalResponse)]
8586
Approval {
8687
token_id: String,
8788
spender: String,
8889
include_expired: Option<bool>,
8990
},
9091
/// Return approvals that a token has
91-
/// Return type: `ApprovalsResponse`
92+
#[returns(cw721::msg::ApprovalsResponse)]
9293
Approvals {
9394
token_id: String,
9495
include_expired: Option<bool>,
9596
},
9697
/// List all operators that can access all of the owner's tokens
97-
/// Return type: `OperatorsResponse`
98+
#[returns(cw721::msg::OperatorsResponse)]
9899
AllOperators {
99100
owner: String,
100101
/// unset or false will filter out expired items, you must set to true to see them
@@ -103,20 +104,23 @@ pub enum QueryMsg<Q> {
103104
limit: Option<u32>,
104105
},
105106
/// Total number of tokens issued
107+
#[returns(cw721::msg::NumTokensResponse)]
106108
NumTokens {},
107109

108110
/// With MetaData Extension.
109-
/// Returns top-level metadata about the contract: `ContractInfoResponse`
111+
#[returns(cw721::msg::ContractInfoResponse)]
110112
ContractInfo {},
111113
/// With MetaData Extension.
112114
/// Returns metadata about one particular token, based on *ERC721 Metadata JSON Schema*
113-
/// but directly from the contract: `NftInfoResponse`
115+
/// but directly from the contract
116+
#[returns(cw721::msg::NftInfoResponse)]
114117
NftInfo {
115118
token_id: String,
116119
},
117120
/// With MetaData Extension.
118121
/// Returns the result of both `NftInfo` and `OwnerOf` as one query as an optimization
119-
/// for clients: `AllNftInfo`
122+
/// for clients
123+
#[returns(cw721::msg::AllNftInfoResponse)]
120124
AllNftInfo {
121125
token_id: String,
122126
/// unset or false will filter out expired approvals, you must set to true to see them
@@ -125,15 +129,15 @@ pub enum QueryMsg<Q> {
125129

126130
/// With Enumerable extension.
127131
/// Returns all tokens owned by the given address, [] if unset.
128-
/// Return type: TokensResponse.
132+
#[returns(cw721::msg::TokensResponse)]
129133
Tokens {
130134
owner: String,
131135
start_after: Option<String>,
132136
limit: Option<u32>,
133137
},
134138
/// With Enumerable extension.
135139
/// Requires pagination. Lists all token_ids controlled by the contract.
136-
/// Return type: TokensResponse.
140+
#[returns(cw721::msg::TokensResponse)]
137141
AllTokens {
138142
start_after: Option<String>,
139143
limit: Option<u32>,

0 commit comments

Comments
 (0)