Add some more logic and fix previous issues
This commit is contained in:
parent
10b497dfbd
commit
2e561f6f3c
62
src/AA.sol
62
src/AA.sol
|
@ -9,7 +9,7 @@ contract AA is Ownable {
|
|||
string[] nfts;
|
||||
|
||||
mapping (address => bool) public airdropped;
|
||||
address[] public allowed;
|
||||
mapping (address => bool) public eligible;
|
||||
|
||||
constructor(string memory name,
|
||||
string memory symbol,
|
||||
|
@ -28,36 +28,47 @@ contract AA is Ownable {
|
|||
|
||||
// Mint Function
|
||||
// Simplify
|
||||
function _mint(address to, string memory uri) public onlyOwner {
|
||||
dco2sc.safeMint(to, uri);
|
||||
function mintNFT(address to, uint index) external onlyOwner {
|
||||
require(!airdropped[to], "account already airdropped");
|
||||
dco2sc.safeMint(to, nfts[index]);
|
||||
removeNFTAt(index);
|
||||
airdropped[to] = true;
|
||||
}
|
||||
|
||||
// @notice Random giveaway function
|
||||
function airdrop() public {
|
||||
//require(eligible(msg.sender));
|
||||
require(!airdropped[msg.sender], "address already airdropped");
|
||||
// top 20 is for Auction
|
||||
uint256 randomURI = getRandomNumber() % nfts.length - 20;
|
||||
dco2sc.safeMint(msg.sender, nfts[randomURI]);
|
||||
// Require remove the URI so that is not mintable again
|
||||
airdropped[msg.sender] = true;
|
||||
|
||||
}
|
||||
|
||||
// @eligible
|
||||
function eligible(address to) public view returns (bool winner) {
|
||||
// @Notice Check if eligible
|
||||
function checkIfEligible() public view returns (bool winner) {
|
||||
if (airdropped[msg.sender] == true) {
|
||||
winner = false;
|
||||
} else if (eligible[msg.sender] == true) {
|
||||
winner = true;
|
||||
} else {
|
||||
winner = false;
|
||||
}
|
||||
// require( callable until specific date)
|
||||
// Activity
|
||||
// Longest Holders
|
||||
// Top Holders
|
||||
// or Allowed Wallets()
|
||||
return winner;
|
||||
}
|
||||
|
||||
// @notice allowed addresses that supports DECA
|
||||
function allow(address supporter) public onlyOwner {
|
||||
//require(eligible(supporter));
|
||||
require(!airdropped[supporter], "address already airdropped");
|
||||
allowed.push(supporter);
|
||||
// @notice Random giveaway function
|
||||
function airdrop() external {
|
||||
require(!airdropped[msg.sender], "account already airdropped");
|
||||
require(checkIfEligible(), "account not eligible");
|
||||
// top 20 is for Auction
|
||||
uint256 randomURI = getRandomNumber() % nfts.length - 20;
|
||||
dco2sc.safeMint(msg.sender, nfts[randomURI]);
|
||||
removeNFTAt(randomURI);
|
||||
// Require remove the URI so that is not mintable again
|
||||
airdropped[msg.sender] = true;
|
||||
}
|
||||
|
||||
// @notice adds addresses to the eligible list
|
||||
// thanks for supporting DECA
|
||||
function inviteEligible(address supporter) public onlyOwner {
|
||||
require(!airdropped[msg.sender], "account already airdropped");
|
||||
eligible[supporter] = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,6 +78,13 @@ contract AA is Ownable {
|
|||
randomNumber = block.prevrandao;
|
||||
}
|
||||
|
||||
// @notice removes NFT URI from index
|
||||
function removeNFTAt(uint index) public {
|
||||
require(index < nfts.length, "nft index out of bounds");
|
||||
nfts[index] = nfts[nfts.length - 1];
|
||||
nfts.pop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue