Skip to content

Commit

Permalink
add common interface (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
orenyodfat authored Mar 25, 2020
1 parent 557b8d7 commit c9921be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
7 changes: 7 additions & 0 deletions contracts/schemes/CommonInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pragma solidity ^0.5.16;


contract CommonInterface {
string public constant FUNDED_BEFORE_DEADLINE_KEY = "FUNDED_BEFORE_DEADLINE";
string public constant FUNDED_BEFORE_DEADLINE_VALUE = "TRUE";
}
12 changes: 7 additions & 5 deletions contracts/schemes/JoinAndQuit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.5.16;
import "../votingMachines/VotingMachineCallbacks.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../libs/StringUtil.sol";
import "./CommonInterface.sol";


/**
Expand All @@ -14,7 +15,8 @@ import "../libs/StringUtil.sol";
contract JoinAndQuit is
VotingMachineCallbacks,
ProposalExecuteInterface,
Initializable {
Initializable,
CommonInterface {
using SafeMath for uint;
using SafeERC20 for address;
using StringUtil for string;
Expand Down Expand Up @@ -68,8 +70,6 @@ contract JoinAndQuit is
uint256 public fundingGoal;
uint256 public fundingGoalDeadLine;
uint256 public totalDonation;
string public constant FUNDED_BEFORE_DEADLINE_KEY = "FUNDED_BEFORE_DEADLINE";
string public constant FUNDED_BEFORE_DEADLINE_VALUE = "TRUE";

/**
* @dev initialize
Expand Down Expand Up @@ -261,13 +261,15 @@ contract JoinAndQuit is
} else {
avatarBalance = fundingToken.balanceOf(address(avatar));
}
if ((avatar.db(FUNDED_BEFORE_DEADLINE_KEY).hashCompareWithLengthCheck(FUNDED_BEFORE_DEADLINE_VALUE) == false) &&
if ((avatar.db(CommonInterface.FUNDED_BEFORE_DEADLINE_KEY)
.hashCompareWithLengthCheck(CommonInterface.FUNDED_BEFORE_DEADLINE_VALUE) == false) &&
(avatarBalance >= fundingGoal) &&
// solhint-disable-next-line not-rely-on-time
(now < fundingGoalDeadLine)) {
require(
Controller(
avatar.owner()).setDBValue(FUNDED_BEFORE_DEADLINE_KEY, FUNDED_BEFORE_DEADLINE_VALUE));
avatar.owner()).
setDBValue(CommonInterface.FUNDED_BEFORE_DEADLINE_KEY, CommonInterface.FUNDED_BEFORE_DEADLINE_VALUE));
emit FundedBeforeDeadline(address(avatar));
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/joinandquit.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ contract('JoinAndQuit', accounts => {
it("checkFundedBeforeDeadLine with eth", async function() {
var testSetup = await setup(accounts,true);
let avatar = await Avatar.at(testSetup.org.avatar.address);
let key = await testSetup.joinAndQuit.FUNDED_BEFORE_DEADLINE_KEY();
let value = await testSetup.joinAndQuit.FUNDED_BEFORE_DEADLINE_VALUE();
let key = "FUNDED_BEFORE_DEADLINE";
let value = "TRUE";
assert.equal(await avatar.db(key),"");

var tx = await testSetup.joinAndQuit.proposeToJoin(
Expand All @@ -501,7 +501,7 @@ contract('JoinAndQuit', accounts => {
var testSetup = await setup(accounts);
await testSetup.standardTokenMock.approve(testSetup.joinAndQuit.address,testSetup.fundingGoal,{from:accounts[3]});
let avatar = await Avatar.at(testSetup.org.avatar.address);
let key = await testSetup.joinAndQuit.FUNDED_BEFORE_DEADLINE_KEY();
let key = "FUNDED_BEFORE_DEADLINE";
assert.equal(await avatar.db(key),"");
await helpers.increaseTime(testSetup.fundingGoalDeadLine);
await addMember(accounts,testSetup,accounts[4],testSetup.fundingGoal,accounts[3]);
Expand All @@ -511,7 +511,7 @@ contract('JoinAndQuit', accounts => {
it("checkFundedBeforeDeadLine after deadline with eth", async function() {
var testSetup = await setup(accounts,true);
let avatar = await Avatar.at(testSetup.org.avatar.address);
let key = await testSetup.joinAndQuit.FUNDED_BEFORE_DEADLINE_KEY();
let key = "FUNDED_BEFORE_DEADLINE";
assert.equal(await avatar.db(key),"");
await helpers.increaseTime(testSetup.fundingGoalDeadLine);
await addMember(accounts,testSetup,accounts[4],testSetup.fundingGoal,accounts[3]);
Expand Down

0 comments on commit c9921be

Please sign in to comment.