Repository: CosmWasm/cosmwasm (rust)

Issue:
Rename Event::kind -> Event::ty
`ty` seems to be a well established appreviation for `type` in Rust. It almost makes you say "type" in your head.

See https://github.com/CosmWasm/cosmwasm/pull/966#discussion_r653505769

Pull request:
Rename `Event.kind` to `Event.ty`
Closes #967

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7eda36afa..d9ce2f7a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,6 +50,7 @@ and this project adheres to
   limit to any those constructors ([#961]).
 - 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`.
 
 [#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 834eda140..4733ad3ee 100644
--- a/contracts/ibc-reflect/src/contract.rs
+++ b/contracts/ibc-reflect/src/contract.rs
@@ -50,7 +50,7 @@ pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> StdResult<Response> {
 fn parse_contract_from_event(events: Vec<Event>) -> Option<String> {
     events
         .into_iter()
-        .find(|e| e.kind == "message")
+        .find(|e| e.ty == "message")
         .and_then(|ev| {
             ev.attributes
                 .into_iter()
@@ -369,7 +369,7 @@ mod tests {
 
     fn fake_events(reflect_addr: &str) -> Vec<Event> {
         let event = Event {
-            kind: "message".into(),
+            ty: "message".into(),
             attributes: vec![
                 attr("module", "wasm"),
                 attr("signer", MOCK_CONTRACT_ADDR),
diff --git a/contracts/reflect/schema/response_for__custom_msg.json b/contracts/reflect/schema/response_for__custom_msg.json
index 5ed40b1c9..7cdacab8f 100644
--- a/contracts/reflect/schema/response_for__custom_msg.json
+++ b/contracts/reflect/schema/response_for__custom_msg.json
@@ -327,7 +327,7 @@
           }
         },
         "type": {
-          "description": "The event type. This is renamed to \"kind\" because \"type\" is reserved in Rust. This sucks, we know.",
+          "description": "The event type. This is renamed to \"ty\" because \"type\" is reserved in Rust. This sucks, we know.",
           "type": "string"
         }
       }
diff --git a/packages/std/src/results/subcall.rs b/packages/std/src/results/subcall.rs
index df073e011..3b57734a2 100644
--- a/packages/std/src/results/subcall.rs
+++ b/packages/std/src/results/subcall.rs
@@ -126,17 +126,17 @@ pub struct SubcallResponse {
 /// the Rust-Go interface, JSON deserialization and the `NewEvent` call in Cosmos SDK.
 #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
 pub struct Event {
-    /// The event type. This is renamed to "kind" because "type" is reserved in Rust. This sucks, we know.
+    /// The event type. This is renamed to "ty" because "type" is reserved in Rust. This sucks, we know.
     #[serde(rename = "type")]
-    pub kind: String,
+    pub ty: String,
     pub attributes: Vec<Attribute>,
 }
 
 impl Event {
     /// Create a new event with the given type and an empty list of attributes.
-    pub fn new(kind: impl Into<String>) -> Self {
+    pub fn new(ty: impl Into<String>) -> Self {
         Event {
-            kind: kind.into(),
+            ty: ty.into(),
             attributes: Vec::with_capacity(10),
         }
     }
@@ -159,7 +159,7 @@ mod tests {
     #[test]
     fn event_construction() {
         let event_direct = Event {
-            kind: "test".to_string(),
+            ty: "test".to_string(),
             attributes: vec![attr("foo", "bar"), attr("bar", "baz")],
         };
         let event_builder = Event::new("test").attr("foo", "bar").attr("bar", "baz");
diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs
index c2175d22b..0e55d673d 100644
--- a/packages/vm/src/calls.rs
+++ b/packages/vm/src/calls.rs
@@ -711,7 +711,7 @@ mod tests {
             assert_eq!(ReplyOn::Success, res.messages[0].reply_on);
             let id = res.messages[0].id;
             let event = Event {
-                kind: "message".into(),
+                ty: "message".into(),
                 attributes: vec![attr("contract_address", &account)],
             };
             // which creates a reflect account. here we get the callback


Test patch:
diff --git a/contracts/ibc-reflect/tests/integration.rs b/contracts/ibc-reflect/tests/integration.rs
index 6ba171e44..59e8f6b6e 100644
--- a/contracts/ibc-reflect/tests/integration.rs
+++ b/contracts/ibc-reflect/tests/integration.rs
@@ -58,7 +58,7 @@ fn setup() -> Instance<MockApi, MockStorage, MockQuerier> {
 
 fn fake_events(reflect_addr: &str) -> Vec<Event> {
     let event = Event {
-        kind: "message".into(),
+        ty: "message".into(),
         attributes: vec![
             attr("module", "wasm"),
             attr("signer", MOCK_CONTRACT_ADDR),