Skip to content

Commit

Permalink
add total supply to Post NFT ERC-1155
Browse files Browse the repository at this point in the history
  • Loading branch information
tempe-techie committed Feb 5, 2024
1 parent 36ae677 commit ccb0a94
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 29 deletions.
3 changes: 3 additions & 0 deletions contracts/post/IggyPostNft1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ contract IggyPostNft1155 is ERC1155, OwnableWithManagers, ReentrancyGuard {
uint256 public counter = 1; // id counter, starts with 1
uint256 public defaultPrice; // default price for minting a post
uint256 public maxTextPreviewLength = 243; // max length of the text preview
uint256 public totalSupply; // total supply of NFTs

string public name;
string public symbol;
Expand Down Expand Up @@ -146,6 +147,8 @@ contract IggyPostNft1155 is ERC1155, OwnableWithManagers, ReentrancyGuard {

_mint(_nftReceiver, tokenId, _quantity, "");

totalSupply += _quantity;

emit MintPost(_nftReceiver, _postId, _author, _quantity);
}

Expand Down
19 changes: 18 additions & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,20 @@ module.exports = {
gas: "auto", // gas limit
gasPrice: 125000000000, // 125 gwei
},
taikoJolnir: { // Taiko testnet (L2)
taikoJolnir: { // Taiko Jolnir testnet (L2)
url: 'https://rpc.jolnir.taiko.xyz',
chainId: 167007,
accounts: [process.env.DEPLOYER_PRIVATE_KEY],
gas: "auto", // gas limit
gasPrice: 1000000000, // 1 gwei
},
taikoKatla: { // Taiko Katla testnet (L2)
url: 'https://rpc.katla.taiko.xyz',
chainId: 167008,
accounts: [process.env.DEPLOYER_PRIVATE_KEY],
gas: "auto", // gas limit
gasPrice: 1000000000, // 1 gwei
},
zkfair: { // zkFair mainnet
url: 'https://rpc.zkfair.io',
chainId: 42766,
Expand Down Expand Up @@ -243,6 +250,7 @@ module.exports = {
sokol: "randomstring",
songbird: "randomstring",
taikoJolnir: "42069",
taikoKatla: "42069",
zkfair: "randomstring"
},
customChains: [
Expand Down Expand Up @@ -372,6 +380,15 @@ module.exports = {
browserURL: "https://explorer.jolnir.taiko.xyz/"
}
},
{
network: "taikoKatla",
chainId: 167008,
urls: {
//apiURL: "https://api.routescan.io/v2/network/testnet/evm/167007/etherscan",
apiURL: "https://explorer.katla.taiko.xyz/api",
browserURL: "https://explorer.katla.taiko.xyz/"
}
},
{
network: "zkfair",
chainId: 42766,
Expand Down
2 changes: 1 addition & 1 deletion scripts/distributor/distributorFactory.deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// npx hardhat run scripts/distributor/distributorFactory.deploy.js --network bsc
// npx hardhat run scripts/distributor/distributorFactory.deploy.js --network scroll

const contractName = "RevenueDistributorFactory";

Expand Down
19 changes: 19 additions & 0 deletions scripts/distributor/other/verifyDistributor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// TODO:
// 1. Create the first NFT collection through the factory.
// 2. Verify the contract on block explorer using this script (run the command below).
// Run: npx hardhat run scripts/distributor/other/verifyDistributor.js --network scroll

const contractAddress = "0x0E66249733DDFe422F7A127B0b9E906601F23E06";

async function main() {
console.log("Copy the line below and paste it in your terminal to verify the TLD contract on Etherscan:");
console.log("");
console.log("npx hardhat verify --network " + network.name + " " + contractAddress);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
8 changes: 4 additions & 4 deletions scripts/launchpad/erc721/3_launchpadBonding.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

const contractName = "IggyLaunchpad721Bonding";

const metadataAddress = "0xc486B08Ed47fFe5c1b4b1A2ff5c671EA0083D9bA";
const mintingFeeReceiver = "0x6771F33Cfd8C6FC0A1766331f715f5d2E1d4E0e2"; // revenue distributor contract address
const directoryAddress = "0x6AbDd1Bf5078cC6b0D75caFCdDC69A8339067F50";
const statsMiddlewareAddress = "0xce314209aB485bE222CE85F653Ac918f54532503";
const metadataAddress = "";
const mintingFeeReceiver = ""; // revenue distributor contract address
const directoryAddress = "";
const statsMiddlewareAddress = "";
const mintingFeePercentage = ethers.utils.parseEther("0.02");
const price = ethers.utils.parseEther("0.0001"); // price for creating a new NFT collection

Expand Down
10 changes: 5 additions & 5 deletions scripts/post/IggyPostNft1155/1_metadata.deploy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// 1. Deploy metadata contract
// npx hardhat run scripts/post/IggyPostNft1155/1_metadata.deploy.js --network taikoJolnir
// npx hardhat run scripts/post/IggyPostNft1155/1_metadata.deploy.js --network scroll

const contractName = "IggyPostMetadata";

const mdName = "TKO Chat Post";
const description = "TKO.chat is the first decentralized social network on Taiko testnet. Go visit here: https://tko.chat/";
const url = "https://tko.chat/post/";
const tldAddress = "0x4087fb91A1fBdef05761C02714335D232a2Bf3a1";
const mdName = "Scrolly Post";
const description = "Scrolly Hub is a web3 place for all-things around the Scrolly web3 community. Go visit here: https://hub.scrolly.xyz/";
const url = "https://hub.scrolly.xyz/post/";
const tldAddress = "0xc2C543D39426bfd1dB66bBde2Dd9E4a5c7212876";

async function main() {
const [deployer] = await ethers.getSigners();
Expand Down
8 changes: 4 additions & 4 deletions scripts/post/IggyPostNft1155/2_iggyPostNft1155.deploy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// 2. Deploy NFT contract
// npx hardhat run scripts/post/IggyPostNft1155/2_iggyPostNft1155.deploy.js --network taikoJolnir
// npx hardhat run scripts/post/IggyPostNft1155/2_iggyPostNft1155.deploy.js --network scroll

const contractName = "IggyPostNft1155";

const defaultPrice = ethers.utils.parseEther("0.0001"); // TODO: change price!!!
const metadataAddress = "0x633Ae857445cF0cd02B21C6a3033C7CE74fB32c2";
const collectionName = "TKO Chat Posts";
const collectionSymbol = "TKOCHATPOST";
const metadataAddress = "0xa6b7116A5b6eF4e1336980dF4FB162eeBC38b766";
const collectionName = "Scrolly Posts";
const collectionSymbol = "SCROLLYPOST";

async function main() {
const [deployer] = await ethers.getSigners();
Expand Down
12 changes: 6 additions & 6 deletions scripts/post/IggyPostNft1155/3_minter.deploy.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// 3. Deploy minter contract
// npx hardhat run scripts/post/IggyPostNft1155/3_minter.deploy.js --network taikoJolnir
// npx hardhat run scripts/post/IggyPostNft1155/3_minter.deploy.js --network scroll

const contractName = "IggyPostMinter";

const daoAddress = "0x6771F33Cfd8C6FC0A1766331f715f5d2E1d4E0e2"; // distributor contract
const devAddress = "0x6771F33Cfd8C6FC0A1766331f715f5d2E1d4E0e2"; // iggy address
const postAddress = "0x06A7Ab7Bb68b0ad6eB7688C5781E60BE6AFc658d";
const daoAddress = "0x0E66249733DDFe422F7A127B0b9E906601F23E06"; // distributor contract
const devAddress = "0xE08033d0bDBcEbE7e619c3aE165E7957Ab577961"; // iggy address
const postAddress = "0xa9cfa4e8EA79537F5893f45c3B1491A2f7B54e7E";

const daoFee = 2000; // 10%
const devFee = 0; // 10%
const daoFee = 1000; // 10%
const devFee = 1000; // 10%
const refFee = 1000; // 10%

const postInterface = new ethers.utils.Interface([
Expand Down
4 changes: 2 additions & 2 deletions scripts/post/IggyPostNft1155/4_stats.deploy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// 4. Deploy stats contract
// npx hardhat run scripts/post/IggyPostNft1155/4_stats.deploy.js --network taikoJolnir
// npx hardhat run scripts/post/IggyPostNft1155/4_stats.deploy.js --network scroll

const contractName = "IggyPostStats";

const minterAddress = "0x5e54CebB2612744cB56547bC7CC41466ad7ac557";
const minterAddress = "0xeb485A72393728990264EeE32e8098E6Da94cE01";
const shouldStatsBeEnabled = true;

const minterInterface = new ethers.utils.Interface([
Expand Down
8 changes: 4 additions & 4 deletions scripts/swap/IggySwapRouter.deploy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// npx hardhat run scripts/swap/IggySwapRouter.deploy.js --network taikoJolnir
// npx hardhat run scripts/swap/IggySwapRouter.deploy.js --network taikoKatla

const contractName = "IggySwapRouter";

const iggyAddress = "0x6771F33Cfd8C6FC0A1766331f715f5d2E1d4E0e2"; // mandatory
const routerAddress = "0xE4f7776c753aF46D2aa23e3348d17548C86DC47D"; // mandatory
const iggyAddress = ""; // mandatory
const routerAddress = ""; // mandatory
const frontendAddress = ethers.constants.AddressZero; // optional
const stakingAddress = ethers.constants.AddressZero; // optional
const statsAddress = ethers.constants.AddressZero; // stats middleware address (optional)
const statsAddress = ""; // stats middleware address (optional)

const swapFee = 80; // 0.8%
const stakingShare = 4000; // bps
Expand Down
22 changes: 20 additions & 2 deletions test/post/iggyPostNft1155.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,17 @@ describe("IggyPostNft1155", function () {
// get author's ETH balance before
const authorEthBalanceBefore = await author.getBalance();

//return;

// check dao ETH balance before
const daoEthBalanceBefore = await dao.getBalance();

// check dev ETH balance before
const devEthBalanceBefore = await dev.getBalance();

// check NFT total supply before
const totalSupplyBefore = await iggyPostContract.totalSupply();
expect(totalSupplyBefore).to.equal(0);
console.log("Total supply before:", totalSupplyBefore.toString());

// mint through the minter contract
const tx = await minterContract.connect(user1).mint(
postId, // post ID
Expand All @@ -161,6 +164,11 @@ describe("IggyPostNft1155", function () {
const receipt = await tx.wait();
calculateGasCosts("mintOneNftDefaultPrice", receipt);

// check NFT total supply after
const totalSupplyAfter = await iggyPostContract.totalSupply();
expect(totalSupplyAfter).to.equal(1);
console.log("Total supply after:", totalSupplyAfter.toString());

// check user1 balance after
const user1BalanceAfter = await iggyPostContract.balanceOf(user1.address, tokenId);
expect(user1BalanceAfter).to.equal(quantityOne);
Expand Down Expand Up @@ -262,6 +270,11 @@ describe("IggyPostNft1155", function () {
// check dev ETH balance before
const devEthBalanceBefore = await dev.getBalance();

// check NFT total supply before
const totalSupplyBefore = await iggyPostContract.totalSupply();
expect(totalSupplyBefore).to.equal(0);
console.log("Total supply before:", totalSupplyBefore.toString());

// mint through the minter contract
const tx = await minterContract.connect(user1).mint(
postId, // post ID
Expand All @@ -279,6 +292,11 @@ describe("IggyPostNft1155", function () {
const receipt = await tx.wait();
calculateGasCosts("mintMultipleNftsDefaultPrice", receipt);

// check NFT total supply after 1
const totalSupplyAfter1 = await iggyPostContract.totalSupply();
expect(totalSupplyAfter1).to.equal(quantityMultiple);
console.log("Total supply after 1:", totalSupplyAfter1.toString());

// check user1 balance after
const user1BalanceAfter = await iggyPostContract.balanceOf(user1.address, tokenId);
expect(user1BalanceAfter).to.equal(quantityMultiple);
Expand Down

0 comments on commit ccb0a94

Please sign in to comment.