diff --git a/contracts/core/04-channel/IBCChannelHandshake.sol b/contracts/core/04-channel/IBCChannelHandshake.sol index 4cc64e96..57d828f8 100644 --- a/contracts/core/04-channel/IBCChannelHandshake.sol +++ b/contracts/core/04-channel/IBCChannelHandshake.sol @@ -55,6 +55,10 @@ contract IBCChannelHandshake is IBCModuleManager, IIBCChannelHandshake, IIBCChan } string memory channelId = generateChannelIdentifier(); + ChannelStorage storage channelStorage = getChannelStorage()[msg_.portId][channelId]; + if (channelStorage.channel.state != Channel.State.STATE_UNINITIALIZED_UNSPECIFIED) { + revert IBCChannelAlreadyChannelExists(); + } initializeSequences(msg_.portId, channelId); emit GeneratedChannelIdentifier(channelId); @@ -130,6 +134,10 @@ contract IBCChannelHandshake is IBCModuleManager, IIBCChannelHandshake, IIBCChan ); string memory channelId = generateChannelIdentifier(); + ChannelStorage storage channelStorage = getChannelStorage()[msg_.portId][channelId]; + if (channelStorage.channel.state != Channel.State.STATE_UNINITIALIZED_UNSPECIFIED) { + revert IBCChannelAlreadyChannelExists(); + } initializeSequences(msg_.portId, channelId); emit GeneratedChannelIdentifier(channelId); diff --git a/contracts/core/04-channel/IIBCChannelErrors.sol b/contracts/core/04-channel/IIBCChannelErrors.sol index aea595c1..81f102cd 100644 --- a/contracts/core/04-channel/IIBCChannelErrors.sol +++ b/contracts/core/04-channel/IIBCChannelErrors.sol @@ -5,6 +5,8 @@ import {Height} from "../../proto/Client.sol"; import {Channel} from "../../proto/Channel.sol"; interface IIBCChannelErrors { + error IBCChannelAlreadyChannelExists(); + /// @param state channel state error IBCChannelUnexpectedChannelState(Channel.State state);