Skip to content

Commit

Permalink
Merge pull request #169 from orcaprotocol/willkim/qsp-14
Browse files Browse the repository at this point in the history
fix: QSP-14
  • Loading branch information
Will Kim authored Oct 25, 2022
2 parents 0e07b8e + b55bd23 commit a2b5a94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
13 changes: 2 additions & 11 deletions contracts/SafeTeller.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
pragma solidity ^0.8.7;

import "./utils/DelegateSetupHelper.sol";
import "openzeppelin-contracts/utils/Address.sol";
import "./interfaces/IGnosisSafe.sol";
import "./interfaces/IGnosisSafeProxyFactory.sol";

contract SafeTeller {
contract SafeTeller is DelegateSetupHelper {
using Address for address;

// mainnet: 0x76E2cFc1F5Fa8F6a5b3fC4c8F4788F0116861F9B;
Expand Down Expand Up @@ -384,14 +385,4 @@ contract SafeTeller {
IGnosisSafe.Operation.Call
);
}

// TODO: move to library
// Used in a delegate call to enable module add on setup
function enableModule(address module) external {
require(module == address(0));
}

function delegateSetup(address _context) external {
this.enableModule(_context);
}
}
21 changes: 21 additions & 0 deletions contracts/utils/DelegateSetupHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pragma solidity 0.8.7;

// These functions are not used by the SafeTeller directly, so have been moved
// to their own contract
contract DelegateSetupHelper {
// In our `SafeTeller.createSafe()` function, we call `GnosisSafeProxyFactory.createProxyWithNonce()`
// with a callback to this `delegateSetup()` function. The proxy factory will then call this function
// via a delegate call.
// In the context of this delegate call, `this` will refer to the proxy factory, which then in turn makes a
// delegate call to GnosisSafe, and `this` will then refer to GnosisSafe
// therefore this function will call `GnosisSafe.enableModule()`, which is inherited from `ModuleManager`.
function delegateSetup(address _context) external {
this.enableModule(_context);
}

// This function is here solely to allow compilation.
// This function should not be called, see the above doc block for explanation.
function enableModule(address) external {
revert("should not be called");
}
}

0 comments on commit a2b5a94

Please sign in to comment.