Skip to content

Commit

Permalink
Rename AcknowledgementMsg::Err to ::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Aug 23, 2023
1 parent b959315 commit 793bc1c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions contracts/ibc-reflect-send/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn acknowledge_who_am_i(
// ignore errors (but mention in log)
let WhoAmIResponse { account } = match ack {
AcknowledgementMsg::Ok(res) => res,
AcknowledgementMsg::Err(e) => {
AcknowledgementMsg::Error(e) => {
return Ok(IbcBasicResponse::new()
.add_attribute("action", "acknowledge_who_am_i")
.add_attribute("error", e))
Expand Down Expand Up @@ -176,7 +176,7 @@ fn acknowledge_balances(
// ignore errors (but mention in log)
let BalancesResponse { account, balances } = match ack {
AcknowledgementMsg::Ok(res) => res,
AcknowledgementMsg::Err(e) => {
AcknowledgementMsg::Error(e) => {
return Ok(IbcBasicResponse::new()
.add_attribute("action", "acknowledge_balances")
.add_attribute("error", e))
Expand Down
7 changes: 3 additions & 4 deletions contracts/ibc-reflect-send/src/ibc_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ pub enum PacketMsg {
#[cw_serde]
pub enum AcknowledgementMsg<S> {
Ok(S),
#[serde(rename = "error")]
Err(String),
Error(String),
}

impl<S> AcknowledgementMsg<S> {
pub fn unwrap(self) -> S {
match self {
AcknowledgementMsg::Ok(data) => data,
AcknowledgementMsg::Err(err) => panic!("{}", err),
AcknowledgementMsg::Error(err) => panic!("{}", err),
}
}

pub fn unwrap_err(self) -> String {
match self {
AcknowledgementMsg::Ok(_) => panic!("not an error"),
AcknowledgementMsg::Err(err) => err,
AcknowledgementMsg::Error(err) => err,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/ibc-reflect/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub fn migrate(_deps: DepsMut, _env: Env, _msg: Empty) -> StdResult<Response> {
// this encode an error or error message into a proper acknowledgement to the recevier
fn encode_ibc_error(msg: impl Into<String>) -> Binary {
// this cannot error, unwrap to keep the interface simple
to_binary(&AcknowledgementMsg::<()>::Err(msg.into())).unwrap()
to_binary(&AcknowledgementMsg::<()>::Error(msg.into())).unwrap()
}

#[entry_point]
Expand Down
7 changes: 3 additions & 4 deletions contracts/ibc-reflect/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,21 @@ pub enum PacketMsg {
#[cw_serde]
pub enum AcknowledgementMsg<S> {
Ok(S),
#[serde(rename = "error")]
Err(String),
Error(String),
}

impl<S> AcknowledgementMsg<S> {
pub fn unwrap(self) -> S {
match self {
AcknowledgementMsg::Ok(data) => data,
AcknowledgementMsg::Err(err) => panic!("{}", err),
AcknowledgementMsg::Error(err) => panic!("{}", err),
}
}

pub fn unwrap_err(self) -> String {
match self {
AcknowledgementMsg::Ok(_) => panic!("not an error"),
AcknowledgementMsg::Err(err) => err,
AcknowledgementMsg::Error(err) => err,
}
}
}
Expand Down

0 comments on commit 793bc1c

Please sign in to comment.