Add TokenMinter contract
This commit is contained in:
parent
2f8c8f3ac7
commit
99ae087e55
|
@ -101,6 +101,8 @@ _Note: The following descriptions are for AuRa contracts only. HBBFT contract im
|
|||
- withdrawing tokens and rewards by participants from the pools;
|
||||
- moving tokens between pools by participant.
|
||||
|
||||
- `TokenMinter`: used when we need to have an ability to mint POSDAO tokens not only by the bridge, but also by the `BlockRewardAuRa` contract if the staking token contract doesn't support a `mintReward` function.
|
||||
|
||||
- `TxPermission`: along with the `Certifier` contract, controls the use of zero gas price by validators in service transactions, protecting the network against "transaction spamming" by malicious validators. The protection logic is declared in the `allowedTxTypes` function.
|
||||
|
||||
- `TxPriority`: manages and stores the transactions priority list used by Ethereum client. See https://github.com/NethermindEth/nethermind/issues/2300 for description.
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
pragma solidity 0.5.10;
|
||||
|
||||
|
||||
interface IToken {
|
||||
function claimTokens(address _token, address payable _to) external;
|
||||
function mint(address _to, uint256 _amount) external returns (bool);
|
||||
function transferOwnership(address _newOwner) external;
|
||||
}
|
||||
|
||||
|
||||
/// @dev Used when we need to have an ability to mint POSDAO tokens not only by the bridge,
|
||||
/// but also by the BlockRewardAuRa contract if the staking token contract doesn't support
|
||||
/// the `mintReward` function.
|
||||
contract TokenMinter {
|
||||
|
||||
address public blockRewardContract;
|
||||
address public bridgeContract;
|
||||
IToken public tokenContract;
|
||||
|
||||
modifier onlyBlockRewardContract() {
|
||||
require(msg.sender == blockRewardContract);
|
||||
_;
|
||||
}
|
||||
|
||||
modifier onlyBridgeContract() {
|
||||
require(msg.sender == bridgeContract);
|
||||
_;
|
||||
}
|
||||
|
||||
constructor(address _blockRewardContract, address _bridgeContract, IToken _tokenContract) public {
|
||||
require(_isContract(_blockRewardContract));
|
||||
require(_isContract(_bridgeContract));
|
||||
require(_isContract(address(_tokenContract)));
|
||||
blockRewardContract = _blockRewardContract;
|
||||
bridgeContract = _bridgeContract;
|
||||
tokenContract = _tokenContract;
|
||||
}
|
||||
|
||||
function claimTokens(address _token, address payable _to) public onlyBridgeContract {
|
||||
tokenContract.claimTokens(_token, _to);
|
||||
}
|
||||
|
||||
function mint(address _to, uint256 _amount) external onlyBridgeContract returns (bool) {
|
||||
return tokenContract.mint(_to, _amount);
|
||||
}
|
||||
|
||||
function mintReward(uint256 _amount) external onlyBlockRewardContract {
|
||||
if (_amount == 0) return;
|
||||
tokenContract.mint(blockRewardContract, _amount);
|
||||
}
|
||||
|
||||
function setBlockRewardContract(address _blockRewardContract) external onlyBridgeContract {
|
||||
require(_isContract(_blockRewardContract));
|
||||
blockRewardContract = _blockRewardContract;
|
||||
}
|
||||
|
||||
function setBridgeContract(address _bridgeContract) external onlyBridgeContract {
|
||||
require(_isContract(_bridgeContract));
|
||||
bridgeContract = _bridgeContract;
|
||||
}
|
||||
|
||||
function transferOwnership(address _newOwner) external onlyBridgeContract {
|
||||
tokenContract.transferOwnership(_newOwner);
|
||||
}
|
||||
|
||||
function _isContract(address _account) private view returns (bool) {
|
||||
uint256 size;
|
||||
assembly { size := extcodesize(_account) }
|
||||
return size > 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -249,13 +249,16 @@ contract BlockRewardAuRaTokens is BlockRewardAuRaBase, IBlockRewardAuRaTokens {
|
|||
|
||||
bridgeTokenReward = 0;
|
||||
|
||||
IERC677 tokenContract = IERC677(IStakingAuRaTokens(_stakingContract).erc677TokenContract());
|
||||
ITokenMinter minterContract;
|
||||
if (tokenMinterContract == ITokenMinter(0)) {
|
||||
minterContract = ITokenMinter(
|
||||
IStakingAuRaTokens(_stakingContract).erc677TokenContract()
|
||||
);
|
||||
if (tokenMinterContract != ITokenMinter(0) && tokenContract != IERC677(0)) {
|
||||
if (tokenContract.owner() == address(tokenMinterContract)) {
|
||||
minterContract = tokenMinterContract;
|
||||
} else {
|
||||
minterContract = ITokenMinter(0);
|
||||
}
|
||||
} else {
|
||||
minterContract = tokenMinterContract;
|
||||
minterContract = ITokenMinter(address(tokenContract));
|
||||
}
|
||||
|
||||
uint256 distributedAmount = 0;
|
||||
|
|
|
@ -7,5 +7,6 @@ interface IERC677 {
|
|||
|
||||
// Other functions (ERC677)
|
||||
function balanceOf(address) external view returns(uint256);
|
||||
function owner() external view returns(address);
|
||||
function transfer(address, uint256) external returns(bool);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ async function main() {
|
|||
//contractName.startsWith('ERC677BridgeTokenRewardable') ||
|
||||
contractName.startsWith('Initializer') ||
|
||||
contractName.startsWith('Migrations') ||
|
||||
contractName.startsWith('Registry')
|
||||
contractName.startsWith('Registry') ||
|
||||
contractName.startsWith('TokenMinter')
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue