From 0f3c014b07f8d3eabc227e98ad99475c92e853b8 Mon Sep 17 00:00:00 2001 From: "nicoacosta.eth" Date: Tue, 15 Oct 2024 04:12:59 -0300 Subject: [PATCH] plasa + spaces: fix --- src/plasa/Plasa.sol | 2 +- src/spaces/Space.sol | 44 ++++++++++++++------------------ src/spaces/interfaces/ISpace.sol | 7 +++-- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/plasa/Plasa.sol b/src/plasa/Plasa.sol index 08c23ff..361df8d 100644 --- a/src/plasa/Plasa.sol +++ b/src/plasa/Plasa.sol @@ -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); diff --git a/src/spaces/Space.sol b/src/spaces/Space.sol index 76cdea6..b0ad086 100644 --- a/src/spaces/Space.sol +++ b/src/spaces/Space.sol @@ -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 @@ -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 @@ -83,16 +86,15 @@ 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); } @@ -100,19 +102,11 @@ contract Space is ISpace, SpaceAccessControl { 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); } @@ -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 }); diff --git a/src/spaces/interfaces/ISpace.sol b/src/spaces/interfaces/ISpace.sol index c82e45a..4ddea74 100644 --- a/src/spaces/interfaces/ISpace.sol +++ b/src/spaces/interfaces/ISpace.sol @@ -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 @@ -17,7 +18,7 @@ interface ISpace is ISpaceAccessControl { string name; string description; string imageUrl; - IFollowerSinceStamp.FollowerSinceStampView stamp; + IStampView.StampView stampView; PointsView points; QuestionPreview[] questions; } @@ -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