From a347f8ed6c4d3b537bd05ee27989c3f4a5d6f4bc Mon Sep 17 00:00:00 2001 From: orenyodfat Date: Tue, 9 Oct 2018 13:49:13 +0300 Subject: [PATCH] Use infra 08 (#552) * use infra 07 * fix genericshcme test * solc v 0.4.25 * add return at balanceOfStakingToken --- contracts/Migrations.sol | 2 +- ...llbacks.sol => VotingMachineCallbacks.sol} | 8 +- contracts/controller/Avatar.sol | 2 +- contracts/controller/Controller.sol | 2 +- contracts/controller/ControllerInterface.sol | 2 +- contracts/controller/DAOToken.sol | 2 +- contracts/controller/UController.sol | 2 +- .../GlobalConstraintInterface.sol | 2 +- contracts/globalConstraints/TokenCapGC.sol | 2 +- contracts/libs/RealMath.sol | 2 +- contracts/schemes/Auction4Reputation.sol | 2 +- .../schemes/ExternalLocking4Reputation.sol | 2 +- contracts/schemes/FixReputationAllocation.sol | 2 +- contracts/schemes/Locking4Reputation.sol | 2 +- contracts/schemes/LockingEth4Reputation.sol | 2 +- contracts/schemes/LockingToken4Reputation.sol | 2 +- contracts/test/ARCDebug.sol | 2 +- .../test/ARCGenesisProtocolCallbacksMock.sol | 6 +- contracts/test/ActionMock.sol | 2 +- contracts/test/ExternalTokenLockerMock.sol | 2 +- contracts/test/GlobalConstraintMock.sol | 2 +- contracts/test/StandardTokenMock.sol | 2 +- contracts/test/UniversalSchemeMock.sol | 2 +- contracts/token/ERC827/ERC827.sol | 2 +- contracts/token/ERC827/ERC827Token.sol | 2 +- .../universalSchemes/ContributionReward.sol | 11 +-- contracts/universalSchemes/DaoCreator.sol | 2 +- contracts/universalSchemes/GenericScheme.sol | 10 +-- .../GlobalConstraintRegistrar.sol | 12 +-- .../universalSchemes/OrganizationRegister.sol | 2 +- .../universalSchemes/SchemeRegistrar.sol | 13 ++-- contracts/universalSchemes/SimpleICO.sol | 2 +- .../universalSchemes/UniversalScheme.sol | 2 +- .../UniversalSchemeInterface.sol | 2 +- contracts/universalSchemes/UpgradeScheme.sol | 12 +-- contracts/universalSchemes/VestingScheme.sol | 10 +-- .../VoteInOrganizationScheme.sol | 10 +-- contracts/utils/Redeemer.sol | 2 +- package-lock.json | 75 +++++++++++++++++-- package.json | 4 +- test/contributionreward.js | 4 +- test/genericscheme.js | 7 +- test/globalconstraintregistrar.js | 4 +- test/helpers.js | 14 +++- test/schemeregistrar.js | 2 +- test/upgradescheme.js | 2 +- test/vestingscheme.js | 2 +- test/voteinorganization.js | 36 +++++---- ...callbacks.js => votingmachinecallbacks.js} | 31 ++++---- truffle.js | 2 +- 50 files changed, 210 insertions(+), 123 deletions(-) rename contracts/VotingMachines/{GenesisProtocolCallbacks.sol => VotingMachineCallbacks.sol} (88%) rename test/{genesisprotocolcallbacks.js => votingmachinecallbacks.js} (69%) diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol index 322fe4e7..43a77f1e 100644 --- a/contracts/Migrations.sol +++ b/contracts/Migrations.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; contract Migrations { diff --git a/contracts/VotingMachines/GenesisProtocolCallbacks.sol b/contracts/VotingMachines/VotingMachineCallbacks.sol similarity index 88% rename from contracts/VotingMachines/GenesisProtocolCallbacks.sol rename to contracts/VotingMachines/VotingMachineCallbacks.sol index d9db3881..55d20156 100644 --- a/contracts/VotingMachines/GenesisProtocolCallbacks.sol +++ b/contracts/VotingMachines/VotingMachineCallbacks.sol @@ -1,10 +1,10 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "../universalSchemes/UniversalScheme.sol"; import "@daostack/infra/contracts/VotingMachines/GenesisProtocol.sol"; -contract GenesisProtocolCallbacks is GenesisProtocolCallbacksInterface { +contract VotingMachineCallbacks is VotingMachineCallbacksInterface { struct ProposalInfo { uint blockNumber; // the proposal's block number @@ -67,4 +67,8 @@ contract GenesisProtocolCallbacks is GenesisProtocolCallbacksInterface { return ControllerInterface(avatar.owner()).externalTokenTransfer(_stakingToken,_beneficiary,_amount,address(avatar)); } + function balanceOfStakingToken(StandardToken _stakingToken,bytes32 _proposalId) external view returns(uint) { + Avatar avatar = proposalsInfo[_proposalId].avatar; + return _stakingToken.balanceOf(address(avatar)); + } } diff --git a/contracts/controller/Avatar.sol b/contracts/controller/Avatar.sol index c24eaaf2..f55e3f52 100644 --- a/contracts/controller/Avatar.sol +++ b/contracts/controller/Avatar.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/Reputation.sol"; import "./DAOToken.sol"; diff --git a/contracts/controller/Controller.sol b/contracts/controller/Controller.sol index 8a2fd68d..890e1dd9 100644 --- a/contracts/controller/Controller.sol +++ b/contracts/controller/Controller.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./Avatar.sol"; import "../globalConstraints/GlobalConstraintInterface.sol"; diff --git a/contracts/controller/ControllerInterface.sol b/contracts/controller/ControllerInterface.sol index ba8962f0..3c534e10 100644 --- a/contracts/controller/ControllerInterface.sol +++ b/contracts/controller/ControllerInterface.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./Avatar.sol"; import "../globalConstraints/GlobalConstraintInterface.sol"; diff --git a/contracts/controller/DAOToken.sol b/contracts/controller/DAOToken.sol index 073cc02f..ef04ff06 100644 --- a/contracts/controller/DAOToken.sol +++ b/contracts/controller/DAOToken.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol"; import "openzeppelin-solidity/contracts/token/ERC20/BurnableToken.sol"; diff --git a/contracts/controller/UController.sol b/contracts/controller/UController.sol index 92db4af0..e86839b6 100644 --- a/contracts/controller/UController.sol +++ b/contracts/controller/UController.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./Avatar.sol"; import "../globalConstraints/GlobalConstraintInterface.sol"; diff --git a/contracts/globalConstraints/GlobalConstraintInterface.sol b/contracts/globalConstraints/GlobalConstraintInterface.sol index b592b745..5984e8f1 100644 --- a/contracts/globalConstraints/GlobalConstraintInterface.sol +++ b/contracts/globalConstraints/GlobalConstraintInterface.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; contract GlobalConstraintInterface { diff --git a/contracts/globalConstraints/TokenCapGC.sol b/contracts/globalConstraints/TokenCapGC.sol index 363375f7..08d7a943 100644 --- a/contracts/globalConstraints/TokenCapGC.sol +++ b/contracts/globalConstraints/TokenCapGC.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol"; import "./GlobalConstraintInterface.sol"; diff --git a/contracts/libs/RealMath.sol b/contracts/libs/RealMath.sol index 692a7a76..efea9d51 100644 --- a/contracts/libs/RealMath.sol +++ b/contracts/libs/RealMath.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; /** * RealMath: fixed-point math library, based on fractional and integer parts. diff --git a/contracts/schemes/Auction4Reputation.sol b/contracts/schemes/Auction4Reputation.sol index f6a92e6d..49ec6d05 100644 --- a/contracts/schemes/Auction4Reputation.sol +++ b/contracts/schemes/Auction4Reputation.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import { RealMath } from "../libs/RealMath.sol"; diff --git a/contracts/schemes/ExternalLocking4Reputation.sol b/contracts/schemes/ExternalLocking4Reputation.sol index 5693f15a..c3a47a99 100644 --- a/contracts/schemes/ExternalLocking4Reputation.sol +++ b/contracts/schemes/ExternalLocking4Reputation.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./Locking4Reputation.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; diff --git a/contracts/schemes/FixReputationAllocation.sol b/contracts/schemes/FixReputationAllocation.sol index dfd8a10e..15b7167c 100644 --- a/contracts/schemes/FixReputationAllocation.sol +++ b/contracts/schemes/FixReputationAllocation.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "../controller/ControllerInterface.sol"; import { RealMath } from "../libs/RealMath.sol"; diff --git a/contracts/schemes/Locking4Reputation.sol b/contracts/schemes/Locking4Reputation.sol index 908d3b1f..3323164c 100644 --- a/contracts/schemes/Locking4Reputation.sol +++ b/contracts/schemes/Locking4Reputation.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "../controller/ControllerInterface.sol"; import { RealMath } from "../libs/RealMath.sol"; diff --git a/contracts/schemes/LockingEth4Reputation.sol b/contracts/schemes/LockingEth4Reputation.sol index 0b180d69..2ae109ae 100644 --- a/contracts/schemes/LockingEth4Reputation.sol +++ b/contracts/schemes/LockingEth4Reputation.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./Locking4Reputation.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; diff --git a/contracts/schemes/LockingToken4Reputation.sol b/contracts/schemes/LockingToken4Reputation.sol index f128fa6e..45558055 100644 --- a/contracts/schemes/LockingToken4Reputation.sol +++ b/contracts/schemes/LockingToken4Reputation.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./Locking4Reputation.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; diff --git a/contracts/test/ARCDebug.sol b/contracts/test/ARCDebug.sol index 63c02345..714433f9 100644 --- a/contracts/test/ARCDebug.sol +++ b/contracts/test/ARCDebug.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/VotingMachines/GenesisProtocol.sol"; import "@daostack/infra/contracts/VotingMachines/AbsoluteVote.sol"; diff --git a/contracts/test/ARCGenesisProtocolCallbacksMock.sol b/contracts/test/ARCGenesisProtocolCallbacksMock.sol index 30c6cb8e..c0d5b96d 100644 --- a/contracts/test/ARCGenesisProtocolCallbacksMock.sol +++ b/contracts/test/ARCGenesisProtocolCallbacksMock.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; -import "../VotingMachines/GenesisProtocolCallbacks.sol"; +import "../VotingMachines/VotingMachineCallbacks.sol"; -contract ARCGenesisProtocolCallbacksMock is GenesisProtocolCallbacks { +contract ARCVotingMachineCallbacksMock is VotingMachineCallbacks { function propose(bytes32 _proposalId,Avatar _avatar,address _votingMachine) public { proposalsInfo[_proposalId] = ProposalInfo( diff --git a/contracts/test/ActionMock.sol b/contracts/test/ActionMock.sol index 66ba6d50..ae353b11 100644 --- a/contracts/test/ActionMock.sol +++ b/contracts/test/ActionMock.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "../controller/Avatar.sol"; diff --git a/contracts/test/ExternalTokenLockerMock.sol b/contracts/test/ExternalTokenLockerMock.sol index df363b6e..d417e918 100644 --- a/contracts/test/ExternalTokenLockerMock.sol +++ b/contracts/test/ExternalTokenLockerMock.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; contract ExternalTokenLockerMock { diff --git a/contracts/test/GlobalConstraintMock.sol b/contracts/test/GlobalConstraintMock.sol index d275d89c..b6665d3d 100644 --- a/contracts/test/GlobalConstraintMock.sol +++ b/contracts/test/GlobalConstraintMock.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "../globalConstraints/GlobalConstraintInterface.sol"; diff --git a/contracts/test/StandardTokenMock.sol b/contracts/test/StandardTokenMock.sol index 0b7d3f9e..e632b09a 100644 --- a/contracts/test/StandardTokenMock.sol +++ b/contracts/test/StandardTokenMock.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol"; diff --git a/contracts/test/UniversalSchemeMock.sol b/contracts/test/UniversalSchemeMock.sol index 962ded98..770c5143 100644 --- a/contracts/test/UniversalSchemeMock.sol +++ b/contracts/test/UniversalSchemeMock.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "../universalSchemes/UniversalScheme.sol"; import "../controller/ControllerInterface.sol"; diff --git a/contracts/token/ERC827/ERC827.sol b/contracts/token/ERC827/ERC827.sol index 97aef58a..773a1958 100644 --- a/contracts/token/ERC827/ERC827.sol +++ b/contracts/token/ERC827/ERC827.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; diff --git a/contracts/token/ERC827/ERC827Token.sol b/contracts/token/ERC827/ERC827Token.sol index 37fee306..af9bc1c3 100644 --- a/contracts/token/ERC827/ERC827Token.sol +++ b/contracts/token/ERC827/ERC827Token.sol @@ -1,6 +1,6 @@ /* solium-disable security/no-low-level-calls */ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./ERC827.sol"; import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol"; diff --git a/contracts/universalSchemes/ContributionReward.sol b/contracts/universalSchemes/ContributionReward.sol index 6cca9f2b..0d91db49 100644 --- a/contracts/universalSchemes/ContributionReward.sol +++ b/contracts/universalSchemes/ContributionReward.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol"; -import "@daostack/infra/contracts/VotingMachines/GenesisProtocolCallbacksInterface.sol"; +import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol"; import "./UniversalScheme.sol"; -import "../VotingMachines/GenesisProtocolCallbacks.sol"; +import "../VotingMachines/VotingMachineCallbacks.sol"; /** @@ -12,7 +12,7 @@ import "../VotingMachines/GenesisProtocolCallbacks.sol"; * him with token, reputation, ether or any combination. */ -contract ContributionReward is UniversalScheme,GenesisProtocolCallbacks,GenesisProtocolExecuteInterface { +contract ContributionReward is UniversalScheme,VotingMachineCallbacks,ProposalExecuteInterface { using SafeMath for uint; event NewContributionProposal( @@ -148,7 +148,8 @@ contract ContributionReward is UniversalScheme,GenesisProtocolCallbacks,GenesisP bytes32 contributionId = controllerParams.intVote.propose( 2, controllerParams.voteApproveParams, - msg.sender + msg.sender, + _avatar ); // Check beneficiary is not null: diff --git a/contracts/universalSchemes/DaoCreator.sol b/contracts/universalSchemes/DaoCreator.sol index abd9f1f7..1a3fcb5f 100644 --- a/contracts/universalSchemes/DaoCreator.sol +++ b/contracts/universalSchemes/DaoCreator.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./UniversalScheme.sol"; import "../controller/UController.sol"; diff --git a/contracts/universalSchemes/GenericScheme.sol b/contracts/universalSchemes/GenericScheme.sol index f26ca8a2..8c40bef3 100644 --- a/contracts/universalSchemes/GenericScheme.sol +++ b/contracts/universalSchemes/GenericScheme.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol"; -import "@daostack/infra/contracts/VotingMachines/GenesisProtocolCallbacksInterface.sol"; +import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol"; import "./UniversalScheme.sol"; -import "../VotingMachines/GenesisProtocolCallbacks.sol"; +import "../VotingMachines/VotingMachineCallbacks.sol"; /** @@ -11,7 +11,7 @@ import "../VotingMachines/GenesisProtocolCallbacks.sol"; * @dev A scheme for proposing and executing calls to an arbitrary function * on a specific contract on behalf of the organization avatar. */ -contract GenericScheme is UniversalScheme,GenesisProtocolCallbacks,GenesisProtocolExecuteInterface { +contract GenericScheme is UniversalScheme,VotingMachineCallbacks,ProposalExecuteInterface { event NewCallProposal( address indexed _avatar, bytes32 indexed _proposalId, @@ -116,7 +116,7 @@ contract GenericScheme is UniversalScheme,GenesisProtocolCallbacks,GenesisProtoc Parameters memory params = parameters[getParametersFromController(_avatar)]; IntVoteInterface intVote = params.intVote; - bytes32 proposalId = intVote.propose(2, params.voteParams,msg.sender); + bytes32 proposalId = intVote.propose(2, params.voteParams,msg.sender,_avatar); organizationsProposals[_avatar][proposalId] = CallProposal({ callData: _callData, diff --git a/contracts/universalSchemes/GlobalConstraintRegistrar.sol b/contracts/universalSchemes/GlobalConstraintRegistrar.sol index a6e33c29..41013e7a 100644 --- a/contracts/universalSchemes/GlobalConstraintRegistrar.sol +++ b/contracts/universalSchemes/GlobalConstraintRegistrar.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol"; -import "@daostack/infra/contracts/VotingMachines/GenesisProtocolCallbacksInterface.sol"; +import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol"; import "./UniversalScheme.sol"; -import "../VotingMachines/GenesisProtocolCallbacks.sol"; +import "../VotingMachines/VotingMachineCallbacks.sol"; @@ -11,7 +11,7 @@ import "../VotingMachines/GenesisProtocolCallbacks.sol"; * @title A scheme to manage global constraint for organizations * @dev The scheme is used to register or remove new global constraints */ -contract GlobalConstraintRegistrar is UniversalScheme,GenesisProtocolCallbacks,GenesisProtocolExecuteInterface { +contract GlobalConstraintRegistrar is UniversalScheme,VotingMachineCallbacks,ProposalExecuteInterface { event NewGlobalConstraintsProposal( address indexed _avatar, bytes32 indexed _proposalId, @@ -132,7 +132,7 @@ contract GlobalConstraintRegistrar is UniversalScheme,GenesisProtocolCallbacks,G Parameters memory votingParams = parameters[getParametersFromController(_avatar)]; IntVoteInterface intVote = votingParams.intVote; - bytes32 proposalId = intVote.propose(2, votingParams.voteRegisterParams,msg.sender); + bytes32 proposalId = intVote.propose(2, votingParams.voteRegisterParams,msg.sender,_avatar); GCProposal memory proposal = GCProposal({ gc: _gc, @@ -169,7 +169,7 @@ contract GlobalConstraintRegistrar is UniversalScheme,GenesisProtocolCallbacks,G require(controller.isGlobalConstraintRegistered(_gc,address(_avatar))); Parameters memory params = parameters[getParametersFromController(_avatar)]; IntVoteInterface intVote = params.intVote; - bytes32 proposalId = intVote.propose(2, voteToRemoveParams[_avatar][_gc],msg.sender); + bytes32 proposalId = intVote.propose(2, voteToRemoveParams[_avatar][_gc],msg.sender,_avatar); GCProposal memory proposal = GCProposal({ gc: _gc, diff --git a/contracts/universalSchemes/OrganizationRegister.sol b/contracts/universalSchemes/OrganizationRegister.sol index bd20823d..4b1d8404 100644 --- a/contracts/universalSchemes/OrganizationRegister.sol +++ b/contracts/universalSchemes/OrganizationRegister.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./UniversalScheme.sol"; diff --git a/contracts/universalSchemes/SchemeRegistrar.sol b/contracts/universalSchemes/SchemeRegistrar.sol index 997a4fe7..4146ed95 100644 --- a/contracts/universalSchemes/SchemeRegistrar.sol +++ b/contracts/universalSchemes/SchemeRegistrar.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol"; -import "@daostack/infra/contracts/VotingMachines/GenesisProtocolCallbacksInterface.sol"; +import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol"; import "./UniversalScheme.sol"; -import "../VotingMachines/GenesisProtocolCallbacks.sol"; +import "../VotingMachines/VotingMachineCallbacks.sol"; /** @@ -11,7 +11,7 @@ import "../VotingMachines/GenesisProtocolCallbacks.sol"; * @dev The SchemeRegistrar is used for registering and unregistering schemes at organizations */ -contract SchemeRegistrar is UniversalScheme,GenesisProtocolCallbacks,GenesisProtocolExecuteInterface { +contract SchemeRegistrar is UniversalScheme,VotingMachineCallbacks,ProposalExecuteInterface { event NewSchemeProposal( address indexed _avatar, bytes32 indexed _proposalId, @@ -126,7 +126,8 @@ contract SchemeRegistrar is UniversalScheme,GenesisProtocolCallbacks,GenesisProt bytes32 proposalId = controllerParams.intVote.propose( 2, controllerParams.voteRegisterParams, - msg.sender + msg.sender, + _avatar ); SchemeProposal memory proposal = SchemeProposal({ @@ -168,7 +169,7 @@ contract SchemeRegistrar is UniversalScheme,GenesisProtocolCallbacks,GenesisProt Parameters memory params = parameters[paramsHash]; IntVoteInterface intVote = params.intVote; - bytes32 proposalId = intVote.propose(2, params.voteRemoveParams,msg.sender); + bytes32 proposalId = intVote.propose(2, params.voteRemoveParams,msg.sender,_avatar); organizationsProposals[_avatar][proposalId].proposalType = 2; organizationsProposals[_avatar][proposalId].scheme = _scheme; diff --git a/contracts/universalSchemes/SimpleICO.sol b/contracts/universalSchemes/SimpleICO.sol index a666e41c..399eb16d 100644 --- a/contracts/universalSchemes/SimpleICO.sol +++ b/contracts/universalSchemes/SimpleICO.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./UniversalScheme.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; diff --git a/contracts/universalSchemes/UniversalScheme.sol b/contracts/universalSchemes/UniversalScheme.sol index 7759f355..5772b809 100644 --- a/contracts/universalSchemes/UniversalScheme.sol +++ b/contracts/universalSchemes/UniversalScheme.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "./UniversalSchemeInterface.sol"; import "../controller/ControllerInterface.sol"; diff --git a/contracts/universalSchemes/UniversalSchemeInterface.sol b/contracts/universalSchemes/UniversalSchemeInterface.sol index 56640e0a..82abb2f9 100644 --- a/contracts/universalSchemes/UniversalSchemeInterface.sol +++ b/contracts/universalSchemes/UniversalSchemeInterface.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "../controller/Controller.sol"; import "../controller/Avatar.sol"; diff --git a/contracts/universalSchemes/UpgradeScheme.sol b/contracts/universalSchemes/UpgradeScheme.sol index 9fb666e9..3314673b 100644 --- a/contracts/universalSchemes/UpgradeScheme.sol +++ b/contracts/universalSchemes/UpgradeScheme.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol"; -import "@daostack/infra/contracts/VotingMachines/GenesisProtocolExecuteInterface.sol"; +import "@daostack/infra/contracts/VotingMachines/ProposalExecuteInterface.sol"; import "./UniversalScheme.sol"; -import "../VotingMachines/GenesisProtocolCallbacks.sol"; +import "../VotingMachines/VotingMachineCallbacks.sol"; /** @@ -11,7 +11,7 @@ import "../VotingMachines/GenesisProtocolCallbacks.sol"; * @dev The scheme is used to upgrade the controller of an organization to a new controller. */ -contract UpgradeScheme is UniversalScheme,GenesisProtocolCallbacks,GenesisProtocolExecuteInterface { +contract UpgradeScheme is UniversalScheme,VotingMachineCallbacks,ProposalExecuteInterface { event NewUpgradeProposal( address indexed _avatar, bytes32 indexed _proposalId, @@ -117,7 +117,7 @@ contract UpgradeScheme is UniversalScheme,GenesisProtocolCallbacks,GenesisProtoc returns(bytes32) { Parameters memory params = parameters[getParametersFromController(_avatar)]; - bytes32 proposalId = params.intVote.propose(2, params.voteParams,msg.sender); + bytes32 proposalId = params.intVote.propose(2, params.voteParams,msg.sender,_avatar); UpgradeProposal memory proposal = UpgradeProposal({ proposalType: 1, upgradeContract: _newController, @@ -150,7 +150,7 @@ contract UpgradeScheme is UniversalScheme,GenesisProtocolCallbacks,GenesisProtoc { Parameters memory params = parameters[getParametersFromController(_avatar)]; IntVoteInterface intVote = params.intVote; - bytes32 proposalId = intVote.propose(2, params.voteParams,msg.sender); + bytes32 proposalId = intVote.propose(2, params.voteParams,msg.sender,_avatar); require(organizationsProposals[_avatar][proposalId].proposalType == 0); UpgradeProposal memory proposal = UpgradeProposal({ diff --git a/contracts/universalSchemes/VestingScheme.sol b/contracts/universalSchemes/VestingScheme.sol index 039a3a77..13d1eff8 100644 --- a/contracts/universalSchemes/VestingScheme.sol +++ b/contracts/universalSchemes/VestingScheme.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol"; -import "@daostack/infra/contracts/VotingMachines/GenesisProtocolCallbacksInterface.sol"; +import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol"; import "./UniversalScheme.sol"; -import "../VotingMachines/GenesisProtocolCallbacks.sol"; +import "../VotingMachines/VotingMachineCallbacks.sol"; /** @@ -11,7 +11,7 @@ import "../VotingMachines/GenesisProtocolCallbacks.sol"; * @dev Can be used without organization just as a vesting component. */ -contract VestingScheme is UniversalScheme,GenesisProtocolCallbacks,GenesisProtocolExecuteInterface { +contract VestingScheme is UniversalScheme,VotingMachineCallbacks,ProposalExecuteInterface { using SafeMath for uint; event ProposalExecuted(address indexed _avatar, bytes32 indexed _proposalId,int _param); @@ -130,7 +130,7 @@ contract VestingScheme is UniversalScheme,GenesisProtocolCallbacks,GenesisProtoc { // Open voting: Parameters memory params = parameters[getParametersFromController(_avatar)]; - bytes32 proposalId = params.intVote.propose(2, params.voteParams,msg.sender); + bytes32 proposalId = params.intVote.propose(2, params.voteParams,msg.sender,_avatar); require(_signaturesReqToCancel <= _signersArray.length); require(_periodLength > 0); require(_numOfAgreedPeriods > 0, "Number of Agreed Periods must be greater than 0"); diff --git a/contracts/universalSchemes/VoteInOrganizationScheme.sol b/contracts/universalSchemes/VoteInOrganizationScheme.sol index 84380e75..0e6e1017 100644 --- a/contracts/universalSchemes/VoteInOrganizationScheme.sol +++ b/contracts/universalSchemes/VoteInOrganizationScheme.sol @@ -1,16 +1,16 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol"; -import "@daostack/infra/contracts/VotingMachines/GenesisProtocolCallbacksInterface.sol"; +import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol"; import "./UniversalScheme.sol"; -import "../VotingMachines/GenesisProtocolCallbacks.sol"; +import "../VotingMachines/VotingMachineCallbacks.sol"; /** * @title VoteInOrganizationScheme. * @dev A scheme to allow an organization to vote in a proposal. */ -contract VoteInOrganizationScheme is UniversalScheme,GenesisProtocolCallbacks,GenesisProtocolExecuteInterface { +contract VoteInOrganizationScheme is UniversalScheme,VotingMachineCallbacks,ProposalExecuteInterface { event NewVoteProposal( address indexed _avatar, bytes32 indexed _proposalId, @@ -134,7 +134,7 @@ contract VoteInOrganizationScheme is UniversalScheme,GenesisProtocolCallbacks,Ge //vote originalNumOfChoices+1 to vote 0 in the other organization. proposalNumberOfChoices += 1; } - bytes32 proposalId = intVote.propose(proposalNumberOfChoices, params.voteParams,msg.sender); + bytes32 proposalId = intVote.propose(proposalNumberOfChoices, params.voteParams,msg.sender,_avatar); organizationsProposals[_avatar][proposalId] = VoteProposal({ originalIntVote: _originalIntVote, diff --git a/contracts/utils/Redeemer.sol b/contracts/utils/Redeemer.sol index ff747a5b..e0733a14 100644 --- a/contracts/utils/Redeemer.sol +++ b/contracts/utils/Redeemer.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity ^0.4.25; import "../universalSchemes/ContributionReward.sol"; import "@daostack/infra/contracts/VotingMachines/GenesisProtocol.sol"; diff --git a/package-lock.json b/package-lock.json index 23a79893..73afe0e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.0-alpha.53", + "version": "0.0.0-alpha.54", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -161,9 +161,9 @@ } }, "@daostack/infra": { - "version": "0.0.0-alpha.6", - "resolved": "https://registry.npmjs.org/@daostack/infra/-/infra-0.0.0-alpha.6.tgz", - "integrity": "sha512-9XqySiviym4qn2MSpN9rlgLdYoW7B0xCLPI+pfW5qCQoWUJbJOPzhPO9qtEkbBGctB2Yy3WRpGlBP5H0e6G8kA==", + "version": "0.0.0-alpha.8", + "resolved": "https://registry.npmjs.org/@daostack/infra/-/infra-0.0.0-alpha.8.tgz", + "integrity": "sha512-n3V3Ox7sCwLepUoFhLJCcUgiwUeQT5IDzNFlXqGoMDCF4UAq5Gn3MDtumRFW+5pP2JQBNffNK6XTMl7ysW9S0g==", "requires": { "ethereumjs-abi": "^0.6.5", "openzeppelin-solidity": "1.12.0" @@ -6416,14 +6416,73 @@ "dev": true }, "truffle": { - "version": "5.0.0-beta.0", - "resolved": "https://registry.npmjs.org/truffle/-/truffle-5.0.0-beta.0.tgz", - "integrity": "sha512-hZ3TvO0ByHZabVvF5kH3phliAMLbeTM9XrBuJRTfM5x2Q4kHVYnTQa1oOhetPPVPaULsVai5T+iQPV3ptOq9jA==", + "version": "5.0.0-beta.1", + "resolved": "https://registry.npmjs.org/truffle/-/truffle-5.0.0-beta.1.tgz", + "integrity": "sha512-U9vNwUAX0kb+pgpUWsWDFQeU2XeCHYm4swVxQdRi37mDQCOedEVgiE+Lr87LNQMAIuAY+8sG/9KF7HwVks0ncQ==", "dev": true, "requires": { "mocha": "^4.1.0", "original-require": "1.0.1", - "solc": "0.4.24" + "solc": "0.4.25" + }, + "dependencies": { + "fs-extra": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", + "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^2.1.0", + "klaw": "^1.0.0", + "path-is-absolute": "^1.0.0", + "rimraf": "^2.2.8" + } + }, + "jsonfile": { + "version": "2.4.0", + "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "solc": { + "version": "0.4.25", + "resolved": "https://registry.npmjs.org/solc/-/solc-0.4.25.tgz", + "integrity": "sha512-jU1YygRVy6zatgXrLY2rRm7HW1d7a8CkkEgNJwvH2VLpWhMFsMdWcJn6kUqZwcSz/Vm+w89dy7Z/aB5p6AFTrg==", + "dev": true, + "requires": { + "fs-extra": "^0.30.0", + "memorystream": "^0.3.1", + "require-from-string": "^1.1.0", + "semver": "^5.3.0", + "yargs": "^4.7.1" + } + }, + "yargs": { + "version": "4.8.1", + "resolved": "http://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz", + "integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=", + "dev": true, + "requires": { + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "lodash.assign": "^4.0.3", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.1", + "which-module": "^1.0.0", + "window-size": "^0.2.0", + "y18n": "^3.2.1", + "yargs-parser": "^2.4.1" + } + } } }, "tv4": { diff --git a/package.json b/package.json index b92ada99..afe75415 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.0-alpha.53", + "version": "0.0.0-alpha.54", "description": "A platform for building DAOs", "files": [ "contracts/", @@ -81,7 +81,7 @@ }, "homepage": "https://daostack.io", "dependencies": { - "@daostack/infra": "^0.0.0-alpha.06", + "@daostack/infra": "0.0.0-alpha.08", "ethereumjs-abi": "^0.6.5", "openzeppelin-solidity": "1.12.0" }, diff --git a/test/contributionreward.js b/test/contributionreward.js index 75f15506..7bd41af0 100644 --- a/test/contributionreward.js +++ b/test/contributionreward.js @@ -53,7 +53,7 @@ const setupContributionRewardParams = async function( var contributionRewardParams = new ContributionRewardParams(); contributionRewardParams.orgNativeTokenFee = orgNativeTokenFee; if (genesisProtocol === true) { - contributionRewardParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,avatar); + contributionRewardParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,avatar,0); await contributionReward.setParameters( contributionRewardParams.orgNativeTokenFee, contributionRewardParams.votingMachine.params, @@ -62,7 +62,7 @@ const setupContributionRewardParams = async function( contributionRewardParams.votingMachine.params, contributionRewardParams.votingMachine.genesisProtocol.address); } else { - contributionRewardParams.votingMachine = await helpers.setupAbsoluteVote(); + contributionRewardParams.votingMachine = await helpers.setupAbsoluteVote(true,50,contributionReward.address); await contributionReward.setParameters(contributionRewardParams.orgNativeTokenFee, contributionRewardParams.votingMachine.params, contributionRewardParams.votingMachine.absoluteVote.address); diff --git a/test/genericscheme.js b/test/genericscheme.js index 8655db6c..676ddf2f 100644 --- a/test/genericscheme.js +++ b/test/genericscheme.js @@ -18,18 +18,17 @@ const setupGenericSchemeParams = async function( genericScheme, accounts, contractToCall, - reputationAccount=0, genesisProtocol = false, tokenAddress = 0 ) { var genericSchemeParams = new GenericSchemeParams(); if (genesisProtocol === true){ - genericSchemeParams.votingMachine = await helpers.setupGenesisProtocol(accounts,tokenAddress); + genericSchemeParams.votingMachine = await helpers.setupGenesisProtocol(accounts,tokenAddress,0,0); await genericScheme.setParameters(genericSchemeParams.votingMachine.params,genericSchemeParams.votingMachine.genesisProtocol.address,contractToCall); genericSchemeParams.paramsHash = await genericScheme.getParametersHash(genericSchemeParams.votingMachine.params,genericSchemeParams.votingMachine.genesisProtocol.address,contractToCall); } else { - genericSchemeParams.votingMachine = await helpers.setupAbsoluteVote(true,50,reputationAccount); + genericSchemeParams.votingMachine = await helpers.setupAbsoluteVote(true,50,genericScheme.address); await genericScheme.setParameters(genericSchemeParams.votingMachine.params,genericSchemeParams.votingMachine.absoluteVote.address,contractToCall); genericSchemeParams.paramsHash = await genericScheme.getParametersHash(genericSchemeParams.votingMachine.params,genericSchemeParams.votingMachine.absoluteVote.address,contractToCall); } @@ -50,7 +49,7 @@ const setup = async function (accounts,contractToCall = 0,reputationAccount=0,ge } else { testSetup.org = await helpers.setupOrganizationWithArrays(testSetup.daoCreator,[accounts[0],accounts[1],reputationAccount],[1000,1000,1000],testSetup.reputationArray); } - testSetup.genericSchemeParams= await setupGenericSchemeParams(testSetup.genericScheme,accounts,contractToCall,reputationAccount,genesisProtocol,tokenAddress); + testSetup.genericSchemeParams= await setupGenericSchemeParams(testSetup.genericScheme,accounts,contractToCall,genesisProtocol,tokenAddress); var permissions = "0x00000010"; diff --git a/test/globalconstraintregistrar.js b/test/globalconstraintregistrar.js index c1b274c3..1760ed1c 100644 --- a/test/globalconstraintregistrar.js +++ b/test/globalconstraintregistrar.js @@ -23,13 +23,13 @@ const setupGlobalConstraintRegistrarParams = async function( ) { var globalConstraintRegistrarParams = new GlobalConstraintRegistrarParams(); if (genesisProtocol === true) { - globalConstraintRegistrarParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token); + globalConstraintRegistrarParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,0,0); await globalConstraintRegistrar.setParameters(globalConstraintRegistrarParams.votingMachine.params, globalConstraintRegistrarParams.votingMachine.genesisProtocol.address); globalConstraintRegistrarParams.paramsHash = await globalConstraintRegistrar.getParametersHash(globalConstraintRegistrarParams.votingMachine.params, globalConstraintRegistrarParams.votingMachine.genesisProtocol.address); } else { - globalConstraintRegistrarParams.votingMachine = await helpers.setupAbsoluteVote(); + globalConstraintRegistrarParams.votingMachine = await helpers.setupAbsoluteVote(true,50,globalConstraintRegistrar.address); await globalConstraintRegistrar.setParameters(globalConstraintRegistrarParams.votingMachine.params, globalConstraintRegistrarParams.votingMachine.absoluteVote.address); globalConstraintRegistrarParams.paramsHash = await globalConstraintRegistrar.getParametersHash(globalConstraintRegistrarParams.votingMachine.params, diff --git a/test/helpers.js b/test/helpers.js index 11107146..aea11581 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -121,7 +121,7 @@ export function assertJump(error) { assert.isAbove(error.message.search('invalid JUMP'), -1, 'Invalid JUMP error must be returned' + error.message); } -export const setupAbsoluteVote = async function (isOwnedVote=true, precReq=50) { +export const setupAbsoluteVote = async function (isOwnedVote=true, precReq=50 ) { var votingMachine = new VotingMachine(); votingMachine.absoluteVote = await AbsoluteVote.new(); // register some parameters @@ -238,6 +238,18 @@ export const checkVotesStatus = async function(proposalId, _votesStatus,votingMa } }; +export async function getProposalId(tx,contract,eventName) { + var proposalId; + await contract.getPastEvents(eventName, { + fromBlock: tx.blockNumber, + toBlock: 'latest' + }) + .then(function(events){ + proposalId = events[0].args._proposalId; + }); + return proposalId; +} + // export const increaseTime = async function (addSeconds) { // web3.currentProvider.sendAsync({ // jsonrpc: '2.0', diff --git a/test/schemeregistrar.js b/test/schemeregistrar.js index 5d60c0f9..cdb09bc4 100644 --- a/test/schemeregistrar.js +++ b/test/schemeregistrar.js @@ -18,7 +18,7 @@ const setupSchemeRegistrarParams = async function( schemeRegistrar, ) { var schemeRegistrarParams = new SchemeRegistrarParams(); - schemeRegistrarParams.votingMachine = await helpers.setupAbsoluteVote(); + schemeRegistrarParams.votingMachine = await helpers.setupAbsoluteVote(true,50,schemeRegistrar.address); await schemeRegistrar.setParameters(schemeRegistrarParams.votingMachine.params,schemeRegistrarParams.votingMachine.params,schemeRegistrarParams.votingMachine.absoluteVote.address); schemeRegistrarParams.paramsHash = await schemeRegistrar.getParametersHash(schemeRegistrarParams.votingMachine.params,schemeRegistrarParams.votingMachine.params,schemeRegistrarParams.votingMachine.absoluteVote.address); return schemeRegistrarParams; diff --git a/test/upgradescheme.js b/test/upgradescheme.js index bad19407..2f6823aa 100644 --- a/test/upgradescheme.js +++ b/test/upgradescheme.js @@ -22,7 +22,7 @@ const setupUpgradeSchemeParams = async function( upgradeScheme, ) { var upgradeSchemeParams = new UpgradeSchemeParams(); - upgradeSchemeParams.votingMachine = await helpers.setupAbsoluteVote(); + upgradeSchemeParams.votingMachine = await helpers.setupAbsoluteVote(true,50,upgradeScheme.address); await upgradeScheme.setParameters(upgradeSchemeParams.votingMachine.params,upgradeSchemeParams.votingMachine.absoluteVote.address); upgradeSchemeParams.paramsHash = await upgradeScheme.getParametersHash(upgradeSchemeParams.votingMachine.params,upgradeSchemeParams.votingMachine.absoluteVote.address); return upgradeSchemeParams; diff --git a/test/vestingscheme.js b/test/vestingscheme.js index 2a40c521..c4997529 100644 --- a/test/vestingscheme.js +++ b/test/vestingscheme.js @@ -16,7 +16,7 @@ const setupVestingSchemeParams = async function( vestingScheme, ) { var vestingSchemeParams = new VestingSchemeParams(); - vestingSchemeParams.votingMachine = await helpers.setupAbsoluteVote(); + vestingSchemeParams.votingMachine = await helpers.setupAbsoluteVote(true,50,vestingScheme.address); await vestingScheme.setParameters(vestingSchemeParams.votingMachine.params,vestingSchemeParams.votingMachine.absoluteVote.address); vestingSchemeParams.paramsHash = await vestingScheme.getParametersHash(vestingSchemeParams.votingMachine.params,vestingSchemeParams.votingMachine.absoluteVote.address); return vestingSchemeParams; diff --git a/test/voteinorganization.js b/test/voteinorganization.js index 9c04a5e3..ab0cc1c8 100644 --- a/test/voteinorganization.js +++ b/test/voteinorganization.js @@ -17,14 +17,13 @@ export class VoteInOrganizationParams { const setupVoteInOrganizationParams = async function( voteInOrganization, accounts, - reputationAccount=0, genesisProtocol = false, tokenAddress = 0, avatar ) { var voteInOrganizationParams = new VoteInOrganizationParams(); if (genesisProtocol === true){ - voteInOrganizationParams.votingMachine = await helpers.setupGenesisProtocol(accounts,tokenAddress,avatar); + voteInOrganizationParams.votingMachine = await helpers.setupGenesisProtocol(accounts,tokenAddress,avatar,0); await voteInOrganization.setParameters( voteInOrganizationParams.votingMachine.params, @@ -35,7 +34,7 @@ const setupVoteInOrganizationParams = async function( ); } else { - voteInOrganizationParams.votingMachine = await helpers.setupAbsoluteVote(true,50,reputationAccount); + voteInOrganizationParams.votingMachine = await helpers.setupAbsoluteVote(true,50); await voteInOrganization.setParameters(voteInOrganizationParams.votingMachine.params, voteInOrganizationParams.votingMachine.absoluteVote.address); voteInOrganizationParams.paramsHash = await voteInOrganization.getParametersHash(voteInOrganizationParams.votingMachine.params, @@ -61,7 +60,6 @@ const setup = async function (accounts,reputationAccount=0,genesisProtocol = fal testSetup.voteInOrganizationParams= await setupVoteInOrganizationParams(testSetup.voteInOrganization, accounts, - reputationAccount, genesisProtocol, tokenAddress, testSetup.org.avatar); @@ -98,8 +96,9 @@ contract('VoteInOrganizationScheme', accounts => { var tx = await absoluteVoteExecuteMock.propose(5, anotherTestSetup.voteInOrganizationParams.votingMachine.params, anotherTestSetup.org.avatar.address, - accounts[0]); - const proposalId = await helpers.getValueFromLogs(tx, '_proposalId'); + accounts[0],helpers.NULL_ADDRESS); + + const proposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); tx = await testSetup.voteInOrganization.proposeVote(testSetup.org.avatar.address, anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, proposalId); @@ -116,8 +115,10 @@ contract('VoteInOrganizationScheme', accounts => { var tx = await absoluteVoteExecuteMock.propose(2, anotherTestSetup.voteInOrganizationParams.votingMachine.params, anotherTestSetup.org.avatar.address, - accounts[0]); - var originalProposalId = await helpers.getValueFromLogs(tx, '_proposalId'); + accounts[0], + helpers.NULL_ADDRESS); + const originalProposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); + tx = await testSetup.voteInOrganization.proposeVote(testSetup.org.avatar.address, anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, originalProposalId); @@ -137,8 +138,10 @@ contract('VoteInOrganizationScheme', accounts => { var tx = await absoluteVoteExecuteMock.propose(2, anotherTestSetup.voteInOrganizationParams.votingMachine.params, anotherTestSetup.org.avatar.address, - accounts[0]); - var originalProposalId = await helpers.getValueFromLogs(tx, '_proposalId'); + accounts[0], + helpers.NULL_ADDRESS); + const originalProposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); + tx = await testSetup.voteInOrganization.proposeVote(testSetup.org.avatar.address, anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, originalProposalId); @@ -160,9 +163,10 @@ contract('VoteInOrganizationScheme', accounts => { var tx = await absoluteVoteExecuteMock.propose(2, anotherTestSetup.voteInOrganizationParams.votingMachine.params, anotherTestSetup.org.avatar.address, - accounts[0]); + accounts[0], + helpers.NULL_ADDRESS); - var originalProposalId = await helpers.getValueFromLogs(tx, '_proposalId'); + const originalProposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); tx = await testSetup.voteInOrganization.proposeVote(testSetup.org.avatar.address, anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, originalProposalId); @@ -180,8 +184,9 @@ contract('VoteInOrganizationScheme', accounts => { var tx = await absoluteVoteExecuteMock.propose(2, anotherTestSetup.voteInOrganizationParams.votingMachine.params, anotherTestSetup.org.avatar.address, - accounts[0]); - var originalProposalId = await helpers.getValueFromLogs(tx, '_proposalId'); + accounts[0], + helpers.NULL_ADDRESS); + const originalProposalId = await helpers.getProposalId(tx,anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote, 'NewProposal'); tx = await testSetup.voteInOrganization.proposeVote(testSetup.org.avatar.address, anotherTestSetup.voteInOrganizationParams.votingMachine.absoluteVote.address, originalProposalId); @@ -206,7 +211,8 @@ contract('VoteInOrganizationScheme', accounts => { var tx = await genesisProtocolCallbacksMock.propose(2, anotherTestSetup.voteInOrganizationParams.votingMachine.params, anotherTestSetup.org.avatar.address, - accounts[0]); + accounts[0], + helpers.NULL_ADDRESS); var originalProposalId = await helpers.getValueFromLogs(tx, '_proposalId'); tx = await testSetup.voteInOrganization.proposeVote(testSetup.org.avatar.address, anotherTestSetup.voteInOrganizationParams.votingMachine.genesisProtocol.address, diff --git a/test/genesisprotocolcallbacks.js b/test/votingmachinecallbacks.js similarity index 69% rename from test/genesisprotocolcallbacks.js rename to test/votingmachinecallbacks.js index 3e6654bd..320474dd 100644 --- a/test/genesisprotocolcallbacks.js +++ b/test/votingmachinecallbacks.js @@ -3,7 +3,7 @@ const constants = require('./constants'); const StandardTokenMock = artifacts.require('./test/StandardTokenMock.sol'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); -const ARCGenesisProtocolCallbacksMock = artifacts.require("./ARCGenesisProtocolCallbacksMock.sol"); +const ARCVotingMachineCallbacksMock = artifacts.require("./ARCVotingMachineCallbacksMock.sol"); const proposalId = "0x1234000000000000000000000000000000000000000000000000000000000000"; const setup = async function (accounts) { @@ -13,32 +13,32 @@ const setup = async function (accounts) { testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.standardTokenMock = await StandardTokenMock.new(testSetup.org.avatar.address,100); - testSetup.arcGenesisProtocolCallbacksMock = await ARCGenesisProtocolCallbacksMock.new(); + testSetup.arcVotingMachineCallbacksMock = await ARCVotingMachineCallbacksMock.new(); var permissions = "0x00000000"; await testSetup.daoCreator.setSchemes(testSetup.org.avatar.address, - [testSetup.arcGenesisProtocolCallbacksMock.address], + [testSetup.arcVotingMachineCallbacksMock.address], [helpers.NULL_HASH], [permissions]); - await testSetup.arcGenesisProtocolCallbacksMock.propose(proposalId, + await testSetup.arcVotingMachineCallbacksMock.propose(proposalId, testSetup.org.avatar.address, accounts[0]); return testSetup; }; -contract('GenesisProtocolCallbacks', function(accounts) { +contract('VotingMachineCallbacks', function(accounts) { it("getTotalReputationSupply & reputationOf ", async function() { var testSetup = await setup(accounts); - assert.equal(await testSetup.arcGenesisProtocolCallbacksMock.getTotalReputationSupply(proposalId),1000); - assert.equal(await testSetup.arcGenesisProtocolCallbacksMock.reputationOf(accounts[0],proposalId),1000); + assert.equal(await testSetup.arcVotingMachineCallbacksMock.getTotalReputationSupply(proposalId),1000); + assert.equal(await testSetup.arcVotingMachineCallbacksMock.reputationOf(accounts[0],proposalId),1000); }); it("mintReputation allowed only for genesisProtocol", async function() { var testSetup = await setup(accounts); try { - await testSetup.arcGenesisProtocolCallbacksMock.mintReputation(1000,accounts[0],proposalId,{from:accounts[1]}); + await testSetup.arcVotingMachineCallbacksMock.mintReputation(1000,accounts[0],proposalId,{from:accounts[1]}); assert(false, 'mintReputation allowed only for votingMachine'); } catch (ex) { helpers.assertVMException(ex); @@ -47,14 +47,14 @@ contract('GenesisProtocolCallbacks', function(accounts) { it("mintReputation ", async function() { var testSetup = await setup(accounts); - await testSetup.arcGenesisProtocolCallbacksMock.mintReputation(1000,accounts[2],proposalId,{from:accounts[0]}); + await testSetup.arcVotingMachineCallbacksMock.mintReputation(1000,accounts[2],proposalId,{from:accounts[0]}); assert.equal(await testSetup.org.reputation.totalSupply(),2000); }); it("burnReputation allowed only for votingMachine", async function() { var testSetup = await setup(accounts); try { - await testSetup.arcGenesisProtocolCallbacksMock.burnReputation(500,accounts[0],proposalId,{from:accounts[1]}); + await testSetup.arcVotingMachineCallbacksMock.burnReputation(500,accounts[0],proposalId,{from:accounts[1]}); assert(false, 'burnReputation allowed only for votingMachine'); } catch (ex) { helpers.assertVMException(ex); @@ -63,14 +63,14 @@ contract('GenesisProtocolCallbacks', function(accounts) { it("burnReputation ", async function() { var testSetup = await setup(accounts); - await testSetup.arcGenesisProtocolCallbacksMock.burnReputation(500,accounts[0],proposalId,{from:accounts[0]}); + await testSetup.arcVotingMachineCallbacksMock.burnReputation(500,accounts[0],proposalId,{from:accounts[0]}); assert.equal(await testSetup.org.reputation.totalSupply(),500); }); it("stakingTokenTransfer allowed only for votingMachine", async function() { var testSetup = await setup(accounts); try { - await testSetup.arcGenesisProtocolCallbacksMock.stakingTokenTransfer(testSetup.standardTokenMock.address, + await testSetup.arcVotingMachineCallbacksMock.stakingTokenTransfer(testSetup.standardTokenMock.address, accounts[0], 100, proposalId, @@ -84,11 +84,16 @@ contract('GenesisProtocolCallbacks', function(accounts) { it("stakingTokenTransfer ", async function() { var testSetup = await setup(accounts); assert.equal(await testSetup.standardTokenMock.balanceOf(accounts[0]),0); - await testSetup.arcGenesisProtocolCallbacksMock.stakingTokenTransfer(testSetup.standardTokenMock.address, + await testSetup.arcVotingMachineCallbacksMock.stakingTokenTransfer(testSetup.standardTokenMock.address, accounts[0], 100, proposalId, {from:accounts[0]}); assert.equal(await testSetup.standardTokenMock.balanceOf(accounts[0]),100); }); + + it("balanceOfStakingToken", async function() { + var testSetup = await setup(accounts); + assert.equal(await testSetup.arcVotingMachineCallbacksMock.balanceOfStakingToken(testSetup.standardTokenMock.address,proposalId),100); + }); }); diff --git a/truffle.js b/truffle.js index 54724c1b..d9f37fdd 100644 --- a/truffle.js +++ b/truffle.js @@ -49,7 +49,7 @@ module.exports = { }, compilers: { solc: { - version: "0.4.24", // Fetch exact version from solc-bin (default: truffle's version) + version: "0.4.25", // Fetch exact version from solc-bin (default: truffle's version) // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) optimizer: { enabled: true,