From 26a5bdb166f66ba556b485b20eed46456c6485b7 Mon Sep 17 00:00:00 2001 From: Thomas Dekeyser Date: Wed, 14 Feb 2024 17:30:15 +0100 Subject: [PATCH] fix connectedchannels on close deletion issue --- contracts/CustomChanIbcContract.sol | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contracts/CustomChanIbcContract.sol b/contracts/CustomChanIbcContract.sol index 8f9b82b..c7d1904 100644 --- a/contracts/CustomChanIbcContract.sol +++ b/contracts/CustomChanIbcContract.sol @@ -30,7 +30,7 @@ contract CustomChanIbcContract is IbcReceiverBase, IbcReceiver { function updateDispatcher(IbcDispatcher _dispatcher) external onlyOwner { dispatcher = _dispatcher; } - + /** * @dev Sends a packet with a greeting message over a specified channel. * @param message The greeting message to be sent. @@ -160,7 +160,10 @@ contract CustomChanIbcContract is IbcReceiverBase, IbcReceiver { bool channelFound = false; for (uint256 i = 0; i < connectedChannels.length; i++) { if (connectedChannels[i].channelId == channelId) { - delete connectedChannels[i]; + for (uint256 j = i; j < connectedChannels.length - 1; j++) { + connectedChannels[j] = connectedChannels[j + 1]; + } + connectedChannels.pop(); channelFound = true; break; }