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

Add SupplyResponse::new #1552

Merged
merged 4 commits into from Dec 21, 2022
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ and this project adheres to
- cosmwasm-std: Upgrade `serde-json-wasm` dependency to 0.5.0 which adds map
support to `to_vec`/`to_binary` and friends.
- cosmwasm-std: Implement `AsRef<[u8]>` for `Binary` and `HexBinary` ([#1550]).
- cosmwasm-std: Add constructor `SupplyResponse::new` ([#1552]).

[#1436]: https://github.com/CosmWasm/cosmwasm/issues/1436
[#1437]: https://github.com/CosmWasm/cosmwasm/issues/1437
[#1481]: https://github.com/CosmWasm/cosmwasm/pull/1481
[#1478]: https://github.com/CosmWasm/cosmwasm/pull/1478
[#1533]: https://github.com/CosmWasm/cosmwasm/pull/1533
[#1550]: https://github.com/CosmWasm/cosmwasm/issues/1550
[#1552]: https://github.com/CosmWasm/cosmwasm/pull/1552
[#1554]: https://github.com/CosmWasm/cosmwasm/pull/1554

### Changed
Expand Down
12 changes: 12 additions & 0 deletions packages/std/src/query/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ pub struct SupplyResponse {
pub amount: Coin,
}

#[cfg(feature = "cosmwasm_1_1")]
impl SupplyResponse {
/// Constructor for testing frameworks such as cw-multi-test.
/// This is required because query response types should be #[non_exhaustive].
/// As a contract developer you should not need this constructor since
/// query responses are constructed for you via deserialization.
#[doc(hidden)]
pub fn new(amount: Coin) -> Self {
Self { amount }
}
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct BalanceResponse {
Expand Down
5 changes: 4 additions & 1 deletion packages/std/src/query/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ pub struct ContractInfoResponse {
}

impl ContractInfoResponse {
/// Convenience constructor for tests / mocks
/// Constructor for testing frameworks such as cw-multi-test.
/// This is required because query response types should be #[non_exhaustive].
/// As a contract developer you should not need this constructor since
/// query responses are constructed for you via deserialization.
#[doc(hidden)]
pub fn new(code_id: u64, creator: impl Into<String>) -> Self {
Self {
Expand Down