From f9167be6635c505e439c7b6d3326d63d2502d31a Mon Sep 17 00:00:00 2001 From: Kai Kang Date: Fri, 12 Apr 2024 19:26:21 +0800 Subject: [PATCH] MOD: nft min price --- contracts/aime/AIMeFactoryV4.sol | 21 +- .../AIMePowerFairLaunchV2.spec.ts | 122 ++-- test/AIMeFactoryV4.spec.ts | 659 ++++++++++++++++++ 3 files changed, 735 insertions(+), 67 deletions(-) rename {test => test-archived}/AIMePowerFairLaunchV2.spec.ts (82%) create mode 100644 test/AIMeFactoryV4.spec.ts diff --git a/contracts/aime/AIMeFactoryV4.sol b/contracts/aime/AIMeFactoryV4.sol index 94445ae..7ad7d27 100644 --- a/contracts/aime/AIMeFactoryV4.sol +++ b/contracts/aime/AIMeFactoryV4.sol @@ -25,13 +25,14 @@ contract AIMeFactoryV4 is Ownable { protocolFee = _protocolFee; } - function createAIME( + function createAIMeVerified( string memory name_, string memory avatar_, string memory bio_, string memory image_, string memory socialKey_, string memory socialId_, + uint256 minPrice_, uint256 priceIncrement_, address aimePowerAddress, bytes memory signature @@ -45,11 +46,14 @@ contract AIMeFactoryV4 is Ownable { avatar_, bio_, image_, - socialKey_, - socialId_, - priceIncrement_, - aimePowerAddress, - addressNonce[msg.sender] + abi.encodePacked( + socialKey_, + socialId_, + minPrice_, + priceIncrement_, + aimePowerAddress, + addressNonce[msg.sender] + ) ) ) ); @@ -64,6 +68,7 @@ contract AIMeFactoryV4 is Ownable { avatar_, bio_, image_, + minPrice_, priceIncrement_, protocolSigner, aimePowerAddress @@ -86,6 +91,7 @@ contract AIMeFactoryV4 is Ownable { string memory avatar_, string memory bio_, string memory image_, + uint256 minPrice_, uint256 priceIncrement_, address aimeSigner, address aimePowerAddress @@ -95,6 +101,7 @@ contract AIMeFactoryV4 is Ownable { avatar_, bio_, image_, + minPrice_, priceIncrement_, aimeSigner, aimePowerAddress @@ -106,6 +113,7 @@ contract AIMeFactoryV4 is Ownable { string memory avatar_, string memory bio_, string memory image_, + uint256 minPrice_, uint256 priceIncrement_, address aimeSigner, address aimePowerAddress @@ -119,6 +127,7 @@ contract AIMeFactoryV4 is Ownable { avatar_, bio_, image_, + minPrice_, priceIncrement_, aimePowerAddress ); diff --git a/test/AIMePowerFairLaunchV2.spec.ts b/test-archived/AIMePowerFairLaunchV2.spec.ts similarity index 82% rename from test/AIMePowerFairLaunchV2.spec.ts rename to test-archived/AIMePowerFairLaunchV2.spec.ts index 26bf947..824f563 100644 --- a/test/AIMePowerFairLaunchV2.spec.ts +++ b/test-archived/AIMePowerFairLaunchV2.spec.ts @@ -246,67 +246,67 @@ describe("AimePowerFairLaunchV2", () => { // }); // }); - describe("launch start", () => { - it("can start after all minted", async () => { - await signer2.sendTransaction({ - to: aimePowerFairLaunchV2.address, - value: price.mul(3), - }); - - const minted = await aimePowerFairLaunchV2.minted(); - const mintLimit = await aimePowerFairLaunchV2.mintLimit(); - console.log("minted:", minted.toString()); - expect(minted).to.be.eq(mintLimit); - - const wethBalanceBefore = await wethContract.balanceOf( - aimePowerFairLaunchV2.address - ); - console.log("weth balance before:", wethBalanceBefore.toString()); - - const powerBalanceBefore = await aimePowerFairLaunchV2.balanceOf( - aimePowerFairLaunchV2.address - ); - console.log("power balance before:", powerBalanceBefore.toString()); - - const ethBalanceBefore = await ethers.provider.getBalance( - aimePowerFairLaunchV2.address - ); - console.log("eth balance before:", ethBalanceBefore.toString()); - - // transfer 0 value? - const tx = await signer2.sendTransaction({ - to: aimePowerFairLaunchV2.address, - value: 0, - }); - await tx.wait(); - - const started = await aimePowerFairLaunchV2.started(); - expect(started).to.be.eq(true); - - const wethBalance = await wethContract.balanceOf( - aimePowerFairLaunchV2.address - ); - console.log("weth balance:", wethBalance.toString()); - - const powerBalance = await aimePowerFairLaunchV2.balanceOf( - aimePowerFairLaunchV2.address - ); - console.log("power balance:", powerBalance.toString()); - - const ethBalance = await ethers.provider.getBalance( - aimePowerFairLaunchV2.address - ); - console.log("eth balance before:", ethBalance.toString()); - - const pool = await aimePowerFairLaunchV2.pool(); - poolContract = IUniswapV3Pool__factory.connect(pool, owner); - const tickSpacing = await poolContract.tickSpacing(); - console.log("tickSpacing:", tickSpacing.toString()); - - const slot0 = await poolContract.slot0(); - console.log("slot0:", slot0); - }); - }); + // describe("launch start", () => { + // it("can start after all minted", async () => { + // await signer2.sendTransaction({ + // to: aimePowerFairLaunchV2.address, + // value: price.mul(3), + // }); + + // const minted = await aimePowerFairLaunchV2.minted(); + // const mintLimit = await aimePowerFairLaunchV2.mintLimit(); + // console.log("minted:", minted.toString()); + // expect(minted).to.be.eq(mintLimit); + + // const wethBalanceBefore = await wethContract.balanceOf( + // aimePowerFairLaunchV2.address + // ); + // console.log("weth balance before:", wethBalanceBefore.toString()); + + // const powerBalanceBefore = await aimePowerFairLaunchV2.balanceOf( + // aimePowerFairLaunchV2.address + // ); + // console.log("power balance before:", powerBalanceBefore.toString()); + + // const ethBalanceBefore = await ethers.provider.getBalance( + // aimePowerFairLaunchV2.address + // ); + // console.log("eth balance before:", ethBalanceBefore.toString()); + + // // transfer 0 value? + // const tx = await signer2.sendTransaction({ + // to: aimePowerFairLaunchV2.address, + // value: 0, + // }); + // await tx.wait(); + + // const started = await aimePowerFairLaunchV2.started(); + // expect(started).to.be.eq(true); + + // const wethBalance = await wethContract.balanceOf( + // aimePowerFairLaunchV2.address + // ); + // console.log("weth balance:", wethBalance.toString()); + + // const powerBalance = await aimePowerFairLaunchV2.balanceOf( + // aimePowerFairLaunchV2.address + // ); + // console.log("power balance:", powerBalance.toString()); + + // const ethBalance = await ethers.provider.getBalance( + // aimePowerFairLaunchV2.address + // ); + // console.log("eth balance before:", ethBalance.toString()); + + // const pool = await aimePowerFairLaunchV2.pool(); + // poolContract = IUniswapV3Pool__factory.connect(pool, owner); + // const tickSpacing = await poolContract.tickSpacing(); + // console.log("tickSpacing:", tickSpacing.toString()); + + // const slot0 = await poolContract.slot0(); + // console.log("slot0:", slot0); + // }); + // }); // describe("swap (after launch started)", () => { // beforeEach("mint token and launch", async () => { diff --git a/test/AIMeFactoryV4.spec.ts b/test/AIMeFactoryV4.spec.ts new file mode 100644 index 0000000..8e5cba2 --- /dev/null +++ b/test/AIMeFactoryV4.spec.ts @@ -0,0 +1,659 @@ +import { ethers } from "hardhat"; +import { AIMeFactoryV4 } from "../typechain"; +import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; +import { BigNumberish } from "ethers"; +const { expect } = require("chai"); + +export const genSig = async ( + signer: SignerWithAddress, + creatorAddress: string, + aimeAddress: string, + tokenId: BigNumberish, + key: string, + type: string, + data: string, + image: string, + amount: BigNumberish, + nounce: BigNumberish +) => { + let message = ethers.utils.solidityPack( + [ + "address", + "address", + "uint256", + "string", + "string", + "string", + "string", + "uint256", + "uint256", + ], + [ + creatorAddress, + aimeAddress, + tokenId, + key, + type, + data, + image, + amount, + nounce, + ] + ); + message = ethers.utils.solidityKeccak256(["bytes"], [message]); + const signature = await signer.signMessage(ethers.utils.arrayify(message)); + return signature; +}; + +describe("AIMe Factory and NFT Contract", () => { + let aimeFactoryContract: AIMeFactoryV4; + let owner: SignerWithAddress; + let aimeSigner: SignerWithAddress; + let signer3: SignerWithAddress; + const protocolFeeEthValue = "0.001"; + const protocolFeeCreateEthValue = "0.01"; + + beforeEach("init", async () => { + [owner, aimeSigner, signer3] = await ethers.getSigners(); + + const aimeContractFactory = await ethers.getContractFactory( + "AIMeFactoryV4" + ); + aimeFactoryContract = await aimeContractFactory.deploy(); + await aimeFactoryContract.deployed(); + + await aimeFactoryContract.updateProtocolSigner( + "0x0C5f64fDBb86F80AE5b8Bb85D8425B1c5A8b8a9b" + ); + + console.log("signer 3 address:", signer3.address); + }); + + describe("Contract deploy", () => { + it("aime contract deployed with owner", async () => { + console.log("aimeContract address", aimeFactoryContract.address); + // const aimeSigner = await aimeFactoryContract.aimeSigner(); + // expect(aimeSigner).eq(ethers.constants.AddressZero); + const ownerAddress = await owner.getAddress(); + const contractOwner = await aimeFactoryContract.owner(); + expect(contractOwner).eq(ownerAddress); + }); + + // it("owner can set signer", async () => { + // const tx = await aimeFactoryContract + // .connect(owner) + // .updateSigner(aimeSigner.address); + // await tx.wait(); + // const newSigner = await aimeFactoryContract.aimeSigner(); + // expect(newSigner).eq(aimeSigner.address); + + // await expect( + // aimeFactoryContract.connect(signer3).updateSigner(owner.address) + // ).to.be.revertedWith(`OwnableUnauthorizedAccount("${signer3.address}")`); + // }); + + it("owner can set protocol fee", async () => { + const feeBefore = await aimeFactoryContract.protocolFee(); + expect(feeBefore).eq(ethers.utils.parseEther(protocolFeeEthValue)); + + const newFee = ethers.utils.parseEther("1"); + const tx = await aimeFactoryContract + .connect(owner) + .updateProtocolFee(newFee); + await tx.wait(); + const feeAfter = await aimeFactoryContract.protocolFee(); + expect(feeAfter).eq(newFee); + + await expect( + aimeFactoryContract + .connect(signer3) + .updateProtocolFee(ethers.utils.parseEther(protocolFeeEthValue)) + ).to.be.revertedWith(`Ownable: caller is not the owner`); + }); + }); + + describe("Create AIMe", () => { + let name = "test_aime"; + let bio = "bio"; + let image = "image_url"; + let avatar = "avatar_url"; + let socialKey = "twitter"; + let socialId = "some_twitter_handle"; + let minPrice = 20; + let priceIncrement = 10; + let aimePowerAddres = "0xdAA208F5842645d9eB84C39B52194a022e3fbd99"; + + it("test signature", async () => { + const sig = + "0x7779f904a166021bce05579f31eb969b5111e20aaf101c0d7a854a2860ed57e24b91c9be04e4fa3117d747e7bac9ce6c488bfaf7702561482d88c1334a8988f01b"; + const nonce = await aimeFactoryContract.addressNonce(signer3.address); + console.log("current nonce", nonce); + const tx = await aimeFactoryContract + .connect(signer3) + .createAIMeVerified( + name, + avatar, + bio, + image, + socialKey, + socialId, + minPrice, + priceIncrement, + aimePowerAddres, + sig, + { value: ethers.utils.parseEther(protocolFeeCreateEthValue) } + ); + await tx.wait(); + }); + }); + + // describe("Create AIMe", () => { + // let name = "test_aime"; + // let key = "basic_prompt"; + // let type = "static"; + // let data = "Hello World"; + // let image = "image_url"; + // let avatar = "avatar_url"; + + // it("can not create aime for free or not enough fee", async () => { + // await expect( + // aimeFactoryContract.createAIME( + // "", + // "", + // "", + // "", + // ethers.constants.AddressZero, + // ethers.constants.AddressZero, + // ) + // ).to.be.revertedWith("Insufficient payment"); + + // await expect( + // aimeFactoryContract.createAIME( + // "", + // "", + // "", + // "", + // ethers.constants.AddressZero, + // ethers.constants.AddressZero, + // { value: ethers.utils.parseEther("0.00001") } + // ) + // ).to.be.revertedWith("Insufficient payment"); + // }); + + // it("can create aime with fee", async () => { + // const tx = await aimeFactoryContract.createAIME( + // name, + // avatar, + // data, + // image, + // ethers.constants.AddressZero, + // ethers.constants.AddressZero, + // { value: ethers.utils.parseEther(protocolFeeCreateEthValue) } + // ); + // await tx.wait(); + // }); + + // it("can create aime with signer", async () => { + // const tx = await aimeFactoryContract.createAIME( + // name, + // avatar, + // data, + // image, + // aimeSigner.address, + // ethers.constants.AddressZero, + // { value: ethers.utils.parseEther(protocolFeeCreateEthValue) } + // ); + // await tx.wait(); + + // const aimeAddress = await aimeFactoryContract.aimeAddresses(name); + // const aimeSignerAddress = await aimeFactoryContract.aimeSigners( + // aimeAddress + // ); + // expect(aimeSignerAddress).eq(aimeSigner.address); + // }); + + // it("can not create aime with same name", async () => { + // const tx = await aimeFactoryContract.createAIME( + // name, + // avatar, + // data, + // image, + // aimeSigner.address, + // ethers.constants.AddressZero, + // { value: ethers.utils.parseEther(protocolFeeCreateEthValue) } + // ); + // await tx.wait(); + + // await expect( + // aimeFactoryContract.createAIME( + // name, + // avatar, + // data, + // image, + // aimeSigner.address, + // ethers.constants.AddressZero, + // { value: ethers.utils.parseEther(protocolFeeCreateEthValue) } + // ) + // ).to.be.revertedWith("AIME already exists"); + // }); + + // it("can create aime and receive fee", async () => { + // // const currentNonce = await aimeFactoryContract.connect(owner).addressNonce(owner.address); + // // expect(currentNonce).eq(0); + // const contractBalanceBefore = await ethers.provider.getBalance( + // aimeFactoryContract.address + // ); + + // const tx = await aimeFactoryContract + // .connect(owner) + // .createAIME(name, avatar, data, image, ethers.constants.AddressZero, ethers.constants.AddressZero, { + // value: ethers.utils.parseEther(protocolFeeCreateEthValue), + // }); + // const receipt = await tx.wait(); + // const aimeCreatedEvent = receipt.events?.find( + // (e: any) => e.event === "AIMeCreated" + // ); + // console.log("gas used for create AIME:", receipt.gasUsed); + // const aimeNftContractAddress = aimeCreatedEvent?.args?.aimeAddress; + // console.log("aime address:", aimeNftContractAddress); + // // const newNonce = await aimeFactoryContract.addressNonce(owner.address); + // // expect(newNonce).eq(currentNonce.add(1)); + + // const contractBalanceAfter = await ethers.provider.getBalance( + // aimeFactoryContract.address + // ); + // const balanceDiff = contractBalanceAfter.sub(contractBalanceBefore); + // expect(balanceDiff).eq(ethers.utils.parseEther(protocolFeeCreateEthValue)); + // }); + + // it("can withdraw protocol fee", async () => { + // // first create aime + // const tx = await aimeFactoryContract + // .connect(owner) + // .createAIME(name, avatar, data, image, ethers.constants.AddressZero, ethers.constants.AddressZero, { + // value: ethers.utils.parseEther(protocolFeeCreateEthValue), + // }); + // await tx.wait(); + + // // withdraw protocol fee + // const balanceBefore = await ethers.provider.getBalance(owner.address); + // const tx2 = await aimeFactoryContract.connect(owner).withdrawFee(); + // const receipt = await tx2.wait(); + // // console.log('receipt:', receipt); + // const balanceAfter = await ethers.provider.getBalance(owner.address); + // const balanceDiff = balanceAfter + // .add(receipt.cumulativeGasUsed.mul(receipt.effectiveGasPrice)) + // .sub(balanceBefore); + // expect(balanceDiff).eq(ethers.utils.parseEther(protocolFeeCreateEthValue)); + // expect(await ethers.provider.getBalance(aimeFactoryContract.address)).eq( + // 0 + // ); + // }); + + // it("only owner can withdraw protocol fee", async () => { + // // first create aime + // const tx = await aimeFactoryContract + // .connect(owner) + // .createAIME(name, avatar, data, image, ethers.constants.AddressZero, ethers.constants.AddressZero, { + // value: ethers.utils.parseEther(protocolFeeCreateEthValue), + // }); + // await tx.wait(); + + // // withdraw protocol fee + // await expect( + // aimeFactoryContract.connect(signer3).withdrawFee() + // ).to.be.revertedWith(`Ownable: caller is not the owner`); + // }); + + // describe("Mint AIME NFT", () => { + // let aimeNftContractAddress: string; + // let name = "aime_name"; + // let key = "new_key"; + // let type = "editable"; + // let data = "new_data_for_new_key"; + // let avatar = "new_avatar_url"; + // let image = "new_image_url"; + // let nft_price = ethers.utils.parseEther("200"); + + // beforeEach("create a new aime", async () => { + // // create aime with aimeSigner + // const txCreate = await aimeFactoryContract + // .connect(owner) + // .createAIME(name, avatar, data, image, aimeSigner.address, ethers.constants.AddressZero, { + // value: ethers.utils.parseEther(protocolFeeCreateEthValue), + // }); + // const receipt = await txCreate.wait(); + // const aimeCreatedEvent = receipt.events?.find( + // (e: any) => e.event === "AIMeCreated" + // ); + // aimeNftContractAddress = aimeCreatedEvent?.args?.aimeAddress; + // }); + + // // it("can not mint if fee not enough", async () => { + // // const currentNonce = await aimeFactoryContract.addressNonce( + // // signer3.address + // // ); + // // const sig = await genSig( + // // aimeSigner, + // // signer3.address, + // // aimeNftContractAddress, + // // "0", + // // key, + // // type, + // // data, + // // image, + // // nft_price, + // // currentNonce + // // ); + // // await expect( + // // aimeFactoryContract.mintAIMeNFT( + // // aimeNftContractAddress, + // // key, + // // type, + // // data, + // // image, + // // nft_price, + // // sig + // // ) + // // ).to.be.revertedWith("Insufficient payment"); + + // // await expect( + // // aimeFactoryContract.mintAIMeNFT( + // // aimeNftContractAddress, + // // key, + // // type, + // // data, + // // image, + // // nft_price, + // // sig, + // // { value: ethers.utils.parseEther("0.0001") } + // // ) + // // ).to.be.revertedWith("Insufficient payment"); + // // }); + + // // it("can mint with fee and sig", async () => { + // // const currentNonce = await aimeFactoryContract.addressNonce( + // // signer3.address + // // ); + // // const sig = await genSig( + // // aimeSigner, + // // signer3.address, + // // aimeNftContractAddress, + // // "0", + // // key, + // // type, + // // data, + // // image, + // // nft_price, + // // currentNonce + // // ); + + // // const contractBalanceBefore = await ethers.provider.getBalance( + // // aimeFactoryContract.address + // // ); + // // const tx = await aimeFactoryContract + // // .connect(signer3) + // // .mintAIMeNFT( + // // aimeNftContractAddress, + // // key, + // // type, + // // data, + // // image, + // // nft_price, + // // sig, + // // { value: ethers.utils.parseEther(protocolFeeEthValue) } + // // ); + // // const receipt = await tx.wait(); + // // const contractBalanceAfter = await ethers.provider.getBalance( + // // aimeFactoryContract.address + // // ); + // // const nonceAfter = await aimeFactoryContract.addressNonce( + // // signer3.address + // // ); + // // expect(nonceAfter).eq(currentNonce.add(1)); + // // expect(contractBalanceAfter.sub(contractBalanceBefore)).eq( + // // ethers.utils.parseEther(protocolFeeEthValue) + // // ); + + // // const mintEvent = receipt.events?.find( + // // (e: any) => e.event === "AIMeNFTMinted" + // // ); + // // // console.log("mintEvent:", mintEvent); + // // expect(mintEvent?.args?.creator).eq(signer3.address); + // // expect(mintEvent?.args?.aimeAddress).eq(aimeNftContractAddress); + + // // // cannot reuse the same sig + // // await expect( + // // aimeFactoryContract + // // .connect(signer3) + // // .mintAIMeNFT( + // // aimeNftContractAddress, + // // key, + // // type, + // // data, + // // image, + // // nft_price, + // // sig, + // // { value: ethers.utils.parseEther(protocolFeeEthValue) } + // // ) + // // ).to.be.revertedWith("Invalid signature"); + // // }); + + // // describe("Update NFT data", () => { + // // const newData = "new_data"; + // // const newImage = "new_image"; + // // const tokenId = 1; + + // // beforeEach("mint an nft for signer3", async () => { + // // const currentNonce = await aimeFactoryContract.addressNonce( + // // signer3.address + // // ); + // // const sig = await genSig( + // // aimeSigner, + // // signer3.address, + // // aimeNftContractAddress, + // // "0", + // // key, + // // type, + // // data, + // // image, + // // nft_price, + // // currentNonce + // // ); + + // // const tx = await aimeFactoryContract + // // .connect(signer3) + // // .mintAIMeNFT( + // // aimeNftContractAddress, + // // key, + // // type, + // // data, + // // image, + // // nft_price, + // // sig, + // // { value: ethers.utils.parseEther(protocolFeeEthValue) } + // // ); + // // await tx.wait(); + // // }); + + // // it("can not update the nft data without enough fee", async () => { + // // const currentNonce = await aimeFactoryContract.addressNonce( + // // signer3.address + // // ); + // // const sig = await genSig( + // // aimeSigner, + // // signer3.address, + // // aimeNftContractAddress, + // // tokenId, + // // "", + // // "", + // // newData, + // // newImage, + // // 0, + // // currentNonce + // // ); + + // // await expect( + // // aimeFactoryContract + // // .connect(signer3) + // // .updateAIMeNFT(aimeNftContractAddress, 1, newData, newImage, sig) + // // ).to.be.revertedWith("Insufficient payment"); + // // await expect( + // // aimeFactoryContract + // // .connect(signer3) + // // .updateAIMeNFT( + // // aimeNftContractAddress, + // // 1, + // // newData, + // // newImage, + // // sig, + // // { value: ethers.utils.parseEther("0.0001") } + // // ) + // // ).to.be.revertedWith("Insufficient payment"); + // // }); + + // // it("can update the nft data with fee", async () => { + // // const currentNonce = await aimeFactoryContract.addressNonce( + // // signer3.address + // // ); + // // const sig = await genSig( + // // aimeSigner, + // // signer3.address, + // // aimeNftContractAddress, + // // tokenId, + // // "", + // // "", + // // newData, + // // newImage, + // // 0, + // // currentNonce + // // ); + + // // const contractBalanceBefore = await ethers.provider.getBalance( + // // aimeFactoryContract.address + // // ); + // // const tx = await aimeFactoryContract + // // .connect(signer3) + // // .updateAIMeNFT(aimeNftContractAddress, 1, newData, newImage, sig, { + // // value: ethers.utils.parseEther(protocolFeeEthValue), + // // }); + // // const receipt = await tx.wait(); + // // const contractBalanceAfter = await ethers.provider.getBalance( + // // aimeFactoryContract.address + // // ); + // // const nonceAfter = await aimeFactoryContract.addressNonce( + // // signer3.address + // // ); + // // expect(nonceAfter).eq(currentNonce.add(1)); + // // expect(contractBalanceAfter.sub(contractBalanceBefore)).eq( + // // ethers.utils.parseEther(protocolFeeEthValue) + // // ); + + // // const updateEvent = receipt.events?.find( + // // (e: any) => e.event === "AIMeNFTUpdated" + // // ); + // // expect(updateEvent?.args?.nftOwner).eq(signer3.address); + // // expect(updateEvent?.args?.aimeAddress).eq(aimeNftContractAddress); + // // }); + // // }); + // }); + // }); + + // describe("AIME with no signer", async () => { + // let aimePowerContract: AIMePower; + // let aimeNFTContract: AIMeNFTV3; + + // const name = 'aime_no_signer'; + // const type = 'static'; + // const key = 'key'; + // const avatar = 'avatar'; + // const data = 'data'; + // const image = 'image'; + // const nftPrice = ethers.utils.parseEther("200"); + // let aimeNftAddress: string; + // const newData = "new_data"; + // const newImage = "new_image"; + + // beforeEach("Create aime with no signer", async () => { + // const aimePowerFactory = await ethers.getContractFactory("AIMePower"); + // aimePowerContract = await aimePowerFactory.deploy("Kai", "Kai"); + // await aimePowerContract.deployed(); + // aimePowerContract.mint(signer3.address, ethers.utils.parseEther("10000")); + + // const tx = await aimeFactoryContract.createAIME( + // name, + // avatar, + // data, + // image, + // ethers.constants.AddressZero, + // aimePowerContract.address, + // { value: ethers.utils.parseEther(protocolFeeCreateEthValue) } + // ); + // await tx.wait(); + + // aimeNftAddress = await aimeFactoryContract.aimeAddresses(name); + // const aimeSignerAddress = await aimeFactoryContract.aimeSigners( + // aimeNftAddress + // ); + // expect(aimeSignerAddress).eq(ethers.constants.AddressZero); + + // const tx2 = await aimePowerContract.connect(signer3).approve(aimeNftAddress, ethers.utils.parseEther("10000")) + // await tx2.wait(); + + // const aimeNFTFactory = await ethers.getContractFactory("AIMeNFTV3"); + // aimeNFTContract = await aimeNFTFactory.attach(aimeNftAddress); + // await aimeNFTContract.deployed(); + // }); + + // it("can mint nft without sig", async () => { + // const tx = await aimeFactoryContract + // .connect(signer3) + // .mintAIMeNFT(aimeNftAddress, key, type, data, image, nftPrice, "0x11", { + // value: ethers.utils.parseEther(protocolFeeEthValue), + // }); + // const receipt = await tx.wait(); + + // const nftOnwer = await aimeNFTContract.ownerOf(1); + // expect(nftOnwer).eq(signer3.address); + // const tokenData = await aimeNFTContract.tokenContents(1); + // // console.log('tokenData', tokenData) + + + // // console.log("receipt", receipt) + // // receipt.events?.forEach((e: any) => { + // // console.log("topic", e.topics) + // // }) + // // const mintEvent = receipt.events?.find( + // // (e: any) => e.event === "AIMeNFTMinted" + // // ); + // // console.log("mint event", mintEvent) + // // expect(mintEvent?.args?.creator).eq(signer3.address); + // // expect(mintEvent?.args?.aimeAddress).eq(aimeNftAddress); + // }); + + // // it("can update nft without sig", async () => { + // // const tx = await aimeFactoryContract + // // .connect(signer3) + // // .mintAIMeNFT(aimeNftAddress, key, type, data, image, nftPrice, "0x11", { + // // value: ethers.utils.parseEther(protocolFeeEthValue), + // // }); + // // const receipt = await tx.wait(); + // // const mintEvent = receipt.events?.find( + // // (e: any) => e.event === "AIMeNFTMinted" + // // ); + // // const tokenId = mintEvent?.args?.tokenId; + + // // const tx2 = await aimeFactoryContract + // // .connect(signer3) + // // .updateAIMeNFT(aimeNftAddress, tokenId, newData, newImage, "0x11", { + // // value: ethers.utils.parseEther(protocolFeeEthValue), + // // }); + // // const receipt2 = await tx2.wait(); + // // const updateEvent = receipt2.events?.find( + // // (e: any) => e.event === "AIMeNFTUpdated" + // // ); + // // expect(updateEvent?.args?.nftOwner).eq(signer3.address); + // // expect(updateEvent?.args?.data).eq(newData); + // // }); + // }); +});