From 3c181a17a493a0749b6d40ff745cd3327344ba88 Mon Sep 17 00:00:00 2001 From: Giorgi Lagidze Date: Sun, 6 Oct 2024 17:58:28 +0400 Subject: [PATCH] fallback to dao as a target if no target set --- contracts/src/plugin/Plugin.sol | 9 ++++++--- contracts/src/plugin/PluginCloneable.sol | 9 ++++++--- contracts/src/plugin/PluginUUPSUpgradeable.sol | 9 ++++++--- contracts/test/plugin/plugin-clonable.ts | 4 ++-- contracts/test/plugin/plugin-uups-upgradeable.ts | 4 ++-- contracts/test/plugin/plugin.ts | 4 ++-- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/contracts/src/plugin/Plugin.sol b/contracts/src/plugin/Plugin.sol index 11b33e1f..2bb52154 100644 --- a/contracts/src/plugin/Plugin.sol +++ b/contracts/src/plugin/Plugin.sol @@ -111,9 +111,10 @@ abstract contract Plugin is IPlugin, ERC165, DaoAuthorizable, ProtocolVersion { } /// @notice Forwards the actions to the currently set `target` for the execution. + /// @dev If target is not set, passes actions to the dao. /// @param _callId Identifier for this execution. /// @param _actions actions that will be eventually called. - /// @param _allowFailureMap Bitmap-encoded number. TODO: + /// @param _allowFailureMap Bitmap-encoded number. /// @return execResults address of the implementation contract. /// @return failureMap address of the implementation contract. function _execute( @@ -121,13 +122,15 @@ abstract contract Plugin is IPlugin, ERC165, DaoAuthorizable, ProtocolVersion { Action[] memory _actions, uint256 _allowFailureMap ) internal virtual returns (bytes[] memory execResults, uint256 failureMap) { + TargetConfig memory targetConfig = getTargetConfig(); + return _execute( - currentTargetConfig.target, + targetConfig.target, _callId, _actions, _allowFailureMap, - currentTargetConfig.operation + targetConfig.operation ); } diff --git a/contracts/src/plugin/PluginCloneable.sol b/contracts/src/plugin/PluginCloneable.sol index cb1704c8..7413827c 100644 --- a/contracts/src/plugin/PluginCloneable.sol +++ b/contracts/src/plugin/PluginCloneable.sol @@ -126,9 +126,10 @@ abstract contract PluginCloneable is } /// @notice Forwards the actions to the currently set `target` for the execution. + /// @dev If target is not set, passes actions to the dao. /// @param _callId Identifier for this execution. /// @param _actions actions that will be eventually called. - /// @param _allowFailureMap Bitmap-encoded number. TODO: + /// @param _allowFailureMap Bitmap-encoded number. /// @return execResults address of the implementation contract. /// @return failureMap address of the implementation contract. function _execute( @@ -136,13 +137,15 @@ abstract contract PluginCloneable is Action[] memory _actions, uint256 _allowFailureMap ) internal virtual returns (bytes[] memory execResults, uint256 failureMap) { + TargetConfig memory targetConfig = getTargetConfig(); + return _execute( - currentTargetConfig.target, + targetConfig.target, _callId, _actions, _allowFailureMap, - currentTargetConfig.operation + targetConfig.operation ); } diff --git a/contracts/src/plugin/PluginUUPSUpgradeable.sol b/contracts/src/plugin/PluginUUPSUpgradeable.sol index fa7c7c02..dcd42a71 100644 --- a/contracts/src/plugin/PluginUUPSUpgradeable.sol +++ b/contracts/src/plugin/PluginUUPSUpgradeable.sol @@ -153,9 +153,10 @@ abstract contract PluginUUPSUpgradeable is } /// @notice Forwards the actions to the currently set `target` for the execution. + /// @dev If target is not set, passes actions to the dao. /// @param _callId Identifier for this execution. /// @param _actions actions that will be eventually called. - /// @param _allowFailureMap Bitmap-encoded number. TODO: + /// @param _allowFailureMap Bitmap-encoded number. /// @return execResults address of the implementation contract. /// @return failureMap address of the implementation contract. function _execute( @@ -163,13 +164,15 @@ abstract contract PluginUUPSUpgradeable is Action[] memory _actions, uint256 _allowFailureMap ) internal virtual returns (bytes[] memory execResults, uint256 failureMap) { + TargetConfig memory targetConfig = getTargetConfig(); + return _execute( - currentTargetConfig.target, + targetConfig.target, _callId, _actions, _allowFailureMap, - currentTargetConfig.operation + targetConfig.operation ); } diff --git a/contracts/test/plugin/plugin-clonable.ts b/contracts/test/plugin/plugin-clonable.ts index 6914d46a..d797122a 100644 --- a/contracts/test/plugin/plugin-clonable.ts +++ b/contracts/test/plugin/plugin-clonable.ts @@ -271,10 +271,10 @@ describe('PluginCloneable', function () { }); describe('execute with current target', async () => { - it('reverts with ambiguity if target is not set', async () => { + it('executes on the dao if target is not set', async () => { await expect( proxy['execute(uint256,(address,uint256,bytes)[],uint256)'](1, [], 0) - ).to.be.reverted; + ).to.emit(daoMock, 'Executed'); }); describe('Execute with operation = `call`', async () => { diff --git a/contracts/test/plugin/plugin-uups-upgradeable.ts b/contracts/test/plugin/plugin-uups-upgradeable.ts index 36c70d04..44fed30e 100644 --- a/contracts/test/plugin/plugin-uups-upgradeable.ts +++ b/contracts/test/plugin/plugin-uups-upgradeable.ts @@ -284,10 +284,10 @@ describe('PluginUUPSUpgradeable', function () { }); describe('execute with current target', async () => { - it('reverts with ambiguity if target is not set', async () => { + it('executes on the dao if target is not set', async () => { await expect( proxy['execute(uint256,(address,uint256,bytes)[],uint256)'](1, [], 0) - ).to.be.reverted; + ).to.emit(daoMock, 'Executed'); }); describe('Execute with operation = `call`', async () => { diff --git a/contracts/test/plugin/plugin.ts b/contracts/test/plugin/plugin.ts index 1de5f99d..4482eb2a 100644 --- a/contracts/test/plugin/plugin.ts +++ b/contracts/test/plugin/plugin.ts @@ -214,10 +214,10 @@ describe('Plugin', function () { }); describe('execute with current target', async () => { - it('reverts with ambiguity if target is not set', async () => { + it('executes on the dao if target is not set', async () => { await expect( plugin['execute(uint256,(address,uint256,bytes)[],uint256)'](1, [], 0) - ).to.be.reverted; + ).to.emit(daoMock, 'Executed'); }); describe('Execute with operation = `call`', async () => {