Skip to content

Commit

Permalink
add a single task to deploy all contracts together
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityblast committed Feb 14, 2024
1 parent 00ee386 commit 4f124fd
Show file tree
Hide file tree
Showing 28 changed files with 500 additions and 327 deletions.
34 changes: 1 addition & 33 deletions docker/deploy-contracts.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
export SKIP_CONFIRMATIONS=true

TIMEFORMAT='(🟢 %3R seconds)';

time pnpm run deploy-project-registry dev && \
time pnpm run deploy-program-factory dev && \
time pnpm run deploy-program-implementation dev && \
time pnpm run link-program-implementation dev && \
\
time pnpm run deploy-qf-factory dev && \
time pnpm run deploy-qf-implementation dev && \
time pnpm run link-qf-implementation dev && \
\
time pnpm run deploy-merkle-factory dev && \
time pnpm run deploy-merkle-implementation dev && \
time pnpm run link-merkle-implementation dev && \
\
time pnpm run deploy-direct-factory dev && \
time pnpm run deploy-direct-implementation dev && \
time pnpm run link-direct-implementation dev && \
\
time pnpm run deploy-allo-settings dev && \
time pnpm run set-protocol-fee dev && \
\
time pnpm run deploy-round-factory dev && \
time pnpm run deploy-round-implementation dev && \
time pnpm run link-round-implementation dev && \
time pnpm run link-allo-settings dev && \

echo "🟢 Allo V1 deployed and populated"

# pnpm run create-program dev
# pnpm run create-qf-contract dev
# pnpm run create-merkle-contract dev
# pnpm run create-round dev
pnpm hardhat run scripts/dev/deployAllContracts.ts --network dev;
79 changes: 79 additions & 0 deletions scripts/dev/deployAllContracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { main as deployRegistry } from "../projectRegistry/deployProjectRegistry";

import { main as deployProgramFactory } from "../program/deployProgramFactory";
import { main as deployProgramImplementation } from "../program/deployProgramImplementation";
import { main as linkProgramImplementation } from "../program/linkProgramImplementation";

import { main as deployQFVotingStrategyFactory } from "../votingStrategy/quadraticFunding/deployQFVotingStrategyFactory";
import { main as deployQFVotingStrategyImplementation } from "../votingStrategy/quadraticFunding/deployQFVotingStrategyImplementation";
import { main as linkQFVotingStrategyImplementation } from "../votingStrategy/quadraticFunding/linkQFVotingStrategyImplementation";

import { main as deployMerklePayoutStrategyFactory } from "../payoutStrategy/merkle/deployMerklePayoutStrategyFactory";
import { main as deployMerklePayoutStrategyImplementation } from "../payoutStrategy/merkle/deployMerklePayoutStrategyImplementation";
import { main as linkMerklePayoutStrategyImplementation } from "../payoutStrategy/merkle/linkMerklePayoutStrategyImplementation";

import { main as deployDirectPayoutStrategyFactory } from "../payoutStrategy/direct/deployDirectPayoutStrategyFactory";
import { main as deployDirectPayoutStrategyImplementation } from "../payoutStrategy/direct/deployDirectPayoutStrategyImplementation";
import { main as linkDirectPayoutStrategyImplementation } from "../payoutStrategy/direct/linkDirectPayoutStrategyImplementation";

import { main as deployAlloSettings } from "../settings/deployAlloSettings";
import { main as setProtocolFeeDetails } from "../settings/setProtocolFeeDetails";

import { main as deployRoundFactory } from "../round/deployRoundFactory";
import { main as deployRoundImplementation } from "../round/deployRoundImplementation";
import { main as linkRoundImplementation } from "../round/linkRoundImplementation";
import { main as linkAlloSettings } from "../round/linkAlloSettings";

async function main() {
const registry = await deployRegistry();

const programFactory = await deployProgramFactory();
const programImplementation = await deployProgramImplementation();
await linkProgramImplementation();

const qfVotingStrategyFactory = await deployQFVotingStrategyFactory();
const qfVotingStrategyImplementation =
await deployQFVotingStrategyImplementation();
await linkQFVotingStrategyImplementation();

const merklePayoutStrategyFactory = await deployMerklePayoutStrategyFactory();
const merklePayoutStrategyImplementation =
await deployMerklePayoutStrategyImplementation();
await linkMerklePayoutStrategyImplementation();

const directPayoutStrategyFactory = await deployDirectPayoutStrategyFactory();
const directPayoutStrategyImplementation =
await deployDirectPayoutStrategyImplementation();
await linkDirectPayoutStrategyImplementation();

const alloSettings = await deployAlloSettings();
await setProtocolFeeDetails();

const roundFactory = await deployRoundFactory();
const roundImplementation = await deployRoundImplementation();

await linkRoundImplementation();
await linkAlloSettings();

console.log("---------------------------------------");
console.log("\nAllo V1 contracts deployed successfully\n");
console.table({
Registry: registry,
ProgramFactory: programFactory,
ProgramImplementation: programImplementation,
QFVotingStrategyFactory: qfVotingStrategyFactory,
QFVotingStrategyImplementation: qfVotingStrategyImplementation,
MerklePayoutStrategyFactory: merklePayoutStrategyFactory,
MerklePayoutStrategyImplementation: merklePayoutStrategyImplementation,
DirectPayoutStrategyFactory: directPayoutStrategyFactory,
DirectPayoutStrategyImplementation: directPayoutStrategyImplementation,
AlloSettings: alloSettings,
RoundFactory: roundFactory,
RoundImplementation: roundImplementation,
});
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
36 changes: 20 additions & 16 deletions scripts/payoutStrategy/direct/createDirectPayoutStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import { ethers } from "hardhat";
import hre from "hardhat";
import { confirmContinue } from "../../../utils/script-utils";
import { DirectPayoutParams } from '../../config/payoutStrategy.config';
import { AlloSettingsParams } from '../../config/allo.config';
import { DirectPayoutParams } from "../../config/payoutStrategy.config";
import { AlloSettingsParams } from "../../config/allo.config";
import * as utils from "../../utils";

utils.assertEnvironment();

export async function main() {

const network = hre.network;

const networkParams = DirectPayoutParams[network.name];
Expand All @@ -24,7 +23,6 @@ export async function main() {
const payoutImplementationContract = networkParams.implementation;
const alloSettingsContract = alloNetworkParams.alloSettingsContract;


if (!payoutFactoryContract) {
throw new Error(`error: missing factory`);
}
Expand All @@ -37,17 +35,19 @@ export async function main() {
throw new Error(`error: missing alloSettingsContract`);
}

const DirectPayoutStrategyFactory = await ethers.getContractAt('DirectPayoutStrategyFactory', payoutFactoryContract);
const DirectPayoutStrategyFactory = await ethers.getContractAt(
"DirectPayoutStrategyFactory",
payoutFactoryContract
);

await confirmContinue({
"info" : "create a direct payout strategy contract",
"DirectPayoutStrategyFactoryContract" : payoutFactoryContract,
"DirectPayoutStrategyImplementationContract" : payoutImplementationContract,
"network" : network.name,
"chainId" : network.config.chainId
info: "create a direct payout strategy contract",
DirectPayoutStrategyFactoryContract: payoutFactoryContract,
DirectPayoutStrategyImplementationContract: payoutImplementationContract,
network: network.name,
chainId: network.config.chainId,
});


const payoutStrategyTx = await DirectPayoutStrategyFactory.create(
alloSettingsContract,
ethers.constants.AddressZero, // safe vault
Expand All @@ -59,7 +59,9 @@ export async function main() {
let payoutStrategyAddress;

if (receipt.events) {
const event = receipt.events.find(e => e.event === 'PayoutContractCreated');
const event = receipt.events.find(
(e) => e.event === "PayoutContractCreated"
);
if (event && event.args) {
payoutStrategyAddress = event.args.payoutContractAddress;
}
Expand All @@ -69,7 +71,9 @@ export async function main() {
console.log("✅ Direct Payout contract created: ", payoutStrategyAddress);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export async function main() {
return await address;
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export async function main() {
const resp = contract.deploymentTransaction();
const address = await contract.getAddress();

console.log(
`Deploying DirectPayoutStrategyImplementation to ${address}`
);
console.log(`Deploying DirectPayoutStrategyImplementation to ${address}`);
await resp.wait(getBlocksToWait(hre.network.name));
console.log("✅ Deployed");

Expand All @@ -31,7 +29,9 @@ export async function main() {

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export async function main(
await confirmContinue({
contract: "DirectPayoutStrategyFactory",
directPayoutStrategyFactoryContract: directPayoutStrategyFactoryContract,
directPayoutStrategyImplementationContract: directPayoutStrategyImplementationContract,
directPayoutStrategyImplementationContract:
directPayoutStrategyImplementationContract,
network: network.name,
chainId: network.config.chainId,
});
Expand All @@ -61,7 +62,9 @@ export async function main(
);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
37 changes: 20 additions & 17 deletions scripts/payoutStrategy/merkle/createMerklePayoutStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// This is a helper script to create a merkle payout contract.
// This is a helper script to create a merkle payout contract.
// This should be created via the frontend and this script is meant to be used for quick test
import { ethers } from "hardhat";
import hre from "hardhat";
import { confirmContinue } from "../../../utils/script-utils";
import { MerklePayoutParams } from '../../config/payoutStrategy.config';
import { MerklePayoutParams } from "../../config/payoutStrategy.config";
import * as utils from "../../utils";

utils.assertEnvironment();

export async function main() {

const network = hre.network;

const networkParams = MerklePayoutParams[network.name];
Expand All @@ -20,7 +19,6 @@ export async function main() {
const payoutFactoryContract = networkParams.factory;
const payoutImplementationContract = networkParams.implementation;


if (!payoutFactoryContract) {
throw new Error(`error: missing factory`);
}
Expand All @@ -29,25 +27,28 @@ export async function main() {
throw new Error(`error: missing implementation`);
}

const MerklePayoutStrategyFactory = await ethers.getContractAt(
"MerklePayoutStrategyFactory",
payoutFactoryContract
);

const MerklePayoutStrategyFactory = await ethers.getContractAt('MerklePayoutStrategyFactory', payoutFactoryContract);

await confirmContinue({
"info" : "create a merkle payout strategy contract",
"MerklePayoutStrategyFactoryContract" : payoutFactoryContract,
"MerklePayoutStrategyImplementationContract" : payoutImplementationContract,
"network" : network.name,
"chainId" : network.config.chainId
info: "create a merkle payout strategy contract",
MerklePayoutStrategyFactoryContract: payoutFactoryContract,
MerklePayoutStrategyImplementationContract: payoutImplementationContract,
network: network.name,
chainId: network.config.chainId,
});


const payoutStrategyTx = await MerklePayoutStrategyFactory.create();

const receipt = await payoutStrategyTx.wait();
let payoutStrategyAddress;

if (receipt.events) {
const event = receipt.events.find(e => e.event === 'PayoutContractCreated');
const event = receipt.events.find(
(e) => e.event === "PayoutContractCreated"
);
if (event && event.args) {
payoutStrategyAddress = event.args.payoutContractAddress;
}
Expand All @@ -57,7 +58,9 @@ export async function main() {
console.log("✅ Merkle Payout contract created: ", payoutStrategyAddress);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export async function main() {
return address;
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export async function main() {
const resp = contract.deploymentTransaction();
const address = await contract.getAddress();

console.log(
`Deploying MerklePayoutStrategyImplementation to ${address}`
);
console.log(`Deploying MerklePayoutStrategyImplementation to ${address}`);
await resp.wait(getBlocksToWait(hre.network.name));
console.log("✅ Deployed");

Expand All @@ -31,7 +29,9 @@ export async function main() {

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export async function main(
);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
Loading

0 comments on commit 4f124fd

Please sign in to comment.