Skip to content

Commit

Permalink
cargo schema
Browse files Browse the repository at this point in the history
  • Loading branch information
taitruong committed Aug 9, 2024
1 parent 7d6e297 commit 8607b64
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 447 deletions.
5 changes: 3 additions & 2 deletions build-schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ FILES=$(ls -d ./contracts/*)

for FILE in $FILES; do
$(
cd ./contracts/$FILE
cd $FILE
cargo schema
)
done

FILES=$(ls -d ./packages/*)

for FILE in $FILES; do
echo "================= $FILE ================="
$(
cd ./packages/$FILE
cd $FILE
cargo schema
)
done
16 changes: 6 additions & 10 deletions contracts/cw2981-royalties/schema/cw2981-royalties.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
],
"properties": {
"collection_info": {
"$ref": "#/definitions/CollectionInfoMsg_for_Nullable_Empty"
"$ref": "#/definitions/CollectionInfoMsg_for_Empty"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -552,18 +552,14 @@
}
}
},
"CollectionInfoMsg_for_Nullable_Empty": {
"CollectionInfoMsg_for_Empty": {
"type": "object",
"required": [
"extension"
],
"properties": {
"extension": {
"anyOf": [
{
"$ref": "#/definitions/Empty"
},
{
"type": "null"
}
]
"$ref": "#/definitions/Empty"
},
"name": {
"type": [
Expand Down
170 changes: 5 additions & 165 deletions contracts/cw721-base/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
],
"properties": {
"collection_info": {
"$ref": "#/definitions/CollectionInfoMsg_for_Nullable_CollectionExtensionMsg_for_RoyaltyInfoResponse"
"$ref": "#/definitions/CollectionInfoMsg_for_Nullable_Empty"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -252,7 +252,7 @@
"description": "Any custom extension used by this contract",
"anyOf": [
{
"$ref": "#/definitions/NftExtensionMsg"
"$ref": "#/definitions/Empty"
},
{
"type": "null"
Expand Down Expand Up @@ -340,7 +340,7 @@
"extension": {
"anyOf": [
{
"$ref": "#/definitions/NftExtensionMsg"
"$ref": "#/definitions/Empty"
},
{
"type": "null"
Expand Down Expand Up @@ -493,64 +493,13 @@
}
}
},
"CollectionExtensionMsg_for_RoyaltyInfoResponse": {
"description": "NOTE: In case `info` is not provided in `create()` or `validate()` (like for migration), creator/minter assertion is skipped.",
"type": "object",
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"explicit_content": {
"type": [
"boolean",
"null"
]
},
"external_link": {
"type": [
"string",
"null"
]
},
"image": {
"type": [
"string",
"null"
]
},
"royalty_info": {
"anyOf": [
{
"$ref": "#/definitions/RoyaltyInfoResponse"
},
{
"type": "null"
}
]
},
"start_trading_time": {
"anyOf": [
{
"$ref": "#/definitions/Timestamp"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
},
"CollectionInfoMsg_for_Nullable_CollectionExtensionMsg_for_RoyaltyInfoResponse": {
"CollectionInfoMsg_for_Nullable_Empty": {
"type": "object",
"properties": {
"extension": {
"anyOf": [
{
"$ref": "#/definitions/CollectionExtensionMsg_for_RoyaltyInfoResponse"
"$ref": "#/definitions/Empty"
},
{
"type": "null"
Expand All @@ -572,10 +521,6 @@
},
"additionalProperties": false
},
"Decimal": {
"description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)",
"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"
Expand Down Expand Up @@ -627,89 +572,6 @@
}
]
},
"NftExtensionMsg": {
"type": "object",
"properties": {
"animation_url": {
"description": "NOTE: Empty string is handled as None",
"type": [
"string",
"null"
]
},
"attributes": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Trait"
}
},
"background_color": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"external_url": {
"description": "NOTE: Empty string is handled as None",
"type": [
"string",
"null"
]
},
"image": {
"description": "NOTE: Empty string is handled as None",
"type": [
"string",
"null"
]
},
"image_data": {
"type": [
"string",
"null"
]
},
"name": {
"type": [
"string",
"null"
]
},
"youtube_url": {
"description": "NOTE: Empty string is handled as None",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
},
"RoyaltyInfoResponse": {
"type": "object",
"required": [
"payment_address",
"share"
],
"properties": {
"payment_address": {
"type": "string"
},
"share": {
"$ref": "#/definitions/Decimal"
}
},
"additionalProperties": false
},
"Timestamp": {
"description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```",
"allOf": [
Expand All @@ -718,28 +580,6 @@
}
]
},
"Trait": {
"type": "object",
"required": [
"trait_type",
"value"
],
"properties": {
"display_type": {
"type": [
"string",
"null"
]
},
"trait_type": {
"type": "string"
},
"value": {
"type": "string"
}
},
"additionalProperties": false
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
Expand Down
88 changes: 4 additions & 84 deletions contracts/cw721-base/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"description": "Optional extension of the collection metadata",
"anyOf": [
{
"$ref": "#/definitions/CollectionExtension_for_RoyaltyInfo"
"$ref": "#/definitions/Empty"
},
{
"type": "null"
Expand Down Expand Up @@ -49,89 +49,9 @@
},
"additionalProperties": false,
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
},
"CollectionExtension_for_RoyaltyInfo": {
"type": "object",
"required": [
"description",
"image"
],
"properties": {
"description": {
"type": "string"
},
"explicit_content": {
"type": [
"boolean",
"null"
]
},
"external_link": {
"type": [
"string",
"null"
]
},
"image": {
"type": "string"
},
"royalty_info": {
"anyOf": [
{
"$ref": "#/definitions/RoyaltyInfo"
},
{
"type": "null"
}
]
},
"start_trading_time": {
"anyOf": [
{
"$ref": "#/definitions/Timestamp"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
},
"Decimal": {
"description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)",
"type": "string"
},
"RoyaltyInfo": {
"type": "object",
"required": [
"payment_address",
"share"
],
"properties": {
"payment_address": {
"$ref": "#/definitions/Addr"
},
"share": {
"$ref": "#/definitions/Decimal"
}
},
"additionalProperties": false
},
"Timestamp": {
"description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
},
"Uint64": {
"description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```",
"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"
}
}
}
Loading

0 comments on commit 8607b64

Please sign in to comment.