Skip to content

Commit

Permalink
Improved interfaces and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Nov 12, 2024
1 parent 413c70c commit 927079d
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 132 deletions.
8 changes: 5 additions & 3 deletions src/EmergencyMultisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ contract EmergencyMultisig is IEmergencyMultisig, PluginUUPSUpgradeable, Proposa
}

// Register the approval as being made by the owner
address _owner = multisigSettings.signerList.getListedOwnerAtBlock(_sender, proposal_.parameters.snapshotBlock);
address _owner =
multisigSettings.signerList.getListedEncryptionOwnerAtBlock(_sender, proposal_.parameters.snapshotBlock);
proposal_.approvers[_owner] = true;

// We emit the event as the owner's approval
Expand Down Expand Up @@ -294,7 +295,8 @@ contract EmergencyMultisig is IEmergencyMultisig, PluginUUPSUpgradeable, Proposa
/// @inheritdoc IEmergencyMultisig
function hasApproved(uint256 _proposalId, address _account) public view returns (bool) {
Proposal storage proposal_ = proposals[_proposalId];
address _owner = multisigSettings.signerList.getListedOwnerAtBlock(_account, proposal_.parameters.snapshotBlock);
address _owner =
multisigSettings.signerList.getListedEncryptionOwnerAtBlock(_account, proposal_.parameters.snapshotBlock);

return proposals[_proposalId].approvers[_owner];
}
Expand Down Expand Up @@ -356,7 +358,7 @@ contract EmergencyMultisig is IEmergencyMultisig, PluginUUPSUpgradeable, Proposa
// This internally calls `isListedAtBlock`.
// If not listed or resolved, it returns address(0)
(address _resolvedOwner, address _resolvedVoter) =
multisigSettings.signerList.resolveAccountAtBlock(_approver, proposal_.parameters.snapshotBlock);
multisigSettings.signerList.resolveEncryptionAccountAtBlock(_approver, proposal_.parameters.snapshotBlock);
if (_resolvedOwner == address(0) || _resolvedVoter == address(0)) {
// Not listedAtBlock() nor appointed by a listed owner
return false;
Expand Down
8 changes: 5 additions & 3 deletions src/Multisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ contract Multisig is IMultisig, PluginUUPSUpgradeable, ProposalUpgradeable {
}

// Register the approval as being made by the owner. isListedAtBlock() relates to it
address _owner = multisigSettings.signerList.getListedOwnerAtBlock(_sender, proposal_.parameters.snapshotBlock);
address _owner =
multisigSettings.signerList.getListedEncryptionOwnerAtBlock(_sender, proposal_.parameters.snapshotBlock);
proposal_.approvers[_owner] = true;

// We emit the event as the owner's approval
Expand Down Expand Up @@ -296,7 +297,8 @@ contract Multisig is IMultisig, PluginUUPSUpgradeable, ProposalUpgradeable {
/// @inheritdoc IMultisig
function hasApproved(uint256 _proposalId, address _account) public view returns (bool) {
Proposal storage proposal_ = proposals[_proposalId];
address _owner = multisigSettings.signerList.getListedOwnerAtBlock(_account, proposal_.parameters.snapshotBlock);
address _owner =
multisigSettings.signerList.getListedEncryptionOwnerAtBlock(_account, proposal_.parameters.snapshotBlock);

return proposals[_proposalId].approvers[_owner];
}
Expand Down Expand Up @@ -341,7 +343,7 @@ contract Multisig is IMultisig, PluginUUPSUpgradeable, ProposalUpgradeable {
// This internally calls `isListedAtBlock`.
// If not listed or resolved, it returns address(0)
(address _resolvedOwner, address _resolvedVoter) =
multisigSettings.signerList.resolveAccountAtBlock(_approver, proposal_.parameters.snapshotBlock);
multisigSettings.signerList.resolveEncryptionAccountAtBlock(_approver, proposal_.parameters.snapshotBlock);
if (_resolvedOwner == address(0) || _resolvedVoter == address(0)) {
// Not listedAtBlock() nor appointed by a listed owner
return false;
Expand Down
8 changes: 6 additions & 2 deletions src/SignerList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ contract SignerList is ISignerList, Addresslist, ERC165Upgradeable, DaoAuthoriza
}

/// @inheritdoc ISignerList
function getListedOwnerAtBlock(address _address, uint256 _blockNumber) public view returns (address _owner) {
function getListedEncryptionOwnerAtBlock(address _address, uint256 _blockNumber)
public
view
returns (address _owner)
{
if (isListedAtBlock(_address, _blockNumber)) {
return _address;
}
Expand All @@ -127,7 +131,7 @@ contract SignerList is ISignerList, Addresslist, ERC165Upgradeable, DaoAuthoriza
}

/// @inheritdoc ISignerList
function resolveAccountAtBlock(address _address, uint256 _blockNumber)
function resolveEncryptionAccountAtBlock(address _address, uint256 _blockNumber)
public
view
returns (address _owner, address _voter)
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/ISignerList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ interface ISignerList {
/// @param sender The address to check within the list of signers or the appointed accounts.
/// @param blockNumber The block at which the list should be checked
/// @return owner If resolved to an account, it contains the encryption owner's address. Returns address(0) otherwise.
function getListedOwnerAtBlock(address sender, uint256 blockNumber) external returns (address owner);
function getListedEncryptionOwnerAtBlock(address sender, uint256 blockNumber) external returns (address owner);

/// @notice Given an address, determines the corresponding (listed) owner account and the appointed wallet, if any.
/// @return owner If listed and resolved to an account, it contains the encryption owner's address. Returns address(0) otherwise.
/// @return voter If listed and resolved, it contains the wallet address appointed for decryption, if any. Returns address(0) otherwise.
function resolveAccountAtBlock(address sender, uint256 _blockNumber)
function resolveEncryptionAccountAtBlock(address sender, uint256 _blockNumber)
external
returns (address owner, address voter);

Expand Down
Loading

0 comments on commit 927079d

Please sign in to comment.