Skip to content

Commit 9997ae2

Browse files
authored
Merge pull request #972 from CosmWasm/rename-subcallresponse
Rename subcall to submsg
2 parents f9ae492 + 048dc38 commit 9997ae2

File tree

13 files changed

+43
-35
lines changed

13 files changed

+43
-35
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ and this project adheres to
5151
- cosmwasm-std: Change `Event`'s constructor - it no longer takes a vector of
5252
attributes and instead constructs an empty one
5353
- cosmwasm-std: Rename `Event.kind` to `Event.ty`.
54+
- cosmwasm-std: Rename `SubcallResponse` to `SubMsgExecutionResponse`.
55+
- contracts: Rename `ReflectSubCall` to `ReflectSubMsg` and `SubCallResult` to
56+
`SubCallMsg` in the `reflect` contract.
57+
- cosmwasm-std: Rename the `subcall` module to `submessages`.
5458

5559
[#961]: https://github.com/CosmWasm/cosmwasm/pull/961
5660

contracts/ibc-reflect/src/contract.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use cosmwasm_std::{
22
attr, entry_point, from_slice, to_binary, wasm_execute, BankMsg, Binary, ContractResult,
33
CosmosMsg, Deps, DepsMut, Empty, Env, Event, IbcAcknowledgement, IbcBasicResponse, IbcChannel,
44
IbcOrder, IbcPacket, IbcReceiveResponse, MessageInfo, Order, QueryResponse, Reply, Response,
5-
StdError, StdResult, SubMsg, SubcallResponse, WasmMsg,
5+
StdError, StdResult, SubMsg, SubMsgExecutionResponse, WasmMsg,
66
};
77

88
use crate::msg::{
@@ -59,7 +59,10 @@ fn parse_contract_from_event(events: Vec<Event>) -> Option<String> {
5959
.map(|a| a.value)
6060
}
6161

62-
pub fn handle_init_callback(deps: DepsMut, response: SubcallResponse) -> StdResult<Response> {
62+
pub fn handle_init_callback(
63+
deps: DepsMut,
64+
response: SubMsgExecutionResponse,
65+
) -> StdResult<Response> {
6366
// we use storage to pass info from the caller to the reply
6467
let id = pending_channel(deps.storage).load()?;
6568
pending_channel(deps.storage).remove();
@@ -401,7 +404,7 @@ mod tests {
401404
// fake a reply and ensure this works
402405
let response = Reply {
403406
id,
404-
result: ContractResult::Ok(SubcallResponse {
407+
result: ContractResult::Ok(SubMsgExecutionResponse {
405408
events: fake_events(&account),
406409
data: None,
407410
}),
@@ -475,7 +478,7 @@ mod tests {
475478
// fake a reply and ensure this works
476479
let response = Reply {
477480
id,
478-
result: ContractResult::Ok(SubcallResponse {
481+
result: ContractResult::Ok(SubMsgExecutionResponse {
479482
events: fake_events(&REFLECT_ADDR),
480483
data: None,
481484
}),

contracts/ibc-reflect/tests/integration.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use cosmwasm_std::testing::{mock_ibc_channel, mock_ibc_packet_recv};
2121
use cosmwasm_std::{
2222
attr, coins, BankMsg, ContractResult, CosmosMsg, Event, IbcBasicResponse, IbcOrder,
23-
IbcReceiveResponse, Reply, Response, SubcallResponse, WasmMsg,
23+
IbcReceiveResponse, Reply, Response, SubMsgExecutionResponse, WasmMsg,
2424
};
2525
use cosmwasm_vm::testing::{
2626
ibc_channel_connect, ibc_channel_open, ibc_packet_receive, instantiate, mock_env, mock_info,
@@ -91,7 +91,7 @@ fn connect<T: Into<String>>(
9191
// fake a reply and ensure this works
9292
let response = Reply {
9393
id,
94-
result: ContractResult::Ok(SubcallResponse {
94+
result: ContractResult::Ok(SubMsgExecutionResponse {
9595
events: fake_events(&account),
9696
data: None,
9797
}),
@@ -167,7 +167,7 @@ fn proper_handshake_flow() {
167167
// we get the callback from reflect
168168
let response = Reply {
169169
id,
170-
result: ContractResult::Ok(SubcallResponse {
170+
result: ContractResult::Ok(SubMsgExecutionResponse {
171171
events: fake_events(&REFLECT_ADDR),
172172
data: None,
173173
}),

contracts/reflect/schema/execute_msg.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
{
2929
"type": "object",
3030
"required": [
31-
"reflect_sub_call"
31+
"reflect_sub_msg"
3232
],
3333
"properties": {
34-
"reflect_sub_call": {
34+
"reflect_sub_msg": {
3535
"type": "object",
3636
"required": [
3737
"msgs"

contracts/reflect/schema/query_msg.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@
8282
"additionalProperties": false
8383
},
8484
{
85-
"description": "If there was a previous ReflectSubCall with this ID, returns cosmwasm_std::Reply",
85+
"description": "If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply",
8686
"type": "object",
8787
"required": [
88-
"sub_call_result"
88+
"sub_msg_result"
8989
],
9090
"properties": {
91-
"sub_call_result": {
91+
"sub_msg_result": {
9292
"type": "object",
9393
"required": [
9494
"id"

contracts/reflect/src/contract.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn execute(
3030
) -> Result<Response<CustomMsg>, ReflectError> {
3131
match msg {
3232
ExecuteMsg::ReflectMsg { msgs } => try_reflect(deps, env, info, msgs),
33-
ExecuteMsg::ReflectSubCall { msgs } => try_reflect_subcall(deps, env, info, msgs),
33+
ExecuteMsg::ReflectSubMsg { msgs } => try_reflect_subcall(deps, env, info, msgs),
3434
ExecuteMsg::ChangeOwner { owner } => try_change_owner(deps, env, info, owner),
3535
}
3636
}
@@ -126,7 +126,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<QueryResponse> {
126126
QueryMsg::Capitalized { text } => to_binary(&query_capitalized(deps, text)?),
127127
QueryMsg::Chain { request } => to_binary(&query_chain(deps, &request)?),
128128
QueryMsg::Raw { contract, key } => to_binary(&query_raw(deps, contract, key)?),
129-
QueryMsg::SubCallResult { id } => to_binary(&query_subcall(deps, id)?),
129+
QueryMsg::SubMsgResult { id } => to_binary(&query_subcall(deps, id)?),
130130
}
131131
}
132132

@@ -180,7 +180,7 @@ mod tests {
180180
use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR};
181181
use cosmwasm_std::{
182182
coin, coins, from_binary, AllBalanceResponse, BankMsg, BankQuery, Binary, ContractResult,
183-
Event, StakingMsg, StdError, SubcallResponse,
183+
Event, StakingMsg, StdError, SubMsgExecutionResponse,
184184
};
185185

186186
#[test]
@@ -415,7 +415,7 @@ mod tests {
415415
id,
416416
);
417417

418-
let msg = ExecuteMsg::ReflectSubCall {
418+
let msg = ExecuteMsg::ReflectSubMsg {
419419
msgs: vec![payload.clone()],
420420
};
421421
let info = mock_info("creator", &[]);
@@ -437,7 +437,7 @@ mod tests {
437437
let id = 123u64;
438438
let data = Binary::from(b"foobar");
439439
let events = vec![Event::new("message").attr("signer", "caller-addr")];
440-
let result = ContractResult::Ok(SubcallResponse {
440+
let result = ContractResult::Ok(SubMsgExecutionResponse {
441441
events: events.clone(),
442442
data: Some(data.clone()),
443443
});
@@ -449,12 +449,12 @@ mod tests {
449449
let qres = query(
450450
deps.as_ref(),
451451
mock_env(),
452-
QueryMsg::SubCallResult { id: 65432 },
452+
QueryMsg::SubMsgResult { id: 65432 },
453453
);
454454
assert!(qres.is_err());
455455

456456
// query for the real id
457-
let raw = query(deps.as_ref(), mock_env(), QueryMsg::SubCallResult { id }).unwrap();
457+
let raw = query(deps.as_ref(), mock_env(), QueryMsg::SubMsgResult { id }).unwrap();
458458
let qres: Reply = from_binary(&raw).unwrap();
459459
assert_eq!(qres.id, id);
460460
let result = qres.result.unwrap();

contracts/reflect/src/msg.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct InstantiateMsg {}
1010
#[serde(rename_all = "snake_case")]
1111
pub enum ExecuteMsg {
1212
ReflectMsg { msgs: Vec<CosmosMsg<CustomMsg>> },
13-
ReflectSubCall { msgs: Vec<SubMsg<CustomMsg>> },
13+
ReflectSubMsg { msgs: Vec<SubMsg<CustomMsg>> },
1414
ChangeOwner { owner: String },
1515
}
1616

@@ -31,8 +31,8 @@ pub enum QueryMsg {
3131
contract: String,
3232
key: Binary,
3333
},
34-
/// If there was a previous ReflectSubCall with this ID, returns cosmwasm_std::Reply
35-
SubCallResult {
34+
/// If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply
35+
SubMsgResult {
3636
id: u64,
3737
},
3838
}

contracts/reflect/tests/integration.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
use cosmwasm_std::{
2121
coin, coins, from_binary, BankMsg, Binary, Coin, ContractResult, Event, Reply, Response,
22-
StakingMsg, SubMsg, SubcallResponse, SystemResult,
22+
StakingMsg, SubMsg, SubMsgExecutionResponse, SystemResult,
2323
};
2424
use cosmwasm_vm::{
2525
testing::{
@@ -204,7 +204,7 @@ fn reflect_subcall() {
204204
id,
205205
);
206206

207-
let msg = ExecuteMsg::ReflectSubCall {
207+
let msg = ExecuteMsg::ReflectSubMsg {
208208
msgs: vec![payload.clone()],
209209
};
210210
let info = mock_info("creator", &[]);
@@ -226,7 +226,7 @@ fn reply_and_query() {
226226
let id = 123u64;
227227
let data = Binary::from(b"foobar");
228228
let events = vec![Event::new("message").attr("signer", "caller-addr")];
229-
let result = ContractResult::Ok(SubcallResponse {
229+
let result = ContractResult::Ok(SubMsgExecutionResponse {
230230
events: events.clone(),
231231
data: Some(data.clone()),
232232
});
@@ -235,11 +235,11 @@ fn reply_and_query() {
235235
assert_eq!(0, res.messages.len());
236236

237237
// query for a non-existant id
238-
let qres = query(&mut deps, mock_env(), QueryMsg::SubCallResult { id: 65432 });
238+
let qres = query(&mut deps, mock_env(), QueryMsg::SubMsgResult { id: 65432 });
239239
assert!(qres.is_err());
240240

241241
// query for the real id
242-
let raw = query(&mut deps, mock_env(), QueryMsg::SubCallResult { id }).unwrap();
242+
let raw = query(&mut deps, mock_env(), QueryMsg::SubMsgResult { id }).unwrap();
243243
let qres: Reply = from_binary(&raw).unwrap();
244244
assert_eq!(qres.id, id);
245245
let result = qres.result.unwrap();

packages/std/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ pub use crate::query::{
5353
pub use crate::query::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse};
5454
pub use crate::results::{
5555
attr, wasm_execute, wasm_instantiate, Attribute, BankMsg, ContractResult, CosmosMsg, Empty,
56-
Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubcallResponse, SystemResult, WasmMsg,
56+
Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubMsgExecutionResponse, SystemResult,
57+
WasmMsg,
5758
};
5859
#[cfg(feature = "staking")]
5960
pub use crate::results::{DistributionMsg, StakingMsg};

packages/std/src/results/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod cosmos_msg;
66
mod empty;
77
mod query;
88
mod response;
9-
mod subcall;
9+
mod submessages;
1010
mod system_result;
1111

1212
pub use attribute::{attr, Attribute};
@@ -17,5 +17,5 @@ pub use cosmos_msg::{DistributionMsg, StakingMsg};
1717
pub use empty::Empty;
1818
pub use query::QueryResponse;
1919
pub use response::Response;
20-
pub use subcall::{Event, Reply, ReplyOn, SubMsg, SubcallResponse};
20+
pub use submessages::{Event, Reply, ReplyOn, SubMsg, SubMsgExecutionResponse};
2121
pub use system_result::SystemResult;

packages/std/src/results/response.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ where
145145
mod tests {
146146
use super::super::BankMsg;
147147
use super::*;
148-
use crate::results::subcall::{ReplyOn, UNUSED_MSG_ID};
148+
use crate::results::submessages::{ReplyOn, UNUSED_MSG_ID};
149149
use crate::{coins, from_slice, to_vec};
150150

151151
#[test]

packages/std/src/results/subcall.rs packages/std/src/results/submessages.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ pub struct Reply {
107107
/// The ID that the contract set when emitting the `SubMsg`.
108108
/// Use this to identify which submessage triggered the `reply`.
109109
pub id: u64,
110-
pub result: ContractResult<SubcallResponse>,
110+
pub result: ContractResult<SubMsgExecutionResponse>,
111111
}
112112

113113
/// The information we get back from a successful sub-call, with full sdk events
114114
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
115-
pub struct SubcallResponse {
115+
pub struct SubMsgExecutionResponse {
116116
pub events: Vec<Event>,
117117
pub data: Option<Binary>,
118118
}

packages/vm/src/calls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ mod tests {
678678
mock_env, mock_info, mock_instance, MockApi, MockQuerier, MockStorage,
679679
};
680680
use cosmwasm_std::testing::{mock_ibc_channel, mock_ibc_packet_ack};
681-
use cosmwasm_std::{attr, Empty, Event, IbcOrder, Reply, ReplyOn, SubcallResponse};
681+
use cosmwasm_std::{attr, Empty, Event, IbcOrder, Reply, ReplyOn, SubMsgExecutionResponse};
682682
static CONTRACT: &[u8] = include_bytes!("../testdata/ibc_reflect.wasm");
683683
const IBC_VERSION: &str = "ibc-reflect-v1";
684684
fn setup(
@@ -717,7 +717,7 @@ mod tests {
717717
// which creates a reflect account. here we get the callback
718718
let response = Reply {
719719
id,
720-
result: ContractResult::Ok(SubcallResponse {
720+
result: ContractResult::Ok(SubMsgExecutionResponse {
721721
events: vec![event],
722722
data: None,
723723
}),

0 commit comments

Comments
 (0)