Skip to content

Commit

Permalink
update spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoAcosta committed Oct 19, 2024
1 parent e87c934 commit 61c88f0
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 308 deletions.
1 change: 0 additions & 1 deletion examples/plasa-query.ts

This file was deleted.

2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ out = "out"
libs = ["lib"]
fs_permissions = [{ access = "read", path = "./deployment_log.json" }]
solc_version = "0.8.20"
optimizer = true
optimizer_runs = 200

# Add this line to include OpenZeppelin
remappings = ["@openzeppelin/=lib/openzeppelin-contracts/"]
Expand Down
102 changes: 22 additions & 80 deletions script/deploy/DeployPoC.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import "@openzeppelin/contracts/utils/Strings.sol";
import { FollowerSinceStamp } from "../../src/stamps/FollowerSinceStamp.sol";
import { FollowerSincePoints } from "../../src/points/FollowerSincePoints.sol";
import { Plasa } from "../../src/plasa/Plasa.sol";
import { FixedQuestion } from "../../src/voting/FixedQuestion.sol";

contract DeployPoC is Script {
function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");

// Create an instance of DeployPoCArgs with the deployer's address
address deployer = vm.addr(deployerPrivateKey);
Expand All @@ -31,8 +32,6 @@ contract DeployPoC is Script {

Space space = new Space(
args.initialSuperAdmins,
args.initialAdmins,
args.initialModerators,
args.spaceName,
args.spaceDescription,
args.spaceImageUrl,
Expand All @@ -44,87 +43,30 @@ contract DeployPoC is Script {
// Set space initial super admin as Plasa owner
Plasa plasa = new Plasa(args.initialSuperAdmins[0]);

// Stop the broadcast with the deployer's private key
vm.stopBroadcast();

// Start a new broadcast with the initial super admin's private key
uint256 superAdminPrivateKey = vm.envUint("SUPER_ADMIN_PRIVATE_KEY");
vm.startBroadcast(superAdminPrivateKey);

plasa.addStamp(address(stamp));
plasa.addSpace(address(space));

vm.stopBroadcast();
// Deploy a fixed question using the super admin's private key
FixedQuestion fixedQuestion = new FixedQuestion(
address(space),
args.fixedQuestionTitle,
args.fixedQuestionDescription,
args.fixedQuestionDeadline,
args.fixedQuestionOptionTitles,
args.fixedQuestionOptionDescriptions
);

// Log deployment information in JSON format
console.log("DEPLOYMENT_LOG_START");
console.log("{");
console.log(' "DeployerAddress": "%s",', deployer);
console.log(' "ChainId": %d,', block.chainid);
// console.log(' "CompilerVersion": "%s",', vm.envString("FOUNDRY_SOLC_VERSION"));
console.log(' "Contracts": [');
console.log(" {");
console.log(' "FollowerSinceStamp": {');
console.log(' "address": "%s",', address(stamp));
console.log(' "deployer": "%s",', deployer);
console.log(' "contractName": "FollowerSinceStamp",');
console.log(' "sourcePath": "src/stamps/FollowerSinceStamp.sol",');
console.log(' "arguments": {');
console.log(' "signer": "%s",', args.stampSigner);
console.log(' "platform": "%s",', args.stampPlatform);
console.log(' "followed": "%s"', args.stampFollowed);
console.log(" }");
console.log(" }");
console.log(" },");
console.log(" {");
console.log(' "FollowerSincePoints": {');
console.log(' "address": "%s",', address(points));
console.log(' "deployer": "%s",', deployer);
console.log(' "contractName": "FollowerSincePoints",');
console.log(' "sourcePath": "src/points/FollowerSincePoints.sol",');
console.log(' "arguments": {');
console.log(' "followerStamp": "%s",', address(stamp));
console.log(' "name": "%s",', args.pointsName);
console.log(' "symbol": "%s"', args.pointsSymbol);
console.log(" }");
console.log(" }");
console.log(" },");
console.log(" {");
console.log(' "Space": {');
console.log(' "address": "%s",', address(space));
console.log(' "deployer": "%s",', deployer);
console.log(' "contractName": "Space",');
console.log(' "sourcePath": "src/spaces/Space.sol",');
console.log(' "arguments": {');
console.log(' "initialSuperAdmins": %s,', _formatAddressArray(args.initialSuperAdmins));
console.log(' "initialAdmins": %s,', _formatAddressArray(args.initialAdmins));
console.log(' "initialModerators": %s,', _formatAddressArray(args.initialModerators));
console.log(' "spaceName": "%s",', args.spaceName);
console.log(' "spaceDescription": "%s",', args.spaceDescription);
console.log(' "spaceImageUrl": "%s",', args.spaceImageUrl);
console.log(' "defaultPoints": "%s",', address(points));
console.log(' "minPointsToAddOpenQuestionOption": %d', args.minPointsToAddOpenQuestionOption);
console.log(" }");
console.log(" }");
console.log(" },");
console.log(" {");
console.log(' "Plasa": {');
console.log(' "address": "%s",', address(plasa));
console.log(' "deployer": "%s",', deployer);
console.log(' "contractName": "Plasa",');
console.log(' "sourcePath": "src/plasa/Plasa.sol",');
console.log(' "arguments": {');
console.log(' "initialOwner": "%s"', args.initialSuperAdmins[0]);
console.log(" }");
console.log(" }");
console.log(" }");
console.log(" ]");
console.log("}");
console.log("DEPLOYMENT_LOG_END");
}
// Add the question to the space
space.addQuestion(address(fixedQuestion));

function _formatAddressArray(address[] memory addresses) internal pure returns (string memory) {
bytes memory result = "[";
for (uint i = 0; i < addresses.length; i++) {
if (i > 0) {
result = abi.encodePacked(result, ",");
}
result = abi.encodePacked(result, '"', Strings.toHexString(uint160(addresses[i]), 20), '"');
}
result = abi.encodePacked(result, "]");
return string(result);
// Stop the broadcast with the super admin's private key
vm.stopBroadcast();
}
}
35 changes: 21 additions & 14 deletions script/deploy/DeployPoCArgs.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,22 @@ contract DeployPoCArgs is Script {
string pointsSymbol;
// Space args
address[] initialSuperAdmins;
address[] initialAdmins;
address[] initialModerators;
string spaceName;
string spaceDescription;
string spaceImageUrl;
uint256 minPointsToAddOpenQuestionOption;
// Fixed Question args
string fixedQuestionTitle;
string fixedQuestionDescription;
uint256 fixedQuestionDeadline;
string[] fixedQuestionOptionTitles;
string[] fixedQuestionOptionDescriptions;
}

function getArgs() public view returns (DeploymentArgs memory) {
address[] memory superAdmins = new address[](1);
superAdmins[0] = vm.envAddress("SUPER_ADMIN_ADDRESS");

// address[] memory superAdmins = new address[](1);
// superAdmins[0] = vm.envAddress("SUPER_ADMIN_ADDRESS");

// address[] memory admins = new address[](1);
// admins[0] = vm.envAddress("ADMIN_ADDRESS");

// address[] memory moderators = new address[](1);
// modulators[0] = vm.envAddress("MODERATOR_ADDRESS");

DeploymentArgs memory args = DeploymentArgs({
// Stamp args
stampSigner: vm.envAddress("EIP712_SIGNER_ADDRESS"),
Expand All @@ -45,14 +40,26 @@ contract DeployPoCArgs is Script {
pointsSymbol: "ONCHAIN",
// Space args
initialSuperAdmins: superAdmins,
initialAdmins: new address[](0),
initialModerators: new address[](0),
spaceName: "Base",
spaceDescription: "The (un)official community space for Base Onchain community",
spaceImageUrl: "https://raw.githubusercontent.com/base-org/brand-kit/refs/heads/main/logo/in-product/Base_Network_Logo.png",
minPointsToAddOpenQuestionOption: 100
minPointsToAddOpenQuestionOption: 100,
// Fixed Question args
fixedQuestionTitle: "Where should the next Onchain Summit be held?",
fixedQuestionDescription: "Vote for the location of the next Onchain Summit",
fixedQuestionDeadline: block.timestamp + 7 days,
fixedQuestionOptionTitles: new string[](3),
fixedQuestionOptionDescriptions: new string[](3)
});

args.fixedQuestionOptionTitles[0] = "Buenos Aires";
args.fixedQuestionOptionTitles[1] = "San Francisco";
args.fixedQuestionOptionTitles[2] = "Lisbon";

args.fixedQuestionOptionDescriptions[0] = "The vibrant capital of Argentina";
args.fixedQuestionOptionDescriptions[1] = "The tech hub of Silicon Valley";
args.fixedQuestionOptionDescriptions[2] = "The historic capital of Portugal";

return args;
}
}
Loading

0 comments on commit 61c88f0

Please sign in to comment.