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

bulk mint & uri update added #37

Merged
merged 20 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions contracts/AppNFTUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,15 @@ contract AppNFTUpgradeable is Initializable, ERC721Upgradeable, ERC721Enumerable
/**
* @dev Mint multiple NFTs and assign them to a specified address.
* @param to The address to assign the minted NFTs to.
* @param appNames An array of app names to use for the NFTs.
* @param names An array of names to use for the NFTs.
* @param uris An array of URIs to use for the NFTs.
*/
function bulkMintAndURIupdate(address[] calldata to, uint256[] calldata tokenIds, string[] calldata appNames, string[] calldata uris) external onlyOwner {
uint256 quantity = appNames.length;
require(quantity == uris.length, "appNames and uris length mismatch");
for (uint256 i = 0; i < appNames.length; i++) {
function bulkMintAndURIupdate(address[] calldata to, uint256[] calldata tokenIds, string[] calldata names, string[] calldata uris) external onlyOwner {
uint256 quantity = tokenIds.length;
require(quantity == uris.length, "tokenIds and uris length mismatch");
for (uint256 i = 0; i < tokenIds.length; i++) {
if(tokenIds[i] == 0){
mint(to[i], uris[i], appNames[i]);
mint(to[i], uris[i], names[i]);
} else {
_setTokenURI(tokenIds[i], uris[i]);
}
Expand Down
31 changes: 31 additions & 0 deletions contracts/AppStoreNFTUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,37 @@ contract AppStoreNFTUpgradeable is Initializable, ERC721Upgradeable, ERC721Enume
require(_to.send(amount), 'Fee Transfer to Owner failed.');
}

/**
* @dev Mint multiple NFTs and assign them to a specified address.
* @param to The address to assign the minted NFTs to.
* @param names An array of names to use for the NFTs.
* @param uris An array of URIs to use for the NFTs.
*/
function bulkMintAndURIupdate(address[] calldata to, uint256[] calldata tokenIds, string[] calldata names, string[] calldata uris) external onlyOwner {
uint256 quantity = tokenIds.length;
require(quantity == uris.length, "tokenIds and uris length mismatch");
for (uint256 i = 0; i < tokenIds.length; i++) {
if(tokenIds[i] == 0){
mint(to[i], uris[i], names[i]);
} else {
_setTokenURI(tokenIds[i], uris[i]);
}
}
}

/**
* @dev Transfer multiple NFTs from one address to another.
* @param to The address to transfer the NFTs to.
* @param tokenIds An array of token IDs to transfer.
*/
function bulkTransfer(address to, uint256[] calldata tokenIds) external {
for (uint256 i = 0; i < tokenIds.length; i++) {
uint256 tokenId = tokenIds[i];
require(_isApprovedOrOwner(_msgSender(), tokenId), "Caller is not owner nor approved");
_transfer(_msgSender(), to, tokenId);
}
}

/**
* @notice function to set trusted forwarder
* @dev only owner can call this function
Expand Down
31 changes: 31 additions & 0 deletions contracts/DevNFTUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,37 @@ contract DevNFTUpgradeable is Initializable, ERC721Upgradeable, ERC721Enumerable
require(_to.send(amount), 'Fee Transfer to Owner failed.');
}

/**
* @dev Mint multiple NFTs and assign them to a specified address.
* @param to The address to assign the minted NFTs to.
* @param names An array of names to use for the NFTs.
* @param uris An array of URIs to use for the NFTs.
*/
function bulkMintAndURIupdate(address[] calldata to, uint256[] calldata tokenIds, string[] calldata names, string[] calldata uris) external onlyOwner {
uint256 quantity = tokenIds.length;
require(quantity == uris.length, "tokenIds and uris length mismatch");
for (uint256 i = 0; i < tokenIds.length; i++) {
if(tokenIds[i] == 0){
mint(to[i], uris[i], names[i]);
} else {
_setTokenURI(tokenIds[i], uris[i]);
}
}
}

/**
* @dev Transfer multiple NFTs from one address to another.
* @param to The address to transfer the NFTs to.
* @param tokenIds An array of token IDs to transfer.
*/
function bulkTransfer(address to, uint256[] calldata tokenIds) external {
for (uint256 i = 0; i < tokenIds.length; i++) {
uint256 tokenId = tokenIds[i];
require(_isApprovedOrOwner(_msgSender(), tokenId), "Caller is not owner nor approved");
_transfer(_msgSender(), to, tokenId);
}
}

/**
* @notice function to set trusted forwarder
* @dev only owner can call this function
Expand Down
1 change: 1 addition & 0 deletions scripts/upgradeDevProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var file = require("./config.json");
async function main() {
const DevNFT = await ethers.getContractFactory("DevNFTUpgradeable");
const devNFT = await upgrades.upgradeProxy(file.DevNFTUpgradeable, DevNFT, [
file.DappNameList,
process.env.TRUSTED_FORWARDER_ADDRESS,
]);
console.log("DevNFT upgraded", devNFT);
Expand Down
Loading