-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
314 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
interface IAIMeFactory { | ||
function createAIMeVerified( | ||
address creator_, | ||
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 | ||
) external payable; | ||
} | ||
|
||
interface IAIMePowerLauncher { | ||
function launchPower( | ||
uint256 _price, | ||
uint256 _amountPerUnits, | ||
uint256 _totalSupply, | ||
uint256 _reservedAmount, | ||
uint256 _deadline, | ||
uint24 _poolFee, | ||
string memory _name, | ||
string memory _symbol | ||
) external returns (address); | ||
} | ||
|
||
contract AIMeCreator is Ownable { | ||
IAIMeFactory public factory; | ||
IAIMePowerLauncher public powerLauncher; | ||
|
||
struct PowerConfig { | ||
uint256 price; | ||
uint256 amountPerUnits; | ||
uint256 totalSupply; | ||
uint256 reservedAmount; | ||
uint256 deadline; | ||
uint24 poolFee; | ||
} | ||
|
||
struct AIMeConfig { | ||
string name; | ||
string avatar; | ||
string bio; | ||
string image; | ||
string socialKey; | ||
string socialId; | ||
uint256 minPrice; | ||
uint256 priceIncrement; | ||
} | ||
|
||
constructor() {} | ||
|
||
function updateAIMeAddresses(IAIMeFactory _factory, IAIMePowerLauncher _powerLauncher) public onlyOwner { | ||
factory = _factory; | ||
powerLauncher = _powerLauncher; | ||
} | ||
|
||
function create( | ||
string memory _name, | ||
string memory _symbol, | ||
PowerConfig memory _powerConfig, | ||
AIMeConfig memory _aimeConfig, | ||
bytes memory signature | ||
) public payable { | ||
address powerAddress = powerLauncher.launchPower( | ||
_powerConfig.price, | ||
_powerConfig.amountPerUnits, | ||
_powerConfig.totalSupply, | ||
_powerConfig.reservedAmount, | ||
_powerConfig.deadline, | ||
_powerConfig.poolFee, | ||
_name, | ||
_symbol | ||
); | ||
|
||
bytes memory data = abi.encodeWithSignature( | ||
"createAIMeVerified(address,string,string,string,string,string,string,uint256,uint256,address,bytes)", | ||
msg.sender, | ||
_aimeConfig.name, | ||
_aimeConfig.avatar, | ||
_aimeConfig.bio, | ||
_aimeConfig.image, | ||
_aimeConfig.socialKey, | ||
_aimeConfig.socialId, | ||
_aimeConfig.minPrice, | ||
_aimeConfig.priceIncrement, | ||
powerAddress, | ||
signature | ||
); | ||
(bool success, ) = address(factory).call{value: msg.value}(data); | ||
|
||
require(success, "Call failed"); | ||
} | ||
|
||
receive() external payable {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,53 @@ | ||
import { ethers } from "hardhat"; | ||
import { AIMeFactoryV4 } from "../../typechain"; | ||
import { AIMeFactoryV4, AIMePowerLauncher, AIMeCreator } from "../../typechain"; | ||
|
||
async function deployAIMeForTest(): Promise<AIMeFactoryV4> { | ||
async function deployAIMeContracts() { | ||
const contractFactory = await ethers.getContractFactory("AIMeFactoryV4"); | ||
const instance = await contractFactory.deploy(); | ||
await instance.deployed(); | ||
|
||
console.log("AIMeFactory V4 contract deployed to", instance.address); | ||
|
||
return instance; | ||
const powerLauncherContractFactory = await ethers.getContractFactory( | ||
"AIMePowerLauncher" | ||
); | ||
const powerLauncher = await powerLauncherContractFactory.deploy(); | ||
await powerLauncher.deployed(); | ||
|
||
console.log("powerLauncher contract deployed to", powerLauncher.address); | ||
|
||
const aimeCreatorContractFactory = await ethers.getContractFactory( | ||
"AIMeCreator" | ||
); | ||
const aimeCreator = await aimeCreatorContractFactory.deploy(); | ||
await aimeCreator.deployed(); | ||
|
||
console.log("aimeCreator contract deployed to", aimeCreator.address); | ||
} | ||
|
||
async function deployAIMePowerLauncher() { | ||
const powerLauncherContractFactory = await ethers.getContractFactory( | ||
"AIMePowerLauncher" | ||
); | ||
const powerLauncher = await powerLauncherContractFactory.deploy(); | ||
await powerLauncher.deployed(); | ||
|
||
console.log("powerLauncher contract deployed to", powerLauncher.address); | ||
} | ||
|
||
async function deployAIMeCreatorLauncher() { | ||
const aimeCreatorContractFactory = await ethers.getContractFactory( | ||
"AIMeCreator" | ||
); | ||
const aimeCreator = await aimeCreatorContractFactory.deploy(); | ||
await aimeCreator.deployed(); | ||
|
||
console.log("aimeCreator contract deployed to", aimeCreator.address); | ||
} | ||
|
||
// We recommend this pattern to be able to use async/await everywhere | ||
// and properly handle errors. | ||
deployAIMeForTest().catch((error) => { | ||
deployAIMeCreatorLauncher().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
Oops, something went wrong.