From b1f17b422688cd4aca1677e12fefbca7fe2d2caf Mon Sep 17 00:00:00 2001 From: bennett Date: Thu, 7 Nov 2024 09:16:10 -0600 Subject: [PATCH] improve: allow the removal of adapters Signed-off-by: bennett --- contracts/chain-adapters/ForwarderBase.sol | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/contracts/chain-adapters/ForwarderBase.sol b/contracts/chain-adapters/ForwarderBase.sol index 388780906..a21508be9 100644 --- a/contracts/chain-adapters/ForwarderBase.sol +++ b/contracts/chain-adapters/ForwarderBase.sol @@ -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)); } /** @@ -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.