@towns-protocol/contracts 0.0.368 → 0.0.369

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@towns-protocol/contracts",
3
- "version": "0.0.368",
3
+ "version": "0.0.369",
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.368",
38
+ "@towns-protocol/prettier-config": "^0.0.369",
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": "bb014c92cd91d742be6ea53ac56027ec90e4d345"
60
+ "gitHead": "5a4adeead17c71980426b92b98c23952536e08fa"
61
61
  }
@@ -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;