-
Notifications
You must be signed in to change notification settings - Fork 5
/
MultiSigWallet.sol
102 lines (73 loc) · 2.28 KB
/
MultiSigWallet.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (C) 2017-2018 MixBytes, LLC
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND (express or implied).
pragma solidity ^0.4.24;
import './multiowned.sol';
import './SimpleMultiSigWallet.sol';
import 'openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol';
/**
* @title Multisignature wallet with ERC20 tokens support.
*/
contract MultiSigWallet is SimpleMultiSigWallet {
// EVENTS
event TokensSent(address token, address indexed to, uint256 value);
// MODIFIERS
modifier notFrozen {
require(getCurrentTime() >= m_thawTs);
_;
}
// PUBLIC FUNCTIONS
constructor (address[] _owners, uint256 _signaturesRequired, uint256 _thawTs)
public
SimpleMultiSigWallet(_owners, _signaturesRequired)
{
m_thawTs = _thawTs;
}
function sendEther(address to, uint256 value)
public
notFrozen
{
super.sendEther(to, value);
}
function sendTokens(address token, address to, uint256 value)
public
notFrozen
onlymanyowners(keccak256(msg.data))
returns (bool)
{
require(address(0) != to);
require(address(0) != token);
require(token != to);
require(isContract(token));
if (ERC20Basic(token).transfer(to, value)) {
emit TokensSent(token, to, value);
return true;
}
return false;
}
// PUBLIC VIEW FUNCTIONS
function tokenBalance(address token) public view returns (uint256) {
return ERC20Basic(token).balanceOf(this);
}
function frozenUntil() public view returns (uint256) {
return m_thawTs;
}
// INTERNAL FUNCTIONS
function isContract(address _addr)
private
view
returns (bool hasCode)
{
uint256 length;
assembly { length := extcodesize(_addr) }
return length > 0;
}
function getCurrentTime() internal view returns (uint256) {
return now;
}
// FIELDS
uint256 private m_thawTs;
}