From 2e561f6f3c028f1240f9d52c47b0b05ed4167e4c Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron R." Date: Wed, 27 Dec 2023 20:04:52 -0600 Subject: [PATCH 1/3] Add some more logic and fix previous issues --- src/AA.sol | 62 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/src/AA.sol b/src/AA.sol index a014c52..1b6dbbb 100644 --- a/src/AA.sol +++ b/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(); + } + } From 1dc6fea59145f60fb6436d639f81b159b4efca55 Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron R." Date: Wed, 27 Dec 2023 20:05:41 -0600 Subject: [PATCH 2/3] Add mint by index and some ToDo Tests --- test/AA.t.sol | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/AA.t.sol b/test/AA.t.sol index 5ed08c7..c23b38f 100644 --- a/test/AA.t.sol +++ b/test/AA.t.sol @@ -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 } From f5f2a42c2a5be234c9feaf73c0adeb17ac521b71 Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron R." Date: Wed, 10 Apr 2024 19:40:29 -0600 Subject: [PATCH 3/3] Update solidity script version --- script/DCO2s.s.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/DCO2s.s.sol b/script/DCO2s.s.sol index ea028bc..7b82747 100644 --- a/script/DCO2s.s.sol +++ b/script/DCO2s.s.sol @@ -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";