-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1560 from CosmWasm/contruct-trhough-default
Add QueryResponseType trait and supply Default implementations
- Loading branch information
Showing
7 changed files
with
43 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use crate::Empty; | |
|
||
mod bank; | ||
mod ibc; | ||
mod query_response; | ||
mod staking; | ||
mod wasm; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use serde::de::DeserializeOwned; | ||
|
||
/// A marker trait for query response types. | ||
/// | ||
/// Those types have in common that they should be `#[non_exhaustive]` in order | ||
/// to allow adding fields in a backwards compatible way. In contracts they are | ||
/// only constructed through deserialization. We want to make it hard for | ||
/// contract developers to construct those types themselves as this is most likely | ||
/// not what they should do. | ||
/// | ||
/// In hosts they are constructed as follows: | ||
/// - wasmvm: Go types with the same JSON layout | ||
/// - multi-test/cw-sdk: create a default instance and mutate the fields | ||
/// | ||
/// This trait is crate-internal and can change any time. | ||
pub(crate) trait QueryResponseType: Default + DeserializeOwned {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters