Created
July 29, 2016 22:05
-
-
Save AlexeyAkhunov/3150341e8b38f39a090d4433ae4448ab 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
contract DAO { | |
function balanceOf(address addr) returns (uint); | |
function transferFrom(address from, address to, uint balance) returns (bool); | |
uint public totalSupply; | |
function getNewDAOAddress(uint _proposalID) constant returns(address _newDAO); | |
} | |
/** | |
* @title trustedChildRefund | |
* @author Paul Szczesny | |
* A simple refund contract for trusted childDAOs affected by the hard fork. | |
* Based on the official WithdrawDAO contract found here: https://etherscan.io/address/0xbf4ed7b27f1d666546e30d74d50d173d20bca754#code | |
*/ | |
contract trustedChildRefund { | |
DAO constant public mainDAO = DAO(0xbb9bc244d798123fde783fcc1c72d3bb8c189413); | |
uint[] constant trustedProposals = [7, 10, 16, 20, 23, 26, 27, 28, 29, 31, 34, 37, 39, 41, 44, 52, 54, 56, 57, 60, 61, 63, 64, 65, 66]; | |
mapping (uint => DAO) public whiteList; | |
function trustedChildRefund() { | |
for(uint i=0; i<trustedProposals.length; i++) { | |
uint proposalId = trustedProposals[i]; | |
whiteList[proposalId] = mainDAO.getNewDAOAddress(proposalId); | |
} | |
} | |
/** | |
* Function call to refund ETH by burning childDao tokens. | |
* @param proposalId The split proposal ID which created the childDao | |
* @dev This requires that the token-holder authorizes this contract's address using the approve() function. | |
*/ | |
function refund(uint proposalId) { | |
//Check the token balance | |
uint balance = whiteList[proposalId].balanceOf(msg.sender); | |
// Transfer childDao tokens first, then send Ether back in return | |
if (!whiteList[proposalId].transferFrom(msg.sender, this, balance) || !msg.sender.send(balance)) | |
throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment