Skip to content

Commit

Permalink
Emergency multisig tests complete
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed May 9, 2024
1 parent 47d59ab commit ecaab89
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 104 deletions.
22 changes: 11 additions & 11 deletions src/EmergencyMultisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ contract EmergencyMultisig is IEmergencyMultisig, IMembership, PluginUUPSUpgrade
/// @notice Emitted when the plugin settings are set.
/// @param onlyListed Whether only listed addresses can create a proposal.
/// @param minApprovals The minimum amount of approvals needed to pass a proposal.
event MultisigSettingsUpdated(bool onlyListed, uint16 indexed minApprovals);
/// @param addresslistSource The address of the contract holding the address list to use.
event MultisigSettingsUpdated(bool onlyListed, uint16 indexed minApprovals, Addresslist addresslistSource);

/// @notice Initializes Release 1, Build 1.
/// @dev This method is required to support [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822).
Expand Down Expand Up @@ -376,26 +377,25 @@ contract EmergencyMultisig is IEmergencyMultisig, IMembership, PluginUUPSUpgrade
/// @notice Internal function to update the plugin settings.
/// @param _multisigSettings The new settings.
function _updateMultisigSettings(MultisigSettings calldata _multisigSettings) internal {
uint16 addresslistLength_ = uint16(multisigSettings.addresslistSource.addresslistLength());

if (_multisigSettings.minApprovals > addresslistLength_) {
revert MinApprovalsOutOfBounds({limit: addresslistLength_, actual: _multisigSettings.minApprovals});
}

if (_multisigSettings.minApprovals < 1) {
if (!IERC165(address(_multisigSettings.addresslistSource)).supportsInterface(type(Addresslist).interfaceId)) {
revert InvalidAddressListSource();
} else if (_multisigSettings.minApprovals < 1) {
revert MinApprovalsOutOfBounds({limit: 1, actual: _multisigSettings.minApprovals});
}

if (!IERC165(address(_multisigSettings.addresslistSource)).supportsInterface(type(Addresslist).interfaceId)) {
revert InvalidAddressListSource();
uint16 addresslistLength_ = uint16(_multisigSettings.addresslistSource.addresslistLength());

if (_multisigSettings.minApprovals > addresslistLength_) {
revert MinApprovalsOutOfBounds({limit: addresslistLength_, actual: _multisigSettings.minApprovals});
}

multisigSettings = _multisigSettings;
lastMultisigSettingsChange = block.number.toUint64();

emit MultisigSettingsUpdated({
onlyListed: _multisigSettings.onlyListed,
minApprovals: _multisigSettings.minApprovals
minApprovals: _multisigSettings.minApprovals,
addresslistSource: _multisigSettings.addresslistSource
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/OptimisticTokenVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ contract OptimisticTokenVotingPlugin is
++i;
}
}

// For emergency multisig: execute if already possible
if (canExecute(proposalId)) {
execute(proposalId);
}
}

/// @inheritdoc IOptimisticTokenVoting
Expand Down
Loading

0 comments on commit ecaab89

Please sign in to comment.