@@ -3,6 +3,7 @@ pragma solidity ^0.8.23;
33
44// interfaces
55import {IAppFactoryBase} from "src/apps/facets/factory/IAppFactory.sol " ;
6+ import {UpgradeableBeaconFacet} from "src/diamond/facets/beacon/UpgradeableBeaconFacet.sol " ;
67
78// libraries
89import {console} from "forge-std/console.sol " ;
@@ -14,50 +15,83 @@ import {DeployAppRegistry} from "../deployments/diamonds/DeployAppRegistry.s.sol
1415import {DeploySimpleAppBeacon} from "../deployments/diamonds/DeploySimpleAppBeacon.s.sol " ;
1516
1617// 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 " ;
18+ import {MultiInit} from "@towns-protocol/diamond/src/initializers/MultiInit.sol " ;
19+ import {DeployIdentityRegistry} from "../deployments/facets/DeployIdentityRegistry.s.sol " ;
20+ import {DeployReputationRegistry} from "../deployments/facets/DeployReputationRegistry.s.sol " ;
21+ import {DeployFacet} from "../common/DeployFacet.s.sol " ;
2022
2123contract InteractAppRegistry is Interaction , AlphaHelper {
2224 DeployAppRegistry private deployHelper = new DeployAppRegistry ();
2325 DeploySimpleAppBeacon private beaconHelper = new DeploySimpleAppBeacon ();
26+ DeployFacet private facetHelper = new DeployFacet ();
27+
28+ string internal constant FEEDBACK_SCHEMA =
29+ "uint256 agentId, uint8 score, bytes32 tag1, bytes32 tag2, string feedbackUri, bytes32 feedbackHash " ;
30+ string internal constant RESPONSE_SCHEMA =
31+ "uint256 agentId, address reviewerAddress, uint64 feedbackIndex, string responseUri, bytes32 responseHash " ;
2432
2533 function __interact (address deployer ) internal override {
26- // Get the deployed AppRegistry diamond address
34+ // Get the deployed contract addresses
2735 address appRegistry = getDeployment ("appRegistry " );
28- address spaceFactory = getDeployment ("spaceFactory " );
2936 address simpleAppBeacon = getDeployment ("simpleAppBeacon " );
30- address entryPoint = getDeployment ("entryPoint " );
3137
3238 console.log ("AppRegistry Diamond: " , appRegistry);
33- console.log ("Space Factory: " , spaceFactory);
3439 console.log ("Simple App Beacon: " , simpleAppBeacon);
3540
3641 // Deploy new facet implementations
3742 console.log ("\n=== Deploying New Facets === " );
3843 vm.setEnv ("OVERRIDE_DEPLOYMENTS " , "1 " );
3944
40- address appRegistryFacet = DeployAppRegistryFacet.deploy ();
41- console.log ("AppRegistryFacet deployed at: " , appRegistryFacet);
45+ // Deploy Identity Registry Facet
46+ address identityRegistryFacet = DeployIdentityRegistry.deploy ();
47+ console.log ("IdentityRegistryFacet deployed at: " , identityRegistryFacet);
48+
49+ // Deploy Reputation Registry Facet
50+ address reputationRegistryFacet = DeployReputationRegistry.deploy ();
51+ console.log ("ReputationRegistryFacet deployed at: " , reputationRegistryFacet);
52+
53+ // Deploy new version of Simple App Facet
54+ facetHelper.add ("SimpleAppFacet " );
55+ facetHelper.deployBatch (deployer);
56+ address newSimpleAppFacet = facetHelper.getDeployedAddress ("SimpleAppFacet " );
57+ console.log ("SimpleAppFacet deployed at: " , newSimpleAppFacet);
4258
43- address appInstallerFacet = DeployAppInstallerFacet.deploy ();
44- console.log ("AppInstallerFacet deployed at: " , appInstallerFacet);
59+ // Upgrade Simple App Beacon to use new implementation
60+ console.log ("\n=== Upgrading Simple App Beacon === " );
61+ vm.broadcast (deployer);
62+ UpgradeableBeaconFacet (simpleAppBeacon).upgradeTo (newSimpleAppFacet);
63+ console.log ("Simple App Beacon upgraded to: " , newSimpleAppFacet);
4564
46- address appFactoryFacet = DeployAppFactoryFacet.deploy ();
47- console.log ("AppFactoryFacet deployed at: " , appFactoryFacet);
65+ // Add the cuts for the new registry facets (Add action)
66+ addCut (DeployIdentityRegistry.makeCut (identityRegistryFacet, FacetCutAction.Add));
67+ addCut (DeployReputationRegistry.makeCut (reputationRegistryFacet, FacetCutAction.Add));
68+
69+ // Prepare initialization data for the new facets
70+ bytes memory identityInitData = DeployIdentityRegistry.makeInitData ();
71+ bytes memory reputationInitData = DeployReputationRegistry.makeInitData (
72+ FEEDBACK_SCHEMA,
73+ RESPONSE_SCHEMA
74+ );
4875
49- // Add the cuts for the new facet implementations
50- addCut (DeployAppRegistryFacet.makeCut (appRegistryFacet, FacetCutAction.Replace));
51- addCut (DeployAppInstallerFacet.makeCut (appInstallerFacet, FacetCutAction.Replace));
52- addCut (DeployAppFactoryFacet.makeCut (appFactoryFacet, FacetCutAction.Replace));
76+ // Prepare combined initialization using MultiInit pattern
77+ address [] memory initAddresses = new address [](2 );
78+ bytes [] memory initDatas = new bytes [](2 );
5379
54- // Prepare initialization data for AppFactoryFacet with the beacon configuration
55- IAppFactoryBase.Beacon[] memory beacons = new IAppFactoryBase.Beacon [](1 );
56- beacons[0 ] = IAppFactoryBase.Beacon ({
57- beaconId: beaconHelper.SIMPLE_APP_BEACON_ID (),
58- beacon: simpleAppBeacon
59- });
60- bytes memory initData = DeployAppFactoryFacet.makeInitData (beacons, entryPoint);
80+ initAddresses[0 ] = identityRegistryFacet;
81+ initDatas[0 ] = identityInitData;
82+
83+ initAddresses[1 ] = reputationRegistryFacet;
84+ initDatas[1 ] = reputationInitData;
85+
86+ // Get MultiInit address from facet helper
87+ facetHelper.add ("MultiInit " );
88+ facetHelper.deployBatch (deployer);
89+ address multiInit = facetHelper.getDeployedAddress ("MultiInit " );
90+
91+ bytes memory combinedInitData = abi.encodeCall (
92+ MultiInit.multiInit,
93+ (initAddresses, initDatas)
94+ );
6195
6296 // Generate and execute smart cuts with initialization
6397 console.log ("\n=== Executing Diamond Cut with Initialization === " );
@@ -66,8 +100,8 @@ contract InteractAppRegistry is Interaction, AlphaHelper {
66100 appRegistry,
67101 "AppRegistry " ,
68102 deployHelper,
69- appFactoryFacet ,
70- initData
103+ multiInit ,
104+ combinedInitData
71105 );
72106
73107 console.log ("\n=== Diamond Cut Complete === " );
0 commit comments