Merge pull request 'develop' (#1) from p1r0/DECANFT-SC:develop into develop
Reviewed-on: #1
This commit is contained in:
commit
1d77c57534
|
@ -1,5 +1,5 @@
|
||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity ^0.8.13;
|
pragma solidity ^0.8.23;
|
||||||
|
|
||||||
import {Script, console2} from "forge-std/Script.sol";
|
import {Script, console2} from "forge-std/Script.sol";
|
||||||
import { DCO2s } from "src/DCO2s.sol";
|
import { DCO2s } from "src/DCO2s.sol";
|
||||||
|
|
62
src/AA.sol
62
src/AA.sol
|
@ -9,7 +9,7 @@ contract AA is Ownable {
|
||||||
string[] nfts;
|
string[] nfts;
|
||||||
|
|
||||||
mapping (address => bool) public airdropped;
|
mapping (address => bool) public airdropped;
|
||||||
address[] public allowed;
|
mapping (address => bool) public eligible;
|
||||||
|
|
||||||
constructor(string memory name,
|
constructor(string memory name,
|
||||||
string memory symbol,
|
string memory symbol,
|
||||||
|
@ -28,36 +28,47 @@ contract AA is Ownable {
|
||||||
|
|
||||||
// Mint Function
|
// Mint Function
|
||||||
// Simplify
|
// Simplify
|
||||||
function _mint(address to, string memory uri) public onlyOwner {
|
function mintNFT(address to, uint index) external onlyOwner {
|
||||||
dco2sc.safeMint(to, uri);
|
require(!airdropped[to], "account already airdropped");
|
||||||
|
dco2sc.safeMint(to, nfts[index]);
|
||||||
|
removeNFTAt(index);
|
||||||
|
airdropped[to] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @notice Random giveaway function
|
// @Notice Check if eligible
|
||||||
function airdrop() public {
|
function checkIfEligible() public view returns (bool winner) {
|
||||||
//require(eligible(msg.sender));
|
if (airdropped[msg.sender] == true) {
|
||||||
require(!airdropped[msg.sender], "address already airdropped");
|
winner = false;
|
||||||
// top 20 is for Auction
|
} else if (eligible[msg.sender] == true) {
|
||||||
uint256 randomURI = getRandomNumber() % nfts.length - 20;
|
winner = true;
|
||||||
dco2sc.safeMint(msg.sender, nfts[randomURI]);
|
} else {
|
||||||
// Require remove the URI so that is not mintable again
|
winner = false;
|
||||||
airdropped[msg.sender] = true;
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// @eligible
|
|
||||||
function eligible(address to) public view returns (bool winner) {
|
|
||||||
// require( callable until specific date)
|
// require( callable until specific date)
|
||||||
// Activity
|
// Activity
|
||||||
// Longest Holders
|
// Longest Holders
|
||||||
// Top Holders
|
// Top Holders
|
||||||
// or Allowed Wallets()
|
// or Allowed Wallets()
|
||||||
|
return winner;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @notice allowed addresses that supports DECA
|
// @notice Random giveaway function
|
||||||
function allow(address supporter) public onlyOwner {
|
function airdrop() external {
|
||||||
//require(eligible(supporter));
|
require(!airdropped[msg.sender], "account already airdropped");
|
||||||
require(!airdropped[supporter], "address already airdropped");
|
require(checkIfEligible(), "account not eligible");
|
||||||
allowed.push(supporter);
|
// 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;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,16 +20,19 @@ contract AATest is Test {
|
||||||
// @notice this code safe mints an NFT to address 0x1
|
// @notice this code safe mints an NFT to address 0x1
|
||||||
function testMint() public {
|
function testMint() public {
|
||||||
address to = address(0x1);
|
address to = address(0x1);
|
||||||
aaContract._mint(to,nfts[0]);
|
aaContract.mintNFT(to, 0);
|
||||||
console.log("hola");
|
address dco2scAddress = address(aaContract.dco2sc());
|
||||||
|
console.log("{}",dco2scAddress);
|
||||||
//assertEq(aaContract.ownerOf(0), to, "Token should be minted to specified address.");
|
//assertEq(aaContract.ownerOf(0), to, "Token should be minted to specified address.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// @notice: here we test getting the Base and full URIS
|
// Test mint all NFTs but -20
|
||||||
//function testGetURI68() public {
|
|
||||||
// aaContract._mint(address(0x1), nfts[68]);
|
// Test Invite Eligible
|
||||||
// string memory tokenURI = aaContract.tokenURI(0);
|
|
||||||
// console.log(tokenURI);
|
// test Check If Eligible
|
||||||
// assertEq(tokenURI, string.concat(baseURI, nfts[68]));
|
|
||||||
//}
|
// Test Airdrop
|
||||||
|
|
||||||
|
// Test Others
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue