Skip to content

Commit

Permalink
plasa + spaces: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoAcosta committed Oct 15, 2024
1 parent 18e010f commit 0f3c014
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/plasa/Plasa.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ contract Plasa is Ownable {
revert StampAlreadyExists(platform);
}

IAccountOwnershipStamp newStamp = new AccountOwnershipStamp(stampSigner, platform);
IAccountOwnershipStamp newStamp = new AccountOwnershipStamp(address(this), stampSigner, platform);
accountOwnershipStamps[platform] = newStamp;
emit AccountOwnershipStampCreated(platform, address(newStamp));
return address(newStamp);
Expand Down
44 changes: 19 additions & 25 deletions src/spaces/Space.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "./interfaces/ISpace.sol";
import "../stamps/interfaces/IFollowerSinceStamp.sol";
import "../points/interfaces/IFollowerSincePoints.sol";
import "../voting/interfaces/IQuestion.sol";
import "../voting/FixedQuestion.sol";
import "../voting/OpenQuestion.sol";
import "../stamps/FollowerSinceStamp.sol";
import "../points/FollowerSincePoints.sol";
import "./SpaceAccessControl.sol";
import { ISpace } from "./interfaces/ISpace.sol";
import { IFollowerSinceStamp } from "../stamps/interfaces/IFollowerSinceStamp.sol";
import { IFollowerSincePoints } from "../points/interfaces/IFollowerSincePoints.sol";
import { IQuestion } from "../voting/interfaces/IQuestion.sol";
import { FixedQuestion } from "../voting/FixedQuestion.sol";
import { OpenQuestion } from "../voting/OpenQuestion.sol";
import { FollowerSinceStamp } from "../stamps/FollowerSinceStamp.sol";
import { FollowerSincePoints } from "../points/FollowerSincePoints.sol";
import { SpaceAccessControl } from "./SpaceAccessControl.sol";
import { IQuestionView } from "../voting/interfaces/IQuestionView.sol";

/// @title Space - A contract for managing community spaces in Plasa
/// @notice This contract represents a space, organization, or leader using Plasa for their community
Expand Down Expand Up @@ -52,7 +53,9 @@ contract Space is ISpace, SpaceAccessControl {
spaceImageUrl = _spaceImageUrl;

// Deploy FollowerSinceStamp contract
followerStamp = IFollowerSinceStamp(address(new FollowerSinceStamp(stampSigner, platform, followed)));
followerStamp = IFollowerSinceStamp(
address(new FollowerSinceStamp(address(this), stampSigner, platform, followed))
);
emit FollowerStampDeployed(address(followerStamp));

// Deploy FollowerSincePoints contract
Expand Down Expand Up @@ -83,36 +86,27 @@ contract Space is ISpace, SpaceAccessControl {
string[] memory initialOptionDescriptions
) external onlyAllowed(PermissionName.CreateFixedQuestion) returns (address) {
FixedQuestion newQuestion = new FixedQuestion(
msg.sender,
address(this),
questionTitle,
questionDescription,
deadline,
address(defaultPoints),
initialOptionTitles,
initialOptionDescriptions
);
questions.push(IQuestion(address(newQuestion)));
emit QuestionDeployed(address(newQuestion), IQuestion.QuestionType.Fixed);
emit QuestionDeployed(address(newQuestion), IQuestionView.QuestionType.Fixed);
return address(newQuestion);
}

/// @inheritdoc ISpace
function deployOpenQuestion(
string memory questionTitle,
string memory questionDescription,
uint256 deadline,
uint256 minPointsToAddOption
uint256 deadline
) external onlyAllowed(PermissionName.CreateOpenQuestion) returns (address) {
OpenQuestion newQuestion = new OpenQuestion(
msg.sender,
questionTitle,
questionDescription,
deadline,
address(defaultPoints),
minPointsToAddOption
);
OpenQuestion newQuestion = new OpenQuestion(address(this), questionTitle, questionDescription, deadline);
questions.push(IQuestion(address(newQuestion)));
emit QuestionDeployed(address(newQuestion), IQuestion.QuestionType.Open);
emit QuestionDeployed(address(newQuestion), IQuestionView.QuestionType.Open);
return address(newQuestion);
}

Expand Down Expand Up @@ -166,7 +160,7 @@ contract Space is ISpace, SpaceAccessControl {
name: spaceName,
description: spaceDescription,
imageUrl: spaceImageUrl,
stamp: followerStamp.getFollowerSinceStampView(user),
stampView: followerStamp.getStampView(user),
points: PointsView({ addr: address(defaultPoints), userCurrentBalance: defaultPoints.balanceOf(user) }),
questions: questionPreviews
});
Expand Down
7 changes: 3 additions & 4 deletions src/spaces/interfaces/ISpace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IQuestion } from "../../voting/interfaces/IQuestion.sol";
import { IFollowerSinceStamp } from "../../stamps/interfaces/IFollowerSinceStamp.sol";
import { IFollowerSincePoints } from "../../points/interfaces/IFollowerSincePoints.sol";
import { ISpaceAccessControl } from "./ISpaceAccessControl.sol";
import { IStampView } from "../../stamps/interfaces/IStampView.sol";

/// @title ISpace - Interface for managing community spaces in Plasa
/// @notice This interface defines the structure for managing follower stamps, points, and questions within a space
Expand All @@ -17,7 +18,7 @@ interface ISpace is ISpaceAccessControl {
string name;
string description;
string imageUrl;
IFollowerSinceStamp.FollowerSinceStampView stamp;
IStampView.StampView stampView;
PointsView points;
QuestionPreview[] questions;
}
Expand Down Expand Up @@ -92,13 +93,11 @@ interface ISpace is ISpaceAccessControl {
/// @param questionTitle The title of the question
/// @param questionDescription The description of the question
/// @param deadline The deadline for voting
/// @param minPointsToAddOption The minimum points required to add an option
/// @return The address of the newly deployed question contract
function deployOpenQuestion(
string memory questionTitle,
string memory questionDescription,
uint256 deadline,
uint256 minPointsToAddOption
uint256 deadline
) external returns (address);

/// @notice Updates the name of the space
Expand Down

0 comments on commit 0f3c014

Please sign in to comment.