@towns-protocol/contracts 0.0.376 → 0.0.377

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.376",
3
+ "version": "0.0.377",
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.376",
38
+ "@towns-protocol/prettier-config": "^0.0.377",
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": "500000c0d1b16a866df765a75c7972b5d1691693"
60
+ "gitHead": "a289c507ab3ae080d0b07e9f881743223580fdf4"
61
61
  }
@@ -14,13 +14,13 @@ import {CustomRevert} from "../../utils/libraries/CustomRevert.sol";
14
14
  import {EntitlementsManagerStorage} from "./entitlements/EntitlementsManagerStorage.sol";
15
15
  import {MembershipStorage} from "./membership/MembershipStorage.sol";
16
16
  import {BanningStorage} from "./banning/BanningStorage.sol";
17
- import {AppAccountStorage} from "./account/AppAccountStorage.sol";
17
+ import {AppAccountBase} from "./account/AppAccountBase.sol";
18
18
  import {DependencyLib} from "./DependencyLib.sol";
19
19
 
20
20
  // contracts
21
21
  import {TokenOwnableBase} from "@towns-protocol/diamond/src/facets/ownable/token/TokenOwnableBase.sol";
22
22
 
23
- abstract contract Entitled is IEntitlementBase, TokenOwnableBase {
23
+ abstract contract Entitled is IEntitlementBase, TokenOwnableBase, AppAccountBase {
24
24
  using EnumerableSet for EnumerableSet.AddressSet;
25
25
  using EnumerableSet for EnumerableSet.UintSet;
26
26
  using CustomRevert for bytes4;
@@ -135,7 +135,7 @@ abstract contract Entitled is IEntitlementBase, TokenOwnableBase {
135
135
  address app = DependencyLib.getAppRegistry().getAppByClient(client);
136
136
  if (app == address(0)) return false;
137
137
 
138
- return AppAccountStorage.isAppEntitled(app, client, permission);
138
+ return _isAppEntitled(app, client, permission);
139
139
  }
140
140
 
141
141
  function _hasAnyBannedWallet(address[] memory wallets) internal view returns (bool) {
@@ -241,7 +241,27 @@ abstract contract AppAccountBase is
241
241
  address client,
242
242
  bytes32 permission
243
243
  ) internal view returns (bool) {
244
- return AppAccountStorage.isAppEntitled(module, client, permission);
244
+ bytes32 appId = AppAccountStorage.getLayout().appIdByApp[module];
245
+ if (appId == EMPTY_UID) return false;
246
+
247
+ IAppRegistry registry = DependencyLib.getAppRegistry();
248
+ if (registry.isAppBanned(module)) return false;
249
+
250
+ IAppRegistry.App memory app = registry.getAppById(appId);
251
+ if (app.appId == EMPTY_UID) return false;
252
+
253
+ (bool hasClientAccess, , bool isGroupActive) = ExecutorStorage.hasGroupAccess(
254
+ app.appId,
255
+ client
256
+ );
257
+ if (!hasClientAccess || !isGroupActive) return false;
258
+
259
+ uint256 permissionsLength = app.permissions.length;
260
+ for (uint256 i; i < permissionsLength; ++i) {
261
+ if (app.permissions[i] == permission) return true;
262
+ }
263
+
264
+ return false;
245
265
  }
246
266
 
247
267
  /// @notice Gets the ID of the installed app.
@@ -37,27 +37,4 @@ library AppAccountStorage {
37
37
  if (appId == EMPTY_UID) return app;
38
38
  return DependencyLib.getAppRegistry().getAppById(appId);
39
39
  }
40
-
41
- function isAppEntitled(
42
- address module,
43
- address client,
44
- bytes32 permission
45
- ) internal view returns (bool) {
46
- IAppRegistry.App memory app = getApp(module);
47
-
48
- if (app.appId == EMPTY_UID) return false;
49
-
50
- (bool hasClientAccess, , bool isGroupActive) = ExecutorStorage.hasGroupAccess(
51
- app.appId,
52
- client
53
- );
54
- if (!hasClientAccess || !isGroupActive) return false;
55
-
56
- uint256 permissionsLength = app.permissions.length;
57
- for (uint256 i; i < permissionsLength; ++i) {
58
- if (app.permissions[i] == permission) return true;
59
- }
60
-
61
- return false;
62
- }
63
40
  }
@@ -60,7 +60,7 @@ interface ITippingBase {
60
60
  TipRecipientType indexed recipientType,
61
61
  address currency,
62
62
  uint256 amount,
63
- uint256 tokenId // 0 if not a member tip
63
+ bytes data
64
64
  );
65
65
 
66
66
  // Maintain legacy event for backwards compatibility
@@ -84,7 +84,7 @@ abstract contract TippingBase is ITippingBase, PointsBase {
84
84
  TipRecipientType.Member,
85
85
  tipRequest.currency,
86
86
  tipAmount,
87
- tipRequest.tokenId
87
+ abi.encode(tipRequest.tokenId)
88
88
  );
89
89
  }
90
90
 
@@ -121,7 +121,7 @@ abstract contract TippingBase is ITippingBase, PointsBase {
121
121
  TipRecipientType.Member,
122
122
  params.currency,
123
123
  tipAmount,
124
- params.tokenId
124
+ params.metadata.data
125
125
  );
126
126
 
127
127
  emit Tip(
@@ -165,7 +165,7 @@ abstract contract TippingBase is ITippingBase, PointsBase {
165
165
  TipRecipientType.Bot,
166
166
  params.currency,
167
167
  tipAmount,
168
- 0
168
+ params.metadata.data
169
169
  );
170
170
  }
171
171