Skip to content

Commit 299480a

Browse files
authored
Merge pull request #971 from CosmWasm/rename-kind-to-ty
Rename `Event.kind` to `Event.ty`
2 parents 3cea0ae + 820c038 commit 299480a

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ and this project adheres to
5050
limit to any those constructors ([#961]).
5151
- cosmwasm-std: Change `Event`'s constructor - it no longer takes a vector of
5252
attributes and instead constructs an empty one
53+
- cosmwasm-std: Rename `Event.kind` to `Event.ty`.
5354

5455
[#961]: https://github.com/CosmWasm/cosmwasm/pull/961
5556

contracts/ibc-reflect/src/contract.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> StdResult<Response> {
5050
fn parse_contract_from_event(events: Vec<Event>) -> Option<String> {
5151
events
5252
.into_iter()
53-
.find(|e| e.kind == "message")
53+
.find(|e| e.ty == "message")
5454
.and_then(|ev| {
5555
ev.attributes
5656
.into_iter()
@@ -369,7 +369,7 @@ mod tests {
369369

370370
fn fake_events(reflect_addr: &str) -> Vec<Event> {
371371
let event = Event {
372-
kind: "message".into(),
372+
ty: "message".into(),
373373
attributes: vec![
374374
attr("module", "wasm"),
375375
attr("signer", MOCK_CONTRACT_ADDR),

contracts/ibc-reflect/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn setup() -> Instance<MockApi, MockStorage, MockQuerier> {
5858

5959
fn fake_events(reflect_addr: &str) -> Vec<Event> {
6060
let event = Event {
61-
kind: "message".into(),
61+
ty: "message".into(),
6262
attributes: vec![
6363
attr("module", "wasm"),
6464
attr("signer", MOCK_CONTRACT_ADDR),

contracts/reflect/schema/response_for__custom_msg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
}
328328
},
329329
"type": {
330-
"description": "The event type. This is renamed to \"kind\" because \"type\" is reserved in Rust. This sucks, we know.",
330+
"description": "The event type. This is renamed to \"ty\" because \"type\" is reserved in Rust. This sucks, we know.",
331331
"type": "string"
332332
}
333333
}

packages/std/src/results/subcall.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,17 @@ pub struct SubcallResponse {
126126
/// the Rust-Go interface, JSON deserialization and the `NewEvent` call in Cosmos SDK.
127127
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
128128
pub struct Event {
129-
/// The event type. This is renamed to "kind" because "type" is reserved in Rust. This sucks, we know.
129+
/// The event type. This is renamed to "ty" because "type" is reserved in Rust. This sucks, we know.
130130
#[serde(rename = "type")]
131-
pub kind: String,
131+
pub ty: String,
132132
pub attributes: Vec<Attribute>,
133133
}
134134

135135
impl Event {
136136
/// Create a new event with the given type and an empty list of attributes.
137-
pub fn new(kind: impl Into<String>) -> Self {
137+
pub fn new(ty: impl Into<String>) -> Self {
138138
Event {
139-
kind: kind.into(),
139+
ty: ty.into(),
140140
attributes: Vec::with_capacity(10),
141141
}
142142
}
@@ -159,7 +159,7 @@ mod tests {
159159
#[test]
160160
fn event_construction() {
161161
let event_direct = Event {
162-
kind: "test".to_string(),
162+
ty: "test".to_string(),
163163
attributes: vec![attr("foo", "bar"), attr("bar", "baz")],
164164
};
165165
let event_builder = Event::new("test").attr("foo", "bar").attr("bar", "baz");

packages/vm/src/calls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ mod tests {
711711
assert_eq!(ReplyOn::Success, res.messages[0].reply_on);
712712
let id = res.messages[0].id;
713713
let event = Event {
714-
kind: "message".into(),
714+
ty: "message".into(),
715715
attributes: vec![attr("contract_address", &account)],
716716
};
717717
// which creates a reflect account. here we get the callback

0 commit comments

Comments
 (0)