Skip to content

Commit

Permalink
improve: allow the removal of adapters
Browse files Browse the repository at this point in the history
Signed-off-by: bennett <[email protected]>
  • Loading branch information
bmzig committed Nov 7, 2024
1 parent d7550b8 commit b1f17b4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions contracts/chain-adapters/ForwarderBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,15 @@ abstract contract ForwarderBase is UUPSUpgradeable, ForwarderInterface {
*/
function updateAdapter(uint256 _destinationChainId, address _l2Adapter) external onlyAdmin {
if (_l2Adapter == address(0)) revert InvalidChainAdapter();
chainAdapters[_destinationChainId] = _l2Adapter;
emit ChainAdaptersUpdated(_destinationChainId, _l2Adapter);
_updateAdapter(_destinationChainId, _l2Adapter);
}

/**
* @notice Removes this contract's set adapter for the specified chain ID.
* @param _destinationChainId The chain ID of the target network.
*/
function removeAdapter(uint256 _destinationChainId) external onlyAdmin {
_updateAdapter(_destinationChainId, address(0));
}

/**
Expand Down Expand Up @@ -147,6 +154,11 @@ abstract contract ForwarderBase is UUPSUpgradeable, ForwarderInterface {
emit SetXDomainAdmin(_newCrossDomainAdmin);
}

function _updateAdapter(uint256 _destinationChainId, address _l2Adapter) internal {
chainAdapters[_destinationChainId] = _l2Adapter;
emit ChainAdaptersUpdated(_destinationChainId, _l2Adapter);
}

// Reserve storage slots for future versions of this base contract to add state variables without
// affecting the storage layout of child contracts. Decrement the size of __gap whenever state variables
// are added. This is at bottom of contract to make sure it's always at the end of storage.
Expand Down

0 comments on commit b1f17b4

Please sign in to comment.