@towns-protocol/contracts 0.0.455 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/scripts/deployments/diamonds/DeployL1Resolver.s.sol +155 -0
- package/scripts/deployments/diamonds/DeployL2Registrar.s.sol +171 -0
- package/scripts/deployments/diamonds/DeployL2Resolver.s.sol +196 -0
- package/scripts/deployments/diamonds/DeploySpaceFactory.s.sol +0 -12
- package/scripts/deployments/facets/DeployAddrResolverFacet.s.sol +36 -0
- package/scripts/deployments/facets/DeployArchitect.s.sol +1 -3
- package/scripts/deployments/facets/DeployContentHashResolverFacet.s.sol +34 -0
- package/scripts/deployments/facets/DeployCreateSpace.s.sol +2 -1
- package/scripts/deployments/facets/{DeploySpaceFactoryInit.s.sol → DeployExtendedResolverFacet.s.sol} +10 -10
- package/scripts/deployments/facets/DeployL1ResolverFacet.s.sol +61 -0
- package/scripts/deployments/facets/DeployL2RegistrarFacet.s.sol +56 -0
- package/scripts/deployments/facets/DeployL2RegistryFacet.s.sol +71 -0
- package/scripts/deployments/facets/DeployNodeRegistry.s.sol +4 -1
- package/scripts/deployments/facets/DeployTextResolverFacet.s.sol +34 -0
- package/scripts/deployments/utils/DeployDomainFeeHook.s.sol +78 -0
- package/scripts/interactions/InteractAlphaPost.s.sol +0 -7
- package/scripts/interactions/InteractBaseAlpha.s.sol +1 -14
- package/scripts/interactions/InteractDomainFee.s.sol +62 -0
- package/scripts/interactions/InteractSetStreamDistributionBalancingAdvantage.s.sol +42 -0
- package/scripts/interactions/InteractSetStreamDistributionRequiredOperators.s.sol +32 -0
- package/scripts/interactions/helpers/RiverConfigValues.sol +6 -0
- package/src/domains/facets/l1/IL1ResolverService.sol +20 -0
- package/src/domains/facets/l1/L1ResolverFacet.sol +100 -0
- package/src/domains/facets/l1/L1ResolverMod.sol +245 -0
- package/src/domains/facets/l2/AddrResolverFacet.sol +59 -0
- package/src/domains/facets/l2/ContentHashResolverFacet.sol +41 -0
- package/src/domains/facets/l2/ExtendedResolverFacet.sol +38 -0
- package/src/domains/facets/l2/IL2Registry.sol +79 -0
- package/src/domains/facets/l2/L2RegistryFacet.sol +203 -0
- package/src/domains/facets/l2/TextResolverFacet.sol +43 -0
- package/src/domains/facets/l2/modules/AddrResolverMod.sol +110 -0
- package/src/domains/facets/l2/modules/ContentHashResolverMod.sol +60 -0
- package/src/domains/facets/l2/modules/L2RegistryMod.sol +286 -0
- package/src/domains/facets/l2/modules/TextResolverMod.sol +62 -0
- package/src/domains/facets/l2/modules/VersionRecordMod.sol +42 -0
- package/src/domains/facets/registrar/IL2Registrar.sol +57 -0
- package/src/domains/facets/registrar/L2RegistrarFacet.sol +127 -0
- package/src/domains/facets/registrar/L2RegistrarMod.sol +224 -0
- package/src/domains/hooks/DomainFeeHook.sol +212 -0
- package/src/factory/facets/architect/Architect.sol +48 -29
- package/src/factory/facets/architect/IArchitect.sol +2 -21
- package/src/factory/facets/architect/ImplementationStorage.sol +12 -20
- package/src/factory/facets/create/CreateSpace.sol +5 -0
- package/src/factory/facets/create/CreateSpaceBase.sol +32 -8
- package/src/factory/facets/create/ICreateSpace.sol +5 -0
- package/src/factory/facets/fee/FeeManagerFacet.sol +10 -0
- package/src/factory/facets/fee/FeeTypesLib.sol +3 -0
- package/src/river/registry/facets/node/INodeRegistry.sol +25 -0
- package/src/river/registry/facets/node/NodeRegistry.sol +53 -2
- package/src/river/registry/libraries/RegistryStorage.sol +5 -0
- package/src/spaces/facets/ProtocolFeeLib.sol +56 -1
- package/src/spaces/facets/proxy/SpaceProxyInitializer.sol +6 -8
- package/src/spaces/facets/xchain/SpaceEntitlementGated.sol +9 -0
- package/LICENSE.txt +0 -21
- package/scripts/bytecode-diff/README.md +0 -182
- package/scripts/deployments/utils/DeploySpaceProxyInitializer.s.sol +0 -28
- package/scripts/readme.md +0 -289
- package/src/diamond/readme.md +0 -50
- package/src/factory/SpaceFactoryInit.sol +0 -17
- package/src/factory/facets/architect/ArchitectBase.sol +0 -95
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@towns-protocol/contracts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"clean": "forge clean",
|
|
6
6
|
"compile": "forge build",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"account-abstraction": "github:eth-infinitism/account-abstraction#v0.7.0",
|
|
26
26
|
"crypto-lib": "github:towns-protocol/crypto-lib#v1.0.1",
|
|
27
27
|
"modular-account": "github:towns-protocol/modular-account#v1.0.0",
|
|
28
|
-
"solady": "^0.1.26"
|
|
28
|
+
"solady": "^0.1.26",
|
|
29
|
+
"ens-contracts": "github:ensdomains/ens-contracts#v1.6.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@layerzerolabs/lz-evm-messagelib-v2": "^3.0.112",
|
|
@@ -49,6 +50,5 @@
|
|
|
49
50
|
],
|
|
50
51
|
"publishConfig": {
|
|
51
52
|
"access": "public"
|
|
52
|
-
}
|
|
53
|
-
"gitHead": "9a5d511378b12fca4eb316895e0bbfe137de137b"
|
|
53
|
+
}
|
|
54
54
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.29;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IDiamondInitHelper} from "./IDiamondInitHelper.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
import {DeployDiamondCut} from "@towns-protocol/diamond/scripts/deployments/facets/DeployDiamondCut.sol";
|
|
9
|
+
import {DeployDiamondLoupe} from "@towns-protocol/diamond/scripts/deployments/facets/DeployDiamondLoupe.sol";
|
|
10
|
+
import {DeployIntrospection} from "@towns-protocol/diamond/scripts/deployments/facets/DeployIntrospection.sol";
|
|
11
|
+
import {DeployOwnable} from "@towns-protocol/diamond/scripts/deployments/facets/DeployOwnable.sol";
|
|
12
|
+
import {DeployMetadata} from "../facets/DeployMetadata.s.sol";
|
|
13
|
+
import {DeployL1ResolverFacet} from "../facets/DeployL1ResolverFacet.s.sol";
|
|
14
|
+
import {LibString} from "solady/utils/LibString.sol";
|
|
15
|
+
|
|
16
|
+
// contracts
|
|
17
|
+
import {Diamond} from "@towns-protocol/diamond/src/Diamond.sol";
|
|
18
|
+
import {MultiInit} from "@towns-protocol/diamond/src/initializers/MultiInit.sol";
|
|
19
|
+
import {DiamondHelper} from "@towns-protocol/diamond/scripts/common/helpers/DiamondHelper.s.sol";
|
|
20
|
+
|
|
21
|
+
// deployers
|
|
22
|
+
import {DeployFacet} from "../../common/DeployFacet.s.sol";
|
|
23
|
+
import {Deployer} from "../../common/Deployer.s.sol";
|
|
24
|
+
|
|
25
|
+
contract DeployL1Resolver is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
26
|
+
using LibString for string;
|
|
27
|
+
|
|
28
|
+
DeployFacet private facetHelper = new DeployFacet();
|
|
29
|
+
|
|
30
|
+
// Placeholder gateway URL - should be configured for production
|
|
31
|
+
string private GATEWAY_URL = "https://ccip.towns.app/v1/ccip-read/{sender}/{data}";
|
|
32
|
+
address private GATEWAY_SIGNER;
|
|
33
|
+
|
|
34
|
+
bytes32 internal constant METADATA_NAME = bytes32("L1Resolver");
|
|
35
|
+
|
|
36
|
+
function versionName() public pure override returns (string memory) {
|
|
37
|
+
return "l1Resolver";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function setGatewayURL(string memory gatewayUrl) external {
|
|
41
|
+
GATEWAY_URL = gatewayUrl;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function setGatewaySigner(address gatewaySigner) external {
|
|
45
|
+
GATEWAY_SIGNER = gatewaySigner;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function addImmutableCuts(address deployer) internal {
|
|
49
|
+
// Queue up all core facets for batch deployment
|
|
50
|
+
facetHelper.add("DiamondCutFacet");
|
|
51
|
+
facetHelper.add("DiamondLoupeFacet");
|
|
52
|
+
facetHelper.add("IntrospectionFacet");
|
|
53
|
+
facetHelper.add("OwnableFacet");
|
|
54
|
+
|
|
55
|
+
// Get predicted addresses and add facets
|
|
56
|
+
address facet = facetHelper.predictAddress("DiamondCutFacet");
|
|
57
|
+
addFacet(
|
|
58
|
+
makeCut(facet, FacetCutAction.Add, DeployDiamondCut.selectors()),
|
|
59
|
+
facet,
|
|
60
|
+
DeployDiamondCut.makeInitData()
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
facet = facetHelper.predictAddress("DiamondLoupeFacet");
|
|
64
|
+
addFacet(
|
|
65
|
+
makeCut(facet, FacetCutAction.Add, DeployDiamondLoupe.selectors()),
|
|
66
|
+
facet,
|
|
67
|
+
DeployDiamondLoupe.makeInitData()
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
facet = facetHelper.predictAddress("IntrospectionFacet");
|
|
71
|
+
addFacet(
|
|
72
|
+
makeCut(facet, FacetCutAction.Add, DeployIntrospection.selectors()),
|
|
73
|
+
facet,
|
|
74
|
+
DeployIntrospection.makeInitData()
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
facet = facetHelper.predictAddress("OwnableFacet");
|
|
78
|
+
addFacet(
|
|
79
|
+
makeCut(facet, FacetCutAction.Add, DeployOwnable.selectors()),
|
|
80
|
+
facet,
|
|
81
|
+
DeployOwnable.makeInitData(deployer)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function diamondInitParams(address deployer) public returns (Diamond.InitParams memory) {
|
|
86
|
+
// Use deployer as gateway signer if not set
|
|
87
|
+
address gatewaySigner = GATEWAY_SIGNER == address(0) ? deployer : GATEWAY_SIGNER;
|
|
88
|
+
|
|
89
|
+
// Queue up feature facets for batch deployment
|
|
90
|
+
facetHelper.add("MultiInit");
|
|
91
|
+
facetHelper.add("MetadataFacet");
|
|
92
|
+
facetHelper.add("L1ResolverFacet");
|
|
93
|
+
|
|
94
|
+
// Deploy the batch of facets
|
|
95
|
+
facetHelper.deployBatch(deployer);
|
|
96
|
+
|
|
97
|
+
// Add MetadataFacet
|
|
98
|
+
address facet = facetHelper.getDeployedAddress("MetadataFacet");
|
|
99
|
+
addFacet(
|
|
100
|
+
makeCut(facet, FacetCutAction.Add, DeployMetadata.selectors()),
|
|
101
|
+
facet,
|
|
102
|
+
DeployMetadata.makeInitData(METADATA_NAME, "")
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// Add L1ResolverFacet
|
|
106
|
+
facet = facetHelper.getDeployedAddress("L1ResolverFacet");
|
|
107
|
+
addFacet(
|
|
108
|
+
makeCut(facet, FacetCutAction.Add, DeployL1ResolverFacet.selectors()),
|
|
109
|
+
facet,
|
|
110
|
+
DeployL1ResolverFacet.makeInitData(GATEWAY_URL, gatewaySigner)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
address multiInit = facetHelper.getDeployedAddress("MultiInit");
|
|
114
|
+
|
|
115
|
+
return
|
|
116
|
+
Diamond.InitParams({
|
|
117
|
+
baseFacets: baseFacets(),
|
|
118
|
+
init: multiInit,
|
|
119
|
+
initData: abi.encodeCall(MultiInit.multiInit, (_initAddresses, _initDatas))
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function diamondInitHelper(
|
|
124
|
+
address deployer,
|
|
125
|
+
string[] memory facetNames
|
|
126
|
+
) external override returns (FacetCut[] memory) {
|
|
127
|
+
for (uint256 i; i < facetNames.length; ++i) {
|
|
128
|
+
facetHelper.add(facetNames[i]);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
facetHelper.deployBatch(deployer);
|
|
132
|
+
|
|
133
|
+
for (uint256 i; i < facetNames.length; ++i) {
|
|
134
|
+
string memory facetName = facetNames[i];
|
|
135
|
+
address facet = facetHelper.getDeployedAddress(facetName);
|
|
136
|
+
|
|
137
|
+
if (facetName.eq("L1ResolverFacet")) {
|
|
138
|
+
addCut(makeCut(facet, FacetCutAction.Add, DeployL1ResolverFacet.selectors()));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return baseFacets();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function __deploy(address deployer) internal override returns (address) {
|
|
146
|
+
addImmutableCuts(deployer);
|
|
147
|
+
|
|
148
|
+
Diamond.InitParams memory initDiamondCut = diamondInitParams(deployer);
|
|
149
|
+
|
|
150
|
+
vm.broadcast(deployer);
|
|
151
|
+
Diamond diamond = new Diamond(initDiamondCut);
|
|
152
|
+
|
|
153
|
+
return address(diamond);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.29;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IDiamondInitHelper} from "./IDiamondInitHelper.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
import {DeployDiamondCut} from "@towns-protocol/diamond/scripts/deployments/facets/DeployDiamondCut.sol";
|
|
9
|
+
import {DeployDiamondLoupe} from "@towns-protocol/diamond/scripts/deployments/facets/DeployDiamondLoupe.sol";
|
|
10
|
+
import {DeployIntrospection} from "@towns-protocol/diamond/scripts/deployments/facets/DeployIntrospection.sol";
|
|
11
|
+
import {DeployOwnable} from "@towns-protocol/diamond/scripts/deployments/facets/DeployOwnable.sol";
|
|
12
|
+
import {DeployMetadata} from "../facets/DeployMetadata.s.sol";
|
|
13
|
+
import {DeployL2RegistrarFacet} from "../facets/DeployL2RegistrarFacet.s.sol";
|
|
14
|
+
import {LibString} from "solady/utils/LibString.sol";
|
|
15
|
+
|
|
16
|
+
// contracts
|
|
17
|
+
import {Diamond} from "@towns-protocol/diamond/src/Diamond.sol";
|
|
18
|
+
import {MultiInit} from "@towns-protocol/diamond/src/initializers/MultiInit.sol";
|
|
19
|
+
import {DiamondHelper} from "@towns-protocol/diamond/scripts/common/helpers/DiamondHelper.s.sol";
|
|
20
|
+
|
|
21
|
+
// deployers
|
|
22
|
+
import {DeployFacet} from "../../common/DeployFacet.s.sol";
|
|
23
|
+
import {Deployer} from "../../common/Deployer.s.sol";
|
|
24
|
+
|
|
25
|
+
contract DeployL2Registrar is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
26
|
+
using LibString for string;
|
|
27
|
+
|
|
28
|
+
bytes32 internal constant METADATA_NAME = bytes32("L2Registrar");
|
|
29
|
+
|
|
30
|
+
DeployFacet private facetHelper = new DeployFacet();
|
|
31
|
+
|
|
32
|
+
address private REGISTRY;
|
|
33
|
+
address private SPACE_FACTORY;
|
|
34
|
+
address private USDC;
|
|
35
|
+
|
|
36
|
+
function setRegistry(address registry) external {
|
|
37
|
+
REGISTRY = registry;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function setSpaceFactory(address spaceFactory) external {
|
|
41
|
+
SPACE_FACTORY = spaceFactory;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function setUSDC(address usdc) external {
|
|
45
|
+
USDC = usdc;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function diamondInitHelper(
|
|
49
|
+
address deployer,
|
|
50
|
+
string[] memory facetNames
|
|
51
|
+
) external override returns (FacetCut[] memory) {
|
|
52
|
+
for (uint256 i; i < facetNames.length; ++i) {
|
|
53
|
+
facetHelper.add(facetNames[i]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
facetHelper.deployBatch(deployer);
|
|
57
|
+
|
|
58
|
+
for (uint256 i; i < facetNames.length; ++i) {
|
|
59
|
+
string memory facetName = facetNames[i];
|
|
60
|
+
address facet = facetHelper.getDeployedAddress(facetName);
|
|
61
|
+
|
|
62
|
+
if (facetName.eq("L2RegistrarFacet")) {
|
|
63
|
+
addCut(makeCut(facet, FacetCutAction.Add, DeployL2RegistrarFacet.selectors()));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return baseFacets();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function diamondInitParams(address deployer) public returns (Diamond.InitParams memory) {
|
|
71
|
+
// Queue up feature facets for batch deployment
|
|
72
|
+
facetHelper.add("MultiInit");
|
|
73
|
+
facetHelper.add("MetadataFacet");
|
|
74
|
+
facetHelper.add("L2RegistrarFacet");
|
|
75
|
+
|
|
76
|
+
// Deploy the batch of facets
|
|
77
|
+
facetHelper.deployBatch(deployer);
|
|
78
|
+
|
|
79
|
+
// Add MetadataFacet
|
|
80
|
+
address facet = facetHelper.getDeployedAddress("MetadataFacet");
|
|
81
|
+
addFacet(
|
|
82
|
+
makeCut(facet, FacetCutAction.Add, DeployMetadata.selectors()),
|
|
83
|
+
facet,
|
|
84
|
+
DeployMetadata.makeInitData(METADATA_NAME, "")
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Add L2RegistrarFacet
|
|
88
|
+
facet = facetHelper.getDeployedAddress("L2RegistrarFacet");
|
|
89
|
+
addFacet(
|
|
90
|
+
makeCut(facet, FacetCutAction.Add, DeployL2RegistrarFacet.selectors()),
|
|
91
|
+
facet,
|
|
92
|
+
DeployL2RegistrarFacet.makeInitData(getRegistry(), getSpaceFactory(), getUSDC())
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
address multiInit = facetHelper.getDeployedAddress("MultiInit");
|
|
96
|
+
|
|
97
|
+
return
|
|
98
|
+
Diamond.InitParams({
|
|
99
|
+
baseFacets: baseFacets(),
|
|
100
|
+
init: multiInit,
|
|
101
|
+
initData: abi.encodeCall(MultiInit.multiInit, (_initAddresses, _initDatas))
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function versionName() public pure override returns (string memory) {
|
|
106
|
+
return "l2Registrar";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function getRegistry() internal returns (address) {
|
|
110
|
+
if (REGISTRY == address(0)) return getDeployment("l2Resolver");
|
|
111
|
+
else return REGISTRY;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getSpaceFactory() internal returns (address) {
|
|
115
|
+
if (SPACE_FACTORY == address(0)) return getDeployment("spaceFactory");
|
|
116
|
+
else return SPACE_FACTORY;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getUSDC() internal returns (address) {
|
|
120
|
+
if (USDC == address(0)) return getDeployment("usdc");
|
|
121
|
+
else return USDC;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function addImmutableCuts(address deployer) internal {
|
|
125
|
+
// Queue up all core facets for batch deployment
|
|
126
|
+
facetHelper.add("DiamondCutFacet");
|
|
127
|
+
facetHelper.add("DiamondLoupeFacet");
|
|
128
|
+
facetHelper.add("IntrospectionFacet");
|
|
129
|
+
facetHelper.add("OwnableFacet");
|
|
130
|
+
|
|
131
|
+
// Get predicted addresses and add facets
|
|
132
|
+
address facet = facetHelper.predictAddress("DiamondCutFacet");
|
|
133
|
+
addFacet(
|
|
134
|
+
makeCut(facet, FacetCutAction.Add, DeployDiamondCut.selectors()),
|
|
135
|
+
facet,
|
|
136
|
+
DeployDiamondCut.makeInitData()
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
facet = facetHelper.predictAddress("DiamondLoupeFacet");
|
|
140
|
+
addFacet(
|
|
141
|
+
makeCut(facet, FacetCutAction.Add, DeployDiamondLoupe.selectors()),
|
|
142
|
+
facet,
|
|
143
|
+
DeployDiamondLoupe.makeInitData()
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
facet = facetHelper.predictAddress("IntrospectionFacet");
|
|
147
|
+
addFacet(
|
|
148
|
+
makeCut(facet, FacetCutAction.Add, DeployIntrospection.selectors()),
|
|
149
|
+
facet,
|
|
150
|
+
DeployIntrospection.makeInitData()
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
facet = facetHelper.predictAddress("OwnableFacet");
|
|
154
|
+
addFacet(
|
|
155
|
+
makeCut(facet, FacetCutAction.Add, DeployOwnable.selectors()),
|
|
156
|
+
facet,
|
|
157
|
+
DeployOwnable.makeInitData(deployer)
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function __deploy(address deployer) internal override returns (address) {
|
|
162
|
+
addImmutableCuts(deployer);
|
|
163
|
+
|
|
164
|
+
Diamond.InitParams memory initDiamondCut = diamondInitParams(deployer);
|
|
165
|
+
|
|
166
|
+
vm.broadcast(deployer);
|
|
167
|
+
Diamond diamond = new Diamond(initDiamondCut);
|
|
168
|
+
|
|
169
|
+
return address(diamond);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.29;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IDiamondInitHelper} from "./IDiamondInitHelper.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
import {DeployDiamondCut} from "@towns-protocol/diamond/scripts/deployments/facets/DeployDiamondCut.sol";
|
|
9
|
+
import {DeployDiamondLoupe} from "@towns-protocol/diamond/scripts/deployments/facets/DeployDiamondLoupe.sol";
|
|
10
|
+
import {DeployIntrospection} from "@towns-protocol/diamond/scripts/deployments/facets/DeployIntrospection.sol";
|
|
11
|
+
import {DeployOwnable} from "@towns-protocol/diamond/scripts/deployments/facets/DeployOwnable.sol";
|
|
12
|
+
import {DeployMetadata} from "../facets/DeployMetadata.s.sol";
|
|
13
|
+
import {DeployL2RegistryFacet} from "../facets/DeployL2RegistryFacet.s.sol";
|
|
14
|
+
import {DeployAddrResolverFacet} from "../facets/DeployAddrResolverFacet.s.sol";
|
|
15
|
+
import {DeployTextResolverFacet} from "../facets/DeployTextResolverFacet.s.sol";
|
|
16
|
+
import {DeployExtendedResolverFacet} from "../facets/DeployExtendedResolverFacet.s.sol";
|
|
17
|
+
import {DeployContentHashResolverFacet} from "../facets/DeployContentHashResolverFacet.s.sol";
|
|
18
|
+
import {LibString} from "solady/utils/LibString.sol";
|
|
19
|
+
|
|
20
|
+
// contracts
|
|
21
|
+
import {Diamond} from "@towns-protocol/diamond/src/Diamond.sol";
|
|
22
|
+
import {MultiInit} from "@towns-protocol/diamond/src/initializers/MultiInit.sol";
|
|
23
|
+
import {DiamondHelper} from "@towns-protocol/diamond/scripts/common/helpers/DiamondHelper.s.sol";
|
|
24
|
+
|
|
25
|
+
// deployers
|
|
26
|
+
import {DeployFacet} from "../../common/DeployFacet.s.sol";
|
|
27
|
+
import {Deployer} from "../../common/Deployer.s.sol";
|
|
28
|
+
|
|
29
|
+
contract DeployL2Resolver is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
30
|
+
using LibString for string;
|
|
31
|
+
|
|
32
|
+
DeployFacet private facetHelper = new DeployFacet();
|
|
33
|
+
|
|
34
|
+
string private DOMAIN = "towns.eth";
|
|
35
|
+
|
|
36
|
+
bytes32 internal constant METADATA_NAME = bytes32("L2Resolver");
|
|
37
|
+
|
|
38
|
+
function versionName() public pure override returns (string memory) {
|
|
39
|
+
return "l2Resolver";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function setDomain(string memory domain) external {
|
|
43
|
+
DOMAIN = domain;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function addImmutableCuts(address deployer) internal {
|
|
47
|
+
// Queue up all core facets for batch deployment
|
|
48
|
+
facetHelper.add("DiamondCutFacet");
|
|
49
|
+
facetHelper.add("DiamondLoupeFacet");
|
|
50
|
+
facetHelper.add("IntrospectionFacet");
|
|
51
|
+
facetHelper.add("OwnableFacet");
|
|
52
|
+
|
|
53
|
+
// Get predicted addresses and add facets
|
|
54
|
+
address facet = facetHelper.predictAddress("DiamondCutFacet");
|
|
55
|
+
addFacet(
|
|
56
|
+
makeCut(facet, FacetCutAction.Add, DeployDiamondCut.selectors()),
|
|
57
|
+
facet,
|
|
58
|
+
DeployDiamondCut.makeInitData()
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
facet = facetHelper.predictAddress("DiamondLoupeFacet");
|
|
62
|
+
addFacet(
|
|
63
|
+
makeCut(facet, FacetCutAction.Add, DeployDiamondLoupe.selectors()),
|
|
64
|
+
facet,
|
|
65
|
+
DeployDiamondLoupe.makeInitData()
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
facet = facetHelper.predictAddress("IntrospectionFacet");
|
|
69
|
+
addFacet(
|
|
70
|
+
makeCut(facet, FacetCutAction.Add, DeployIntrospection.selectors()),
|
|
71
|
+
facet,
|
|
72
|
+
DeployIntrospection.makeInitData()
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
facet = facetHelper.predictAddress("OwnableFacet");
|
|
76
|
+
addFacet(
|
|
77
|
+
makeCut(facet, FacetCutAction.Add, DeployOwnable.selectors()),
|
|
78
|
+
facet,
|
|
79
|
+
DeployOwnable.makeInitData(deployer)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function diamondInitParams(address deployer) public returns (Diamond.InitParams memory) {
|
|
84
|
+
// Queue up feature facets for batch deployment
|
|
85
|
+
facetHelper.add("MultiInit");
|
|
86
|
+
facetHelper.add("MetadataFacet");
|
|
87
|
+
facetHelper.add("L2RegistryFacet");
|
|
88
|
+
facetHelper.add("AddrResolverFacet");
|
|
89
|
+
facetHelper.add("TextResolverFacet");
|
|
90
|
+
facetHelper.add("ExtendedResolverFacet");
|
|
91
|
+
facetHelper.add("ContentHashResolverFacet");
|
|
92
|
+
|
|
93
|
+
// Deploy the batch of facets
|
|
94
|
+
facetHelper.deployBatch(deployer);
|
|
95
|
+
|
|
96
|
+
// Add MetadataFacet
|
|
97
|
+
address facet = facetHelper.getDeployedAddress("MetadataFacet");
|
|
98
|
+
addFacet(
|
|
99
|
+
makeCut(facet, FacetCutAction.Add, DeployMetadata.selectors()),
|
|
100
|
+
facet,
|
|
101
|
+
DeployMetadata.makeInitData(METADATA_NAME, "")
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// Add L2RegistryFacet
|
|
105
|
+
facet = facetHelper.getDeployedAddress("L2RegistryFacet");
|
|
106
|
+
addFacet(
|
|
107
|
+
makeCut(facet, FacetCutAction.Add, DeployL2RegistryFacet.selectors()),
|
|
108
|
+
facet,
|
|
109
|
+
DeployL2RegistryFacet.makeInitData(DOMAIN, deployer)
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Add AddrResolverFacet
|
|
113
|
+
facet = facetHelper.getDeployedAddress("AddrResolverFacet");
|
|
114
|
+
addFacet(
|
|
115
|
+
makeCut(facet, FacetCutAction.Add, DeployAddrResolverFacet.selectors()),
|
|
116
|
+
facet,
|
|
117
|
+
DeployAddrResolverFacet.makeInitData()
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
// Add TextResolverFacet
|
|
121
|
+
facet = facetHelper.getDeployedAddress("TextResolverFacet");
|
|
122
|
+
addFacet(
|
|
123
|
+
makeCut(facet, FacetCutAction.Add, DeployTextResolverFacet.selectors()),
|
|
124
|
+
facet,
|
|
125
|
+
DeployTextResolverFacet.makeInitData()
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// Add ExtendedResolverFacet
|
|
129
|
+
facet = facetHelper.getDeployedAddress("ExtendedResolverFacet");
|
|
130
|
+
addFacet(
|
|
131
|
+
makeCut(facet, FacetCutAction.Add, DeployExtendedResolverFacet.selectors()),
|
|
132
|
+
facet,
|
|
133
|
+
DeployExtendedResolverFacet.makeInitData()
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// Add ContentHashResolverFacet
|
|
137
|
+
facet = facetHelper.getDeployedAddress("ContentHashResolverFacet");
|
|
138
|
+
addFacet(
|
|
139
|
+
makeCut(facet, FacetCutAction.Add, DeployContentHashResolverFacet.selectors()),
|
|
140
|
+
facet,
|
|
141
|
+
DeployContentHashResolverFacet.makeInitData()
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
address multiInit = facetHelper.getDeployedAddress("MultiInit");
|
|
145
|
+
|
|
146
|
+
return
|
|
147
|
+
Diamond.InitParams({
|
|
148
|
+
baseFacets: baseFacets(),
|
|
149
|
+
init: multiInit,
|
|
150
|
+
initData: abi.encodeCall(MultiInit.multiInit, (_initAddresses, _initDatas))
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function diamondInitHelper(
|
|
155
|
+
address deployer,
|
|
156
|
+
string[] memory facetNames
|
|
157
|
+
) external override returns (FacetCut[] memory) {
|
|
158
|
+
for (uint256 i; i < facetNames.length; ++i) {
|
|
159
|
+
facetHelper.add(facetNames[i]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
facetHelper.deployBatch(deployer);
|
|
163
|
+
|
|
164
|
+
for (uint256 i; i < facetNames.length; ++i) {
|
|
165
|
+
string memory facetName = facetNames[i];
|
|
166
|
+
address facet = facetHelper.getDeployedAddress(facetName);
|
|
167
|
+
|
|
168
|
+
if (facetName.eq("L2RegistryFacet")) {
|
|
169
|
+
addCut(makeCut(facet, FacetCutAction.Add, DeployL2RegistryFacet.selectors()));
|
|
170
|
+
} else if (facetName.eq("AddrResolverFacet")) {
|
|
171
|
+
addCut(makeCut(facet, FacetCutAction.Add, DeployAddrResolverFacet.selectors()));
|
|
172
|
+
} else if (facetName.eq("TextResolverFacet")) {
|
|
173
|
+
addCut(makeCut(facet, FacetCutAction.Add, DeployTextResolverFacet.selectors()));
|
|
174
|
+
} else if (facetName.eq("ExtendedResolverFacet")) {
|
|
175
|
+
addCut(makeCut(facet, FacetCutAction.Add, DeployExtendedResolverFacet.selectors()));
|
|
176
|
+
} else if (facetName.eq("ContentHashResolverFacet")) {
|
|
177
|
+
addCut(
|
|
178
|
+
makeCut(facet, FacetCutAction.Add, DeployContentHashResolverFacet.selectors())
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return baseFacets();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function __deploy(address deployer) internal override returns (address) {
|
|
187
|
+
addImmutableCuts(deployer);
|
|
188
|
+
|
|
189
|
+
Diamond.InitParams memory initDiamondCut = diamondInitParams(deployer);
|
|
190
|
+
|
|
191
|
+
vm.broadcast(deployer);
|
|
192
|
+
Diamond diamond = new Diamond(initDiamondCut);
|
|
193
|
+
|
|
194
|
+
return address(diamond);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -15,7 +15,6 @@ import {DeployProxyManager} from "@towns-protocol/diamond/scripts/deployments/ut
|
|
|
15
15
|
import {DeployFeatureManager} from "../facets/DeployFeatureManager.s.sol";
|
|
16
16
|
import {DeployMetadata} from "../facets/DeployMetadata.s.sol";
|
|
17
17
|
import {DeployPricingModules} from "../facets/DeployPricingModules.s.sol";
|
|
18
|
-
import {DeploySpaceFactoryInit} from "../facets/DeploySpaceFactoryInit.s.sol";
|
|
19
18
|
import {DeployArchitect} from "../facets/DeployArchitect.s.sol";
|
|
20
19
|
import {DeployCreateSpace} from "../facets/DeployCreateSpace.s.sol";
|
|
21
20
|
import {DeployImplementationRegistry} from "../facets/DeployImplementationRegistry.s.sol";
|
|
@@ -64,10 +63,6 @@ contract DeploySpaceFactory is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
64
63
|
address public fixedPricing;
|
|
65
64
|
address public mockDelegationRegistry;
|
|
66
65
|
|
|
67
|
-
// init
|
|
68
|
-
address public spaceFactoryInit;
|
|
69
|
-
bytes public spaceFactoryInitData;
|
|
70
|
-
|
|
71
66
|
function versionName() public pure override returns (string memory) {
|
|
72
67
|
return "spaceFactory";
|
|
73
68
|
}
|
|
@@ -150,8 +145,6 @@ contract DeploySpaceFactory is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
150
145
|
facetHelper.add("PartnerRegistry");
|
|
151
146
|
facetHelper.add("FeatureManagerFacet");
|
|
152
147
|
facetHelper.add("FeeManagerFacet");
|
|
153
|
-
facetHelper.add("SpaceProxyInitializer");
|
|
154
|
-
facetHelper.add("SpaceFactoryInit");
|
|
155
148
|
|
|
156
149
|
if (isAnvil()) {
|
|
157
150
|
facetHelper.add("MockDelegationRegistry");
|
|
@@ -277,11 +270,6 @@ contract DeploySpaceFactory is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
277
270
|
DeployFeeManager.makeInitData(deployer)
|
|
278
271
|
);
|
|
279
272
|
|
|
280
|
-
address spaceProxyInitializer = facetHelper.getDeployedAddress("SpaceProxyInitializer");
|
|
281
|
-
spaceFactoryInit = facetHelper.getDeployedAddress("SpaceFactoryInit");
|
|
282
|
-
spaceFactoryInitData = DeploySpaceFactoryInit.makeInitData(spaceProxyInitializer);
|
|
283
|
-
addInit(spaceFactoryInit, spaceFactoryInitData);
|
|
284
|
-
|
|
285
273
|
address multiInit = facetHelper.getDeployedAddress("MultiInit");
|
|
286
274
|
|
|
287
275
|
return
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.29;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IDiamond} from "@towns-protocol/diamond/src/IDiamond.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
import {LibDeploy} from "@towns-protocol/diamond/src/utils/LibDeploy.sol";
|
|
9
|
+
|
|
10
|
+
// contracts
|
|
11
|
+
import {AddrResolverFacet} from "src/domains/facets/l2/AddrResolverFacet.sol";
|
|
12
|
+
|
|
13
|
+
library DeployAddrResolverFacet {
|
|
14
|
+
function selectors() internal pure returns (bytes4[] memory res) {
|
|
15
|
+
res = new bytes4[](4);
|
|
16
|
+
res[0] = bytes4(keccak256("setAddr(bytes32,uint256,bytes)"));
|
|
17
|
+
res[1] = bytes4(keccak256("setAddr(bytes32,address)"));
|
|
18
|
+
res[2] = bytes4(keccak256("addr(bytes32,uint256)"));
|
|
19
|
+
res[3] = bytes4(keccak256("addr(bytes32)"));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function makeCut(
|
|
23
|
+
address facetAddress,
|
|
24
|
+
IDiamond.FacetCutAction action
|
|
25
|
+
) internal pure returns (IDiamond.FacetCut memory) {
|
|
26
|
+
return IDiamond.FacetCut(facetAddress, action, selectors());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function makeInitData() internal pure returns (bytes memory) {
|
|
30
|
+
return abi.encodeCall(AddrResolverFacet.__AddrResolverFacet_init, ());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function deploy() internal returns (address) {
|
|
34
|
+
return LibDeploy.deployCode("AddrResolverFacet.sol", "");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -13,13 +13,11 @@ import {Architect} from "src/factory/facets/architect/Architect.sol";
|
|
|
13
13
|
|
|
14
14
|
library DeployArchitect {
|
|
15
15
|
function selectors() internal pure returns (bytes4[] memory _selectors) {
|
|
16
|
-
_selectors = new bytes4[](
|
|
16
|
+
_selectors = new bytes4[](4);
|
|
17
17
|
_selectors[0] = IArchitect.getSpaceByTokenId.selector;
|
|
18
18
|
_selectors[1] = IArchitect.getTokenIdBySpace.selector;
|
|
19
19
|
_selectors[2] = IArchitect.setSpaceArchitectImplementations.selector;
|
|
20
20
|
_selectors[3] = IArchitect.getSpaceArchitectImplementations.selector;
|
|
21
|
-
_selectors[4] = IArchitect.setProxyInitializer.selector;
|
|
22
|
-
_selectors[5] = IArchitect.getProxyInitializer.selector;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
function makeCut(
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.29;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IDiamond} from "@towns-protocol/diamond/src/IDiamond.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
import {LibDeploy} from "@towns-protocol/diamond/src/utils/LibDeploy.sol";
|
|
9
|
+
|
|
10
|
+
// contracts
|
|
11
|
+
import {ContentHashResolverFacet} from "src/domains/facets/l2/ContentHashResolverFacet.sol";
|
|
12
|
+
|
|
13
|
+
library DeployContentHashResolverFacet {
|
|
14
|
+
function selectors() internal pure returns (bytes4[] memory res) {
|
|
15
|
+
res = new bytes4[](2);
|
|
16
|
+
res[0] = ContentHashResolverFacet.setContenthash.selector;
|
|
17
|
+
res[1] = ContentHashResolverFacet.contenthash.selector;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function makeCut(
|
|
21
|
+
address facetAddress,
|
|
22
|
+
IDiamond.FacetCutAction action
|
|
23
|
+
) internal pure returns (IDiamond.FacetCut memory) {
|
|
24
|
+
return IDiamond.FacetCut(facetAddress, action, selectors());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function makeInitData() internal pure returns (bytes memory) {
|
|
28
|
+
return abi.encodeCall(ContentHashResolverFacet.__ContentHashResolverFacet_init, ());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function deploy() internal returns (address) {
|
|
32
|
+
return LibDeploy.deployCode("ContentHashResolverFacet.sol", "");
|
|
33
|
+
}
|
|
34
|
+
}
|