Skip to content

Commit dafa1d7

Browse files
authored
Add redeemEnableTime for lock4reputation schemes (#557)
* use infra 09 * add redeemEnableTime to lock4reputation schems * rename VotingMachines -> votingMachines * auction4reputation add transferToWallet * auction4reputation fix error msg
1 parent 5e057c3 commit dafa1d7

22 files changed

+274
-50
lines changed

contracts/schemes/Auction4Reputation.sol

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ contract Auction4Reputation is Ownable {
3434
uint public numberOfAuctions;
3535
uint public auctionReputationReward;
3636
uint public auctionPeriod;
37+
uint public redeemEnableTime;
3738
StandardToken public token;
3839
address public wallet;
3940

@@ -44,24 +45,28 @@ contract Auction4Reputation is Ownable {
4445
* for the token locking
4546
* @param _auctionsStartTime auctions period start time
4647
* @param _auctionsEndTime auctions period end time.
47-
* redeem reputation can be done after this period.
4848
* bidding is disable after this time.
4949
* @param _numberOfAuctions number of auctions.
50+
* @param _redeemEnableTime redeem enable time .
51+
* redeem reputation can be done after this time.
5052
* @param _token the bidding token
53+
* @param _wallet the address of the wallet the token will be transfer to.
5154
*/
5255
function initialize(
5356
Avatar _avatar,
5457
uint _reputationReward,
5558
uint _auctionsStartTime,
5659
uint _auctionsEndTime,
5760
uint _numberOfAuctions,
61+
uint _redeemEnableTime,
5862
StandardToken _token,
5963
address _wallet)
6064
external
6165
onlyOwner
6266
{
6367
require(avatar == Avatar(0), "can be called only one time");
6468
require(_avatar != Avatar(0), "avatar cannot be zero");
69+
require(_redeemEnableTime >= _auctionsEndTime, "_redeemEnableTime >= _auctionsEndTime");
6570
// number of auctions cannot be zero
6671
// auctionsEndTime should be greater than auctionsStartTime
6772
auctionPeriod = (_auctionsEndTime.sub(_auctionsStartTime)).div(_numberOfAuctions);
@@ -74,6 +79,7 @@ contract Auction4Reputation is Ownable {
7479
wallet = _wallet;
7580
auctionReputationReward = _reputationReward / _numberOfAuctions;
7681
reputationRewardLeft = _reputationReward;
82+
redeemEnableTime = _redeemEnableTime;
7783
}
7884

7985
/**
@@ -84,7 +90,7 @@ contract Auction4Reputation is Ownable {
8490
*/
8591
function redeem(address _beneficiary, uint _auctionId) public returns(bool) {
8692
// solium-disable-next-line security/no-block-members
87-
require(now > auctionsEndTime, "check the auctions period pass");
93+
require(now > redeemEnableTime, "now > redeemEnableTime");
8894
Auction storage auction = auctions[_auctionId];
8995
uint bid = auction.bids[_beneficiary];
9096
require(bid > 0, "bidding amount should be > 0");
@@ -109,7 +115,7 @@ contract Auction4Reputation is Ownable {
109115
require(now <= auctionsEndTime, "bidding should be within the allowed bidding period");
110116
// solium-disable-next-line security/no-block-members
111117
require(now >= auctionsStartTime, "bidding is enable only after bidding auctionsStartTime");
112-
require(token.transferFrom(msg.sender, wallet, _amount), "transferFrom should success");
118+
require(token.transferFrom(msg.sender, this, _amount), "transferFrom should success");
113119
// solium-disable-next-line security/no-block-members
114120
auctionId = (now - auctionsStartTime) / auctionPeriod;
115121
Auction storage auction = auctions[auctionId];
@@ -128,4 +134,15 @@ contract Auction4Reputation is Ownable {
128134
return auctions[_auctionId].bids[_bidder];
129135
}
130136

137+
/**
138+
* @dev transferToWallet transfer the tokens to the wallet.
139+
* can be called only after auctionsEndTime
140+
*/
141+
function transferToWallet() public {
142+
// solium-disable-next-line security/no-block-members
143+
require(now > auctionsEndTime, "now > auctionsEndTime");
144+
uint tokenBalance = token.balanceOf(this);
145+
require(token.transfer(wallet,tokenBalance), "transfer should success");
146+
}
147+
131148
}

contracts/schemes/ExternalLocking4Reputation.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ contract ExternalLocking4Reputation is Locking4Reputation, Ownable {
2323
* for the token locking
2424
* @param _lockingStartTime locking starting period time.
2525
* @param _lockingEndTime the locking end time.
26-
* redeem reputation can be done after this period.
2726
* locking is disable after this time.
27+
* @param _redeemEnableTime redeem enable time .
28+
* redeem reputation can be done after this time.
2829
* @param _externalLockingContract the contract which lock the token.
2930
* @param _getBalanceFuncSignature get balance function signature
3031
* e.g "lockedTokenBalances(address)"
@@ -34,6 +35,7 @@ contract ExternalLocking4Reputation is Locking4Reputation, Ownable {
3435
uint _reputationReward,
3536
uint _lockingStartTime,
3637
uint _lockingEndTime,
38+
uint _redeemEnableTime,
3739
address _externalLockingContract,
3840
string _getBalanceFuncSignature)
3941
external
@@ -47,6 +49,7 @@ contract ExternalLocking4Reputation is Locking4Reputation, Ownable {
4749
_reputationReward,
4850
_lockingStartTime,
4951
_lockingEndTime,
52+
_redeemEnableTime,
5053
1);
5154
}
5255

@@ -69,7 +72,7 @@ contract ExternalLocking4Reputation is Locking4Reputation, Ownable {
6972
case 0 { revert(0, returndatasize) }
7073
default { lockedAmount := mload(0) }
7174
}
72-
75+
7376
return super._lock(lockedAmount, 1, msg.sender);
7477
}
7578
}

contracts/schemes/Locking4Reputation.sol

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ contract Locking4Reputation {
3838
uint public lockingEndTime;
3939
uint public maxLockingPeriod;
4040
uint public lockingStartTime;
41+
uint public redeemEnableTime;
4142

4243
/**
4344
* @dev redeem reputation function
@@ -46,7 +47,7 @@ contract Locking4Reputation {
4647
*/
4748
function redeem(address _beneficiary) public returns(bool) {
4849
// solium-disable-next-line security/no-block-members
49-
require(block.timestamp > lockingEndTime, "check the lock period pass");
50+
require(block.timestamp > redeemEnableTime, "now > redeemEnableTime");
5051
require(scores[_beneficiary] > 0, "score should be > 0");
5152
uint score = scores[_beneficiary];
5253
scores[_beneficiary] = 0;
@@ -118,28 +119,32 @@ contract Locking4Reputation {
118119
* for eth/token locking
119120
* @param _lockingStartTime the locking start time.
120121
* @param _lockingEndTime the locking end time.
121-
* redeem reputation can be done after this period.
122122
* locking is disable after this time.
123+
* @param _redeemEnableTime redeem enable time .
124+
* redeem reputation can be done after this time.
123125
* @param _maxLockingPeriod maximum locking period allowed.
124126
*/
125127
function _initialize(
126128
Avatar _avatar,
127129
uint _reputationReward,
128130
uint _lockingStartTime,
129131
uint _lockingEndTime,
132+
uint _redeemEnableTime,
130133
uint _maxLockingPeriod)
131134
internal
132135
{
133136
require(avatar == Avatar(0), "can be called only one time");
134137
require(_avatar != Avatar(0), "avatar cannot be zero");
135138
require(_lockingEndTime > _lockingStartTime, "locking end time should be greater than locking start time");
139+
require(_redeemEnableTime >= _lockingEndTime, "redeemEnableTime >= lockingEndTime");
136140

137141
reputationReward = _reputationReward;
138142
reputationRewardLeft = _reputationReward;
139143
lockingEndTime = _lockingEndTime;
140144
maxLockingPeriod = _maxLockingPeriod;
141145
avatar = _avatar;
142146
lockingStartTime = _lockingStartTime;
147+
redeemEnableTime = _redeemEnableTime;
143148
}
144149

145150
}

contracts/schemes/LockingEth4Reputation.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ contract LockingEth4Reputation is Locking4Reputation, Ownable {
1717
* for eth locking
1818
* @param _lockingStartTime locking starting period time.
1919
* @param _lockingEndTime the locking end time.
20-
* redeem reputation can be done after this period.
2120
* locking is disable after this time.
21+
* @param _redeemEnableTime redeem enable time .
22+
* redeem reputation can be done after this time.
2223
* @param _maxLockingPeriod maximum locking period allowed.
2324
*/
2425
function initialize(
2526
Avatar _avatar,
2627
uint _reputationReward,
2728
uint _lockingStartTime,
2829
uint _lockingEndTime,
30+
uint _redeemEnableTime,
2931
uint _maxLockingPeriod)
3032
external
3133
onlyOwner
@@ -35,6 +37,7 @@ contract LockingEth4Reputation is Locking4Reputation, Ownable {
3537
_reputationReward,
3638
_lockingStartTime,
3739
_lockingEndTime,
40+
_redeemEnableTime,
3841
_maxLockingPeriod);
3942
}
4043

@@ -47,7 +50,7 @@ contract LockingEth4Reputation is Locking4Reputation, Ownable {
4750
function release(address _beneficiary, bytes32 _lockingId) public returns(bool) {
4851
uint amount = super._release(_beneficiary, _lockingId);
4952
_beneficiary.transfer(amount);
50-
53+
5154
return true;
5255
}
5356

contracts/schemes/LockingToken4Reputation.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ contract LockingToken4Reputation is Locking4Reputation, Ownable {
1818
* for the token locking
1919
* @param _lockingStartTime locking starting period time.
2020
* @param _lockingEndTime the locking end time.
21-
* redeem reputation can be done after this period.
2221
* locking is disable after this time.
22+
* @param _redeemEnableTime redeem enable time .
23+
* redeem reputation can be done after this time.
2324
* @param _maxLockingPeriod maximum locking period allowed.
2425
* @param _token the locking token
2526
*/
@@ -28,6 +29,7 @@ contract LockingToken4Reputation is Locking4Reputation, Ownable {
2829
uint _reputationReward,
2930
uint _lockingStartTime,
3031
uint _lockingEndTime,
32+
uint _redeemEnableTime,
3133
uint _maxLockingPeriod,
3234
StandardToken _token)
3335
external
@@ -39,6 +41,7 @@ contract LockingToken4Reputation is Locking4Reputation, Ownable {
3941
_reputationReward,
4042
_lockingStartTime,
4143
_lockingEndTime,
44+
_redeemEnableTime,
4245
_maxLockingPeriod);
4346
}
4447

@@ -51,7 +54,7 @@ contract LockingToken4Reputation is Locking4Reputation, Ownable {
5154
function release(address _beneficiary,bytes32 _lockingId) public returns(bool) {
5255
uint amount = super._release(_beneficiary, _lockingId);
5356
require(token.transfer(_beneficiary, amount), "transfer should success");
54-
57+
5558
return true;
5659
}
5760

@@ -63,7 +66,7 @@ contract LockingToken4Reputation is Locking4Reputation, Ownable {
6366
*/
6467
function lock(uint _amount, uint _period) public returns(bytes32) {
6568
require(token.transferFrom(msg.sender, address(this), _amount), "transferFrom should success");
66-
69+
6770
return super._lock(_amount, _period, msg.sender);
6871
}
6972

contracts/test/ARCDebug.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pragma solidity ^0.4.25;
22

3-
import "@daostack/infra/contracts/VotingMachines/GenesisProtocol.sol";
4-
import "@daostack/infra/contracts/VotingMachines/AbsoluteVote.sol";
5-
import "@daostack/infra/contracts/VotingMachines/QuorumVote.sol";
3+
import "@daostack/infra/contracts/votingMachines/GenesisProtocol.sol";
4+
import "@daostack/infra/contracts/votingMachines/AbsoluteVote.sol";
5+
import "@daostack/infra/contracts/votingMachines/QuorumVote.sol";
66
import "@daostack/infra/contracts/test/AbsoluteVoteExecuteMock.sol";
77
import "@daostack/infra/contracts/test/GenesisProtocolCallbacksMock.sol";
88

contracts/test/ARCGenesisProtocolCallbacksMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.25;
22

3-
import "../VotingMachines/VotingMachineCallbacks.sol";
3+
import "../votingMachines/VotingMachineCallbacks.sol";
44

55

66
contract ARCVotingMachineCallbacksMock is VotingMachineCallbacks {

contracts/universalSchemes/ContributionReward.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pragma solidity ^0.4.25;
22

3-
import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol";
4-
import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol";
3+
import "@daostack/infra/contracts/votingMachines/IntVoteInterface.sol";
4+
import "@daostack/infra/contracts/votingMachines/VotingMachineCallbacksInterface.sol";
55
import "./UniversalScheme.sol";
6-
import "../VotingMachines/VotingMachineCallbacks.sol";
6+
import "../votingMachines/VotingMachineCallbacks.sol";
77

88

99
/**

contracts/universalSchemes/GenericScheme.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pragma solidity ^0.4.25;
22

3-
import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol";
4-
import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol";
3+
import "@daostack/infra/contracts/votingMachines/IntVoteInterface.sol";
4+
import "@daostack/infra/contracts/votingMachines/VotingMachineCallbacksInterface.sol";
55
import "./UniversalScheme.sol";
6-
import "../VotingMachines/VotingMachineCallbacks.sol";
6+
import "../votingMachines/VotingMachineCallbacks.sol";
77

88

99
/**

contracts/universalSchemes/GlobalConstraintRegistrar.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pragma solidity ^0.4.25;
22

3-
import "@daostack/infra/contracts/VotingMachines/IntVoteInterface.sol";
4-
import "@daostack/infra/contracts/VotingMachines/VotingMachineCallbacksInterface.sol";
3+
import "@daostack/infra/contracts/votingMachines/IntVoteInterface.sol";
4+
import "@daostack/infra/contracts/votingMachines/VotingMachineCallbacksInterface.sol";
55
import "./UniversalScheme.sol";
6-
import "../VotingMachines/VotingMachineCallbacks.sol";
6+
import "../votingMachines/VotingMachineCallbacks.sol";
77

88

99

0 commit comments

Comments
 (0)