Skip to content

Commit

Permalink
Refactored contract folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
rmeissner committed Aug 22, 2018
1 parent 77e3b6a commit 943f3e6
Show file tree
Hide file tree
Showing 24 changed files with 107 additions and 81 deletions.
32 changes: 0 additions & 32 deletions contracts/GnosisSafe.sol

This file was deleted.

51 changes: 28 additions & 23 deletions contracts/GnosisSafePersonalEdition.sol
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
pragma solidity 0.4.24;
import "./GnosisSafe.sol";
import "./MasterCopy.sol";
import "./SignatureDecoder.sol";
import "./SecuredTokenTransfer.sol";

contract ISingatureValidator {
/**
* @dev Should return whether the signature provided is valid for the provided data
* @param _data Arbitrary length data signed on the behalf of address(this)
* @param _signature Signature byte array associated with _data
*
* MUST return a bool upon valid or invalid signature with corresponding _data
* MUST take (bytes, bytes) as arguments
*/
function isValidSignature(
bytes _data,
bytes _signature)
public
view
returns (bool isValid);
}
import "./base/BaseSafe.sol";
import "./common/MasterCopy.sol";
import "./common/SignatureDecoder.sol";
import "./common/SecuredTokenTransfer.sol";
import "./interfaces/ISignatureValidator.sol";

/// @title Gnosis Safe Personal Edition - A multisignature wallet with support for confirmations using signed messages based on ERC191.
/// @author Stefan George - <[email protected]>
/// @author Richard Meissner - <[email protected]>
/// @author Ricardo Guilherme Schmidt - (Status Research & Development GmbH) - Gas Token Payment
contract GnosisSafePersonalEdition is MasterCopy, GnosisSafe, SignatureDecoder, SecuredTokenTransfer, ISingatureValidator {
contract GnosisSafePersonalEdition is MasterCopy, BaseSafe, SignatureDecoder, SecuredTokenTransfer, ISignatureValidator {

string public constant NAME = "Gnosis Safe Personal Edition";
string public constant VERSION = "0.0.1";

//keccak256(
// "EIP712Domain(address verifyingContract)"
//);
bytes32 public constant DOMAIN_SEPERATOR_TYPEHASH = 0x035aff83d86937d35b32e04f0ddc6ff469290eef2f1b692d8a815c89404d4749;

//keccak256(
// "PersonalSafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 dataGas,uint256 gasPrice,address gasToken,uint256 nonce)"
//);
bytes32 public constant SAFE_TX_TYPEHASH = 0x068c3b33cc9bff6dde08209527b62abfb1d4ed576706e2078229623d72374b5b;

//keccak256(
// "PersonalSafeMessage(bytes message)"
//);
Expand All @@ -41,8 +32,22 @@ contract GnosisSafePersonalEdition is MasterCopy, GnosisSafe, SignatureDecoder,
event ExecutionFailed(bytes32 txHash);

uint256 public nonce;
bytes32 public domainSeperator;
mapping(bytes32 => uint256) signedMessage;

/// @dev Setup function sets initial storage of contract.
/// @param _owners List of Safe owners.
/// @param _threshold Number of required confirmations for a Safe transaction.
/// @param to Contract address for optional delegate call.
/// @param data Data payload for optional delegate call.
function setup(address[] _owners, uint256 _threshold, address to, bytes data)
public
{
require(domainSeperator == 0, "Domain Seperator already set!");
domainSeperator = keccak256(abi.encode(DOMAIN_SEPERATOR_TYPEHASH, this));
setupSafe(_owners, _threshold, to, data);
}

/// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.
/// Note: The fees are always transfered, even if the user transaction fails.
/// @param to Destination address of Safe transaction.
Expand Down Expand Up @@ -124,7 +129,7 @@ contract GnosisSafePersonalEdition is MasterCopy, GnosisSafe, SignatureDecoder,
// The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s
contractSignature := add(add(signatures, s), 0x20)
}
if (!ISingatureValidator(currentOwner).isValidSignature(message, contractSignature)) {
if (!ISignatureValidator(currentOwner).isValidSignature(message, contractSignature)) {
return false;
}
} else {
Expand Down
17 changes: 14 additions & 3 deletions contracts/GnosisSafeTeamEdition.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pragma solidity 0.4.24;
import "./GnosisSafe.sol";
import "./MasterCopy.sol";
import "./base/BaseSafe.sol";
import "./common/MasterCopy.sol";


/// @title Gnosis Safe Team Edition - A multisignature wallet with support for confirmations.
/// @author Stefan George - <[email protected]>
/// @author Richard Meissner - <[email protected]>
contract GnosisSafeTeamEdition is MasterCopy, GnosisSafe {
contract GnosisSafeTeamEdition is MasterCopy, BaseSafe {

string public constant NAME = "Gnosis Safe Team Edition";
string public constant VERSION = "0.0.1";
Expand All @@ -22,6 +22,17 @@ contract GnosisSafeTeamEdition is MasterCopy, GnosisSafe {
// uint256 is used to optimize the generated assembly. if 0 then false else true
mapping (bytes32 => mapping(address => uint256)) public isApproved;

/// @dev Setup function sets initial storage of contract.
/// @param _owners List of Safe owners.
/// @param _threshold Number of required confirmations for a Safe transaction.
/// @param to Contract address for optional delegate call.
/// @param data Data payload for optional delegate call.
function setup(address[] _owners, uint256 _threshold, address to, bytes data)
public
{
setupSafe(_owners, _threshold, to, data);
}

/// @dev Allows to confirm a Safe transaction with a regular transaction.
/// This can only be done from an owner address.
/// @param transactionHash Hash of the Safe transaction.
Expand Down
24 changes: 24 additions & 0 deletions contracts/base/BaseSafe.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pragma solidity 0.4.24;
import "./Module.sol";
import "./ModuleManager.sol";
import "./OwnerManager.sol";


/// @title Base Safe - A multisignature wallet with support for modules and owners. This contract needs to be extented to add functionality to execute transactions.
/// @author Stefan George - <[email protected]>
/// @author Richard Meissner - <[email protected]>
contract BaseSafe is ModuleManager, OwnerManager {

/// @dev Setup function sets initial storage of contract.
/// @param _owners List of Safe owners.
/// @param _threshold Number of required confirmations for a Safe transaction.
/// @param to Contract address for optional delegate call.
/// @param data Data payload for optional delegate call.
function setupSafe(address[] _owners, uint256 _threshold, address to, bytes data)
internal
{
setupOwners(_owners, _threshold);
// As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules
setupModules(to, data);
}
}
4 changes: 2 additions & 2 deletions contracts/Executor.sol → contracts/base/Executor.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity 0.4.24;
import "./Enum.sol";
import "./EtherPaymentFallback.sol";
import "../common/Enum.sol";
import "../common/EtherPaymentFallback.sol";


/// @title Executor - A contract that can execute transactions
Expand Down
2 changes: 1 addition & 1 deletion contracts/Module.sol → contracts/base/Module.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma solidity 0.4.24;
import "./MasterCopy.sol";
import "../common/MasterCopy.sol";
import "./ModuleManager.sol";


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity 0.4.24;
import "./Enum.sol";
import "../common/Enum.sol";
import "../common/SelfAuthorized.sol";
import "./Executor.sol";
import "./Module.sol";
import "./SelfAuthorized.sol";


/// @title Module Manager - A contract that manages modules that can execute transactions via this contract
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma solidity 0.4.24;
import "./SelfAuthorized.sol";
import "../common/SelfAuthorized.sol";

/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.
/// @author Stefan George - <[email protected]>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions contracts/interfaces/ISignatureValidator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pragma solidity 0.4.24;

contract ISignatureValidator {
/**
* @dev Should return whether the signature provided is valid for the provided data
* @param _data Arbitrary length data signed on the behalf of address(this)
* @param _signature Signature byte array associated with _data
*
* MUST return a bool upon valid or invalid signature with corresponding _data
* MUST take (bytes, bytes) as arguments
*/
function isValidSignature(
bytes _data,
bytes _signature)
public
view
returns (bool isValid);
}
2 changes: 1 addition & 1 deletion contracts/libraries/CreateAndAddModules.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma solidity 0.4.24;
import "../Module.sol";
import "../base/Module.sol";


/// @title Create and Add Modules - Allows to create and add multiple module in one transaction.
Expand Down
8 changes: 4 additions & 4 deletions contracts/modules/DailyLimitModule.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity 0.4.24;
import "../Module.sol";
import "../ModuleManager.sol";
import "../OwnerManager.sol";
import "../Enum.sol";
import "../base/Module.sol";
import "../base/ModuleManager.sol";
import "../base/OwnerManager.sol";
import "../common/Enum.sol";


/// @title Daily Limit Module - Allows to transfer limited amounts of ERC20 tokens and Ether without confirmations.
Expand Down
8 changes: 4 additions & 4 deletions contracts/modules/SocialRecoveryModule.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity 0.4.24;
import "../Enum.sol";
import "../Module.sol";
import "../ModuleManager.sol";
import "../OwnerManager.sol";
import "../base/Module.sol";
import "../base/ModuleManager.sol";
import "../base/OwnerManager.sol";
import "../common/Enum.sol";


/// @title Social Recovery Module - Allows to replace an owner without Safe confirmations if friends approve the replacement.
Expand Down
6 changes: 3 additions & 3 deletions contracts/modules/StateChannelModule.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity 0.4.24;
import "../Module.sol";
import "../OwnerManager.sol";
import "../SignatureDecoder.sol";
import "../base/Module.sol";
import "../base/OwnerManager.sol";
import "../common/SignatureDecoder.sol";


/// @title Gnosis Safe State Module - A module that allows interaction with statechannels.
Expand Down
8 changes: 4 additions & 4 deletions contracts/modules/WhitelistModule.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity 0.4.24;
import "../Enum.sol";
import "../Module.sol";
import "../ModuleManager.sol";
import "../OwnerManager.sol";
import "../base/Module.sol";
import "../base/ModuleManager.sol";
import "../base/OwnerManager.sol";
import "../common/Enum.sol";


/// @title Whitelist Module - Allows to execute transactions to whitelisted addresses without confirmations.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity 0.4.24;
import "../common/SecuredTokenTransfer.sol";
import "./DelegateConstructorProxy.sol";
import "./SecuredTokenTransfer.sol";

/// @title Paying Proxy - Generic proxy contract allows to execute all transactions applying the code of a master contract. It is possible to send along initialization data with the constructor. And sends funds after creation to a specified account.
/// @author Stefan George - <[email protected]>
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 943f3e6

Please sign in to comment.