Repository: unionlabs/union
File: lib/ics-008-wasm-client/src/ibc_client.rs (Rust)

Code before:
    ) -> Result<Binary, IbcClientError<Self>> {
        match msg {
            QueryMsg::Status {} => to_json_binary(&Into::<StatusResult>::into(
                Self::status(deps, &env).map_err(IbcClientError::ClientSpecific)?,
            )),
            QueryMsg::ExportMetadata {} => to_json_binary(&ExportMetadataResult {
                genesis_metadata: Self::export_metadata(deps, &env)
                    .map_err(IbcClientError::ClientSpecific)?,
            }),
            QueryMsg::VerifyClientMessage { client_message } => {
                if let Ok(header) =
                    <Self::Header as Decode<Self::Encoding>>::decode(&client_message.0)
                {
                    to_json_binary(
                        &Self::verify_header(deps, env, header)
                            .map_err(IbcClientError::ClientSpecific)?,
                    )
                } else if let Ok(misbehaviour) =
                    <Self::Misbehaviour as Decode<Self::Encoding>>::decode(&client_message.0)
                {
                    to_json_binary(
                        &Self::verify_misbehaviour(deps, misbehaviour)
                            .map_err(IbcClientError::ClientSpecific)?,
                    )
                } else {
                    return Err(IbcClientError::MisbehaviourDataDecode(client_message.0));
                }
            }
            QueryMsg::CheckForMisbehaviour { client_message } => {
                if let Ok(header) =
                    <Self::Header as Decode<Self::Encoding>>::decode(&client_message.0)
                {
                    to_json_binary(&CheckForMisbehaviourResult {
                        found_misbehaviour: Self::check_for_misbehaviour_on_header(deps, header)
                            .map_err(IbcClientError::ClientSpecific)?,
                    })
                } else if let Ok(misbehaviour) =
                    <Self::Misbehaviour as Decode<Self::Encoding>>::decode(&client_message.0)
                {
                    to_json_binary(&CheckForMisbehaviourResult {
                        found_misbehaviour: Self::check_for_misbehaviour_on_misbehaviour(
                            deps,
                            misbehaviour,
                        )
                        .map_err(IbcClientError::ClientSpecific)?,
                    })
                } else {
                    return Err(IbcClientError::MisbehaviourDataDecode(client_message.0));
                }
            }
            QueryMsg::TimestampAtHeight { height } => to_json_binary(&TimestampAtHeightResult {

Review comment (suggestion):
i think this error should be renamed to "invalid client message" or something along those lines, since it's not just the misbehaviour erroring here

Code after:
    ) -> Result<Binary, IbcClientError<Self>> {
        match msg {
            QueryMsg::Status {} => to_json_binary(&Into::<StatusResult>::into(
                Self::status(deps, &env).map_err(IbcClientError::ClientSpecific)?,
            )),
            QueryMsg::ExportMetadata {} => to_json_binary(&ExportMetadataResult {
                genesis_metadata: Self::export_metadata(deps, &env)
                    .map_err(IbcClientError::ClientSpecific)?,
            }),
            QueryMsg::VerifyClientMessage { client_message } => {
                if let Ok(header) =
                    <Self::Header as Decode<Self::Encoding>>::decode(&client_message.0)
                {
                    to_json_binary(
                        &Self::verify_header(deps, env, header)
                            .map_err(IbcClientError::ClientSpecific)?,
                    )
                } else if let Ok(misbehaviour) =
                    <Self::Misbehaviour as Decode<Self::Encoding>>::decode(&client_message.0)
                {
                    to_json_binary(
                        &Self::verify_misbehaviour(deps, misbehaviour)
                            .map_err(IbcClientError::ClientSpecific)?,
                    )
                } else {
                    return Err(IbcClientError::InvalidClientMessage(client_message.0));
                }
            }
            QueryMsg::CheckForMisbehaviour { client_message } => {
                if let Ok(header) =
                    <Self::Header as Decode<Self::Encoding>>::decode(&client_message.0)
                {
                    to_json_binary(&CheckForMisbehaviourResult {
                        found_misbehaviour: Self::check_for_misbehaviour_on_header(deps, header)
                            .map_err(IbcClientError::ClientSpecific)?,
                    })
                } else if let Ok(misbehaviour) =
                    <Self::Misbehaviour as Decode<Self::Encoding>>::decode(&client_message.0)
                {
                    to_json_binary(&CheckForMisbehaviourResult {
                        found_misbehaviour: Self::check_for_misbehaviour_on_misbehaviour(
                            deps,
                            misbehaviour,
                        )
                        .map_err(IbcClientError::ClientSpecific)?,
                    })
                } else {
                    return Err(IbcClientError::InvalidClientMessage(client_message.0));
                }
            }
            QueryMsg::TimestampAtHeight { height } => to_json_binary(&TimestampAtHeightResult {