forked from wanqianglvluo/safe-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored contract folder structure
- Loading branch information
Showing
24 changed files
with
107 additions
and
81 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" | ||
//); | ||
|
@@ -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. | ||
|
@@ -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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
@@ -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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
contracts/ModuleManager.sol → contracts/base/ModuleManager.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]> | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]> | ||
|
File renamed without changes.
File renamed without changes.