diff --git a/contracts/DODODrops/DODODropsV2/DODODrops.sol b/contracts/DODODrops/DODODropsV2/DODODrops.sol index 5ef3e41..b000330 100644 --- a/contracts/DODODrops/DODODropsV2/DODODrops.sol +++ b/contracts/DODODrops/DODODropsV2/DODODrops.sol @@ -54,6 +54,8 @@ contract DODODrops is InitializableMintableERC20, ReentrancyGuard { uint256 public _REVEAL_RN_ = 0; address public _RNG_; + bool public _CAN_TRANSFER_; + fallback() external payable {} receive() external payable {} @@ -65,6 +67,11 @@ contract DODODrops is InitializableMintableERC20, ReentrancyGuard { _; } + modifier canTransfer() { + require(_CAN_TRANSFER_, "DropsTickets: not allowed transfer"); + _; + } + // ============ Event ============= event BuyTicket(address account, uint256 payAmount, uint256 feeAmount, uint256 ticketAmount); event RedeemPrize(address account, uint256 tokenId, address referer); @@ -80,6 +87,8 @@ contract DODODrops is InitializableMintableERC20, ReentrancyGuard { event SetTokenIdMapByIndex(uint256 index); // only for ProbMode event SetFixedAmountInfo(); // only for FixedAmount mode + event SetCantransfer(bool allowed); + function init( address[] memory addrList, //0 owner, 1 buyToken, 2 feeModel, 3 defaultMaintainer 4 rng 5 nftToken @@ -217,7 +226,28 @@ contract DODODrops is InitializableMintableERC20, ReentrancyGuard { emit SetFixedAmountInfo(); } + + function approve(address spender, uint256 amount) canTransfer public override returns (bool) { + return super.approve(spender, amount); + } + + function transferFrom( + address from, + address to, + uint256 amount + ) canTransfer public override returns (bool) { + return super.transferFrom(from, to, amount); + } + + function transfer(address to, uint256 amount) canTransfer public override returns (bool) { + return super.transfer(to, amount); + } + // ================= Owner =================== + function setCantransfer(bool allowed) public onlyOwner { + _CAN_TRANSFER_ = allowed; + emit SetCantransfer(allowed); + } function withdraw() external onlyOwner { uint256 amount = IERC20(_BUY_TOKEN_).universalBalanceOf(address(this)); @@ -227,6 +257,7 @@ contract DODODrops is InitializableMintableERC20, ReentrancyGuard { function setRevealRn() external onlyOwner { require(_REVEAL_RN_ == 0, "ALREADY_SET"); + require(!_CAN_TRANSFER_, "NEED_CLOSE_TRANSFER"); _REVEAL_RN_ = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1)))); emit SetReveal(); } diff --git a/contracts/external/ERC20/InitializableMintableERC20.sol b/contracts/external/ERC20/InitializableMintableERC20.sol index 587c8ad..7199dea 100644 --- a/contracts/external/ERC20/InitializableMintableERC20.sol +++ b/contracts/external/ERC20/InitializableMintableERC20.sol @@ -42,7 +42,7 @@ contract InitializableMintableERC20 is InitializableOwnable { emit Transfer(address(0), _creator, _initSupply); } - function transfer(address to, uint256 amount) public returns (bool) { + function transfer(address to, uint256 amount) public virtual returns (bool) { require(to != address(0), "TO_ADDRESS_IS_EMPTY"); require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH"); @@ -60,7 +60,7 @@ contract InitializableMintableERC20 is InitializableOwnable { address from, address to, uint256 amount - ) public returns (bool) { + ) public virtual returns (bool) { require(to != address(0), "TO_ADDRESS_IS_EMPTY"); require(amount <= balances[from], "BALANCE_NOT_ENOUGH"); require(amount <= allowed[from][msg.sender], "ALLOWANCE_NOT_ENOUGH"); @@ -72,7 +72,7 @@ contract InitializableMintableERC20 is InitializableOwnable { return true; } - function approve(address spender, uint256 amount) public returns (bool) { + function approve(address spender, uint256 amount) public virtual returns (bool) { allowed[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true;