change sth
This commit is contained in:
parent
c91d36cb33
commit
a17b99a390
File diff suppressed because one or more lines are too long
85
contracts/activity/AirdropNft.sol
Normal file
85
contracts/activity/AirdropNft.sol
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity 0.8.10;
|
||||||
|
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
|
||||||
|
import "../interfaces/IAsset.sol";
|
||||||
|
import "../interfaces/IBEERC721.sol";
|
||||||
|
import "../utils/UInt.sol";
|
||||||
|
|
||||||
|
contract AirdropNft is AccessControlEnumerable {
|
||||||
|
using UInt for uint256;
|
||||||
|
bytes32 public constant MANAGE_ROLE = keccak256("MANAGE_ROLE");
|
||||||
|
|
||||||
|
event EventDrop(
|
||||||
|
address indexed nftAddress,
|
||||||
|
uint256 indexed serialNum,
|
||||||
|
uint256 firstTokenId,
|
||||||
|
uint256 batchSize
|
||||||
|
);
|
||||||
|
|
||||||
|
constructor(address[] memory _manageAddress) {
|
||||||
|
// Set up the ADMIN_ROLE and MANAGE_ROLE
|
||||||
|
_setRoleAdmin(MANAGE_ROLE, DEFAULT_ADMIN_ROLE);
|
||||||
|
|
||||||
|
// Grant the ADMIN_ROLE to the deployer and to the contract itself
|
||||||
|
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
|
||||||
|
|
||||||
|
// Grant the MANAGE_ROLE to the specified address
|
||||||
|
for (uint256 i = 0; i < _manageAddress.length; ++i) {
|
||||||
|
_setupRole(MANAGE_ROLE, _manageAddress[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Modifier that checks if the caller has the MANAGE_ROLE.
|
||||||
|
*
|
||||||
|
* The function uses the _checkRole() function from the AccessControl library.
|
||||||
|
* If the check is successful, the code defined by the function that uses this modifier is executed.
|
||||||
|
*/
|
||||||
|
modifier onlyManager() {
|
||||||
|
// Check if the caller has the MANAGE_ROLE
|
||||||
|
_checkRole(MANAGE_ROLE, _msgSender());
|
||||||
|
// If the check is successful, execute the code in the function that uses this modifier
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropMintNft(
|
||||||
|
address tokenAddr,
|
||||||
|
uint256 serialNum,
|
||||||
|
address[] memory _recipients,
|
||||||
|
uint256[] memory _amounts
|
||||||
|
) public onlyManager returns (bool) {
|
||||||
|
require(_recipients.length == _amounts.length, "ERC:length mismatch");
|
||||||
|
uint256 beginToken = 0;
|
||||||
|
uint256 batchSize = 0;
|
||||||
|
for (uint16 i = 0; i < _recipients.length; i++) {
|
||||||
|
uint256[] memory _nftIds = IBEERC721(tokenAddr).batchMint(
|
||||||
|
_recipients[i],
|
||||||
|
_amounts[i]
|
||||||
|
);
|
||||||
|
batchSize += _amounts[i];
|
||||||
|
if (i == 0) {
|
||||||
|
beginToken = _nftIds[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit EventDrop(tokenAddr, serialNum, beginToken, batchSize);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropMintAsset(
|
||||||
|
address tokenAddr,
|
||||||
|
uint256 serialNum,
|
||||||
|
address[] memory _recipients,
|
||||||
|
uint256[] memory _tokenIds
|
||||||
|
) external onlyManager returns (bool) {
|
||||||
|
require(_recipients.length == _tokenIds.length, "ERC:length mismatch");
|
||||||
|
uint256 beginToken = _tokenIds[0];
|
||||||
|
for (uint16 i = 0; i < _recipients.length; i++) {
|
||||||
|
IAsset(tokenAddr).batchMint(
|
||||||
|
_recipients[i],
|
||||||
|
_tokenIds[i].asSingletonArray()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
emit EventDrop(tokenAddr, serialNum, beginToken, _tokenIds.length);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -23,8 +23,6 @@ contract ClaimBoxFactory is HasSignature, TimeChecker {
|
|||||||
uint256 tokenId
|
uint256 tokenId
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor() HasSignature("ClaimBoxFactory", "1") {}
|
|
||||||
|
|
||||||
function addTokenSupport(address nftToken) external onlyOwner {
|
function addTokenSupport(address nftToken) external onlyOwner {
|
||||||
tokenSupported[nftToken] = true;
|
tokenSupported[nftToken] = true;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ pragma solidity 0.8.10;
|
|||||||
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
||||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||||
|
|
||||||
contract HasSignature is Ownable {
|
contract HasSignature712 is Ownable {
|
||||||
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
|
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
|
||||||
uint256 private immutable _CACHED_CHAIN_ID;
|
uint256 private immutable _CACHED_CHAIN_ID;
|
||||||
address private immutable _CACHED_THIS;
|
address private immutable _CACHED_THIS;
|
||||||
|
@ -81,5 +81,4 @@ module.exports = async function (deployer, network, accounts) {
|
|||||||
walletInstance.address
|
walletInstance.address
|
||||||
);
|
);
|
||||||
console.log("success add distributor to badge's mint role");
|
console.log("success add distributor to badge's mint role");
|
||||||
jetpack.write("./out.json", cfgs);
|
|
||||||
};
|
};
|
||||||
|
@ -94,5 +94,23 @@
|
|||||||
"type": "logic",
|
"type": "logic",
|
||||||
"json": "assets/contracts/JSONMetadata.json",
|
"json": "assets/contracts/JSONMetadata.json",
|
||||||
"address": "0xfba1F2861718993B94edd5DCe1D06b3Cbe19353d"
|
"address": "0xfba1F2861718993B94edd5DCe1D06b3Cbe19353d"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BEMultiSigWallet",
|
||||||
|
"type": "logic",
|
||||||
|
"json": "assets/contracts/BEMultiSigWallet.json",
|
||||||
|
"address": "0xE68F149daF2F314d9960c08496D8701BC7671850"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "TestBadge",
|
||||||
|
"type": "erc721",
|
||||||
|
"json": "assets/contracts/BEBadge.json",
|
||||||
|
"address": "0x2d3Afa678F777Df6b59186A54E5427c3527C637c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AridropNft",
|
||||||
|
"type": "logic",
|
||||||
|
"json": "assets/contracts/AridropNft.json",
|
||||||
|
"address": "0x95DD930634694709425d9a929619B3c653C85F73"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user