Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brean review #2

Open
wants to merge 31 commits into
base: init
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c5020bb
Add deploy + contract additions
nickkatsios Oct 30, 2023
6b9f040
Remove redundant folder
nickkatsios Oct 31, 2023
2b4cb8c
Add cumulative deposit bdv, first deposit season and individual depos…
nickkatsios Nov 2, 2023
eb158ed
Add csv extraction
nickkatsios Nov 2, 2023
3dabbda
Add AddressHasBeaNFT criteria + cleanup
nickkatsios Nov 2, 2023
5ade609
Add way to get total count of Bean nfts from wallet
nickkatsios Nov 2, 2023
87b0eca
Order initially qualified deposits by season to get the first season …
nickkatsios Nov 3, 2023
fb6000a
Add remove deposit seasons cummulative removed bdv , preliminary filt…
nickkatsios Nov 3, 2023
9b3bb30
Final filtering for qualified deposits
nickkatsios Nov 3, 2023
02a4b5c
remove accounts with 0 deposits
nickkatsios Nov 3, 2023
5c9a110
Add qualified account csv + code for individual deposit csv
nickkatsios Nov 3, 2023
22b4bca
Contract compilation + deployment
nickkatsios Nov 3, 2023
c57e45c
update dependencies
nickkatsios Nov 3, 2023
7dbd291
contract tests
nickkatsios Nov 4, 2023
c4a024f
Upgrade tests and natspec
nickkatsios Nov 4, 2023
c098deb
Upgraded base uri , more tests
nickkatsios Nov 5, 2023
7262b39
Add gas reporter
nickkatsios Nov 5, 2023
6f2ee96
Update query process and add transfer test
nickkatsios Nov 6, 2023
d9b113e
gas reports
nickkatsios Nov 6, 2023
abb47f5
transferOwnership test
nickkatsios Nov 7, 2023
08613ca
Add individaual collection beanft count per account
nickkatsios Nov 7, 2023
fa7ccb4
add upgrade script for future use
nickkatsios Nov 8, 2023
72d2d8d
Add realistic gas report
nickkatsios Nov 8, 2023
c8398cc
Add baseURI + configs for deployment
nickkatsios Nov 8, 2023
b35f538
Add upgrade nft script
nickkatsios Nov 8, 2023
94ecde4
Add upgraded base uri
nickkatsios Nov 9, 2023
4821622
Sepolia deployment
nickkatsios Nov 9, 2023
59e27a0
upgrade ipfs urls to point to new collection
nickkatsios Nov 10, 2023
0758b94
delete old deployment addresses
nickkatsios Nov 12, 2023
b8f6c70
fix failing tests due to prev baseURI
nickkatsios Nov 13, 2023
339de08
Merge branch 'main' into brean-review
Brean0 Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ typechain-types
# Hardhat files
cache
artifacts

.vscode
node_modules
196 changes: 196 additions & 0 deletions contracts/ERC721ABeanBasin.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// SPDX-License-Identifier: MIT
// Code adopted and modified from:
// Chiru labs: ERC721AUpsgradable v4.2.3
Brean0 marked this conversation as resolved.
Show resolved Hide resolved

pragma solidity ^0.8.20;

import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
import 'erc721a-upgradeable/contracts/ERC721AUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

/*
* ERC721A Bean Basin
* Contracts for the Basin NFT collection
* Minted to users who deposited >1000 bdv in the 600 seasons
* post basin deployment
* NFTs are batch minted to addresses on initialization
* No need for a mint function
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
*/
contract ERC721ABeanBasin is ERC721AUpgradeable, OwnableUpgradeable, UUPSUpgradeable {

// Mapping to mark token upgrades after 1800 seasons of deposit holding
// after basin deployment
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
mapping(uint256 => bool) public tokenUpgraded;
Brean0 marked this conversation as resolved.
Show resolved Hide resolved

/*
* @param name_ string name of the NFT
* @param symbol_ string symbol of the NFT
* @param addresses_ array of addresses to mint to
* @param amt_ array of amounts to mint to each address
* Upon initialization, the contract will mint the NFTs to the addresses provided
*/
function initialize(string memory name_, string memory symbol_,address[] calldata addresses_, uint256[] calldata amounts_) initializerERC721A initializer public {
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
__ERC721A_init(name_, symbol_);
__Ownable_init(msg.sender);
__batchMintAllInit(addresses_,amounts_);
}

/*
* Perform an upgrade of an ERC1967Proxy, when this contract
* is set as the implementation behind such a proxy.
* The _authorizeUpgrade function must be overridden
* to include access restriction to the upgrade mechanism.
*/
function _authorizeUpgrade(address) internal override onlyOwner {}

/*
* @dev __batchMintAllInit function used to mint NFT(s) to addresses
* @param addresses_ array of addresses to mint to
* @param amt_ array of amounts to mint to each address
* This function can only be called on initialization of the contract
*
* _mintERC2309 mints `quantity` tokens and transfers them to `to`.
*
* It emits only one {ConsecutiveTransfer} as defined in
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
* instead of a sequence of {Transfer} event(s).
*/
function __batchMintAllInit(address[] calldata addresses, uint256[] calldata amount) internal onlyInitializingERC721A{
// check that length of addresses == length of amount
require(addresses.length == amount.length, "ERC721ABeanBasin: length of addresses != length of amounts to mint");

for(uint256 i; i < addresses.length; ++i){
_mintERC2309(addresses[i], amount[i]);
}
}

/*
* @dev baseURI function used to return the IPFS baseURI for the metadata
* @return string baseURI of the NFT
*/
function baseURI() public view returns (string memory) {
return _baseURI();
}

function _baseURI() internal view virtual override returns (string memory) {
return 'ipfs://QmT5roBqPD9cQX8pPFVmLygGPBdw3gY2azqYDeCT6YHsnw/';
}

/*
* @dev baseURI function used to return the IPFS baseURI for the metadata
* @return string baseURI of the NFT
*/
function upgradedBaseURI() public view returns (string memory) {
return _upgradedBaseURI();
}


function _upgradedBaseURI() internal view virtual returns (string memory) {
return 'ipfs://QmXQd2bpwZTtDst3eaGcCHEv13yzanbKsBuvuZhzXKs15a/';
}

/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

if (tokenUpgraded[tokenId]) {
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
// return upgraded tokenURI with easter egg
string memory __upgradedBaseURI = _upgradedBaseURI();
return bytes(__upgradedBaseURI).length != 0 ? string(abi.encodePacked(__upgradedBaseURI, _toString(tokenId),".json")) : '';
} else {
string memory __baseURI = _baseURI();
return bytes(__baseURI).length != 0 ? string(abi.encodePacked(__baseURI, _toString(tokenId),".json")) : '';
}
}

/*
* @dev exists function used to check if a tokenId exists
* @param tokenId uint256 tokenId of NFT to check
* @return bool true if exists, false if not
*/
function exists(uint256 tokenId) public view returns (bool) {
return _exists(tokenId);
}

Brean0 marked this conversation as resolved.
Show resolved Hide resolved
/*
* @dev burn function used to burn NFT(s)
* @param tokenId uint256 tokenId of NFT to burn
*/
function burn(uint256 tokenId) public {
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
_burn(tokenId);
}

/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function burn(uint256 tokenId, bool approvalCheck) public {
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
_burn(tokenId, approvalCheck);
}

/*
* @dev upgradeNFTs function used to mark NFTs as upgraded
* Upgraded nfts with easter egg will have a different tokenURI
* Farmers will get an upgrade if they held their
* BEANETH Deposit for 1000+ seasons
* @param tokenIds array of tokenIds to mark as upgraded
*/
function upgradeNFTs(uint256[] calldata tokenIds) public onlyOwner {
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
for(uint256 i; i < tokenIds.length; ++i){
tokenUpgraded[tokenIds[i]] = true;
}
}

/**
* Returns the number of tokens minted by `owner`.
*/
function numberMinted(address owner) public view returns (uint256) {
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
return _numberMinted(owner);
}

/**
* @dev Returns the total amount of tokens minted in the contract.
*/
function totalMinted() public view returns (uint256) {
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
return _totalMinted();
}


/**
* @dev Returns the total number of tokens burned.
*/
function totalBurned() public view returns (uint256) {
return _totalBurned();
}

/**
* @dev Returns the next token ID to be minted.
*/
function nextTokenId() public view returns (uint256) {
return _nextTokenId();
}

/**
* Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function getAux(address owner) public view returns (uint64) {
return _getAux(owner);
}

/**
* Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function setAux(address owner, uint64 aux) public {
_setAux(owner, aux);
Brean0 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add a mint function (called only by the owner), in case we missed an address.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in: 87c821a

72 changes: 72 additions & 0 deletions contracts/MockBatchMint.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: MIT
// Code adopted and modified from:
// Chiru labs: ERC721AUpsgradable v4.2.3
Brean0 marked this conversation as resolved.
Show resolved Hide resolved

pragma solidity ^0.8.20;

import 'erc721a-upgradeable/contracts/ERC721AUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";


/*
* ERC721A Bean Basin
* Contracts for the Basin NFT collection
* Minted to users who deposited >1000 bdv in the 600 seasons
* post basin deployment
* NFTs are batch minted to addresses on initialization
* No need for a mint function
*/
contract MockBatchMint is ERC721AUpgradeable, OwnableUpgradeable, UUPSUpgradeable {
Brean0 marked this conversation as resolved.
Show resolved Hide resolved

// Mapping to mark token upgrades after 1000 seasons of deposit holding
mapping(uint256 => bool) public tokenUpgraded;

/*
* @param name_ string name of the NFT
* @param symbol_ string symbol of the NFT
* @param addresses_ array of addresses to mint to
* @param amt_ array of amounts to mint to each address
* Upon initialization, the contract will mint the NFTs to the addresses provided
*/
function initialize(string memory name_, string memory symbol_) initializerERC721A initializer public {
__ERC721A_init(name_, symbol_);
__Ownable_init(msg.sender);
}

/*
* Perform an upgrade of an ERC1967Proxy, when this contract
* is set as the implementation behind such a proxy.
* The _authorizeUpgrade function must be overridden
* to include access restriction to the upgrade mechanism.
*/
function _authorizeUpgrade(address) internal override onlyOwner {}

/*
* @dev __batchMintAllInit function used to mint NFT(s) to addresses
* @param addresses_ array of addresses to mint to
* @param amt_ array of amounts to mint to each address
* This function can only be called on initialization of the contract
*
* _mintERC2309 mints `quantity` tokens and transfers them to `to`.
*
* It emits only one {ConsecutiveTransfer} as defined in
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
* instead of a sequence of {Transfer} event(s).
*/
function __batchMintAllInit(address[] calldata addresses, uint256[] calldata amount) public {
// check that length of addresses == length of amount
require(addresses.length == amount.length, "MockBatchMint: length of addresses != length of amounts to mint");

for(uint256 i; i < addresses.length; ++i){
_mintERC2309(addresses[i], amount[i]);
}
}

/**
* @dev Returns the next token ID to be minted.
*/
function nextTokenId() public view returns (uint256) {
return _nextTokenId();
}
}
Loading