Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme ganache #3

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
11c0ff9
up
julienbrg May 5, 2017
e480b10
up
julienbrg May 5, 2017
3ec30d3
up
julienbrg May 8, 2017
6201433
async
julienbrg Jul 2, 2017
72925d9
fix candidate
julienbrg Jul 2, 2017
91b232e
test vote
julienbrg Jul 2, 2017
11b80f6
Create members.js
julienbrg Jul 2, 2017
d1f0115
minor change
julienbrg Jul 2, 2017
fc4aa51
minor change
julienbrg Jul 2, 2017
2791fe6
redo
julienbrg Jul 2, 2017
decd609
Update
julienbrg Jul 3, 2017
c45dbc3
Slight update
julienbrg Jul 3, 2017
97b9194
update next steps
julienbrg Jul 21, 2017
8a7d9ef
update next steps
julienbrg Jul 21, 2017
48525ce
add roadmap
julienbrg Jul 23, 2017
09760ce
Update 'next steps'
julienbrg Aug 31, 2017
f78d4fb
Minor update
julienbrg Aug 31, 2017
fd75b13
useless
julienbrg Sep 17, 2017
ec6b2ed
fix build
n1c01a5 Jan 27, 2018
2b563da
added votes on proposals
Xalava Jan 28, 2018
df2cec5
Merge port 9545 ganache
Xalava Jan 28, 2018
12a6d2c
updated requirements, install and run guidelines
MaloData Jan 28, 2018
17d3679
Update README.md
FinLouarn Jan 28, 2018
756f1da
Update README.md
FinLouarn Jan 28, 2018
89d1758
Update README.md
FinLouarn Jan 28, 2018
a9c3f65
improved display date and rerendering
Xalava Jan 28, 2018
7b2dc2a
Merge pull request #3 from FinLouarn/SebT-branch
julienbrg Mar 21, 2018
2689dfe
Merge pull request #1 from AbieFund/fix_build
julienbrg Mar 21, 2018
c1cca25
Slight update
julienbrg Mar 22, 2018
f5f2d33
Create Abie.sol
julienbrg Mar 27, 2018
227782d
(re)create Abie.sol
julienbrg Mar 27, 2018
fc51259
Set theme jekyll-theme-minimal
julienbrg Mar 27, 2018
8039aff
update
Apr 2, 2018
2718c6d
basic test
julienbrg May 8, 2018
610a9aa
fix time
julienbrg May 8, 2018
ad5c63d
with getAccounts
julienbrg May 8, 2018
3717e46
up
julienbrg May 8, 2018
d6fb6f5
up
julienbrg May 8, 2018
749b714
switch port
julienbrg May 8, 2018
a63278e
switch port
julienbrg May 8, 2018
c930bab
add link
julienbrg May 8, 2018
f23ae9f
up
julienbrg May 8, 2018
6058052
add node versions
julienbrg May 8, 2018
c54c8c4
add wiki
julienbrg May 8, 2018
a7bb202
up
julienbrg May 8, 2018
c2b62ba
add comment
julienbrg May 10, 2018
f287f07
up
julienbrg May 10, 2018
14c1bfa
uncomment
julienbrg May 10, 2018
f4555c4
up
julienbrg May 10, 2018
76b844b
up
julienbrg May 10, 2018
d4b8f80
up
julienbrg May 10, 2018
a0eaa2f
up
julienbrg May 10, 2018
2e8d73a
up
julienbrg May 10, 2018
e6c8bae
add ropsten
julienbrg May 10, 2018
f89dfc4
up
May 20, 2018
c419505
up
May 20, 2018
ee36c01
up
May 20, 2018
673a198
add cmd to run ganache
n1c01a5 May 21, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified LICENSE
100644 → 100755
Empty file.
538 changes: 39 additions & 499 deletions README.md
100644 → 100755

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-minimal
140 changes: 84 additions & 56 deletions contracts/AbieFund.sol → contracts/Abie.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/* Part of this contract is from the solidity documentation
TODO: Set a license.
MIT License: https://github.com/AbieFund/abie/blob/master/LICENSE
*/

pragma solidity ^0.4.8;

/// @title Fund for donations.
contract AbieFund {
/// @title The easy fund
contract Abie {

uint public membershipFee = 0.1 ether;
uint public deposit = 1 ether;
bytes32 public name;
bytes32 public statement;
uint public fee = 0.1 ether;
uint public nbMembers;
uint public nbProposalsFund;
uint public nbMembershipReq;
uint public registrationTime = 1 years;
uint[2] public voteLength = [1 weeks, 1 weeks];
uint MAX_DELEGATION_DEPTH=1000;
uint[2] public voteLength = [2 minutes, 2 minutes];
uint MAX_DELEGATION_DEPTH=10;
address NOT_COUNTED=0;
address COUNTED=1;

Expand Down Expand Up @@ -63,23 +65,25 @@ contract AbieFund {

/// Require at least price to be paid.
modifier costs(uint price) {
if (msg.value<price)
throw;
require(msg.value>=price);
_;
}

/// Require the caller to be a member.
modifier isMember() {
if(!isValidMember(msg.sender))
throw;
require(isValidMember(msg.sender));
_;
}


/// @param initialMembers First members of the organization.
function AbieFund(address[] initialMembers) {
/// @param _name The name of the DAO
/// @param _statement The statement of intent of the DAO
function Abie(bytes32 _name, bytes32 _statement, address[] initialMembers) public {

name=_name;
statement=_statement;
for (uint i;i<initialMembers.length;++i){
Member member=members[initialMembers[i]];
Member storage member=members[initialMembers[i]];
member.registration=now;
if (i==0) { // initialize the list with the first member
memberList.first=initialMembers[0];
Expand All @@ -89,11 +93,17 @@ contract AbieFund {
}
}
nbMembers=initialMembers.length;
}
// Set default member.
if (nbMembers==0){
addMember(msg.sender);
}
}

// Add the member m to the member list.
// Assume that there is at least 1 member registrated.
function addMember(address m) private {
members[m].registration=now;
++nbMembers;
members[memberList.last].succ=m;
members[m].prev=memberList.last;
memberList.last=m;
Expand All @@ -103,19 +113,19 @@ contract AbieFund {
* @param proposalType 0 for AddMember, 1 for FundProject.
* @param target account to delegate to.
*/
function setDelegate(uint8 proposalType, address target)
function setDelegate(uint8 proposalType, address target) public
{
members[msg.sender].delegate[proposalType] = target;
}

/// Receive funds.
function () payable {
function () payable public{
Donated(msg.sender, msg.value);
}

/// Ask membership of the fund.
function askMembership () payable costs(membershipFee) {
Donated(msg.sender,msg.value); // Register the donation.
/// Ask for membership.
function askMembership () payable public costs(fee) {
Donated(msg.sender,msg.value); // Register the donation.

// Create a proposal to add the member.
proposals.push(Proposal({
Expand All @@ -126,14 +136,17 @@ contract AbieFund {
value: 0x0,
data: 0x0,
proposalType: ProposalType.AddMember,
endDate: now + voteLength[uint256(ProposalType.AddMember)],
endDate: now + 2 minutes,
//voteLength[uint256(ProposalType.AddMember)],
lastMemberCounted: 0,
executed: false
}));

++nbMembershipReq;
}

/// Add Proposal.
function addProposal (bytes32 _name, uint _value, bytes32 _data) payable costs(deposit) {
function addProposal (bytes32 _name, uint _value, bytes32 _data) payable public costs(fee) {
Donated(msg.sender,msg.value); // Register the donation.

// Create a proposal to add the member.
Expand All @@ -145,7 +158,7 @@ contract AbieFund {
value: _value,
data: _data,
proposalType: ProposalType.FundProject,
endDate: now,
endDate: now + 2 minutes,
lastMemberCounted: 0,
executed: false
}));
Expand All @@ -157,20 +170,17 @@ contract AbieFund {
* @param proposalID ID of the proposal to count votes from.
* @param voteType Yes or No.
*/
function vote (uint proposalID, VoteType voteType) isMember {
Proposal proposal = proposals[proposalID];
if (proposal.vote[msg.sender] != VoteType.Abstain) // Has already voted.
throw;
if (proposal.endDate < now) // Vote is over.
throw;

function vote (uint proposalID, VoteType voteType) public isMember {
Proposal storage proposal = proposals[proposalID];
require(proposal.vote[msg.sender] == VoteType.Abstain); // Has already voted.
require(proposal.endDate >= now); // Vote is over.
proposals[proposalID].vote[msg.sender] = voteType;
}

/** Count all the votes. You can call this function if gas limit is not an issue.
* @param proposalID ID of the proposal to count votes from.
*/
function countAllVotes (uint proposalID) {
function countAllVotes (uint proposalID) public{
countVotes (proposalID,uint(-1));
}

Expand All @@ -181,28 +191,26 @@ contract AbieFund {
* @param proposalID ID of the proposal to count votes from.
* @param max maximum to count.
*/
function countVotes (uint proposalID, uint max) {
Proposal proposal = proposals[proposalID];
function countVotes (uint proposalID, uint max) public {
Proposal storage proposal = proposals[proposalID];
address current;
if (proposal.endDate > now) // You can't count while the vote is not over.
throw;
if (proposal.lastMemberCounted == COUNTED) // The count is already over
throw;
require (proposal.endDate <= now); // You can't count while the vote is not over.
require (proposal.lastMemberCounted != COUNTED); // The count is already over

if (proposal.lastMemberCounted == NOT_COUNTED)
current = memberList.first;
else
current = proposal.lastMemberCounted;

while (max-- != 0) {
Member member=members[current];
Member storage member = members[current];
address delegate=current;
if(isValidMember(current)) {
uint depth=0;
// Seach the final vote.
// Search the final vote.
while (true){
VoteType vote=proposal.vote[delegate];
if (vote==VoteType.Abstain) { // Look at the delegate
VoteType voteNow = proposal.vote[delegate];
if (voteNow==VoteType.Abstain) { // Look at the delegate
depth+=1;
delegate=members[delegate].delegate[uint(proposal.proposalType)]; // Find the delegate.
if (delegate==current // The delegation chain forms a circle.
Expand All @@ -211,10 +219,10 @@ contract AbieFund {
break;
}
}
if (vote==VoteType.Yes) {
if (voteNow==VoteType.Yes) {
proposal.voteYes+=1;
break;
} else if (vote==VoteType.No) {
} else if (voteNow==VoteType.No) {
proposal.voteNo+=1;
break;
}
Expand All @@ -228,19 +236,30 @@ contract AbieFund {
proposal.lastMemberCounted=COUNTED;
break;
}

}

}

function executeAddMemberProposal(uint proposalID) {
Proposal proposal = proposals[proposalID];
if (proposal.proposalType != ProposalType.AddMember) // Not a proposal to add a member.
throw;
if (!isExecutable(proposalID)) // Proposal was not approved.
throw;
function executeAddMemberProposal(uint proposalID) public {
Proposal storage proposal = proposals[proposalID];
require (proposal.proposalType == ProposalType.AddMember); // Not a proposal to add a member.
require (isExecutable(proposalID)); // Proposal was not approved.
proposal.executed=true; // The proposal will be executed.
addMember(proposal.recipient);

}

// The following function has NOT been reviewed so far.
function claim(uint proposalID) public payable costs(fee) {
Proposal storage proposal = proposals[proposalID];
address beneficiary = proposal.recipient;
uint value = proposal.value;
uint check = fee*2+value;
require (isExecutable(proposalID)); // rejected if not executable
require(proposal.executed == false); // rejected if executed already
require (beneficiary == msg.sender); // rejected if caller is not the beneficiary
proposal.executed = true; // The proposal is flagged ‘executed’.
proposal.executed = true; // The proposal was executed.
beneficiary.transfer(check); // The beneficiary gets the requested amount.
}

/// CONSTANTS ///
Expand All @@ -249,31 +268,40 @@ contract AbieFund {
* @param member member to get the delegate from.
* @param proposalType 0 for AddMember, 1 for FundProject.
*/
function getDelegate(address member, uint8 proposalType) constant returns (address){
function getDelegate(address member, uint8 proposalType) public constant returns (address){
return members[member].delegate[proposalType];
}

/** Return true if the proposal is validated, false otherwise.
* @param proposalID ID of the proposal to count votes from.
*/
function isExecutable(uint proposalID) constant returns (bool) {
Proposal proposal = proposals[proposalID];
function isExecutable(uint proposalID) public constant returns (bool) {
Proposal storage proposal = proposals[proposalID];

if (proposal.lastMemberCounted != COUNTED) // Not counted yet.
return false;
if (proposal.executed) // The proposal has already been executed.
return false;
if (proposal.value>this.balance) // Not enough to execute it.
if (proposal.value > address(this).balance) // Not enough to execute it.
return false;

return (proposal.voteYes>proposal.voteNo);
}

function isValidMember(address m) constant returns(bool) {
function isValidMember(address m) public constant returns(bool) {
if (members[m].registration==0) // Not a member.
return false;
if (members[m].registration+registrationTime<now) // Has expired.
return false;
return true;
}

function contractBalance() public constant returns(uint256) {
return address(this).balance;
}

function timeLeft(uint proposalID) public constant returns(uint256) {
Proposal storage proposal = proposals[proposalID];
return proposal.endDate - now;
}
}
Empty file modified contracts/Migrations.sol
100644 → 100755
Empty file.
Empty file modified migrations/1_initial_migration.js
100644 → 100755
Empty file.
12 changes: 4 additions & 8 deletions migrations/2_deploy_contracts.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
var AbieFund = artifacts.require("./AbieFund.sol");
//var Web3 = require('../node_modules/web3');

var Abie = artifacts.require("./Abie.sol");
module.exports = function(deployer) {
//var web3RPC = new Web3(deployer.provider);
deployer.deploy(AbieFund);
/*web3RPC.eth.getAccounts((error, accounts) => {
deployer.deploy(AbieFund,[accounts[0],accounts[1],accounts[2]]);
});*/
web3.eth.getAccounts((error, accounts) => {
deployer.deploy(Abie,"0x596f","0x596f",[accounts[0],accounts[1]])
});
};
Loading