Skip to content

Commit

Permalink
feat: create deploy space with questions script
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoAcosta committed Nov 18, 2024
1 parent 1333e70 commit 43d3a7a
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ broadcast/

DeployPoCArgs.sol
DeploySingleArgs.sol
AddOpenQuestionArgs.sol
AddOpenQuestionArgs.sol
DeploySpaceWithQuestionsArgs.sol
120 changes: 120 additions & 0 deletions script/deploy/DeploySpaceWithQuestions.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import { Script, console } from "forge-std/Script.sol";
import { Space } from "../../src/spaces/Space.sol";
import { DeploySpaceWithQuestionsArgs } from "./DeploySpaceWithQuestionsArgs.sol";
import { FixedQuestion } from "../../src/questions/FixedQuestion.sol";
import { OpenQuestion } from "../../src/questions/OpenQuestion.sol";

contract DeploySpaceWithQuestions is Script {
function deployFixedQuestion(
address spaceAddress,
address pointsAddress,
DeploySpaceWithQuestionsArgs.FixedQuestionArgs memory args,
address plasaAddress
) private returns (FixedQuestion) {
return
new FixedQuestion(
spaceAddress,
pointsAddress,
args.title,
args.description,
args.tags,
args.deadline,
args.optionTitles,
args.optionDescriptions,
plasaAddress
);
}

function deployOpenQuestion(
address spaceAddress,
address pointsAddress,
DeploySpaceWithQuestionsArgs.OpenQuestionArgs memory args,
address plasaAddress
) private returns (OpenQuestion) {
return
new OpenQuestion(
spaceAddress,
pointsAddress,
args.title,
args.description,
args.tags,
args.deadline,
plasaAddress
);
}

function run() public {
uint256 superAdminPrivateKey = vm.envUint("SUPER_ADMIN_PRIVATE_KEY");
address superAdmin = vm.addr(superAdminPrivateKey);
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);

console.log("Super Admin address:", superAdmin);
console.log("Deployer address:", deployer);

DeploySpaceWithQuestionsArgs deployArgs = new DeploySpaceWithQuestionsArgs();
DeploySpaceWithQuestionsArgs.DeploymentArgs memory args = deployArgs.getArgs();

vm.startBroadcast(deployerPrivateKey);

// Deploy Space
Space space = new Space(
args.initialSuperAdmins,
args.spaceName,
args.spaceDescription,
args.spaceImageUrl,
args.pointsAddress,
args.minPointsToAddOpenQuestionOption
);

// Deploy Fixed Questions
FixedQuestion fixedQuestion1 = deployFixedQuestion(
address(space),
args.pointsAddress,
args.fixedQuestion1,
args.plasaAddress
);
FixedQuestion fixedQuestion2 = deployFixedQuestion(
address(space),
args.pointsAddress,
args.fixedQuestion2,
args.plasaAddress
);

// Deploy Open Questions
OpenQuestion openQuestion1 = deployOpenQuestion(
address(space),
args.pointsAddress,
args.openQuestion1,
args.plasaAddress
);
OpenQuestion openQuestion2 = deployOpenQuestion(
address(space),
args.pointsAddress,
args.openQuestion2,
args.plasaAddress
);

vm.stopBroadcast();

vm.startBroadcast(deployerPrivateKey);

// Add questions to space
space.addQuestion(address(fixedQuestion1));
space.addQuestion(address(fixedQuestion2));
space.addQuestion(address(openQuestion1));
space.addQuestion(address(openQuestion2));

vm.stopBroadcast();

// Log deployed contract addresses
console.log("Space deployed at:", address(space));
console.log("Fixed Question 1 deployed at:", address(fixedQuestion1));
console.log("Fixed Question 2 deployed at:", address(fixedQuestion2));
console.log("Open Question 1 deployed at:", address(openQuestion1));
console.log("Open Question 2 deployed at:", address(openQuestion2));
}
}

0 comments on commit 43d3a7a

Please sign in to comment.