diff --git a/src/PRBProxy.sol b/src/PRBProxy.sol index ac9701d..5f0ea8d 100644 --- a/src/PRBProxy.sol +++ b/src/PRBProxy.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.4; import { IPRBProxy } from "./interfaces/IPRBProxy.sol"; -import { IPlugin } from "./interfaces/IPlugin.sol"; +import { IPRBProxyPlugin } from "./interfaces/IPRBProxyPlugin.sol"; /// @title PRBProxy /// @author Paul Razvan Berg @@ -23,7 +23,7 @@ contract PRBProxy is IPRBProxy { //////////////////////////////////////////////////////////////////////////*/ /// @dev Maps plugin methods to plugin implementation. - mapping(bytes4 => IPlugin) internal plugins; + mapping(bytes4 => IPRBProxyPlugin) internal plugins; /// @dev Maps envoys to target contracts to function selectors to boolean flags. mapping(address => mapping(address => mapping(bytes4 => bool))) internal permissions; @@ -46,7 +46,7 @@ contract PRBProxy is IPRBProxy { // solhint-disable no-complex-fallback fallback(bytes calldata data) external payable returns (bytes memory response) { // Check if the function signature exists in the installed plugin methods mapping. - IPlugin plugin = plugins[msg.sig]; + IPRBProxyPlugin plugin = plugins[msg.sig]; if (address(plugin) == address(0)) { revert PRBProxy_NoPluginFound(msg.sender, msg.sig); } @@ -85,7 +85,7 @@ contract PRBProxy is IPRBProxy { } /// @inheritdoc IPRBProxy - function getPluginForMethod(bytes4 method) external view override returns (IPlugin plugin) { + function getPluginForMethod(bytes4 method) external view override returns (IPRBProxyPlugin plugin) { plugin = plugins[method]; } @@ -144,7 +144,7 @@ contract PRBProxy is IPRBProxy { } /// @inheritdoc IPRBProxy - function installPlugin(IPlugin plugin) external override { + function installPlugin(IPRBProxyPlugin plugin) external override { // Check that the caller is the owner. if (owner != msg.sender) { revert PRBProxy_NotOwner(owner, msg.sender); @@ -190,7 +190,7 @@ contract PRBProxy is IPRBProxy { } /// @inheritdoc IPRBProxy - function uninstallPlugin(IPlugin plugin) external override { + function uninstallPlugin(IPRBProxyPlugin plugin) external override { // Check that the caller is the owner. if (owner != msg.sender) { revert PRBProxy_NotOwner(owner, msg.sender); diff --git a/src/interfaces/IPRBProxy.sol b/src/interfaces/IPRBProxy.sol index 976e496..d05f8e3 100644 --- a/src/interfaces/IPRBProxy.sol +++ b/src/interfaces/IPRBProxy.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.4; -import { IPlugin } from "./IPlugin.sol"; +import { IPRBProxyPlugin } from "./IPRBProxyPlugin.sol"; /// @title IPRBProxy /// @author Paul Razvan Berg @@ -24,13 +24,13 @@ interface IPRBProxy { error PRBProxy_NotOwner(address owner, address caller); /// @notice Emitted when the plugin has no listed methods. - error PRBProxy_NoPluginMethods(IPlugin plugin); + error PRBProxy_NoPluginMethods(IPRBProxyPlugin plugin); /// @notice Emitted when the owner is changed during the DELEGATECALL. error PRBProxy_OwnerChanged(address originalOwner, address newOwner); /// @notice Emitted when a plugin execution reverts with no reason. - error PRBProxy_PluginExecutionReverted(IPlugin plugin); + error PRBProxy_PluginExecutionReverted(IPRBProxyPlugin plugin); /// @notice Emitted when passing an EOA or an undeployed contract as the target. error PRBProxy_TargetNotContract(address target); @@ -41,11 +41,11 @@ interface IPRBProxy { event Execute(address indexed target, bytes data, bytes response); - event InstallPlugin(IPlugin indexed plugin); + event InstallPlugin(IPRBProxyPlugin indexed plugin); event TransferOwnership(address indexed oldOwner, address indexed newOwner); - event UninstallPlugin(IPlugin indexed plugin); + event UninstallPlugin(IPRBProxyPlugin indexed plugin); /*////////////////////////////////////////////////////////////////////////// PUBLIC CONSTANT FUNCTIONS @@ -58,7 +58,7 @@ interface IPRBProxy { /// @notice Returns the address of the plugin installed for the the given method. /// @dev Returns the zero address if no plugin is installed. /// @param method The signature of the method to make the query for. - function getPluginForMethod(bytes4 method) external view returns (IPlugin plugin); + function getPluginForMethod(bytes4 method) external view returns (IPRBProxyPlugin plugin); /// @notice The address of the owner account or contract. function owner() external view returns (address); @@ -97,7 +97,7 @@ interface IPRBProxy { /// - Does not revert if the plugin is already installed. /// /// @param plugin The address of the plugin to install. - function installPlugin(IPlugin plugin) external; + function installPlugin(IPRBProxyPlugin plugin) external; /// @notice Gives or takes a permission from an envoy to call the given target contract and function selector /// on behalf of the owner. @@ -132,5 +132,5 @@ interface IPRBProxy { /// - Does not revert if the plugin is not already installed. /// /// @param plugin The address of the plugin to uninstall. - function uninstallPlugin(IPlugin plugin) external; + function uninstallPlugin(IPRBProxyPlugin plugin) external; } diff --git a/src/interfaces/IPlugin.sol b/src/interfaces/IPRBProxyPlugin.sol similarity index 52% rename from src/interfaces/IPlugin.sol rename to src/interfaces/IPRBProxyPlugin.sol index 1130629..33ac6fb 100644 --- a/src/interfaces/IPlugin.sol +++ b/src/interfaces/IPRBProxyPlugin.sol @@ -1,14 +1,15 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.4; -/// @title IPlugin -/// @notice Interface for the plugins that can be installed on the proxy. -interface IPlugin { +/// @title IPRBProxyPlugin +/// @notice Interface for the plugins that can be installed on a proxy. +interface IPRBProxyPlugin { /// @notice Lists the methods that the plugin implements. /// @dev These methods are installed and uninstalled by the proxy. /// /// Requirements: - /// - The proxy needs at least one method to be installed. - /// @return methods The methods that the plugin exports. + /// - The plugin needs at least one method to be listed. + /// + /// @return methods The methods that the plugin implements. function methodList() external returns (bytes4[] memory methods); } diff --git a/test/Base.t.sol b/test/Base.t.sol index 4b637a0..21b8079 100644 --- a/test/Base.t.sol +++ b/test/Base.t.sol @@ -7,9 +7,9 @@ import { PRBTest } from "@prb/test/PRBTest.sol"; import { StdCheats } from "forge-std/StdCheats.sol"; import { StdUtils } from "forge-std/StdUtils.sol"; -import { IPlugin } from "src/interfaces/IPlugin.sol"; import { IPRBProxy } from "src/interfaces/IPRBProxy.sol"; import { IPRBProxyFactory } from "src/interfaces/IPRBProxyFactory.sol"; +import { IPRBProxyPlugin } from "src/interfaces/IPRBProxyPlugin.sol"; import { IPRBProxyRegistry } from "src/interfaces/IPRBProxyRegistry.sol"; import { PRBProxy } from "src/PRBProxy.sol"; import { PRBProxyFactory } from "src/PRBProxyFactory.sol"; @@ -78,13 +78,13 @@ abstract contract Base_Test is PRBTest, StdCheats, StdUtils { INTERNAL NON-CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ - /// @dev Helper function to compare two `IPlugin` addresses. - function assertEq(IPlugin a, IPlugin b) internal { + /// @dev Helper function to compare two `IPRBProxyPlugin` addresses. + function assertEq(IPRBProxyPlugin a, IPRBProxyPlugin b) internal { assertEq(address(a), address(b)); } - /// @dev Helper function to compare two `IPlugin` addresses. - function assertEq(IPlugin a, IPlugin b, string memory err) internal { + /// @dev Helper function to compare two `IPRBProxyPlugin` addresses. + function assertEq(IPRBProxyPlugin a, IPRBProxyPlugin b, string memory err) internal { assertEq(address(a), address(b), err); } diff --git a/test/helpers/plugins/PluginDummy.t.sol b/test/helpers/plugins/PluginDummy.t.sol index c021be4..cafa376 100644 --- a/test/helpers/plugins/PluginDummy.t.sol +++ b/test/helpers/plugins/PluginDummy.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; -import { IPlugin } from "src/interfaces/IPlugin.sol"; +import { IPRBProxyPlugin } from "src/interfaces/IPRBProxyPlugin.sol"; -contract PluginDummy is IPlugin { +contract PluginDummy is IPRBProxyPlugin { function foo() external pure returns (string memory) { return "foo"; } diff --git a/test/helpers/plugins/PluginEmpty.t.sol b/test/helpers/plugins/PluginEmpty.t.sol index 0d8b1b5..9f5a79a 100644 --- a/test/helpers/plugins/PluginEmpty.t.sol +++ b/test/helpers/plugins/PluginEmpty.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; -import { IPlugin } from "src/interfaces/IPlugin.sol"; +import { IPRBProxyPlugin } from "src/interfaces/IPRBProxyPlugin.sol"; -contract PluginEmpty is IPlugin { +contract PluginEmpty is IPRBProxyPlugin { function methodList() external pure override returns (bytes4[] memory) { bytes4[] memory methods = new bytes4[](0); return methods; diff --git a/test/helpers/plugins/PluginRevert.t.sol b/test/helpers/plugins/PluginRevert.t.sol index 8c2277e..22aefd7 100644 --- a/test/helpers/plugins/PluginRevert.t.sol +++ b/test/helpers/plugins/PluginRevert.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; -import { IPlugin } from "src/interfaces/IPlugin.sol"; +import { IPRBProxyPlugin } from "src/interfaces/IPRBProxyPlugin.sol"; -contract PluginRevert is IPlugin { +contract PluginRevert is IPRBProxyPlugin { error PluginError(); function methodList() external pure override returns (bytes4[] memory) { diff --git a/test/helpers/targets/TargetPluginRevert.t.sol b/test/helpers/targets/TargetPluginRevert.t.sol index 8c2277e..22aefd7 100644 --- a/test/helpers/targets/TargetPluginRevert.t.sol +++ b/test/helpers/targets/TargetPluginRevert.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; -import { IPlugin } from "src/interfaces/IPlugin.sol"; +import { IPRBProxyPlugin } from "src/interfaces/IPRBProxyPlugin.sol"; -contract PluginRevert is IPlugin { +contract PluginRevert is IPRBProxyPlugin { error PluginError(); function methodList() external pure override returns (bytes4[] memory) { diff --git a/test/prb-proxy/PRBProxy.t.sol b/test/prb-proxy/PRBProxy.t.sol index 1fd1d37..abad9f7 100644 --- a/test/prb-proxy/PRBProxy.t.sol +++ b/test/prb-proxy/PRBProxy.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; -import { IPlugin } from "src/interfaces/IPlugin.sol"; +import { IPRBProxyPlugin } from "src/interfaces/IPRBProxyPlugin.sol"; import { PRBProxy } from "src/PRBProxy.sol"; import { Base_Test } from "../Base.t.sol"; @@ -43,11 +43,11 @@ contract PRBProxy_Test is Base_Test { event Execute(address indexed target, bytes data, bytes response); - event InstallPlugin(IPlugin indexed plugin); + event InstallPlugin(IPRBProxyPlugin indexed plugin); event TransferOwnership(address indexed oldOwner, address indexed newOwner); - event UninstallPlugin(IPlugin indexed plugin); + event UninstallPlugin(IPRBProxyPlugin indexed plugin); /*////////////////////////////////////////////////////////////////////////// TESTING VARIABLES diff --git a/test/prb-proxy/install-plugin/installPlugin.t.sol b/test/prb-proxy/install-plugin/installPlugin.t.sol index b81d425..268e721 100644 --- a/test/prb-proxy/install-plugin/installPlugin.t.sol +++ b/test/prb-proxy/install-plugin/installPlugin.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; -import { IPlugin } from "src/interfaces/IPlugin.sol"; import { IPRBProxy } from "src/interfaces/IPRBProxy.sol"; +import { IPRBProxyPlugin } from "src/interfaces/IPRBProxyPlugin.sol"; import { PRBProxy_Test } from "../PRBProxy.t.sol"; import { PluginDummy } from "../../helpers/plugins/PluginDummy.t.sol"; @@ -45,8 +45,8 @@ contract InstallPlugin_Test is PRBProxy_Test { // Assert that every plugin method has been installed. bytes4[] memory pluginMethods = plugins.dummy.methodList(); for (uint256 i = 0; i < pluginMethods.length; ++i) { - IPlugin actualPlugin = proxy.getPluginForMethod(pluginMethods[i]); - IPlugin expectedPlugin = plugins.dummy; + IPRBProxyPlugin actualPlugin = proxy.getPluginForMethod(pluginMethods[i]); + IPRBProxyPlugin expectedPlugin = plugins.dummy; assertEq(actualPlugin, expectedPlugin, "Plugin method not installed"); } } @@ -63,8 +63,8 @@ contract InstallPlugin_Test is PRBProxy_Test { // Assert that every plugin method has been installed. bytes4[] memory pluginMethods = plugins.dummy.methodList(); for (uint256 i = 0; i < pluginMethods.length; ++i) { - IPlugin actualPlugin = proxy.getPluginForMethod(pluginMethods[i]); - IPlugin expectedPlugin = plugins.dummy; + IPRBProxyPlugin actualPlugin = proxy.getPluginForMethod(pluginMethods[i]); + IPRBProxyPlugin expectedPlugin = plugins.dummy; assertEq(actualPlugin, expectedPlugin, "PLugin method not installed"); } } diff --git a/test/prb-proxy/uninstall-plugin/uninstallPlugin.t.sol b/test/prb-proxy/uninstall-plugin/uninstallPlugin.t.sol index 6bdd49e..8ef64ef 100644 --- a/test/prb-proxy/uninstall-plugin/uninstallPlugin.t.sol +++ b/test/prb-proxy/uninstall-plugin/uninstallPlugin.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; -import { IPlugin } from "src/interfaces/IPlugin.sol"; import { IPRBProxy } from "src/interfaces/IPRBProxy.sol"; +import { IPRBProxyPlugin } from "src/interfaces/IPRBProxyPlugin.sol"; import { PRBProxy_Test } from "../PRBProxy.t.sol"; import { PluginDummy } from "../../helpers/plugins/PluginDummy.t.sol"; @@ -42,8 +42,8 @@ contract UninstallPlugin_Test is PRBProxy_Test { // Assert that every plugin method has been uninstalled. bytes4[] memory pluginMethods = plugins.dummy.methodList(); for (uint256 i = 0; i < pluginMethods.length; ++i) { - IPlugin actualPlugin = proxy.getPluginForMethod(pluginMethods[i]); - IPlugin expectedPlugin = IPlugin(address(0)); + IPRBProxyPlugin actualPlugin = proxy.getPluginForMethod(pluginMethods[i]); + IPRBProxyPlugin expectedPlugin = IPRBProxyPlugin(address(0)); assertEq(actualPlugin, expectedPlugin, "Plugin method installed"); } } @@ -62,8 +62,8 @@ contract UninstallPlugin_Test is PRBProxy_Test { // Assert that every plugin method has been uninstalled. bytes4[] memory pluginMethods = plugins.dummy.methodList(); for (uint256 i = 0; i < pluginMethods.length; ++i) { - IPlugin actualPlugin = proxy.getPluginForMethod(pluginMethods[i]); - IPlugin expectedPlugin = IPlugin(address(0)); + IPRBProxyPlugin actualPlugin = proxy.getPluginForMethod(pluginMethods[i]); + IPRBProxyPlugin expectedPlugin = IPRBProxyPlugin(address(0)); assertEq(actualPlugin, expectedPlugin, "Plugin method installed"); } }