@towns-protocol/contracts 0.0.368 → 0.0.370
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 +3 -3
- package/scripts/deployments/diamonds/DeployAppRegistry.s.sol +9 -9
- package/scripts/deployments/diamonds/DeploySubscriptionModule.s.sol +9 -9
- package/scripts/interactions/helpers/AlphaHelper.sol +4 -2
- package/src/apps/modules/subscription/SubscriptionModuleStorage.sol +1 -1
- package/src/spaces/facets/membership/IMembership.sol +2 -0
- package/src/spaces/facets/membership/MembershipBase.sol +4 -0
- package/src/spaces/facets/membership/MembershipFacet.sol +6 -0
- package/src/spaces/facets/membership/join/MembershipJoin.sol +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@towns-protocol/contracts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.370",
|
|
4
4
|
"packageManager": "yarn@3.8.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build-types": "bash scripts/build-contract-types.sh",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@layerzerolabs/oapp-evm": "^0.3.2",
|
|
36
36
|
"@openzeppelin/merkle-tree": "^1.0.8",
|
|
37
37
|
"@prb/test": "^0.6.4",
|
|
38
|
-
"@towns-protocol/prettier-config": "^0.0.
|
|
38
|
+
"@towns-protocol/prettier-config": "^0.0.370",
|
|
39
39
|
"@typechain/ethers-v5": "^11.1.2",
|
|
40
40
|
"@wagmi/cli": "^2.2.0",
|
|
41
41
|
"forge-std": "github:foundry-rs/forge-std#v1.10.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "a39b3d31251fbe2ec4f6c0902d9a5195974e8b9e"
|
|
61
61
|
}
|
|
@@ -54,7 +54,6 @@ contract DeployAppRegistry is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
54
54
|
facetHelper.add("DiamondLoupeFacet");
|
|
55
55
|
facetHelper.add("IntrospectionFacet");
|
|
56
56
|
facetHelper.add("OwnableFacet");
|
|
57
|
-
facetHelper.add("MetadataFacet");
|
|
58
57
|
|
|
59
58
|
// Deploy the first batch of facets
|
|
60
59
|
facetHelper.deployBatch(deployer);
|
|
@@ -87,26 +86,27 @@ contract DeployAppRegistry is IDiamondInitHelper, DiamondHelper, Deployer {
|
|
|
87
86
|
facet,
|
|
88
87
|
DeployOwnable.makeInitData(deployer)
|
|
89
88
|
);
|
|
90
|
-
|
|
91
|
-
facet = facetHelper.predictAddress("MetadataFacet");
|
|
92
|
-
addFacet(
|
|
93
|
-
makeCut(facet, FacetCutAction.Add, DeployMetadata.selectors()),
|
|
94
|
-
facet,
|
|
95
|
-
DeployMetadata.makeInitData(bytes32("AppRegistry"), "")
|
|
96
|
-
);
|
|
97
89
|
}
|
|
98
90
|
|
|
99
91
|
function diamondInitParams(address deployer) public returns (Diamond.InitParams memory) {
|
|
100
92
|
// Queue up feature facets for batch deployment
|
|
101
93
|
facetHelper.add("MultiInit");
|
|
94
|
+
facetHelper.add("MetadataFacet");
|
|
102
95
|
facetHelper.add("UpgradeableBeaconFacet");
|
|
103
96
|
facetHelper.add("AppRegistryFacet");
|
|
104
97
|
facetHelper.add("SimpleApp");
|
|
105
98
|
|
|
106
99
|
facetHelper.deployBatch(deployer);
|
|
107
100
|
|
|
101
|
+
address facet = facetHelper.getDeployedAddress("MetadataFacet");
|
|
102
|
+
addFacet(
|
|
103
|
+
makeCut(facet, FacetCutAction.Add, DeployMetadata.selectors()),
|
|
104
|
+
facet,
|
|
105
|
+
DeployMetadata.makeInitData(bytes32("AppRegistry"), "")
|
|
106
|
+
);
|
|
107
|
+
|
|
108
108
|
address simpleApp = facetHelper.getDeployedAddress("SimpleApp");
|
|
109
|
-
|
|
109
|
+
facet = facetHelper.getDeployedAddress("UpgradeableBeaconFacet");
|
|
110
110
|
|
|
111
111
|
addFacet(
|
|
112
112
|
makeCut(facet, FacetCutAction.Add, DeployUpgradeableBeacon.selectors()),
|
|
@@ -62,13 +62,21 @@ contract DeploySubscriptionModule is DiamondHelper, Deployer, IDiamondInitHelper
|
|
|
62
62
|
function diamondInitParams(address deployer) public returns (Diamond.InitParams memory) {
|
|
63
63
|
// Queue up feature facets for batch deployment
|
|
64
64
|
facetHelper.add("MultiInit");
|
|
65
|
+
facetHelper.add("MetadataFacet");
|
|
65
66
|
facetHelper.add("SubscriptionModuleFacet");
|
|
66
67
|
|
|
67
68
|
// Deploy all facets in a batch
|
|
68
69
|
facetHelper.deployBatch(deployer);
|
|
69
70
|
|
|
70
71
|
// Add feature facets
|
|
71
|
-
address facet = facetHelper.getDeployedAddress("
|
|
72
|
+
address facet = facetHelper.getDeployedAddress("MetadataFacet");
|
|
73
|
+
addFacet(
|
|
74
|
+
makeCut(facet, FacetCutAction.Add, DeployMetadata.selectors()),
|
|
75
|
+
facet,
|
|
76
|
+
DeployMetadata.makeInitData(METADATA_NAME, "")
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
facet = facetHelper.getDeployedAddress("SubscriptionModuleFacet");
|
|
72
80
|
addFacet(
|
|
73
81
|
makeCut(facet, FacetCutAction.Add, DeploySubscriptionModuleFacet.selectors()),
|
|
74
82
|
facet,
|
|
@@ -95,7 +103,6 @@ contract DeploySubscriptionModule is DiamondHelper, Deployer, IDiamondInitHelper
|
|
|
95
103
|
facetHelper.add("DiamondLoupeFacet");
|
|
96
104
|
facetHelper.add("IntrospectionFacet");
|
|
97
105
|
facetHelper.add("OwnableFacet");
|
|
98
|
-
facetHelper.add("MetadataFacet");
|
|
99
106
|
|
|
100
107
|
// Get predicted addresses
|
|
101
108
|
address facet = facetHelper.predictAddress("DiamondCutFacet");
|
|
@@ -125,13 +132,6 @@ contract DeploySubscriptionModule is DiamondHelper, Deployer, IDiamondInitHelper
|
|
|
125
132
|
facet,
|
|
126
133
|
DeployOwnable.makeInitData(deployer)
|
|
127
134
|
);
|
|
128
|
-
|
|
129
|
-
facet = facetHelper.predictAddress("MetadataFacet");
|
|
130
|
-
addFacet(
|
|
131
|
-
makeCut(facet, FacetCutAction.Add, DeployMetadata.selectors()),
|
|
132
|
-
facet,
|
|
133
|
-
DeployMetadata.makeInitData(METADATA_NAME, "")
|
|
134
|
-
);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
function __deploy(address deployer) internal override returns (address) {
|
|
@@ -8,6 +8,7 @@ import {IDiamondLoupe, IDiamondLoupeBase} from "@towns-protocol/diamond/src/face
|
|
|
8
8
|
import {IERC173} from "@towns-protocol/diamond/src/facets/ownable/IERC173.sol";
|
|
9
9
|
import {IOwnablePending} from "@towns-protocol/diamond/src/facets/ownable/pending/IOwnablePending.sol";
|
|
10
10
|
import {IDiamondInitHelper} from "scripts/deployments/diamonds/IDiamondInitHelper.sol";
|
|
11
|
+
import {IMetadata} from "src/diamond/facets/metadata/IMetadata.sol";
|
|
11
12
|
|
|
12
13
|
// libraries
|
|
13
14
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
@@ -55,13 +56,14 @@ abstract contract AlphaHelper is Interaction, DiamondHelper, IDiamondLoupeBase {
|
|
|
55
56
|
function getCoreFacetAddresses(
|
|
56
57
|
address diamond
|
|
57
58
|
) internal view returns (address[] memory coreFacets) {
|
|
58
|
-
coreFacets = new address[](
|
|
59
|
+
coreFacets = new address[](6);
|
|
59
60
|
|
|
60
61
|
coreFacets[0] = IDiamondLoupe(diamond).facetAddress(IDiamondCut.diamondCut.selector);
|
|
61
62
|
coreFacets[1] = IDiamondLoupe(diamond).facetAddress(IDiamondLoupe.facets.selector);
|
|
62
63
|
coreFacets[2] = IDiamondLoupe(diamond).facetAddress(IERC165.supportsInterface.selector);
|
|
63
64
|
coreFacets[3] = IDiamondLoupe(diamond).facetAddress(IERC173.owner.selector);
|
|
64
65
|
coreFacets[4] = IDiamondLoupe(diamond).facetAddress(IOwnablePending.currentOwner.selector);
|
|
66
|
+
coreFacets[5] = IDiamondLoupe(diamond).facetAddress(IMetadata.contractType.selector);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/// @notice Check if an address is a core facet that should not be removed
|
|
@@ -254,7 +256,7 @@ abstract contract AlphaHelper is Interaction, DiamondHelper, IDiamondLoupeBase {
|
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
if (removeSelectors.length() > 0) {
|
|
257
|
-
addCut(FacetCut(
|
|
259
|
+
addCut(FacetCut(facetAddr, FacetCutAction.Remove, asBytes4Array(removeSelectors)));
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
262
|
}
|
|
@@ -46,7 +46,7 @@ library SubscriptionModuleStorage {
|
|
|
46
46
|
|
|
47
47
|
function getOperatorBuffer(address operator) internal view returns (uint256) {
|
|
48
48
|
OperatorConfig storage config = getLayout().operatorConfig[operator];
|
|
49
|
-
if (config.interval == 0) return MIN_RENEWAL_BUFFER;
|
|
49
|
+
if (config.interval == 0 || config.buffer == 0) return MIN_RENEWAL_BUFFER;
|
|
50
50
|
return config.buffer;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -72,6 +72,8 @@ interface IMembershipBase {
|
|
|
72
72
|
error Membership__InvalidTransactionType();
|
|
73
73
|
error Membership__Banned();
|
|
74
74
|
error Membership__InvalidAction();
|
|
75
|
+
error Membership__CannotSetFreeAllocationOnPaidSpace();
|
|
76
|
+
error Membership__CannotSetPriceOnFreeSpace();
|
|
75
77
|
|
|
76
78
|
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
77
79
|
/* EVENTS */
|
|
@@ -36,6 +36,8 @@ abstract contract MembershipBase is IMembershipBase {
|
|
|
36
36
|
|
|
37
37
|
if (info.price > 0) {
|
|
38
38
|
_verifyPrice(info.price);
|
|
39
|
+
if (info.freeAllocation > 0)
|
|
40
|
+
Membership__CannotSetFreeAllocationOnPaidSpace.selector.revertWith();
|
|
39
41
|
IMembershipPricing(info.pricingModule).setPrice(info.price);
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -169,6 +171,8 @@ abstract contract MembershipBase is IMembershipBase {
|
|
|
169
171
|
// get free allocation
|
|
170
172
|
uint256 freeAllocation = _getMembershipFreeAllocation();
|
|
171
173
|
membershipPrice = IMembershipPricing(pricingModule).getPrice(freeAllocation, totalSupply);
|
|
174
|
+
if (membershipPrice == 0) return 0;
|
|
175
|
+
|
|
172
176
|
uint256 minPrice = platform.getMembershipMinPrice();
|
|
173
177
|
if (membershipPrice < minPrice) return platform.getMembershipFee();
|
|
174
178
|
}
|
|
@@ -99,6 +99,8 @@ contract MembershipFacet is IMembership, MembershipJoin, ReentrancyGuard, Facet
|
|
|
99
99
|
/// @inheritdoc IMembership
|
|
100
100
|
function setMembershipPrice(uint256 newPrice) external onlyOwner {
|
|
101
101
|
_verifyPrice(newPrice);
|
|
102
|
+
if (newPrice > 0 && _getMembershipFreeAllocation() > 0)
|
|
103
|
+
Membership__CannotSetPriceOnFreeSpace.selector.revertWith();
|
|
102
104
|
IMembershipPricing(_getPricingModule()).setPrice(newPrice);
|
|
103
105
|
}
|
|
104
106
|
|
|
@@ -131,6 +133,10 @@ contract MembershipFacet is IMembership, MembershipJoin, ReentrancyGuard, Facet
|
|
|
131
133
|
Membership__InvalidFreeAllocation.selector.revertWith();
|
|
132
134
|
}
|
|
133
135
|
|
|
136
|
+
if (_getMembershipPrice(_totalSupply()) > 0) {
|
|
137
|
+
Membership__CannotSetFreeAllocationOnPaidSpace.selector.revertWith();
|
|
138
|
+
}
|
|
139
|
+
|
|
134
140
|
// verify newLimit is not more than the allowed platform limit
|
|
135
141
|
_verifyFreeAllocation(newAllocation);
|
|
136
142
|
_setMembershipFreeAllocation(newAllocation);
|
|
@@ -75,6 +75,8 @@ abstract contract MembershipJoin is
|
|
|
75
75
|
uint256 membershipPrice = _getMembershipPrice(totalSupply);
|
|
76
76
|
uint256 freeAllocation = _getMembershipFreeAllocation();
|
|
77
77
|
|
|
78
|
+
if (membershipPrice == 0) return joinDetails;
|
|
79
|
+
|
|
78
80
|
joinDetails.basePrice = membershipPrice;
|
|
79
81
|
if (freeAllocation > totalSupply) {
|
|
80
82
|
return joinDetails;
|