Skip to content

Commit e9c3603

Browse files
authored
Merge pull request #803 from CosmWasm/pointless-defaults
Remove pointless Default implementations
2 parents a674bf7 + c355ed3 commit e9c3603

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ and this project adheres to
7575
- cosmwasm-std: Rename `MessageInfo::sent_funds` to `MessageInfo::funds`.
7676
- cosmwasm-std: Merge response types `InitResponse`, `HandleResponse` and
7777
`MigrateResponse` into the new `Response`.
78+
- cosmwasm-std: Remove `Default` implementation from `HumanAddr`,
79+
`CanonicalAddr`, `ContractInfo`, `MessageInfo`, `BlockInfo` and `Env`. If you
80+
need one of those, you're probably doing something wrong.
7881
- cosmwasm-vm: Avoid serialization of Modules in `InMemoryCache`, for
7982
performance. Also, remove `memory_limit` from `InstanceOptions`, and define it
8083
instead at `Cache` level (same memory limit for all cached instances).

packages/std/src/addresses.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::ops::Deref;
55

66
use crate::binary::Binary;
77

8-
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, Hash, JsonSchema)]
8+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash, JsonSchema)]
99
pub struct HumanAddr(pub String);
1010

1111
impl HumanAddr {
@@ -94,7 +94,7 @@ impl PartialEq<HumanAddr> for &str {
9494
}
9595
}
9696

97-
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, Hash, JsonSchema)]
97+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash, JsonSchema)]
9898
pub struct CanonicalAddr(pub Binary);
9999

100100
impl From<&[u8]> for CanonicalAddr {

packages/std/src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use serde::{Deserialize, Serialize};
44
use crate::addresses::HumanAddr;
55
use crate::coins::Coin;
66

7-
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)]
7+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
88
pub struct Env {
99
pub block: BlockInfo,
1010
pub contract: ContractInfo,
1111
}
1212

13-
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)]
13+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
1414
pub struct BlockInfo {
1515
pub height: u64,
1616
/// Absolute time of the block creation in seconds since the UNIX epoch (00:00:00 on 1970-01-01 UTC).
@@ -71,7 +71,7 @@ pub struct BlockInfo {
7171
///
7272
/// [MsgInstantiateContract]: https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L47-L61
7373
/// [MsgExecuteContract]: https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L68-L78
74-
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)]
74+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
7575
pub struct MessageInfo {
7676
/// The `sender` field from `MsgInstantiateContract` and `MsgExecuteContract`.
7777
/// You can think of this as the address that initiated the action (i.e. the message). What that
@@ -89,7 +89,7 @@ pub struct MessageInfo {
8989
pub funds: Vec<Coin>,
9090
}
9191

92-
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)]
92+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
9393
pub struct ContractInfo {
9494
pub address: HumanAddr,
9595
}

0 commit comments

Comments
 (0)