-
Notifications
You must be signed in to change notification settings - Fork 21
Added AuthorizedMintRep scheme #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
pragma solidity 0.5.13; | ||
|
||
import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "openzeppelin-solidity/contracts/math/SafeMath.sol"; | ||
import "../controller/Controller.sol"; | ||
|
||
/** | ||
* @title A scheme for reputation allocation by an authorized account | ||
*/ | ||
|
||
contract AuthorizedMintRep is Ownable { | ||
using SafeMath for uint256; | ||
|
||
Avatar public avatar; | ||
uint256 public activationStartTime; | ||
uint256 public activationEndTime; | ||
uint256 public repRewardLeft; | ||
bool public limitRepReward; | ||
|
||
/** | ||
* @dev initialize | ||
* @param _avatar the avatar to mint reputation from | ||
* @param _activationStartTime start time for allowing minting | ||
* @param _activationEndTime end time for allowing minting | ||
* @param _maxRepReward maximum reputation mintable by this scheme | ||
*/ | ||
function initialize( | ||
Avatar _avatar, | ||
uint256 _activationStartTime, | ||
uint256 _activationEndTime, | ||
uint256 _maxRepReward | ||
) external onlyOwner { | ||
require(avatar == Avatar(0), "can be called only one time"); | ||
require(_avatar != Avatar(0), "avatar cannot be zero"); | ||
require(_activationStartTime < _activationEndTime, "_activationStartTime < _activationEndTime"); | ||
avatar = _avatar; | ||
activationStartTime = _activationStartTime; | ||
activationEndTime = _activationEndTime; | ||
repRewardLeft = _maxRepReward; | ||
limitRepReward = _maxRepReward != 0; | ||
} | ||
|
||
/** | ||
* @dev reputationMint function | ||
* @param _beneficiary the beneficiary address to mint reputation for | ||
* @param _amount the amount of reputation to mint the the beneficirary | ||
*/ | ||
function reputationMint(address _beneficiary, uint256 _amount) external onlyOwner { | ||
// solhint-disable-next-line not-rely-on-time | ||
require(now >= activationStartTime, "Minting period did not start yet"); | ||
// solhint-disable-next-line not-rely-on-time | ||
require(now < activationEndTime, "Minting period ended."); | ||
|
||
if (limitRepReward) { | ||
repRewardLeft = repRewardLeft.sub(_amount); | ||
} | ||
|
||
require( | ||
Controller(avatar.owner()).mintReputation(_amount, _beneficiary, address(avatar)), | ||
"Minting reputation should succeed" | ||
); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does it means != 0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not 0 I want to skip the check of the limit of reputation
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is strange syntax .
do we have a test which cover this case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, what's weird about this syntax?