Skip to content

Commit

Permalink
restrict use of setAxelarChainId
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Jun 25, 2024
1 parent 56ff882 commit 2c000b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/axelar/AxelarTransceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ contract AxelarTransceiver is IAxelarTransceiver, AxelarGMPExecutable, Transceiv
string calldata transceiverAddress
) external virtual onlyOwner {
// We allow empty chainName and transceiverAddress to allow removing chains.
if (chainId == 0) revert ZeroChainId();
if (chainId == 0 || bytes(chainName).length == 0 || bytes(transceiverAddress).length == 0) revert InvalidChainIdParams();

AxelarTransceiverStorage storage slot = _storage();
if(bytes(slot.idToAxelarChainId[chainId]).length != 0) revert ChainIdAlreadySet(chainId);
slot.idToAxelarChainId[chainId] = chainName;
slot.axelarChainIdToId[chainName] = chainId;
slot.idToTransceiverAddress[chainId] = transceiverAddress;
Expand Down
7 changes: 5 additions & 2 deletions src/axelar/interfaces/IAxelarTransceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ interface IAxelarTransceiver is ITransceiver {
/// @param transceiverAddress The address of the Transceiver as a string.
error InvalidChainId(uint16 chainId, string chainName, string transceiverAddress);

/// @notice Chain Id passed is zero.
error ZeroChainId();
/// @notice Chain Id passed is zero, or Axelar Chain Id or Transceiver Address were empty.
error InvalidChainIdParams();

/// @notice Chain Id is already being used.
error ChainIdAlreadySet(uint16 chainId);

/// @notice Emmited when a transceiver message is sent.
/// @param recipientChainId The wormhole chainId of the destination chain.
Expand Down

0 comments on commit 2c000b2

Please sign in to comment.