Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cw1155 specification #247

Merged
merged 11 commits into from
Mar 19, 2021
4 changes: 3 additions & 1 deletion packages/cw1155/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ the `CW1155Receiver` interface. The operator should eitherbe the `from` account
`ApprovedForAll{owner, include_expired, start_after, limit}` - List all operators that can
access all of the owner's tokens. Return type is `ApprovedForAllResponse`.
If `include_expired` is set, show expired owners in the results, otherwise,
ignore them. If query for some specific operator, set `start_after` to the operator, and set limit to 1.
ignore them.

`ApprovedForAllItem{owner, operator}` - Query approved status `owner` granted to `operator`. Return type is `ApprovedForAllItemResponse`.

### Receiver

Expand Down
1 change: 1 addition & 0 deletions packages/cw1155/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn main() {
export_schema(&schema_for!(cw1155::BalanceResponse), &out_dir);
export_schema(&schema_for!(cw1155::BatchBalanceResponse), &out_dir);
export_schema(&schema_for!(cw1155::ApprovedForAllResponse), &out_dir);
export_schema(&schema_for!(cw1155::ApprovedForAllItemResponse), &out_dir);
export_schema(&schema_for!(cw1155::TokenInfoResponse), &out_dir);
export_schema(&schema_for!(cw1155::TokensResponse), &out_dir);
}
13 changes: 13 additions & 0 deletions packages/cw1155/schema/approved_for_all_item_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ApprovedForAllItemResponse",
"type": "object",
"required": [
"approved"
],
"properties": {
"approved": {
"type": "boolean"
}
}
}
24 changes: 24 additions & 0 deletions packages/cw1155/schema/cw1155_query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,30 @@
}
}
},
{
"description": "Query approved status `owner` granted to `operator`. Return type: ApprovedForAllItemResponse",
"type": "object",
"required": [
"approved_for_all_item"
],
"properties": {
"approved_for_all_item": {
"type": "object",
"required": [
"operator",
"owner"
],
"properties": {
"operator": {
"$ref": "#/definitions/HumanAddr"
},
"owner": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"description": "With MetaData Extension. Query metadata of token Return type: TokenInfoResponse.",
"type": "object",
Expand Down
4 changes: 2 additions & 2 deletions packages/cw1155/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use crate::msg::{Cw1155HandleMsg, TokenId};
pub use crate::query::{
Approval, ApprovedForAllResponse, BalanceResponse, BatchBalanceResponse, Cw1155QueryMsg,
TokenInfoResponse, TokensResponse,
Approval, ApprovedForAllItemResponse, ApprovedForAllResponse, BalanceResponse,
BatchBalanceResponse, Cw1155QueryMsg, TokenInfoResponse, TokensResponse,
};
pub use crate::receiver::{Cw1155BatchReceiveMsg, Cw1155ReceiveMsg};

Expand Down
11 changes: 11 additions & 0 deletions packages/cw1155/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ pub enum Cw1155QueryMsg {
start_after: Option<HumanAddr>,
limit: Option<u32>,
},
/// Query approved status `owner` granted to `operator`.
/// Return type: ApprovedForAllItemResponse
ApprovedForAllItem {
ethanfrey marked this conversation as resolved.
Show resolved Hide resolved
owner: HumanAddr,
operator: HumanAddr,
},

/// With MetaData Extension.
/// Query metadata of token
Expand Down Expand Up @@ -73,6 +79,11 @@ pub struct ApprovedForAllResponse {
pub operators: Vec<Approval>,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct ApprovedForAllItemResponse {
pub approved: bool,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct TokenInfoResponse {
/// Should be a url point to a json file
Expand Down