Skip to content

Commit 7577291

Browse files
authored
feat: add Space interaction scripts and reorganize contract structure (#4440)
### Description This PR reorganizes interaction scripts and adds new functionality for Space and SpaceFactory diamonds. It moves the AppRegistry interaction script out of the diamonds directory and introduces new scripts for interacting with Space and SpaceFactory contracts. ### Changes - Moved `InteractAppRegistry.s.sol` from `diamonds/` directory to the parent folder - Removed unused import `IAppFactory` from AppRegistry interaction script - Added new `InteractSpace.s.sol` script that: - Deploys a new TippingFacet implementation - Replaces the existing TippingFacet on the Space diamond - Added new `InteractSpaceFactory.s.sol` script that: - Sets fee recipient in PlatformRequirementsFacet - Deploys a new FeeManagerFacet implementation - Adds the FeeManagerFacet to the SpaceFactory diamond with initialization - Configures a 0.5% fee for member tipping ### Checklist - [ ] Tests added where required - [ ] Documentation updated where applicable - [ ] Changes adhere to the repository's contribution guidelines
1 parent 74641e4 commit 7577291

File tree

3 files changed

+119
-8
lines changed

3 files changed

+119
-8
lines changed

packages/contracts/scripts/interactions/diamonds/InteractAppRegistry.s.sol renamed to packages/contracts/scripts/interactions/InteractAppRegistry.s.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
pragma solidity ^0.8.23;
33

44
// interfaces
5-
import {IAppFactory, IAppFactoryBase} from "src/apps/facets/factory/IAppFactory.sol";
5+
import {IAppFactoryBase} from "src/apps/facets/factory/IAppFactory.sol";
66

77
// libraries
88
import {console} from "forge-std/console.sol";
99

1010
// contracts
11-
import {Interaction} from "../../common/Interaction.s.sol";
12-
import {AlphaHelper} from "../helpers/AlphaHelper.sol";
13-
import {DeployAppRegistry} from "../../deployments/diamonds/DeployAppRegistry.s.sol";
14-
import {DeploySimpleAppBeacon} from "../../deployments/diamonds/DeploySimpleAppBeacon.s.sol";
11+
import {Interaction} from "../common/Interaction.s.sol";
12+
import {AlphaHelper} from "./helpers/AlphaHelper.sol";
13+
import {DeployAppRegistry} from "../deployments/diamonds/DeployAppRegistry.s.sol";
14+
import {DeploySimpleAppBeacon} from "../deployments/diamonds/DeploySimpleAppBeacon.s.sol";
1515

1616
// facet deployers
17-
import {DeployAppRegistryFacet} from "../../deployments/facets/DeployAppRegistryFacet.s.sol";
18-
import {DeployAppInstallerFacet} from "../../deployments/facets/DeployAppInstallerFacet.s.sol";
19-
import {DeployAppFactoryFacet} from "../../deployments/facets/DeployAppFactoryFacet.s.sol";
17+
import {DeployAppRegistryFacet} from "../deployments/facets/DeployAppRegistryFacet.s.sol";
18+
import {DeployAppInstallerFacet} from "../deployments/facets/DeployAppInstallerFacet.s.sol";
19+
import {DeployAppFactoryFacet} from "../deployments/facets/DeployAppFactoryFacet.s.sol";
2020

2121
contract InteractAppRegistry is Interaction, AlphaHelper {
2222
DeployAppRegistry private deployHelper = new DeployAppRegistry();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.23;
3+
4+
// interfaces
5+
import {IDiamondCut} from "@towns-protocol/diamond/src/facets/cut/IDiamondCut.sol";
6+
7+
// libraries
8+
import {console} from "forge-std/console.sol";
9+
import {DeployTipping} from "../deployments/facets/DeployTipping.s.sol";
10+
11+
// contracts
12+
import {Interaction} from "../common/Interaction.s.sol";
13+
import {AlphaHelper} from "./helpers/AlphaHelper.sol";
14+
15+
contract InteractSpace is Interaction, AlphaHelper {
16+
function __interact(address deployer) internal override {
17+
// Get the deployed Space diamond address
18+
address space = getDeployment("space");
19+
20+
console.log("Space Diamond:", space);
21+
22+
// Deploy new TippingFacet implementation
23+
console.log("\n=== Deploying TippingFacet ===");
24+
vm.setEnv("OVERRIDE_DEPLOYMENTS", "1");
25+
26+
address tippingFacet = DeployTipping.deploy();
27+
console.log("TippingFacet deployed at:", tippingFacet);
28+
29+
// Add the cut for replacing the existing facet implementation
30+
addCut(DeployTipping.makeCut(tippingFacet, FacetCutAction.Replace));
31+
32+
// Execute the diamond cut without initialization
33+
console.log("\n=== Executing Diamond Cut to Replace TippingFacet ===");
34+
vm.broadcast(deployer);
35+
IDiamondCut(space).diamondCut(baseFacets(), address(0), "");
36+
37+
console.log("\n=== Diamond Cut Complete ===");
38+
console.log("TippingFacet successfully updated on Space diamond");
39+
}
40+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.23;
3+
4+
// interfaces
5+
import {IFeeManager} from "src/factory/facets/fee/IFeeManager.sol";
6+
import {IPlatformRequirements} from "src/factory/facets/platform/requirements/IPlatformRequirements.sol";
7+
import {IDiamondCut} from "@towns-protocol/diamond/src/facets/cut/IDiamondCut.sol";
8+
9+
// libraries
10+
import {FeeTypesLib} from "src/factory/facets/fee/FeeTypesLib.sol";
11+
import {FeeCalculationMethod} from "src/factory/facets/fee/FeeManagerStorage.sol";
12+
import {console} from "forge-std/console.sol";
13+
import {DeployFeeManager} from "../deployments/facets/DeployFeeManager.s.sol";
14+
15+
// contracts
16+
import {Interaction} from "../common/Interaction.s.sol";
17+
import {AlphaHelper} from "./helpers/AlphaHelper.sol";
18+
19+
contract InteractSpaceFactory is Interaction, AlphaHelper {
20+
function __interact(address deployer) internal override {
21+
// Get the deployed SpaceFactory diamond address
22+
address spaceFactory = getDeployment("spaceFactory");
23+
24+
console.log("SpaceFactory Diamond:", spaceFactory);
25+
26+
// Set fee recipient in PlatformRequirementsFacet
27+
console.log("\n=== Setting Fee Recipient in PlatformRequirementsFacet ===");
28+
vm.broadcast(deployer);
29+
IPlatformRequirements(spaceFactory).setFeeRecipient(deployer);
30+
console.log("Fee recipient set to:", deployer);
31+
32+
// Get fee recipient from PlatformRequirementsFacet
33+
address protocolFeeRecipient = IPlatformRequirements(spaceFactory).getFeeRecipient();
34+
console.log("Protocol Fee Recipient:", protocolFeeRecipient);
35+
36+
// Deploy new FeeManagerFacet implementation
37+
console.log("\n=== Deploying FeeManagerFacet ===");
38+
vm.setEnv("OVERRIDE_DEPLOYMENTS", "1");
39+
40+
address feeManagerFacet = DeployFeeManager.deploy();
41+
console.log("FeeManagerFacet deployed at:", feeManagerFacet);
42+
43+
// Add the cut for the new facet implementation
44+
addCut(DeployFeeManager.makeCut(feeManagerFacet, FacetCutAction.Add));
45+
46+
// Prepare initialization data with the fee recipient from PlatformRequirementsFacet
47+
bytes memory initData = DeployFeeManager.makeInitData(protocolFeeRecipient);
48+
49+
// Execute the diamond cut with initialization
50+
console.log("\n=== Executing Diamond Cut with Initialization ===");
51+
vm.broadcast(deployer);
52+
IDiamondCut(spaceFactory).diamondCut(baseFacets(), feeManagerFacet, initData);
53+
54+
console.log("\n=== Diamond Cut Complete ===");
55+
56+
// Set fee config for tipping
57+
console.log("\n=== Setting Fee Config for Tipping ===");
58+
vm.broadcast(deployer);
59+
IFeeManager(spaceFactory).setFeeConfig(
60+
FeeTypesLib.TIP_MEMBER,
61+
address(0),
62+
FeeCalculationMethod.PERCENT,
63+
50, // 0.5% (50 basis points)
64+
0,
65+
true
66+
);
67+
68+
console.log("Fee config set for TIP_MEMBER: 0.5% (50 bps)");
69+
console.log("\n=== Interaction Complete ===");
70+
}
71+
}

0 commit comments

Comments
 (0)