Merge pull request 'develop' (#1) from p1r0/DECANFT-SC:develop into develop

Reviewed-on: #1
This commit is contained in:
p1r0 2024-04-11 01:47:54 +00:00
commit 1d77c57534
3 changed files with 53 additions and 32 deletions

View File

@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.23;
import {Script, console2} from "forge-std/Script.sol";
import { DCO2s } from "src/DCO2s.sol";

View File

@ -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();
}
}

View File

@ -20,16 +20,19 @@ contract AATest is Test {
// @notice this code safe mints an NFT to address 0x1
function testMint() public {
address to = address(0x1);
aaContract._mint(to,nfts[0]);
console.log("hola");
aaContract.mintNFT(to, 0);
address dco2scAddress = address(aaContract.dco2sc());
console.log("{}",dco2scAddress);
//assertEq(aaContract.ownerOf(0), to, "Token should be minted to specified address.");
}
// Test mint all NFTs but -20
// @notice: here we test getting the Base and full URIS
//function testGetURI68() public {
// aaContract._mint(address(0x1), nfts[68]);
// string memory tokenURI = aaContract.tokenURI(0);
// console.log(tokenURI);
// assertEq(tokenURI, string.concat(baseURI, nfts[68]));
//}
// Test Invite Eligible
// test Check If Eligible
// Test Airdrop
// Test Others
}