Skip to content

Commit

Permalink
Merge pull request #343 from Thetta/dev
Browse files Browse the repository at this point in the history
dev -> master
  • Loading branch information
AnthonyAkentiev committed Sep 28, 2018
2 parents 3b4c3ad + 90e26c6 commit 403f5c3
Show file tree
Hide file tree
Showing 38 changed files with 1,387 additions and 3,562 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ coverage/*
coverage.json

.jsapi.json

.DS_Store
3 changes: 2 additions & 1 deletion contracts/DaoBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ contract DaoBase is IDaoBase, Ownable {
* @dev this function add address _a to group na me with name _groupName into storage
*/
function addGroupMember(string _groupName, address _a) public isCanDoOrByOwner(MANAGE_GROUPS) {
emit DaoBaseAddGroupMember(_groupName, _a);
emit DaoBaseAddGroupMember(_groupName, _a);
require(bytes(_groupName).length>0);
daoStorage.addGroupMember(stringHash(_groupName), _a);
}

Expand Down
36 changes: 18 additions & 18 deletions contracts/DaoBaseAuto.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import "./utils/UtilsLib.sol";
* Please see 'tests' folder for example.
*/
contract DaoBaseAuto is GenericCaller {
constructor(IDaoBase _dao)public
GenericCaller(_dao)
constructor(IDaoBase _daoBase)public
GenericCaller(_daoBase)
{
}

Expand All @@ -34,8 +34,8 @@ contract DaoBaseAuto is GenericCaller {
params[1] = bytes32(_a);

return doAction(
DaoBase(address(dao)).MANAGE_GROUPS(),
dao,
DaoBase(address(daoBase)).MANAGE_GROUPS(),
daoBase,
msg.sender,
"addGroupMemberGeneric(bytes32[])",
params
Expand All @@ -56,8 +56,8 @@ contract DaoBaseAuto is GenericCaller {
params[2] = bytes32(_amount);

return doAction(
DaoBase(address(dao)).ISSUE_TOKENS(),
dao,
DaoBase(address(daoBase)).ISSUE_TOKENS(),
daoBase,
msg.sender,
"issueTokensGeneric(bytes32[])",
params
Expand All @@ -74,8 +74,8 @@ contract DaoBaseAuto is GenericCaller {
params[0] = bytes32(_newMc);

return doAction(
DaoBase(address(dao)).UPGRADE_DAO_CONTRACT(),
dao,
DaoBase(address(daoBase)).UPGRADE_DAO_CONTRACT(),
daoBase,
msg.sender,
"upgradeDaoContractGeneric(bytes32[])",
params
Expand All @@ -95,8 +95,8 @@ contract DaoBaseAuto is GenericCaller {
params[1] = bytes32(_a);

return doAction(
DaoBase(address(dao)).REMOVE_GROUP_MEMBER(),
dao,
DaoBase(address(daoBase)).REMOVE_GROUP_MEMBER(),
daoBase,
msg.sender,
"removeGroupMemberGeneric(bytes32[])",
params
Expand All @@ -115,8 +115,8 @@ contract DaoBaseAuto is GenericCaller {
params[1] = bytes32(_tokenAddress);

return doAction(
DaoBase(address(dao)).ALLOW_ACTION_BY_SHAREHOLDER(),
dao,
DaoBase(address(daoBase)).ALLOW_ACTION_BY_SHAREHOLDER(),
daoBase,
msg.sender,
"allowActionByShareholderGeneric(bytes32[])",
params
Expand All @@ -135,8 +135,8 @@ contract DaoBaseAuto is GenericCaller {
params[1] = bytes32(_tokenAddress);

return doAction(
DaoBase(address(dao)).ALLOW_ACTION_BY_VOTING(),
dao,
DaoBase(address(daoBase)).ALLOW_ACTION_BY_VOTING(),
daoBase,
msg.sender,
"allowActionByVotingGeneric(bytes32[])",
params
Expand All @@ -155,8 +155,8 @@ contract DaoBaseAuto is GenericCaller {
params[1] = bytes32(_a);

return doAction(
DaoBase(address(dao)).ALLOW_ACTION_BY_ADDRESS(),
dao,
DaoBase(address(daoBase)).ALLOW_ACTION_BY_ADDRESS(),
daoBase,
msg.sender,
"allowActionByAddressGeneric(bytes32[])",
params
Expand All @@ -175,8 +175,8 @@ contract DaoBaseAuto is GenericCaller {
params[1] = UtilsLib.stringToBytes32(_groupName);

return doAction(
DaoBase(address(dao)).ALLOW_ACTION_BY_ANY_MEMBER_OF_GROUP(),
dao,
DaoBase(address(daoBase)).ALLOW_ACTION_BY_ANY_MEMBER_OF_GROUP(),
daoBase,
msg.sender,
"allowActionByAnyMemberOfGroupGeneric(bytes32[])",
params
Expand Down
20 changes: 10 additions & 10 deletions contracts/DaoBaseImpersonated.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import "./utils/UtilsLib.sol";
* Please see 'tests' folder for example.
*/
contract DaoBaseImpersonated is ImpersonationCaller {
constructor(IDaoBase _dao)public
ImpersonationCaller(_dao)
constructor(IDaoBase _daoBase)public
ImpersonationCaller(_daoBase)
{
}

Expand All @@ -38,7 +38,7 @@ contract DaoBaseImpersonated is ImpersonationCaller {
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(dao).ISSUE_TOKENS(),
DaoBase(daoBase).ISSUE_TOKENS(),
"issueTokensGeneric(bytes32[])",
params
);
Expand All @@ -57,7 +57,7 @@ contract DaoBaseImpersonated is ImpersonationCaller {
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(dao).UPGRADE_DAO_CONTRACT(),
DaoBase(daoBase).UPGRADE_DAO_CONTRACT(),
"upgradeDaoContractGeneric(bytes32[])",
params
);
Expand All @@ -78,7 +78,7 @@ contract DaoBaseImpersonated is ImpersonationCaller {
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(dao).MANAGE_GROUPS(),
DaoBase(daoBase).MANAGE_GROUPS(),
"addGroupMemberGeneric(bytes32[])",
params
);
Expand All @@ -99,7 +99,7 @@ contract DaoBaseImpersonated is ImpersonationCaller {
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(dao).REMOVE_GROUP_MEMBER(),
DaoBase(daoBase).REMOVE_GROUP_MEMBER(),
"removeGroupMemberGeneric(bytes32[])",
params
);
Expand All @@ -120,7 +120,7 @@ contract DaoBaseImpersonated is ImpersonationCaller {
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(dao).ALLOW_ACTION_BY_SHAREHOLDER(),
DaoBase(daoBase).ALLOW_ACTION_BY_SHAREHOLDER(),
"allowActionByShareholderGeneric(bytes32[])",
params
);
Expand All @@ -141,7 +141,7 @@ contract DaoBaseImpersonated is ImpersonationCaller {
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(dao).ALLOW_ACTION_BY_VOTING(),
DaoBase(daoBase).ALLOW_ACTION_BY_VOTING(),
"allowActionByVotingGeneric(bytes32[])",
params
);
Expand All @@ -162,7 +162,7 @@ contract DaoBaseImpersonated is ImpersonationCaller {
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(dao).ALLOW_ACTION_BY_ADDRESS(),
DaoBase(daoBase).ALLOW_ACTION_BY_ADDRESS(),
"allowActionByAddressGeneric(bytes32[])",
params
);
Expand All @@ -183,7 +183,7 @@ contract DaoBaseImpersonated is ImpersonationCaller {
doActionOnBehalfOf(
_hash,
_sig,
DaoBase(dao).ALLOW_ACTION_BY_ANY_MEMBER_OF_GROUP(),
DaoBase(daoBase).ALLOW_ACTION_BY_ANY_MEMBER_OF_GROUP(),
"allowActionByAnyMemberOfGroupGeneric(bytes32[])",
params
);
Expand Down
8 changes: 0 additions & 8 deletions contracts/DaoBaseLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ library DaoBaseLib {
revert(); // if not found!
}

/**
* @param _s string
* @return hash for string _s
*/
function stringHash(string _s) public pure returns(bytes32) {
return keccak256(abi.encodePacked(_s));
}

/**
* @param _daoStorage storage
* @param _p address of the proposal
Expand Down
26 changes: 13 additions & 13 deletions contracts/DaoClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ import "./IDaoObserver.sol";

/**
* @title DaoClient, just an easy-to-use wrapper.
* @dev This contract provides you with internal 'dao' variable.
* Once your DAO controller is upgraded -> all DaoClients will be notified and 'dao' var will be updated automatically.
* @dev This contract provides you with internal 'daoBase' variable.
* Once your DAO controller is upgraded -> all DaoClients will be notified and 'daoBase' var will be updated automatically.
*
* Some contracts like Votings or Auto-callers has 'dao' variable and don't use DaoClient.
* Some contracts like Votings or Auto-callers has 'daoBase' variable and don't use DaoClient.
* In this case they will stop working if the controller (DAO) is upgraded (it is as inteded).
*/
contract DaoClient is IDaoObserver {
IDaoBase dao;
IDaoBase daoBase;

modifier isCanDo(bytes32 _what) {
require(dao.isCanDoAction(msg.sender, _what));
require(daoBase.isCanDoAction(msg.sender, _what));
_;
}

constructor(IDaoBase _dao) public {
dao = _dao;
dao.addObserver(IDaoObserver(this));
constructor(IDaoBase _daoBase) public {
daoBase = _daoBase;
daoBase.addObserver(IDaoObserver(this));
}

/**
* @dev If your company is upgraded -> then this will automatically update the current dao.
* dao will point at NEW contract!
* @dev If your company is upgraded -> then this will automatically update the current daoBase.
* daoBase will point at NEW contract!
* @param _newAddress New controller.
*/
function onUpgrade(address _newAddress) public {
require(msg.sender == address(dao));
require(msg.sender == address(daoBase));

dao = IDaoBase(_newAddress);
daoBase = IDaoBase(_newAddress);

// this is not needed because we are already in the list of observers (in the store)
// and the controller is upgraded only
//dao.addObserver(this);
//daoBase.addObserver(this);
}
}
10 changes: 5 additions & 5 deletions contracts/ICO/SimpleICO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ contract SimpleICO is DaoClient, Ownable {
constructor(
uint256 _rate,
address _tokenAddress,
IDaoBase _dao,
IDaoBase _daoBase,
uint256 _minPurchase,
uint256 _maxPurchase,
uint256 _startDate,
uint256 _endDate,
uint256 _softCap,
uint256 _hardCap
) public
DaoClient(_dao)
DaoClient(_daoBase)
{
require(_rate > 0);
require(_tokenAddress != address(0));
Expand Down Expand Up @@ -101,7 +101,7 @@ contract SimpleICO is DaoClient, Ownable {
uint256 tokens = _getTokenAmount(weiAmount);
weiRaised = weiRaised.add(weiAmount);

dao.issueTokens(tokenAddress, _beneficiary, tokens);
daoBase.issueTokens(tokenAddress, _beneficiary, tokens);

emit TokenPurchase(
msg.sender,
Expand Down Expand Up @@ -160,7 +160,7 @@ contract SimpleICO is DaoClient, Ownable {
require(_addresses.length == _tokenAmounts.length);

for(uint256 i = 0; i < _addresses.length; i++) {
dao.issueTokens(tokenAddress, _addresses[i], _tokenAmounts[i]);
daoBase.issueTokens(tokenAddress, _addresses[i], _tokenAmounts[i]);
}
}

Expand All @@ -175,7 +175,7 @@ contract SimpleICO is DaoClient, Ownable {
require (_addresses.length == _tokenAmounts.length);

for(uint256 i = 0; i < _addresses.length; i++) {
dao.issueTokens(tokenAddress, _addresses[i], _tokenAmounts[i]);
daoBase.issueTokens(tokenAddress, _addresses[i], _tokenAmounts[i]);
}
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/ImpersonationCaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "./IDaoBase.sol";
* @dev This is a convenient wrapper that is used by the contract below (see DaoBaseImpersonated). Do not use it directly.
*/
contract ImpersonationCaller is DaoClient {
constructor(IDaoBase _dao) public DaoClient(_dao) {
constructor(IDaoBase _daoBase) public DaoClient(_daoBase) {
}

/**
Expand All @@ -27,10 +27,10 @@ contract ImpersonationCaller is DaoClient {
address client = ECRecovery.recover(prefixedHash, _sig);

// 2 - should be allowed to call action by a client
require(dao.isCanDoAction(client, _action));
require(daoBase.isCanDoAction(client, _action));

// 3 - call
if(!address(dao).call(
if(!address(daoBase).call(
bytes4(keccak256(abi.encodePacked(_methodSig))),
uint256(32), // pointer to the length of the array
uint256(_params.length), // length of the array
Expand Down
10 changes: 5 additions & 5 deletions contracts/governance/Voting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ contract Voting is IVoting, Ownable {
event DelegationRemoved(address _from, address _to);

/*
* @param _dao – DAO where proposal was created.
* @param _daoBase – DAO where proposal was created.
* @param _proposal – proposal, which create vote.
* @param _origin – who create voting (group member).
* @param _minutesToVote - if is zero -> voting until quorum reached, else voting finish after minutesToVote minutes
* @param _quorumPercent - percent of group members to make quorum reached. If minutesToVote==0 and quorum reached -> voting is finished
* @param _consensusPercent - percent of voters (not of group members!) to make consensus reached. If consensus reached -> voting is finished with YES result
* @param _votingType – one of the voting type, see enum votingType
* @param _groupName – for votings that for dao group members only
* @param _groupName – for votings that for daoBase group members only
* @param _tokenAddress – for votings that uses token amount of voter
*/
constructor(IDaoBase _dao, IProposal _proposal,
constructor(IDaoBase _daoBase, IProposal _proposal,
address _origin, VotingLib.VotingType _votingType,
uint _minutesToVote, string _groupName,
uint _quorumPercent, uint _consensusPercent,
address _tokenAddress) public
{
store.generalConstructor(
_dao,
_daoBase,
_proposal,
_origin,
_votingType,
Expand Down Expand Up @@ -69,7 +69,7 @@ contract Voting is IVoting, Ownable {

/**
* @return name of group
* @dev for votings that for dao group members only
* @dev for votings that for daoBase group members only
*/
function groupName() public view returns(string) {
return store.groupName;
Expand Down
Loading

0 comments on commit 403f5c3

Please sign in to comment.