fix dropsV2
This commit is contained in:
@@ -54,6 +54,8 @@ contract DODODrops is InitializableMintableERC20, ReentrancyGuard {
|
|||||||
uint256 public _REVEAL_RN_ = 0;
|
uint256 public _REVEAL_RN_ = 0;
|
||||||
address public _RNG_;
|
address public _RNG_;
|
||||||
|
|
||||||
|
bool public _CAN_TRANSFER_;
|
||||||
|
|
||||||
fallback() external payable {}
|
fallback() external payable {}
|
||||||
|
|
||||||
receive() 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 =============
|
||||||
event BuyTicket(address account, uint256 payAmount, uint256 feeAmount, uint256 ticketAmount);
|
event BuyTicket(address account, uint256 payAmount, uint256 feeAmount, uint256 ticketAmount);
|
||||||
event RedeemPrize(address account, uint256 tokenId, address referer);
|
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 SetTokenIdMapByIndex(uint256 index); // only for ProbMode
|
||||||
event SetFixedAmountInfo(); // only for FixedAmount mode
|
event SetFixedAmountInfo(); // only for FixedAmount mode
|
||||||
|
|
||||||
|
event SetCantransfer(bool allowed);
|
||||||
|
|
||||||
|
|
||||||
function init(
|
function init(
|
||||||
address[] memory addrList, //0 owner, 1 buyToken, 2 feeModel, 3 defaultMaintainer 4 rng 5 nftToken
|
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();
|
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 ===================
|
// ================= Owner ===================
|
||||||
|
function setCantransfer(bool allowed) public onlyOwner {
|
||||||
|
_CAN_TRANSFER_ = allowed;
|
||||||
|
emit SetCantransfer(allowed);
|
||||||
|
}
|
||||||
|
|
||||||
function withdraw() external onlyOwner {
|
function withdraw() external onlyOwner {
|
||||||
uint256 amount = IERC20(_BUY_TOKEN_).universalBalanceOf(address(this));
|
uint256 amount = IERC20(_BUY_TOKEN_).universalBalanceOf(address(this));
|
||||||
@@ -227,6 +257,7 @@ contract DODODrops is InitializableMintableERC20, ReentrancyGuard {
|
|||||||
|
|
||||||
function setRevealRn() external onlyOwner {
|
function setRevealRn() external onlyOwner {
|
||||||
require(_REVEAL_RN_ == 0, "ALREADY_SET");
|
require(_REVEAL_RN_ == 0, "ALREADY_SET");
|
||||||
|
require(!_CAN_TRANSFER_, "NEED_CLOSE_TRANSFER");
|
||||||
_REVEAL_RN_ = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1))));
|
_REVEAL_RN_ = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1))));
|
||||||
emit SetReveal();
|
emit SetReveal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ contract InitializableMintableERC20 is InitializableOwnable {
|
|||||||
emit Transfer(address(0), _creator, _initSupply);
|
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(to != address(0), "TO_ADDRESS_IS_EMPTY");
|
||||||
require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH");
|
require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH");
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ contract InitializableMintableERC20 is InitializableOwnable {
|
|||||||
address from,
|
address from,
|
||||||
address to,
|
address to,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
) public returns (bool) {
|
) public virtual returns (bool) {
|
||||||
require(to != address(0), "TO_ADDRESS_IS_EMPTY");
|
require(to != address(0), "TO_ADDRESS_IS_EMPTY");
|
||||||
require(amount <= balances[from], "BALANCE_NOT_ENOUGH");
|
require(amount <= balances[from], "BALANCE_NOT_ENOUGH");
|
||||||
require(amount <= allowed[from][msg.sender], "ALLOWANCE_NOT_ENOUGH");
|
require(amount <= allowed[from][msg.sender], "ALLOWANCE_NOT_ENOUGH");
|
||||||
@@ -72,7 +72,7 @@ contract InitializableMintableERC20 is InitializableOwnable {
|
|||||||
return true;
|
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;
|
allowed[msg.sender][spender] = amount;
|
||||||
emit Approval(msg.sender, spender, amount);
|
emit Approval(msg.sender, spender, amount);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user