Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getting real safe settings data #18

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions solidity/contracts/UpdateStorageMirrorGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {BaseGuard} from 'safe-contracts/base/GuardManager.sol';
import {Enum} from 'safe-contracts/common/Enum.sol';
import {IGuardCallbackModule} from 'interfaces/IGuardCallbackModule.sol';
import {IStorageMirror} from 'interfaces/IStorageMirror.sol';
import {ISafe} from 'interfaces/ISafe.sol';

/**
* @title UpdateStorageMirrorGuard
Expand Down Expand Up @@ -52,9 +53,11 @@ contract UpdateStorageMirrorGuard is BaseGuard {
*/
function checkAfterExecution(bytes32 _txHash, bool _success) external {
if (_success) {
address[] memory _owners = new address[](1);
_owners[0] = msg.sender;
IStorageMirror.SafeSettings memory _safeSettings = IStorageMirror.SafeSettings({owners: _owners, threshold: 1});
address[] memory _owners = ISafe(msg.sender).getOwners();
uint256 _threshold = ISafe(msg.sender).getThreshold();

IStorageMirror.SafeSettings memory _safeSettings =
IStorageMirror.SafeSettings({owners: _owners, threshold: _threshold});
bytes32 _settingsHash = keccak256(abi.encode(_safeSettings));

// NOTE: No need to reset settings as this function will only be called when the settings change
Expand Down
10 changes: 10 additions & 0 deletions solidity/test/unit/UpdateStorageMirrorGuard.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Test} from 'forge-std/Test.sol';
import {UpdateStorageMirrorGuard} from 'contracts/UpdateStorageMirrorGuard.sol';
import {IGuardCallbackModule} from 'interfaces/IGuardCallbackModule.sol';
import {IStorageMirror} from 'interfaces/IStorageMirror.sol';
import {ISafe} from 'interfaces/ISafe.sol';

abstract contract Base is Test {
event SettingsChanged(address indexed _safe, bytes32 indexed _settingsHash, IStorageMirror.SafeSettings _settings);
Expand All @@ -30,6 +31,15 @@ abstract contract Base is Test {

contract UnitUpdateStorageMirrorGuard is Base {
function testCheckAfterExecution(bytes32 _txHash) public {
address[] memory _owners = new address[](1);
_owners[0] = safe;

uint256 _threshold = 1;

vm.mockCall(address(safe), abi.encodeCall(ISafe.getOwners, ()), abi.encode(_owners));

vm.mockCall(address(safe), abi.encodeCall(ISafe.getThreshold, ()), abi.encode(_threshold));

vm.mockCall(
address(guardCallbackModule),
abi.encodeCall(IGuardCallbackModule.saveUpdatedSettings, (safe, settingsHash)),
Expand Down