Skip to content

Commit 8a652d7

Browse files
authored
Merge pull request #1926 from CosmWasm/try-IntoAny
Add Any message with blanket implementation
2 parents 2d42f5d + 304348b commit 8a652d7

File tree

11 files changed

+189
-108
lines changed

11 files changed

+189
-108
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ and this project adheres to
4747
- cosmwasm-std: Change `DistributionQuerier::new` to take `IntoIterator` instead
4848
of `HashMap`. ([#1941])
4949
- cosmwasm-vm: Make `instantiate` entrypoint optional. ([#1933])
50+
- cosmwasm-std: Rename `CosmosMsg::Stargate` to `CosmosMsg::Any` and use a
51+
nested msg struct like in other messages. ([#1926])
5052

5153
[#1874]: https://github.com/CosmWasm/cosmwasm/pull/1874
5254
[#1876]: https://github.com/CosmWasm/cosmwasm/pull/1876
@@ -55,6 +57,7 @@ and this project adheres to
5557
[#1884]: https://github.com/CosmWasm/cosmwasm/pull/1884
5658
[#1898]: https://github.com/CosmWasm/cosmwasm/pull/1898
5759
[#1902]: https://github.com/CosmWasm/cosmwasm/pull/1902
60+
[#1926]: https://github.com/CosmWasm/cosmwasm/pull/1926
5861
[#1933]: https://github.com/CosmWasm/cosmwasm/pull/1933
5962
[#1939]: https://github.com/CosmWasm/cosmwasm/pull/1939
6063
[#1940]: https://github.com/CosmWasm/cosmwasm/pull/1940

MIGRATING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ major releases of `cosmwasm`. Note that you can also view the
118118
+Ok(IbcReceiveResponse::new(b""))
119119
```
120120

121+
- Replace all uses of `CosmosMsg::Stargate` with `CosmosMsg::Any`:
122+
123+
```diff
124+
-CosmosMsg::Stargate { type_url, value }
125+
+CosmosMsg::Any(AnyMsg { type_url, value })
126+
```
127+
121128
## 1.4.x -> 1.5.0
122129

123130
- Update `cosmwasm-*` dependencies in Cargo.toml (skip the ones you don't use):

contracts/ibc-reflect-send/schema/ibc-reflect-send.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@
114114
}
115115
],
116116
"definitions": {
117+
"AnyMsg": {
118+
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
119+
"type": "object",
120+
"required": [
121+
"type_url",
122+
"value"
123+
],
124+
"properties": {
125+
"type_url": {
126+
"type": "string"
127+
},
128+
"value": {
129+
"$ref": "#/definitions/Binary"
130+
}
131+
}
132+
},
117133
"BankMsg": {
118134
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
119135
"oneOf": [
@@ -241,26 +257,13 @@
241257
"additionalProperties": false
242258
},
243259
{
244-
"description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
245260
"type": "object",
246261
"required": [
247-
"stargate"
262+
"any"
248263
],
249264
"properties": {
250-
"stargate": {
251-
"type": "object",
252-
"required": [
253-
"type_url",
254-
"value"
255-
],
256-
"properties": {
257-
"type_url": {
258-
"type": "string"
259-
},
260-
"value": {
261-
"$ref": "#/definitions/Binary"
262-
}
263-
}
265+
"any": {
266+
"$ref": "#/definitions/AnyMsg"
264267
}
265268
},
266269
"additionalProperties": false

contracts/ibc-reflect-send/schema/ibc/packet_msg.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@
5252
}
5353
],
5454
"definitions": {
55+
"AnyMsg": {
56+
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
57+
"type": "object",
58+
"required": [
59+
"type_url",
60+
"value"
61+
],
62+
"properties": {
63+
"type_url": {
64+
"type": "string"
65+
},
66+
"value": {
67+
"$ref": "#/definitions/Binary"
68+
}
69+
}
70+
},
5571
"BankMsg": {
5672
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
5773
"oneOf": [
@@ -179,26 +195,13 @@
179195
"additionalProperties": false
180196
},
181197
{
182-
"description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
183198
"type": "object",
184199
"required": [
185-
"stargate"
200+
"any"
186201
],
187202
"properties": {
188-
"stargate": {
189-
"type": "object",
190-
"required": [
191-
"type_url",
192-
"value"
193-
],
194-
"properties": {
195-
"type_url": {
196-
"type": "string"
197-
},
198-
"value": {
199-
"$ref": "#/definitions/Binary"
200-
}
201-
}
203+
"any": {
204+
"$ref": "#/definitions/AnyMsg"
202205
}
203206
},
204207
"additionalProperties": false

contracts/ibc-reflect-send/schema/raw/execute.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@
103103
}
104104
],
105105
"definitions": {
106+
"AnyMsg": {
107+
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
108+
"type": "object",
109+
"required": [
110+
"type_url",
111+
"value"
112+
],
113+
"properties": {
114+
"type_url": {
115+
"type": "string"
116+
},
117+
"value": {
118+
"$ref": "#/definitions/Binary"
119+
}
120+
}
121+
},
106122
"BankMsg": {
107123
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
108124
"oneOf": [
@@ -230,26 +246,13 @@
230246
"additionalProperties": false
231247
},
232248
{
233-
"description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
234249
"type": "object",
235250
"required": [
236-
"stargate"
251+
"any"
237252
],
238253
"properties": {
239-
"stargate": {
240-
"type": "object",
241-
"required": [
242-
"type_url",
243-
"value"
244-
],
245-
"properties": {
246-
"type_url": {
247-
"type": "string"
248-
},
249-
"value": {
250-
"$ref": "#/definitions/Binary"
251-
}
252-
}
254+
"any": {
255+
"$ref": "#/definitions/AnyMsg"
253256
}
254257
},
255258
"additionalProperties": false

contracts/ibc-reflect/schema/ibc/packet_msg.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@
112112
}
113113
],
114114
"definitions": {
115+
"AnyMsg": {
116+
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
117+
"type": "object",
118+
"required": [
119+
"type_url",
120+
"value"
121+
],
122+
"properties": {
123+
"type_url": {
124+
"type": "string"
125+
},
126+
"value": {
127+
"$ref": "#/definitions/Binary"
128+
}
129+
}
130+
},
115131
"BankMsg": {
116132
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
117133
"oneOf": [
@@ -215,26 +231,13 @@
215231
"additionalProperties": false
216232
},
217233
{
218-
"description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
219234
"type": "object",
220235
"required": [
221-
"stargate"
236+
"any"
222237
],
223238
"properties": {
224-
"stargate": {
225-
"type": "object",
226-
"required": [
227-
"type_url",
228-
"value"
229-
],
230-
"properties": {
231-
"type_url": {
232-
"type": "string"
233-
},
234-
"value": {
235-
"$ref": "#/definitions/Binary"
236-
}
237-
}
239+
"any": {
240+
"$ref": "#/definitions/AnyMsg"
238241
}
239242
},
240243
"additionalProperties": false

contracts/reflect/schema/raw/execute.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@
7373
}
7474
],
7575
"definitions": {
76+
"AnyMsg": {
77+
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
78+
"type": "object",
79+
"required": [
80+
"type_url",
81+
"value"
82+
],
83+
"properties": {
84+
"type_url": {
85+
"type": "string"
86+
},
87+
"value": {
88+
"$ref": "#/definitions/Binary"
89+
}
90+
}
91+
},
7692
"BankMsg": {
7793
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
7894
"oneOf": [
@@ -200,26 +216,13 @@
200216
"additionalProperties": false
201217
},
202218
{
203-
"description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
204219
"type": "object",
205220
"required": [
206-
"stargate"
221+
"any"
207222
],
208223
"properties": {
209-
"stargate": {
210-
"type": "object",
211-
"required": [
212-
"type_url",
213-
"value"
214-
],
215-
"properties": {
216-
"type_url": {
217-
"type": "string"
218-
},
219-
"value": {
220-
"$ref": "#/definitions/Binary"
221-
}
222-
}
224+
"any": {
225+
"$ref": "#/definitions/AnyMsg"
223226
}
224227
},
225228
"additionalProperties": false

contracts/reflect/schema/reflect.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@
8383
}
8484
],
8585
"definitions": {
86+
"AnyMsg": {
87+
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
88+
"type": "object",
89+
"required": [
90+
"type_url",
91+
"value"
92+
],
93+
"properties": {
94+
"type_url": {
95+
"type": "string"
96+
},
97+
"value": {
98+
"$ref": "#/definitions/Binary"
99+
}
100+
}
101+
},
86102
"BankMsg": {
87103
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
88104
"oneOf": [
@@ -210,26 +226,13 @@
210226
"additionalProperties": false
211227
},
212228
{
213-
"description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
214229
"type": "object",
215230
"required": [
216-
"stargate"
231+
"any"
217232
],
218233
"properties": {
219-
"stargate": {
220-
"type": "object",
221-
"required": [
222-
"type_url",
223-
"value"
224-
],
225-
"properties": {
226-
"type_url": {
227-
"type": "string"
228-
},
229-
"value": {
230-
"$ref": "#/definitions/Binary"
231-
}
232-
}
234+
"any": {
235+
"$ref": "#/definitions/AnyMsg"
233236
}
234237
},
235238
"additionalProperties": false

packages/std/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ pub use crate::query::{
8080
#[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))]
8181
pub use crate::results::WeightedVoteOption;
8282
pub use crate::results::{
83-
attr, wasm_execute, wasm_instantiate, Attribute, BankMsg, ContractResult, CosmosMsg, CustomMsg,
84-
Empty, Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubMsgResponse, SubMsgResult,
85-
SystemResult, WasmMsg,
83+
attr, wasm_execute, wasm_instantiate, AnyMsg, Attribute, BankMsg, ContractResult, CosmosMsg,
84+
CustomMsg, Empty, Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubMsgResponse,
85+
SubMsgResult, SystemResult, WasmMsg,
8686
};
8787
#[cfg(feature = "staking")]
8888
pub use crate::results::{DistributionMsg, StakingMsg};

0 commit comments

Comments
 (0)