Skip to content

Commit

Permalink
Merge pull request #445 from CosmWasm/440-customizable-nft
Browse files Browse the repository at this point in the history
Make NFT Customisable
  • Loading branch information
ethanfrey committed Sep 23, 2021
2 parents 236a9db + 51f9cb9 commit 9671cc2
Show file tree
Hide file tree
Showing 19 changed files with 1,713 additions and 1,201 deletions.
17 changes: 13 additions & 4 deletions contracts/cw721-base/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::env::current_dir;
use std::fs::create_dir_all;

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

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

fn main() {
Expand All @@ -16,13 +17,21 @@ fn main() {
remove_schemas(&out_dir).unwrap();

export_schema(&schema_for!(InstantiateMsg), &out_dir);
export_schema(&schema_for!(ExecuteMsg), &out_dir);
export_schema_with_title(&schema_for!(ExecuteMsg<Extension>), &out_dir, "ExecuteMsg");
export_schema(&schema_for!(QueryMsg), &out_dir);
export_schema(&schema_for!(AllNftInfoResponse), &out_dir);
export_schema_with_title(
&schema_for!(AllNftInfoResponse<Extension>),
&out_dir,
"AllNftInfoResponse",
);
export_schema(&schema_for!(ApprovedForAllResponse), &out_dir);
export_schema(&schema_for!(ContractInfoResponse), &out_dir);
export_schema(&schema_for!(MinterResponse), &out_dir);
export_schema(&schema_for!(NftInfoResponse), &out_dir);
export_schema_with_title(
&schema_for!(NftInfoResponse<Extension>),
&out_dir,
"NftInfoResponse",
);
export_schema(&schema_for!(NumTokensResponse), &out_dir);
export_schema(&schema_for!(OwnerOfResponse), &out_dir);
export_schema(&schema_for!(TokensResponse), &out_dir);
Expand Down
19 changes: 17 additions & 2 deletions contracts/cw721-base/schema/all_nft_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"description": "Data on the token itself,",
"allOf": [
{
"$ref": "#/definitions/NftInfoResponse"
"$ref": "#/definitions/NftInfoResponse_for_Nullable_Empty"
}
]
}
Expand All @@ -46,6 +46,10 @@
}
}
},
"Empty": {
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
"type": "object"
},
"Expiration": {
"description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)",
"anyOf": [
Expand Down Expand Up @@ -92,7 +96,7 @@
}
]
},
"NftInfoResponse": {
"NftInfoResponse_for_Nullable_Empty": {
"type": "object",
"required": [
"description",
Expand All @@ -103,6 +107,17 @@
"description": "Describes the asset to which this NFT represents",
"type": "string"
},
"extension": {
"description": "You can add any custom metadata here when you extend cw721-base",
"anyOf": [
{
"$ref": "#/definitions/Empty"
},
{
"type": "null"
}
]
},
"image": {
"description": "\"A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive. TODO: Use https://docs.rs/url_serde for type-safety",
"type": [
Expand Down
19 changes: 17 additions & 2 deletions contracts/cw721-base/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
],
"properties": {
"mint": {
"$ref": "#/definitions/MintMsg"
"$ref": "#/definitions/MintMsg_for_Nullable_Empty"
}
},
"additionalProperties": false
Expand All @@ -188,6 +188,10 @@
"description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>",
"type": "string"
},
"Empty": {
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
"type": "object"
},
"Expiration": {
"description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)",
"anyOf": [
Expand Down Expand Up @@ -234,7 +238,7 @@
}
]
},
"MintMsg": {
"MintMsg_for_Nullable_Empty": {
"type": "object",
"required": [
"name",
Expand All @@ -249,6 +253,17 @@
"null"
]
},
"extension": {
"description": "Any custom extension used by this contract",
"anyOf": [
{
"$ref": "#/definitions/Empty"
},
{
"type": "null"
}
]
},
"image": {
"description": "A URI pointing to an image representing the asset",
"type": [
Expand Down
17 changes: 17 additions & 0 deletions contracts/cw721-base/schema/nft_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
"description": "Describes the asset to which this NFT represents",
"type": "string"
},
"extension": {
"description": "You can add any custom metadata here when you extend cw721-base",
"anyOf": [
{
"$ref": "#/definitions/Empty"
},
{
"type": "null"
}
]
},
"image": {
"description": "\"A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive. TODO: Use https://docs.rs/url_serde for type-safety",
"type": [
Expand All @@ -22,5 +33,11 @@
"description": "Identifies the asset to which this NFT represents",
"type": "string"
}
},
"definitions": {
"Empty": {
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
"type": "object"
}
}
}

0 comments on commit 9671cc2

Please sign in to comment.