Skip to content

Commit 2b7d8b7

Browse files
authored
Revert "Add conversion from &IbcEvent to abci::Event (#438)" (#494)
This reverts commit 66972bd.
1 parent 66972bd commit 2b7d8b7

File tree

7 files changed

+239
-248
lines changed

7 files changed

+239
-248
lines changed

.changelog/unreleased/breaking-changes/416-conver-ref-ibc_event2abci_event.md

-2
This file was deleted.

crates/ibc/src/core/ics02_client/events.rs

+40-48
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ struct ClientIdAttribute {
4343
client_id: ClientId,
4444
}
4545

46-
impl From<&ClientIdAttribute> for abci::EventAttribute {
47-
fn from(attr: &ClientIdAttribute) -> Self {
46+
impl From<ClientIdAttribute> for abci::EventAttribute {
47+
fn from(attr: ClientIdAttribute) -> Self {
4848
(CLIENT_ID_ATTRIBUTE_KEY, attr.client_id.as_str()).into()
4949
}
5050
}
@@ -67,8 +67,8 @@ struct ClientTypeAttribute {
6767
client_type: ClientType,
6868
}
6969

70-
impl From<&ClientTypeAttribute> for abci::EventAttribute {
71-
fn from(attr: &ClientTypeAttribute) -> Self {
70+
impl From<ClientTypeAttribute> for abci::EventAttribute {
71+
fn from(attr: ClientTypeAttribute) -> Self {
7272
(CLIENT_TYPE_ATTRIBUTE_KEY, attr.client_type.as_str()).into()
7373
}
7474
}
@@ -91,8 +91,8 @@ struct ConsensusHeightAttribute {
9191
consensus_height: Height,
9292
}
9393

94-
impl From<&ConsensusHeightAttribute> for abci::EventAttribute {
95-
fn from(attr: &ConsensusHeightAttribute) -> Self {
94+
impl From<ConsensusHeightAttribute> for abci::EventAttribute {
95+
fn from(attr: ConsensusHeightAttribute) -> Self {
9696
(CONSENSUS_HEIGHT_ATTRIBUTE_KEY, attr.consensus_height).into()
9797
}
9898
}
@@ -115,11 +115,11 @@ struct ConsensusHeightsAttribute {
115115
consensus_heights: Vec<Height>,
116116
}
117117

118-
impl From<&ConsensusHeightsAttribute> for abci::EventAttribute {
119-
fn from(attr: &ConsensusHeightsAttribute) -> Self {
118+
impl From<ConsensusHeightsAttribute> for abci::EventAttribute {
119+
fn from(attr: ConsensusHeightsAttribute) -> Self {
120120
let consensus_heights: Vec<String> = attr
121121
.consensus_heights
122-
.iter()
122+
.into_iter()
123123
.map(|consensus_height| consensus_height.to_string())
124124
.collect();
125125
(CONSENSUS_HEIGHTS_ATTRIBUTE_KEY, consensus_heights.join(",")).into()
@@ -144,11 +144,11 @@ struct HeaderAttribute {
144144
header: Any,
145145
}
146146

147-
impl From<&HeaderAttribute> for abci::EventAttribute {
148-
fn from(attr: &HeaderAttribute) -> Self {
147+
impl From<HeaderAttribute> for abci::EventAttribute {
148+
fn from(attr: HeaderAttribute) -> Self {
149149
(
150150
HEADER_ATTRIBUTE_KEY,
151-
String::from_utf8(hex::encode(&attr.header.value)).unwrap(),
151+
String::from_utf8(hex::encode(attr.header.value)).unwrap(),
152152
)
153153
.into()
154154
}
@@ -197,14 +197,14 @@ impl CreateClient {
197197
}
198198
}
199199

200-
impl From<&CreateClient> for abci::Event {
201-
fn from(c: &CreateClient) -> Self {
200+
impl From<CreateClient> for abci::Event {
201+
fn from(c: CreateClient) -> Self {
202202
Self {
203203
kind: IbcEventType::CreateClient.as_str().to_owned(),
204204
attributes: vec![
205-
abci::EventAttribute::from(&c.client_id),
206-
abci::EventAttribute::from(&c.client_type),
207-
abci::EventAttribute::from(&c.consensus_height),
205+
c.client_id.into(),
206+
c.client_type.into(),
207+
c.consensus_height.into(),
208208
],
209209
}
210210
}
@@ -273,16 +273,16 @@ impl UpdateClient {
273273
}
274274
}
275275

276-
impl From<&UpdateClient> for abci::Event {
277-
fn from(u: &UpdateClient) -> Self {
276+
impl From<UpdateClient> for abci::Event {
277+
fn from(u: UpdateClient) -> Self {
278278
Self {
279279
kind: IbcEventType::UpdateClient.as_str().to_owned(),
280280
attributes: vec![
281-
abci::EventAttribute::from(&u.client_id),
282-
abci::EventAttribute::from(&u.client_type),
283-
abci::EventAttribute::from(&u.consensus_height),
284-
abci::EventAttribute::from(&u.consensus_heights),
285-
abci::EventAttribute::from(&u.header),
281+
u.client_id.into(),
282+
u.client_type.into(),
283+
u.consensus_height.into(),
284+
u.consensus_heights.into(),
285+
u.header.into(),
286286
],
287287
}
288288
}
@@ -326,14 +326,11 @@ impl ClientMisbehaviour {
326326
}
327327
}
328328

329-
impl From<&ClientMisbehaviour> for abci::Event {
330-
fn from(c: &ClientMisbehaviour) -> Self {
329+
impl From<ClientMisbehaviour> for abci::Event {
330+
fn from(c: ClientMisbehaviour) -> Self {
331331
Self {
332332
kind: IbcEventType::ClientMisbehaviour.as_str().to_owned(),
333-
attributes: vec![
334-
abci::EventAttribute::from(&c.client_id),
335-
abci::EventAttribute::from(&c.client_type),
336-
],
333+
attributes: vec![c.client_id.into(), c.client_type.into()],
337334
}
338335
}
339336
}
@@ -381,14 +378,14 @@ impl UpgradeClient {
381378
}
382379
}
383380

384-
impl From<&UpgradeClient> for abci::Event {
385-
fn from(u: &UpgradeClient) -> Self {
381+
impl From<UpgradeClient> for abci::Event {
382+
fn from(u: UpgradeClient) -> Self {
386383
Self {
387384
kind: IbcEventType::UpgradeClient.as_str().to_owned(),
388385
attributes: vec![
389-
abci::EventAttribute::from(&u.client_id),
390-
abci::EventAttribute::from(&u.client_type),
391-
abci::EventAttribute::from(&u.consensus_height),
386+
u.client_id.into(),
387+
u.client_type.into(),
388+
u.consensus_height.into(),
392389
],
393390
}
394391
}
@@ -437,39 +434,34 @@ mod tests {
437434
let tests: Vec<Test> = vec![
438435
Test {
439436
kind: IbcEventType::CreateClient,
440-
event: AbciEvent::from(&CreateClient::new(
441-
client_id.clone(),
442-
client_type.clone(),
443-
consensus_height,
444-
)),
437+
event: CreateClient::new(client_id.clone(), client_type.clone(), consensus_height)
438+
.into(),
445439
expected_keys: expected_keys[0..3].to_vec(),
446440
expected_values: expected_values[0..3].to_vec(),
447441
},
448442
Test {
449443
kind: IbcEventType::UpdateClient,
450-
event: AbciEvent::from(&UpdateClient::new(
444+
event: UpdateClient::new(
451445
client_id.clone(),
452446
client_type.clone(),
453447
consensus_height,
454448
consensus_heights,
455449
header,
456-
)),
450+
)
451+
.into(),
457452
expected_keys: expected_keys.clone(),
458453
expected_values: expected_values.clone(),
459454
},
460455
Test {
461456
kind: IbcEventType::UpgradeClient,
462-
event: AbciEvent::from(&UpgradeClient::new(
463-
client_id.clone(),
464-
client_type.clone(),
465-
consensus_height,
466-
)),
457+
event: UpgradeClient::new(client_id.clone(), client_type.clone(), consensus_height)
458+
.into(),
467459
expected_keys: expected_keys[0..3].to_vec(),
468460
expected_values: expected_values[0..3].to_vec(),
469461
},
470462
Test {
471463
kind: IbcEventType::ClientMisbehaviour,
472-
event: AbciEvent::from(&ClientMisbehaviour::new(client_id, client_type)),
464+
event: ClientMisbehaviour::new(client_id, client_type).into(),
473465
expected_keys: expected_keys[0..2].to_vec(),
474466
expected_values: expected_values[0..2].to_vec(),
475467
},

crates/ibc/src/core/ics03_connection/events.rs

+25-26
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ struct Attributes {
3434
}
3535

3636
/// Convert attributes to Tendermint ABCI tags
37-
impl From<&Attributes> for Vec<abci::EventAttribute> {
38-
fn from(a: &Attributes) -> Self {
37+
impl From<Attributes> for Vec<abci::EventAttribute> {
38+
fn from(a: Attributes) -> Self {
3939
let conn_id = (CONN_ID_ATTRIBUTE_KEY, a.connection_id.as_str()).into();
4040
let client_id = (CLIENT_ID_ATTRIBUTE_KEY, a.client_id.as_str()).into();
4141

@@ -108,11 +108,11 @@ impl OpenInit {
108108
}
109109
}
110110

111-
impl From<&OpenInit> for abci::Event {
112-
fn from(v: &OpenInit) -> Self {
111+
impl From<OpenInit> for abci::Event {
112+
fn from(v: OpenInit) -> Self {
113113
abci::Event {
114114
kind: IbcEventType::OpenInitConnection.as_str().to_owned(),
115-
attributes: Vec::<abci::EventAttribute>::from(&v.0),
115+
attributes: v.0.into(),
116116
}
117117
}
118118
}
@@ -163,11 +163,11 @@ impl OpenTry {
163163
}
164164
}
165165

166-
impl From<&OpenTry> for abci::Event {
167-
fn from(v: &OpenTry) -> Self {
166+
impl From<OpenTry> for abci::Event {
167+
fn from(v: OpenTry) -> Self {
168168
abci::Event {
169169
kind: IbcEventType::OpenTryConnection.as_str().to_owned(),
170-
attributes: Vec::<abci::EventAttribute>::from(&v.0),
170+
attributes: v.0.into(),
171171
}
172172
}
173173
}
@@ -218,11 +218,11 @@ impl OpenAck {
218218
}
219219
}
220220

221-
impl From<&OpenAck> for abci::Event {
222-
fn from(v: &OpenAck) -> Self {
221+
impl From<OpenAck> for abci::Event {
222+
fn from(v: OpenAck) -> Self {
223223
abci::Event {
224224
kind: IbcEventType::OpenAckConnection.as_str().to_owned(),
225-
attributes: Vec::<abci::EventAttribute>::from(&v.0),
225+
attributes: v.0.into(),
226226
}
227227
}
228228
}
@@ -273,11 +273,11 @@ impl OpenConfirm {
273273
}
274274
}
275275

276-
impl From<&OpenConfirm> for abci::Event {
277-
fn from(v: &OpenConfirm) -> Self {
276+
impl From<OpenConfirm> for abci::Event {
277+
fn from(v: OpenConfirm) -> Self {
278278
abci::Event {
279279
kind: IbcEventType::OpenConfirmConnection.as_str().to_owned(),
280-
attributes: Vec::<abci::EventAttribute>::from(&v.0),
280+
attributes: v.0.into(),
281281
}
282282
}
283283
}
@@ -318,11 +318,12 @@ mod tests {
318318
let tests: Vec<Test> = vec![
319319
Test {
320320
kind: IbcEventType::OpenInitConnection,
321-
event: AbciEvent::from(&OpenInit::new(
321+
event: OpenInit::new(
322322
conn_id_on_a.clone(),
323323
client_id_on_a.clone(),
324324
client_id_on_b.clone(),
325-
)),
325+
)
326+
.into(),
326327
expected_keys: expected_keys.clone(),
327328
expected_values: expected_values
328329
.iter()
@@ -332,34 +333,32 @@ mod tests {
332333
},
333334
Test {
334335
kind: IbcEventType::OpenTryConnection,
335-
event: AbciEvent::from(&OpenTry::new(
336+
event: OpenTry::new(
336337
conn_id_on_b.clone(),
337338
client_id_on_b.clone(),
338339
conn_id_on_a.clone(),
339340
client_id_on_a.clone(),
340-
)),
341+
)
342+
.into(),
341343
expected_keys: expected_keys.clone(),
342344
expected_values: expected_values.iter().rev().cloned().collect(),
343345
},
344346
Test {
345347
kind: IbcEventType::OpenAckConnection,
346-
event: AbciEvent::from(&OpenAck::new(
348+
event: OpenAck::new(
347349
conn_id_on_a.clone(),
348350
client_id_on_a.clone(),
349351
conn_id_on_b.clone(),
350352
client_id_on_b.clone(),
351-
)),
353+
)
354+
.into(),
352355
expected_keys: expected_keys.clone(),
353356
expected_values: expected_values.clone(),
354357
},
355358
Test {
356359
kind: IbcEventType::OpenConfirmConnection,
357-
event: AbciEvent::from(&OpenConfirm::new(
358-
conn_id_on_b,
359-
client_id_on_b,
360-
conn_id_on_a,
361-
client_id_on_a,
362-
)),
360+
event: OpenConfirm::new(conn_id_on_b, client_id_on_b, conn_id_on_a, client_id_on_a)
361+
.into(),
363362
expected_keys: expected_keys.clone(),
364363
expected_values: expected_values.iter().rev().cloned().collect(),
365364
},

0 commit comments

Comments
 (0)