Skip to content

Commit d46ff9c

Browse files
committed
feat/upgrade-rust-version
1 parent c277c32 commit d46ff9c

File tree

30 files changed

+508
-320
lines changed

30 files changed

+508
-320
lines changed

Cargo.lock

+338-150
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/client.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,9 @@ impl<'a> CwIbcCoreContext<'a> {
298298
.may_load(store, client_type)
299299
{
300300
Ok(result) => match result {
301-
Some(_) => Err(ClientError::Other {
301+
Some(_) => Err(Into::<ContractError>::into(ClientError::Other {
302302
description: "Client Implementation Already Exist".to_string(),
303-
})
304-
.map_err(Into::<ContractError>::into),
303+
})),
305304

306305
None => Ok(()),
307306
},
@@ -332,10 +331,9 @@ impl<'a> CwIbcCoreContext<'a> {
332331
let client = self.get_client_implementations(store, client_id).ok();
333332

334333
if client.is_none() {
335-
return Err(ClientError::ClientSpecific {
334+
return Err(Into::<ContractError>::into(ClientError::ClientSpecific {
336335
description: "LightclientNotFount".to_string(),
337-
})
338-
.map_err(Into::<ContractError>::into);
336+
}));
339337
}
340338
Ok(client.unwrap())
341339
}
@@ -408,7 +406,7 @@ impl<'a> CwIbcCoreContext<'a> {
408406
client_id: &common::ibc::core::ics24_host::identifier::ClientId,
409407
) -> Result<Box<dyn IClientState>, ContractError> {
410408
let light_client = self.get_light_client(deps.storage, client_id)?;
411-
return light_client.get_client_state(deps, client_id);
409+
light_client.get_client_state(deps, client_id)
412410
}
413411

414412
pub fn client_state_any(
@@ -428,7 +426,7 @@ impl<'a> CwIbcCoreContext<'a> {
428426
) -> Result<Box<dyn IConsensusState>, ContractError> {
429427
let client_impl = self.get_light_client(deps.storage, client_id)?;
430428
let height = height.revision_height();
431-
return client_impl.get_consensus_state(deps, client_id, height);
429+
client_impl.get_consensus_state(deps, client_id, height)
432430
}
433431

434432
pub fn consensus_state_any(

contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs

+27-26
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,9 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> {
139139
let client_state = self.client_state(deps.as_ref(), &client_id)?;
140140

141141
if client_state.is_frozen() {
142-
return Err(ClientError::ClientFrozen {
142+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
143143
client_id: client_id.clone(),
144-
})
145-
.map_err(Into::<ContractError>::into);
144+
}));
146145
}
147146

148147
self.store_callback_data(deps.storage, EXECUTE_UPDATE_CLIENT, &client_id)?;
@@ -195,10 +194,9 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> {
195194
})?;
196195

197196
if old_client_state.is_frozen() {
198-
return Err(ClientError::ClientFrozen {
197+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
199198
client_id: client_id.clone(),
200-
})
201-
.map_err(Into::<ContractError>::into);
199+
}));
202200
}
203201

204202
let old_consensus_state =
@@ -214,11 +212,12 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> {
214212
.map_err(Into::<ContractError>::into)?;
215213

216214
if old_client_state.expired(duration) {
217-
return Err(ClientError::HeaderNotWithinTrustPeriod {
218-
latest_time: old_consensus_state.timestamp(),
219-
update_time: now,
220-
})
221-
.map_err(Into::<ContractError>::into);
215+
return Err(Into::<ContractError>::into(
216+
ClientError::HeaderNotWithinTrustPeriod {
217+
latest_time: old_consensus_state.timestamp(),
218+
update_time: now,
219+
},
220+
));
222221
};
223222

224223
let wasm_exec_message = LightClientMessage::UpgradeClient {
@@ -354,13 +353,14 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> {
354353
.add_attribute("methods", "execute_update_client_reply")
355354
.add_attribute("height", height))
356355
}
357-
None => Err(ClientError::Other {
356+
None => Err(Into::<ContractError>::into(ClientError::Other {
358357
description: "UNKNOWN ERROR".to_string(),
359-
})
360-
.map_err(Into::<ContractError>::into),
358+
})),
361359
},
362360
cosmwasm_std::SubMsgResult::Err(error) => {
363-
Err(ClientError::Other { description: error }).map_err(Into::<ContractError>::into)
361+
Err(Into::<ContractError>::into(ClientError::Other {
362+
description: error,
363+
}))
364364
}
365365
}
366366
}
@@ -417,13 +417,14 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> {
417417
.add_attribute("method", "execute_upgrade_client_reply")
418418
.add_attribute("client_id", client_id.as_str()))
419419
}
420-
None => Err(ClientError::Other {
420+
None => Err(Into::<ContractError>::into(ClientError::Other {
421421
description: "Invalid Response Data".to_string(),
422-
})
423-
.map_err(Into::<ContractError>::into),
422+
})),
424423
},
425424
cosmwasm_std::SubMsgResult::Err(error) => {
426-
Err(ClientError::Other { description: error }).map_err(Into::<ContractError>::into)
425+
Err(Into::<ContractError>::into(ClientError::Other {
426+
description: error,
427+
}))
427428
}
428429
}
429430
}
@@ -459,10 +460,9 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> {
459460
let client_state = self.client_state(deps.as_ref(), &client_id)?;
460461

461462
if client_state.is_frozen() {
462-
return Err(ClientError::ClientFrozen {
463+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
463464
client_id: client_id.clone(),
464-
})
465-
.map_err(Into::<ContractError>::into);
465+
}));
466466
}
467467
let client = self.get_light_client(deps.as_ref().storage, &client_id)?;
468468

@@ -535,13 +535,14 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> {
535535
.add_attribute("method", "execute_misbheaviour_reply")
536536
.add_attribute("client_id", client_id.as_str()))
537537
}
538-
None => Err(ClientError::Other {
538+
None => Err(Into::<ContractError>::into(ClientError::Other {
539539
description: "Invalid Response Data".to_string(),
540-
})
541-
.map_err(Into::<ContractError>::into),
540+
})),
542541
},
543542
cosmwasm_std::SubMsgResult::Err(error) => {
544-
Err(ClientError::Other { description: error }).map_err(Into::<ContractError>::into)
543+
Err(Into::<ContractError>::into(ClientError::Other {
544+
description: error,
545+
}))
545546
}
546547
}
547548
}

contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ impl<'a> CwIbcCoreContext<'a> {
255255
.may_load(store, client_id)
256256
{
257257
Ok(result) => match result {
258-
Some(id) => Err(ConnectionError::ConnectionExists(id.to_string()))
259-
.map_err(Into::<ContractError>::into),
258+
Some(id) => Err(Into::<ContractError>::into(
259+
ConnectionError::ConnectionExists(id.to_string()),
260+
)),
260261
None => Ok(()),
261262
},
262263
Err(error) => Err(ContractError::Std(error)),

contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ impl<'a> CwIbcCoreContext<'a> {
4949
let client_state = self.client_state(deps.as_ref(), &client_id)?;
5050

5151
if client_state.is_frozen() {
52-
return Err(ClientError::ClientFrozen {
52+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
5353
client_id: client_id.clone(),
54-
})
55-
.map_err(Into::<ContractError>::into);
54+
}));
5655
}
5756

5857
let delay_period = Duration::from_nanos(message.delay_period);
@@ -64,8 +63,7 @@ impl<'a> CwIbcCoreContext<'a> {
6463
if self.get_compatible_versions().contains(&version) {
6564
vec![version]
6665
} else {
67-
return Err(ConnectionError::EmptyVersions)
68-
.map_err(Into::<ContractError>::into);
66+
return Err(Into::<ContractError>::into(ConnectionError::EmptyVersions));
6967
}
7068
}
7169
None => self.get_compatible_versions(),
@@ -175,10 +173,9 @@ impl<'a> CwIbcCoreContext<'a> {
175173
let client_state = self.client_state(deps.as_ref(), client_id)?;
176174

177175
if client_state.is_frozen() {
178-
return Err(ClientError::ClientFrozen {
176+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
179177
client_id: client_id.clone(),
180-
})
181-
.map_err(Into::<ContractError>::into);
178+
}));
182179
}
183180
let prefix = self.commitment_prefix(deps.as_ref(), &env);
184181

@@ -316,10 +313,9 @@ impl<'a> CwIbcCoreContext<'a> {
316313
let client_state = self.client_state(deps.as_ref(), &client_id)?;
317314

318315
if client_state.is_frozen() {
319-
return Err(ClientError::ClientFrozen {
316+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
320317
client_id: client_id.clone(),
321-
})
322-
.map_err(Into::<ContractError>::into);
318+
}));
323319
}
324320

325321
let counterparty = to_ibc_counterparty(message.counterparty)?;
@@ -493,10 +489,9 @@ impl<'a> CwIbcCoreContext<'a> {
493489
let client_state = self.client_state(deps.as_ref(), client_id)?;
494490

495491
if client_state.is_frozen() {
496-
return Err(ClientError::ClientFrozen {
492+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
497493
client_id: client_id.clone(),
498-
})
499-
.map_err(Into::<ContractError>::into);
494+
}));
500495
}
501496
let prefix = self.commitment_prefix(deps.as_ref(), &env);
502497
cw_println!(

contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/channel.rs

+21-19
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ impl<'a> CwIbcCoreContext<'a> {
3030
.may_load(store, (port_id, channel_id))?
3131
{
3232
Some(request) => Ok(request),
33-
None => Err(ChannelError::ChannelNotFound {
33+
None => Err(Into::<ContractError>::into(ChannelError::ChannelNotFound {
3434
port_id: port_id.clone(),
3535
channel_id: channel_id.clone(),
36-
})
37-
.map_err(Into::<ContractError>::into)?,
36+
}))?,
3837
}
3938
}
4039

@@ -233,11 +232,12 @@ impl<'a> CwIbcCoreContext<'a> {
233232
|req_id| -> Result<_, ContractError> {
234233
match req_id {
235234
Some(seq) => Ok(seq.increment()),
236-
None => Err(PacketError::MissingNextSendSeq {
237-
port_id: port_id.clone(),
238-
channel_id: channel_id.clone(),
239-
})
240-
.map_err(Into::<ContractError>::into)?,
235+
None => Err(Into::<ContractError>::into(
236+
PacketError::MissingNextSendSeq {
237+
port_id: port_id.clone(),
238+
channel_id: channel_id.clone(),
239+
},
240+
))?,
241241
}
242242
},
243243
)?;
@@ -345,11 +345,12 @@ impl<'a> CwIbcCoreContext<'a> {
345345
|req_id| -> Result<_, ContractError> {
346346
match req_id {
347347
Some(seq) => Ok(seq.increment()),
348-
None => Err(PacketError::MissingNextRecvSeq {
349-
port_id: port_id.clone(),
350-
channel_id: channel_id.clone(),
351-
})
352-
.map_err(Into::<ContractError>::into)?,
348+
None => Err(Into::<ContractError>::into(
349+
PacketError::MissingNextRecvSeq {
350+
port_id: port_id.clone(),
351+
channel_id: channel_id.clone(),
352+
},
353+
))?,
353354
}
354355
},
355356
)?;
@@ -462,11 +463,12 @@ impl<'a> CwIbcCoreContext<'a> {
462463
|req_id| -> Result<_, ContractError> {
463464
match req_id {
464465
Some(seq) => Ok(seq.increment()),
465-
None => Err(PacketError::MissingNextAckSeq {
466-
port_id: port_id.clone(),
467-
channel_id: channel_id.clone(),
468-
})
469-
.map_err(Into::<ContractError>::into)?,
466+
None => Err(Into::<ContractError>::into(
467+
PacketError::MissingNextAckSeq {
468+
port_id: port_id.clone(),
469+
channel_id: channel_id.clone(),
470+
},
471+
))?,
470472
}
471473
},
472474
)?;
@@ -525,7 +527,7 @@ impl<'a> CwIbcCoreContext<'a> {
525527
) -> Result<(), ContractError> {
526528
let channel_commitment_key = commitment::channel_commitment_key(port_id, channel_id);
527529

528-
let raw_channel: RawChannel = channel_end.clone().try_into().unwrap();
530+
let raw_channel: RawChannel = channel_end.clone().into();
529531
let channel_end_commitment = raw_channel.encode_to_vec();
530532

531533
self.ibc_store().save_commitment(

contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> {
7272
let src_port = to_ibc_port_id(&message.port_id)?;
7373

7474
if channel_end.connection_hops.len() != 1 {
75-
return Err(ChannelError::InvalidConnectionHopsLength {
76-
expected: 1,
77-
actual: channel_end.connection_hops.len(),
78-
})
79-
.map_err(Into::<ContractError>::into)?;
75+
return Err(Into::<ContractError>::into(
76+
ChannelError::InvalidConnectionHopsLength {
77+
expected: 1,
78+
actual: channel_end.connection_hops.len(),
79+
},
80+
))?;
8081
}
8182
let connection_id = channel_end.connection_hops[0].clone();
8283
// An IBC connection running on the local (host) chain should exist.
@@ -85,10 +86,9 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> {
8586
let client_state = self.client_state(deps.as_ref(), client_id)?;
8687

8788
if client_state.is_frozen() {
88-
return Err(ClientError::ClientFrozen {
89+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
8990
client_id: client_id.clone(),
90-
})
91-
.map_err(Into::<ContractError>::into);
91+
}));
9292
}
9393
channel_open_init_msg_validate(&channel_end, connection_end)?;
9494
let counter = self.channel_counter(deps.storage)?;
@@ -217,7 +217,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> {
217217
vec![conn_id_on_a.clone()],
218218
channel_end.version().clone(),
219219
);
220-
let raw_expected_chan = RawChannel::try_from(expected_channel_end).unwrap();
220+
let raw_expected_chan = RawChannel::from(expected_channel_end);
221221
let chan_end_path_on_a = commitment::channel_path(&source_port, &source_channel);
222222
let vector = raw_expected_chan.encode_to_vec();
223223

@@ -348,7 +348,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> {
348348
version.clone(),
349349
);
350350

351-
let raw_expected_chan = RawChannel::try_from(expected_channel_end).unwrap();
351+
let raw_expected_chan = RawChannel::from(expected_channel_end);
352352
let chan_end_path_on_b = commitment::channel_path(&dst_port, &dst_channel);
353353
let vector = raw_expected_chan.encode_to_vec();
354354

@@ -471,7 +471,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> {
471471
channel_end.version.clone(),
472472
);
473473

474-
let raw_expected_chan = RawChannel::try_from(expected_channel_end).unwrap();
474+
let raw_expected_chan = RawChannel::from(expected_channel_end);
475475
let counterparty_channel_path = commitment::channel_path(src_port, src_channel);
476476

477477
let expected_counterparty_channel_end = raw_expected_chan.encode_to_vec();
@@ -557,10 +557,9 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> {
557557
let client_state = self.client_state(deps.as_ref(), client_id)?;
558558

559559
if client_state.is_frozen() {
560-
return Err(ClientError::ClientFrozen {
560+
return Err(Into::<ContractError>::into(ClientError::ClientFrozen {
561561
client_id: client_id.clone(),
562-
})
563-
.map_err(Into::<ContractError>::into);
562+
}));
564563
}
565564

566565
ensure_connection_state(&connection_id, &connection_end, &ConnectionState::Open)?;
@@ -673,7 +672,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> {
673672
vec![conn_id_on_a.clone()],
674673
channel_end.version().clone(),
675674
);
676-
let raw_expected_chan = RawChannel::try_from(expected_channel_end).unwrap();
675+
let raw_expected_chan = RawChannel::from(expected_channel_end);
677676

678677
let counterparty_chan_end_path = commitment::channel_path(src_port, src_channel);
679678
let expected_counterparty_channel_end = raw_expected_chan.encode_to_vec();

0 commit comments

Comments
 (0)