Skip to content

Commit fe993e7

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

4 files changed

Lines changed: 30 additions & 62 deletions

File tree

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: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cosmwasm_schema::cw_serde;
1+
use cosmwasm_schema::{cw_serde, QueryResponses};
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::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::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::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::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,21 @@ pub enum QueryMsg<Q> {
103104
limit: Option<u32>,
104105
},
105106
/// Total number of tokens issued
107+
#[returns(cw721::NumTokensResponse)]
106108
NumTokens {},
107109

108110
/// With MetaData Extension.
109-
/// Returns top-level metadata about the contract: `ContractInfoResponse`
111+
#[returns(cw721::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`
114-
NftInfo {
115-
token_id: String,
116-
},
115+
/// but directly from the contract
116+
#[returns(cw721::NftInfoResponse)]
117+
NftInfo { token_id: String },
117118
/// With MetaData Extension.
118119
/// Returns the result of both `NftInfo` and `OwnerOf` as one query as an optimization
119-
/// for clients: `AllNftInfo`
120+
/// for clients
121+
#[returns(cw721::AllNftInfoResponse)]
120122
AllNftInfo {
121123
token_id: String,
122124
/// unset or false will filter out expired approvals, you must set to true to see them
@@ -125,27 +127,26 @@ pub enum QueryMsg<Q> {
125127

126128
/// With Enumerable extension.
127129
/// Returns all tokens owned by the given address, [] if unset.
128-
/// Return type: TokensResponse.
130+
#[returns(cw721::TokensResponse)]
129131
Tokens {
130132
owner: String,
131133
start_after: Option<String>,
132134
limit: Option<u32>,
133135
},
134136
/// With Enumerable extension.
135137
/// Requires pagination. Lists all token_ids controlled by the contract.
136-
/// Return type: TokensResponse.
138+
#[returns(cw721::TokensResponse)]
137139
AllTokens {
138140
start_after: Option<String>,
139141
limit: Option<u32>,
140142
},
141143

142-
// Return the minter
144+
#[returns(crate::msg::MinterResponse)]
143145
Minter {},
144146

145147
/// Extension query
146-
Extension {
147-
msg: Q,
148-
},
148+
#[returns(())]
149+
Extension { msg: Q },
149150
}
150151

151152
/// Shows who can mint these tokens

0 commit comments

Comments
 (0)