From a997d03b715017dd143bdac48fcf94209a6299a6 Mon Sep 17 00:00:00 2001 From: Clara van Staden Date: Tue, 22 Oct 2024 14:55:17 +0200 Subject: [PATCH] Audit Issue 9: Remove unused code (#1317) * remove unused code * revert removing agent mapping in storage --- contracts/src/AgentExecutor.sol | 1 - contracts/src/Assets.sol | 5 ----- contracts/src/Gateway.sol | 19 ------------------- 3 files changed, 25 deletions(-) diff --git a/contracts/src/AgentExecutor.sol b/contracts/src/AgentExecutor.sol index c3ed7e2f81..629a25381e 100644 --- a/contracts/src/AgentExecutor.sol +++ b/contracts/src/AgentExecutor.sol @@ -7,7 +7,6 @@ import {SubstrateTypes} from "./SubstrateTypes.sol"; import {IERC20} from "./interfaces/IERC20.sol"; import {SafeTokenTransfer, SafeNativeTransfer} from "./utils/SafeTransfer.sol"; -import {Gateway} from "./Gateway.sol"; /// @title Code which will run within an `Agent` using `delegatecall`. /// @dev This is a singleton contract, meaning that all agents will execute the same code. diff --git a/contracts/src/Assets.sol b/contracts/src/Assets.sol index d1fcbcb0b6..b8f4db66ed 100644 --- a/contracts/src/Assets.sol +++ b/contracts/src/Assets.sol @@ -310,9 +310,4 @@ library Assets { } return $.tokenAddressOf[tokenID]; } - - function _isTokenRegistered(address token) internal view returns (bool) { - AssetsStorage.Layout storage $ = AssetsStorage.layout(); - return $.tokenRegistry[token].isRegistered; - } } diff --git a/contracts/src/Gateway.sol b/contracts/src/Gateway.sol index 07efb9f04c..b41ea95f04 100644 --- a/contracts/src/Gateway.sol +++ b/contracts/src/Gateway.sol @@ -97,10 +97,8 @@ contract Gateway is IGateway, IInitializable, IUpgradable { error ChannelAlreadyCreated(); error ChannelDoesNotExist(); error InvalidChannelUpdate(); - error AgentExecutionFailed(bytes returndata); error InvalidAgentExecutionPayload(); error InvalidConstructorParams(); - error AlreadyInitialized(); error TokenNotRegistered(); // Message handlers can only be dispatched by the gateway itself @@ -111,15 +109,6 @@ contract Gateway is IGateway, IInitializable, IUpgradable { _; } - // handler functions are privileged from agent only - modifier onlyAgent(bytes32 agentID) { - bytes32 _agentID = _ensureAgentAddress(msg.sender); - if (_agentID != agentID) { - revert Unauthorized(); - } - _; - } - constructor( address beefyClient, address agentExecutor, @@ -583,14 +572,6 @@ contract Gateway is IGateway, IInitializable, IUpgradable { } } - /// @dev Ensure that the specified address is an valid agent - function _ensureAgentAddress(address agent) internal view returns (bytes32 agentID) { - agentID = CoreStorage.layout().agentAddresses[agent]; - if (agentID == bytes32(0)) { - revert AgentDoesNotExist(); - } - } - /// @dev Invoke some code within an agent function _invokeOnAgent(address agent, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = (Agent(payable(agent)).invoke(AGENT_EXECUTOR, data));