Created
July 18, 2016 09:45
-
-
Save CJentzsch/488d4a544e79d0117cfb09979ab65a94 to your computer and use it in GitHub Desktop.
Relevant code for withdraw contract
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
contract DAO { | |
function balanceOf(address addr) returns (uint); | |
function transferFrom(address from, address to, uint balance) returns (bool); | |
uint public totalSupply; | |
} | |
contract WithdrawDAO { | |
DAO constant public mainDAO = DAO(0xbb9bc244d798123fde783fcc1c72d3bb8c189413); | |
address public trustee = 0xda4a4626d3e16e094de3225a751aab7128e96526; | |
function withdraw(){ | |
uint balance = mainDAO.balanceOf(msg.sender); | |
if (!mainDAO.transferFrom(msg.sender, this, balance) || !msg.sender.send(balance)) | |
throw; | |
} | |
function trusteeWithdraw() { | |
trustee.send((this.balance + mainDAO.balanceOf(this)) - mainDAO.totalSupply()); | |
} | |
} | |
Relevant functions in the DAO: https://github.com/slockit/DAO/blob/v1.0/DAO.sol | |
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { | |
if (isFueled | |
&& now > closingTime | |
&& !isBlocked(_from) | |
&& transferPaidOut(_from, _to, _value) | |
&& super.transferFrom(_from, _to, _value)) { | |
return true; | |
} else { | |
throw; | |
} | |
} | |
function isBlocked(address _account) internal returns (bool) { | |
if (blocked[_account] == 0) | |
return false; | |
Proposal p = proposals[blocked[_account]]; | |
if (now > p.votingDeadline) { | |
blocked[_account] = 0; | |
return false; | |
} else { | |
return true; | |
} | |
} | |
function transferPaidOut( | |
address _from, | |
address _to, | |
uint256 _value | |
) internal returns (bool success) { | |
uint transferPaidOut = paidOut[_from] * _value / balanceOf(_from); | |
if (transferPaidOut > paidOut[_from]) | |
throw; | |
paidOut[_from] -= transferPaidOut; | |
paidOut[_to] += transferPaidOut; | |
return true; | |
} | |
in Token.sol ("super.transferFrom"): | |
function transferFrom( | |
address _from, | |
address _to, | |
uint256 _amount | |
) noEther returns (bool success) { | |
if (balances[_from] >= _amount | |
&& allowed[_from][msg.sender] >= _amount | |
&& _amount > 0) { | |
balances[_to] += _amount; | |
balances[_from] -= _amount; | |
allowed[_from][msg.sender] -= _amount; | |
Transfer(_from, _to, _amount); | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function balanceOf(address _owner) constant returns (uint256 balance) { | |
return balances[_owner]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These are the functions that are directly invoked by the refund contract. But the refund contract implicitly relies on other functions that manipulate the data fields used in these functions.