Skip to content

Commit dcb15dd

Browse files
committed
add SampleOfferWithoutReward
1 parent 0d216d5 commit dcb15dd

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

SampleOfferWithoutReward.sol

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
This file is part of the DAO.
3+
4+
The DAO is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU lesser General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
The DAO is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU lesser General Public License
15+
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
19+
/*
20+
Sample Proposal from a Contractor to the DAO.
21+
Feel free to use as a template for your own proposal.
22+
*/
23+
24+
import "./DAO.sol";
25+
26+
contract SampleOfferWithoutRewards {
27+
28+
uint public totalCosts;
29+
uint public oneTimeCosts;
30+
uint public dailyWithdrawLimit;
31+
32+
address public contractor;
33+
bytes32 public IPFSHashOfTheProposalDocument;
34+
uint public minDailyWithdrawLimit;
35+
uint public paidOut;
36+
37+
uint public dateOfSignature;
38+
DAO public client; // address of DAO
39+
DAO public originalClient; // address of DAO who signed the contract
40+
bool public isContractValid;
41+
42+
modifier onlyClient {
43+
if (msg.sender != address(client))
44+
throw;
45+
_
46+
}
47+
48+
// Prevents methods from perfoming any value transfer
49+
modifier noEther() {if (msg.value > 0) throw; _}
50+
51+
function SampleOffer(
52+
address _contractor,
53+
address _client,
54+
bytes32 _IPFSHashOfTheProposalDocument,
55+
uint _totalCosts,
56+
uint _oneTimeCosts,
57+
uint _minDailyWithdrawLimit
58+
) {
59+
contractor = _contractor;
60+
originalClient = DAO(_client);
61+
client = DAO(_client);
62+
IPFSHashOfTheProposalDocument = _IPFSHashOfTheProposalDocument;
63+
totalCosts = _totalCosts;
64+
oneTimeCosts = _oneTimeCosts;
65+
minDailyWithdrawLimit = _minDailyWithdrawLimit;
66+
dailyWithdrawLimit = _minDailyWithdrawLimit;
67+
}
68+
69+
function sign() {
70+
if (msg.sender != address(originalClient) // no good samaritans give us money
71+
|| msg.value != totalCosts // no under/over payment
72+
|| dateOfSignature != 0) // don't sign twice
73+
throw;
74+
if (!contractor.send(oneTimeCosts))
75+
throw;
76+
dateOfSignature = now;
77+
isContractValid = true;
78+
}
79+
80+
function setDailyWithdrawLimit(uint _dailyWithdrawLimit) onlyClient noEther {
81+
if (_dailyWithdrawLimit >= minDailyWithdrawLimit)
82+
dailyWithdrawLimit = _dailyWithdrawLimit;
83+
}
84+
85+
// "fire the contractor"
86+
function returnRemainingEther() onlyClient {
87+
if (originalClient.DAOrewardAccount().call.value(this.balance)())
88+
isContractValid = false;
89+
}
90+
91+
function getDailyPayment() {
92+
if (msg.sender != contractor)
93+
throw;
94+
uint amount = (now - dateOfSignature + 1 days) / (1 days) * dailyWithdrawLimit - paidOut;
95+
if (contractor.send(amount))
96+
paidOut += amount;
97+
}
98+
99+
// Change the client DAO by giving the new DAO's address
100+
// warning: The new DAO must come either from a split of the original
101+
// DAO or an update via `newContract()` so that it can claim rewards
102+
function updateClientAddress(DAO _newClient) onlyClient noEther {
103+
client = _newClient;
104+
}
105+
106+
function () {
107+
throw; // this is a business contract, no donations
108+
}
109+
}

0 commit comments

Comments
 (0)