Skip to content

Commit

Permalink
Merge pull request #2080 from CosmWasm/aw/allow-unknown-fields
Browse files Browse the repository at this point in the history
Explicitly allow unknown fields
  • Loading branch information
aumetra authored Apr 4, 2024
2 parents f44c38c + 48a6d5e commit 6f46db9
Show file tree
Hide file tree
Showing 33 changed files with 502 additions and 230 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to
ECDSA signature verification over secp256r1. ([#1983], [#2057], [#2058])
- cosmwasm-vm: Add metrics for the pinned memory cache ([#2059])
- cosmwasm-derive: The crate used in the expansion can now be renamed ([#2068])
- cosmwasm-schema-derive: The crate used in the expansion can now be renamed
([#2070])
- cosmwasm-std: The decimal types now implement `TryFrom` for their respective
integer representations ([#2075])

Expand All @@ -26,10 +28,18 @@ and this project adheres to
- cosmwasm-std: Enable `add_event` and `add_events` functions to process types
implementing `Into<Event>` ([#2044])
- cosmwasm-vm: Improve performance of the `Cache::analyze` function ([#2051])
- cosmwasm-derive: Update to `syn` v2 ([#2063])
- cosmwasm-schema-derive: Update to `syn` v2 ([#2063])
- cosmwasm-schema-derive: Improve emitted error messages ([#2063])
- cosmwasm-schema: `#[cw_serde]` now doesn't add `#[serde(deny_unknown_fields)]`
to the expanded code anymore ([#2080])

[#2044]: https://github.com/CosmWasm/cosmwasm/pull/2044
[#2051]: https://github.com/CosmWasm/cosmwasm/pull/2051
[#2059]: https://github.com/CosmWasm/cosmwasm/pull/2059
[#2063]: https://github.com/CosmWasm/cosmwasm/pull/2063
[#2070]: https://github.com/CosmWasm/cosmwasm/pull/2070
[#2080]: https://github.com/CosmWasm/cosmwasm/pull/2080

## [2.0.1] - 2024-04-03

Expand Down
23 changes: 16 additions & 7 deletions contracts/cyberpunk/schema/cyberpunk.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "InstantiateMsg",
"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"
"type": "object",
"additionalProperties": false
},
"execute": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down Expand Up @@ -299,6 +300,7 @@
"type": "string"
}
},
"additionalProperties": false,
"definitions": {
"DenomUnit": {
"description": "Replicates the cosmos-sdk bank module DenomUnit type",
Expand All @@ -323,7 +325,8 @@
"format": "uint32",
"minimum": 0.0
}
}
},
"additionalProperties": false
}
}
},
Expand Down Expand Up @@ -376,7 +379,8 @@
"uri_hash": {
"type": "string"
}
}
},
"additionalProperties": false
},
"DenomUnit": {
"description": "Replicates the cosmos-sdk bank module DenomUnit type",
Expand All @@ -401,7 +405,8 @@
"format": "uint32",
"minimum": 0.0
}
}
},
"additionalProperties": false
}
}
},
Expand Down Expand Up @@ -432,6 +437,7 @@
]
}
},
"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.",
Expand Down Expand Up @@ -462,7 +468,8 @@
}
]
}
}
},
"additionalProperties": false
},
"ContractInfo": {
"type": "object",
Expand All @@ -473,7 +480,8 @@
"address": {
"$ref": "#/definitions/Addr"
}
}
},
"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); ```",
Expand All @@ -495,7 +503,8 @@
"format": "uint32",
"minimum": 0.0
}
}
},
"additionalProperties": false
},
"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); ```",
Expand Down
3 changes: 2 additions & 1 deletion contracts/cyberpunk/schema/raw/instantiate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "InstantiateMsg",
"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"
"type": "object",
"additionalProperties": false
}
4 changes: 3 additions & 1 deletion contracts/cyberpunk/schema/raw/response_to_denom.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"type": "string"
}
},
"additionalProperties": false,
"definitions": {
"DenomUnit": {
"description": "Replicates the cosmos-sdk bank module DenomUnit type",
Expand All @@ -66,7 +67,8 @@
"format": "uint32",
"minimum": 0.0
}
}
},
"additionalProperties": false
}
}
}
6 changes: 4 additions & 2 deletions contracts/cyberpunk/schema/raw/response_to_denoms.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"uri_hash": {
"type": "string"
}
}
},
"additionalProperties": false
},
"DenomUnit": {
"description": "Replicates the cosmos-sdk bank module DenomUnit type",
Expand All @@ -72,7 +73,8 @@
"format": "uint32",
"minimum": 0.0
}
}
},
"additionalProperties": false
}
}
}
10 changes: 7 additions & 3 deletions contracts/cyberpunk/schema/raw/response_to_mirror_env.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
]
}
},
"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.",
Expand Down Expand Up @@ -55,7 +56,8 @@
}
]
}
}
},
"additionalProperties": false
},
"ContractInfo": {
"type": "object",
Expand All @@ -66,7 +68,8 @@
"address": {
"$ref": "#/definitions/Addr"
}
}
},
"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); ```",
Expand All @@ -88,7 +91,8 @@
"format": "uint32",
"minimum": 0.0
}
}
},
"additionalProperties": false
},
"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); ```",
Expand Down
3 changes: 2 additions & 1 deletion contracts/floaty/schema/floaty.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "InstantiateMsg",
"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"
"type": "object",
"additionalProperties": false
},
"execute": null,
"query": {
Expand Down
3 changes: 2 additions & 1 deletion contracts/floaty/schema/raw/instantiate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "InstantiateMsg",
"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"
"type": "object",
"additionalProperties": false
}
7 changes: 5 additions & 2 deletions contracts/hackatom/schema/hackatom.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@
"denom": {
"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); ```",
Expand Down Expand Up @@ -338,6 +339,7 @@
}
}
},
"additionalProperties": false,
"definitions": {
"Coin": {
"type": "object",
Expand All @@ -352,7 +354,8 @@
"denom": {
"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); ```",
Expand Down
4 changes: 3 additions & 1 deletion contracts/hackatom/schema/raw/response_to_other_balance.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
}
},
"additionalProperties": false,
"definitions": {
"Coin": {
"type": "object",
Expand All @@ -28,7 +29,8 @@
"denom": {
"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); ```",
Expand Down
3 changes: 2 additions & 1 deletion contracts/hackatom/schema/raw/sudo.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"denom": {
"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); ```",
Expand Down
Loading

0 comments on commit 6f46db9

Please sign in to comment.