Skip to content

Commit

Permalink
Improve IBC unauth error message
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolacy committed Jan 27, 2024
1 parent c170596 commit 81f1074
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions contracts/provider/external-staking/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub enum ContractError {
#[error("Unauthorized")]
Unauthorized,

#[error("Unauthorized. Received connection id: {0}, counterparty port id: {1}. Expected connection id: {2}, counterparty port id: {3}.")]
IbcUnauthorized(String, String, String, String),

#[error("Invalid denom, {0} expected")]
InvalidDenom(String),

Expand Down
8 changes: 6 additions & 2 deletions contracts/provider/external-staking/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ pub fn ibc_channel_open(
if authorized.connection_id != channel.connection_id
|| authorized.port_id != channel.counterparty_endpoint.port_id
{
// FIXME: do we need a better error here?
return Err(ContractError::Unauthorized);
return Err(ContractError::IbcUnauthorized(
channel.connection_id,
channel.counterparty_endpoint.port_id,
authorized.connection_id,
authorized.port_id,
));
}

// we handshake with the counterparty version, it must not be empty
Expand Down

0 comments on commit 81f1074

Please sign in to comment.