This repository has been archived by the owner on Dec 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
ChooseWHGReturnAddress.sol
77 lines (63 loc) · 2.8 KB
/
ChooseWHGReturnAddress.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
pragma solidity ^0.4.13;
contract Owned {
function Owned() {
owner = msg.sender;
}
address public owner;
// This contract only defines a modifier and a few useful functions
// The function body is inserted where the special symbol "_" in the
// definition of a modifier appears.
modifier onlyOwner { if (msg.sender == owner) _; }
function changeOwner(address _newOwner) onlyOwner {
owner = _newOwner;
}
// This is a general safty function that allows the owner to do a lot
// of things in the unlikely event that something goes wrong
// _dst is the contract being called making this like a 1/1 multisig
function execute(address _dst, uint _value, bytes _data) onlyOwner {
_dst.call.value(_value)(_data);
}
}
contract ChooseWHGReturnAddress is Owned {
mapping (address => address) returnAddresses;
uint public endDate;
/// @param _endDate After this time, if `requestReturn()` has not been called
/// the upgraded parity multisig will be locked in as the 'returnAddr'
function ChooseWHGReturnAddress(uint _endDate) {
endDate = _endDate;
}
/////////////////////////
// IMPORTANT
/////////////////////////
// @dev The `returnAddr` can be changed only once.
// We will send the funds to the chosen address. This is Crypto, if the
// address is wrong, your funds could be lost, please, proceed with extreme
// caution and treat this like you are sending all of your funds to this
// address.
/// @notice This function is used to choose an address for returning the funds.
/// This function can only be called once, PLEASE READ THE NOTE ABOVE.
/// @param _returnAddr The address that will receive the recued funds
function requestReturn(address _returnAddr) {
// After the end date, the newly deployed parity multisig will be
// chosen if no transaction is made.
require(now <= endDate);
require(returnAddresses[msg.sender] == 0x0);
returnAddresses[msg.sender] = _returnAddr;
ReturnRequested(msg.sender, _returnAddr);
}
/// @notice This is a simple getter function that will be used to return the
/// address that the WHG will return the funds to
/// @param _addr The address of the newly deployed parity multisig
/// @return address The chosen address that the funds will be returned to
function getReturnAddress(address _addr) constant returns (address) {
if (returnAddresses[_addr] == 0x0) {
return _addr;
} else {
return returnAddresses[_addr];
}
}
function isReturnRequested(address _addr) constant returns (bool) {
return returnAddresses[_addr] != 0x0;
}
event ReturnRequested(address indexed origin, address indexed returnAddress);
}