@towns-protocol/contracts 0.0.302

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.
Files changed (396) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +206 -0
  3. package/docs/permitAndStake_integration_guide.md +266 -0
  4. package/docs/swap_integration_guide.md +591 -0
  5. package/package.json +57 -0
  6. package/scripts/common/DeployBase.s.sol +26 -0
  7. package/scripts/common/DeployFacet.s.sol +7 -0
  8. package/scripts/common/Deployer.s.sol +33 -0
  9. package/scripts/common/Interaction.s.sol +51 -0
  10. package/scripts/deployments/diamonds/DeployAppRegistry.s.sol +168 -0
  11. package/scripts/deployments/diamonds/DeployBaseRegistry.s.sol +263 -0
  12. package/scripts/deployments/diamonds/DeployRiverAirdrop.s.sol +203 -0
  13. package/scripts/deployments/diamonds/DeployRiverMigration.s.sol +129 -0
  14. package/scripts/deployments/diamonds/DeployRiverRegistry.s.sol +175 -0
  15. package/scripts/deployments/diamonds/DeploySpace.s.sol +285 -0
  16. package/scripts/deployments/diamonds/DeploySpaceFactory.s.sol +416 -0
  17. package/scripts/deployments/diamonds/DeploySpaceOwner.s.sol +183 -0
  18. package/scripts/deployments/diamonds/DeploySwapRouter.s.sol +176 -0
  19. package/scripts/deployments/diamonds/IDiamondInitHelper.sol +11 -0
  20. package/scripts/deployments/facets/DeployAppAccount.s.sol +51 -0
  21. package/scripts/deployments/facets/DeployAppRegistryFacet.s.sol +69 -0
  22. package/scripts/deployments/facets/DeployArchitect.s.sol +51 -0
  23. package/scripts/deployments/facets/DeployAttestationRegistry.s.sol +36 -0
  24. package/scripts/deployments/facets/DeployBanning.s.sol +30 -0
  25. package/scripts/deployments/facets/DeployChannels.s.sol +35 -0
  26. package/scripts/deployments/facets/DeployCreateSpace.s.sol +42 -0
  27. package/scripts/deployments/facets/DeployDropFacet.s.sol +49 -0
  28. package/scripts/deployments/facets/DeployERC721A.s.sol +48 -0
  29. package/scripts/deployments/facets/DeployERC721ANonTransferable.s.sol +49 -0
  30. package/scripts/deployments/facets/DeployERC721AQueryable.s.sol +30 -0
  31. package/scripts/deployments/facets/DeployEntitlementChecker.s.sol +49 -0
  32. package/scripts/deployments/facets/DeployEntitlementDataQueryable.s.sol +29 -0
  33. package/scripts/deployments/facets/DeployEntitlementsManager.s.sol +33 -0
  34. package/scripts/deployments/facets/DeployExecutorFacet.s.sol +60 -0
  35. package/scripts/deployments/facets/DeployFeatureManager.s.sol +38 -0
  36. package/scripts/deployments/facets/DeployGuardianFacet.s.sol +39 -0
  37. package/scripts/deployments/facets/DeployImplementationRegistry.s.sol +36 -0
  38. package/scripts/deployments/facets/DeployMainnetDelegation.s.sol +43 -0
  39. package/scripts/deployments/facets/DeployMembership.s.sol +77 -0
  40. package/scripts/deployments/facets/DeployMembershipMetadata.s.sol +30 -0
  41. package/scripts/deployments/facets/DeployMembershipToken.s.sol +47 -0
  42. package/scripts/deployments/facets/DeployMerkleAirdrop.s.sol +37 -0
  43. package/scripts/deployments/facets/DeployMetadata.s.sol +39 -0
  44. package/scripts/deployments/facets/DeployMockLegacyArchitect.s.sol +33 -0
  45. package/scripts/deployments/facets/DeployNodeOperator.s.sol +49 -0
  46. package/scripts/deployments/facets/DeployNodeRegistry.s.sol +37 -0
  47. package/scripts/deployments/facets/DeployOperatorRegistry.s.sol +36 -0
  48. package/scripts/deployments/facets/DeployPartnerRegistry.s.sol +41 -0
  49. package/scripts/deployments/facets/DeployPlatformRequirements.s.sol +75 -0
  50. package/scripts/deployments/facets/DeployPrepayFacet.s.sol +31 -0
  51. package/scripts/deployments/facets/DeployPricingModules.s.sol +36 -0
  52. package/scripts/deployments/facets/DeployReferrals.s.sol +34 -0
  53. package/scripts/deployments/facets/DeployReviewFacet.s.sol +31 -0
  54. package/scripts/deployments/facets/DeployRewardsDistributionV2.s.sol +76 -0
  55. package/scripts/deployments/facets/DeployRiverConfig.s.sol +41 -0
  56. package/scripts/deployments/facets/DeployRoles.s.sol +48 -0
  57. package/scripts/deployments/facets/DeploySchemaRegistry.s.sol +35 -0
  58. package/scripts/deployments/facets/DeploySignerFacet.s.sol +47 -0
  59. package/scripts/deployments/facets/DeploySimpleApp.s.sol +10 -0
  60. package/scripts/deployments/facets/DeploySpaceDelegation.s.sol +43 -0
  61. package/scripts/deployments/facets/DeploySpaceEntitlementGated.s.sol +31 -0
  62. package/scripts/deployments/facets/DeploySpaceFactoryInit.s.sol +33 -0
  63. package/scripts/deployments/facets/DeploySpaceOwnerFacet.s.sol +71 -0
  64. package/scripts/deployments/facets/DeployStreamRegistry.s.sol +50 -0
  65. package/scripts/deployments/facets/DeploySwapFacet.s.sol +33 -0
  66. package/scripts/deployments/facets/DeploySwapRouterFacet.s.sol +38 -0
  67. package/scripts/deployments/facets/DeployTipping.s.sol +31 -0
  68. package/scripts/deployments/facets/DeployTokenMigration.s.sol +40 -0
  69. package/scripts/deployments/facets/DeployTownsPoints.s.sol +53 -0
  70. package/scripts/deployments/facets/DeployTreasury.s.sol +30 -0
  71. package/scripts/deployments/facets/DeployUpgradeableBeacon.s.sol +34 -0
  72. package/scripts/deployments/facets/DeployWalletLink.s.sol +56 -0
  73. package/scripts/deployments/facets/DeployXChain.s.sol +35 -0
  74. package/scripts/deployments/utils/DeployAccountFactory.s.sol +40 -0
  75. package/scripts/deployments/utils/DeployEntitlementGatedExample.s.sol +23 -0
  76. package/scripts/deployments/utils/DeployEntrypoint.s.sol +28 -0
  77. package/scripts/deployments/utils/DeployMember.s.sol +95 -0
  78. package/scripts/deployments/utils/DeployMockDiamond.s.sol +7 -0
  79. package/scripts/deployments/utils/DeployMockERC20.s.sol +24 -0
  80. package/scripts/deployments/utils/DeployMockERC721A.s.sol +45 -0
  81. package/scripts/deployments/utils/DeployMockLegacyMembership.s.sol +29 -0
  82. package/scripts/deployments/utils/DeployMockMessenger.s.sol +42 -0
  83. package/scripts/deployments/utils/DeployMockNFT.s.sol +86 -0
  84. package/scripts/deployments/utils/DeployPoapEntitlement.s.sol +16 -0
  85. package/scripts/deployments/utils/DeployProxyBatchDelegation.s.sol +112 -0
  86. package/scripts/deployments/utils/DeploySpaceProxyInitializer.s.sol +28 -0
  87. package/scripts/deployments/utils/DeployTieredLogPricingV2.s.sol +23 -0
  88. package/scripts/deployments/utils/DeployTieredLogPricingV3.s.sol +23 -0
  89. package/scripts/deployments/utils/DeployTownsBase.s.sol +95 -0
  90. package/scripts/deployments/utils/DeployTownsMainnet.s.sol +66 -0
  91. package/scripts/deployments/utils/DeployTownsMulti.s.sol +53 -0
  92. package/scripts/deployments/utils/DeployWrappedTowns.s.sol +52 -0
  93. package/scripts/deployments/utils/LibLayerZeroValues.sol +34 -0
  94. package/scripts/deployments/utils/pricing/TieredLogPricing.s.sol +45 -0
  95. package/scripts/interactions/InteractAirdrop.s.sol +57 -0
  96. package/scripts/interactions/InteractAlphaPost.s.sol +32 -0
  97. package/scripts/interactions/InteractAlphaSparse.s.sol +173 -0
  98. package/scripts/interactions/InteractBaseAlpha.s.sol +84 -0
  99. package/scripts/interactions/InteractBaseBridge.s.sol +48 -0
  100. package/scripts/interactions/InteractBridgeLayerZero.s.sol +102 -0
  101. package/scripts/interactions/InteractClaimCondition.s.sol +56 -0
  102. package/scripts/interactions/InteractCreateSpace.s.sol +50 -0
  103. package/scripts/interactions/InteractDiamondCut.s.sol +47 -0
  104. package/scripts/interactions/InteractDropFacet.s.sol +32 -0
  105. package/scripts/interactions/InteractEnableNewSnapshotFormat.s.sol +27 -0
  106. package/scripts/interactions/InteractEnableNode2NodeAuth.s.sol +27 -0
  107. package/scripts/interactions/InteractMembership.s.sol +42 -0
  108. package/scripts/interactions/InteractMockERC721A.s.sol +20 -0
  109. package/scripts/interactions/InteractNodeOperators.s.sol +41 -0
  110. package/scripts/interactions/InteractPostDeploy.s.sol +59 -0
  111. package/scripts/interactions/InteractPrepay.s.sol +30 -0
  112. package/scripts/interactions/InteractRegisterApp.s.sol +61 -0
  113. package/scripts/interactions/InteractRiverAlpha.s.sol +30 -0
  114. package/scripts/interactions/InteractRiverAlphaSparse.s.sol +117 -0
  115. package/scripts/interactions/InteractRiverMainnet.s.sol +27 -0
  116. package/scripts/interactions/InteractRiverRegistry.s.sol +36 -0
  117. package/scripts/interactions/InteractRiverRegistrySetBlocklist.s.sol +30 -0
  118. package/scripts/interactions/InteractRiverRegistrySetFreq.s.sol +27 -0
  119. package/scripts/interactions/InteractRiverRegistrySetRepl.s.sol +30 -0
  120. package/scripts/interactions/InteractSetDefaultUri.s.sol +20 -0
  121. package/scripts/interactions/InteractSetDefaultUriLocalhost.s.sol +19 -0
  122. package/scripts/interactions/InteractTransferOwnership.s.sol +21 -0
  123. package/scripts/interactions/InteractUpdateMbRecencyCheck.s.sol +27 -0
  124. package/scripts/interactions/InteractUpdateMediaChunkCount.s.sol +27 -0
  125. package/scripts/interactions/InteractUpdateMediaChunkSize.s.sol +27 -0
  126. package/scripts/interactions/helpers/AlphaHelper.sol +149 -0
  127. package/scripts/interactions/helpers/RiverConfigValues.sol +22 -0
  128. package/scripts/interactions/interfaces/IL1StandardBridge.sol +35 -0
  129. package/scripts/interactions/interfaces/IL2StandardBridge.sol +69 -0
  130. package/src/airdrop/drop/DropBase.sol +210 -0
  131. package/src/airdrop/drop/DropClaim.sol +55 -0
  132. package/src/airdrop/drop/DropFacet.sol +176 -0
  133. package/src/airdrop/drop/DropGroup.sol +111 -0
  134. package/src/airdrop/drop/DropStorage.sol +23 -0
  135. package/src/airdrop/drop/IDropFacet.sol +136 -0
  136. package/src/airdrop/points/CheckIn.sol +71 -0
  137. package/src/airdrop/points/ITownsPoints.sol +64 -0
  138. package/src/airdrop/points/TownsPoints.sol +196 -0
  139. package/src/airdrop/points/TownsPointsStorage.sol +22 -0
  140. package/src/apps/BaseApp.sol +62 -0
  141. package/src/apps/ITownsApp.sol +28 -0
  142. package/src/apps/SchemaResolver.sol +170 -0
  143. package/src/apps/facets/attest/AttestationBase.sol +335 -0
  144. package/src/apps/facets/attest/AttestationLib.sol +64 -0
  145. package/src/apps/facets/attest/AttestationRegistry.sol +39 -0
  146. package/src/apps/facets/attest/AttestationStorage.sol +35 -0
  147. package/src/apps/facets/attest/IAttestationRegistry.sol +43 -0
  148. package/src/apps/facets/registry/AppRegistryBase.sol +403 -0
  149. package/src/apps/facets/registry/AppRegistryFacet.sol +173 -0
  150. package/src/apps/facets/registry/AppRegistryStorage.sol +53 -0
  151. package/src/apps/facets/registry/IAppRegistry.sol +159 -0
  152. package/src/apps/facets/schema/ISchema.sol +14 -0
  153. package/src/apps/facets/schema/SchemaBase.sol +88 -0
  154. package/src/apps/facets/schema/SchemaLib.sol +14 -0
  155. package/src/apps/facets/schema/SchemaRegistry.sol +51 -0
  156. package/src/apps/facets/schema/SchemaStorage.sol +34 -0
  157. package/src/apps/helpers/ISimpleApp.sol +51 -0
  158. package/src/apps/helpers/SimpleApp.sol +97 -0
  159. package/src/apps/helpers/SimpleAppStorage.sol +27 -0
  160. package/src/base/registry/facets/checker/EntitlementChecker.sol +237 -0
  161. package/src/base/registry/facets/checker/EntitlementCheckerStorage.sol +28 -0
  162. package/src/base/registry/facets/checker/IEntitlementChecker.sol +95 -0
  163. package/src/base/registry/facets/delegation/ISpaceDelegation.sol +69 -0
  164. package/src/base/registry/facets/delegation/SpaceDelegationFacet.sol +250 -0
  165. package/src/base/registry/facets/delegation/SpaceDelegationStorage.sol +35 -0
  166. package/src/base/registry/facets/distribution/v1/IRewardsDistribution.sol +51 -0
  167. package/src/base/registry/facets/distribution/v1/RewardsDistribution.sol +439 -0
  168. package/src/base/registry/facets/distribution/v1/RewardsDistributionStorage.sol +32 -0
  169. package/src/base/registry/facets/distribution/v2/DelegationProxy.sol +53 -0
  170. package/src/base/registry/facets/distribution/v2/IRewardsDistribution.sol +372 -0
  171. package/src/base/registry/facets/distribution/v2/RewardsDistributionBase.sol +299 -0
  172. package/src/base/registry/facets/distribution/v2/RewardsDistributionStorage.sol +37 -0
  173. package/src/base/registry/facets/distribution/v2/RewardsDistributionV2.sol +392 -0
  174. package/src/base/registry/facets/distribution/v2/StakingRewards.sol +466 -0
  175. package/src/base/registry/facets/mainnet/ICrossDomainMessenger.sol +58 -0
  176. package/src/base/registry/facets/mainnet/IMainnetDelegation.sol +127 -0
  177. package/src/base/registry/facets/mainnet/MainnetDelegation.sol +119 -0
  178. package/src/base/registry/facets/mainnet/MainnetDelegationBase.sol +274 -0
  179. package/src/base/registry/facets/mainnet/MainnetDelegationStorage.sol +36 -0
  180. package/src/base/registry/facets/operator/INodeOperator.sol +91 -0
  181. package/src/base/registry/facets/operator/NodeOperatorFacet.sol +189 -0
  182. package/src/base/registry/facets/operator/NodeOperatorStorage.sol +39 -0
  183. package/src/base/registry/facets/xchain/IXChain.sol +54 -0
  184. package/src/base/registry/facets/xchain/XChain.sol +158 -0
  185. package/src/base/registry/facets/xchain/XChainCheckLib.sol +105 -0
  186. package/src/base/registry/facets/xchain/XChainLib.sol +46 -0
  187. package/src/diamond/facets/beacon/UpgradeableBeacon.sol +38 -0
  188. package/src/diamond/facets/beacon/UpgradeableBeaconFacet.sol +34 -0
  189. package/src/diamond/facets/governance/votes/Checkpoints.sol +642 -0
  190. package/src/diamond/facets/governance/votes/Votes.sol +63 -0
  191. package/src/diamond/facets/governance/votes/VotesBase.sol +274 -0
  192. package/src/diamond/facets/governance/votes/VotesStorage.sol +21 -0
  193. package/src/diamond/facets/governance/votes/enumerable/IVotesEnumerable.sol +38 -0
  194. package/src/diamond/facets/governance/votes/enumerable/VotesEnumerable.sol +39 -0
  195. package/src/diamond/facets/governance/votes/enumerable/VotesEnumerableLib.sol +102 -0
  196. package/src/diamond/facets/metadata/IMetadata.sol +27 -0
  197. package/src/diamond/facets/metadata/MetadataFacet.sol +71 -0
  198. package/src/diamond/facets/token/ERC5643/ERC5643.sol +51 -0
  199. package/src/diamond/facets/token/ERC5643/ERC5643Base.sol +48 -0
  200. package/src/diamond/facets/token/ERC5643/ERC5643Storage.sol +26 -0
  201. package/src/diamond/facets/token/ERC5643/IERC5643.sol +44 -0
  202. package/src/diamond/facets/token/ERC721A/ERC721A.sol +270 -0
  203. package/src/diamond/facets/token/ERC721A/ERC721ABase.sol +829 -0
  204. package/src/diamond/facets/token/ERC721A/ERC721ANonTransferable.sol +21 -0
  205. package/src/diamond/facets/token/ERC721A/ERC721AStorage.sol +115 -0
  206. package/src/diamond/facets/token/ERC721A/IERC721A.sol +283 -0
  207. package/src/diamond/facets/token/ERC721A/extensions/ERC721AQueryable.sol +134 -0
  208. package/src/diamond/facets/token/ERC721A/extensions/IERC721AQueryable.sol +83 -0
  209. package/src/diamond/utils/Context.sol +19 -0
  210. package/src/factory/SpaceFactoryInit.sol +17 -0
  211. package/src/factory/facets/architect/Architect.sol +98 -0
  212. package/src/factory/facets/architect/ArchitectBase.sol +95 -0
  213. package/src/factory/facets/architect/ArchitectStorage.sol +28 -0
  214. package/src/factory/facets/architect/IArchitect.sol +155 -0
  215. package/src/factory/facets/architect/ImplementationStorage.sol +42 -0
  216. package/src/factory/facets/architect/pricing/IPricingModules.sol +41 -0
  217. package/src/factory/facets/architect/pricing/PricingModulesBase.sol +89 -0
  218. package/src/factory/facets/architect/pricing/PricingModulesFacet.sol +40 -0
  219. package/src/factory/facets/architect/pricing/PricingModulesStorage.sol +30 -0
  220. package/src/factory/facets/create/CreateSpace.sol +107 -0
  221. package/src/factory/facets/create/CreateSpaceLib.sol +335 -0
  222. package/src/factory/facets/create/ICreateSpace.sol +70 -0
  223. package/src/factory/facets/feature/FeatureConditionLib.sol +53 -0
  224. package/src/factory/facets/feature/FeatureManagerFacet.sol +66 -0
  225. package/src/factory/facets/feature/FeatureManagerLib.sol +168 -0
  226. package/src/factory/facets/feature/IFeatureManagerFacet.sol +73 -0
  227. package/src/factory/facets/partner/IPartnerRegistry.sol +56 -0
  228. package/src/factory/facets/partner/PartnerRegistry.sol +57 -0
  229. package/src/factory/facets/partner/PartnerRegistryBase.sol +132 -0
  230. package/src/factory/facets/partner/PartnerRegistryStorage.sol +40 -0
  231. package/src/factory/facets/platform/requirements/IPlatformRequirements.sol +143 -0
  232. package/src/factory/facets/platform/requirements/PlatformRequirementsBase.sol +124 -0
  233. package/src/factory/facets/platform/requirements/PlatformRequirementsFacet.sol +122 -0
  234. package/src/factory/facets/platform/requirements/PlatformRequirementsStorage.sol +41 -0
  235. package/src/factory/facets/registry/IImplementationRegistry.sol +46 -0
  236. package/src/factory/facets/registry/ImplementationRegistry.sol +64 -0
  237. package/src/factory/facets/registry/ImplementationRegistryStorage.sol +28 -0
  238. package/src/factory/facets/wallet-link/IWalletLink.sol +218 -0
  239. package/src/factory/facets/wallet-link/WalletLink.sol +108 -0
  240. package/src/factory/facets/wallet-link/WalletLinkBase.sol +492 -0
  241. package/src/factory/facets/wallet-link/interfaces/IDelegateRegistry.sol +63 -0
  242. package/src/factory/facets/wallet-link/interfaces/IDelegateRegistryV1.sol +35 -0
  243. package/src/factory/facets/wallet-link/interfaces/ISCL_EIP6565.sol +24 -0
  244. package/src/factory/facets/wallet-link/libraries/SolanaUtils.sol +161 -0
  245. package/src/factory/facets/wallet-link/libraries/WalletLib.sol +62 -0
  246. package/src/river/registry/facets/config/IRiverConfig.sol +117 -0
  247. package/src/river/registry/facets/config/RiverConfig.sol +174 -0
  248. package/src/river/registry/facets/node/INodeRegistry.sol +69 -0
  249. package/src/river/registry/facets/node/NodeRegistry.sol +143 -0
  250. package/src/river/registry/facets/operator/IOperatorRegistry.sol +28 -0
  251. package/src/river/registry/facets/operator/OperatorRegistry.sol +86 -0
  252. package/src/river/registry/facets/stream/IStreamRegistry.sol +184 -0
  253. package/src/river/registry/facets/stream/StreamRegistry.sol +396 -0
  254. package/src/river/registry/libraries/RegistryErrors.sol +24 -0
  255. package/src/river/registry/libraries/RegistryStorage.sol +181 -0
  256. package/src/router/ISwapRouter.sol +226 -0
  257. package/src/router/Permit2Hash.sol +92 -0
  258. package/src/router/SwapRouter.sol +463 -0
  259. package/src/router/SwapRouterStorage.sol +21 -0
  260. package/src/spaces/entitlements/ICrossChainEntitlement.sol +22 -0
  261. package/src/spaces/entitlements/IEntitlement.sol +61 -0
  262. package/src/spaces/entitlements/PolymarketEntitlement.sol +79 -0
  263. package/src/spaces/entitlements/poap/IPOAP.sol +26 -0
  264. package/src/spaces/entitlements/poap/PoapEntitlement.sol +56 -0
  265. package/src/spaces/entitlements/rule/IRuleEntitlement.sol +174 -0
  266. package/src/spaces/entitlements/rule/RuleEntitlement.sol +183 -0
  267. package/src/spaces/entitlements/rule/RuleEntitlementV2.sol +219 -0
  268. package/src/spaces/entitlements/user/IUserEntitlement.sol +24 -0
  269. package/src/spaces/entitlements/user/UserEntitlement.sol +273 -0
  270. package/src/spaces/facets/DependencyLib.sol +60 -0
  271. package/src/spaces/facets/Entitled.sol +172 -0
  272. package/src/spaces/facets/Permissions.sol +21 -0
  273. package/src/spaces/facets/account/AppAccount.sol +93 -0
  274. package/src/spaces/facets/account/AppAccountBase.sol +275 -0
  275. package/src/spaces/facets/account/AppAccountStorage.sol +63 -0
  276. package/src/spaces/facets/account/IAppAccount.sol +71 -0
  277. package/src/spaces/facets/account/SignerFacet.sol +26 -0
  278. package/src/spaces/facets/banning/Banning.sol +41 -0
  279. package/src/spaces/facets/banning/BanningBase.sol +33 -0
  280. package/src/spaces/facets/banning/BanningStorage.sol +23 -0
  281. package/src/spaces/facets/banning/IBanning.sol +35 -0
  282. package/src/spaces/facets/channels/ChannelBase.sol +87 -0
  283. package/src/spaces/facets/channels/ChannelService.sol +177 -0
  284. package/src/spaces/facets/channels/ChannelStorage.sol +34 -0
  285. package/src/spaces/facets/channels/Channels.sol +80 -0
  286. package/src/spaces/facets/channels/IChannel.sol +98 -0
  287. package/src/spaces/facets/dispatcher/DispatcherBase.sol +86 -0
  288. package/src/spaces/facets/dispatcher/DispatcherStorage.sol +21 -0
  289. package/src/spaces/facets/dispatcher/IDispatcher.sol +6 -0
  290. package/src/spaces/facets/entitlements/EntitlementsManager.sol +49 -0
  291. package/src/spaces/facets/entitlements/EntitlementsManagerBase.sol +87 -0
  292. package/src/spaces/facets/entitlements/EntitlementsManagerService.sol +142 -0
  293. package/src/spaces/facets/entitlements/EntitlementsManagerStorage.sol +34 -0
  294. package/src/spaces/facets/entitlements/IEntitlementsManager.sol +67 -0
  295. package/src/spaces/facets/entitlements/extensions/EntitlementDataQueryable.sol +153 -0
  296. package/src/spaces/facets/entitlements/extensions/IEntitlementDataQueryable.sol +32 -0
  297. package/src/spaces/facets/executor/ExecutorBase.sol +564 -0
  298. package/src/spaces/facets/executor/ExecutorFacet.sol +178 -0
  299. package/src/spaces/facets/executor/ExecutorStorage.sol +99 -0
  300. package/src/spaces/facets/executor/GroupLib.sol +128 -0
  301. package/src/spaces/facets/executor/IExecutor.sol +287 -0
  302. package/src/spaces/facets/executor/hooks/HookBase.sol +172 -0
  303. package/src/spaces/facets/executor/hooks/HookLib.sol +38 -0
  304. package/src/spaces/facets/executor/hooks/IHookBase.sol +48 -0
  305. package/src/spaces/facets/gated/EntitlementGated.sol +59 -0
  306. package/src/spaces/facets/gated/EntitlementGatedBase.sol +324 -0
  307. package/src/spaces/facets/gated/EntitlementGatedStorage.sol +29 -0
  308. package/src/spaces/facets/gated/IEntitlementGated.sol +55 -0
  309. package/src/spaces/facets/guardian/GuardianBase.sol +80 -0
  310. package/src/spaces/facets/guardian/GuardianFacet.sol +43 -0
  311. package/src/spaces/facets/guardian/GuardianStorage.sol +27 -0
  312. package/src/spaces/facets/guardian/IGuardian.sol +54 -0
  313. package/src/spaces/facets/membership/IMembership.sol +216 -0
  314. package/src/spaces/facets/membership/MembershipBase.sol +272 -0
  315. package/src/spaces/facets/membership/MembershipFacet.sol +191 -0
  316. package/src/spaces/facets/membership/MembershipStorage.sol +40 -0
  317. package/src/spaces/facets/membership/join/MembershipJoin.sol +547 -0
  318. package/src/spaces/facets/membership/metadata/IMembershipMetadata.sol +9 -0
  319. package/src/spaces/facets/membership/metadata/MembershipMetadata.sol +32 -0
  320. package/src/spaces/facets/membership/pricing/IMembershipPricing.sol +18 -0
  321. package/src/spaces/facets/membership/pricing/fixed/FixedPricing.sol +29 -0
  322. package/src/spaces/facets/membership/pricing/fixed/FixedPricingStorage.sol +27 -0
  323. package/src/spaces/facets/membership/pricing/tiered/TieredLogPricingOracleV2.sol +148 -0
  324. package/src/spaces/facets/membership/pricing/tiered/TieredLogPricingOracleV3.sol +137 -0
  325. package/src/spaces/facets/membership/token/MembershipToken.sol +25 -0
  326. package/src/spaces/facets/owner/ISpaceOwner.sol +85 -0
  327. package/src/spaces/facets/owner/SpaceOwner.sol +174 -0
  328. package/src/spaces/facets/owner/SpaceOwnerBase.sol +121 -0
  329. package/src/spaces/facets/owner/SpaceOwnerStorage.sol +41 -0
  330. package/src/spaces/facets/owner/SpaceOwnerUriBase.sol +54 -0
  331. package/src/spaces/facets/points/PointsBase.sol +35 -0
  332. package/src/spaces/facets/prepay/IPrepay.sol +43 -0
  333. package/src/spaces/facets/prepay/PrepayBase.sol +27 -0
  334. package/src/spaces/facets/prepay/PrepayFacet.sol +59 -0
  335. package/src/spaces/facets/prepay/PrepayStorage.sol +26 -0
  336. package/src/spaces/facets/proxy/ISpaceProxyInitializer.sol +21 -0
  337. package/src/spaces/facets/proxy/SpaceProxy.sol +15 -0
  338. package/src/spaces/facets/proxy/SpaceProxyInitializer.sol +55 -0
  339. package/src/spaces/facets/referrals/IReferrals.sol +98 -0
  340. package/src/spaces/facets/referrals/ReferralsBase.sol +81 -0
  341. package/src/spaces/facets/referrals/ReferralsFacet.sol +65 -0
  342. package/src/spaces/facets/referrals/ReferralsStorage.sol +36 -0
  343. package/src/spaces/facets/review/IReview.sol +50 -0
  344. package/src/spaces/facets/review/ReviewFacet.sol +105 -0
  345. package/src/spaces/facets/review/ReviewStorage.sol +29 -0
  346. package/src/spaces/facets/roles/IRoles.sol +197 -0
  347. package/src/spaces/facets/roles/Roles.sol +123 -0
  348. package/src/spaces/facets/roles/RolesBase.sol +420 -0
  349. package/src/spaces/facets/roles/RolesStorage.sol +132 -0
  350. package/src/spaces/facets/swap/ISwapFacet.sol +91 -0
  351. package/src/spaces/facets/swap/SwapFacet.sol +290 -0
  352. package/src/spaces/facets/swap/SwapFacetStorage.sol +24 -0
  353. package/src/spaces/facets/tipping/ITipping.sol +80 -0
  354. package/src/spaces/facets/tipping/TippingBase.sol +73 -0
  355. package/src/spaces/facets/tipping/TippingFacet.sol +123 -0
  356. package/src/spaces/facets/treasury/ITreasury.sol +64 -0
  357. package/src/spaces/facets/treasury/Treasury.sol +82 -0
  358. package/src/spaces/facets/xchain/SpaceEntitlementGated.sol +62 -0
  359. package/src/tokens/Member.sol +246 -0
  360. package/src/tokens/lock/ILock.sol +42 -0
  361. package/src/tokens/lock/LockBase.sol +64 -0
  362. package/src/tokens/lock/LockFacet.sol +44 -0
  363. package/src/tokens/lock/LockStorage.sol +26 -0
  364. package/src/tokens/mainnet/claimer/AuthorizedClaimerStorage.sol +26 -0
  365. package/src/tokens/mainnet/claimer/AuthorizedClaimers.sol +84 -0
  366. package/src/tokens/mainnet/claimer/IAuthorizedClaimers.sol +36 -0
  367. package/src/tokens/mainnet/delegation/ProxyBatchDelegation.sol +86 -0
  368. package/src/tokens/migration/ITokenMigration.sol +35 -0
  369. package/src/tokens/migration/TokenMigrationFacet.sol +86 -0
  370. package/src/tokens/migration/TokenMigrationStorage.sol +27 -0
  371. package/src/tokens/towns/base/IERC7802.sol +30 -0
  372. package/src/tokens/towns/base/IOptimismMintableERC20.sol +31 -0
  373. package/src/tokens/towns/base/ISemver.sol +13 -0
  374. package/src/tokens/towns/base/Towns.sol +283 -0
  375. package/src/tokens/towns/base/TownsDeployer.sol +32 -0
  376. package/src/tokens/towns/base/TownsLib.sol +31 -0
  377. package/src/tokens/towns/base/versions/TownsV2.sol +15 -0
  378. package/src/tokens/towns/mainnet/ITowns.sol +56 -0
  379. package/src/tokens/towns/mainnet/Towns.sol +220 -0
  380. package/src/tokens/towns/mainnet/libs/TokenInflationLib.sol +89 -0
  381. package/src/tokens/towns/multichain/Towns.sol +19 -0
  382. package/src/tokens/towns/multichain/wTowns.sol +18 -0
  383. package/src/utils/Airdrop.sol +156 -0
  384. package/src/utils/airdrop/merkle/IMerkleAirdrop.sol +55 -0
  385. package/src/utils/airdrop/merkle/MerkleAirdrop.sol +118 -0
  386. package/src/utils/airdrop/merkle/MerkleAirdropStorage.sol +29 -0
  387. package/src/utils/interfaces/AggregatorV3Interface.sol +37 -0
  388. package/src/utils/interfaces/IMulticall.sol +10 -0
  389. package/src/utils/interfaces/IWETH.sol +10 -0
  390. package/src/utils/libraries/BasisPoints.sol +24 -0
  391. package/src/utils/libraries/Create2Utils.sol +74 -0
  392. package/src/utils/libraries/CurrencyTransfer.sol +99 -0
  393. package/src/utils/libraries/CustomRevert.sol +49 -0
  394. package/src/utils/libraries/Factory.sol +66 -0
  395. package/src/utils/libraries/StringSet.sol +190 -0
  396. package/src/utils/libraries/Validator.sol +31 -0
@@ -0,0 +1,117 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ // interfaces
5
+ import {IDiamondCut} from "@towns-protocol/diamond/src/facets/cut/IDiamondCut.sol";
6
+
7
+ // libraries
8
+ import {stdJson} from "forge-std/StdJson.sol";
9
+ import "forge-std/console.sol";
10
+
11
+ // contracts
12
+ import {AlphaHelper, DiamondFacetData, FacetData} from "scripts/interactions/helpers/AlphaHelper.sol";
13
+
14
+ import {DeployRiverRegistry} from "scripts/deployments/diamonds/DeployRiverRegistry.s.sol";
15
+ import {IDiamondInitHelper} from "../deployments/diamonds/IDiamondInitHelper.sol";
16
+
17
+ contract InteractRiverAlphaSparse is AlphaHelper {
18
+ mapping(string => address) private diamondDeployments;
19
+
20
+ constructor() {
21
+ diamondDeployments["riverRegistry"] = address(new DeployRiverRegistry());
22
+ }
23
+
24
+ string constant DEFAULT_JSON_FILE = "compiled_source_diff.json";
25
+ string constant DEFAULT_REPORT_PATH = "/scripts/bytecode-diff/source-diffs/";
26
+
27
+ string private jsonData;
28
+
29
+ function readJSON(string memory jsonPath) internal {
30
+ jsonData = vm.readFile(jsonPath);
31
+ }
32
+
33
+ /**
34
+ * @notice Decodes diamond and facet data from a JSON file output by the bytecode-diff script
35
+ * @dev Reads the JSON file specified by the DEFAULT_JSON_FILE constant
36
+ * and parses it to extract information about updated diamonds and their facets
37
+ * @return An array of DiamondFacetData structs containing the decoded information
38
+ */
39
+ function decodeDiamondsFromJSON() internal view returns (DiamondFacetData[] memory) {
40
+ uint256 updatedDiamondLen = abi.decode(vm.parseJson(jsonData, ".numUpdated"), (uint256));
41
+ DiamondFacetData[] memory diamonds = new DiamondFacetData[](updatedDiamondLen);
42
+
43
+ for (uint256 i = 0; i < updatedDiamondLen; i++) {
44
+ // Decode diamond name and number of facets
45
+ DiamondFacetData memory diamondData = abi.decode(
46
+ vm.parseJson(jsonData, string.concat("$.updated[", vm.toString(i), "]")),
47
+ (DiamondFacetData)
48
+ );
49
+
50
+ diamonds[i] = diamondData;
51
+ }
52
+
53
+ return diamonds;
54
+ }
55
+
56
+ /**
57
+ * @notice Processes diamond and facet updates based on JSON input
58
+ * @dev This function reads a JSON file containing information about diamond and facet updates,
59
+ * then applies these updates to the corresponding diamonds. It performs the following
60
+ * steps:
61
+ * 1. Sets the OVERRIDE_DEPLOYMENTS environment variable
62
+ * 2. Determines the JSON input path (either from INTERACTION_INPUT_PATH env var or using a
63
+ * default)
64
+ * 3. Reads and decodes the JSON data
65
+ * 4. Iterates through each diamond update:
66
+ * - Identifies the diamond type (space, spaceOwner, spaceFactory, or baseRegistry)
67
+ * - Removes existing facets that are to be updated
68
+ * - Prepares new facet cuts
69
+ * - Executes a diamondCut operation to apply the updates
70
+ * @param deployer The address of the account that will deploy and interact with the contracts
71
+ */
72
+ function __interact(address deployer) internal override {
73
+ vm.setEnv("OVERRIDE_DEPLOYMENTS", "1");
74
+
75
+ string memory jsonPath;
76
+ try vm.envString("INTERACTION_INPUT_PATH") returns (string memory path) {
77
+ jsonPath = path;
78
+ } catch {
79
+ jsonPath = string.concat(vm.projectRoot(), DEFAULT_REPORT_PATH, DEFAULT_JSON_FILE);
80
+ }
81
+
82
+ readJSON(jsonPath);
83
+
84
+ DiamondFacetData[] memory diamonds = decodeDiamondsFromJSON();
85
+
86
+ // Iterate over diamonds array and process each diamond
87
+ for (uint256 i = 0; i < diamonds.length; i++) {
88
+ console.log("interact::diamondName", diamonds[i].diamond);
89
+ string memory diamondName = diamonds[i].diamond;
90
+ address diamondDeployedAddress;
91
+ FacetCut[] memory newCuts;
92
+ uint256 numFacets = diamonds[i].facets.length;
93
+ string[] memory facetNames = new string[](numFacets);
94
+ address[] memory facetAddresses = new address[](numFacets);
95
+
96
+ for (uint256 j = 0; j < numFacets; j++) {
97
+ FacetData memory facetData = diamonds[i].facets[j];
98
+ facetAddresses[j] = facetData.deployedAddress;
99
+ facetNames[j] = facetData.facetName;
100
+ }
101
+
102
+ address diamondHelper = diamondDeployments[diamondName];
103
+ if (diamondHelper != address(0)) {
104
+ console.log("interact::diamondDeployedName", diamondName);
105
+ diamondDeployedAddress = getDeployment(diamondName);
106
+ removeRemoteFacetsByAddresses(deployer, diamondDeployedAddress, facetAddresses);
107
+ console.log("interact::diamondHelper", diamondHelper);
108
+ console.log("interact::facetNames", facetNames[0]);
109
+ console.log("diamondDeployedAddress", diamondDeployedAddress);
110
+ newCuts = IDiamondInitHelper(diamondHelper).diamondInitHelper(deployer, facetNames);
111
+
112
+ vm.broadcast(deployer);
113
+ IDiamondCut(diamondDeployedAddress).diamondCut(newCuts, address(0), "");
114
+ }
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ // interfaces
5
+
6
+ // libraries
7
+
8
+ // contracts
9
+ import {Interaction} from "scripts/common/Interaction.s.sol";
10
+ import {Towns} from "src/tokens/towns/mainnet/Towns.sol";
11
+
12
+ // debugging
13
+ import {console} from "forge-std/console.sol";
14
+
15
+ contract InteractRiverMainnet is Interaction {
16
+ function __interact(address) internal view override {
17
+ address towns = address(0);
18
+
19
+ address[] memory delegators = Towns(towns).getDelegators();
20
+
21
+ for (uint256 i = 0; i < delegators.length; i++) {
22
+ address delegator = delegators[i];
23
+ console.log("Delegator:", delegator);
24
+ console.log("Delegates:", Towns(towns).delegates(delegator));
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.24;
3
+
4
+ // interfaces
5
+ import {IRiverConfig} from "src/river/registry/facets/config/IRiverConfig.sol";
6
+
7
+ // libraries
8
+ import {RiverConfigValues} from "scripts/interactions/helpers/RiverConfigValues.sol";
9
+
10
+ // contracts
11
+ import {Interaction} from "scripts/common/Interaction.s.sol";
12
+
13
+ contract InteractRiverRegistry is Interaction {
14
+ function __interact(address deployer) internal override {
15
+ address riverRegistry = getDeployment("riverRegistry");
16
+
17
+ uint64[] memory chains = new uint64[](9);
18
+ chains[0] = 1; // mainnet
19
+ chains[1] = 11_155_111; // sepolia
20
+ chains[2] = 8453; // base
21
+ chains[3] = 84_532; // base sepolia
22
+ chains[4] = 137; // polygon
23
+ chains[5] = 42_161; // arbitrum
24
+ chains[6] = 10; // optimism
25
+ chains[7] = 100; // gnosis
26
+ chains[8] = 10_200; // gnosis chiado
27
+
28
+ vm.startBroadcast(deployer);
29
+ IRiverConfig(riverRegistry).setConfiguration(
30
+ RiverConfigValues.XCHAIN_BLOCKCHAINS,
31
+ 0,
32
+ abi.encode(chains)
33
+ );
34
+ vm.stopBroadcast();
35
+ }
36
+ }
@@ -0,0 +1,30 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.24;
3
+
4
+ // interfaces
5
+ import {IRiverConfig} from "src/river/registry/facets/config/IRiverConfig.sol";
6
+
7
+ // libraries
8
+ import {RiverConfigValues} from "scripts/interactions/helpers/RiverConfigValues.sol";
9
+
10
+ // contracts
11
+ import {Interaction} from "scripts/common/Interaction.s.sol";
12
+
13
+ contract InteractRiverRegistrySetFreq is Interaction {
14
+ function __interact(address deployer) internal override {
15
+ address riverRegistry = getDeployment("riverRegistry");
16
+
17
+ address[] memory value = new address[](3);
18
+ value[0] = 0xa7f7D83843aB78706344D3Ae882b1d4f9404F254;
19
+ value[1] = 0x01A7dCd51409758f220c171c209eF3E1C8b10F1E;
20
+ value[2] = 0xC6CF68A1BCD3B9285fe1d13c128953a14Dd1Bb60;
21
+
22
+ vm.startBroadcast(deployer);
23
+ IRiverConfig(riverRegistry).setConfiguration(
24
+ RiverConfigValues.NODE_BLOCKLIST,
25
+ 13_396_808,
26
+ abi.encode(value)
27
+ );
28
+ vm.stopBroadcast();
29
+ }
30
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.24;
3
+
4
+ // interfaces
5
+ import {IRiverConfig} from "src/river/registry/facets/config/IRiverConfig.sol";
6
+
7
+ // libraries
8
+ import {RiverConfigValues} from "scripts/interactions/helpers/RiverConfigValues.sol";
9
+
10
+ // contracts
11
+ import {Interaction} from "scripts/common/Interaction.s.sol";
12
+
13
+ contract InteractRiverRegistrySetFreq is Interaction {
14
+ function __interact(address deployer) internal override {
15
+ address riverRegistry = getDeployment("riverRegistry");
16
+
17
+ uint64 value = 10;
18
+
19
+ vm.startBroadcast(deployer);
20
+ IRiverConfig(riverRegistry).setConfiguration(
21
+ RiverConfigValues.STREAM_MINIBLOCK_REGISTRATION_FREQUENCY,
22
+ 0,
23
+ abi.encode(value)
24
+ );
25
+ vm.stopBroadcast();
26
+ }
27
+ }
@@ -0,0 +1,30 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.24;
3
+
4
+ // interfaces
5
+ import {IRiverConfig} from "src/river/registry/facets/config/IRiverConfig.sol";
6
+
7
+ // libraries
8
+ import {RiverConfigValues} from "scripts/interactions/helpers/RiverConfigValues.sol";
9
+
10
+ // contracts
11
+ import {Interaction} from "scripts/common/Interaction.s.sol";
12
+
13
+ contract InteractRiverRegistrySetFreq is Interaction {
14
+ function __interact(address deployer) internal override {
15
+ address riverRegistry = getDeployment("riverRegistry");
16
+
17
+ uint64 value = 3;
18
+
19
+ // NOTE: Set block to something recent, otherwise older records will supersede the new one
20
+ // For get recent block from command line for env:
21
+ // ./core/env/<ENV_NAME>/run.sh registry blocknumber
22
+ vm.startBroadcast(deployer);
23
+ IRiverConfig(riverRegistry).setConfiguration(
24
+ RiverConfigValues.STREAM_REPLICATION_FACTOR,
25
+ 13824246, // Block number
26
+ abi.encode(value)
27
+ );
28
+ vm.stopBroadcast();
29
+ }
30
+ }
@@ -0,0 +1,20 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import {Interaction} from "../common/Interaction.s.sol";
5
+ import {ISpaceOwner} from "src/spaces/facets/owner/ISpaceOwner.sol";
6
+ import {LibString} from "solady/utils/LibString.sol";
7
+
8
+ contract InteractSetDefaultUri is Interaction {
9
+ string internal constant URI = "https://alpha.river.delivery/";
10
+
11
+ function __interact(address deployer) internal override {
12
+ // vm.setEnv("DEPLOYMENT_CONTEXT", "alpha");
13
+ address spaceOwner = getDeployment("spaceOwner");
14
+
15
+ vm.broadcast(deployer);
16
+ ISpaceOwner(spaceOwner).setDefaultUri(URI);
17
+
18
+ require(LibString.eq(ISpaceOwner(spaceOwner).getDefaultUri(), URI));
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import {Interaction} from "../common/Interaction.s.sol";
5
+ import {ISpaceOwner} from "src/spaces/facets/owner/ISpaceOwner.sol";
6
+ import {LibString} from "solady/utils/LibString.sol";
7
+
8
+ contract InteractSetDefaultUriLocalhost is Interaction {
9
+ string internal constant URI = "http://localhost:3002/";
10
+
11
+ function __interact(address deployer) internal override {
12
+ address spaceOwner = getDeployment("spaceOwner");
13
+
14
+ vm.broadcast(deployer);
15
+ ISpaceOwner(spaceOwner).setDefaultUri(URI);
16
+
17
+ require(LibString.eq(ISpaceOwner(spaceOwner).getDefaultUri(), URI));
18
+ }
19
+ }
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ // interfaces
5
+ import {IERC173} from "@towns-protocol/diamond/src/facets/ownable/IERC173.sol";
6
+
7
+ // libraries
8
+
9
+ // contracts
10
+ import {Interaction} from "../common/Interaction.s.sol";
11
+
12
+ contract InteractTransferOwnership is Interaction {
13
+ function __interact(address deployer) internal override {
14
+ address registry = getDeployment("space");
15
+ address newOwner = 0x92D549e96C470573b2af464F4E4A865C46C6D728;
16
+
17
+ vm.startBroadcast(deployer);
18
+ IERC173(registry).transferOwnership(newOwner);
19
+ vm.stopBroadcast();
20
+ }
21
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.24;
3
+
4
+ // interfaces
5
+ import {IRiverConfig} from "src/river/registry/facets/config/IRiverConfig.sol";
6
+
7
+ // libraries
8
+ import {RiverConfigValues} from "scripts/interactions/helpers/RiverConfigValues.sol";
9
+
10
+ // contracts
11
+ import {Interaction} from "scripts/common/Interaction.s.sol";
12
+
13
+ contract InteractUpdateMbRecencyCheck is Interaction {
14
+ function __interact(address deployer) internal override {
15
+ address riverRegistry = getDeployment("riverRegistry");
16
+
17
+ uint64 value = 30;
18
+
19
+ vm.startBroadcast(deployer);
20
+ IRiverConfig(riverRegistry).setConfiguration(
21
+ RiverConfigValues.MB_RECENCY_CHECK,
22
+ 0,
23
+ abi.encode(value)
24
+ );
25
+ vm.stopBroadcast();
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.24;
3
+
4
+ // interfaces
5
+ import {IRiverConfig} from "src/river/registry/facets/config/IRiverConfig.sol";
6
+
7
+ // libraries
8
+ import {RiverConfigValues} from "scripts/interactions/helpers/RiverConfigValues.sol";
9
+
10
+ // contracts
11
+ import {Interaction} from "scripts/common/Interaction.s.sol";
12
+
13
+ contract InteractUpdateMediaChunkCount is Interaction {
14
+ function __interact(address deployer) internal override {
15
+ address riverRegistry = getDeployment("riverRegistry");
16
+
17
+ uint64 value = 21;
18
+
19
+ vm.startBroadcast(deployer);
20
+ IRiverConfig(riverRegistry).setConfiguration(
21
+ RiverConfigValues.MEDIA_CHUNK_COUNT,
22
+ 0,
23
+ abi.encode(value)
24
+ );
25
+ vm.stopBroadcast();
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.24;
3
+
4
+ // interfaces
5
+ import {IRiverConfig} from "src/river/registry/facets/config/IRiverConfig.sol";
6
+
7
+ // libraries
8
+ import {RiverConfigValues} from "scripts/interactions/helpers/RiverConfigValues.sol";
9
+
10
+ // contracts
11
+ import {Interaction} from "scripts/common/Interaction.s.sol";
12
+
13
+ contract InteractUpdateMediaChunkSize is Interaction {
14
+ function __interact(address deployer) internal override {
15
+ address riverRegistry = getDeployment("riverRegistry");
16
+
17
+ uint64 value = 1200000;
18
+
19
+ vm.startBroadcast(deployer);
20
+ IRiverConfig(riverRegistry).setConfiguration(
21
+ RiverConfigValues.MEDIA_CHUNK_SIZE,
22
+ 0,
23
+ abi.encode(value)
24
+ );
25
+ vm.stopBroadcast();
26
+ }
27
+ }
@@ -0,0 +1,149 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ // interfaces
5
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
+ import {IDiamondCut} from "@towns-protocol/diamond/src/facets/cut/IDiamondCut.sol";
7
+ import {IDiamondLoupe, IDiamondLoupeBase} from "@towns-protocol/diamond/src/facets/loupe/IDiamondLoupe.sol";
8
+ import {IERC173} from "@towns-protocol/diamond/src/facets/ownable/IERC173.sol";
9
+ import {IOwnablePending} from "@towns-protocol/diamond/src/facets/ownable/pending/IOwnablePending.sol";
10
+
11
+ // libraries
12
+
13
+ // contracts
14
+ import {DiamondHelper} from "@towns-protocol/diamond/scripts/common/helpers/DiamondHelper.s.sol";
15
+ import {Diamond} from "@towns-protocol/diamond/src/Diamond.sol";
16
+ import {Interaction} from "scripts/common/Interaction.s.sol";
17
+
18
+ /// @dev note: struct fields must be in alphabetical order for the json parser to work
19
+ // see: https://book.getfoundry.sh/cheatcodes/parse-json
20
+ struct DiamondFacetData {
21
+ string chainName;
22
+ string diamond;
23
+ FacetData[] facets;
24
+ uint256 numFacets;
25
+ }
26
+
27
+ struct FacetData {
28
+ address deployedAddress;
29
+ string facetName;
30
+ bytes32 sourceHash;
31
+ }
32
+
33
+ abstract contract AlphaHelper is Interaction, DiamondHelper, IDiamondLoupeBase {
34
+ /// @notice Get addresses of core facets that should never be removed
35
+ /// @param diamond The diamond contract address
36
+ /// @return coreFacets An array of core facet addresses
37
+ function getCoreFacetAddresses(
38
+ address diamond
39
+ ) internal view returns (address[] memory coreFacets) {
40
+ coreFacets = new address[](5);
41
+
42
+ coreFacets[0] = IDiamondLoupe(diamond).facetAddress(IDiamondCut.diamondCut.selector);
43
+ coreFacets[1] = IDiamondLoupe(diamond).facetAddress(IDiamondLoupe.facets.selector);
44
+ coreFacets[2] = IDiamondLoupe(diamond).facetAddress(IERC165.supportsInterface.selector);
45
+ coreFacets[3] = IDiamondLoupe(diamond).facetAddress(IERC173.owner.selector);
46
+ coreFacets[4] = IDiamondLoupe(diamond).facetAddress(IOwnablePending.currentOwner.selector);
47
+ }
48
+
49
+ /// @notice Check if an address is a core facet that should not be removed
50
+ /// @param facetAddress The facet address to check
51
+ /// @param coreFacets Array of core facet addresses
52
+ /// @return True if the address is a core facet
53
+ function isCoreFacet(
54
+ address facetAddress,
55
+ address[] memory coreFacets
56
+ ) internal pure returns (bool) {
57
+ for (uint256 i; i < coreFacets.length; ++i) {
58
+ if (facetAddress == coreFacets[i]) {
59
+ return true;
60
+ }
61
+ }
62
+ return false;
63
+ }
64
+
65
+ /// @notice Execute a diamond cut to remove facets
66
+ /// @param deployer The address that will execute the diamond cut
67
+ /// @param diamond The diamond contract address
68
+ function executeDiamondCut(address deployer, address diamond) internal {
69
+ FacetCut[] memory cuts = baseFacets();
70
+ if (cuts.length == 0) return;
71
+ vm.broadcast(deployer);
72
+ IDiamondCut(diamond).diamondCut(cuts, address(0), "");
73
+ clearCuts();
74
+ }
75
+
76
+ /// @notice Remove all non-core facets from a diamond
77
+ /// @param deployer The address that will execute the diamond cut
78
+ /// @param diamond The diamond contract address
79
+ function removeRemoteFacets(address deployer, address diamond) internal {
80
+ Facet[] memory facets = IDiamondLoupe(diamond).facets();
81
+ address[] memory coreFacets = getCoreFacetAddresses(diamond);
82
+
83
+ for (uint256 i; i < facets.length; ++i) {
84
+ address facet = facets[i].facet;
85
+
86
+ if (isCoreFacet(facet, coreFacets)) {
87
+ info("Skipping core facet: %s", facet);
88
+ continue;
89
+ }
90
+
91
+ addCut(
92
+ FacetCut({
93
+ facetAddress: facet,
94
+ action: FacetCutAction.Remove,
95
+ functionSelectors: facets[i].selectors
96
+ })
97
+ );
98
+ }
99
+
100
+ executeDiamondCut(deployer, diamond);
101
+ }
102
+
103
+ /// @notice Remove specific facets from a diamond by address
104
+ /// @param deployer The address that will execute the diamond cut
105
+ /// @param diamond The diamond contract address
106
+ /// @param facetAddresses Array of facet addresses to remove
107
+ function removeRemoteFacetsByAddresses(
108
+ address deployer,
109
+ address diamond,
110
+ address[] memory facetAddresses
111
+ ) internal {
112
+ addCutsToRemove(diamond, facetAddresses);
113
+ executeDiamondCut(deployer, diamond);
114
+ }
115
+
116
+ /// @notice Add the facet cuts to remove from a diamond
117
+ /// @param diamond The diamond contract address
118
+ /// @param facetAddresses Array of facet addresses to remove
119
+ function addCutsToRemove(address diamond, address[] memory facetAddresses) internal {
120
+ Facet[] memory facets = IDiamondLoupe(diamond).facets();
121
+ address[] memory coreFacets = getCoreFacetAddresses(diamond);
122
+
123
+ for (uint256 i; i < facets.length; ++i) {
124
+ address facet = facets[i].facet;
125
+
126
+ if (isCoreFacet(facet, coreFacets)) {
127
+ continue;
128
+ }
129
+
130
+ if (contains(facetAddresses, facet)) {
131
+ addCut(
132
+ FacetCut({
133
+ facetAddress: facet,
134
+ action: FacetCutAction.Remove,
135
+ functionSelectors: facets[i].selectors
136
+ })
137
+ );
138
+ }
139
+ }
140
+ }
141
+
142
+ /// @notice Check if an address is in an array of addresses
143
+ function contains(address[] memory facetAddresses, address facet) internal pure returns (bool) {
144
+ for (uint256 i; i < facetAddresses.length; ++i) {
145
+ if (facet == facetAddresses[i]) return true;
146
+ }
147
+ return false;
148
+ }
149
+ }
@@ -0,0 +1,22 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ // interfaces
5
+
6
+ // libraries
7
+
8
+ // contracts
9
+
10
+ library RiverConfigValues {
11
+ bytes32 public constant ENABLE_NEW_SNAPSHOT_FORMAT =
12
+ keccak256("stream.enablenewsnapshotformat");
13
+ bytes32 public constant XCHAIN_BLOCKCHAINS = keccak256("xchain.blockchains");
14
+ bytes32 public constant NODE_BLOCKLIST = keccak256("node.blocklist");
15
+ bytes32 public constant STREAM_MINIBLOCK_REGISTRATION_FREQUENCY =
16
+ keccak256("stream.miniblockregistrationfrequency");
17
+ bytes32 public constant STREAM_REPLICATION_FACTOR = keccak256("stream.replicationfactor");
18
+ bytes32 public constant MEDIA_CHUNK_SIZE = keccak256("stream.media.maxchunksize");
19
+ bytes32 public constant MEDIA_CHUNK_COUNT = keccak256("stream.media.maxchunkcount");
20
+ bytes32 public constant ENABLE_NODE_2_NODE_AUTH = keccak256("server.enablenode2nodeauth");
21
+ bytes32 public constant MB_RECENCY_CHECK = keccak256("stream.recencyconstraints.ageseconds");
22
+ }
@@ -0,0 +1,35 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ // interfaces
5
+
6
+ // libraries
7
+
8
+ // contracts
9
+
10
+ interface IL1StandardBridge {
11
+ function depositETH(uint32 _minGasLimit, bytes calldata _extraData) external payable;
12
+
13
+ function depositETHTo(
14
+ address _to,
15
+ uint32 _minGasLimit,
16
+ bytes calldata _extraData
17
+ ) external payable;
18
+
19
+ function depositERC20(
20
+ address _l1Token,
21
+ address _l2Token,
22
+ uint256 _amount,
23
+ uint32 _minGasLimit,
24
+ bytes calldata _extraData
25
+ ) external;
26
+
27
+ function depositERC20To(
28
+ address _l1Token,
29
+ address _l2Token,
30
+ address _to,
31
+ uint256 _amount,
32
+ uint32 _minGasLimit,
33
+ bytes calldata _extraData
34
+ ) external;
35
+ }