Skip to content

Commit

Permalink
Merge pull request #1552 from 0xArbi/arb/supplyresponse
Browse files Browse the repository at this point in the history
Add SupplyResponse::new
  • Loading branch information
webmaster128 authored Dec 21, 2022
2 parents 0ec587d + 629aa72 commit 2bd030a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
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

0 comments on commit 2bd030a

Please sign in to comment.