Skip to content

Commit

Permalink
create fallback create space (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppecrj authored Oct 16, 2024
1 parent 4b2cde9 commit 1282e53
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
15 changes: 14 additions & 1 deletion contracts/scripts/deployments/facets/DeployCreateSpace.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ import {CreateSpaceFacet} from "contracts/src/factory/facets/create/CreateSpace.
contract DeployCreateSpace is FacetHelper, Deployer {
constructor() {
addSelector(CreateSpaceFacet.createSpace.selector);
addSelector(CreateSpaceFacet.createSpaceWithPrepay.selector);
addSelector(
bytes4(
keccak256(
"createSpaceWithPrepay(((string,string,string,string),((string,string,uint256,uint256,uint64,address,address,uint256,address),(bool,address[],bytes,bool),string[]),(string),(uint256)))"
)
)
);
addSelector(
bytes4(
keccak256(
"createSpaceWithPrepay(((string,string,string,string),((string,string,uint256,uint256,uint64,address,address,uint256,address),(bool,address[],bytes),string[]),(string),(uint256)))"
)
)
);
}

function initializer() public pure override returns (bytes4) {
Expand Down
19 changes: 19 additions & 0 deletions contracts/src/factory/facets/architect/IArchitect.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ interface IArchitectBase {
// STRUCTS
// =============================================================

struct MembershipRequirementsOld {
bool everyone;
address[] users;
bytes ruleData;
}

struct MembershipOld {
IMembershipBase.Membership settings;
MembershipRequirementsOld requirements;
string[] permissions;
}

struct CreateSpaceOld {
Metadata metadata;
MembershipOld membership;
ChannelInfo channel;
Prepay prepay;
}

// Latest
struct MembershipRequirements {
bool everyone;
Expand Down
23 changes: 23 additions & 0 deletions contracts/src/factory/facets/create/CreateSpace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,27 @@ contract CreateSpaceFacet is
) external payable nonReentrant whenNotPaused returns (address) {
return _createSpaceWithPrepay(spaceInfo);
}

function createSpaceWithPrepay(
CreateSpaceOld memory spaceInfo
) external payable nonReentrant whenNotPaused returns (address) {
MembershipRequirements memory requirements = MembershipRequirements({
everyone: spaceInfo.membership.requirements.everyone,
users: spaceInfo.membership.requirements.users,
ruleData: spaceInfo.membership.requirements.ruleData,
syncEntitlements: false
});
Membership memory membership = Membership({
settings: spaceInfo.membership.settings,
requirements: requirements,
permissions: spaceInfo.membership.permissions
});
CreateSpace memory newSpaceInfo = CreateSpace({
metadata: spaceInfo.metadata,
membership: membership,
channel: spaceInfo.channel,
prepay: spaceInfo.prepay
});
return _createSpaceWithPrepay(newSpaceInfo);
}
}

0 comments on commit 1282e53

Please sign in to comment.