Skip to content

Commit

Permalink
Provides a way to deploy legacy spaces and new spaces for testing (#546)
Browse files Browse the repository at this point in the history
Co-authored-by: Shuhui Luo <[email protected]>
Co-authored-by: Crystal Lemire <[email protected]>
  • Loading branch information
3 people authored Aug 13, 2024
1 parent 0c25464 commit 8ba36a6
Show file tree
Hide file tree
Showing 167 changed files with 6,923 additions and 846 deletions.
12 changes: 12 additions & 0 deletions contracts/scripts/deployments/DeployRuleEntitlement.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.24;
import {Deployer} from "../common/Deployer.s.sol";

import {RuleEntitlement} from "contracts/src/spaces/entitlements/rule/RuleEntitlement.sol";
import {RuleEntitlementV2} from "contracts/src/spaces/entitlements/rule/RuleEntitlementV2.sol";

contract DeployRuleEntitlement is Deployer {
function versionName() public pure override returns (string memory) {
Expand All @@ -15,3 +16,14 @@ contract DeployRuleEntitlement is Deployer {
return address(new RuleEntitlement());
}
}

contract DeployRuleEntitlementV2 is Deployer {
function versionName() public pure override returns (string memory) {
return "ruleEntitlementV2";
}

function __deploy(address deployer) public override returns (address) {
vm.broadcast(deployer);
return address(new RuleEntitlementV2());
}
}
35 changes: 32 additions & 3 deletions contracts/scripts/deployments/DeploySpaceFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {DeployUserEntitlement} from "contracts/scripts/deployments/DeployUserEnt
import {DeployMultiInit} from "contracts/scripts/deployments/DeployMultiInit.s.sol";
import {DeploySpace} from "contracts/scripts/deployments/DeploySpace.s.sol";
import {DeploySpaceOwner} from "contracts/scripts/deployments/DeploySpaceOwner.s.sol";
import {DeployRuleEntitlement} from "contracts/scripts/deployments/DeployRuleEntitlement.s.sol";
import {DeployRuleEntitlement, DeployRuleEntitlementV2} from "contracts/scripts/deployments/DeployRuleEntitlement.s.sol";
import {DeployWalletLink} from "contracts/scripts/deployments/facets/DeployWalletLink.s.sol";
import {DeployTieredLogPricing} from "contracts/scripts/deployments/DeployTieredLogPricing.s.sol";
import {DeployFixedPricing} from "contracts/scripts/deployments/DeployFixedPricing.s.sol";
Expand All @@ -40,6 +40,9 @@ import {DeployPausable} from "contracts/scripts/deployments/facets/DeployPausabl
import {DeployPlatformRequirements} from "./facets/DeployPlatformRequirements.s.sol";
import {DeployEIP712Facet} from "contracts/scripts/deployments/facets/DeployEIP712Facet.s.sol";

// legacy
import {DeployMockLegacyArchitect} from "./facets/DeployMockLegacyArchitect.s.sol";

contract DeploySpaceFactory is DiamondDeployer {
// diamond helpers
DeployOwnable ownableHelper = new DeployOwnable();
Expand All @@ -61,13 +64,20 @@ contract DeploySpaceFactory is DiamondDeployer {
DeploySpace deploySpace = new DeploySpace();
DeploySpaceOwner deploySpaceOwner = new DeploySpaceOwner();
DeployUserEntitlement deployUserEntitlement = new DeployUserEntitlement();
DeployRuleEntitlement deployRuleEntitlement = new DeployRuleEntitlement();
DeployRuleEntitlement deployLegacyRuleEntitlement =
new DeployRuleEntitlement();
DeployRuleEntitlementV2 deployRuleEntitlementV2 =
new DeployRuleEntitlementV2();

DeployTieredLogPricing deployTieredLogPricing = new DeployTieredLogPricing();
DeployFixedPricing deployFixedPricing = new DeployFixedPricing();
DeployPlatformRequirements platformReqsHelper =
new DeployPlatformRequirements();
DeployEIP712Facet eip712Helper = new DeployEIP712Facet();

DeployMockLegacyArchitect deployMockLegacyArchitect =
new DeployMockLegacyArchitect();

// helpers

// diamond addresses
Expand All @@ -79,6 +89,7 @@ contract DeploySpaceFactory is DiamondDeployer {

// space addresses
address architect;
address legacyArchitect;
address proxyManager;
address pausable;
address platformReqs;
Expand All @@ -89,6 +100,7 @@ contract DeploySpaceFactory is DiamondDeployer {

// external contracts
address public userEntitlement;
address public legacyRuleEntitlement;
address public ruleEntitlement;
address public spaceOwner;

Expand All @@ -109,7 +121,8 @@ contract DeploySpaceFactory is DiamondDeployer {

// entitlement modules
userEntitlement = deployUserEntitlement.deploy();
ruleEntitlement = deployRuleEntitlement.deploy();
ruleEntitlement = deployRuleEntitlementV2.deploy();
legacyRuleEntitlement = deployLegacyRuleEntitlement.deploy();

// pricing modules
tieredLogPricing = deployTieredLogPricing.deploy();
Expand Down Expand Up @@ -138,6 +151,9 @@ contract DeploySpaceFactory is DiamondDeployer {

eip712 = eip712Helper.deploy();

// legacy
legacyArchitect = deployMockLegacyArchitect.deploy();

addFacet(
diamondCutHelper.makeCut(diamondCut, IDiamond.FacetCutAction.Add),
diamondCut,
Expand Down Expand Up @@ -172,6 +188,19 @@ contract DeploySpaceFactory is DiamondDeployer {
ruleEntitlement // ruleEntitlement
)
);
addFacet(
deployMockLegacyArchitect.makeCut(
legacyArchitect,
IDiamond.FacetCutAction.Add
),
legacyArchitect,
deployMockLegacyArchitect.makeInitData(
spaceOwner, // spaceOwnerToken
userEntitlement, // userEntitlement
ruleEntitlement, // ruleEntitlement
legacyRuleEntitlement // legacy ruleEntitlement
)
);
addFacet(
proxyManagerHelper.makeCut(proxyManager, IDiamond.FacetCutAction.Add),
proxyManager,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

//interfaces

//libraries

//contracts
import {Deployer} from "contracts/scripts/common/Deployer.s.sol";
import {MockLegacyArchitect} from "contracts/test/mocks/legacy/MockLegacyArchitect.sol";
import {FacetHelper} from "contracts/test/diamond/Facet.t.sol";

contract DeployMockLegacyArchitect is FacetHelper, Deployer {
constructor() {
addSelector(MockLegacyArchitect.createSpace.selector);
}

function initializer() public pure override returns (bytes4) {
return MockLegacyArchitect.__Architect_init.selector;
}

function makeInitData(
address _spaceOwnerToken,
address _userEntitlement,
address _ruleEntitlement,
address _legacyRuleEntitlement
) public pure returns (bytes memory) {
return
abi.encodeWithSelector(
initializer(),
_spaceOwnerToken,
_userEntitlement,
_ruleEntitlement,
_legacyRuleEntitlement
);
}

function versionName() public pure override returns (string memory) {
return "legacyArchitectFacet";
}

function __deploy(address deployer) public override returns (address) {
vm.startBroadcast(deployer);
MockLegacyArchitect architect = new MockLegacyArchitect();
vm.stopBroadcast();
return address(architect);
}
}
4 changes: 2 additions & 2 deletions contracts/src/factory/facets/architect/ArchitectBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ abstract contract ArchitectBase is Factory, IArchitectBase {
);
}

if (requirements.ruleData.operations.length > 0) {
if (requirements.ruleData.length > 0) {
IRoles(spaceAddress).addRoleToEntitlement(
roleId,
IRolesBase.CreateEntitlement({
module: ruleEntitlement,
data: abi.encode(requirements.ruleData)
data: requirements.ruleData
})
);
}
Expand Down
4 changes: 3 additions & 1 deletion contracts/src/factory/facets/architect/IArchitect.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ interface IArchitectBase {
// =============================================================
// STRUCTS
// =============================================================

// Latest
struct MembershipRequirements {
bool everyone;
address[] users;
IRuleEntitlement.RuleData ruleData;
bytes ruleData;
}

struct Membership {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ library ImplementationStorage {
IRuleEntitlement ruleEntitlement;
IWalletLink walletLink;
IEntitlementChecker entitlementChecker;
IRuleEntitlement legacyRuleEntitlement;
}

function layout() internal pure returns (Layout storage ds) {
Expand Down
Loading

0 comments on commit 8ba36a6

Please sign in to comment.