Skip to content

Commit 2825e16

Browse files
ben-kaufmanorenyodfat
authored andcommitted
Added AuthorizedMintRep scheme (#704)
* Added AuthorizedMintRep scheme Fix #703 * fix comment * Fix * bump version
1 parent cf1ce51 commit 2825e16

File tree

4 files changed

+273
-13
lines changed

4 files changed

+273
-13
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
pragma solidity 0.5.13;
2+
3+
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
4+
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
5+
import "../controller/Controller.sol";
6+
7+
/**
8+
* @title A scheme for reputation allocation by an authorized account
9+
*/
10+
11+
contract AuthorizedMintRep is Ownable {
12+
using SafeMath for uint256;
13+
14+
Avatar public avatar;
15+
uint256 public activationStartTime;
16+
uint256 public activationEndTime;
17+
uint256 public repRewardLeft;
18+
bool public limitRepReward;
19+
20+
/**
21+
* @dev initialize
22+
* @param _avatar the avatar to mint reputation from
23+
* @param _activationStartTime start time for allowing minting
24+
* @param _activationEndTime end time for allowing minting
25+
* @param _maxRepReward maximum reputation mintable by this scheme
26+
*/
27+
function initialize(
28+
Avatar _avatar,
29+
uint256 _activationStartTime,
30+
uint256 _activationEndTime,
31+
uint256 _maxRepReward
32+
) external onlyOwner {
33+
require(avatar == Avatar(0), "can be called only one time");
34+
require(_avatar != Avatar(0), "avatar cannot be zero");
35+
require(_activationStartTime < _activationEndTime, "_activationStartTime < _activationEndTime");
36+
avatar = _avatar;
37+
activationStartTime = _activationStartTime;
38+
activationEndTime = _activationEndTime;
39+
repRewardLeft = _maxRepReward;
40+
limitRepReward = _maxRepReward != 0;
41+
}
42+
43+
/**
44+
* @dev reputationMint function
45+
* @param _beneficiary the beneficiary address to mint reputation for
46+
* @param _amount the amount of reputation to mint the the beneficirary
47+
*/
48+
function reputationMint(address _beneficiary, uint256 _amount) external onlyOwner {
49+
// solhint-disable-next-line not-rely-on-time
50+
require(now >= activationStartTime, "Minting period did not start yet");
51+
// solhint-disable-next-line not-rely-on-time
52+
require(now < activationEndTime, "Minting period ended.");
53+
54+
if (limitRepReward) {
55+
repRewardLeft = repRewardLeft.sub(_amount);
56+
}
57+
58+
require(
59+
Controller(avatar.owner()).mintReputation(_amount, _beneficiary, address(avatar)),
60+
"Minting reputation should succeed"
61+
);
62+
}
63+
}

package-lock.json

Lines changed: 31 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daostack/arc",
3-
"version": "0.0.1-rc.36",
3+
"version": "0.0.1-rc.37",
44
"description": "A platform for building DAOs",
55
"files": [
66
"contracts/",

0 commit comments

Comments
 (0)