From f3585454fe7c782c95c6f4e87a5fd2d164ee096d Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Sat, 27 Mar 2021 23:43:20 +0530 Subject: [PATCH] Update mint and initial supply --- contracts/TokenDelegate.sol | 8 +++++--- contracts/TokenDelegator.sol | 4 +++- contracts/TokenInterfaces.sol | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/contracts/TokenDelegate.sol b/contracts/TokenDelegate.sol index 2b65978..9b9e89f 100644 --- a/contracts/TokenDelegate.sol +++ b/contracts/TokenDelegate.sol @@ -28,11 +28,14 @@ contract TokenDelegate is TokenDelegateStorageV1, TokenEvents { * @param mintingAllowedAfter_ Timestamp of the next allowed minting * @param transferPaused_ Flag to make the token non-transferable */ - function initialize(address account, uint mintingAllowedAfter_, bool transferPaused_) public { + function initialize(address account, uint initialSupply_, uint mintingAllowedAfter_, bool transferPaused_) public { require(mintingAllowedAfter == 0, "Token::initialize: can only initialize once"); require(totalSupply == 0, "Token::initialize: can only initialize once"); require(mintingAllowedAfter_ >= block.timestamp, "Token::constructor: minting can only begin after deployment"); require(account != address(0), "Token::initialize: invalid address"); + require(initialSupply_ > 0, "Token::initialize: invalid initial supply"); + + totalSupply = initialSupply_; balances[account] = uint96(totalSupply); emit Transfer(address(0), account, totalSupply); @@ -198,8 +201,7 @@ contract TokenDelegate is TokenDelegateStorageV1, TokenEvents { * @param dst The address of the destination account * @param rawAmount The number of tokens to be minted */ - function mint(address dst, uint rawAmount) external { - require(msg.sender == minter, "Tkn::mint: only the minter can mint"); + function mint(address dst, uint rawAmount) external isMaster { require(block.timestamp >= mintingAllowedAfter, "Uni::mint: minting not allowed yet"); require(dst != address(0), "Tkn::mint: cannot transfer to the zero address"); diff --git a/contracts/TokenDelegator.sol b/contracts/TokenDelegator.sol index db3488e..eed89f4 100644 --- a/contracts/TokenDelegator.sol +++ b/contracts/TokenDelegator.sol @@ -7,6 +7,7 @@ contract TokenDelegator is TokenDelegatorStorage, TokenEvents { constructor( address account, address implementation_, + uint initialSupply_, uint mintingAllowedAfter_, uint changeImplementationAfter_, bool transferPaused_ @@ -14,8 +15,9 @@ contract TokenDelegator is TokenDelegatorStorage, TokenEvents { delegateTo( implementation_, abi.encodeWithSignature( - "initialize(address,uint256,bool)", + "initialize(address,uint256,uint256,bool)", account, + initialSupply_, mintingAllowedAfter_, transferPaused_ ) diff --git a/contracts/TokenInterfaces.sol b/contracts/TokenInterfaces.sol index f67e5d0..8d8ae50 100644 --- a/contracts/TokenInterfaces.sol +++ b/contracts/TokenInterfaces.sol @@ -54,7 +54,7 @@ contract TokenDelegatorStorage { string public symbol = ""; // TODO - Replace it /// @notice Total number of tokens in circulation - uint public totalSupply = 10000000e18; // TODO - Replace it + uint public totalSupply; /// @notice EIP-20 token decimals for this token uint8 public constant decimals = 18;