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

Use macros for extending CW721 execute/query messages #91

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions contracts/cw2981-royalties/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use std::env::current_dir;
use std::fs::create_dir_all;

use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for};
use cosmwasm_std::Empty;

use cw721::{
AllNftInfoResponse, ContractInfoResponse, NftInfoResponse, NumTokensResponse,
OperatorsResponse, OwnerOfResponse, TokensResponse,
};
use cw721_base::{ExecuteMsg, Extension, InstantiateMsg, MinterResponse, QueryMsg};
use cw721_base::{ExecuteMsg, Extension, InstantiateMsg, MinterResponse};

use cw2981_royalties::msg::{CheckRoyaltiesResponse, Cw2981QueryMsg, RoyaltiesInfoResponse};
use cw2981_royalties::msg::{CheckRoyaltiesResponse, RoyaltiesInfoResponse};
use cw2981_royalties::QueryMsg;

fn main() {
let mut out_dir = current_dir().unwrap();
Expand All @@ -19,12 +19,8 @@ fn main() {
remove_schemas(&out_dir).unwrap();

export_schema(&schema_for!(InstantiateMsg), &out_dir);
export_schema_with_title(
&schema_for!(ExecuteMsg<Extension, Empty>),
&out_dir,
"ExecuteMsg",
);
export_schema(&schema_for!(QueryMsg<Cw2981QueryMsg>), &out_dir);
export_schema_with_title(&schema_for!(ExecuteMsg<Extension>), &out_dir, "ExecuteMsg");
export_schema(&schema_for!(QueryMsg), &out_dir);
export_schema_with_title(
&schema_for!(AllNftInfoResponse<Extension>),
&out_dir,
Expand All @@ -41,7 +37,6 @@ fn main() {
export_schema(&schema_for!(NumTokensResponse), &out_dir);
export_schema(&schema_for!(OwnerOfResponse), &out_dir);
export_schema(&schema_for!(TokensResponse), &out_dir);
export_schema(&schema_for!(Cw2981QueryMsg), &out_dir);
export_schema(&schema_for!(RoyaltiesInfoResponse), &out_dir);
export_schema(&schema_for!(CheckRoyaltiesResponse), &out_dir);
}
3 changes: 2 additions & 1 deletion contracts/cw2981-royalties/schema/all_nft_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
],
"properties": {
"never": {
"type": "object"
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
52 changes: 0 additions & 52 deletions contracts/cw2981-royalties/schema/cw2981_query_msg.json

This file was deleted.

97 changes: 38 additions & 59 deletions contracts/cw2981-royalties/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
"description": "This is like Cw721ExecuteMsg but we add a Mint command for an owner to make this stand-alone. You will likely want to remove mint and use other control logic in any contract that inherits this.",
"oneOf": [
{
"description": "Transfer is a base message to move a token to another account without triggering actions",
"description": "Mint a new NFT, can only be called by the contract minter",
"type": "object",
"required": [
"mint"
],
"properties": {
"mint": {
"$ref": "#/definitions/MintMsg_for_Nullable_Empty"
}
},
"additionalProperties": false
},
{
"description": "Transfer is a base message to move a token to another account without triggering actions.",
"type": "object",
"required": [
"transfer_nft"
Expand Down Expand Up @@ -60,7 +73,7 @@
"additionalProperties": false
},
{
"description": "Allows operator to transfer / send the token from the owner's account. If expiration is set, then this allowance has a time/height limit",
"description": "Allows operator to transfer / send the token from the owner's account. If expiration is set, then this allowance has a time/height limit.",
"type": "object",
"required": [
"approve"
Expand Down Expand Up @@ -96,33 +109,7 @@
"additionalProperties": false
},
{
"description": "Remove previously granted Approval",
"type": "object",
"required": [
"revoke"
],
"properties": {
"revoke": {
"type": "object",
"required": [
"spender",
"token_id"
],
"properties": {
"spender": {
"type": "string"
},
"token_id": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Allows operator to transfer / send any token from the owner's account. If expiration is set, then this allowance has a time/height limit",
"description": "Allows operator to transfer / send any token from the owner's account. If expiration is set, then this allowance has a time/height limit.",
"type": "object",
"required": [
"approve_all"
Expand Down Expand Up @@ -154,19 +141,23 @@
"additionalProperties": false
},
{
"description": "Remove previously granted ApproveAll permission",
"description": "Remove previously granted Approval",
"type": "object",
"required": [
"revoke_all"
"revoke"
],
"properties": {
"revoke_all": {
"revoke": {
"type": "object",
"required": [
"operator"
"spender",
"token_id"
],
"properties": {
"operator": {
"spender": {
"type": "string"
},
"token_id": {
"type": "string"
}
},
Expand All @@ -176,32 +167,19 @@
"additionalProperties": false
},
{
"description": "Mint a new NFT, can only be called by the contract minter",
"type": "object",
"required": [
"mint"
],
"properties": {
"mint": {
"$ref": "#/definitions/MintMsg_for_Nullable_Empty"
}
},
"additionalProperties": false
},
{
"description": "Burn an NFT the sender has access to",
"description": "Remove previously granted ApproveAll permission",
"type": "object",
"required": [
"burn"
"revoke_all"
],
"properties": {
"burn": {
"revoke_all": {
"type": "object",
"required": [
"token_id"
"operator"
],
"properties": {
"token_id": {
"operator": {
"type": "string"
}
},
Expand All @@ -211,20 +189,20 @@
"additionalProperties": false
},
{
"description": "Extension msg",
"description": "Burn an NFT the sender has access to",
"type": "object",
"required": [
"extension"
"burn"
],
"properties": {
"extension": {
"burn": {
"type": "object",
"required": [
"msg"
"token_id"
],
"properties": {
"msg": {
"$ref": "#/definitions/Empty"
"token_id": {
"type": "string"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -281,7 +259,8 @@
],
"properties": {
"never": {
"type": "object"
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
3 changes: 2 additions & 1 deletion contracts/cw2981-royalties/schema/operators_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
],
"properties": {
"never": {
"type": "object"
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
3 changes: 2 additions & 1 deletion contracts/cw2981-royalties/schema/owner_of_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
],
"properties": {
"never": {
"type": "object"
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
Loading