Skip to content

Commit

Permalink
Audit Issue 9: Remove unused code (#1317)
Browse files Browse the repository at this point in the history
* remove unused code

* revert removing agent mapping in storage
  • Loading branch information
claravanstaden authored Oct 22, 2024
1 parent e87ddb2 commit a997d03
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 25 deletions.
1 change: 0 additions & 1 deletion contracts/src/AgentExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions contracts/src/Assets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
19 changes: 0 additions & 19 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit a997d03

Please sign in to comment.