Repository: CosmWasm/cosmwasm (rust)

Issue:
Rename SubcallResponse
As recently described very well in https://twitter.com/larry0x/status/1402171906988642304, we are not doing calls.

The struct is a response of an execution of a submessage. This we need to find a nice name for.

- [ ] `SubcallResponse` -> `SubMsgExecutionResponse`
- [ ] In `contracts/reflect/src/msg.rs`: `ReflectSubCall`/`SubCallResult` 
- [ ] Filename `packages/std/src/results/subcall.rs` -> `submessages.rs`

Pull request description:
Rename subcall to submsg
Closes #942 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d9ce2f7a7..751fb1968 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -51,6 +51,10 @@ and this project adheres to
 - cosmwasm-std: Change `Event`'s constructor - it no longer takes a vector of
   attributes and instead constructs an empty one
 - cosmwasm-std: Rename `Event.kind` to `Event.ty`.
+- cosmwasm-std: Rename `SubcallResponse` to `SubMsgExecutionResponse`.
+- contracts: Rename `ReflectSubCall` to `ReflectSubMsg` and `SubCallResult` to
+  `SubCallMsg` in the `reflect` contract.
+- cosmwasm-std: Rename the `subcall` module to `submessages`.
 
 [#961]: https://github.com/CosmWasm/cosmwasm/pull/961
 
diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs
index 4733ad3ee..c282b4f50 100644
--- a/contracts/ibc-reflect/src/contract.rs
+++ b/contracts/ibc-reflect/src/contract.rs
@@ -2,7 +2,7 @@ use cosmwasm_std::{
     attr, entry_point, from_slice, to_binary, wasm_execute, BankMsg, Binary, ContractResult,
     CosmosMsg, Deps, DepsMut, Empty, Env, Event, IbcAcknowledgement, IbcBasicResponse, IbcChannel,
     IbcOrder, IbcPacket, IbcReceiveResponse, MessageInfo, Order, QueryResponse, Reply, Response,
-    StdError, StdResult, SubMsg, SubcallResponse, WasmMsg,
+    StdError, StdResult, SubMsg, SubMsgExecutionResponse, WasmMsg,
 };
 
 use crate::msg::{
@@ -59,7 +59,10 @@ fn parse_contract_from_event(events: Vec<Event>) -> Option<String> {
         .map(|a| a.value)
 }
 
-pub fn handle_init_callback(deps: DepsMut, response: SubcallResponse) -> StdResult<Response> {
+pub fn handle_init_callback(
+    deps: DepsMut,
+    response: SubMsgExecutionResponse,
+) -> StdResult<Response> {
     // we use storage to pass info from the caller to the reply
     let id = pending_channel(deps.storage).load()?;
     pending_channel(deps.storage).remove();
@@ -401,7 +404,7 @@ mod tests {
         // fake a reply and ensure this works
         let response = Reply {
             id,
-            result: ContractResult::Ok(SubcallResponse {
+            result: ContractResult::Ok(SubMsgExecutionResponse {
                 events: fake_events(&account),
                 data: None,
             }),
@@ -475,7 +478,7 @@ mod tests {
         // fake a reply and ensure this works
         let response = Reply {
             id,
-            result: ContractResult::Ok(SubcallResponse {
+            result: ContractResult::Ok(SubMsgExecutionResponse {
                 events: fake_events(&REFLECT_ADDR),
                 data: None,
             }),
diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json
index 4c42b6a50..6a0515028 100644
--- a/contracts/reflect/schema/execute_msg.json
+++ b/contracts/reflect/schema/execute_msg.json
@@ -28,10 +28,10 @@
     {
       "type": "object",
       "required": [
-        "reflect_sub_call"
+        "reflect_sub_msg"
       ],
       "properties": {
-        "reflect_sub_call": {
+        "reflect_sub_msg": {
           "type": "object",
           "required": [
             "msgs"
diff --git a/contracts/reflect/schema/query_msg.json b/contracts/reflect/schema/query_msg.json
index d8ddf1f7b..7084cacd9 100644
--- a/contracts/reflect/schema/query_msg.json
+++ b/contracts/reflect/schema/query_msg.json
@@ -82,13 +82,13 @@
       "additionalProperties": false
     },
     {
-      "description": "If there was a previous ReflectSubCall with this ID, returns cosmwasm_std::Reply",
+      "description": "If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply",
       "type": "object",
       "required": [
-        "sub_call_result"
+        "sub_msg_result"
       ],
       "properties": {
-        "sub_call_result": {
+        "sub_msg_result": {
           "type": "object",
           "required": [
             "id"
diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs
index 2ab0f14f7..fa15f0a78 100644
--- a/contracts/reflect/src/contract.rs
+++ b/contracts/reflect/src/contract.rs
@@ -30,7 +30,7 @@ pub fn execute(
 ) -> Result<Response<CustomMsg>, ReflectError> {
     match msg {
         ExecuteMsg::ReflectMsg { msgs } => try_reflect(deps, env, info, msgs),
-        ExecuteMsg::ReflectSubCall { msgs } => try_reflect_subcall(deps, env, info, msgs),
+        ExecuteMsg::ReflectSubMsg { msgs } => try_reflect_subcall(deps, env, info, msgs),
         ExecuteMsg::ChangeOwner { owner } => try_change_owner(deps, env, info, owner),
     }
 }
@@ -126,7 +126,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<QueryResponse> {
         QueryMsg::Capitalized { text } => to_binary(&query_capitalized(deps, text)?),
         QueryMsg::Chain { request } => to_binary(&query_chain(deps, &request)?),
         QueryMsg::Raw { contract, key } => to_binary(&query_raw(deps, contract, key)?),
-        QueryMsg::SubCallResult { id } => to_binary(&query_subcall(deps, id)?),
+        QueryMsg::SubMsgResult { id } => to_binary(&query_subcall(deps, id)?),
     }
 }
 
@@ -180,7 +180,7 @@ mod tests {
     use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR};
     use cosmwasm_std::{
         coin, coins, from_binary, AllBalanceResponse, BankMsg, BankQuery, Binary, ContractResult,
-        Event, StakingMsg, StdError, SubcallResponse,
+        Event, StakingMsg, StdError, SubMsgExecutionResponse,
     };
 
     #[test]
@@ -415,7 +415,7 @@ mod tests {
             id,
         );
 
-        let msg = ExecuteMsg::ReflectSubCall {
+        let msg = ExecuteMsg::ReflectSubMsg {
             msgs: vec![payload.clone()],
         };
         let info = mock_info("creator", &[]);
@@ -437,7 +437,7 @@ mod tests {
         let id = 123u64;
         let data = Binary::from(b"foobar");
         let events = vec![Event::new("message").attr("signer", "caller-addr")];
-        let result = ContractResult::Ok(SubcallResponse {
+        let result = ContractResult::Ok(SubMsgExecutionResponse {
             events: events.clone(),
             data: Some(data.clone()),
         });
@@ -449,12 +449,12 @@ mod tests {
         let qres = query(
             deps.as_ref(),
             mock_env(),
-            QueryMsg::SubCallResult { id: 65432 },
+            QueryMsg::SubMsgResult { id: 65432 },
         );
         assert!(qres.is_err());
 
         // query for the real id
-        let raw = query(deps.as_ref(), mock_env(), QueryMsg::SubCallResult { id }).unwrap();
+        let raw = query(deps.as_ref(), mock_env(), QueryMsg::SubMsgResult { id }).unwrap();
         let qres: Reply = from_binary(&raw).unwrap();
         assert_eq!(qres.id, id);
         let result = qres.result.unwrap();
diff --git a/contracts/reflect/src/msg.rs b/contracts/reflect/src/msg.rs
index f3c488822..6098e8568 100644
--- a/contracts/reflect/src/msg.rs
+++ b/contracts/reflect/src/msg.rs
@@ -10,7 +10,7 @@ pub struct InstantiateMsg {}
 #[serde(rename_all = "snake_case")]
 pub enum ExecuteMsg {
     ReflectMsg { msgs: Vec<CosmosMsg<CustomMsg>> },
-    ReflectSubCall { msgs: Vec<SubMsg<CustomMsg>> },
+    ReflectSubMsg { msgs: Vec<SubMsg<CustomMsg>> },
     ChangeOwner { owner: String },
 }
 
@@ -31,8 +31,8 @@ pub enum QueryMsg {
         contract: String,
         key: Binary,
     },
-    /// If there was a previous ReflectSubCall with this ID, returns cosmwasm_std::Reply
-    SubCallResult {
+    /// If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply
+    SubMsgResult {
         id: u64,
     },
 }
diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs
index 0cfa80fdb..30a5207e7 100644
--- a/packages/std/src/lib.rs
+++ b/packages/std/src/lib.rs
@@ -53,7 +53,8 @@ pub use crate::query::{
 pub use crate::query::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse};
 pub use crate::results::{
     attr, wasm_execute, wasm_instantiate, Attribute, BankMsg, ContractResult, CosmosMsg, Empty,
-    Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubcallResponse, SystemResult, WasmMsg,
+    Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubMsgExecutionResponse, SystemResult,
+    WasmMsg,
 };
 #[cfg(feature = "staking")]
 pub use crate::results::{DistributionMsg, StakingMsg};
diff --git a/packages/std/src/results/mod.rs b/packages/std/src/results/mod.rs
index ac2057bef..6321503f7 100644
--- a/packages/std/src/results/mod.rs
+++ b/packages/std/src/results/mod.rs
@@ -6,7 +6,7 @@ mod cosmos_msg;
 mod empty;
 mod query;
 mod response;
-mod subcall;
+mod submessages;
 mod system_result;
 
 pub use attribute::{attr, Attribute};
@@ -17,5 +17,5 @@ pub use cosmos_msg::{DistributionMsg, StakingMsg};
 pub use empty::Empty;
 pub use query::QueryResponse;
 pub use response::Response;
-pub use subcall::{Event, Reply, ReplyOn, SubMsg, SubcallResponse};
+pub use submessages::{Event, Reply, ReplyOn, SubMsg, SubMsgExecutionResponse};
 pub use system_result::SystemResult;
diff --git a/packages/std/src/results/response.rs b/packages/std/src/results/response.rs
index 64272b27e..d105a4095 100644
--- a/packages/std/src/results/response.rs
+++ b/packages/std/src/results/response.rs
@@ -145,7 +145,7 @@ where
 mod tests {
     use super::super::BankMsg;
     use super::*;
-    use crate::results::subcall::{ReplyOn, UNUSED_MSG_ID};
+    use crate::results::submessages::{ReplyOn, UNUSED_MSG_ID};
     use crate::{coins, from_slice, to_vec};
 
     #[test]
diff --git a/packages/std/src/results/subcall.rs b/packages/std/src/results/submessages.rs
similarity index 98%
rename from packages/std/src/results/subcall.rs
rename to packages/std/src/results/submessages.rs
index 3b57734a2..e2e6157c0 100644
--- a/packages/std/src/results/subcall.rs
+++ b/packages/std/src/results/submessages.rs
@@ -107,12 +107,12 @@ pub struct Reply {
     /// The ID that the contract set when emitting the `SubMsg`.
     /// Use this to identify which submessage triggered the `reply`.
     pub id: u64,
-    pub result: ContractResult<SubcallResponse>,
+    pub result: ContractResult<SubMsgExecutionResponse>,
 }
 
 /// The information we get back from a successful sub-call, with full sdk events
 #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
-pub struct SubcallResponse {
+pub struct SubMsgExecutionResponse {
     pub events: Vec<Event>,
     pub data: Option<Binary>,
 }
diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs
index 0e55d673d..a07d70f89 100644
--- a/packages/vm/src/calls.rs
+++ b/packages/vm/src/calls.rs
@@ -678,7 +678,7 @@ mod tests {
             mock_env, mock_info, mock_instance, MockApi, MockQuerier, MockStorage,
         };
         use cosmwasm_std::testing::{mock_ibc_channel, mock_ibc_packet_ack};
-        use cosmwasm_std::{attr, Empty, Event, IbcOrder, Reply, ReplyOn, SubcallResponse};
+        use cosmwasm_std::{attr, Empty, Event, IbcOrder, Reply, ReplyOn, SubMsgExecutionResponse};
         static CONTRACT: &[u8] = include_bytes!("../testdata/ibc_reflect.wasm");
         const IBC_VERSION: &str = "ibc-reflect-v1";
         fn setup(
@@ -717,7 +717,7 @@ mod tests {
             // which creates a reflect account. here we get the callback
             let response = Reply {
                 id,
-                result: ContractResult::Ok(SubcallResponse {
+                result: ContractResult::Ok(SubMsgExecutionResponse {
                     events: vec![event],
                     data: None,
                 }),


Test patch:
diff --git a/contracts/ibc-reflect/tests/integration.rs b/contracts/ibc-reflect/tests/integration.rs
index 59e8f6b6e..e1f3e07ff 100644
--- a/contracts/ibc-reflect/tests/integration.rs
+++ b/contracts/ibc-reflect/tests/integration.rs
@@ -20,7 +20,7 @@
 use cosmwasm_std::testing::{mock_ibc_channel, mock_ibc_packet_recv};
 use cosmwasm_std::{
     attr, coins, BankMsg, ContractResult, CosmosMsg, Event, IbcBasicResponse, IbcOrder,
-    IbcReceiveResponse, Reply, Response, SubcallResponse, WasmMsg,
+    IbcReceiveResponse, Reply, Response, SubMsgExecutionResponse, WasmMsg,
 };
 use cosmwasm_vm::testing::{
     ibc_channel_connect, ibc_channel_open, ibc_packet_receive, instantiate, mock_env, mock_info,
@@ -91,7 +91,7 @@ fn connect<T: Into<String>>(
     // fake a reply and ensure this works
     let response = Reply {
         id,
-        result: ContractResult::Ok(SubcallResponse {
+        result: ContractResult::Ok(SubMsgExecutionResponse {
             events: fake_events(&account),
             data: None,
         }),
@@ -167,7 +167,7 @@ fn proper_handshake_flow() {
     // we get the callback from reflect
     let response = Reply {
         id,
-        result: ContractResult::Ok(SubcallResponse {
+        result: ContractResult::Ok(SubMsgExecutionResponse {
             events: fake_events(&REFLECT_ADDR),
             data: None,
         }),
diff --git a/contracts/reflect/tests/integration.rs b/contracts/reflect/tests/integration.rs
index 2f4005f59..8e113c830 100644
--- a/contracts/reflect/tests/integration.rs
+++ b/contracts/reflect/tests/integration.rs
@@ -19,7 +19,7 @@
 
 use cosmwasm_std::{
     coin, coins, from_binary, BankMsg, Binary, Coin, ContractResult, Event, Reply, Response,
-    StakingMsg, SubMsg, SubcallResponse, SystemResult,
+    StakingMsg, SubMsg, SubMsgExecutionResponse, SystemResult,
 };
 use cosmwasm_vm::{
     testing::{
@@ -204,7 +204,7 @@ fn reflect_subcall() {
         id,
     );
 
-    let msg = ExecuteMsg::ReflectSubCall {
+    let msg = ExecuteMsg::ReflectSubMsg {
         msgs: vec![payload.clone()],
     };
     let info = mock_info("creator", &[]);
@@ -226,7 +226,7 @@ fn reply_and_query() {
     let id = 123u64;
     let data = Binary::from(b"foobar");
     let events = vec![Event::new("message").attr("signer", "caller-addr")];
-    let result = ContractResult::Ok(SubcallResponse {
+    let result = ContractResult::Ok(SubMsgExecutionResponse {
         events: events.clone(),
         data: Some(data.clone()),
     });
@@ -235,11 +235,11 @@ fn reply_and_query() {
     assert_eq!(0, res.messages.len());
 
     // query for a non-existant id
-    let qres = query(&mut deps, mock_env(), QueryMsg::SubCallResult { id: 65432 });
+    let qres = query(&mut deps, mock_env(), QueryMsg::SubMsgResult { id: 65432 });
     assert!(qres.is_err());
 
     // query for the real id
-    let raw = query(&mut deps, mock_env(), QueryMsg::SubCallResult { id }).unwrap();
+    let raw = query(&mut deps, mock_env(), QueryMsg::SubMsgResult { id }).unwrap();
     let qres: Reply = from_binary(&raw).unwrap();
     assert_eq!(qres.id, id);
     let result = qres.result.unwrap();