Created
September 22, 2017 18:32
-
-
Save 3esmit/f6cb7ebffa769ca1d6a8af89111be7b5 to your computer and use it in GitHub Desktop.
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
pragma solidity ^0.4.15; | |
import "./DelegatedCall.sol"; | |
//import "./LibraryReg.sol"; | |
/** | |
* @title MultiSigStub | |
* Contract that delegates calls to a library to build a full MultiSigWallet that is cheap to create. | |
*/ | |
contract MultiSigStub is DelegatedCall { | |
address[] public owners; | |
address[] public tokens; | |
mapping (uint => Transaction) public transactions; | |
mapping (uint => mapping (address => bool)) public confirmations; | |
uint public transactionCount; | |
struct Transaction { | |
address destination; | |
uint value; | |
bytes data; | |
bool executed; | |
} | |
function MultiSigStub(address[] _owners, uint256 _required) { | |
//bytes4 sig = bytes4(sha3("constructor(address[],uint256)")); | |
_getLibraryReg().update(); | |
bytes4 sig = 0x36756a23; | |
uint argarraysize = (2 + _owners.length); | |
uint argsize = (1 + argarraysize) * 32; | |
uint size = 4 + argsize; | |
bytes32 mData = _malloc(size); | |
assembly { | |
mstore(mData, sig) | |
codecopy(add(mData, 0x4), sub(codesize, argsize), argsize) | |
} | |
_delegatecall(mData, size); | |
} | |
function _getDelegatedContract() | |
internal | |
returns(address) | |
{ | |
return _getLibraryReg().addressReg(address(this)); | |
} | |
function _getLibraryReg() private returns (LibraryReg) { | |
return LibraryReg(0xcafecafecafecafecafecafecafecafecafecafe); | |
} | |
function() | |
payable | |
delegated | |
{ | |
} | |
function submitTransaction(address destination, uint value, bytes data) | |
public | |
delegated | |
returns (uint) | |
{ | |
} | |
function confirmTransaction(uint transactionId) | |
public | |
delegated | |
{ | |
} | |
function watch(address _tokenAddr) | |
public | |
delegated | |
{ | |
} | |
function setMyTokenList(address[] _tokenList) | |
public | |
delegated | |
{ | |
} | |
/// @dev Returns the confirmation status of a transaction. | |
/// @param transactionId Transaction ID. | |
/// @return Confirmation status. | |
function isConfirmed(uint transactionId) | |
public | |
constant | |
delegated | |
returns (bool) | |
{ | |
} | |
/* | |
* Web3 call functions | |
*/ | |
function tokenBalances(address tokenAddress) | |
public | |
constant | |
delegated | |
returns (uint) | |
{ | |
} | |
/// @dev Returns number of confirmations of a transaction. | |
/// @param transactionId Transaction ID. | |
/// @return Number of confirmations. | |
function getConfirmationCount(uint transactionId) | |
public | |
constant | |
delegated | |
returns (uint) | |
{ | |
} | |
/// @dev Returns total number of transactions after filters are applied. | |
/// @param pending Include pending transactions. | |
/// @param executed Include executed transactions. | |
/// @return Total number of transactions after filters are applied. | |
function getTransactionCount(bool pending, bool executed) | |
public | |
constant | |
delegated | |
returns (uint) | |
{ | |
} | |
/// @dev Returns list of owners. | |
/// @return List of owner addresses. | |
function getOwners() | |
public | |
constant | |
returns (address[]) | |
{ | |
return owners; | |
} | |
/// @dev Returns list of tokens. | |
/// @return List of token addresses. | |
function getTokenList() | |
public | |
constant | |
returns (address[]) | |
{ | |
return tokens; | |
} | |
/// @dev Returns array with owner addresses, which confirmed transaction. | |
/// @param transactionId Transaction ID. | |
/// @return Returns array of owner addresses. | |
function getConfirmations(uint transactionId) | |
public | |
constant | |
returns (address[] _confirmations) | |
{ | |
address[] memory confirmationsTemp = new address[](owners.length); | |
uint count = 0; | |
uint i; | |
for (i = 0; i < owners.length; i++) { | |
if (confirmations[transactionId][owners[i]]) { | |
confirmationsTemp[count] = owners[i]; | |
count += 1; | |
} | |
} | |
_confirmations = new address[](count); | |
for (i = 0; i < count; i++) { | |
_confirmations[i] = confirmationsTemp[i]; | |
} | |
} | |
/// @dev Returns list of transaction IDs in defined range. | |
/// @param from Index start position of transaction array. | |
/// @param to Index end position of transaction array. | |
/// @param pending Include pending transactions. | |
/// @param executed Include executed transactions. | |
/// @return Returns array of transaction IDs. | |
function getTransactionIds(uint from, uint to, bool pending, bool executed) | |
public | |
constant | |
returns (uint[] _transactionIds) | |
{ | |
uint[] memory transactionIdsTemp = new uint[](transactionCount); | |
uint count = 0; | |
uint i; | |
for (i = 0; i < transactionCount; i++) { | |
if (pending && !transactions[i].executed || executed && transactions[i].executed) { | |
transactionIdsTemp[count] = i; | |
count += 1; | |
} | |
} | |
_transactionIds = new uint[](to - from); | |
for (i = from; i < to; i++) { | |
_transactionIds[i - from] = transactionIdsTemp[i]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment