Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 44 additions & 2 deletions contracts/universalSchemes/DaoCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,44 @@ contract DaoCreator {
controllerCreator = _controllerCreator;
}

/**
* @dev addFounders add founders to the organization.
* this function can be called only after forgeOrg and before setSchemes
* @param _avatar the organization avatar
* @param _founders An array with the addresses of the founders of the organization
* @param _foundersTokenAmount An array of amount of tokens that the founders
* receive in the new organization
* @param _foundersReputationAmount An array of amount of reputation that the
* founders receive in the new organization
* @return bool true or false
*/
function addFounders (
Avatar _avatar,
address[] _founders,
uint[] _foundersTokenAmount,
uint[] _foundersReputationAmount
)
external
returns(bool)
{
require(_founders.length == _foundersTokenAmount.length);
require(_founders.length == _foundersReputationAmount.length);
require(_founders.length > 0);
require(locks[address(_avatar)] == msg.sender);
// Mint token and reputation for founders:
for (uint i = 0 ; i < _founders.length ; i++ ) {
require(_founders[i] != address(0));
if (_foundersTokenAmount[i] > 0) {
ControllerInterface(_avatar.owner()).mintTokens(_foundersTokenAmount[i],_founders[i],address(_avatar));
}
if (_foundersReputationAmount[i] > 0) {
ControllerInterface(_avatar.owner()).mintReputation(_foundersReputationAmount[i],_founders[i],address(_avatar));
}
}
return true;

}

/**
* @dev Create a new organization
* @param _orgName The name of the new organization
Expand Down Expand Up @@ -146,8 +184,12 @@ contract DaoCreator {
// Mint token and reputation for founders:
for (uint i = 0 ; i < _founders.length ; i++ ) {
require(_founders[i] != address(0));
nativeToken.mint(_founders[i],_foundersTokenAmount[i]);
nativeReputation.mint(_founders[i],_foundersReputationAmount[i]);
if (_foundersTokenAmount[i] > 0) {
nativeToken.mint(_founders[i],_foundersTokenAmount[i]);
}
if (_foundersReputationAmount[i] > 0) {
nativeReputation.mint(_founders[i],_foundersReputationAmount[i]);
}
}

// Create Controller:
Expand Down
32 changes: 32 additions & 0 deletions test/daocreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,37 @@ contract('DaoCreator', function(accounts) {
helpers.assertVMException(ex);
}
});
it("setSchemes to none UniversalScheme and addFounders", async function() {
var amountToMint = 10;
await setup(accounts,amountToMint,amountToMint);
var foundersArray = [];
var founderReputation = [];
var founderToken = [];
var i;
var numberOfFounders = 60;
for (i=0;i<numberOfFounders;i++) {
foundersArray[i] = accounts[1];
founderReputation[i] = 1;
founderToken[i] = 1;

}
try {
await daoCreator.addFounders(avatar.address,foundersArray,founderReputation,founderToken,{from:accounts[1],gas:constants.ARC_GAS_LIMIT});
assert(false,"should revert because account is lock for account 0");
}
catch(ex){
helpers.assertVMException(ex);
}

await daoCreator.addFounders(avatar.address,foundersArray,founderReputation,founderToken,{gas:constants.ARC_GAS_LIMIT});
var rep = await reputation.reputationOf(accounts[1]);
assert.equal(rep.toNumber(),numberOfFounders);
var founderBalance = await token.balanceOf(accounts[1]);
assert.equal(founderBalance.toNumber(),numberOfFounders);
var tx = await daoCreator.setSchemes(avatar.address,[accounts[1]],[0],["0x0000000F"]);
assert.equal(tx.logs.length, 1);
assert.equal(tx.logs[0].event, "InitialSchemesSet");
assert.equal(tx.logs[0].args._avatar, avatar.address);
});

});