mirror of
https://github.com/Instadapp/dsa-governance.git
synced 2024-07-29 22:27:52 +00:00
minter => instaIndex.master()
This commit is contained in:
parent
c072d9767c
commit
6b6e662a6e
|
@ -25,20 +25,16 @@ contract TokenDelegate is TokenDelegateStorageV1, TokenEvents {
|
||||||
/**
|
/**
|
||||||
* @notice Used to initialize the contract during delegator constructor
|
* @notice Used to initialize the contract during delegator constructor
|
||||||
* @param account The address to recieve initial suppply
|
* @param account The address to recieve initial suppply
|
||||||
* @param minter_ The address of the minter
|
|
||||||
* @param mintingAllowedAfter_ Timestamp of the next allowed minting
|
* @param mintingAllowedAfter_ Timestamp of the next allowed minting
|
||||||
* @param transferPaused_ Flag to make the token non-transferable
|
* @param transferPaused_ Flag to make the token non-transferable
|
||||||
*/
|
*/
|
||||||
function initialize(address account, address minter_, uint mintingAllowedAfter_, bool transferPaused_) public {
|
function initialize(address account, uint mintingAllowedAfter_, bool transferPaused_) public {
|
||||||
require(mintingAllowedAfter == 0, "Token::initialize: can only initialize once");
|
require(mintingAllowedAfter == 0, "Token::initialize: can only initialize once");
|
||||||
require(mintingAllowedAfter_ >= block.timestamp, "Token::constructor: minting can only begin after deployment");
|
require(mintingAllowedAfter_ >= block.timestamp, "Token::constructor: minting can only begin after deployment");
|
||||||
require(msg.sender == minter, "Token::initialize: admin only");
|
require(account != address(0), "Token::initialize: invalid address");
|
||||||
require(account != address(0) && minter_ != address(0), "Token::initialize: invalid address");
|
|
||||||
|
|
||||||
balances[account] = uint96(totalSupply);
|
balances[account] = uint96(totalSupply);
|
||||||
emit Transfer(address(0), account, totalSupply);
|
emit Transfer(address(0), account, totalSupply);
|
||||||
minter = minter_;
|
|
||||||
emit MinterChanged(address(0), minter);
|
|
||||||
mintingAllowedAfter = mintingAllowedAfter_;
|
mintingAllowedAfter = mintingAllowedAfter_;
|
||||||
transferPaused = transferPaused_;
|
transferPaused = transferPaused_;
|
||||||
|
|
||||||
|
@ -49,21 +45,10 @@ contract TokenDelegate is TokenDelegateStorageV1, TokenEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @notice Change the minter address
|
|
||||||
* @param minter_ The address of the new minter
|
|
||||||
*/
|
|
||||||
function setMinter(address minter_) external {
|
|
||||||
require(msg.sender == minter, "Tkn::setMinter: only the minter can change the minter address");
|
|
||||||
emit MinterChanged(minter, minter_);
|
|
||||||
minter = minter_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notice Pause the token transfer
|
* @notice Pause the token transfer
|
||||||
*/
|
*/
|
||||||
function pauseTransfer() external {
|
function pauseTransfer() external isMaster {
|
||||||
require(msg.sender == minter, "Tkn::pauseTransfer: only the minter can pause token transfer");
|
|
||||||
transferPaused = true;
|
transferPaused = true;
|
||||||
emit TransferPaused(msg.sender);
|
emit TransferPaused(msg.sender);
|
||||||
}
|
}
|
||||||
|
@ -71,8 +56,7 @@ contract TokenDelegate is TokenDelegateStorageV1, TokenEvents {
|
||||||
/**
|
/**
|
||||||
* @notice Unpause the token transfer
|
* @notice Unpause the token transfer
|
||||||
*/
|
*/
|
||||||
function unpauseTransfer() external {
|
function unpauseTransfer() external isMaster {
|
||||||
require(msg.sender == minter, "Tkn::unpauseTransfer: only the minter can unpause token transfer");
|
|
||||||
transferPaused = false;
|
transferPaused = false;
|
||||||
emit TransferUnpaused(msg.sender);
|
emit TransferUnpaused(msg.sender);
|
||||||
}
|
}
|
||||||
|
@ -81,8 +65,7 @@ contract TokenDelegate is TokenDelegateStorageV1, TokenEvents {
|
||||||
* @notice Change token name
|
* @notice Change token name
|
||||||
* @param name_ New token name
|
* @param name_ New token name
|
||||||
*/
|
*/
|
||||||
function changeName(string calldata name_) external {
|
function changeName(string calldata name_) external isMaster {
|
||||||
require(msg.sender == minter, "Tkn::changeName: only the minter can change token name");
|
|
||||||
require(bytes(name_).length > 0, "Tkn::changeName: name_ length invaild");
|
require(bytes(name_).length > 0, "Tkn::changeName: name_ length invaild");
|
||||||
|
|
||||||
emit ChangedName(name, name_);
|
emit ChangedName(name, name_);
|
||||||
|
@ -94,8 +77,7 @@ contract TokenDelegate is TokenDelegateStorageV1, TokenEvents {
|
||||||
* @notice Change token symbol
|
* @notice Change token symbol
|
||||||
* @param symbol_ New token symbol
|
* @param symbol_ New token symbol
|
||||||
*/
|
*/
|
||||||
function changeSymbol(string calldata symbol_) external {
|
function changeSymbol(string calldata symbol_) external isMaster {
|
||||||
require(msg.sender == minter, "Tkn::changeSymbol: only the minter can change token symbol");
|
|
||||||
require(bytes(symbol_).length > 0, "Tkn::changeSymbol: name_name_ length invaild");
|
require(bytes(symbol_).length > 0, "Tkn::changeSymbol: name_name_ length invaild");
|
||||||
|
|
||||||
emit ChangedName(symbol, symbol_);
|
emit ChangedName(symbol, symbol_);
|
||||||
|
|
|
@ -6,21 +6,16 @@ import { TokenDelegatorStorage, TokenEvents } from "./TokenInterfaces.sol";
|
||||||
contract TokenDelegator is TokenDelegatorStorage, TokenEvents {
|
contract TokenDelegator is TokenDelegatorStorage, TokenEvents {
|
||||||
constructor(
|
constructor(
|
||||||
address account,
|
address account,
|
||||||
address minter_,
|
|
||||||
address implementation_,
|
address implementation_,
|
||||||
uint mintingAllowedAfter_,
|
uint mintingAllowedAfter_,
|
||||||
uint changeImplementationAfter_,
|
uint changeImplementationAfter_,
|
||||||
bool transferPaused_
|
bool transferPaused_
|
||||||
) {
|
) {
|
||||||
// Admin set to msg.sender for initialization
|
|
||||||
minter = msg.sender;
|
|
||||||
|
|
||||||
delegateTo(
|
delegateTo(
|
||||||
implementation_,
|
implementation_,
|
||||||
abi.encodeWithSignature(
|
abi.encodeWithSignature(
|
||||||
"initialize(address,address,uint256,bool)",
|
"initialize(address,uint256,bool)",
|
||||||
account,
|
account,
|
||||||
minter_,
|
|
||||||
mintingAllowedAfter_,
|
mintingAllowedAfter_,
|
||||||
transferPaused_
|
transferPaused_
|
||||||
)
|
)
|
||||||
|
@ -29,16 +24,13 @@ contract TokenDelegator is TokenDelegatorStorage, TokenEvents {
|
||||||
changeImplementationAfter = changeImplementationAfter_;
|
changeImplementationAfter = changeImplementationAfter_;
|
||||||
|
|
||||||
_setImplementation(implementation_);
|
_setImplementation(implementation_);
|
||||||
|
|
||||||
minter = minter_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notice Called by the admin to update the implementation of the delegator
|
* @notice Called by the admin to update the implementation of the delegator
|
||||||
* @param implementation_ The address of the new implementation for delegation
|
* @param implementation_ The address of the new implementation for delegation
|
||||||
*/
|
*/
|
||||||
function _setImplementation(address implementation_) public {
|
function _setImplementation(address implementation_) public isMaster {
|
||||||
require(msg.sender == minter, "TokenDelegator::_setImplementation: admin only");
|
|
||||||
require(implementation_ != address(0), "TokenDelegator::_setImplementation: invalid implementation address");
|
require(implementation_ != address(0), "TokenDelegator::_setImplementation: invalid implementation address");
|
||||||
require(changeImplementationAfter >= block.timestamp, "TokenDelegator::_setImplementation: can change implementation changeImplementationAfter time only");
|
require(changeImplementationAfter >= block.timestamp, "TokenDelegator::_setImplementation: can change implementation changeImplementationAfter time only");
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
pragma solidity ^0.7.0;
|
pragma solidity ^0.7.0;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
interface IndexInterface {
|
||||||
|
function master() external view returns (address);
|
||||||
|
}
|
||||||
|
|
||||||
contract TokenEvents {
|
contract TokenEvents {
|
||||||
|
|
||||||
/// @notice An event thats emitted when an account changes its delegate
|
/// @notice An event thats emitted when an account changes its delegate
|
||||||
|
@ -35,8 +39,7 @@ contract TokenEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
contract TokenDelegatorStorage {
|
contract TokenDelegatorStorage {
|
||||||
/// @notice Administrator Token minter
|
IndexInterface constant public instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
|
||||||
address public minter;
|
|
||||||
|
|
||||||
/// @notice Active brains of Token
|
/// @notice Active brains of Token
|
||||||
address public implementation;
|
address public implementation;
|
||||||
|
@ -56,6 +59,10 @@ contract TokenDelegatorStorage {
|
||||||
/// @notice EIP-20 token decimals for this token
|
/// @notice EIP-20 token decimals for this token
|
||||||
uint8 public constant decimals = 18;
|
uint8 public constant decimals = 18;
|
||||||
|
|
||||||
|
modifier isMaster() {
|
||||||
|
require(instaIndex.master() == msg.sender, "Tkn::isMaster: msg.sender not master");
|
||||||
|
_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user