@towns-protocol/contracts 0.0.453 → 1.0.1
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 +7 -7
- package/scripts/common/Interaction.s.sol +3 -3
- package/scripts/deployments/diamonds/DeployBaseRegistry.s.sol +1 -4
- package/scripts/deployments/diamonds/DeployL1Resolver.s.sol +155 -0
- package/scripts/deployments/diamonds/DeployL2Registrar.s.sol +173 -0
- package/scripts/deployments/diamonds/DeployL2Resolver.s.sol +196 -0
- package/scripts/deployments/diamonds/DeploySpace.s.sol +1 -9
- package/scripts/deployments/diamonds/DeploySpaceFactory.s.sol +1 -5
- package/scripts/deployments/facets/DeployAddrResolverFacet.s.sol +36 -0
- package/scripts/deployments/facets/DeployAppFactoryFacet.s.sol +3 -3
- package/scripts/deployments/facets/DeployAppInstallerFacet.s.sol +3 -3
- package/scripts/deployments/facets/DeployAppRegistryFacet.s.sol +3 -3
- package/scripts/deployments/facets/DeployArchitect.s.sol +3 -3
- package/scripts/deployments/facets/DeployAttestationRegistry.s.sol +3 -3
- package/scripts/deployments/facets/DeployContentHashResolverFacet.s.sol +34 -0
- package/scripts/deployments/facets/DeployERC721ANonTransferable.s.sol +3 -3
- package/scripts/deployments/facets/DeployExtendedResolverFacet.s.sol +33 -0
- package/scripts/deployments/facets/DeployFeatureManager.s.sol +3 -3
- 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/DeployMainnetDelegation.s.sol +3 -3
- package/scripts/deployments/facets/DeployMembershipMetadata.s.sol +3 -3
- package/scripts/deployments/facets/DeployMerkleAirdrop.s.sol +3 -3
- package/scripts/deployments/facets/DeployMetadata.s.sol +3 -3
- package/scripts/deployments/facets/DeployMockLegacyArchitect.s.sol +3 -3
- package/scripts/deployments/facets/DeployNodeOperator.s.sol +3 -3
- package/scripts/deployments/facets/DeployPartnerRegistry.s.sol +3 -3
- package/scripts/deployments/facets/DeployPricingModules.s.sol +3 -3
- package/scripts/deployments/facets/DeploySchemaRegistry.s.sol +3 -3
- package/scripts/deployments/facets/DeploySpaceFactoryInit.s.sol +3 -3
- package/scripts/deployments/facets/DeploySpaceOwnerFacet.s.sol +3 -3
- package/scripts/deployments/facets/DeployTextResolverFacet.s.sol +34 -0
- package/scripts/deployments/facets/DeployTokenMigration.s.sol +3 -3
- package/scripts/deployments/facets/DeployXChain.s.sol +3 -3
- package/scripts/deployments/utils/DeployAccountFactory.s.sol +3 -3
- package/scripts/deployments/utils/DeployEntitlementGatedExample.s.sol +3 -3
- package/scripts/deployments/utils/DeployEntrypoint.s.sol +3 -3
- package/scripts/deployments/utils/DeployMember.s.sol +3 -3
- package/scripts/deployments/utils/DeployMockLegacyMembership.s.sol +3 -3
- package/scripts/deployments/utils/DeployMockMessenger.s.sol +3 -3
- package/scripts/deployments/utils/DeploySpaceProxyInitializer.s.sol +3 -3
- package/scripts/deployments/utils/DeployTieredLogPricingV2.s.sol +3 -3
- package/scripts/deployments/utils/DeployTieredLogPricingV3.s.sol +3 -3
- package/scripts/deployments/utils/DeployTownsBase.s.sol +3 -3
- package/scripts/deployments/utils/DeployTownsMainnet.s.sol +3 -3
- package/scripts/deployments/utils/pricing/TieredLogPricing.s.sol +3 -3
- package/scripts/interactions/InteractAirdrop.s.sol +3 -3
- package/scripts/interactions/InteractBaseBridge.s.sol +3 -3
- package/scripts/interactions/InteractRegisterApp.s.sol +2 -2
- package/scripts/interactions/InteractRiverRegistrySetTrimByStreamId.s.sol +44 -0
- package/scripts/interactions/helpers/RiverConfigValues.sol +1 -2
- package/src/account/facets/app/AppManagerFacet.sol +43 -14
- package/src/account/facets/app/AppManagerMod.sol +311 -278
- package/src/account/facets/hub/AccountHubFacet.sol +12 -11
- package/src/account/facets/hub/AccountHubMod.sol +117 -116
- package/src/account/facets/tipping/AccountTippingFacet.sol +10 -9
- package/src/account/facets/tipping/AccountTippingMod.sol +133 -124
- package/src/apps/modules/subscription/SubscriptionModuleStorage.sol +1 -1
- 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/fee/FeeTypesLib.sol +3 -0
- package/src/river/registry/facets/stream/StreamRegistry.sol +4 -1
- package/src/spaces/facets/ProtocolFeeLib.sol +56 -1
- package/src/tokens/Member.sol +3 -4
- package/LICENSE.txt +0 -21
- package/scripts/interactions/InteractRiverRegistrySetFreq.s.sol +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@towns-protocol/contracts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"clean": "forge clean",
|
|
6
6
|
"compile": "forge build",
|
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
"@openzeppelin/contracts": "^5.4.0",
|
|
21
21
|
"@openzeppelin/contracts-upgradeable": "^5.4.0",
|
|
22
22
|
"@prb/math": "^4.1.0",
|
|
23
|
-
"@towns-protocol/diamond": "^0.
|
|
23
|
+
"@towns-protocol/diamond": "^0.7.0",
|
|
24
24
|
"@uniswap/permit2": "github:towns-protocol/permit2#v1.0.0",
|
|
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.
|
|
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",
|
|
@@ -33,9 +34,9 @@
|
|
|
33
34
|
"@layerzerolabs/oapp-evm": "^0.3.2",
|
|
34
35
|
"@openzeppelin/merkle-tree": "^1.0.8",
|
|
35
36
|
"@prb/test": "^0.6.4",
|
|
36
|
-
"@towns-protocol/prettier-config": "
|
|
37
|
+
"@towns-protocol/prettier-config": "workspace:^",
|
|
37
38
|
"@wagmi/cli": "^2.2.0",
|
|
38
|
-
"forge-std": "github:foundry-rs/forge-std#v1.
|
|
39
|
+
"forge-std": "github:foundry-rs/forge-std#v1.12.0",
|
|
39
40
|
"prettier": "^3.5.3",
|
|
40
41
|
"prettier-plugin-solidity": "^1.4.2",
|
|
41
42
|
"solhint": "^5.0.5",
|
|
@@ -49,6 +50,5 @@
|
|
|
49
50
|
],
|
|
50
51
|
"publishConfig": {
|
|
51
52
|
"access": "public"
|
|
52
|
-
}
|
|
53
|
-
"gitHead": "f94c8877f1ce645d78158e8367c0c05b171c9141"
|
|
53
|
+
}
|
|
54
54
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
//interfaces
|
|
4
|
+
// interfaces
|
|
5
5
|
|
|
6
|
-
//libraries
|
|
6
|
+
// libraries
|
|
7
7
|
|
|
8
|
-
//contracts
|
|
8
|
+
// contracts
|
|
9
9
|
|
|
10
10
|
import {DeployBase} from "./DeployBase.s.sol";
|
|
11
11
|
import {Script} from "forge-std/Script.sol";
|
|
@@ -88,16 +88,13 @@ contract DeployBaseRegistry is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
88
88
|
facetHelper.add("NodeOperatorFacet");
|
|
89
89
|
facetHelper.add("MetadataFacet");
|
|
90
90
|
facetHelper.add("EntitlementChecker");
|
|
91
|
-
|
|
92
|
-
facetHelper.deployBatch(deployer);
|
|
93
|
-
|
|
94
91
|
facetHelper.add("RewardsDistributionV2");
|
|
95
92
|
facetHelper.add("SpaceDelegationFacet");
|
|
96
93
|
facetHelper.add("MainnetDelegation");
|
|
97
94
|
facetHelper.add("EIP712Facet");
|
|
98
95
|
facetHelper.add("XChain");
|
|
99
96
|
|
|
100
|
-
// Deploy all facets
|
|
97
|
+
// Deploy all facets
|
|
101
98
|
facetHelper.deployBatch(deployer);
|
|
102
99
|
|
|
103
100
|
// Deploy or retrieve the towns token
|
|
@@ -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,173 @@
|
|
|
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
|
+
require(REGISTRY != address(0), "DeployL2Registrar: registry not set");
|
|
163
|
+
|
|
164
|
+
addImmutableCuts(deployer);
|
|
165
|
+
|
|
166
|
+
Diamond.InitParams memory initDiamondCut = diamondInitParams(deployer);
|
|
167
|
+
|
|
168
|
+
vm.broadcast(deployer);
|
|
169
|
+
Diamond diamond = new Diamond(initDiamondCut);
|
|
170
|
+
|
|
171
|
+
return address(diamond);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -103,20 +103,12 @@ contract DeploySpace is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
103
103
|
facetHelper.add("MembershipFacet");
|
|
104
104
|
facetHelper.add("MembershipMetadata");
|
|
105
105
|
facetHelper.add("EntitlementDataQueryable");
|
|
106
|
-
|
|
107
|
-
// Deploy the first batch of facets
|
|
108
|
-
facetHelper.deployBatch(deployer);
|
|
109
|
-
|
|
110
106
|
facetHelper.add("EntitlementsManager");
|
|
111
107
|
facetHelper.add("Roles");
|
|
112
108
|
facetHelper.add("Channels");
|
|
113
109
|
facetHelper.add("TokenPausableFacet");
|
|
114
110
|
facetHelper.add("ReferralsFacet");
|
|
115
111
|
facetHelper.add("ReviewFacet");
|
|
116
|
-
|
|
117
|
-
// Deploy the second batch of facets
|
|
118
|
-
facetHelper.deployBatch(deployer);
|
|
119
|
-
|
|
120
112
|
facetHelper.add("SpaceEntitlementGated");
|
|
121
113
|
facetHelper.add("SwapFacet");
|
|
122
114
|
facetHelper.add("TippingFacet");
|
|
@@ -128,7 +120,7 @@ contract DeploySpace is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
128
120
|
facetHelper.add("MockLegacyMembership");
|
|
129
121
|
}
|
|
130
122
|
|
|
131
|
-
// Deploy
|
|
123
|
+
// Deploy all facets
|
|
132
124
|
facetHelper.deployBatch(deployer);
|
|
133
125
|
|
|
134
126
|
// deploy and add facets one by one to avoid stack too deep
|
|
@@ -145,10 +145,6 @@ contract DeploySpaceFactory is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
145
145
|
facetHelper.add("PricingModulesFacet");
|
|
146
146
|
facetHelper.add("ImplementationRegistryFacet");
|
|
147
147
|
facetHelper.add("SCL_EIP6565");
|
|
148
|
-
|
|
149
|
-
// Deploy the second batch of facets
|
|
150
|
-
facetHelper.deployBatch(deployer);
|
|
151
|
-
|
|
152
148
|
facetHelper.add("WalletLink");
|
|
153
149
|
facetHelper.add("EIP712Facet");
|
|
154
150
|
facetHelper.add("PartnerRegistry");
|
|
@@ -162,7 +158,7 @@ contract DeploySpaceFactory is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
162
158
|
facetHelper.add("MockLegacyArchitect");
|
|
163
159
|
}
|
|
164
160
|
|
|
165
|
-
// Deploy
|
|
161
|
+
// Deploy all facets
|
|
166
162
|
facetHelper.deployBatch(deployer);
|
|
167
163
|
|
|
168
164
|
if (isAnvil()) {
|