Skip to content

Commit 2bd030a

Browse files
authored
Merge pull request #1552 from 0xArbi/arb/supplyresponse
Add SupplyResponse::new
2 parents 0ec587d + 629aa72 commit 2bd030a

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ and this project adheres to
2323
- cosmwasm-std: Upgrade `serde-json-wasm` dependency to 0.5.0 which adds map
2424
support to `to_vec`/`to_binary` and friends.
2525
- cosmwasm-std: Implement `AsRef<[u8]>` for `Binary` and `HexBinary` ([#1550]).
26+
- cosmwasm-std: Add constructor `SupplyResponse::new` ([#1552]).
2627

2728
[#1436]: https://github.com/CosmWasm/cosmwasm/issues/1436
2829
[#1437]: https://github.com/CosmWasm/cosmwasm/issues/1437
2930
[#1481]: https://github.com/CosmWasm/cosmwasm/pull/1481
3031
[#1478]: https://github.com/CosmWasm/cosmwasm/pull/1478
3132
[#1533]: https://github.com/CosmWasm/cosmwasm/pull/1533
3233
[#1550]: https://github.com/CosmWasm/cosmwasm/issues/1550
34+
[#1552]: https://github.com/CosmWasm/cosmwasm/pull/1552
3335
[#1554]: https://github.com/CosmWasm/cosmwasm/pull/1554
3436

3537
### Changed

packages/std/src/query/bank.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ pub struct SupplyResponse {
3131
pub amount: Coin,
3232
}
3333

34+
#[cfg(feature = "cosmwasm_1_1")]
35+
impl SupplyResponse {
36+
/// Constructor for testing frameworks such as cw-multi-test.
37+
/// This is required because query response types should be #[non_exhaustive].
38+
/// As a contract developer you should not need this constructor since
39+
/// query responses are constructed for you via deserialization.
40+
#[doc(hidden)]
41+
pub fn new(amount: Coin) -> Self {
42+
Self { amount }
43+
}
44+
}
45+
3446
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
3547
#[serde(rename_all = "snake_case")]
3648
pub struct BalanceResponse {

packages/std/src/query/wasm.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ pub struct ContractInfoResponse {
4141
}
4242

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

0 commit comments

Comments
 (0)