diff --git a/contracts/Dispatcher.sol b/contracts/Dispatcher.sol index 7c3d2f58..e8c15c78 100644 --- a/contracts/Dispatcher.sol +++ b/contracts/Dispatcher.sol @@ -578,7 +578,7 @@ contract Dispatcher is IbcDispatcher, Ownable { nextSequenceAck[address(receiver)][packet.src.channelId] = packet.sequence + 1; } - receiver.onAcknowledgementPacket(packet); + receiver.onAcknowledgementPacket(packet, ackPacket); // delete packet commitment to avoid double ack delete sendPacketCommitment[address(receiver)][packet.src.channelId][packet.sequence]; diff --git a/contracts/IbcReceiver.sol b/contracts/IbcReceiver.sol index ab75b7a6..cc621eb3 100644 --- a/contracts/IbcReceiver.sol +++ b/contracts/IbcReceiver.sol @@ -18,7 +18,7 @@ interface IbcReceiver { function onRecvPacket(IbcPacket calldata packet) external returns (AckPacket memory ackPacket); - function onAcknowledgementPacket(IbcPacket calldata packet) external; + function onAcknowledgementPacket(IbcPacket calldata packet, AckPacket calldata ack) external; function onTimeoutPacket(IbcPacket calldata packet) external; diff --git a/contracts/Mars.sol b/contracts/Mars.sol index 7153ad4b..3853f720 100644 --- a/contracts/Mars.sol +++ b/contracts/Mars.sol @@ -7,8 +7,11 @@ import './IbcReceiver.sol'; import './IbcDispatcher.sol'; contract Mars is IbcReceiver, Ownable { + // received packet as chain B IbcPacket[] public recvedPackets; - IbcPacket[] public ackPackets; + // received ack packet as chain A + AckPacket[] public ackPackets; + // received timeout packet as chain A IbcPacket[] public timeoutPackets; bytes32[] public connectedChannels; @@ -19,8 +22,8 @@ contract Mars is IbcReceiver, Ownable { return AckPacket(true, abi.encodePacked('{ "account": "account", "reply": "got the message" }')); } - function onAcknowledgementPacket(IbcPacket calldata packet) external { - ackPackets.push(packet); + function onAcknowledgementPacket(IbcPacket calldata packet, AckPacket calldata ack) external { + ackPackets.push(ack); } function onTimeoutPacket(IbcPacket calldata packet) external { diff --git a/test/Dispatcher.t.sol b/test/Dispatcher.t.sol index 7c92a432..eb65ffc8 100644 --- a/test/Dispatcher.t.sol +++ b/test/Dispatcher.t.sol @@ -634,6 +634,10 @@ contract DispatcherAckPacketTest is PacketSenderTest { vm.expectEmit(true, true, false, true, address(dispatcher)); emit Acknowledgement(address(mars), channelId, sentPacket.sequence); dispatcher.acknowledgement(IbcReceiver(mars), sentPacket, ackPacket, validProof); + // confirm dapp recieved the ack + (bool success, bytes memory data) = mars.ackPackets(sentPacket.sequence - 1); + assertEq(success, ackPacket.success); + assertEq(data, ackPacket.data); } }