-
Notifications
You must be signed in to change notification settings - Fork 0
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
9 changed files
with
351 additions
and
45 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
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,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.11; | ||
|
||
import { Campaign } from "./Campaign.sol"; | ||
|
||
contract CampaignFactory { | ||
struct cmpInput { | ||
string _title; | ||
string _description; | ||
string _category; | ||
string _tags; | ||
uint256 _goalAmount; | ||
uint256 _duration; | ||
string _imageURI; | ||
} | ||
|
||
function createCampaign(address _crf, address payable _creator, address _rwdFactory, cmpInput memory _cmp) public returns (address) { | ||
Campaign cmp = new Campaign( | ||
_crf, | ||
_creator, | ||
_rwdFactory, | ||
_cmp._title, | ||
_cmp._description, | ||
_cmp._category, | ||
_cmp._tags, | ||
_cmp._goalAmount, | ||
_cmp._duration, | ||
_cmp._imageURI | ||
); | ||
|
||
return address(cmp); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.11; | ||
|
||
import { Reward } from "./Reward.sol"; | ||
|
||
contract RewardFactory { | ||
struct rwdInput { | ||
uint256 price; | ||
string _title; | ||
string _description; | ||
string _rpic; | ||
string[] _perks; | ||
uint256 _deadline; | ||
uint256 _quantity; | ||
bool _infinite; | ||
string[] _shipsTo; | ||
} | ||
|
||
function createReward(address _cmpAddress, address _creator, rwdInput memory _rwd) public returns (address) { | ||
Reward rwd = new Reward( | ||
_cmpAddress, | ||
_creator, | ||
_rwd.price, | ||
_rwd._title, | ||
_rwd._description, | ||
_rwd._rpic, | ||
_rwd._perks, | ||
_rwd._deadline, | ||
_rwd._quantity, | ||
_rwd._infinite, | ||
_rwd._shipsTo | ||
); | ||
|
||
return address(rwd); | ||
} | ||
} |
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,34 @@ | ||
import { network, ethers } from "hardhat" | ||
import { DeployFunction } from "hardhat-deploy/dist/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import { developmentChains, networkConfig } from "../helper-hardhat-config" | ||
import verify from "../utils/verify" | ||
import hasKey from "../utils/hasKey" | ||
|
||
const deployRewardFactory: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts } = hre | ||
const { deploy, log } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
const chainId = network.config.chainId | ||
const waitBlockConfirmations = chainId?.toString() == "31337" ? 1 : 4 | ||
|
||
log("==========================") | ||
if(hasKey(networkConfig, chainId!)) | ||
{ const args:any[] = [] | ||
const rewardFactory = await deploy("RewardFactory", { | ||
from: deployer, | ||
args, | ||
log: true, | ||
waitConfirmations: waitBlockConfirmations | ||
}) | ||
|
||
if(!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) { | ||
log("Verifying...") | ||
await verify(rewardFactory.address, args) | ||
} | ||
log("==========================") | ||
} | ||
} | ||
|
||
export default deployRewardFactory | ||
deployRewardFactory.tags = ["all", "rewardfactory"] |
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,34 @@ | ||
import { network, ethers } from "hardhat" | ||
import { DeployFunction } from "hardhat-deploy/dist/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import { developmentChains, networkConfig } from "../helper-hardhat-config" | ||
import verify from "../utils/verify" | ||
import hasKey from "../utils/hasKey" | ||
|
||
const deployCampaignFactory: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts } = hre | ||
const { deploy, log } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
const chainId = network.config.chainId | ||
const waitBlockConfirmations = chainId?.toString() == "31337" ? 1 : 4 | ||
|
||
log("==========================") | ||
if(hasKey(networkConfig, chainId!)) | ||
{ const args:any[] = [] | ||
const campaignFactory = await deploy("CampaignFactory", { | ||
from: deployer, | ||
args, | ||
log: true, | ||
waitConfirmations: waitBlockConfirmations | ||
}) | ||
|
||
if(!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) { | ||
log("Verifying...") | ||
await verify(campaignFactory.address, args) | ||
} | ||
log("==========================") | ||
} | ||
} | ||
|
||
export default deployCampaignFactory | ||
deployCampaignFactory.tags = ["all", "campaignfactory"] |
Oops, something went wrong.