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

Square cw721 spec with cw721-base #65

Merged
merged 8 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions contracts/cw721-base/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,19 @@ pub enum QueryMsg {
/// unset or false will filter out expired approvals, you must set to true to see them
include_expired: Option<bool>,
},

/// Return operator that can access all of the owner's tokens.
/// Return type: `ApprovalResponse`
Approval {
token_id: String,
spender: String,
include_expired: Option<bool>,
},

/// Return approvals that a token has
/// Return type: `ApprovalsResponse`
Approvals {
token_id: String,
include_expired: Option<bool>,
},

/// List all operators that can access all of the owner's tokens
/// Return type: `OperatorsResponse`
AllOperators {
Expand Down
29 changes: 20 additions & 9 deletions packages/cw721/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,26 @@ to the given `operator`.

### Queries

`OwnerOf{token_id}` - Returns the owner of the given token,
as well as anyone with approval on this particular token.
If the token is unknown, returns an error. Return type is
`OwnerResponse{owner}`.

`ApprovedForAll{owner, include_expired}` - 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.
`OwnerOf{token_id, include_expired}` - Returns the owner of the given token,
as well as anyone with approval on this particular token. If the token is
unknown, returns an error. Return type is `OwnerOfResponse`. If
`include_expired` is set, show expired owners in the results, otherwise, ignore
them.

`Approval{token_id, spender, include_expired}` - Return an approval of `spender`
about the given `token_id`. Return type is `ApprovalResponse`. If
`include_expired` is set, show expired owners in the results, otherwise, ignore
them.

`Approvals{token_id, include_expired}` - Return all approvals that owner given
access to. Return type is `ApprovalsResponse`. If `include_expired` is set, show
expired owners in the results, otherwise, ignore them.

`AllOperators{owner, include_expired, start_after, limit}` - List all
operators that can access all of the owner's tokens. Return type is
`OperatorsResponse`. If `include_expired` is set, show expired owners in the
results, otherwise, ignore them. If `start_after` is set, then it returns the
first `limit` operators *after* the given one.

`NumTokens{}` - Total number of tokens issued

Expand Down
55 changes: 44 additions & 11 deletions packages/cw721/schema/cw721_query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,29 @@
"additionalProperties": false
},
{
"description": "Return operator that can access all of the owner's tokens. Return type: `ApprovedResponse`",
"description": "Return operator that can access all of the owner's tokens. Return type: `ApprovalResponse`",
"type": "object",
"required": [
"approved"
"approval"
],
"properties": {
"approved": {
"approval": {
"type": "object",
"required": [
"operator",
"owner"
"spender",
"token_id"
],
"properties": {
"operator": {
"include_expired": {
"type": [
"boolean",
"null"
]
},
"spender": {
"type": "string"
},
"owner": {
"token_id": {
"type": "string"
}
}
Expand All @@ -56,20 +62,47 @@
"additionalProperties": false
},
{
"description": "List all operators that can access all of the owner's tokens. Return type: `ApprovedForAllResponse`",
"description": "Return approvals that a token has Return type: `ApprovalsResponse`",
"type": "object",
"required": [
"approved_for_all"
"approvals"
],
"properties": {
"approved_for_all": {
"approvals": {
"type": "object",
"required": [
"token_id"
],
"properties": {
"include_expired": {
"type": [
"boolean",
"null"
]
},
"token_id": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "List all operators that can access all of the owner's tokens Return type: `OperatorsResponse`",
"type": "object",
"required": [
"all_operators"
],
"properties": {
"all_operators": {
"type": "object",
"required": [
"owner"
],
"properties": {
"include_expired": {
"description": "unset or false will filter out expired approvals, you must set to true to see them",
"description": "unset or false will filter out expired items, you must set to true to see them",
"type": [
"boolean",
"null"
Expand Down
24 changes: 16 additions & 8 deletions packages/cw721/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,24 @@ pub enum Cw721QueryMsg {
/// unset or false will filter out expired approvals, you must set to true to see them
include_expired: Option<bool>,
},

/// Return operator that can access all of the owner's tokens.
/// Return type: `ApprovedResponse`
Approved { owner: String, operator: String },

/// List all operators that can access all of the owner's tokens.
/// Return type: `ApprovedForAllResponse`
ApprovedForAll {
/// Return type: `ApprovalResponse`
Approval {
token_id: String,
spender: String,
include_expired: Option<bool>,
},
/// Return approvals that a token has
/// Return type: `ApprovalsResponse`
Approvals {
token_id: String,
include_expired: Option<bool>,
},
/// List all operators that can access all of the owner's tokens
/// Return type: `OperatorsResponse`
AllOperators {
owner: String,
/// unset or false will filter out expired approvals, you must set to true to see them
/// unset or false will filter out expired items, you must set to true to see them
include_expired: Option<bool>,
start_after: Option<String>,
limit: Option<u32>,
Expand Down