Skip to content

Commit

Permalink
fallback to dao as a target if no target set
Browse files Browse the repository at this point in the history
  • Loading branch information
novaknole committed Oct 6, 2024
1 parent 55a0cc6 commit 3c181a1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
9 changes: 6 additions & 3 deletions contracts/src/plugin/Plugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,26 @@ 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(
bytes32 _callId,
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
);
}

Expand Down
9 changes: 6 additions & 3 deletions contracts/src/plugin/PluginCloneable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,26 @@ 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(
bytes32 _callId,
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
);
}

Expand Down
9 changes: 6 additions & 3 deletions contracts/src/plugin/PluginUUPSUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,26 @@ 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(
bytes32 _callId,
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
);
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/test/plugin/plugin-clonable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/plugin/plugin-uups-upgradeable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 3c181a1

Please sign in to comment.