diff --git a/contracts/schemes/ArcScheme.sol b/contracts/schemes/ArcScheme.sol index f7814272..96133b6f 100644 --- a/contracts/schemes/ArcScheme.sol +++ b/contracts/schemes/ArcScheme.sol @@ -4,20 +4,12 @@ import "../controller/Avatar.sol"; import "@daostack/infra-experimental/contracts/votingMachines/GenesisProtocol.sol"; import "@daostack/infra-experimental/contracts/votingMachines/IntVoteInterface.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol"; -import "../utils/DAOFactory.sol"; -import "../libs/StringUtil.sol"; contract ArcScheme is Initializable { - using StringUtil for string; Avatar public avatar; IntVoteInterface public votingMachine; - - string public constant GENESIS_PROTOCOL_INIT_FUNC_SIGNATURE = - "initialize(address,uint256[11],address,address,address,address)"; - - string public constant ABSOLUTE_VOTE_INIT_FUNC_SIGNATURE = - "initialize(uint256,address,address,address,address)"; + bytes32 public voteParamsHash; /** * @dev _initialize @@ -32,60 +24,35 @@ contract ArcScheme is Initializable { /** * @dev _initializeGovernance * @param _avatar the scheme avatar + * @param _votingMachine the scheme voting machine + * @param _voteParamsHash the scheme vote params * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _callbacks should fulfill voting callbacks interface - * @param _authorizedToPropose only this address allow to propose (unless it is zero) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero */ function _initializeGovernance( Avatar _avatar, + IntVoteInterface _votingMachine, + bytes32 _voteParamsHash, uint256[11] memory _votingParams, - address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - address _callbacks, - address _authorizedToPropose, - uint64[3] memory _packageVersion, - string memory _votingMachineName + address _voteOnBehalf ) internal { - - require(_daoFactory != DAOFactory(0), "daoFactory cannot be zero"); - require( - _daoFactory.getImplementation(_packageVersion, _votingMachineName) != address(0), - "votingMachine name does not exist in ArcHive" - ); + require(_votingMachine != IntVoteInterface(0), "votingMachine cannot be zero"); _initialize(_avatar); - - bytes memory initData; - if (_votingMachineName.hashCompareWithLengthCheck("GenesisProtocol")) { - initData = abi.encodeWithSignature( - GENESIS_PROTOCOL_INIT_FUNC_SIGNATURE, - _stakingToken, - _votingParams, - _voteOnBehalf, - avatar, - _callbacks, - _authorizedToPropose); + votingMachine = _votingMachine; + if (_voteParamsHash == bytes32(0)) { + //genesisProtocol + GenesisProtocol genesisProtocol = GenesisProtocol(address(_votingMachine)); + voteParamsHash = genesisProtocol.getParametersHash(_votingParams, _voteOnBehalf); + (uint256 queuedVoteRequiredPercentage, , , , , , , , , , , ,) = + genesisProtocol.parameters(voteParamsHash); + if (queuedVoteRequiredPercentage == 0) { + //params not set already + genesisProtocol.setParameters(_votingParams, _voteOnBehalf); + } } else { - initData = abi.encodeWithSignature( - ABSOLUTE_VOTE_INIT_FUNC_SIGNATURE, - _votingParams[0], - _voteOnBehalf, - avatar, - _callbacks, - _authorizedToPropose); + //for other voting machines + voteParamsHash = _voteParamsHash; } - - votingMachine = IntVoteInterface(address(_daoFactory.createInstance( - _packageVersion, - _votingMachineName, - address(avatar), - initData))); - } } diff --git a/contracts/schemes/ContributionReward.sol b/contracts/schemes/ContributionReward.sol index 6a0e75bf..e1c49020 100644 --- a/contracts/schemes/ContributionReward.sol +++ b/contracts/schemes/ContributionReward.sol @@ -65,35 +65,22 @@ contract ContributionReward is /** * @dev initialize * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _votingMachine the voting machines address to + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters. */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName + bytes32 _voteParamsHash ) external initializer { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); } /** @@ -140,7 +127,7 @@ contract ContributionReward is returns(bytes32) { validateProposalParams(_reputationChange, _rewards); - bytes32 proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar)); address payable beneficiary = _beneficiary; if (beneficiary == address(0)) { beneficiary = msg.sender; diff --git a/contracts/schemes/ContributionRewardExt.sol b/contracts/schemes/ContributionRewardExt.sol index b8eaf895..9ed35b0b 100644 --- a/contracts/schemes/ContributionRewardExt.sol +++ b/contracts/schemes/ContributionRewardExt.sol @@ -83,37 +83,30 @@ contract ContributionRewardExt is VotingMachineCallbacks, ProposalExecuteInterfa /** * @dev initialize - * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _avatar the avatar to mint reputation from + * @param _votingMachine the voting machines address + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters + * @param _daoFactory DAOFactory instance to instance a rewarder. + * if _daoFactory is zero so no rewarder will be set. + * @param _packageVersion packageVersion to instance the rewarder from. * @param _rewarderName the rewarder contract name. + */ function initialize( Avatar _avatar, - uint256[11] calldata _votingParams, + IntVoteInterface _votingMachine, + uint[11] calldata _votingParams, address _voteOnBehalf, + bytes32 _voteParamsHash, DAOFactory _daoFactory, - address _stakingToken, uint64[3] calldata _packageVersion, - string calldata _votingMachineName, string calldata _rewarderName ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); vault = new Vault(); vault.initialize(address(this)); if (bytes(_rewarderName).length != 0) { @@ -170,7 +163,7 @@ contract ContributionRewardExt is VotingMachineCallbacks, ProposalExecuteInterfa if (proposer == address(0)) { proposer = msg.sender; } - proposalId = votingMachine.propose(2, proposer); + proposalId = votingMachine.propose(2, voteParamsHash, proposer, address(avatar)); address payable beneficiary = _beneficiary; if (beneficiary == address(0)) { beneficiary = msg.sender; diff --git a/contracts/schemes/ControllerUpgradeScheme.sol b/contracts/schemes/ControllerUpgradeScheme.sol index 635a3301..47df3d12 100644 --- a/contracts/schemes/ControllerUpgradeScheme.sol +++ b/contracts/schemes/ControllerUpgradeScheme.sol @@ -41,34 +41,21 @@ contract ControllerUpgradeScheme is VotingMachineCallbacks, ProposalExecuteInter /** * @dev initialize * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _votingMachine the voting machines address to + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters. */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName + bytes32 _voteParamsHash ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); } /** @@ -116,7 +103,7 @@ contract ControllerUpgradeScheme is VotingMachineCallbacks, ProposalExecuteInter public returns(bytes32) { - bytes32 proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar)); UpgradeProposal memory proposal = UpgradeProposal({ proposalType: 1, upgradeContract: _newController @@ -148,7 +135,7 @@ contract ControllerUpgradeScheme is VotingMachineCallbacks, ProposalExecuteInter public returns(bytes32) { - bytes32 proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar)); require(organizationProposals[proposalId].proposalType == 0); UpgradeProposal memory proposal = UpgradeProposal({ diff --git a/contracts/schemes/FundingRequest.sol b/contracts/schemes/FundingRequest.sol index 3665a490..ec99430b 100644 --- a/contracts/schemes/FundingRequest.sol +++ b/contracts/schemes/FundingRequest.sol @@ -46,36 +46,23 @@ contract FundingRequest is /** * @dev initialize * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _votingMachine the voting machines address to + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters. * @param _fundingToken token to transfer to funding requests. 0x0 address for the native coin */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName, + bytes32 _voteParamsHash, IERC20 _fundingToken ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); fundingToken = _fundingToken; } @@ -117,7 +104,7 @@ contract FundingRequest is avatar.db(FUNDED_BEFORE_DEADLINE_KEY).hashCompareWithLengthCheck(FUNDED_BEFORE_DEADLINE_VALUE), "funding is not allowed yet" ); - bytes32 proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar)); address payable beneficiary = _beneficiary; if (beneficiary == address(0)) { beneficiary = msg.sender; diff --git a/contracts/schemes/GenericScheme.sol b/contracts/schemes/GenericScheme.sol index 5a4c2fe6..229ee307 100644 --- a/contracts/schemes/GenericScheme.sol +++ b/contracts/schemes/GenericScheme.sol @@ -47,37 +47,24 @@ contract GenericScheme is VotingMachineCallbacks, ProposalExecuteInterface { /** * @dev initialize - * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _avatar the avatar to mint reputation from + * @param _votingMachine the voting machines address to + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters. * @param _contractToCall the target contract this scheme will call to */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName, + bytes32 _voteParamsHash, address _contractToCall ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); contractToCall = _contractToCall; } @@ -142,7 +129,7 @@ contract GenericScheme is VotingMachineCallbacks, ProposalExecuteInterface { public returns(bytes32) { - bytes32 proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar)); organizationProposals[proposalId] = CallProposal({ callData: _callData, diff --git a/contracts/schemes/GlobalConstraintRegistrar.sol b/contracts/schemes/GlobalConstraintRegistrar.sol index 4ae6ae56..1d44d503 100644 --- a/contracts/schemes/GlobalConstraintRegistrar.sol +++ b/contracts/schemes/GlobalConstraintRegistrar.sol @@ -10,12 +10,12 @@ import "../votingMachines/VotingMachineCallbacks.sol"; * @dev The scheme is used to register or remove new global constraints */ contract GlobalConstraintRegistrar is VotingMachineCallbacks, ProposalExecuteInterface { - event NewGlobalConstraintsProposal( address indexed _avatar, bytes32 indexed _proposalId, address indexed _intVoteInterface, address _gc, + bytes32 _voteToRemoveParams, string _descriptionHash ); @@ -29,47 +29,39 @@ contract GlobalConstraintRegistrar is VotingMachineCallbacks, ProposalExecuteInt event ProposalExecuted(address indexed _avatar, bytes32 indexed _proposalId, int256 _param); event ProposalDeleted(address indexed _avatar, bytes32 indexed _proposalId); + event D(bool x); // The struct that holds the information of a global constraint proposed to be added or removed. struct GCProposal { address gc; // The address of the global constraint contract. bool addGC; // true: add a GC, false: remove a GC. + bytes32 voteToRemoveParams; // Voting parameters for removing this GC. } // GCProposal by avatar and proposalId mapping(bytes32=>GCProposal) public organizationProposals; + // voteToRemoveParams hash by avatar and proposal.gc + mapping(address=>bytes32) public voteToRemoveParams; + /** * @dev initialize * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _votingMachine the voting machines address to + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters. */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName + bytes32 _voteParamsHash ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); } /** @@ -99,6 +91,7 @@ contract GlobalConstraintRegistrar is VotingMachineCallbacks, ProposalExecuteInt // Adding a GC if (proposal.addGC) { retVal = controller.addGlobalConstraint(proposal.gc); + voteToRemoveParams[proposal.gc] = proposal.voteToRemoveParams; } // Removing a GC if (!proposal.addGC) { @@ -112,21 +105,23 @@ contract GlobalConstraintRegistrar is VotingMachineCallbacks, ProposalExecuteInt /** * @dev propose to add a new global constraint: * @param _gc the address of the global constraint that is being proposed + * @param _voteToRemoveParams the conditions (on the voting machine) for removing this global constraint * @param _descriptionHash proposal's description hash * @return bytes32 -the proposal id */ function proposeGlobalConstraint( address _gc, - string calldata _descriptionHash - ) - external + bytes32 _voteToRemoveParams, + string memory _descriptionHash) + public returns(bytes32) { - bytes32 proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar)); GCProposal memory proposal = GCProposal({ gc: _gc, - addGC: true + addGC: true, + voteToRemoveParams: _voteToRemoveParams }); organizationProposals[proposalId] = proposal; @@ -135,6 +130,7 @@ contract GlobalConstraintRegistrar is VotingMachineCallbacks, ProposalExecuteInt proposalId, address(votingMachine), _gc, + _voteToRemoveParams, _descriptionHash ); proposalsBlockNumber[proposalId] = block.number; @@ -150,11 +146,17 @@ contract GlobalConstraintRegistrar is VotingMachineCallbacks, ProposalExecuteInt function proposeToRemoveGC(address _gc, string memory _descriptionHash) public returns(bytes32) { Controller controller = Controller(avatar.owner()); require(controller.isGlobalConstraintRegistered(_gc), "proposed gc is not register"); - bytes32 proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose( + 2, + voteToRemoveParams[_gc], + msg.sender, + address(avatar) + ); GCProposal memory proposal = GCProposal({ gc: _gc, - addGC: false + addGC: false, + voteToRemoveParams: 0 }); organizationProposals[proposalId] = proposal; diff --git a/contracts/schemes/JoinAndQuit.sol b/contracts/schemes/JoinAndQuit.sol index 2fb09d0b..97d1be7f 100644 --- a/contracts/schemes/JoinAndQuit.sol +++ b/contracts/schemes/JoinAndQuit.sol @@ -1,5 +1,4 @@ pragma solidity ^0.5.17; -pragma experimental ABIEncoderV2; import "../votingMachines/VotingMachineCallbacks.sol"; import "../libs/StringUtil.sol"; @@ -67,72 +66,51 @@ contract JoinAndQuit is mapping(bytes32=>Proposal) public proposals; mapping(address=>MemberFund) public fundings; - struct JoinAndQuitParams { - IERC20 fundingToken; //the funding token - if this is zero the donation will be in native token ETH - uint256 minFeeToJoin; //minimum fee required to join - uint256 memberReputation; //the repution which will be allocated for members - //if this param is zero so the repution will be - //allocated proportional to the fee paid - uint256 fundingGoal; //the funding goal - uint256 fundingGoalDeadline; //the funding goal deadline - bool rageQuitEnable; //rageQuit enabling flag - } - - JoinAndQuitParams public joinAndQuitParams; + IERC20 public fundingToken; + uint256 public minFeeToJoin; + uint256 public memberReputation; + uint256 public fundingGoal; + uint256 public fundingGoalDeadline; uint256 public totalDonation; + bool public rageQuitEnable; /** * @dev initialize * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. - * @param _encodedJoinAndQuitParams encoded JoinAndQuitParams + * @param _votingMachine the voting machines address to + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters. + * @param _fundingToken the funding token - if this is zero the donation will be in native token ETH + * @param _minFeeToJoin minimum fee required to join + * @param _memberReputation the repution which will be allocated for members + if this param is zero so the repution will be allocated proportional to the fee paid + * @param _fundingGoal the funding goal + * @param _fundingGoalDeadline the funding goal deadline + * @param _rageQuitEnable rageQuit enabling flag */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName, - bytes calldata _encodedJoinAndQuitParams + bytes32 _voteParamsHash, + IERC20 _fundingToken, + uint256 _minFeeToJoin, + uint256 _memberReputation, + uint256 _fundingGoal, + uint256 _fundingGoalDeadline, + bool _rageQuitEnable ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); - - ( - address fundingToken, - uint256 minFeeToJoin, - uint256 memberReputation, - uint256 fundingGoal, - uint256 fundingGoalDeadline, - bool rageQuitEnable - ) = - abi.decode(_encodedJoinAndQuitParams, (address, uint256, uint256, uint256, uint256, bool)); - - joinAndQuitParams = JoinAndQuitParams({ - fundingToken: IERC20(fundingToken), - minFeeToJoin: minFeeToJoin, - memberReputation: memberReputation, - fundingGoal: fundingGoal, - fundingGoalDeadline: fundingGoalDeadline, - rageQuitEnable: rageQuitEnable - }); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); + fundingToken = _fundingToken; + minFeeToJoin = _minFeeToJoin; + memberReputation = _memberReputation; + fundingGoal = _fundingGoal; + fundingGoalDeadline = _fundingGoalDeadline; + rageQuitEnable = _rageQuitEnable; } /** @@ -151,23 +129,23 @@ contract JoinAndQuit is // Check if vote was successful: if ((_decision == 1) && (avatar.nativeReputation().balanceOf(proposal.proposedMember) == 0)) { proposals[_proposalId].accepted = true; - if (joinAndQuitParams.fundingToken == IERC20(0)) { + if (fundingToken == IERC20(0)) { // solhint-disable-next-line avoid-call-value (success, ) = address(avatar).call.value(proposal.funding)(""); require(success, "sendEther to avatar failed"); } else { - joinAndQuitParams.fundingToken.safeTransfer(address(avatar), proposal.funding); + fundingToken.safeTransfer(address(avatar), proposal.funding); } fundings[proposal.proposedMember].funding = proposal.funding; totalDonation = totalDonation.add(proposal.funding); setFundingGoalReachedFlag(); } else { - if (joinAndQuitParams.fundingToken == IERC20(0)) { + if (fundingToken == IERC20(0)) { // solhint-disable-next-line avoid-call-value (success, ) = proposal.proposedMember.call.value(proposal.funding)(""); require(success, "sendEther to avatar failed"); } else { - joinAndQuitParams.fundingToken.safeTransfer(proposal.proposedMember, proposal.funding); + fundingToken.safeTransfer(proposal.proposedMember, proposal.funding); } } fundings[proposal.proposedMember].candidate = false; @@ -192,14 +170,14 @@ contract JoinAndQuit is address proposer = msg.sender; require(!fundings[proposer].candidate, "already a candidate"); require(avatar.nativeReputation().balanceOf(proposer) == 0, "already a member"); - require(_feeAmount >= joinAndQuitParams.minFeeToJoin, "_feeAmount should be >= then the minFeeToJoin"); + require(_feeAmount >= minFeeToJoin, "_feeAmount should be >= then the minFeeToJoin"); fundings[proposer].candidate = true; - if (joinAndQuitParams.fundingToken == IERC20(0)) { + if (fundingToken == IERC20(0)) { require(_feeAmount == msg.value, "ETH received shoul match the _feeAmount"); } else { - joinAndQuitParams.fundingToken.safeTransferFrom(proposer, address(this), _feeAmount); + fundingToken.safeTransferFrom(proposer, address(this), _feeAmount); } - bytes32 proposalId = votingMachine.propose(2, proposer); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, proposer, address(avatar)); Proposal memory proposal = Proposal({ accepted: false, @@ -233,10 +211,10 @@ contract JoinAndQuit is //set proposal proposedMember to zero to prevent reentrancy attack. proposal.proposedMember = address(0); require(proposal.accepted == true, " proposal not accepted"); - if (joinAndQuitParams.memberReputation == 0) { + if (memberReputation == 0) { reputation = _proposal.funding; } else { - reputation = joinAndQuitParams.memberReputation; + reputation = memberReputation; } require( Controller( @@ -250,7 +228,7 @@ contract JoinAndQuit is */ function refund() public returns(uint256 refundAmount) { // solhint-disable-next-line not-rely-on-time - require(now > joinAndQuitParams.fundingGoalDeadline, "can refund only after fundingGoalDeadline"); + require(now > fundingGoalDeadline, "can refund only after fundingGoalDeadline"); require( (avatar.db(FUNDED_BEFORE_DEADLINE_KEY).hashCompareWithLengthCheck(FUNDED_BEFORE_DEADLINE_VALUE) == false), "can refund only if funding goal not reached"); @@ -268,16 +246,15 @@ contract JoinAndQuit is * @return refundAmount the refund amount */ function rageQuit() public returns(uint256 refundAmount) { - require(joinAndQuitParams.rageQuitEnable, "RageQuit disabled"); + require(rageQuitEnable, "RageQuit disabled"); require(fundings[msg.sender].funding > 0, "no fund to RageQuit"); uint256 userDonation = fundings[msg.sender].funding; fundings[msg.sender].funding = 0; fundings[msg.sender].rageQuit = true; - if (joinAndQuitParams.fundingToken == IERC20(0)) { + if (fundingToken == IERC20(0)) { refundAmount = userDonation.mul(address(avatar.vault()).balance).div(totalDonation); } else { - refundAmount = - userDonation.mul(joinAndQuitParams.fundingToken.balanceOf(address(avatar))).div(totalDonation); + refundAmount = userDonation.mul(fundingToken.balanceOf(address(avatar))).div(totalDonation); } sendToBeneficiary(refundAmount, msg.sender); uint256 msgSenderReputation = avatar.nativeReputation().balanceOf(msg.sender); @@ -293,16 +270,16 @@ contract JoinAndQuit is */ function setFundingGoalReachedFlag() public { uint256 avatarBalance; - if (joinAndQuitParams.fundingToken == IERC20(0)) { + if (fundingToken == IERC20(0)) { avatarBalance = (address(avatar.vault())).balance; } else { - avatarBalance = joinAndQuitParams.fundingToken.balanceOf(address(avatar)); + avatarBalance = fundingToken.balanceOf(address(avatar)); } if ((avatar.db(CommonInterface.FUNDED_BEFORE_DEADLINE_KEY) .hashCompareWithLengthCheck(CommonInterface.FUNDED_BEFORE_DEADLINE_VALUE) == false) && - (avatarBalance >= joinAndQuitParams.fundingGoal) && + (avatarBalance >= fundingGoal) && // solhint-disable-next-line not-rely-on-time - (now < joinAndQuitParams.fundingGoalDeadline)) { + (now < fundingGoalDeadline)) { require( Controller( avatar.owner()). @@ -317,15 +294,14 @@ contract JoinAndQuit is * @param _beneficiary the beneficiary */ function sendToBeneficiary(uint256 _amount, address payable _beneficiary) private { - if (joinAndQuitParams.fundingToken == IERC20(0)) { + if (fundingToken == IERC20(0)) { require( Controller( avatar.owner()).sendEther(_amount, _beneficiary), "send ether failed"); } else { require( Controller( - avatar.owner()).externalTokenTransfer(joinAndQuitParams.fundingToken, _beneficiary, _amount), - "send token failed"); + avatar.owner()).externalTokenTransfer(fundingToken, _beneficiary, _amount), "send token failed"); } } diff --git a/contracts/schemes/SchemeFactory.sol b/contracts/schemes/SchemeFactory.sol index 7e925014..cc805d79 100644 --- a/contracts/schemes/SchemeFactory.sol +++ b/contracts/schemes/SchemeFactory.sol @@ -42,35 +42,23 @@ contract SchemeFactory is VotingMachineCallbacks, ProposalExecuteInterface { /** * @dev initialize * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _votingMachine the voting machines address to + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters to register scheme. + * @param _daoFactory daoFactory contract */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName + bytes32 _voteParamsHash, + DAOFactory _daoFactory ) external { - - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); daoFactory = _daoFactory; } @@ -144,7 +132,12 @@ contract SchemeFactory is VotingMachineCallbacks, ProposalExecuteInterface { revert("proposal must have a scheme name to reister or address to unregister"); } - bytes32 proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose( + 2, + voteParamsHash, + msg.sender, + address(avatar) + ); Proposal memory proposal = Proposal({ schemeName: _schemeName, diff --git a/contracts/schemes/SchemeRegistrar.sol b/contracts/schemes/SchemeRegistrar.sol index c9cba51d..e22608c0 100644 --- a/contracts/schemes/SchemeRegistrar.sol +++ b/contracts/schemes/SchemeRegistrar.sol @@ -43,34 +43,57 @@ contract SchemeRegistrar is VotingMachineCallbacks, ProposalExecuteInterface { /** * @dev initialize * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _votingMachine the voting machines address to + * @param _votingParamsRegister genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalfRegister genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteRegisterParamsHash voting machine parameters to register scheme. + * @param _votingParamsRemove genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalfRemove genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteRemoveParamsHash voting machine parameters to remove scheme. */ function initialize( Avatar _avatar, - uint256[11] calldata _votingParams, - address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName + IntVoteInterface _votingMachine, + uint[11] calldata _votingParamsRegister, + address _voteOnBehalfRegister, + bytes32 _voteRegisterParamsHash, + uint[11] calldata _votingParamsRemove, + address _voteOnBehalfRemove, + bytes32 _voteRemoveParamsHash ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initialize(_avatar); + votingMachine = _votingMachine; + if (_voteRegisterParamsHash == bytes32(0)) { + //genesisProtocol + GenesisProtocol genesisProtocol = GenesisProtocol(address(_votingMachine)); + voteRegisterParamsHash = genesisProtocol.getParametersHash(_votingParamsRegister, _voteOnBehalfRegister); + (uint256 queuedVoteRequiredPercentage, , , , , , , , , , , ,) = + genesisProtocol.parameters(voteRegisterParamsHash); + if (queuedVoteRequiredPercentage == 0) { + //params not set already + genesisProtocol.setParameters(_votingParamsRegister, _voteOnBehalfRegister); + } + } else { + //for other voting machines + voteRegisterParamsHash = _voteRegisterParamsHash; + } + + if (_voteRemoveParamsHash == bytes32(0)) { + //genesisProtocol + GenesisProtocol genesisProtocol = GenesisProtocol(address(_votingMachine)); + voteRemoveParamsHash = genesisProtocol.getParametersHash(_votingParamsRemove, _voteOnBehalfRemove); + (uint256 queuedVoteRequiredPercentage, , , , , , , , , , , ,) = + genesisProtocol.parameters(voteRemoveParamsHash); + if (queuedVoteRequiredPercentage == 0) { + //params not set already + genesisProtocol.setParameters(_votingParamsRemove, _voteOnBehalfRemove); + } + } else { + //for other voting machines + voteRemoveParamsHash = _voteRemoveParamsHash; + } } /** @@ -121,12 +144,17 @@ contract SchemeRegistrar is VotingMachineCallbacks, ProposalExecuteInterface { string memory _descriptionHash ) public - returns(bytes32 proposalId) + returns(bytes32) { // propose require(_scheme != address(0), "scheme cannot be zero"); - proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose( + 2, + voteRegisterParamsHash, + msg.sender, + address(avatar) + ); SchemeProposal memory proposal = SchemeProposal({ scheme: _scheme, @@ -143,6 +171,7 @@ contract SchemeRegistrar is VotingMachineCallbacks, ProposalExecuteInterface { ); organizationProposals[proposalId] = proposal; proposalsBlockNumber[proposalId] = block.number; + return proposalId; } /** @@ -153,13 +182,14 @@ contract SchemeRegistrar is VotingMachineCallbacks, ProposalExecuteInterface { */ function proposeToRemoveScheme(address _scheme, string memory _descriptionHash) public - returns(bytes32 proposalId) + returns(bytes32) { require(_scheme != address(0), "scheme cannot be zero"); - proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteRemoveParamsHash, msg.sender, address(avatar)); organizationProposals[proposalId].scheme = _scheme; emit RemoveSchemeProposal(address(avatar), proposalId, address(votingMachine), _scheme, _descriptionHash); proposalsBlockNumber[proposalId] = block.number; + return proposalId; } } diff --git a/contracts/schemes/SignalScheme.sol b/contracts/schemes/SignalScheme.sol index 9178ccfc..71e1873f 100644 --- a/contracts/schemes/SignalScheme.sol +++ b/contracts/schemes/SignalScheme.sol @@ -30,43 +30,39 @@ contract SignalScheme is VotingMachineCallbacks, ProposalExecuteInterface { bool executed; } - uint256 public signalType; + struct Parameters { + bytes32 voteApproveParams; + IntVoteInterface intVote; + uint256 signalType; + } mapping(bytes32 => Proposal) public proposals; + Parameters public params; + /** * @dev initialize - * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _avatar the scheme avatar * @param _signalType - signal types + * @param _voteApproveParams voting machine params + * @param _votingMachine voting machine address + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero */ - function initialize( - Avatar _avatar, - uint256[11] calldata _votingParams, - address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName, - uint256 _signalType) + function initialize(Avatar _avatar, + uint256 _signalType, + bytes32 _voteApproveParams, + IntVoteInterface _votingMachine, + uint256[11] calldata _votingParams, + address _voteOnBehalf) external initializer { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); - signalType = _signalType; + super._initializeGovernance(_avatar, _votingMachine, _voteApproveParams, _votingParams, _voteOnBehalf); + params = Parameters({ + voteApproveParams: voteParamsHash, + signalType: _signalType, + intVote: _votingMachine + }); } /** @@ -77,23 +73,29 @@ contract SignalScheme is VotingMachineCallbacks, ProposalExecuteInterface { string calldata _descriptionHash ) external - returns(bytes32 proposalId) + returns(bytes32) { require(Controller(avatar.owner()).isSchemeRegistered(address(this)), "scheme is not registered"); - proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = params.intVote.propose( + 2, + params.voteApproveParams, + msg.sender, + address(avatar) + ); proposals[proposalId].descriptionHash = _descriptionHash; emit NewSignalProposal( address(avatar), proposalId, - signalType, + params.signalType, _descriptionHash ); proposalsBlockNumber[proposalId] = block.number; + return proposalId; } /** @@ -108,7 +110,7 @@ contract SignalScheme is VotingMachineCallbacks, ProposalExecuteInterface { if (_param == 1) { emit Signal(address(avatar), _proposalId, - signalType, + params.signalType, proposals[_proposalId].descriptionHash); } return true; diff --git a/contracts/schemes/UpgradeScheme.sol b/contracts/schemes/UpgradeScheme.sol index 2f50fcb7..c38ae0ed 100644 --- a/contracts/schemes/UpgradeScheme.sol +++ b/contracts/schemes/UpgradeScheme.sol @@ -46,38 +46,23 @@ contract UpgradeScheme is VotingMachineCallbacks, ProposalExecuteInterface { /** * @dev initialize - * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. - * @param _arcPackage the arc package to upgrade from + * @param _avatar the avatar to mint reputation from + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters. */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName, - Package _arcPackage + bytes32 _voteParamsHash, + Package _package ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); - arcPackage = _arcPackage; + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); + arcPackage = _package; } /** @@ -133,7 +118,7 @@ contract UpgradeScheme is VotingMachineCallbacks, ProposalExecuteInterface { address[] memory _contractsToUpgrade, string memory _descriptionHash) public - returns(bytes32 proposalId) + returns(bytes32) { require(_contractsNames.length <= 60, "can upgrade up to 60 contracts at a time"); require( @@ -150,7 +135,7 @@ contract UpgradeScheme is VotingMachineCallbacks, ProposalExecuteInterface { ); } - proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar)); organizationProposals[proposalId] = Proposal({ packageVersion: _packageVersion, @@ -167,5 +152,6 @@ contract UpgradeScheme is VotingMachineCallbacks, ProposalExecuteInterface { _contractsToUpgrade, _descriptionHash ); + return proposalId; } } diff --git a/contracts/schemes/VoteInOrganizationScheme.sol b/contracts/schemes/VoteInOrganizationScheme.sol index bd7111f7..3b18d9d9 100644 --- a/contracts/schemes/VoteInOrganizationScheme.sol +++ b/contracts/schemes/VoteInOrganizationScheme.sol @@ -34,34 +34,21 @@ contract VoteInOrganizationScheme is VotingMachineCallbacks, ProposalExecuteInte /** * @dev initialize * @param _avatar the avatar this scheme referring to. - * @param _votingParams genesisProtocol parameters - * @param _voteOnBehalf parameter - * @param _daoFactory DAOFactory instance to instance a votingMachine. - * @param _stakingToken (for GenesisProtocol) - * @param _packageVersion packageVersion to instance the votingMachine from. - * @param _votingMachineName the votingMachine contract name. + * @param _votingMachine the voting machines address to + * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero + * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero + * @param _voteParamsHash voting machine parameters. */ function initialize( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName + bytes32 _voteParamsHash ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); } /** @@ -115,14 +102,14 @@ contract VoteInOrganizationScheme is VotingMachineCallbacks, ProposalExecuteInte uint256 _vote, string memory _descriptionHash) public - returns(bytes32 proposalId) + returns(bytes32) { (uint256 minVote, uint256 maxVote) = _originalIntVote.getAllowedRangeOfChoices(); require(_vote <= maxVote && _vote >= minVote, "vote should be in the allowed range"); require(_vote <= _originalIntVote.getNumberOfChoices(_originalProposalId), "vote should be <= original proposal number of choices"); - proposalId = votingMachine.propose(2, msg.sender); + bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar)); organizationProposals[proposalId] = VoteProposal({ originalIntVote: _originalIntVote, @@ -140,5 +127,6 @@ contract VoteInOrganizationScheme is VotingMachineCallbacks, ProposalExecuteInte _descriptionHash ); proposalsBlockNumber[proposalId] = block.number; + return proposalId; } } diff --git a/contracts/test/SchemeMock.sol b/contracts/test/SchemeMock.sol index 8bb53037..e5aac255 100644 --- a/contracts/test/SchemeMock.sol +++ b/contracts/test/SchemeMock.sol @@ -16,25 +16,14 @@ contract SchemeMock is ArcScheme { function initializeGovernance( Avatar _avatar, + IntVoteInterface _votingMachine, uint256[11] calldata _votingParams, address _voteOnBehalf, - DAOFactory _daoFactory, - address _stakingToken, - uint64[3] calldata _packageVersion, - string calldata _votingMachineName, + bytes32 _voteParamsHash, uint256 _testData ) external { - super._initializeGovernance( - _avatar, - _votingParams, - _voteOnBehalf, - _daoFactory, - _stakingToken, - address(this), - address(this), - _packageVersion, - _votingMachineName); + super._initializeGovernance(_avatar, _votingMachine, _voteParamsHash, _votingParams, _voteOnBehalf); testData = _testData; } diff --git a/package-lock.json b/package-lock.json index 4ca921f6..2c4fc255 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "@daostack/arc-experimental", - "version": "0.1.1-rc.22", + "version": "0.1.1-rc.23", "lockfileVersion": 1, "requires": true, "dependencies": { "@babel/cli": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.10.1.tgz", - "integrity": "sha512-cVB+dXeGhMOqViIaZs3A9OUAe4pKw4SBNdMw6yHJMYR7s4TB+Cei7ThquV/84O19PdIFWuwe03vxxES0BHUm5g==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.8.4.tgz", + "integrity": "sha512-XXLgAm6LBbaNxaGhMAznXXaxtCWfuv6PIDJ9Alsy9JYTOh+j2jJz+L/162kkfU1j/pTSxK1xGmlwI4pdIMkoag==", "dev": true, "requires": { "chokidar": "^2.1.8", @@ -46,101 +46,101 @@ } }, "@babel/code-frame": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz", - "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", "dev": true, "requires": { - "@babel/highlight": "^7.10.1" + "@babel/highlight": "^7.8.3" } }, "@babel/generator": { - "version": "7.10.2", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.2.tgz", - "integrity": "sha512-AxfBNHNu99DTMvlUPlt1h2+Hn7knPpH5ayJ8OqDWSeLld+Fi2AYBTC/IejWDM9Edcii4UzZRCsbUt0WlSDsDsA==", + "version": "7.9.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.6.tgz", + "integrity": "sha512-+htwWKJbH2bL72HRluF8zumBxzuX0ZZUFl3JLNyoUjM/Ho8wnVpPXM6aUz8cfKDqQ/h7zHqKt4xzJteUosckqQ==", "dev": true, "requires": { - "@babel/types": "^7.10.2", + "@babel/types": "^7.9.6", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" } }, "@babel/helper-function-name": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.1.tgz", - "integrity": "sha512-fcpumwhs3YyZ/ttd5Rz0xn0TpIwVkN7X0V38B9TWNfVF42KEkhkAAuPCQ3oXmtTRtiPJrmZ0TrfS0GKF0eMaRQ==", + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz", + "integrity": "sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.10.1", - "@babel/template": "^7.10.1", - "@babel/types": "^7.10.1" + "@babel/helper-get-function-arity": "^7.8.3", + "@babel/template": "^7.8.3", + "@babel/types": "^7.9.5" } }, "@babel/helper-get-function-arity": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.1.tgz", - "integrity": "sha512-F5qdXkYGOQUb0hpRaPoetF9AnsXknKjWMZ+wmsIRsp5ge5sFh4c3h1eH2pRTTuy9KKAA2+TTYomGXAtEL2fQEw==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz", + "integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==", "dev": true, "requires": { - "@babel/types": "^7.10.1" + "@babel/types": "^7.8.3" } }, "@babel/helper-split-export-declaration": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz", - "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", + "integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==", "dev": true, "requires": { - "@babel/types": "^7.10.1" + "@babel/types": "^7.8.3" } }, "@babel/helper-validator-identifier": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", - "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz", + "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==", "dev": true }, "@babel/highlight": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz", - "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.9.0.tgz", + "integrity": "sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.10.1", + "@babel/helper-validator-identifier": "^7.9.0", "chalk": "^2.0.0", "js-tokens": "^4.0.0" } }, "@babel/parser": { - "version": "7.10.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.2.tgz", - "integrity": "sha512-PApSXlNMJyB4JiGVhCOlzKIif+TKFTvu0aQAhnTvfP/z3vVSN6ZypH5bfUNwFXXjRQtUEBNFd2PtmCmG2Py3qQ==", + "version": "7.9.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.6.tgz", + "integrity": "sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q==", "dev": true }, "@babel/template": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz", - "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz", + "integrity": "sha512-zbMsPMy/v0PWFZEhQJ66bqjhH+z0JgMoBWuikXybgG3Gkd/3t5oQ1Rw2WQhnSrsOmsKXnZOx15tkC4qON/+JPg==", "dev": true, "requires": { - "@babel/code-frame": "^7.10.1", - "@babel/parser": "^7.10.1", - "@babel/types": "^7.10.1" + "@babel/code-frame": "^7.8.3", + "@babel/parser": "^7.8.6", + "@babel/types": "^7.8.6" } }, "@babel/traverse": { - "version": "7.10.1", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.1.tgz", - "integrity": "sha512-C/cTuXeKt85K+p08jN6vMDz8vSV0vZcI0wmQ36o6mjbuo++kPMdpOYw23W2XH04dbRt9/nMEfA4W3eR21CD+TQ==", + "version": "7.9.6", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.6.tgz", + "integrity": "sha512-b3rAHSjbxy6VEAvlxM8OV/0X4XrG72zoxme6q1MOoe2vd0bEc+TwayhuC1+Dfgqh1QEG+pj7atQqvUprHIccsg==", "dev": true, "requires": { - "@babel/code-frame": "^7.10.1", - "@babel/generator": "^7.10.1", - "@babel/helper-function-name": "^7.10.1", - "@babel/helper-split-export-declaration": "^7.10.1", - "@babel/parser": "^7.10.1", - "@babel/types": "^7.10.1", + "@babel/code-frame": "^7.8.3", + "@babel/generator": "^7.9.6", + "@babel/helper-function-name": "^7.9.5", + "@babel/helper-split-export-declaration": "^7.8.3", + "@babel/parser": "^7.9.6", + "@babel/types": "^7.9.6", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" @@ -164,20 +164,20 @@ } }, "@babel/types": { - "version": "7.10.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.2.tgz", - "integrity": "sha512-AD3AwWBSz0AWF0AkCN9VPiWrvldXq+/e3cHa4J89vo4ymjz1XwrBFFVZmkJTsQIPNk+ZVomPSXUJqq8yyjZsng==", + "version": "7.9.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.6.tgz", + "integrity": "sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.10.1", + "@babel/helper-validator-identifier": "^7.9.5", "lodash": "^4.17.13", "to-fast-properties": "^2.0.0" } }, "@daostack/infra-experimental": { - "version": "0.1.1-rc.18", - "resolved": "https://registry.npmjs.org/@daostack/infra-experimental/-/infra-experimental-0.1.1-rc.18.tgz", - "integrity": "sha512-vTTb1EPI+tK5ovLnItgYBMxDab1thOFNgmVgY4rrQI+Xl9CTVD0xbA7qBZTHDGGKBWFEwoPtb1pCvyodm/hx0Q==", + "version": "0.1.1-rc.19", + "resolved": "https://registry.npmjs.org/@daostack/infra-experimental/-/infra-experimental-0.1.1-rc.19.tgz", + "integrity": "sha512-wRJ8GJklRVzj9uYAtOVIRXfvxd6q985sdDIRLDMl2Y3BW0mhGUBUgqeWzEt6ovrnrqydFBGtRsfZ/QlIjPWj+A==", "requires": { "@openzeppelin/contracts-ethereum-package": "2.5.0", "@openzeppelin/upgrades": "2.5.3", @@ -234,35 +234,6 @@ "version": "7.2.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==" - }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" - }, - "eth-lib": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", - "integrity": "sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco=", - "requires": { - "bn.js": "^4.11.6", - "elliptic": "^6.4.0", - "xhr-request-promise": "^0.1.2" - } - }, - "web3-utils": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.0.tgz", - "integrity": "sha512-tI1low8ICoaWU2c53cikH0rsksKuIskI2nycH5E5sEXxxl9/BOD3CeDDBFbxgNPQ+bpDevbR7gXNEDB7Ud4G9g==", - "requires": { - "bn.js": "4.11.8", - "eth-lib": "0.2.7", - "ethjs-unit": "0.1.6", - "number-to-bn": "1.7.0", - "randomhex": "0.1.5", - "underscore": "1.9.1", - "utf8": "3.0.0" - } } } }, @@ -293,9 +264,9 @@ } }, "@nomiclabs/buidler": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@nomiclabs/buidler/-/buidler-1.3.5.tgz", - "integrity": "sha512-XhVH2ZjhahXLfS16WnTz058OcyqoaK+TD4UON+AiZ5dN9DdBh1A0XQRAg5MNdvVVo8IQZSGZ+Fp0Qde4fgIDKw==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@nomiclabs/buidler/-/buidler-1.3.4.tgz", + "integrity": "sha512-WfYzETXvoVAtmWYIxEcWWxP/hY+qQLFrEs4PtLVu1dX0fZYnhO8RyuK/nLgdeA5tbE+pPZ6rcdh1Kx+P8DTsHQ==", "dev": true, "requires": { "@nomiclabs/ethereumjs-vm": "^4.1.1", @@ -651,9 +622,9 @@ } }, "@nomiclabs/buidler-truffle5": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/@nomiclabs/buidler-truffle5/-/buidler-truffle5-1.3.4.tgz", - "integrity": "sha512-aPbkdbNUF4R/hbb2B8BULlsQ5AUB5l4baIHFmLQ/fdRmFrkWBx+53tjpf+XOv8g8RZTJstpkxFSBRWD/U1EahA==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@nomiclabs/buidler-truffle5/-/buidler-truffle5-1.3.3.tgz", + "integrity": "sha512-8gAKei3RjRcgepfbCS10BlSPXNng+UI8mOvl5lTh6q0VQs+c7f/r2mORVgbwI3gwKMWmzyXixvkfO4+7bVoQCw==", "dev": true, "requires": { "@nomiclabs/truffle-contract": "^4.1.2", @@ -677,9 +648,9 @@ } }, "@nomiclabs/buidler-web3": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/@nomiclabs/buidler-web3/-/buidler-web3-1.3.4.tgz", - "integrity": "sha512-fVJczSfZBp1xDJA2Bdh49P6mhaAO8vGY7kbi6uoMLO8J288O6s/Ldw36kb7iRebifNbKP69MJsUu2nXLaklqdg==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@nomiclabs/buidler-web3/-/buidler-web3-1.3.3.tgz", + "integrity": "sha512-rESg1mQoQuAHyqfhE+XNnR2KcFvCl3HJFNW/Cfi41jIlYN/dUTkhV0F/BXrbMifW+J3+BXjRtRNKMQZ6BjF9zw==", "dev": true, "requires": { "@types/bignumber.js": "^5.0.0" @@ -1414,9 +1385,9 @@ } }, "eventemitter2": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.2.tgz", - "integrity": "sha512-r/Pwupa5RIzxIHbEKCkNXqpEQIIT4uQDxmP4G/Lug/NokVUWj0joz/WzWl3OxRpC5kDrH/WdiUJoR+IrwvXJEw==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.1.tgz", + "integrity": "sha512-x4TgZ3j6tfLGzAJ4MD7M7qTdAiDlfKdssgFENVpW0csJKdlXTpE27SWUDEDb5eNS/HBWQtiDFPKiO6oHokYDqg==", "dev": true }, "ms": { @@ -1471,9 +1442,9 @@ } }, "eventemitter2": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.2.tgz", - "integrity": "sha512-r/Pwupa5RIzxIHbEKCkNXqpEQIIT4uQDxmP4G/Lug/NokVUWj0joz/WzWl3OxRpC5kDrH/WdiUJoR+IrwvXJEw==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.1.tgz", + "integrity": "sha512-x4TgZ3j6tfLGzAJ4MD7M7qTdAiDlfKdssgFENVpW0csJKdlXTpE27SWUDEDb5eNS/HBWQtiDFPKiO6oHokYDqg==", "dev": true }, "ms": { @@ -1676,9 +1647,9 @@ "dev": true }, "@truffle/interface-adapter": { - "version": "0.4.9", - "resolved": "https://registry.npmjs.org/@truffle/interface-adapter/-/interface-adapter-0.4.9.tgz", - "integrity": "sha512-2dYccf7lAwx90NVYmn89QABpd3dx7BxvDAaHgzVa2YVOUkTUpkZiaIsD2YlsVQ1rew17wMNi5WXH2RFnmzQ82A==", + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/@truffle/interface-adapter/-/interface-adapter-0.4.8.tgz", + "integrity": "sha512-pTD4Vr5vfYcMTCUPefznA2mM060vKScn24o1QhfUYyBbas/fc0dDstrnCv886l0dhqnV/q2ebSzaxVWUyPSfgg==", "dev": true, "requires": { "bn.js": "^4.11.8", @@ -2191,9 +2162,9 @@ "dev": true }, "@types/node": { - "version": "14.0.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.6.tgz", - "integrity": "sha512-FbNmu4F67d3oZMWBV6Y4MaPER+0EpE9eIYf2yaHhCWovc1dlXCZkqGX4NLHfVVr6umt20TNBdRzrNJIzIKfdbw==" + "version": "14.0.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.5.tgz", + "integrity": "sha512-90hiq6/VqtQgX8Sp0EzeIsv3r+ellbGj4URKj5j30tLlZvRUpnAe9YbYnjl3pJM93GyXU0tghHhvXHq+5rnCKA==" }, "@types/pbkdf2": { "version": "3.0.0", @@ -3827,9 +3798,9 @@ "dev": true }, "dayjs": { - "version": "1.8.28", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.28.tgz", - "integrity": "sha512-ccnYgKC0/hPSGXxj7Ju6AV/BP4HUkXC2u15mikXT5mX9YorEaoi1bEKOmAqdkJHN4EEkmAf97SpH66Try5Mbeg==", + "version": "1.8.27", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.27.tgz", + "integrity": "sha512-Jpa2acjWIeOkg8KURUHICk0EqnEFSSF5eMEscsOgyJ92ZukXwmpmRkPSUka7KHSfbj5eKH30ieosYip+ky9emQ==", "dev": true }, "death": { @@ -5040,9 +5011,9 @@ } }, "ignore": { - "version": "5.1.8", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", - "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.6.tgz", + "integrity": "sha512-cgXgkypZBcCnOgSihyeqbo6gjIaIyDqPQB7Ra4vhE9m6kigdGoQDMHjviFhRZo3IMlRy6yElosoviMs5YxZXUA==", "dev": true }, "semver": { @@ -7282,9 +7253,9 @@ }, "dependencies": { "ignore": { - "version": "5.1.8", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", - "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.6.tgz", + "integrity": "sha512-cgXgkypZBcCnOgSihyeqbo6gjIaIyDqPQB7Ra4vhE9m6kigdGoQDMHjviFhRZo3IMlRy6yElosoviMs5YxZXUA==", "dev": true }, "slash": { @@ -7356,9 +7327,9 @@ "dev": true }, "uglify-js": { - "version": "3.9.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.9.4.tgz", - "integrity": "sha512-8RZBJq5smLOa7KslsNsVcSH+KOXf1uDU8yqLeNuVKwmT0T3FA0ZoXlinQfRad7SDcbZZRZE4ov+2v71EnxNyCA==", + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.9.3.tgz", + "integrity": "sha512-r5ImcL6QyzQGVimQoov3aL2ZScywrOgBXGndbWrdehKoSvGe/RmiE5Jpw/v+GvxODt6l2tpBXwA7n+qZVlHBMA==", "dev": true, "optional": true, "requires": { @@ -7781,9 +7752,9 @@ } }, "interpret": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.3.0.tgz", - "integrity": "sha512-RDVhhDkycLoSQtE9o0vpK/vOccVDsCbWVzRxArGYnlQLcihPl2loFbPyiH7CM0m2/ijOJU3+PZbnBPaB6NJ1MA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", + "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", "dev": true }, "into-stream": { @@ -11108,9 +11079,9 @@ } }, "rlp": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.5.tgz", - "integrity": "sha512-y1QxTQOp0OZnjn19FxBmped4p+BSKPHwGndaqrESseyd2xXZtcgR3yuTIosh8CaMaOii9SKIYerBXnV/CpJ3qw==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.4.tgz", + "integrity": "sha512-fdq2yYCWpAQBhwkZv+Z8o/Z4sPmYm1CUq6P7n6lVTOdb949CnqA0sndXal5C1NleSVSZm6q5F3iEbauyVln/iw==", "requires": { "bn.js": "^4.11.1" } @@ -13404,9 +13375,9 @@ } }, "systeminformation": { - "version": "4.26.5", - "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-4.26.5.tgz", - "integrity": "sha512-hTVhCYNIsoDtL8brW6wg/UTHmyRfMRItd/+6f6JZtXjmx06FHKBGCyBe7WN6J+FiDIiDfTK7mvMq7hljM6r5OA==", + "version": "4.26.4", + "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-4.26.4.tgz", + "integrity": "sha512-4+AYe0SfjdQPHEFL0nAyFMWyBUe8c5DZdSHApeJrdAvem5yoE/eS7/dGChnKLAkr+AKAoKcnqucPv302jy2+aA==", "dev": true, "optional": true }, @@ -13828,9 +13799,9 @@ "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" }, "unbzip2-stream": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", - "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.2.tgz", + "integrity": "sha512-pZMVAofMrrHX6Ik39hCk470kulCbmZ2SWfQLPmTWqfJV/oUm0gn1CblvHdUu4+54Je6Jq34x8kY6XjTy6dMkOg==", "requires": { "buffer": "^5.2.1", "through": "^2.3.8" @@ -13993,9 +13964,9 @@ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" }, "v8-compile-cache": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", - "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", "dev": true }, "validate-npm-package-license": { @@ -14819,17 +14790,15 @@ } }, "web3-utils": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.8.tgz", - "integrity": "sha512-9SIVGFLajwlmo5joC4DGxuy2OeDkRCXVWT8JWcDQ+BayNVHyAWGvn0oGkQ0ys14Un0KK6bjjKoD0xYs4k+FaVw==", - "dev": true, + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.0.tgz", + "integrity": "sha512-tI1low8ICoaWU2c53cikH0rsksKuIskI2nycH5E5sEXxxl9/BOD3CeDDBFbxgNPQ+bpDevbR7gXNEDB7Ud4G9g==", "requires": { "bn.js": "4.11.8", "eth-lib": "0.2.7", - "ethereum-bloom-filters": "^1.0.6", "ethjs-unit": "0.1.6", "number-to-bn": "1.7.0", - "randombytes": "^2.1.0", + "randomhex": "0.1.5", "underscore": "1.9.1", "utf8": "3.0.0" }, @@ -14837,14 +14806,12 @@ "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" }, "eth-lib": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", "integrity": "sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco=", - "dev": true, "requires": { "bn.js": "^4.11.6", "elliptic": "^6.4.0", diff --git a/package.json b/package.json index 94c6febb..577deb4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc-experimental", - "version": "0.1.1-rc.22", + "version": "0.1.1-rc.23", "description": "A platform for building DAOs", "files": [ "contracts/", @@ -44,8 +44,7 @@ "rimraf": "^2.6.2", "run-with-ganache": "^0.1.1", "solidity-coverage": "^0.7.0-beta.3", - "uint32": "^0.2.1", - "web3-utils": "^1.2.8" + "uint32": "^0.2.1" }, "repository": { "type": "git", @@ -70,7 +69,7 @@ }, "homepage": "https://daostack.io", "dependencies": { - "@daostack/infra-experimental": "0.1.1-rc.18", + "@daostack/infra-experimental": "0.1.1-rc.19", "@openzeppelin/contracts-ethereum-package": "2.4.0", "@openzeppelin/upgrades": "2.7.1", "math": "0.0.3", diff --git a/test/arcscheme.js b/test/arcscheme.js index 88e04070..ab7f036e 100644 --- a/test/arcscheme.js +++ b/test/arcscheme.js @@ -1,11 +1,11 @@ const helpers = require("./helpers"); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); -const SchemeMock = artifacts.require('./test/SchemeMock.sol'); +const SchemeMock = artifacts.require('./test/SchemeMock.sol'); -var registration; -const setup = async function (accounts, initGov=true) { + var registration; +const setup = async function (accounts, initGov=true, vmZero=false, gpParamsHash=true) { var testSetup = new helpers.TestSetup(); registration = await helpers.registerImplementation(); testSetup.proxyAdmin = accounts[5]; @@ -18,51 +18,41 @@ const setup = async function (accounts, initGov=true) { 1 ) .encodeABI(); - } else { var standardTokenMock = await ERC20Mock.new(accounts[0],1000); testSetup.votingMachine = await helpers.setupGenesisProtocol(accounts,standardTokenMock.address,helpers.NULL_ADDRESS); - schemeMockData = await new web3.eth.Contract(registration.schemeMock.abi) .methods .initializeGovernance( helpers.NULL_ADDRESS, + vmZero ? helpers.NULL_ADDRESS : testSetup.votingMachine.genesisProtocol.address, testSetup.votingMachine.uintArray, testSetup.votingMachine.voteOnBehalf, - registration.daoFactory.address, - standardTokenMock.address, - [0,1,0], - "GenesisProtocol", + gpParamsHash ? testSetup.votingMachine.params : helpers.NULL_HASH, 1 ) .encodeABI(); } + var permissions = "0x00000000"; [testSetup.org,tx] = await helpers.setupOrganizationWithArraysDAOFactory(testSetup.proxyAdmin, - accounts, - registration, - [accounts[0]], - [1000], - [1000], - 0, - [web3.utils.fromAscii("SchemeMock")], - schemeMockData, - [helpers.getBytesLength(schemeMockData)], - [permissions], - "metaData"); - testSetup.standardTokenMock = await ERC20Mock.new(testSetup.org.avatar.address,100); - - if (!initGov) { - testSetup.schemeMock = await SchemeMock.at(tx.logs[6].args._scheme); - } else { - testSetup.schemeMock = await SchemeMock.at(tx.logs[7].args._scheme); - testSetup.votingMachine = tx.logs[5].args._proxy; - - } + accounts, + registration, + [accounts[0]], + [1000], + [1000], + 0, + [web3.utils.fromAscii("SchemeMock")], + schemeMockData, + [helpers.getBytesLength(schemeMockData)], + [permissions], + "metaData"); + testSetup.standardTokenMock = await ERC20Mock.new(testSetup.org.avatar.address,100); + + testSetup.schemeMock = await SchemeMock.at(tx.logs[6].args._scheme); return testSetup; - }; -contract('ArcScheme', function(accounts) { +contract('VotingMachineCallbacks', function(accounts) { it("avatar address cannot be 0 ", async function() { var schemeMock = await SchemeMock.new(); @@ -80,31 +70,21 @@ contract('ArcScheme', function(accounts) { schemeMock = await SchemeMock.new(); try { await schemeMock.initializeGovernance(accounts[0], - params.uintArray, - params.voteOnBehalf, - helpers.NULL_ADDRESS, - helpers.NULL_ADDRESS, - [0,1,0], - "GenesisProtocol", - 1); - assert(false, "daoFactory cannot be zero"); + helpers.NULL_ADDRESS, + params.uintArray, + params.voteOnBehalf, + helpers.NULL_HASH, + 1 + ); + assert(false, "votingMachine cannot be zero"); } catch(error) { // revert } - var registration = await helpers.registerImplementation(); - await schemeMock.initializeGovernance(accounts[0], - params.uintArray, - params.voteOnBehalf, - registration.daoFactory.address, - helpers.NULL_ADDRESS, - [0,1,0], - "GenesisProtocol", - 1); }); it("vm address cannot be 0 ", async function() { try { - await setup(accounts, true); + await setup(accounts, true, false, true); assert(false, "vm 0 address should revert"); } catch(error) { // revert @@ -120,7 +100,22 @@ contract('ArcScheme', function(accounts) { it("initializeGovernance ", async function() { var testSetup = await setup(accounts); assert.equal(await testSetup.schemeMock.avatar(), testSetup.org.avatar.address); - assert.equal(await testSetup.schemeMock.votingMachine(), testSetup.votingMachine); + assert.equal(await testSetup.schemeMock.votingMachine(), testSetup.votingMachine.genesisProtocol.address); + assert.equal(await testSetup.schemeMock.voteParamsHash(), testSetup.votingMachine.params); + }); + + it("initializeGovernance parameters already set", async function() { + var testSetup = await setup(accounts); + testSetup = await setup(accounts); + assert.equal(await testSetup.schemeMock.avatar(), testSetup.org.avatar.address); + assert.equal(await testSetup.schemeMock.votingMachine(), testSetup.votingMachine.genesisProtocol.address); + assert.equal(await testSetup.schemeMock.voteParamsHash(), testSetup.votingMachine.params); }); + it("initializeGovernance gp set params", async function() { + var testSetup = await setup(accounts, true, false, false, false); + assert.equal(await testSetup.schemeMock.avatar(), testSetup.org.avatar.address); + assert.equal(await testSetup.schemeMock.votingMachine(), testSetup.votingMachine.genesisProtocol.address); + assert.equal(await testSetup.schemeMock.voteParamsHash(), testSetup.votingMachine.params); + }); }); diff --git a/test/competition.js b/test/competition.js index e7d5faf0..3a7cbb67 100644 --- a/test/competition.js +++ b/test/competition.js @@ -19,17 +19,18 @@ const setupContributionRewardExt = async function( _rewarderName = 'Competition' ) { var contributionRewardParams = new ContributionRewardParams(); + if (genesisProtocol === true) { contributionRewardParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS); contributionRewardParams.initdata = await new web3.eth.Contract(registration.contributionRewardExt.abi) .methods .initialize(helpers.NULL_ADDRESS, + contributionRewardParams.votingMachine.genesisProtocol.address, contributionRewardParams.votingMachine.uintArray, contributionRewardParams.votingMachine.voteOnBehalf, - _daoFactoryAddress, helpers.NULL_ADDRESS, + _daoFactoryAddress, _packageVersion, - "GenesisProtocol", _rewarderName ) .encodeABI(); @@ -38,12 +39,12 @@ const setupContributionRewardExt = async function( contributionRewardParams.initdata = await new web3.eth.Contract(registration.contributionRewardExt.abi) .methods .initialize(helpers.NULL_ADDRESS, - contributionRewardParams.votingMachine.uintArray, - contributionRewardParams.votingMachine.voteOnBehalf, - _daoFactoryAddress, + contributionRewardParams.votingMachine.absoluteVote.address, + [1,1,1,1,1,1,1,1,1,1,1], helpers.NULL_ADDRESS, + contributionRewardParams.votingMachine.params, + _daoFactoryAddress, _packageVersion, - "AbsoluteVote", _rewarderName) .encodeABI(); } @@ -97,8 +98,6 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=0) { var competitionAddress = await testSetup.contributionRewardExt.rewarder(); testSetup.competition = await Competition.at(competitionAddress); testSetup.admin = accounts[0]; - testSetup.contributionRewardExtParams.votingMachine = - await helpers.getVotingMachine(await testSetup.contributionRewardExt.votingMachine(),genesisProtocol); return testSetup; }; @@ -118,7 +117,12 @@ const proposeCompetition = async function( ) { var block = await web3.eth.getBlock("latest"); - _testSetup.startTime = _startTime > 0 ? block.timestamp + _startTime : 0; + if (_startTime === "invalid") { + _testSetup.startTime = 1; + } else { + _testSetup.startTime = _startTime > 0 ? block.timestamp + _startTime : 0; + + } _testSetup.votingStartTime = block.timestamp + _votingStartTime; _testSetup.endTime = block.timestamp + _endTime; _testSetup.suggestionsEndTime = block.timestamp + _suggestionsEndTime; @@ -205,6 +209,17 @@ contract('Competition', accounts => { helpers.assertVMException(ex); } rewardSplit = [50,25,15,10]; + try { + await proposeCompetition(testSetup, + descriptionHash, + reputationChange, + rewards, + rewardSplit, + "invalid"); + assert(false, 'start time cannot be in the past'); + } catch (ex) { + helpers.assertVMException(ex); + } try { @@ -498,8 +513,8 @@ contract('Competition', accounts => { } catch (ex) { helpers.assertVMException(ex); } - await testSetup.contributionRewardExtParams.votingMachine.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); - await testSetup.contributionRewardExtParams.votingMachine.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); await testSetup.contributionRewardExt.redeem(proposalId,[true,true,true,true]); await helpers.increaseTime(650); await testSetup.competition.vote(1,{from:accounts[1]}); @@ -582,8 +597,8 @@ contract('Competition', accounts => { await testSetup.competition.suggest(proposalId,"suggestion",helpers.NULL_ADDRESS); await testSetup.competition.suggest(proposalId,"suggestion",helpers.NULL_ADDRESS); await testSetup.competition.suggest(proposalId,"suggestion",helpers.NULL_ADDRESS); - await testSetup.contributionRewardExtParams.votingMachine.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); - await testSetup.contributionRewardExtParams.votingMachine.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); await testSetup.contributionRewardExt.redeem(proposalId,[true,true,true,true]); await helpers.increaseTime(650); await testSetup.competition.vote(1,{from:accounts[0]}); @@ -683,8 +698,8 @@ contract('Competition', accounts => { await testSetup.competition.suggest(proposalId,"suggestion",helpers.NULL_ADDRESS); await testSetup.competition.suggest(proposalId,"suggestion",helpers.NULL_ADDRESS); - await testSetup.contributionRewardExtParams.votingMachine.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); - await testSetup.contributionRewardExtParams.votingMachine.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); await testSetup.contributionRewardExt.redeem(proposalId,[true,true,true,true]); await helpers.increaseTime(650); await testSetup.competition.vote(1,{from:accounts[2]}); @@ -723,8 +738,8 @@ contract('Competition', accounts => { await testSetup.competition.suggest(proposalId,"suggestion",helpers.NULL_ADDRESS); await testSetup.competition.suggest(proposalId,"suggestion",helpers.NULL_ADDRESS); - await testSetup.contributionRewardExtParams.votingMachine.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); - await testSetup.contributionRewardExtParams.votingMachine.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); await testSetup.contributionRewardExt.redeem(proposalId,[true,true,true,true]); await helpers.increaseTime(650); await testSetup.competition.vote(1,{from:accounts[1]}); diff --git a/test/contributionreward.js b/test/contributionreward.js index 892dd205..d771b7d3 100644 --- a/test/contributionreward.js +++ b/test/contributionreward.js @@ -43,9 +43,6 @@ const setupContributionReward = async function( accounts, genesisProtocol, token, - avatarAddress, - _daoFactoryAddress, - _packageVersion = [0,1,0] ) { var contributionRewardParams = new ContributionRewardParams(); @@ -54,24 +51,20 @@ const setupContributionReward = async function( contributionRewardParams.initdata = await new web3.eth.Contract(registration.contributionReward.abi) .methods .initialize(helpers.NULL_ADDRESS, + contributionRewardParams.votingMachine.genesisProtocol.address, contributionRewardParams.votingMachine.uintArray, contributionRewardParams.votingMachine.voteOnBehalf, - _daoFactoryAddress, - token, - _packageVersion, - "GenesisProtocol") + helpers.NULL_HASH) .encodeABI(); } else { contributionRewardParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); contributionRewardParams.initdata = await new web3.eth.Contract(registration.contributionReward.abi) .methods .initialize(helpers.NULL_ADDRESS, - contributionRewardParams.votingMachine.uintArray, - contributionRewardParams.votingMachine.voteOnBehalf, - _daoFactoryAddress, + contributionRewardParams.votingMachine.absoluteVote.address, + [1,1,1,1,1,1,1,1,1,1,1], helpers.NULL_ADDRESS, - _packageVersion, - "AbsoluteVote") + contributionRewardParams.votingMachine.params) .encodeABI(); } return contributionRewardParams; @@ -91,9 +84,7 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=0) { testSetup.contributionRewardParams= await setupContributionReward( accounts, genesisProtocol, - tokenAddress, - helpers.NULL_ADDRESS, - registration.daoFactory.address); + tokenAddress); var permissions = "0x00000000"; [testSetup.org,tx] = await helpers.setupOrganizationWithArraysDAOFactory(testSetup.proxyAdmin, accounts, @@ -113,9 +104,6 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=0) { testSetup.contributionReward = await ContributionReward.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.contributionRewardParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.contributionReward.votingMachine(),genesisProtocol); - return testSetup; }; contract('ContributionReward', accounts => { @@ -123,7 +111,7 @@ contract('ContributionReward', accounts => { it("initialize", async function() { var testSetup = await setup(accounts); assert.equal(await testSetup.contributionReward.votingMachine(), - testSetup.contributionRewardParams.votingMachineInstance.address); + testSetup.contributionRewardParams.votingMachine.absoluteVote.address); assert.equal(await testSetup.contributionReward.avatar(),testSetup.org.avatar.address); }); @@ -132,12 +120,10 @@ contract('ContributionReward', accounts => { try { await testSetup.contributionReward.initialize(testSetup.org.avatar.address, - testSetup.contributionRewardParams.votingMachine.uintArray, - testSetup.contributionRewardParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - helpers.NULL_ADDRESS, - [0,1,0], - "AbsoluteVote"); + testSetup.contributionRewardParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + testSetup.contributionRewardParams.votingMachine.params); assert(false, 'cannot initialize twice'); } catch (ex) { helpers.assertVMException(ex); @@ -157,7 +143,7 @@ contract('ContributionReward', accounts => { assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "NewContributionProposal"); assert.equal(await helpers.getValueFromLogs(tx, '_avatar',0), testSetup.org.avatar.address, "Wrong log: _avatar"); - assert.equal(await helpers.getValueFromLogs(tx, '_intVoteInterface',0), testSetup.contributionRewardParams.votingMachineInstance.address, "Wrong log: _intVoteInterface"); + assert.equal(await helpers.getValueFromLogs(tx, '_intVoteInterface',0), testSetup.contributionRewardParams.votingMachine.absoluteVote.address, "Wrong log: _intVoteInterface"); assert.equal(await helpers.getValueFromLogs(tx, '_descriptionHash',15), "description-hash", "Wrong log: _contributionDescription"); assert.equal(await helpers.getValueFromLogs(tx, '_reputationChange',0), 10, "Wrong log: _reputationChange"); var arr = await helpers.getValueFromLogs(tx, '_rewards',0); @@ -196,7 +182,7 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var organizationProposal = await testSetup.contributionReward.organizationProposals(proposalId); assert.notEqual(organizationProposal[8],0);//executionTime }); @@ -215,7 +201,7 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await helpers.increaseTime(periodLength+1); tx = await testSetup.contributionReward.redeem(proposalId,[true,false,false,false]); assert.equal(tx.logs.length, 1); @@ -240,7 +226,7 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await helpers.increaseTime(periodLength+1); tx = await testSetup.contributionReward.redeem(proposalId,[false,true,false,false]); var tokens = await testSetup.org.token.balanceOf(accounts[1]); @@ -268,7 +254,7 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await helpers.increaseTime(periodLength+1); await testSetup.contributionReward.redeem(proposalId,[false,false,true,false]); var vault = await otherAvatar.vault(); @@ -300,7 +286,7 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await helpers.increaseTime(periodLength+1); await testSetup.contributionReward.redeem(proposalId,[false,false,false,true]); var tokens = await testSetup.standardTokenMock.balanceOf(otherAvatar.address); @@ -330,7 +316,7 @@ contract('ContributionReward', accounts => { var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var organizationProposal = await testSetup.contributionReward.organizationProposals(proposalId); assert.equal(organizationProposal[5],otherAvatar.address);//beneficiary - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await helpers.increaseTime(periodLength+1); try { await testSetup.contributionReward.redeem(proposalId,[true,true,true,true]); @@ -361,7 +347,7 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await helpers.increaseTime(periodLength+1); await checkRedeemedPeriods(testSetup,proposalId,0,0,0,0); @@ -460,7 +446,7 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await helpers.increaseTime(periodLength+1); tx = await testSetup.contributionReward.redeem(proposalId,[true,false,false,false]); assert.equal(tx.logs.length, 1); @@ -542,11 +528,11 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); await helpers.increaseTime(periodLength+1); var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeem.call(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); assert.equal(redeemRewards[0][1],100); //redeemRewards[0] gpRewards @@ -561,7 +547,7 @@ contract('ContributionReward', accounts => { assert.equal(redeemRewards[7],externalTokenReward); //crExternalTokenReward await arcUtils.redeem(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var vault = await otherAvatar.vault(); @@ -599,11 +585,11 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); await helpers.increaseTime(periodLength+1); var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeem.call(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); assert.equal(redeemRewards[0][1],100); //redeemRewards[0] gpRewards @@ -618,7 +604,7 @@ contract('ContributionReward', accounts => { assert.equal(redeemRewards[7],0); //crExternalTokenReward await arcUtils.redeem(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var vault = await otherAvatar.vault(); @@ -656,7 +642,7 @@ contract('ContributionReward', accounts => { var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeem.call(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); assert.equal(redeemRewards[0][1],0); //redeemRewards[0] gpRewards @@ -671,9 +657,9 @@ contract('ContributionReward', accounts => { assert.equal(redeemRewards[7],0); //crExternalTokenReward }); - it("execute proposeContributionReward via genesisProtocol and redeem using Redeemer", async function() { + it("execute proposeContributionReward via genesisProtocol and redeem using Redeemer + setParameters", async function() { var standardTokenMock = await ERC20Mock.new(accounts[0],1000); - var testSetup = await setup(accounts,true,standardTokenMock.address); + var testSetup = await setup(accounts,true,standardTokenMock.address,true); var reputationReward = 12; var nativeTokenReward = 12; var ethReward = 12; @@ -692,11 +678,11 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); await helpers.increaseTime(periodLength+1); var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeem.call(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); assert.equal(redeemRewards[0][1],100); //redeemRewards[0] gpRewards @@ -711,7 +697,7 @@ contract('ContributionReward', accounts => { assert.equal(redeemRewards[7],0); //crExternalTokenReward await arcUtils.redeem(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var vault = await otherAvatar.vault(); @@ -749,13 +735,13 @@ contract('ContributionReward', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[1]}); - await standardTokenMock.approve(testSetup.contributionRewardParams.votingMachineInstance.address,1000); - await testSetup.contributionRewardParams.votingMachineInstance.stake(proposalId,1,1000); + await testSetup.contributionRewardParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[1]}); + await standardTokenMock.approve(testSetup.contributionRewardParams.votingMachine.genesisProtocol.address,1000); + await testSetup.contributionRewardParams.votingMachine.genesisProtocol.stake(proposalId,1,1000); await helpers.increaseTime(60+1); var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeem.call(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); assert.equal(redeemRewards[0][1],0); //redeemRewards[0] gpRewards @@ -770,7 +756,7 @@ contract('ContributionReward', accounts => { assert.equal(redeemRewards[7],0); //crExternalTokenReward await arcUtils.redeem(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var vault = await otherAvatar.vault(); @@ -806,11 +792,11 @@ contract('ContributionReward', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardParams.votingMachine.genesisProtocol.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[0]}); await helpers.increaseTime(periodLength+1); var arcUtils = await Redeemer.new(); await arcUtils.redeem(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var eth = await web3.eth.getBalance(otherAvatar.address); @@ -843,14 +829,14 @@ contract('ContributionReward', accounts => { ); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[1]}); + await testSetup.contributionRewardParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[1]}); await helpers.increaseTime(60+1); var arcUtils = await Redeemer.new(); await arcUtils.redeem(testSetup.contributionReward.address, - testSetup.contributionRewardParams.votingMachineInstance.address, + testSetup.contributionRewardParams.votingMachine.genesisProtocol.address, proposalId, accounts[1]); - var proposal = await testSetup.contributionRewardParams.votingMachineInstance.proposals(proposalId); + var proposal = await testSetup.contributionRewardParams.votingMachine.genesisProtocol.proposals(proposalId); assert.equal(proposal.state,1); //ExpiredInQueue var reputation = await testSetup.org.reputation.balanceOf(accounts[1]); //accounts[1] redeems its deposit rep. @@ -886,7 +872,7 @@ contract('ContributionReward', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.contributionReward.redeem(proposalId,[true,false,false,false]); assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "RedeemReputation"); diff --git a/test/contributionrewardext.js b/test/contributionrewardext.js index 7c7b5b96..fcbd4908 100644 --- a/test/contributionrewardext.js +++ b/test/contributionrewardext.js @@ -6,7 +6,7 @@ const Redeemer = artifacts.require("./Redeemer.sol"); const RewarderMock = artifacts.require("./RewarderMock.sol"); -class ContributionRewardExtParams { +class ContributionRewardParams { constructor() { } } @@ -15,43 +15,42 @@ const setupContributionRewardExt = async function( accounts, genesisProtocol, token, - _daoFactoryAddress = helpers.NULL_ADDRESS, + daoFactoryAddress = helpers.NULL_ADDRESS, service = "", - _packageVersion = [0,1,0] + vmZero=false ) { - var contributionRewardExtParams = new ContributionRewardExtParams(); + var contributionRewardParams = new ContributionRewardParams(); if (genesisProtocol === true) { - contributionRewardExtParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS); - contributionRewardExtParams.initdata = await new web3.eth.Contract(registration.contributionRewardExt.abi) + contributionRewardParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS); + contributionRewardParams.initdata = await new web3.eth.Contract(registration.contributionRewardExt.abi) .methods .initialize(helpers.NULL_ADDRESS, - contributionRewardExtParams.votingMachine.uintArray, - contributionRewardExtParams.votingMachine.voteOnBehalf, - _daoFactoryAddress, - token, - _packageVersion, - "GenesisProtocol", - service - ) + contributionRewardParams.votingMachine.genesisProtocol.address, + contributionRewardParams.votingMachine.uintArray, + contributionRewardParams.votingMachine.voteOnBehalf, + helpers.NULL_HASH, + daoFactoryAddress, + [0,1,0], + service) .encodeABI(); } else { - contributionRewardExtParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); - contributionRewardExtParams.initdata = await new web3.eth.Contract(registration.contributionRewardExt.abi) + contributionRewardParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); + contributionRewardParams.initdata = await new web3.eth.Contract(registration.contributionRewardExt.abi) .methods .initialize(helpers.NULL_ADDRESS, - contributionRewardExtParams.votingMachine.uintArray, - contributionRewardExtParams.votingMachine.voteOnBehalf, - _daoFactoryAddress, + vmZero ? helpers.NULL_ADDRESS : contributionRewardParams.votingMachine.absoluteVote.address, + [1,1,1,1,1,1,1,1,1,1,1], helpers.NULL_ADDRESS, - _packageVersion, - "AbsoluteVote", + contributionRewardParams.votingMachine.params, + daoFactoryAddress, + [0,1,0], service) .encodeABI(); } - return contributionRewardExtParams; + return contributionRewardParams; }; var registration; -const setup = async function (accounts,genesisProtocol = false,tokenAddress=helpers.NULL_ADDRESS,service="") { +const setup = async function (accounts,genesisProtocol = false,tokenAddress=0,service="",vmZero=false) { var testSetup = new helpers.TestSetup(); testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100000); registration = await helpers.registerImplementation(); @@ -67,7 +66,8 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=help genesisProtocol, tokenAddress, registration.daoFactory.address, - service); + service, + vmZero); var permissions = "0x00000000"; [testSetup.org,tx] = await helpers.setupOrganizationWithArraysDAOFactory(testSetup.proxyAdmin, @@ -85,8 +85,6 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=help [permissions], "metaData"); testSetup.contributionRewardExt = await ContributionRewardExt.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.contributionRewardExtParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.contributionRewardExt.votingMachine(),genesisProtocol); testSetup.admin = accounts[0]; @@ -96,12 +94,12 @@ contract('ContributionRewardExt', accounts => { it("initialize", async function() { var testSetup = await setup(accounts); - assert.equal(await testSetup.contributionRewardExt.votingMachine(),testSetup.contributionRewardExtParams.votingMachineInstance.address); + assert.equal(await testSetup.contributionRewardExt.votingMachine(),testSetup.contributionRewardExtParams.votingMachine.absoluteVote.address); }); it("initialize vm 0", async function() { try { - await setup(accounts,false,helpers.NULL_ADDRESS,true); + await setup(accounts,false,0,true); assert(false, 'votingMachine cannot be zero'); } catch (ex) { // revert @@ -120,7 +118,7 @@ contract('ContributionRewardExt', accounts => { assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "NewContributionProposal"); assert.equal(await helpers.getValueFromLogs(tx, '_avatar',0), testSetup.org.avatar.address, "Wrong log: _avatar"); - assert.equal(await helpers.getValueFromLogs(tx, '_intVoteInterface',0), testSetup.contributionRewardExtParams.votingMachineInstance.address, "Wrong log: _intVoteInterface"); + assert.equal(await helpers.getValueFromLogs(tx, '_intVoteInterface',0), testSetup.contributionRewardExtParams.votingMachine.absoluteVote.address, "Wrong log: _intVoteInterface"); assert.equal(await helpers.getValueFromLogs(tx, '_descriptionHash',15), "description-hash", "Wrong log: _contributionDescription"); assert.equal(await helpers.getValueFromLogs(tx, '_reputationChange',0), 10, "Wrong log: _reputationChange"); var arr = await helpers.getValueFromLogs(tx, '_rewards',0); @@ -187,7 +185,7 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var organizationProposal = await testSetup.contributionRewardExt.organizationProposals(proposalId); assert.notEqual(organizationProposal.acceptedByVotingMachine,0);//acceptedByVotingMachine }); @@ -205,7 +203,7 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.contributionRewardExt.redeem(proposalId,[true,false,false,false]); assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "RedeemReputation"); @@ -228,7 +226,7 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.contributionRewardExt.redeem(proposalId,[false,true,false,false]); var tokens = await testSetup.org.token.balanceOf(accounts[1]); assert.equal(tokens.toNumber(),nativeTokenReward); @@ -254,7 +252,7 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.contributionRewardExt.redeem(proposalId,[false,false,true,false]); var vault = await otherAvatar.vault(); var eth = await web3.eth.getBalance(vault); @@ -282,7 +280,7 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.contributionRewardExt.redeem(proposalId,[false,false,false,true]); var tokens = await testSetup.standardTokenMock.balanceOf(otherAvatar.address); assert.equal(tokens.toNumber(),externalTokenReward); @@ -310,7 +308,7 @@ contract('ContributionRewardExt', accounts => { var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var organizationProposal = await testSetup.contributionRewardExt.organizationProposals(proposalId); assert.equal(organizationProposal[5],otherAvatar.address);//beneficiary - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); try { await testSetup.contributionRewardExt.redeem(proposalId,[true,true,true,true]); @@ -335,7 +333,7 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.contributionRewardExt.redeem(proposalId,[true,false,false,false]); assert.equal(tx.logs.length, 1); @@ -394,11 +392,11 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeemFromCRExt.call(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); assert.equal(redeemRewards[0][1],100); //redeemRewards[0] gpRewards @@ -413,7 +411,7 @@ contract('ContributionRewardExt', accounts => { assert.equal(redeemRewards[7],externalTokenReward); //crExternalTokenReward await arcUtils.redeemFromCRExt(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var vault = await otherAvatar.vault(); @@ -454,7 +452,7 @@ contract('ContributionRewardExt', accounts => { var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeemFromCRExt.call(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); assert.equal(redeemRewards[0][1],0); //redeemRewards[0] gpRewards @@ -491,11 +489,11 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[0]}); var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeemFromCRExt.call(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); assert.equal(redeemRewards[0][1],100); //redeemRewards[0] gpRewards @@ -510,7 +508,7 @@ contract('ContributionRewardExt', accounts => { assert.equal(redeemRewards[7],0); //crExternalTokenReward await arcUtils.redeemFromCRExt(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var vault = await otherAvatar.vault(); @@ -545,15 +543,15 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[1]}); + await testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[1]}); - await standardTokenMock.approve(testSetup.contributionRewardExtParams.votingMachineInstance.address,1000); - await testSetup.contributionRewardExtParams.votingMachineInstance.stake(proposalId,1,1000); + await standardTokenMock.approve(testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address,1000); + await testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.stake(proposalId,1,1000); await helpers.increaseTime(60+1); var arcUtils = await Redeemer.new(); var redeemRewards = await arcUtils.redeemFromCRExt.call(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); @@ -569,7 +567,7 @@ contract('ContributionRewardExt', accounts => { assert.equal(redeemRewards[7],0); //crExternalTokenReward await arcUtils.redeemFromCRExt(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var vault = await otherAvatar.vault(); @@ -606,11 +604,11 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[0]}); + await testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[0]}); var arcUtils = await Redeemer.new(); await arcUtils.redeemFromCRExt(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[0]); var vault = await otherAvatar.vault(); @@ -644,14 +642,14 @@ contract('ContributionRewardExt', accounts => { ); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[1]}); + await testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[1]}); await helpers.increaseTime(60+1); var arcUtils = await Redeemer.new(); await arcUtils.redeemFromCRExt(testSetup.contributionRewardExt.address, - testSetup.contributionRewardExtParams.votingMachineInstance.address, + testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.address, proposalId, accounts[1]); - var proposal = await testSetup.contributionRewardExtParams.votingMachineInstance.proposals(proposalId); + var proposal = await testSetup.contributionRewardExtParams.votingMachine.genesisProtocol.proposals(proposalId); assert.equal(proposal.state,1); //ExpiredInQueue var reputation = await testSetup.org.reputation.balanceOf(accounts[1]); //accounts[1] redeems its deposit rep. @@ -673,7 +671,7 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.contributionRewardExt.redeem(proposalId,[true,false,false,false]); assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "RedeemReputation"); @@ -692,12 +690,12 @@ contract('ContributionRewardExt', accounts => { try { await testSetup.contributionRewardExt.initialize( testSetup.org.avatar.address, - testSetup.contributionRewardExtParams.votingMachine.uintArray, - testSetup.contributionRewardExtParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, + testSetup.contributionRewardExtParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + helpers.NULL_HASH, helpers.NULL_ADDRESS, [0,1,0], - "GenericProtocol", "" ); assert(false, 'cannot initialize twice'); @@ -724,7 +722,7 @@ contract('ContributionRewardExt', accounts => { ); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.contributionRewardExtParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.contributionRewardExtParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.contributionRewardExt.redeem(proposalId,[true,true,true,true]); var contVault = await testSetup.contributionRewardExt.vault(); var eth = await web3.eth.getBalance(contVault); @@ -870,7 +868,7 @@ contract('ContributionRewardExt', accounts => { }); it("negativ rep change is not allowed for rewarder to set ", async function() { - var testSetup = await setup(accounts,false,helpers.NULL_ADDRESS,"RewarderMock"); + var testSetup = await setup(accounts,false,0,"RewarderMock"); var reputationReward = -12; var nativeTokenReward = 12; var ethReward = 12; diff --git a/test/controllerupgradescheme.js b/test/controllerupgradescheme.js index 70ca8215..5fae8f03 100644 --- a/test/controllerupgradescheme.js +++ b/test/controllerupgradescheme.js @@ -1,5 +1,6 @@ const helpers = require("./helpers"); const Controller = artifacts.require("./Controller.sol"); +const AbsoluteVote = artifacts.require('./AbsoluteVote.sol'); const ControllerUpgradeScheme = artifacts.require('./ControllerUpgradeScheme.sol'); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); const Avatar = artifacts.require("./Avatar.sol"); @@ -13,10 +14,7 @@ class ControllerUpgradeSchemeParams { var registration; const setupControllerUpgradeSchemeParams = async function( accounts, - genesisProtocol, - token, - _daoFactoryAddress, - _packageVersion = [0,1,0] + genesisProtocol ) { var controllerUpgradeSchemeParams = new ControllerUpgradeSchemeParams(); if (genesisProtocol === true) { @@ -24,24 +22,20 @@ const setupControllerUpgradeSchemeParams = async function( controllerUpgradeSchemeParams.initdata = await new web3.eth.Contract(registration.controllerUpgradeScheme.abi) .methods .initialize(helpers.NULL_ADDRESS, + controllerUpgradeSchemeParams.votingMachine.genesisProtocol.address, controllerUpgradeSchemeParams.votingMachine.uintArray, controllerUpgradeSchemeParams.votingMachine.voteOnBehalf, - _daoFactoryAddress, - token, - _packageVersion, - "GenesisProtocol") + helpers.NULL_HASH) .encodeABI(); } else { controllerUpgradeSchemeParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); controllerUpgradeSchemeParams.initdata = await new web3.eth.Contract(registration.controllerUpgradeScheme.abi) .methods .initialize(helpers.NULL_ADDRESS, - controllerUpgradeSchemeParams.votingMachine.uintArray, - controllerUpgradeSchemeParams.votingMachine.voteOnBehalf, - _daoFactoryAddress, + controllerUpgradeSchemeParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], helpers.NULL_ADDRESS, - _packageVersion, - "AbsoluteVote") + controllerUpgradeSchemeParams.votingMachine.params) .encodeABI(); } return controllerUpgradeSchemeParams; @@ -71,7 +65,7 @@ const setupNewController = async function (accounts,permission='0x00000000') { }; -const setup = async function (accounts,genesisProtocol=false,tokenAddress= helpers.NULL_ADDRESS) { +const setup = async function (accounts,genesisProtocol=false) { var testSetup = new helpers.TestSetup(); testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); registration = await helpers.registerImplementation(); @@ -79,9 +73,7 @@ const setup = async function (accounts,genesisProtocol=false,tokenAddress= helpe testSetup.proxyAdmin = accounts[5]; testSetup.controllerUpgradeSchemeParams= await setupControllerUpgradeSchemeParams( accounts, - genesisProtocol, - tokenAddress, - registration.daoFactory.address); + genesisProtocol); var permissions = "0x0000000a"; [testSetup.org,tx] = await helpers.setupOrganizationWithArraysDAOFactory(testSetup.proxyAdmin, accounts, @@ -98,15 +90,25 @@ const setup = async function (accounts,genesisProtocol=false,tokenAddress= helpe [permissions], "metaData"); -testSetup.controllerUpgradeScheme = await ControllerUpgradeScheme.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); -testSetup.controllerUpgradeSchemeParams.votingMachineInstance = -await helpers.getVotingMachine(await testSetup.controllerUpgradeScheme.votingMachine(),genesisProtocol); return testSetup; + testSetup.controllerUpgradeScheme = await ControllerUpgradeScheme.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); + return testSetup; }; contract('ControllerUpgradeScheme', accounts => { before(function() { helpers.etherForEveryone(accounts); }); + it("initialize", async() => { + var controllerUpgradeScheme = await ControllerUpgradeScheme.new(); + var absoluteVote = await AbsoluteVote.new(); + await controllerUpgradeScheme.initialize(helpers.SOME_ADDRESS, + absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + "0x1234"); + assert.equal(await controllerUpgradeScheme.votingMachine(),absoluteVote.address); + }); + it("proposeUpgrade log", async() => { var testSetup = await setup(accounts); @@ -116,7 +118,7 @@ contract('ControllerUpgradeScheme', accounts => { assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "NewControllerUpgradeProposal"); var votingMachine = await helpers.getValueFromLogs(tx, '_intVoteInterface',1); - assert.equal(votingMachine,testSetup.controllerUpgradeSchemeParams.votingMachineInstance.address); + assert.equal(votingMachine,testSetup.controllerUpgradeSchemeParams.votingMachine.absoluteVote.address); }); it("proposeChangeControllerUpgradingScheme log", async function() { @@ -126,7 +128,7 @@ contract('ControllerUpgradeScheme', accounts => { assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "ChangeControllerUpgradeSchemeProposal"); var votingMachine = await helpers.getValueFromLogs(tx, '_intVoteInterface',1); - assert.equal(votingMachine,testSetup.controllerUpgradeSchemeParams.votingMachineInstance.address); + assert.equal(votingMachine,testSetup.controllerUpgradeSchemeParams.votingMachine.absoluteVote.address); }); it("execute proposal upgrade controller -yes - proposal data delete", async function() { @@ -141,7 +143,7 @@ contract('ControllerUpgradeScheme', accounts => { var organizationProposal = await testSetup.controllerUpgradeScheme.organizationProposals(proposalId); assert.equal(organizationProposal[0],newController.address);//new contract address assert.equal(organizationProposal[1].toNumber(),1);//proposalType - await testSetup.controllerUpgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.controllerUpgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(newController.address,await testSetup.org.avatar.owner()); //check organizationsProposals after execution organizationProposal = await testSetup.controllerUpgradeScheme.organizationProposals(proposalId); @@ -161,7 +163,7 @@ contract('ControllerUpgradeScheme', accounts => { var organizationProposal = await testSetup.controllerUpgradeScheme.organizationProposals(proposalId); assert.equal(organizationProposal[0],newController.address);//new contract address assert.equal(organizationProposal[1].toNumber(),1);//proposalType - await testSetup.controllerUpgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.controllerUpgradeSchemeParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(newController.address,await testSetup.org.avatar.owner()); //check organizationsProposals after execution organizationProposal = await testSetup.controllerUpgradeScheme.organizationProposals(proposalId); @@ -181,7 +183,7 @@ contract('ControllerUpgradeScheme', accounts => { assert.equal(organizationProposal[1].toNumber(),1);//proposalType //Vote with reputation to trigger execution - await testSetup.controllerUpgradeSchemeParams.votingMachineInstance.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.controllerUpgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //should not upgrade because the decision is "no" assert.notEqual(newController.address,await testSetup.org.avatar.owner()); //check organizationsProposals after execution @@ -208,7 +210,7 @@ contract('ControllerUpgradeScheme', accounts => { assert.equal(await controller.isSchemeRegistered(accounts[0]),false); assert.equal(await controller.isSchemeRegistered(testSetup.controllerUpgradeScheme.address),true); - await testSetup.controllerUpgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.controllerUpgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution organizationProposal = await testSetup.controllerUpgradeScheme.organizationProposals(proposalId); @@ -238,7 +240,7 @@ contract('ControllerUpgradeScheme', accounts => { assert.equal(await controller.isSchemeRegistered(accounts[0]),false); assert.equal(await controller.isSchemeRegistered(testSetup.controllerUpgradeScheme.address),true); - await testSetup.controllerUpgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.controllerUpgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution organizationProposal = await testSetup.controllerUpgradeScheme.organizationProposals(proposalId); @@ -262,7 +264,7 @@ contract('ControllerUpgradeScheme', accounts => { var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(testSetup.controllerUpgradeScheme.address),true); - await testSetup.controllerUpgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.controllerUpgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution var organizationProposal = await testSetup.controllerUpgradeScheme.organizationProposals(proposalId); diff --git a/test/fundingrequest.js b/test/fundingrequest.js index 98fa18ac..e996c9b2 100644 --- a/test/fundingrequest.js +++ b/test/fundingrequest.js @@ -21,38 +21,41 @@ const setupJoinAndQuit = async function( _minFeeToJoin, _memberReputation, _fundingGoal, - _fundingGoalDeadline, - _packageVersion = [0,1,0] + _fundingGoalDeadline ) { var joinAndQuitParams = new JoinAndQuitParams(); - var encodedJoinAndQuitParams = web3.eth.abi.encodeParameters(['address','uint256','uint256','uint256','uint256','bool'], - [_fundingToken,_minFeeToJoin,_memberReputation,_fundingGoal,_fundingGoalDeadline,false]); if (genesisProtocol === true) { joinAndQuitParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS); joinAndQuitParams.initdata = await new web3.eth.Contract(registration.joinAndQuit.abi) .methods .initialize(helpers.NULL_ADDRESS, + joinAndQuitParams.votingMachine.genesisProtocol.address, joinAndQuitParams.votingMachine.uintArray, joinAndQuitParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "GenesisProtocol", - encodedJoinAndQuitParams) + helpers.NULL_HASH, + _fundingToken, + _minFeeToJoin, + _memberReputation, + _fundingGoal, + _fundingGoalDeadline, + false) .encodeABI(); } else { joinAndQuitParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); joinAndQuitParams.initdata = await new web3.eth.Contract(registration.joinAndQuit.abi) .methods .initialize(helpers.NULL_ADDRESS, - joinAndQuitParams.votingMachine.uintArray, - joinAndQuitParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "AbsoluteVote", - encodedJoinAndQuitParams) + joinAndQuitParams.votingMachine.absoluteVote.address, + [1,1,1,1,1,1,1,1,1,1,1], + helpers.NULL_ADDRESS, + joinAndQuitParams.votingMachine.params, + _fundingToken, + _minFeeToJoin, + _memberReputation, + _fundingGoal, + _fundingGoalDeadline, + false) .encodeABI(); } return joinAndQuitParams; @@ -63,8 +66,7 @@ const setupFundingRequest = async function( accounts, genesisProtocol, token, - externalToken, - _packageVersion = [0,1,0]) { + externalToken) { var fundingRequestParams = new FundingRequestParams(); if (genesisProtocol === true) { @@ -72,12 +74,10 @@ const setupFundingRequest = async function( fundingRequestParams.initdata = await new web3.eth.Contract(registration.fundingRequest.abi) .methods .initialize(helpers.NULL_ADDRESS, + fundingRequestParams.votingMachine.genesisProtocol.address, fundingRequestParams.votingMachine.uintArray, fundingRequestParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "GenesisProtocol", + helpers.NULL_HASH, externalToken ) .encodeABI(); @@ -86,12 +86,10 @@ const setupFundingRequest = async function( fundingRequestParams.initdata = await new web3.eth.Contract(registration.fundingRequest.abi) .methods .initialize(helpers.NULL_ADDRESS, - fundingRequestParams.votingMachine.uintArray, - fundingRequestParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "AbsoluteVote", + fundingRequestParams.votingMachine.absoluteVote.address, + [1,1,1,1,1,1,1,1,1,1,1], + helpers.NULL_ADDRESS, + fundingRequestParams.votingMachine.params, externalToken ) .encodeABI(); @@ -158,13 +156,9 @@ const setup = async function (accounts, [permissions, permissions], "metaData"); - testSetup.joinAndQuit = await JoinAndQuit.at(tx.logs[7].args._scheme); - testSetup.fundingRequest = await FundingRequest.at(tx.logs[10].args._scheme); - testSetup.joinAndQuitParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.joinAndQuit.votingMachine(),genesisProtocol); + testSetup.joinAndQuit = await JoinAndQuit.at(tx.logs[6].args._scheme); + testSetup.fundingRequest = await FundingRequest.at(tx.logs[8].args._scheme); - testSetup.fundingRequestParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.fundingRequest.votingMachine(),genesisProtocol); if(setupJAQProposal) { await testSetup.standardTokenMock.transfer(accounts[3],10000); @@ -178,8 +172,11 @@ const setup = async function (accounts, testSetup.fundingGoal, {value, from:accounts[3]}); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + if (genesisProtocol === false) { + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + } else { + await testSetup.joinAndQuitParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + } } return testSetup; }; @@ -187,9 +184,10 @@ contract('FundingRequest', accounts => { it("initialize", async function() { var testSetup = await setup(accounts, false); - assert.equal(await testSetup.fundingRequest.votingMachine(),testSetup.fundingRequestParams.votingMachineInstance.address); + assert.equal(await testSetup.fundingRequest.votingMachine(),testSetup.fundingRequestParams.votingMachine.absoluteVote.address); assert.equal(await testSetup.fundingRequest.fundingToken(),testSetup.standardTokenMock.address); }); + it("can't propose before funded", async() => { var testSetup = await setup(accounts, false); try { @@ -244,7 +242,7 @@ contract('FundingRequest', accounts => { "description-hash"); let proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.fundingRequestParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.fundingRequestParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.fundingRequest.proposals(proposalId); assert.equal(proposal.executionTime, (await web3.eth.getBlock("latest")).timestamp); }); @@ -259,7 +257,7 @@ contract('FundingRequest', accounts => { "description-hash"); let proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.fundingRequestParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.fundingRequestParams.votingMachine.absoluteVote.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.fundingRequest.proposals(proposalId); assert.equal(proposal.executionTime, 0); }); @@ -273,7 +271,7 @@ contract('FundingRequest', accounts => { "description-hash"); let proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.fundingRequestParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.fundingRequestParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.fundingRequest.proposals(proposalId); assert.equal(proposal.executionTime, (await web3.eth.getBlock("latest")).timestamp); tx = await testSetup.fundingRequest.redeem(proposalId); @@ -297,7 +295,7 @@ contract('FundingRequest', accounts => { "description-hash"); let proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.fundingRequestParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.fundingRequestParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.fundingRequest.proposals(proposalId); assert.equal(proposal.executionTime, (await web3.eth.getBlock("latest")).timestamp); tx = await testSetup.fundingRequest.redeem(proposalId); @@ -322,7 +320,7 @@ contract('FundingRequest', accounts => { "description-hash"); let proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.fundingRequestParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.fundingRequestParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.fundingRequest.proposals(proposalId); assert.equal(proposal.executionTime, (await web3.eth.getBlock("latest")).timestamp); tx = await testSetup.fundingRequest.redeem(proposalId); @@ -368,7 +366,7 @@ contract('FundingRequest', accounts => { "description-hash"); let proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.fundingRequestParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.fundingRequestParams.votingMachine.absoluteVote.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.fundingRequest.proposals(proposalId); assert.equal(proposal.executionTime, 0); try { @@ -389,7 +387,7 @@ contract('FundingRequest', accounts => { "description-hash"); let proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.fundingRequestParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.fundingRequestParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.fundingRequest.proposals(proposalId); assert.equal(proposal.executionTime, (await web3.eth.getBlock("latest")).timestamp); tx = await testSetup.fundingRequest.redeem(proposalId); diff --git a/test/genericscheme.js b/test/genericscheme.js index 7f80729f..fe8628be 100644 --- a/test/genericscheme.js +++ b/test/genericscheme.js @@ -15,8 +15,7 @@ const setupGenericSchemeParams = async function( accounts, genesisProtocol, token, - contractToCall, - _packageVersion = [0,1,0] + contractToCall ) { var genericSchemeParams = new GenericSchemeParams(); @@ -25,12 +24,10 @@ const setupGenericSchemeParams = async function( genericSchemeParams.initdata = await new web3.eth.Contract(registration.genericScheme.abi) .methods .initialize(helpers.NULL_ADDRESS, + genericSchemeParams.votingMachine.genesisProtocol.address, genericSchemeParams.votingMachine.uintArray, genericSchemeParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "GenesisProtocol", + helpers.NULL_HASH, contractToCall) .encodeABI(); } else { @@ -38,19 +35,17 @@ const setupGenericSchemeParams = async function( genericSchemeParams.initdata = await new web3.eth.Contract(registration.genericScheme.abi) .methods .initialize(helpers.NULL_ADDRESS, - genericSchemeParams.votingMachine.uintArray, - genericSchemeParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "AbsoluteVote", + genericSchemeParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + genericSchemeParams.votingMachine.params, contractToCall) .encodeABI(); } return genericSchemeParams; }; -const setup = async function (accounts,contractToCall = 0,reputationAccount=0,genesisProtocol = false,tokenAddress=helpers.NULL_ADDRESS) { +const setup = async function (accounts,contractToCall = 0,reputationAccount=0,genesisProtocol = false,tokenAddress=0) { var testSetup = new helpers.TestSetup(); testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); registration = await helpers.registerImplementation(); @@ -87,8 +82,6 @@ const setup = async function (accounts,contractToCall = 0,reputationAccount=0,ge ); testSetup.genericScheme = await GenericScheme.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.genericSchemeParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.genericScheme.votingMachine(),genesisProtocol); return testSetup; }; @@ -120,7 +113,7 @@ contract('GenericScheme', function(accounts) { var callData = await createCallToActionMock(testSetup.org.avatar.address,actionMock); var tx = await testSetup.genericScheme.proposeCall(callData,0,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.genericSchemeParams.votingMachineInstance.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.genericSchemeParams.votingMachine.absoluteVote.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution var organizationProposal = await testSetup.genericScheme.organizationProposals(proposalId); assert.equal(organizationProposal.passed,false); @@ -135,7 +128,7 @@ contract('GenericScheme', function(accounts) { var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); var organizationProposal = await testSetup.genericScheme.organizationProposals(proposalId); assert.equal(organizationProposal[0],callData,helpers.NULL_HASH); - await testSetup.genericSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.genericSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution organizationProposal = await testSetup.genericScheme.organizationProposals(proposalId); assert.equal(organizationProposal.callData,null);//new contract address @@ -148,7 +141,7 @@ contract('GenericScheme', function(accounts) { var tx = await testSetup.genericScheme.proposeCall(callData,0,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.genericSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.genericSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //actionMock revert because msg.sender is not the _addr param at actionMock thpugh the generic scheme not . var organizationProposal = await testSetup.genericScheme.organizationProposals(proposalId); assert.equal(organizationProposal.exist,true);//new contract address @@ -167,7 +160,7 @@ contract('GenericScheme', function(accounts) { var tx = await testSetup.genericScheme.proposeCall(callData,0,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.genericSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.genericSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //actionMock revert because msg.sender is not the _addr param at actionMock thpugh the generic scheme not . var organizationProposal = await testSetup.genericScheme.organizationProposals(proposalId); assert.equal(organizationProposal.exist,true);//new contract address @@ -197,7 +190,7 @@ contract('GenericScheme', function(accounts) { var tx = await testSetup.genericScheme.proposeCall(encodeABI,0,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.genericSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.genericSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); }); @@ -228,7 +221,7 @@ contract('GenericScheme', function(accounts) { //transfer some eth to avatar await web3.eth.sendTransaction({from:accounts[0],to:testSetup.org.avatar.address, value: web3.utils.toWei('1', "ether")}); assert.equal(await web3.eth.getBalance(actionMock.address),0); - tx = await testSetup.genericSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.genericSchemeParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.genericScheme.getPastEvents('ProposalExecutedByVotingMachine', { fromBlock: tx.blockNumber, toBlock: 'latest' @@ -248,7 +241,7 @@ contract('GenericScheme', function(accounts) { var callData = await createCallToActionMock(testSetup.org.avatar.address,actionMock); var tx = await testSetup.genericScheme.proposeCall(callData,0,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - tx = await testSetup.genericSchemeParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.genericSchemeParams.votingMachine.genesisProtocol.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.genericScheme.getPastEvents('ProposalExecutedByVotingMachine', { fromBlock: tx.blockNumber, toBlock: 'latest' @@ -269,7 +262,7 @@ contract('GenericScheme', function(accounts) { var tx = await testSetup.genericScheme.proposeCall(callData,0,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); assert.equal(await web3.eth.getBalance(wallet.address),web3.utils.toWei('1', "ether")); - await testSetup.genericSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.genericSchemeParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(await web3.eth.getBalance(wallet.address),web3.utils.toWei('1', "ether")); await wallet.transferOwnership(testSetup.org.avatar.address); await testSetup.genericScheme.execute( proposalId); @@ -282,14 +275,12 @@ contract('GenericScheme', function(accounts) { try { await testSetup.genericScheme.initialize( + testSetup.org.avatar.address, + accounts[0], + [0,0,0,0,0,0,0,0,0,0,0], helpers.NULL_ADDRESS, - testSetup.genericSchemeParams.votingMachine.uintArray, - testSetup.genericSchemeParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - helpers.NULL_ADDRESS, - [0,1,0], - "GenesisProtocol", - helpers.NULL_ADDRESS + helpers.SOME_HASH, + accounts[0] ); assert(false, "cannot init twice"); } catch(error) { diff --git a/test/globalconstraintregistrar.js b/test/globalconstraintregistrar.js index ab5010d9..15305ccb 100644 --- a/test/globalconstraintregistrar.js +++ b/test/globalconstraintregistrar.js @@ -10,11 +10,9 @@ class GlobalConstraintRegistrarParams { } var registration; const setupGlobalConstraintRegistrarParams = async function( - globalConstraintRegistrar, accounts, genesisProtocol, - token, - _packageVersion = [0,1,0] + token ) { var globalConstraintRegistrarParams = new GlobalConstraintRegistrarParams(); if (genesisProtocol === true) { @@ -22,24 +20,20 @@ const setupGlobalConstraintRegistrarParams = async function( globalConstraintRegistrarParams.initdata = await new web3.eth.Contract(registration.globalConstraintRegistrar.abi) .methods .initialize(helpers.NULL_ADDRESS, + globalConstraintRegistrarParams.votingMachine.genesisProtocol.address, globalConstraintRegistrarParams.votingMachine.uintArray, globalConstraintRegistrarParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "GenesisProtocol") + helpers.NULL_HASH) .encodeABI(); } else { globalConstraintRegistrarParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); globalConstraintRegistrarParams.initdata = await new web3.eth.Contract(registration.globalConstraintRegistrar.abi) .methods .initialize(helpers.NULL_ADDRESS, - globalConstraintRegistrarParams.votingMachine.uintArray, - globalConstraintRegistrarParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "AbsoluteVote") + globalConstraintRegistrarParams.votingMachine.absoluteVote.address, + [1,1,1,1,1,1,1,1,1,1,1], + helpers.NULL_ADDRESS, + globalConstraintRegistrarParams.votingMachine.params) .encodeABI(); } return globalConstraintRegistrarParams; @@ -52,8 +46,7 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=help testSetup.reputationArray = [20,10,70]; testSetup.proxyAdmin = accounts[5]; - testSetup.globalConstraintRegistrarParams= await setupGlobalConstraintRegistrarParams(testSetup.globalConstraintRegistrar, - accounts, + testSetup.globalConstraintRegistrarParams= await setupGlobalConstraintRegistrarParams(accounts, genesisProtocol, tokenAddress); var permissions = "0x00000004"; @@ -73,34 +66,36 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=help [permissions], "metaData"); testSetup.globalConstraintRegistrar = await GlobalConstraintRegistrar.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.globalConstraintRegistrarParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.globalConstraintRegistrar.votingMachine(),genesisProtocol); return testSetup; }; - -const propose = async function( - testSetup, - gc - ) { - var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( - gc, - "0x1234" - ); - return [await helpers.getValueFromLogs(tx, '_proposalId',1),tx]; -}; contract('GlobalConstraintRegistrar', accounts => { it("initialize", async ()=> { var testSetup = await setup(accounts); - assert.equal(await testSetup.globalConstraintRegistrar.votingMachine(),testSetup.globalConstraintRegistrarParams.votingMachineInstance.address); + assert.equal(await testSetup.globalConstraintRegistrar.votingMachine(),testSetup.globalConstraintRegistrarParams.votingMachine.absoluteVote.address); + }); + + it("proposeGlobalConstraint voteToRemoveParams", async function() { + var testSetup = await setup(accounts); + var globalConstraintMock = await GlobalConstraintMock.new(); + + var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( + globalConstraintMock.address, + "0x1235",helpers.NULL_HASH); + var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); + await testSetup.globalConstraintRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + var voteToRemoveParams = await testSetup.globalConstraintRegistrar.voteToRemoveParams(globalConstraintMock.address); + assert.equal(voteToRemoveParams, "0x1235000000000000000000000000000000000000000000000000000000000000"); }); it("proposeGlobalConstraint organizationsProposals", async function() { var testSetup = await setup(accounts); var globalConstraintMock = await GlobalConstraintMock.new(); - [proposalId, tx] = await propose( testSetup, - globalConstraintMock.address); + var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( + globalConstraintMock.address, + "0x1234",helpers.NULL_HASH); + var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var organizationProposal = await testSetup.globalConstraintRegistrar.organizationProposals(proposalId); assert.equal(organizationProposal[0],globalConstraintMock.address); }); @@ -108,7 +103,10 @@ contract('GlobalConstraintRegistrar', accounts => { it("proposeGlobalConstraint log", async function() { var testSetup = await setup(accounts); var globalConstraintMock = await GlobalConstraintMock.new(); - [proposalId,tx] = await propose(testSetup,globalConstraintMock.address); + + var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( + globalConstraintMock.address, + "0x1234",helpers.NULL_HASH); assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "NewGlobalConstraintsProposal"); }); @@ -121,14 +119,16 @@ contract('GlobalConstraintRegistrar', accounts => { - [proposalId, tx] = await propose( testSetup, - globalConstraintMock.address); + var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( + globalConstraintMock.address, + testSetup.globalConstraintRegistrarParams.votingMachine.params,helpers.NULL_HASH); assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "NewGlobalConstraintsProposal"); + var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); let gcCount = await controller.globalConstraintsCount(); assert.equal(gcCount[0],0); assert.equal(gcCount[1],0); - tx = await testSetup.globalConstraintRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.globalConstraintRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); gcCount = await controller.globalConstraintsCount(); assert.equal(gcCount[0],1); }); @@ -138,9 +138,11 @@ contract('GlobalConstraintRegistrar', accounts => { var globalConstraintMock =await GlobalConstraintMock.new(); await globalConstraintMock.setConstraint(web3.utils.asciiToHex("method"),false,false); - [proposalId,tx] = await propose(testSetup,globalConstraintMock.address); - - await testSetup.globalConstraintRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( + globalConstraintMock.address, + testSetup.globalConstraintRegistrarParams.votingMachine.params,helpers.NULL_HASH); + var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); + await testSetup.globalConstraintRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.globalConstraintRegistrar.proposeToRemoveGC( globalConstraintMock.address,helpers.NULL_HASH); assert.equal(tx.logs.length, 1); @@ -167,9 +169,11 @@ contract('GlobalConstraintRegistrar', accounts => { var globalConstraintMock =await GlobalConstraintMock.new(); await globalConstraintMock.setConstraint(web3.utils.asciiToHex("method"),false,false); - [proposalId,tx] = await propose(testSetup,globalConstraintMock.address); - - await testSetup.globalConstraintRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( + globalConstraintMock.address, + testSetup.globalConstraintRegistrarParams.votingMachine.params,helpers.NULL_HASH); + var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); + await testSetup.globalConstraintRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(await controller.isGlobalConstraintRegistered(globalConstraintMock.address),true); tx = await testSetup.globalConstraintRegistrar.proposeToRemoveGC( globalConstraintMock.address, @@ -179,7 +183,7 @@ contract('GlobalConstraintRegistrar', accounts => { proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); let count = await controller.globalConstraintsCount(); assert.equal(count[0],1); - await testSetup.globalConstraintRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.globalConstraintRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); count = await controller.globalConstraintsCount(); assert.equal(count[0],0); }); @@ -190,8 +194,11 @@ contract('GlobalConstraintRegistrar', accounts => { var globalConstraintMock =await GlobalConstraintMock.new(); await globalConstraintMock.setConstraint(web3.utils.asciiToHex("method"),false,false); - [proposalId,tx] = await propose(testSetup,globalConstraintMock.address); - await testSetup.globalConstraintRegistrarParams.votingMachineInstance.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( + globalConstraintMock.address, + testSetup.globalConstraintRegistrarParams.votingMachine.params,helpers.NULL_HASH); + var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); + await testSetup.globalConstraintRegistrarParams.votingMachine.absoluteVote.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); let count = await controller.globalConstraintsCount(); assert.equal(count[0],0); }); @@ -202,15 +209,20 @@ contract('GlobalConstraintRegistrar', accounts => { var globalConstraintMock =await GlobalConstraintMock.new(); //genesisProtocol use burn reputation. await globalConstraintMock.setConstraint(web3.utils.asciiToHex("burnReputation"),true,true); - [proposalId,tx] = await propose(testSetup,globalConstraintMock.address); - await testSetup.globalConstraintRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + var tx = await testSetup.globalConstraintRegistrar.proposeGlobalConstraint( + globalConstraintMock.address, + testSetup.globalConstraintRegistrarParams.votingMachine.params, + helpers.NULL_HASH); + + var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); + await testSetup.globalConstraintRegistrarParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.globalConstraintRegistrar.proposeToRemoveGC( globalConstraintMock.address, helpers.NULL_HASH); proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var rep = await testSetup.org.reputation.balanceOf(accounts[2]); - await testSetup.globalConstraintRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); - await helpers.checkVoteInfo(testSetup.globalConstraintRegistrarParams.votingMachineInstance,proposalId,accounts[2],[1,rep.toNumber()]); + await testSetup.globalConstraintRegistrarParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await helpers.checkVoteInfo(testSetup.globalConstraintRegistrarParams.votingMachine.genesisProtocol,proposalId,accounts[2],[1,rep.toNumber()]); }); }); diff --git a/test/helpers.js b/test/helpers.js index efcd1695..9f0c4f07 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -5,6 +5,7 @@ const Avatar = artifacts.require("./Avatar.sol"); const DAOToken = artifacts.require("./DAOToken.sol"); const Reputation = artifacts.require("./Reputation.sol"); const AbsoluteVote = artifacts.require("./AbsoluteVote.sol"); +const constants = require('./constants'); const GenesisProtocol = artifacts.require("./GenesisProtocol.sol"); const DAOFactory = artifacts.require("./DAOFactory.sol"); const SchemeMock = artifacts.require('./test/SchemeMock.sol'); @@ -37,6 +38,7 @@ const JoinAndQuit = artifacts.require("./JoinAndQuit.sol"); const FundingRequest = artifacts.require("./FundingRequest.sol"); const Dictator = artifacts.require("./Dictator.sol"); + const MAX_UINT_256 = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'; const NULL_HASH = '0x0000000000000000000000000000000000000000000000000000000000000000'; const SOME_HASH = '0x1000000000000000000000000000000000000000000000000000000000000000'; @@ -153,8 +155,6 @@ const SOME_ADDRESS = '0x1000000000000000000000000000000000000000'; registration.arcVotingMachineCallbacksMock = await ARCVotingMachineCallbacksMock.new(); registration.joinAndQuit = await JoinAndQuit.new(); registration.fundingRequest = await FundingRequest.new(); - registration.genesisProtocol = await GenesisProtocol.new(); - registration.absoluteVote = await AbsoluteVote.new(); registration.rewarderMock = await RewarderMock.new(); registration.dictator = await Dictator.new(); @@ -187,10 +187,9 @@ const SOME_ADDRESS = '0x1000000000000000000000000000000000000000'; await implementationDirectory.setImplementation("ARCVotingMachineCallbacksMock",registration.arcVotingMachineCallbacksMock.address); await implementationDirectory.setImplementation("JoinAndQuit",registration.joinAndQuit.address); await implementationDirectory.setImplementation("FundingRequest",registration.fundingRequest.address); - await implementationDirectory.setImplementation("GenesisProtocol",registration.genesisProtocol.address); - await implementationDirectory.setImplementation("AbsoluteVote",registration.absoluteVote.address); await implementationDirectory.setImplementation("Dictator",registration.dictator.address); + registration.implementationDirectory = implementationDirectory; return registration; @@ -206,21 +205,12 @@ const SOME_ADDRESS = '0x1000000000000000000000000000000000000000'; return registration; }; -const getVotingMachine = async function (votingMachine, genesisProtocol) { - if (genesisProtocol === true) { - return await GenesisProtocol.at(votingMachine); - } - return await AbsoluteVote.at(votingMachine); -}; - const setupAbsoluteVote = async function (voteOnBehalf=NULL_ADDRESS, precReq=50 ) { var votingMachine = new VotingMachine(); + votingMachine.absoluteVote = await AbsoluteVote.new(); // register some parameters - votingMachine.uintArray = [precReq, - 0,0,0,0,0,0,0,0,0,0]; - votingMachine.voteOnBehalf = voteOnBehalf; - - // register some parameters + await votingMachine.absoluteVote.setParameters( precReq, voteOnBehalf); + votingMachine.params = await votingMachine.absoluteVote.getParametersHash( precReq, voteOnBehalf); return votingMachine; }; @@ -256,7 +246,7 @@ await daoFactory.getPastEvents('SchemeInstance', { ) { var votingMachine = new VotingMachine(); - //votingMachine.genesisProtocol = await GenesisProtocol.new(token,{gas: constants.ARC_GAS_LIMIT}); + votingMachine.genesisProtocol = await GenesisProtocol.new(token,{gas: constants.ARC_GAS_LIMIT}); // set up a reputation system votingMachine.reputationArray = [20, 10 ,70]; @@ -273,6 +263,18 @@ await daoFactory.getPastEvents('SchemeInstance', { _daoBountyConst, _activationTime]; votingMachine.voteOnBehalf = voteOnBehalf; + votingMachine.params = await votingMachine.genesisProtocol.getParametersHash([_queuedVoteRequiredPercentage, + _queuedVotePeriodLimit, + _boostedVotePeriodLimit, + _preBoostedVotePeriodLimit, + _thresholdConst, + _quietEndingPeriod, + _proposingRepReward, + _votersReputationLossRatio, + _minimumDaoBounty, + _daoBountyConst, + _activationTime],voteOnBehalf); + return votingMachine; }; @@ -406,6 +408,5 @@ module.exports = { MAX_UINT_256, checkVoteInfo, registrationAddVersionToPackege, concatBytes, - getProposalId, - getVotingMachine, - getSchemeAddress}; + getSchemeAddress, + getProposalId}; diff --git a/test/joinandquit.js b/test/joinandquit.js index cf9806ff..e75d36de 100644 --- a/test/joinandquit.js +++ b/test/joinandquit.js @@ -16,7 +16,7 @@ const addMember = async function(accounts,_testSetup,_fee,_from) { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await _testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await _testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); return tx; }; @@ -36,36 +36,40 @@ const setupJoinAndQuit = async function( _fundingGoal, _fundingGoalDeadline, _rageQuitEnable = true, - _packageVersion= [0,1,0] ) { var joinAndQuitParams = new JoinAndQuitParams(); - var encodedJoinAndQuitParams = web3.eth.abi.encodeParameters(['address','uint256','uint256','uint256','uint256','bool'], - [_fundingToken,_minFeeToJoin,_memberReputation,_fundingGoal,_fundingGoalDeadline,_rageQuitEnable]); + if (genesisProtocol === true) { joinAndQuitParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS); joinAndQuitParams.initdata = await new web3.eth.Contract(registration.joinAndQuit.abi) .methods .initialize(helpers.NULL_ADDRESS, + joinAndQuitParams.votingMachine.genesisProtocol.address, joinAndQuitParams.votingMachine.uintArray, joinAndQuitParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "GenesisProtocol", - encodedJoinAndQuitParams) + helpers.NULL_HASH, + _fundingToken, + _minFeeToJoin, + _memberReputation, + _fundingGoal, + _fundingGoalDeadline, + _rageQuitEnable) .encodeABI(); } else { joinAndQuitParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); joinAndQuitParams.initdata = await new web3.eth.Contract(registration.joinAndQuit.abi) .methods .initialize(helpers.NULL_ADDRESS, - joinAndQuitParams.votingMachine.uintArray, - joinAndQuitParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "AbsoluteVote", - encodedJoinAndQuitParams) + joinAndQuitParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + joinAndQuitParams.votingMachine.params, + _fundingToken, + _minFeeToJoin, + _memberReputation, + _fundingGoal, + _fundingGoalDeadline, + _rageQuitEnable) .encodeABI(); } return joinAndQuitParams; @@ -123,8 +127,6 @@ const setup = async function (accounts, testSetup.joinAndQuit = await JoinAndQuit.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); await testSetup.standardTokenMock.transfer(accounts[3],10000); - testSetup.joinAndQuitParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.joinAndQuit.votingMachine(),genesisProtocol); return testSetup; }; @@ -132,8 +134,8 @@ contract('JoinAndQuit', accounts => { it("initialize", async function() { var testSetup = await setup(accounts); - assert.equal(await testSetup.joinAndQuit.votingMachine(),testSetup.joinAndQuitParams.votingMachineInstance.address); - assert.equal((await testSetup.joinAndQuit.joinAndQuitParams()).fundingGoalDeadline,testSetup.fundingGoalDeadline); + assert.equal(await testSetup.joinAndQuit.votingMachine(),testSetup.joinAndQuitParams.votingMachine.absoluteVote.address); + assert.equal(await testSetup.joinAndQuit.fundingGoalDeadline(),testSetup.fundingGoalDeadline); }); it("propose log", async function() { @@ -218,7 +220,7 @@ contract('JoinAndQuit', accounts => { {from:candidate}); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.joinAndQuit.redeemReputation(proposalId); @@ -270,7 +272,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.joinAndQuit.proposals(proposalId); assert.equal(proposal.accepted,true); assert.equal(await testSetup.standardTokenMock.balanceOf(testSetup.org.avatar.address),testSetup.minFeeToJoin); @@ -287,7 +289,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.joinAndQuit.proposals(proposalId); assert.equal(proposal.accepted,true); assert.equal(await avatarBalance(testSetup),testSetup.minFeeToJoin); @@ -305,7 +307,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.joinAndQuit.proposals(proposalId); assert.equal(proposal.accepted,false); assert.equal(await testSetup.standardTokenMock.balanceOf(testSetup.org.avatar.address),0); @@ -325,7 +327,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var balanceBefore = await web3.eth.getBalance(accounts[3]); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var proposal = await testSetup.joinAndQuit.proposals(proposalId); assert.equal(proposal.accepted,false); assert.equal(await avatarBalance(testSetup),0); @@ -348,7 +350,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.joinAndQuit.redeemReputation(proposalId); assert.equal(tx.logs[0].event, "RedeemReputation"); assert.equal(tx.logs[0].args._amount, testSetup.memberReputation); @@ -371,7 +373,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.joinAndQuit.redeemReputation(proposalId); assert.equal(tx.logs[0].event, "RedeemReputation"); assert.equal(tx.logs[0].args._amount, testSetup.minFeeToJoin); @@ -388,7 +390,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); tx = await testSetup.joinAndQuit.redeemReputation(proposalId); assert.equal(tx.logs[0].event, "RedeemReputation"); assert.equal(tx.logs[0].args._amount, testSetup.memberReputation); @@ -411,7 +413,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); try { await testSetup.joinAndQuit.redeemReputation(proposalId); assert(false, 'reputation cannot redeemed'); @@ -430,7 +432,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(await testSetup.standardTokenMock.balanceOf(testSetup.org.avatar.address),testSetup.minFeeToJoin); assert.equal((await testSetup.joinAndQuit.fundings(accounts[3])).funding,testSetup.minFeeToJoin); await testSetup.joinAndQuit.rageQuit({from:accounts[3]}); @@ -483,7 +485,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(await avatarBalance(testSetup),testSetup.minFeeToJoin); assert.equal((await testSetup.joinAndQuit.fundings(accounts[3])).funding,testSetup.minFeeToJoin); await testSetup.joinAndQuit.rageQuit({from:accounts[3]}); @@ -530,7 +532,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - tx = await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.joinAndQuit.getPastEvents('FundedBeforeDeadline', { fromBlock: tx.blockNumber, toBlock: 'latest' @@ -556,7 +558,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - tx = await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.joinAndQuit.getPastEvents('FundedBeforeDeadline', { fromBlock: tx.blockNumber, toBlock: 'latest' @@ -628,7 +630,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(await testSetup.standardTokenMock.balanceOf(testSetup.org.avatar.address),testSetup.minFeeToJoin); assert.equal((await testSetup.joinAndQuit.fundings(accounts[3])).funding,testSetup.minFeeToJoin); try { @@ -650,7 +652,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(await testSetup.standardTokenMock.balanceOf(testSetup.org.avatar.address),testSetup.minFeeToJoin); assert.equal((await testSetup.joinAndQuit.fundings(accounts[3])).funding,testSetup.minFeeToJoin); try { @@ -679,7 +681,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await helpers.increaseTime(testSetup.fundingGoalDeadline); try { @@ -699,7 +701,7 @@ contract('JoinAndQuit', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.joinAndQuitParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal((await testSetup.joinAndQuit.fundings(accounts[3])).funding,testSetup.minFeeToJoin); try { await testSetup.joinAndQuit.refund({from:accounts[3]}); diff --git a/test/lockingtoken4reputation.js b/test/lockingtoken4reputation.js index 42430e6b..d0e24809 100644 --- a/test/lockingtoken4reputation.js +++ b/test/lockingtoken4reputation.js @@ -356,13 +356,4 @@ contract('LockingToken4Reputation', accounts => { accounts[1], helpers.SOME_HASH); }); - - it("get earned reputation", async () => { - let testSetup = await setup(accounts); - await testSetup.lockingToken4Reputation.lock(web3.utils.toWei('1', "ether"),100,testSetup.lockingToken.address,testSetup.agreementHash); - await helpers.increaseTime(3001); - const reputation = await testSetup.lockingToken4Reputation.redeem.call(accounts[0]); - assert.equal(reputation,100); - assert.equal(await testSetup.org.reputation.balanceOf(accounts[0]),1000); - }); }); diff --git a/test/schemefactory.js b/test/schemefactory.js index 65c78b27..3327c828 100644 --- a/test/schemefactory.js +++ b/test/schemefactory.js @@ -10,9 +10,7 @@ class SchemeFactoryParams { var registration; const setupSchemeFactoryParams = async function( accounts, - genesisProtocol, - token, - _packageVersion=[0,1,0] + genesisProtocol ) { var schemeFactoryParams = new SchemeFactoryParams(); if (genesisProtocol === true) { @@ -20,31 +18,29 @@ const setupSchemeFactoryParams = async function( schemeFactoryParams.initdata = await new web3.eth.Contract(registration.schemeFactory.abi) .methods .initialize(helpers.NULL_ADDRESS, + schemeFactoryParams.votingMachine.genesisProtocol.address, schemeFactoryParams.votingMachine.uintArray, schemeFactoryParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "GenesisProtocol") + helpers.NULL_HASH, + registration.daoFactory.address) .encodeABI(); } else { schemeFactoryParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); schemeFactoryParams.initdata = await new web3.eth.Contract(registration.schemeFactory.abi) .methods .initialize(helpers.NULL_ADDRESS, - schemeFactoryParams.votingMachine.uintArray, - schemeFactoryParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "AbsoluteVote") + schemeFactoryParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + schemeFactoryParams.votingMachine.params, + registration.daoFactory.address) .encodeABI(); } return schemeFactoryParams; }; -const setup = async function (accounts,genesisProtocol = false,tokenAddress=helpers.NULL_ADDRESS) { +const setup = async function (accounts,genesisProtocol = false) { var testSetup = new helpers.TestSetup(); registration = await helpers.registerImplementation(); testSetup.reputationArray = [2000,4000,7000]; @@ -52,8 +48,7 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=help testSetup.schemeFactoryParams= await setupSchemeFactoryParams( accounts, - genesisProtocol, - tokenAddress); + genesisProtocol); var permissions = "0x0000001f"; @@ -75,8 +70,6 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=help ); testSetup.schemeFactory = await SchemeFactory.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.schemeFactoryParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.schemeFactory.votingMachine(),genesisProtocol); return testSetup; }; contract('SchemeFactory', accounts => { @@ -84,7 +77,7 @@ contract('SchemeFactory', accounts => { it("initialize", async() => { var testSetup = await setup(accounts); assert.equal(await testSetup.schemeFactory.votingMachine(), - testSetup.schemeFactoryParams.votingMachineInstance.address); + testSetup.schemeFactoryParams.votingMachine.absoluteVote.address); assert.equal(await testSetup.schemeFactory.avatar(),testSetup.org.avatar.address); assert.equal(await testSetup.schemeFactory.daoFactory(),registration.daoFactory.address); }); @@ -124,12 +117,11 @@ contract('SchemeFactory', accounts => { var initdata = await new web3.eth.Contract(registration.schemeFactory.abi) .methods .initialize(testSetup.org.avatar.address, - testSetup.schemeFactoryParams.votingMachine.uintArray, - testSetup.schemeFactoryParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, + testSetup.schemeFactoryParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], helpers.NULL_ADDRESS, - [0,1,0], - "AbsoluteVote") + testSetup.schemeFactoryParams.votingMachine.params, + registration.daoFactory.address) .encodeABI(); var tx = await testSetup.schemeFactory.proposeScheme( [0,1,0], @@ -141,9 +133,9 @@ contract('SchemeFactory', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - tx = await testSetup.schemeFactoryParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.schemeFactoryParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); let proxyEvents = await registration.daoFactory.getPastEvents("ProxyCreated", {fromBlock: tx.receipt.blockNumber, toBlock: tx.receipt.blockNumber}); - var schemeAddress = proxyEvents[1].returnValues._proxy; + var schemeAddress = proxyEvents[0].returnValues._proxy; var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(schemeAddress),true); assert.equal(await controller.schemesPermissions(schemeAddress),"0x0000001f"); @@ -154,12 +146,11 @@ contract('SchemeFactory', accounts => { var initdata = await new web3.eth.Contract(registration.schemeFactory.abi) .methods .initialize(testSetup.org.avatar.address, - testSetup.schemeFactoryParams.votingMachine.uintArray, - testSetup.schemeFactoryParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, + testSetup.schemeFactoryParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], helpers.NULL_ADDRESS, - [0,1,0], - "AbsoluteVote") + testSetup.schemeFactoryParams.votingMachine.params, + registration.daoFactory.address) .encodeABI(); var tx = await testSetup.schemeFactory.proposeScheme( [0,1,0], @@ -173,9 +164,9 @@ contract('SchemeFactory', accounts => { var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(testSetup.schemeFactory.address),true); - tx = await testSetup.schemeFactoryParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.schemeFactoryParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); let proxyEvents = await registration.daoFactory.getPastEvents("ProxyCreated", {fromBlock: tx.receipt.blockNumber, toBlock: tx.receipt.blockNumber}); - var schemeAddress = proxyEvents[1].returnValues._proxy; + var schemeAddress = proxyEvents[0].returnValues._proxy; assert.equal(await controller.isSchemeRegistered(schemeAddress),true); assert.equal(await controller.schemesPermissions(schemeAddress),"0x0000001f"); assert.equal(await controller.isSchemeRegistered(testSetup.schemeFactory.address),false); @@ -186,12 +177,11 @@ contract('SchemeFactory', accounts => { var initdata = await new web3.eth.Contract(registration.schemeFactory.abi) .methods .initialize(testSetup.org.avatar.address, - testSetup.schemeFactoryParams.votingMachine.uintArray, - testSetup.schemeFactoryParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, + testSetup.schemeFactoryParams.votingMachine.genesisProtocol.address, + [0,0,0,0,0,0,0,0,0,0,0], helpers.NULL_ADDRESS, - [0,1,0], - "GenesisProtocol") + testSetup.schemeFactoryParams.votingMachine.params, + registration.daoFactory.address) .encodeABI(); var tx = await testSetup.schemeFactory.proposeScheme( [0,1,0], @@ -205,9 +195,9 @@ contract('SchemeFactory', accounts => { var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(testSetup.schemeFactory.address),true); - tx = await testSetup.schemeFactoryParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.schemeFactoryParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); let proxyEvents = await registration.daoFactory.getPastEvents("ProxyCreated", {fromBlock: tx.receipt.blockNumber, toBlock: tx.receipt.blockNumber}); - var schemeAddress = proxyEvents[1].returnValues._proxy; + var schemeAddress = proxyEvents[0].returnValues._proxy; assert.equal(await controller.isSchemeRegistered(schemeAddress),true); assert.equal(await controller.schemesPermissions(schemeAddress),"0x0000001f"); assert.equal(await controller.isSchemeRegistered(testSetup.schemeFactory.address),false); @@ -227,7 +217,7 @@ contract('SchemeFactory', accounts => { var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(testSetup.schemeFactory.address),true); - tx = await testSetup.schemeFactoryParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.schemeFactoryParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); let proxyEvents = await registration.daoFactory.getPastEvents("ProxyCreated", {fromBlock: tx.receipt.blockNumber, toBlock: tx.receipt.blockNumber}); assert.equal(proxyEvents.length,0); assert.equal(await controller.isSchemeRegistered(testSetup.schemeFactory.address),false); @@ -247,7 +237,7 @@ contract('SchemeFactory', accounts => { var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); //Vote with reputation to trigger execution - tx = await testSetup.schemeFactoryParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.schemeFactoryParams.votingMachine.absoluteVote.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //should not register because the decision is "no" let proxyEvents = await registration.daoFactory.getPastEvents("ProxyCreated", {fromBlock: tx.receipt.blockNumber, toBlock: tx.receipt.blockNumber}); assert.equal(proxyEvents.length,0); diff --git a/test/schemeregistrar.js b/test/schemeregistrar.js index 2fbd0f49..2bd2d9c0 100644 --- a/test/schemeregistrar.js +++ b/test/schemeregistrar.js @@ -13,33 +13,36 @@ var registration; const setupSchemeRegistrarParams = async function( accounts, genesisProtocol, - token, - _packageVersion = [0,1,0] + token ) { var schemeRegistrarParams = new SchemeRegistrarParams(); if (genesisProtocol === true) { schemeRegistrarParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS); + let removalSchemeParams = [...schemeRegistrarParams.votingMachine.uintArray]; + removalSchemeParams[10] = 1; schemeRegistrarParams.initdata = await new web3.eth.Contract(registration.schemeRegistrar.abi) .methods .initialize(helpers.NULL_ADDRESS, + schemeRegistrarParams.votingMachine.genesisProtocol.address, schemeRegistrarParams.votingMachine.uintArray, schemeRegistrarParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "GenesisProtocol") + helpers.NULL_HASH, + removalSchemeParams, + schemeRegistrarParams.votingMachine.voteOnBehalf, + helpers.NULL_HASH) .encodeABI(); } else { schemeRegistrarParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); schemeRegistrarParams.initdata = await new web3.eth.Contract(registration.schemeRegistrar.abi) .methods .initialize(helpers.NULL_ADDRESS, - schemeRegistrarParams.votingMachine.uintArray, - schemeRegistrarParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "AbsoluteVote") + schemeRegistrarParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + schemeRegistrarParams.votingMachine.params, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + schemeRegistrarParams.votingMachine.params) .encodeABI(); } return schemeRegistrarParams; @@ -74,8 +77,6 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=help [permissions], "metaData"); testSetup.schemeRegistrar = await SchemeRegistrar.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.schemeRegistrarParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.schemeRegistrar.votingMachine(),genesisProtocol); return testSetup; }; contract('SchemeRegistrar', accounts => { @@ -83,7 +84,7 @@ contract('SchemeRegistrar', accounts => { it("initialize", async() => { var testSetup = await setup(accounts); assert.equal(await testSetup.schemeRegistrar.votingMachine(), - testSetup.schemeRegistrarParams.votingMachineInstance.address); + testSetup.schemeRegistrarParams.votingMachine.absoluteVote.address); assert.equal(await testSetup.schemeRegistrar.avatar(),testSetup.org.avatar.address); }); @@ -136,7 +137,7 @@ contract('SchemeRegistrar', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(universalScheme.address),true); }); @@ -148,7 +149,7 @@ contract('SchemeRegistrar', accounts => { //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(universalScheme.address),true); }); @@ -160,7 +161,7 @@ contract('SchemeRegistrar', accounts => { var tx = await testSetup.schemeRegistrar.proposeScheme(accounts[0],permissions,helpers.NULL_HASH); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(accounts[0]),true); assert.equal(await controller.schemesPermissions(accounts[0]),"0x00000001"); @@ -173,7 +174,7 @@ contract('SchemeRegistrar', accounts => { var tx = await testSetup.schemeRegistrar.proposeScheme(accounts[0],permissions,helpers.NULL_HASH); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(accounts[0]),true); assert.equal(await controller.schemesPermissions(accounts[0]),"0x00000003"); @@ -186,7 +187,7 @@ contract('SchemeRegistrar', accounts => { var tx = await testSetup.schemeRegistrar.proposeScheme(accounts[0],permissions,helpers.NULL_HASH); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(accounts[0]),true); assert.equal(await controller.schemesPermissions(accounts[0]),"0x00000003"); @@ -199,7 +200,7 @@ contract('SchemeRegistrar', accounts => { var tx = await testSetup.schemeRegistrar.proposeScheme(accounts[0],permissions,helpers.NULL_HASH); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(accounts[0]),true); assert.equal(await controller.schemesPermissions(accounts[0]),"0x00000009"); @@ -212,7 +213,7 @@ contract('SchemeRegistrar', accounts => { var tx = await testSetup.schemeRegistrar.proposeScheme(accounts[0],permissions,helpers.NULL_HASH); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(accounts[0]),true); assert.equal(await controller.schemesPermissions(accounts[0]),"0x00000011"); @@ -224,7 +225,7 @@ contract('SchemeRegistrar', accounts => { var tx = await testSetup.schemeRegistrar.proposeScheme(accounts[0],"0x00000000",helpers.NULL_HASH); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(accounts[0]),true); assert.equal(await controller.schemesPermissions(accounts[0]),"0x00000001"); @@ -242,7 +243,7 @@ contract('SchemeRegistrar', accounts => { assert.equal(organizationProposal[1],true);//proposalType //Vote with reputation to trigger execution - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var controller = await Controller.at(await testSetup.org.avatar.owner()); //should not register because the decision is "no" assert.equal(await controller.isSchemeRegistered(accounts[0]),false); @@ -259,7 +260,7 @@ contract('SchemeRegistrar', accounts => { var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(testSetup.schemeRegistrar.address),true); //Vote with reputation to trigger execution - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(await controller.isSchemeRegistered(testSetup.schemeRegistrar.address),false); //check organizationsProposals after execution var organizationProposal = await testSetup.schemeRegistrar.organizationProposals(proposalId); @@ -274,7 +275,7 @@ contract('SchemeRegistrar', accounts => { var controller = await Controller.at(await testSetup.org.avatar.owner()); assert.equal(await controller.isSchemeRegistered(testSetup.schemeRegistrar.address),true); //Vote with reputation to trigger execution - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); assert.equal(await controller.isSchemeRegistered(testSetup.schemeRegistrar.address),false); //check organizationsProposals after execution var organizationProposal = await testSetup.schemeRegistrar.organizationProposals(proposalId); @@ -287,7 +288,7 @@ contract('SchemeRegistrar', accounts => { var tx = await testSetup.schemeRegistrar.proposeScheme(universalScheme.address,"0x00000000",helpers.NULL_HASH); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); }); it("execute proposeScheme and execute -yes - autoRegisterOrganization==FALSE arc scheme", async function() { @@ -297,6 +298,6 @@ contract('SchemeRegistrar', accounts => { var tx = await testSetup.schemeRegistrar.proposeScheme(universalScheme.address,"0x00000000",helpers.NULL_HASH); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - await testSetup.schemeRegistrarParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.schemeRegistrarParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); }); }); diff --git a/test/signalscheme.js b/test/signalscheme.js index ce032766..81fbe57a 100644 --- a/test/signalscheme.js +++ b/test/signalscheme.js @@ -12,37 +12,30 @@ var registration; const setupSignalSchemeParam = async function( accounts, genesisProtocol, - token, - _packageVersion = [0,1,0], - _type = 1234 + token ) { var signalSchemeParams = new SignalSchemeParams(); if (genesisProtocol === true) { signalSchemeParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS); signalSchemeParams.initdata = await new web3.eth.Contract(registration.signalScheme.abi) .methods - .initialize( helpers.NULL_ADDRESS, - signalSchemeParams.votingMachine.uintArray, - signalSchemeParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "GenesisProtocol", - _type - ) + .initialize(helpers.NULL_ADDRESS, + 1234, + helpers.NULL_HASH, + signalSchemeParams.votingMachine.genesisProtocol.address, + signalSchemeParams.votingMachine.uintArray, + signalSchemeParams.votingMachine.voteOnBehalf) .encodeABI(); } else { signalSchemeParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50); signalSchemeParams.initdata = await new web3.eth.Contract(registration.signalScheme.abi) .methods .initialize(helpers.NULL_ADDRESS, - signalSchemeParams.votingMachine.uintArray, - signalSchemeParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - token, - _packageVersion, - "AbsoluteVote", - _type) + 1234, + signalSchemeParams.votingMachine.params, + signalSchemeParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS) .encodeABI(); } return signalSchemeParams; @@ -80,17 +73,18 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress = he [permissions], "metaData"); testSetup.signalScheme = await SignalScheme.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.signalSchemeParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.signalScheme.votingMachine(),genesisProtocol); return testSetup; }; contract('SignalScheme', accounts => { it("proposeSignal log", async function() { var testSetup = await setup(accounts); - assert.equal(await testSetup.signalScheme.avatar(),testSetup.org.avatar.address); - assert.equal(await testSetup.signalScheme.signalType(),1234); - assert.equal(await testSetup.signalScheme.votingMachine(),testSetup.signalSchemeParams.votingMachineInstance.address); + var parameters = await testSetup.signalScheme.params(); + var avatar = await testSetup.signalScheme.avatar(); + assert.equal(avatar,testSetup.org.avatar.address); + assert.equal(parameters.signalType,1234); + assert.equal(parameters.voteApproveParams,testSetup.signalSchemeParams.votingMachine.params); + assert.equal(parameters.intVote,testSetup.signalSchemeParams.votingMachine.absoluteVote.address); var tx = await testSetup.signalScheme.proposeSignal("description-hash"); assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "NewSignalProposal"); @@ -105,7 +99,7 @@ contract('SignalScheme', accounts => { var tx = await testSetup.signalScheme.proposeSignal(web3.utils.asciiToHex("description")); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - tx = await testSetup.signalSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.signalSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.signalScheme.getPastEvents('Signal', { fromBlock: tx.blockNumber, toBlock: 'latest' @@ -126,7 +120,7 @@ contract('SignalScheme', accounts => { var tx = await testSetup.signalScheme.proposeSignal(web3.utils.asciiToHex("description")); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - tx = await testSetup.signalSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.signalSchemeParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.signalScheme.getPastEvents('Signal', { fromBlock: tx.blockNumber, toBlock: 'latest' @@ -147,7 +141,7 @@ contract('SignalScheme', accounts => { var tx = await testSetup.signalScheme.proposeSignal(web3.utils.asciiToHex("description")); //Vote with reputation to trigger execution var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1); - tx = await testSetup.signalSchemeParams.votingMachineInstance.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + tx = await testSetup.signalSchemeParams.votingMachine.absoluteVote.vote(proposalId,2,0,helpers.NULL_ADDRESS,{from:accounts[2]}); await testSetup.signalScheme.getPastEvents('Signal', { fromBlock: tx.blockNumber, toBlock: 'latest' @@ -162,14 +156,12 @@ contract('SignalScheme', accounts => { it("cannot initialize twice", async () => { let testSetup = await setup(accounts); try { - await testSetup.signalScheme.initialize( testSetup.org.avatar.address, - testSetup.signalSchemeParams.votingMachine.uintArray, - testSetup.signalSchemeParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - helpers.NULL_ADDRESS, - [0,1,0], - "AbsoluteVote", - 1234); + await testSetup.signalScheme.initialize(testSetup.org.avatar.address, + 1234, + testSetup.signalSchemeParams.votingMachine.params, + testSetup.signalSchemeParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS); assert(false, "cannot initialize twice"); } catch(error) { helpers.assertVMException(error); diff --git a/test/upgradescheme.js b/test/upgradescheme.js index 0c2e51b6..52112eb1 100644 --- a/test/upgradescheme.js +++ b/test/upgradescheme.js @@ -22,12 +22,10 @@ const setupUpgradeSchemeParams = async function( upgradeSchemeParams.initdata = await new web3.eth.Contract(registration.upgradeScheme.abi) .methods .initialize(helpers.NULL_ADDRESS, + upgradeSchemeParams.votingMachine.genesisProtocol.address, upgradeSchemeParams.votingMachine.uintArray, upgradeSchemeParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, helpers.NULL_ADDRESS, - [0,1,0], - "GenesisProtocol", registration.packageInstance.address) .encodeABI(); } else { @@ -35,12 +33,10 @@ const setupUpgradeSchemeParams = async function( upgradeSchemeParams.initdata = await new web3.eth.Contract(registration.upgradeScheme.abi) .methods .initialize(helpers.NULL_ADDRESS, - upgradeSchemeParams.votingMachine.uintArray, - upgradeSchemeParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, + upgradeSchemeParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], helpers.NULL_ADDRESS, - [0,1,0], - "AbsoluteVote", + upgradeSchemeParams.votingMachine.params, registration.packageInstance.address) .encodeABI(); } @@ -84,8 +80,6 @@ const setup = async function (accounts,reputationAccount=0,genesisProtocol = fal "metaData"); testSetup.registration = registration; testSetup.upgradeScheme = await UpgradeScheme.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.upgradeSchemeParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.upgradeScheme.votingMachine(),genesisProtocol); return testSetup; }; @@ -120,7 +114,7 @@ contract('UpgradeScheme', function(accounts) { helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.upgradeSchemeParams.votingMachineInstance.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.upgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution var organizationProposal = await testSetup.upgradeScheme.organizationProposals(proposalId); assert.equal(organizationProposal,false); @@ -142,7 +136,7 @@ contract('UpgradeScheme', function(accounts) { var organizationProposal = await testSetup.upgradeScheme.organizationProposals(proposalId); assert.equal(organizationProposal,true); - await testSetup.upgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.upgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution organizationProposal = await testSetup.upgradeScheme.organizationProposals(proposalId); assert.equal(organizationProposal,false); @@ -250,7 +244,7 @@ contract('UpgradeScheme', function(accounts) { ); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.upgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.upgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var organizationProposal = await testSetup.upgradeScheme.organizationProposals(proposalId); assert.equal(organizationProposal,false); @@ -310,7 +304,7 @@ contract('UpgradeScheme', function(accounts) { ); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.upgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.upgradeSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var organizationProposal = await testSetup.upgradeScheme.organizationProposals(proposalId); assert.equal(organizationProposal,false); @@ -370,7 +364,7 @@ contract('UpgradeScheme', function(accounts) { ); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.upgradeSchemeParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.upgradeSchemeParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); var organizationProposal = await testSetup.upgradeScheme.organizationProposals(proposalId); assert.equal(organizationProposal,false); @@ -398,12 +392,10 @@ contract('UpgradeScheme', function(accounts) { try { await testSetup.upgradeScheme.initialize( testSetup.org.avatar.address, - testSetup.upgradeSchemeParams.votingMachine.uintArray, - testSetup.upgradeSchemeParams.votingMachine.voteOnBehalf, - testSetup.registration.daoFactory.address, - helpers.NULL_ADDRESS, - [0,1,0], - "AbsoluteVote", + testSetup.upgradeSchemeParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], + helpers.NULL_ADDRESS, + testSetup.upgradeSchemeParams.votingMachine.params, testSetup.registration.packageInstance.address ); assert(false, "cannot init twice"); diff --git a/test/voteinorganization.js b/test/voteinorganization.js index b8a676f2..0f44a658 100644 --- a/test/voteinorganization.js +++ b/test/voteinorganization.js @@ -5,8 +5,6 @@ const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); const AbsoluteVoteExecuteMock = artifacts.require("./AbsoluteVoteExecuteMock.sol"); const GenesisProtocolCallbacksMock = artifacts.require("./GenesisProtocolCallbacksMock.sol"); const Reputation = artifacts.require("./Reputation.sol"); -const AbsoluteVote = artifacts.require("./AbsoluteVote.sol"); -const GenesisProtocol = artifacts.require("./GenesisProtocol.sol"); class VoteInOrganizationParams { constructor() { @@ -20,17 +18,16 @@ const setupVoteInOrganizationParams = async function( tokenAddress = helpers.NULL_ADDRESS ) { var voteInOrganizationParams = new VoteInOrganizationParams(); + voteInOrganizationParams.paramsHash = helpers.NULL_HASH; if (genesisProtocol === true){ voteInOrganizationParams.votingMachine = await helpers.setupGenesisProtocol(accounts,tokenAddress,helpers.NULL_ADDRESS); voteInOrganizationParams.initdata = await new web3.eth.Contract(registration.voteInOrganization.abi) .methods .initialize(helpers.NULL_ADDRESS, + voteInOrganizationParams.votingMachine.genesisProtocol.address, voteInOrganizationParams.votingMachine.uintArray, voteInOrganizationParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, - tokenAddress, - [0,1,0], - "GenesisProtocol") + helpers.NULL_HASH) .encodeABI(); } else { @@ -38,12 +35,10 @@ const setupVoteInOrganizationParams = async function( voteInOrganizationParams.initdata = await new web3.eth.Contract(registration.voteInOrganization.abi) .methods .initialize(helpers.NULL_ADDRESS, - voteInOrganizationParams.votingMachine.uintArray, - voteInOrganizationParams.votingMachine.voteOnBehalf, - registration.daoFactory.address, + voteInOrganizationParams.votingMachine.absoluteVote.address, + [0,0,0,0,0,0,0,0,0,0,0], helpers.NULL_ADDRESS, - [0,1,0], - "AbsoluteVote") + voteInOrganizationParams.votingMachine.params) .encodeABI(); } @@ -80,10 +75,8 @@ const setup = async function (accounts,reputationAccount=helpers.NULL_ADDRESS,ge "metaData"); testSetup.voteInOrganization = await VoteInOrganization.at(await helpers.getSchemeAddress(registration.daoFactory.address,tx)); - testSetup.voteInOrganizationParams.votingMachineInstance = - await helpers.getVotingMachine(await testSetup.voteInOrganization.votingMachine(),genesisProtocol); - return testSetup; + return testSetup; }; contract('VoteInOrganizationScheme', accounts => { @@ -94,24 +87,19 @@ contract('VoteInOrganizationScheme', accounts => { it("proposeVote log", async function() { var testSetup = await setup(accounts); - await setup(accounts); - + var anotherTestSetup = await setup(accounts); var absoluteVoteExecuteMock = await AbsoluteVoteExecuteMock.new(); - var absoluteVote = await AbsoluteVote.new(); - await absoluteVote.initialize(50, - helpers.NULL_ADDRESS, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address); - await absoluteVoteExecuteMock.initialize(testSetup.org.reputation.address, - absoluteVote.address); + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address); - var tx = await absoluteVoteExecuteMock.propose(2,helpers.NULL_ADDRESS); + var tx = await absoluteVoteExecuteMock.propose(2, + anotherTestSetup.voteInOrganizationParams.votingMachine.params, + anotherTestSetup.org.avatar.address, + accounts[0],helpers.NULL_ADDRESS); - const proposalId = await helpers.getProposalId(tx,absoluteVote, 'NewProposal'); + const proposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); tx = await testSetup.voteInOrganization.proposeVote( - absoluteVote.address, + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, proposalId,1,helpers.NULL_HASH); assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "NewVoteProposal"); @@ -121,24 +109,20 @@ contract('VoteInOrganizationScheme', accounts => { it("proposeVote vote not an option", async function() { var testSetup = await setup(accounts); - await setup(accounts); + var anotherTestSetup = await setup(accounts); var absoluteVoteExecuteMock = await AbsoluteVoteExecuteMock.new(); - var absoluteVote = await AbsoluteVote.new(); - await absoluteVote.initialize(50, - helpers.NULL_ADDRESS, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address); await absoluteVoteExecuteMock.initialize(testSetup.org.reputation.address, - absoluteVote.address); + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address); var tx = await absoluteVoteExecuteMock.propose(2, - helpers.NULL_ADDRESS); + anotherTestSetup.voteInOrganizationParams.votingMachine.params, + anotherTestSetup.org.avatar.address, + accounts[0],helpers.NULL_ADDRESS); - const proposalId = await helpers.getProposalId(tx,absoluteVote, 'NewProposal'); + const proposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); try { await testSetup.voteInOrganization.proposeVote( - absoluteVote.address, + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, proposalId,3,helpers.NULL_HASH ); assert(false, "vote not an option"); @@ -157,23 +141,19 @@ contract('VoteInOrganizationScheme', accounts => { await reputation.mint(testSetup.org.avatar.address,100); var genesisProtocolCallbacksMock = await GenesisProtocolCallbacksMock.new(); - var genesisProtocol = await GenesisProtocol.new(); - await genesisProtocol.initialize(standardTokenMock.address, - anotherTestSetup.voteInOrganizationParams.votingMachine.uintArray, - anotherTestSetup.voteInOrganizationParams.votingMachine.voteOnBehalf, - genesisProtocolCallbacksMock.address, - genesisProtocolCallbacksMock.address, - genesisProtocolCallbacksMock.address); await genesisProtocolCallbacksMock.initialize(reputation.address, standardTokenMock.address, - genesisProtocol.address); + anotherTestSetup.voteInOrganizationParams.votingMachine.genesisProtocol.address); await reputation.transferOwnership(genesisProtocolCallbacksMock.address); var tx = await genesisProtocolCallbacksMock.propose(2, - helpers.NULL_ADDRESS); + anotherTestSetup.voteInOrganizationParams.votingMachine.params, + anotherTestSetup.org.avatar.address, + accounts[0], + helpers.NULL_ADDRESS); var originalProposalId = await helpers.getValueFromLogs(tx, '_proposalId'); try { await testSetup.voteInOrganization.proposeVote( - genesisProtocol.address, + anotherTestSetup.voteInOrganizationParams.votingMachine.genesisProtocol.address, originalProposalId,3,helpers.NULL_HASH ); assert(false, "vote out of range (too high)"); @@ -183,7 +163,7 @@ contract('VoteInOrganizationScheme', accounts => { try { await testSetup.voteInOrganization.proposeVote( - genesisProtocol.address, + anotherTestSetup.voteInOrganizationParams.votingMachine.genesisProtocol.address, originalProposalId,0,helpers.NULL_HASH ); assert(false, "vote out of range (too low)"); @@ -191,28 +171,26 @@ contract('VoteInOrganizationScheme', accounts => { helpers.assertVMException(error); } }); - + it("execute proposeVote -no decision - proposal data delete", async function() { var testSetup = await setup(accounts); - await setup(accounts); + var anotherTestSetup = await setup(accounts); var absoluteVoteExecuteMock = await AbsoluteVoteExecuteMock.new(); - var absoluteVote = await AbsoluteVote.new(); - await absoluteVote.initialize(50, - helpers.NULL_ADDRESS, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address); await absoluteVoteExecuteMock.initialize(testSetup.org.reputation.address, - absoluteVote.address); - var tx = await absoluteVoteExecuteMock.propose(2,helpers.NULL_ADDRESS); - const originalProposalId = await helpers.getProposalId(tx,absoluteVote, 'NewProposal'); + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address); + var tx = await absoluteVoteExecuteMock.propose(2, + anotherTestSetup.voteInOrganizationParams.votingMachine.params, + anotherTestSetup.org.avatar.address, + accounts[0], + helpers.NULL_ADDRESS); + const originalProposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); tx = await testSetup.voteInOrganization.proposeVote( - absoluteVote.address, + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, originalProposalId,1,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.voteInOrganizationParams.votingMachineInstance.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await testSetup.voteInOrganizationParams.votingMachine.absoluteVote.vote(proposalId,0,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution var organizationProposal = await testSetup.voteInOrganization.organizationProposals(proposalId); assert.equal(organizationProposal[0],0x0000000000000000000000000000000000000000);//new contract address @@ -224,24 +202,22 @@ contract('VoteInOrganizationScheme', accounts => { var anotherTestSetup = await setup(accounts,testSetup.org.avatar.address); //mint reputation to avatar in the other dao. var absoluteVoteExecuteMock = await AbsoluteVoteExecuteMock.new(); - var absoluteVote = await AbsoluteVote.new(); - await absoluteVote.initialize(50, - helpers.NULL_ADDRESS, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address); await absoluteVoteExecuteMock.initialize(anotherTestSetup.org.reputation.address, - absoluteVote.address); - var tx = await absoluteVoteExecuteMock.propose(2,helpers.NULL_ADDRESS); - const originalProposalId = await helpers.getProposalId(tx,absoluteVote, 'NewProposal'); + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address); + var tx = await absoluteVoteExecuteMock.propose(2, + anotherTestSetup.voteInOrganizationParams.votingMachine.params, + anotherTestSetup.org.avatar.address, + accounts[0], + helpers.NULL_ADDRESS); + const originalProposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); tx = await testSetup.voteInOrganization.proposeVote( - absoluteVote.address, + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, originalProposalId,1,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); var organizationProposal = await testSetup.voteInOrganization.organizationProposals(proposalId); - assert.equal(organizationProposal[0],absoluteVote.address);//new contract address - await testSetup.voteInOrganizationParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + assert.equal(organizationProposal[0],anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address);//new contract address + await testSetup.voteInOrganizationParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); //check organizationsProposals after execution organizationProposal = await testSetup.voteInOrganization.organizationProposals(proposalId); assert.equal(organizationProposal[0],0x0000000000000000000000000000000000000000);//new contract address @@ -252,23 +228,21 @@ contract('VoteInOrganizationScheme', accounts => { var anotherTestSetup = await setup(accounts,testSetup.org.avatar.address); var absoluteVoteExecuteMock = await AbsoluteVoteExecuteMock.new(); - var absoluteVote = await AbsoluteVote.new(); - await absoluteVote.initialize(50, - helpers.NULL_ADDRESS, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address, - absoluteVoteExecuteMock.address); await absoluteVoteExecuteMock.initialize(anotherTestSetup.org.reputation.address, - absoluteVote.address); - var tx = await absoluteVoteExecuteMock.propose(2,helpers.NULL_ADDRESS); - - const originalProposalId = await helpers.getProposalId(tx,absoluteVote, 'NewProposal'); + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address); + var tx = await absoluteVoteExecuteMock.propose(2, + anotherTestSetup.voteInOrganizationParams.votingMachine.params, + anotherTestSetup.org.avatar.address, + accounts[0], + helpers.NULL_ADDRESS); + + const originalProposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); tx = await testSetup.voteInOrganization.proposeVote( - absoluteVote.address, + anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, originalProposalId,1,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.voteInOrganizationParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); - await helpers.checkVoteInfo(absoluteVote,originalProposalId, testSetup.org.avatar.address, [1, anotherTestSetup.reputationArray[2]]); + await testSetup.voteInOrganizationParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await helpers.checkVoteInfo(anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote,originalProposalId, testSetup.org.avatar.address, [1, anotherTestSetup.reputationArray[2]]); }); it("execute proposeVote -positive decision - check action - with GenesisProtocol", async function() { @@ -281,24 +255,21 @@ contract('VoteInOrganizationScheme', accounts => { await reputation.mint(testSetup.org.avatar.address,100); var genesisProtocolCallbacksMock = await GenesisProtocolCallbacksMock.new(); - var genesisProtocol = await GenesisProtocol.new(); - await genesisProtocol.initialize(standardTokenMock.address, - anotherTestSetup.voteInOrganizationParams.votingMachine.uintArray, - anotherTestSetup.voteInOrganizationParams.votingMachine.voteOnBehalf, - genesisProtocolCallbacksMock.address, - genesisProtocolCallbacksMock.address, - genesisProtocolCallbacksMock.address); await genesisProtocolCallbacksMock.initialize(reputation.address, standardTokenMock.address, - genesisProtocol.address); + anotherTestSetup.voteInOrganizationParams.votingMachine.genesisProtocol.address); await reputation.transferOwnership(genesisProtocolCallbacksMock.address); - var tx = await genesisProtocolCallbacksMock.propose(2,helpers.NULL_ADDRESS); + var tx = await genesisProtocolCallbacksMock.propose(2, + anotherTestSetup.voteInOrganizationParams.votingMachine.params, + anotherTestSetup.org.avatar.address, + accounts[0], + helpers.NULL_ADDRESS); var originalProposalId = await helpers.getValueFromLogs(tx, '_proposalId'); tx = await testSetup.voteInOrganization.proposeVote( - genesisProtocol.address, + anotherTestSetup.voteInOrganizationParams.votingMachine.genesisProtocol.address, originalProposalId,1,helpers.NULL_HASH); var proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); - await testSetup.voteInOrganizationParams.votingMachineInstance.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); - await helpers.checkVoteInfo(genesisProtocol,originalProposalId, testSetup.org.avatar.address, [1, 100]); + await testSetup.voteInOrganizationParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]}); + await helpers.checkVoteInfo(anotherTestSetup.voteInOrganizationParams.votingMachine.genesisProtocol,originalProposalId, testSetup.org.avatar.address, [1, 100]); }); });