Skip to content

Commit

Permalink
Revert NftTransferError FailedToDeserializeAck and FailedToDeserializ…
Browse files Browse the repository at this point in the history
…ePacketData
  • Loading branch information
seanchen1991 committed Sep 6, 2024
1 parent 283a606 commit 3dc2ff5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
21 changes: 5 additions & 16 deletions ibc-apps/ics721-nft-transfer/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,11 @@ pub fn on_acknowledgement_packet_validate(
acknowledgement: &Acknowledgement,
_relayer: &Signer,
) -> Result<(), NftTransferError> {
let data = serde_json::from_slice::<PacketData>(&packet.data).map_err(|e| {
DecodingError::InvalidJson {
description: format!("failed to deserialize packet data: {e}"),
}
})?;
let data = serde_json::from_slice::<PacketData>(&packet.data)
.map_err(|_| NftTransferError::FailedToDeserializePacketData)?;

let acknowledgement = serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref())
.map_err(|e| DecodingError::InvalidJson {
description: format!("failed to deserialize acknowledgment: {e}"),
})?;
.map_err(|__| NftTransferError::FailedToDeserializeAck)?;

Check warning on line 216 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L216

Added line #L216 was not covered by tests

if !acknowledgement.is_successful() {
refund_packet_nft_validate(ctx, packet, &data)?;
Expand All @@ -236,10 +231,7 @@ pub fn on_acknowledgement_packet_execute(
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
return (
ModuleExtras::empty(),
Err(DecodingError::InvalidJson {
description: "failed to deserialize packet data".to_string(),
}
.into()),
Err(NftTransferError::FailedToDeserializePacketData),
);
};

Expand All @@ -248,10 +240,7 @@ pub fn on_acknowledgement_packet_execute(
else {
return (
ModuleExtras::empty(),
Err(DecodingError::InvalidJson {
description: "failed to deserialize acknowledgment".to_string(),
}
.into()),
Err(NftTransferError::FailedToDeserializeAck),
);
};

Expand Down
4 changes: 4 additions & 0 deletions ibc-apps/ics721-nft-transfer/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ pub enum NftTransferError {
MismatchedChannelOrders { expected: Order, actual: Order },
/// mismatched port IDs: expected `{expected}`, actual `{actual}`
MismatchedPortIds { expected: PortId, actual: PortId },
/// failed to deserialize packet data
FailedToDeserializePacketData,
/// failed to deserialize acknowledgement
FailedToDeserializeAck,
/// failed to parse account ID
FailedToParseAccount,
/// channel cannot be closed
Expand Down

0 comments on commit 3dc2ff5

Please sign in to comment.