diff --git a/SampleOffer.sol b/SampleOffer.sol index dcab778..885dc2e 100644 --- a/SampleOffer.sol +++ b/SampleOffer.sol @@ -17,110 +17,36 @@ along with the DAO. If not, see . /* -Sample Proposal from a Contractor to the DAO. -Feel free to use as a template for your own proposal. + Sample Proposal from a Contractor to the DAO including a reward towards the + DAO. + + Feel free to use as a template for your own proposal. */ import "./DAO.sol"; +import "./SampleOfferWithoutReward.sol"; -contract SampleOffer { - - uint public totalCosts; - uint public oneTimeCosts; - uint public dailyWithdrawLimit; - - address public contractor; - bytes32 public IPFSHashOfTheProposalDocument; - uint public minDailyWithdrawLimit; - uint public paidOut; - - uint public dateOfSignature; - DAO public client; // address of DAO - DAO public originalClient; // address of DAO who signed the contract - bool public isContractValid; +contract SampleOffer is SampleOfferWithoutReward { uint public rewardDivisor; uint public deploymentReward; - modifier onlyClient { - if (msg.sender != address(client)) - throw; - _ - } - - // Prevents methods from perfoming any value transfer - modifier noEther() {if (msg.value > 0) throw; _} - - function SampleOffer( - address _contractor, - address _client, - bytes32 _IPFSHashOfTheProposalDocument, - uint _totalCosts, - uint _oneTimeCosts, - uint _minDailyWithdrawLimit - ) { - contractor = _contractor; - originalClient = DAO(_client); - client = DAO(_client); - IPFSHashOfTheProposalDocument = _IPFSHashOfTheProposalDocument; - totalCosts = _totalCosts; - oneTimeCosts = _oneTimeCosts; - minDailyWithdrawLimit = _minDailyWithdrawLimit; - dailyWithdrawLimit = _minDailyWithdrawLimit; - } - - function sign() { - if (msg.sender != address(originalClient) // no good samaritans give us money - || msg.value != totalCosts // no under/over payment - || dateOfSignature != 0) // don't sign twice - throw; - if (!contractor.send(oneTimeCosts)) - throw; - dateOfSignature = now; - isContractValid = true; - } - - function setDailyWithdrawLimit(uint _dailyWithdrawLimit) onlyClient noEther { - if (_dailyWithdrawLimit >= minDailyWithdrawLimit) - dailyWithdrawLimit = _dailyWithdrawLimit; - } - - // "fire the contractor" - function returnRemainingEther() onlyClient { - if (originalClient.DAOrewardAccount().call.value(this.balance)()) - isContractValid = false; - } - - function getDailyPayment() { - if (msg.sender != contractor) - throw; - uint amount = (now - dateOfSignature + 1 days) / (1 days) * dailyWithdrawLimit - paidOut; - if (amount > this.balance) { - amount = this.balance; + function SampleOffer( + address _contractor, + address _client, + bytes32 _IPFSHashOfTheProposalDocument, + uint _totalCosts, + uint _oneTimeCosts, + uint _minDailyWithdrawLimit + ) SampleOfferWithoutReward( + _contractor, + _client, + _IPFSHashOfTheProposalDocument, + _totalCosts, + _oneTimeCosts, + _minDailyWithdrawLimit) { } - if (contractor.send(amount)) - paidOut += amount; - } - - function setRewardDivisor(uint _rewardDivisor) onlyClient noEther { - rewardDivisor = _rewardDivisor; - } - - function setDeploymentReward(uint _deploymentReward) onlyClient noEther { - deploymentReward = _deploymentReward; - } - - // Change the client DAO by giving the new DAO's address - // warning: The new DAO must come either from a split of the original - // DAO or an update via `newContract()` so that it can claim rewards - function updateClientAddress(DAO _newClient) onlyClient noEther { - client = _newClient; - } - - function () { - throw; // this is a business contract, no donations - } - + // interface for Ethereum Computer function payOneTimeReward() returns(bool) { // client DAO should not be able to pay itself generating diff --git a/SampleOfferWithoutReward.sol b/SampleOfferWithoutReward.sol index 49a06f2..2de4dfc 100644 --- a/SampleOfferWithoutReward.sol +++ b/SampleOfferWithoutReward.sol @@ -17,13 +17,15 @@ along with the DAO. If not, see . /* -Sample Proposal from a Contractor to the DAO. -Feel free to use as a template for your own proposal. + Sample Proposal from a Contractor to the DAO without any reward going back to + the DAO. + + Feel free to use as a template for your own proposal. */ import "./DAO.sol"; -contract SampleOfferWithoutRewards { +contract SampleOfferWithoutReward { uint public totalCosts; uint public oneTimeCosts; @@ -48,7 +50,7 @@ contract SampleOfferWithoutRewards { // Prevents methods from perfoming any value transfer modifier noEther() {if (msg.value > 0) throw; _} - function SampleOffer( + function SampleOfferWithoutReward( address _contractor, address _client, bytes32 _IPFSHashOfTheProposalDocument,