@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.
- package/LICENSE.txt +21 -0
- package/README.md +206 -0
- package/docs/permitAndStake_integration_guide.md +266 -0
- package/docs/swap_integration_guide.md +591 -0
- package/package.json +57 -0
- package/scripts/common/DeployBase.s.sol +26 -0
- package/scripts/common/DeployFacet.s.sol +7 -0
- package/scripts/common/Deployer.s.sol +33 -0
- package/scripts/common/Interaction.s.sol +51 -0
- package/scripts/deployments/diamonds/DeployAppRegistry.s.sol +168 -0
- package/scripts/deployments/diamonds/DeployBaseRegistry.s.sol +263 -0
- package/scripts/deployments/diamonds/DeployRiverAirdrop.s.sol +203 -0
- package/scripts/deployments/diamonds/DeployRiverMigration.s.sol +129 -0
- package/scripts/deployments/diamonds/DeployRiverRegistry.s.sol +175 -0
- package/scripts/deployments/diamonds/DeploySpace.s.sol +285 -0
- package/scripts/deployments/diamonds/DeploySpaceFactory.s.sol +416 -0
- package/scripts/deployments/diamonds/DeploySpaceOwner.s.sol +183 -0
- package/scripts/deployments/diamonds/DeploySwapRouter.s.sol +176 -0
- package/scripts/deployments/diamonds/IDiamondInitHelper.sol +11 -0
- package/scripts/deployments/facets/DeployAppAccount.s.sol +51 -0
- package/scripts/deployments/facets/DeployAppRegistryFacet.s.sol +69 -0
- package/scripts/deployments/facets/DeployArchitect.s.sol +51 -0
- package/scripts/deployments/facets/DeployAttestationRegistry.s.sol +36 -0
- package/scripts/deployments/facets/DeployBanning.s.sol +30 -0
- package/scripts/deployments/facets/DeployChannels.s.sol +35 -0
- package/scripts/deployments/facets/DeployCreateSpace.s.sol +42 -0
- package/scripts/deployments/facets/DeployDropFacet.s.sol +49 -0
- package/scripts/deployments/facets/DeployERC721A.s.sol +48 -0
- package/scripts/deployments/facets/DeployERC721ANonTransferable.s.sol +49 -0
- package/scripts/deployments/facets/DeployERC721AQueryable.s.sol +30 -0
- package/scripts/deployments/facets/DeployEntitlementChecker.s.sol +49 -0
- package/scripts/deployments/facets/DeployEntitlementDataQueryable.s.sol +29 -0
- package/scripts/deployments/facets/DeployEntitlementsManager.s.sol +33 -0
- package/scripts/deployments/facets/DeployExecutorFacet.s.sol +60 -0
- package/scripts/deployments/facets/DeployFeatureManager.s.sol +38 -0
- package/scripts/deployments/facets/DeployGuardianFacet.s.sol +39 -0
- package/scripts/deployments/facets/DeployImplementationRegistry.s.sol +36 -0
- package/scripts/deployments/facets/DeployMainnetDelegation.s.sol +43 -0
- package/scripts/deployments/facets/DeployMembership.s.sol +77 -0
- package/scripts/deployments/facets/DeployMembershipMetadata.s.sol +30 -0
- package/scripts/deployments/facets/DeployMembershipToken.s.sol +47 -0
- package/scripts/deployments/facets/DeployMerkleAirdrop.s.sol +37 -0
- package/scripts/deployments/facets/DeployMetadata.s.sol +39 -0
- package/scripts/deployments/facets/DeployMockLegacyArchitect.s.sol +33 -0
- package/scripts/deployments/facets/DeployNodeOperator.s.sol +49 -0
- package/scripts/deployments/facets/DeployNodeRegistry.s.sol +37 -0
- package/scripts/deployments/facets/DeployOperatorRegistry.s.sol +36 -0
- package/scripts/deployments/facets/DeployPartnerRegistry.s.sol +41 -0
- package/scripts/deployments/facets/DeployPlatformRequirements.s.sol +75 -0
- package/scripts/deployments/facets/DeployPrepayFacet.s.sol +31 -0
- package/scripts/deployments/facets/DeployPricingModules.s.sol +36 -0
- package/scripts/deployments/facets/DeployReferrals.s.sol +34 -0
- package/scripts/deployments/facets/DeployReviewFacet.s.sol +31 -0
- package/scripts/deployments/facets/DeployRewardsDistributionV2.s.sol +76 -0
- package/scripts/deployments/facets/DeployRiverConfig.s.sol +41 -0
- package/scripts/deployments/facets/DeployRoles.s.sol +48 -0
- package/scripts/deployments/facets/DeploySchemaRegistry.s.sol +35 -0
- package/scripts/deployments/facets/DeploySignerFacet.s.sol +47 -0
- package/scripts/deployments/facets/DeploySimpleApp.s.sol +10 -0
- package/scripts/deployments/facets/DeploySpaceDelegation.s.sol +43 -0
- package/scripts/deployments/facets/DeploySpaceEntitlementGated.s.sol +31 -0
- package/scripts/deployments/facets/DeploySpaceFactoryInit.s.sol +33 -0
- package/scripts/deployments/facets/DeploySpaceOwnerFacet.s.sol +71 -0
- package/scripts/deployments/facets/DeployStreamRegistry.s.sol +50 -0
- package/scripts/deployments/facets/DeploySwapFacet.s.sol +33 -0
- package/scripts/deployments/facets/DeploySwapRouterFacet.s.sol +38 -0
- package/scripts/deployments/facets/DeployTipping.s.sol +31 -0
- package/scripts/deployments/facets/DeployTokenMigration.s.sol +40 -0
- package/scripts/deployments/facets/DeployTownsPoints.s.sol +53 -0
- package/scripts/deployments/facets/DeployTreasury.s.sol +30 -0
- package/scripts/deployments/facets/DeployUpgradeableBeacon.s.sol +34 -0
- package/scripts/deployments/facets/DeployWalletLink.s.sol +56 -0
- package/scripts/deployments/facets/DeployXChain.s.sol +35 -0
- package/scripts/deployments/utils/DeployAccountFactory.s.sol +40 -0
- package/scripts/deployments/utils/DeployEntitlementGatedExample.s.sol +23 -0
- package/scripts/deployments/utils/DeployEntrypoint.s.sol +28 -0
- package/scripts/deployments/utils/DeployMember.s.sol +95 -0
- package/scripts/deployments/utils/DeployMockDiamond.s.sol +7 -0
- package/scripts/deployments/utils/DeployMockERC20.s.sol +24 -0
- package/scripts/deployments/utils/DeployMockERC721A.s.sol +45 -0
- package/scripts/deployments/utils/DeployMockLegacyMembership.s.sol +29 -0
- package/scripts/deployments/utils/DeployMockMessenger.s.sol +42 -0
- package/scripts/deployments/utils/DeployMockNFT.s.sol +86 -0
- package/scripts/deployments/utils/DeployPoapEntitlement.s.sol +16 -0
- package/scripts/deployments/utils/DeployProxyBatchDelegation.s.sol +112 -0
- package/scripts/deployments/utils/DeploySpaceProxyInitializer.s.sol +28 -0
- package/scripts/deployments/utils/DeployTieredLogPricingV2.s.sol +23 -0
- package/scripts/deployments/utils/DeployTieredLogPricingV3.s.sol +23 -0
- package/scripts/deployments/utils/DeployTownsBase.s.sol +95 -0
- package/scripts/deployments/utils/DeployTownsMainnet.s.sol +66 -0
- package/scripts/deployments/utils/DeployTownsMulti.s.sol +53 -0
- package/scripts/deployments/utils/DeployWrappedTowns.s.sol +52 -0
- package/scripts/deployments/utils/LibLayerZeroValues.sol +34 -0
- package/scripts/deployments/utils/pricing/TieredLogPricing.s.sol +45 -0
- package/scripts/interactions/InteractAirdrop.s.sol +57 -0
- package/scripts/interactions/InteractAlphaPost.s.sol +32 -0
- package/scripts/interactions/InteractAlphaSparse.s.sol +173 -0
- package/scripts/interactions/InteractBaseAlpha.s.sol +84 -0
- package/scripts/interactions/InteractBaseBridge.s.sol +48 -0
- package/scripts/interactions/InteractBridgeLayerZero.s.sol +102 -0
- package/scripts/interactions/InteractClaimCondition.s.sol +56 -0
- package/scripts/interactions/InteractCreateSpace.s.sol +50 -0
- package/scripts/interactions/InteractDiamondCut.s.sol +47 -0
- package/scripts/interactions/InteractDropFacet.s.sol +32 -0
- package/scripts/interactions/InteractEnableNewSnapshotFormat.s.sol +27 -0
- package/scripts/interactions/InteractEnableNode2NodeAuth.s.sol +27 -0
- package/scripts/interactions/InteractMembership.s.sol +42 -0
- package/scripts/interactions/InteractMockERC721A.s.sol +20 -0
- package/scripts/interactions/InteractNodeOperators.s.sol +41 -0
- package/scripts/interactions/InteractPostDeploy.s.sol +59 -0
- package/scripts/interactions/InteractPrepay.s.sol +30 -0
- package/scripts/interactions/InteractRegisterApp.s.sol +61 -0
- package/scripts/interactions/InteractRiverAlpha.s.sol +30 -0
- package/scripts/interactions/InteractRiverAlphaSparse.s.sol +117 -0
- package/scripts/interactions/InteractRiverMainnet.s.sol +27 -0
- package/scripts/interactions/InteractRiverRegistry.s.sol +36 -0
- package/scripts/interactions/InteractRiverRegistrySetBlocklist.s.sol +30 -0
- package/scripts/interactions/InteractRiverRegistrySetFreq.s.sol +27 -0
- package/scripts/interactions/InteractRiverRegistrySetRepl.s.sol +30 -0
- package/scripts/interactions/InteractSetDefaultUri.s.sol +20 -0
- package/scripts/interactions/InteractSetDefaultUriLocalhost.s.sol +19 -0
- package/scripts/interactions/InteractTransferOwnership.s.sol +21 -0
- package/scripts/interactions/InteractUpdateMbRecencyCheck.s.sol +27 -0
- package/scripts/interactions/InteractUpdateMediaChunkCount.s.sol +27 -0
- package/scripts/interactions/InteractUpdateMediaChunkSize.s.sol +27 -0
- package/scripts/interactions/helpers/AlphaHelper.sol +149 -0
- package/scripts/interactions/helpers/RiverConfigValues.sol +22 -0
- package/scripts/interactions/interfaces/IL1StandardBridge.sol +35 -0
- package/scripts/interactions/interfaces/IL2StandardBridge.sol +69 -0
- package/src/airdrop/drop/DropBase.sol +210 -0
- package/src/airdrop/drop/DropClaim.sol +55 -0
- package/src/airdrop/drop/DropFacet.sol +176 -0
- package/src/airdrop/drop/DropGroup.sol +111 -0
- package/src/airdrop/drop/DropStorage.sol +23 -0
- package/src/airdrop/drop/IDropFacet.sol +136 -0
- package/src/airdrop/points/CheckIn.sol +71 -0
- package/src/airdrop/points/ITownsPoints.sol +64 -0
- package/src/airdrop/points/TownsPoints.sol +196 -0
- package/src/airdrop/points/TownsPointsStorage.sol +22 -0
- package/src/apps/BaseApp.sol +62 -0
- package/src/apps/ITownsApp.sol +28 -0
- package/src/apps/SchemaResolver.sol +170 -0
- package/src/apps/facets/attest/AttestationBase.sol +335 -0
- package/src/apps/facets/attest/AttestationLib.sol +64 -0
- package/src/apps/facets/attest/AttestationRegistry.sol +39 -0
- package/src/apps/facets/attest/AttestationStorage.sol +35 -0
- package/src/apps/facets/attest/IAttestationRegistry.sol +43 -0
- package/src/apps/facets/registry/AppRegistryBase.sol +403 -0
- package/src/apps/facets/registry/AppRegistryFacet.sol +173 -0
- package/src/apps/facets/registry/AppRegistryStorage.sol +53 -0
- package/src/apps/facets/registry/IAppRegistry.sol +159 -0
- package/src/apps/facets/schema/ISchema.sol +14 -0
- package/src/apps/facets/schema/SchemaBase.sol +88 -0
- package/src/apps/facets/schema/SchemaLib.sol +14 -0
- package/src/apps/facets/schema/SchemaRegistry.sol +51 -0
- package/src/apps/facets/schema/SchemaStorage.sol +34 -0
- package/src/apps/helpers/ISimpleApp.sol +51 -0
- package/src/apps/helpers/SimpleApp.sol +97 -0
- package/src/apps/helpers/SimpleAppStorage.sol +27 -0
- package/src/base/registry/facets/checker/EntitlementChecker.sol +237 -0
- package/src/base/registry/facets/checker/EntitlementCheckerStorage.sol +28 -0
- package/src/base/registry/facets/checker/IEntitlementChecker.sol +95 -0
- package/src/base/registry/facets/delegation/ISpaceDelegation.sol +69 -0
- package/src/base/registry/facets/delegation/SpaceDelegationFacet.sol +250 -0
- package/src/base/registry/facets/delegation/SpaceDelegationStorage.sol +35 -0
- package/src/base/registry/facets/distribution/v1/IRewardsDistribution.sol +51 -0
- package/src/base/registry/facets/distribution/v1/RewardsDistribution.sol +439 -0
- package/src/base/registry/facets/distribution/v1/RewardsDistributionStorage.sol +32 -0
- package/src/base/registry/facets/distribution/v2/DelegationProxy.sol +53 -0
- package/src/base/registry/facets/distribution/v2/IRewardsDistribution.sol +372 -0
- package/src/base/registry/facets/distribution/v2/RewardsDistributionBase.sol +299 -0
- package/src/base/registry/facets/distribution/v2/RewardsDistributionStorage.sol +37 -0
- package/src/base/registry/facets/distribution/v2/RewardsDistributionV2.sol +392 -0
- package/src/base/registry/facets/distribution/v2/StakingRewards.sol +466 -0
- package/src/base/registry/facets/mainnet/ICrossDomainMessenger.sol +58 -0
- package/src/base/registry/facets/mainnet/IMainnetDelegation.sol +127 -0
- package/src/base/registry/facets/mainnet/MainnetDelegation.sol +119 -0
- package/src/base/registry/facets/mainnet/MainnetDelegationBase.sol +274 -0
- package/src/base/registry/facets/mainnet/MainnetDelegationStorage.sol +36 -0
- package/src/base/registry/facets/operator/INodeOperator.sol +91 -0
- package/src/base/registry/facets/operator/NodeOperatorFacet.sol +189 -0
- package/src/base/registry/facets/operator/NodeOperatorStorage.sol +39 -0
- package/src/base/registry/facets/xchain/IXChain.sol +54 -0
- package/src/base/registry/facets/xchain/XChain.sol +158 -0
- package/src/base/registry/facets/xchain/XChainCheckLib.sol +105 -0
- package/src/base/registry/facets/xchain/XChainLib.sol +46 -0
- package/src/diamond/facets/beacon/UpgradeableBeacon.sol +38 -0
- package/src/diamond/facets/beacon/UpgradeableBeaconFacet.sol +34 -0
- package/src/diamond/facets/governance/votes/Checkpoints.sol +642 -0
- package/src/diamond/facets/governance/votes/Votes.sol +63 -0
- package/src/diamond/facets/governance/votes/VotesBase.sol +274 -0
- package/src/diamond/facets/governance/votes/VotesStorage.sol +21 -0
- package/src/diamond/facets/governance/votes/enumerable/IVotesEnumerable.sol +38 -0
- package/src/diamond/facets/governance/votes/enumerable/VotesEnumerable.sol +39 -0
- package/src/diamond/facets/governance/votes/enumerable/VotesEnumerableLib.sol +102 -0
- package/src/diamond/facets/metadata/IMetadata.sol +27 -0
- package/src/diamond/facets/metadata/MetadataFacet.sol +71 -0
- package/src/diamond/facets/token/ERC5643/ERC5643.sol +51 -0
- package/src/diamond/facets/token/ERC5643/ERC5643Base.sol +48 -0
- package/src/diamond/facets/token/ERC5643/ERC5643Storage.sol +26 -0
- package/src/diamond/facets/token/ERC5643/IERC5643.sol +44 -0
- package/src/diamond/facets/token/ERC721A/ERC721A.sol +270 -0
- package/src/diamond/facets/token/ERC721A/ERC721ABase.sol +829 -0
- package/src/diamond/facets/token/ERC721A/ERC721ANonTransferable.sol +21 -0
- package/src/diamond/facets/token/ERC721A/ERC721AStorage.sol +115 -0
- package/src/diamond/facets/token/ERC721A/IERC721A.sol +283 -0
- package/src/diamond/facets/token/ERC721A/extensions/ERC721AQueryable.sol +134 -0
- package/src/diamond/facets/token/ERC721A/extensions/IERC721AQueryable.sol +83 -0
- package/src/diamond/utils/Context.sol +19 -0
- package/src/factory/SpaceFactoryInit.sol +17 -0
- package/src/factory/facets/architect/Architect.sol +98 -0
- package/src/factory/facets/architect/ArchitectBase.sol +95 -0
- package/src/factory/facets/architect/ArchitectStorage.sol +28 -0
- package/src/factory/facets/architect/IArchitect.sol +155 -0
- package/src/factory/facets/architect/ImplementationStorage.sol +42 -0
- package/src/factory/facets/architect/pricing/IPricingModules.sol +41 -0
- package/src/factory/facets/architect/pricing/PricingModulesBase.sol +89 -0
- package/src/factory/facets/architect/pricing/PricingModulesFacet.sol +40 -0
- package/src/factory/facets/architect/pricing/PricingModulesStorage.sol +30 -0
- package/src/factory/facets/create/CreateSpace.sol +107 -0
- package/src/factory/facets/create/CreateSpaceLib.sol +335 -0
- package/src/factory/facets/create/ICreateSpace.sol +70 -0
- package/src/factory/facets/feature/FeatureConditionLib.sol +53 -0
- package/src/factory/facets/feature/FeatureManagerFacet.sol +66 -0
- package/src/factory/facets/feature/FeatureManagerLib.sol +168 -0
- package/src/factory/facets/feature/IFeatureManagerFacet.sol +73 -0
- package/src/factory/facets/partner/IPartnerRegistry.sol +56 -0
- package/src/factory/facets/partner/PartnerRegistry.sol +57 -0
- package/src/factory/facets/partner/PartnerRegistryBase.sol +132 -0
- package/src/factory/facets/partner/PartnerRegistryStorage.sol +40 -0
- package/src/factory/facets/platform/requirements/IPlatformRequirements.sol +143 -0
- package/src/factory/facets/platform/requirements/PlatformRequirementsBase.sol +124 -0
- package/src/factory/facets/platform/requirements/PlatformRequirementsFacet.sol +122 -0
- package/src/factory/facets/platform/requirements/PlatformRequirementsStorage.sol +41 -0
- package/src/factory/facets/registry/IImplementationRegistry.sol +46 -0
- package/src/factory/facets/registry/ImplementationRegistry.sol +64 -0
- package/src/factory/facets/registry/ImplementationRegistryStorage.sol +28 -0
- package/src/factory/facets/wallet-link/IWalletLink.sol +218 -0
- package/src/factory/facets/wallet-link/WalletLink.sol +108 -0
- package/src/factory/facets/wallet-link/WalletLinkBase.sol +492 -0
- package/src/factory/facets/wallet-link/interfaces/IDelegateRegistry.sol +63 -0
- package/src/factory/facets/wallet-link/interfaces/IDelegateRegistryV1.sol +35 -0
- package/src/factory/facets/wallet-link/interfaces/ISCL_EIP6565.sol +24 -0
- package/src/factory/facets/wallet-link/libraries/SolanaUtils.sol +161 -0
- package/src/factory/facets/wallet-link/libraries/WalletLib.sol +62 -0
- package/src/river/registry/facets/config/IRiverConfig.sol +117 -0
- package/src/river/registry/facets/config/RiverConfig.sol +174 -0
- package/src/river/registry/facets/node/INodeRegistry.sol +69 -0
- package/src/river/registry/facets/node/NodeRegistry.sol +143 -0
- package/src/river/registry/facets/operator/IOperatorRegistry.sol +28 -0
- package/src/river/registry/facets/operator/OperatorRegistry.sol +86 -0
- package/src/river/registry/facets/stream/IStreamRegistry.sol +184 -0
- package/src/river/registry/facets/stream/StreamRegistry.sol +396 -0
- package/src/river/registry/libraries/RegistryErrors.sol +24 -0
- package/src/river/registry/libraries/RegistryStorage.sol +181 -0
- package/src/router/ISwapRouter.sol +226 -0
- package/src/router/Permit2Hash.sol +92 -0
- package/src/router/SwapRouter.sol +463 -0
- package/src/router/SwapRouterStorage.sol +21 -0
- package/src/spaces/entitlements/ICrossChainEntitlement.sol +22 -0
- package/src/spaces/entitlements/IEntitlement.sol +61 -0
- package/src/spaces/entitlements/PolymarketEntitlement.sol +79 -0
- package/src/spaces/entitlements/poap/IPOAP.sol +26 -0
- package/src/spaces/entitlements/poap/PoapEntitlement.sol +56 -0
- package/src/spaces/entitlements/rule/IRuleEntitlement.sol +174 -0
- package/src/spaces/entitlements/rule/RuleEntitlement.sol +183 -0
- package/src/spaces/entitlements/rule/RuleEntitlementV2.sol +219 -0
- package/src/spaces/entitlements/user/IUserEntitlement.sol +24 -0
- package/src/spaces/entitlements/user/UserEntitlement.sol +273 -0
- package/src/spaces/facets/DependencyLib.sol +60 -0
- package/src/spaces/facets/Entitled.sol +172 -0
- package/src/spaces/facets/Permissions.sol +21 -0
- package/src/spaces/facets/account/AppAccount.sol +93 -0
- package/src/spaces/facets/account/AppAccountBase.sol +275 -0
- package/src/spaces/facets/account/AppAccountStorage.sol +63 -0
- package/src/spaces/facets/account/IAppAccount.sol +71 -0
- package/src/spaces/facets/account/SignerFacet.sol +26 -0
- package/src/spaces/facets/banning/Banning.sol +41 -0
- package/src/spaces/facets/banning/BanningBase.sol +33 -0
- package/src/spaces/facets/banning/BanningStorage.sol +23 -0
- package/src/spaces/facets/banning/IBanning.sol +35 -0
- package/src/spaces/facets/channels/ChannelBase.sol +87 -0
- package/src/spaces/facets/channels/ChannelService.sol +177 -0
- package/src/spaces/facets/channels/ChannelStorage.sol +34 -0
- package/src/spaces/facets/channels/Channels.sol +80 -0
- package/src/spaces/facets/channels/IChannel.sol +98 -0
- package/src/spaces/facets/dispatcher/DispatcherBase.sol +86 -0
- package/src/spaces/facets/dispatcher/DispatcherStorage.sol +21 -0
- package/src/spaces/facets/dispatcher/IDispatcher.sol +6 -0
- package/src/spaces/facets/entitlements/EntitlementsManager.sol +49 -0
- package/src/spaces/facets/entitlements/EntitlementsManagerBase.sol +87 -0
- package/src/spaces/facets/entitlements/EntitlementsManagerService.sol +142 -0
- package/src/spaces/facets/entitlements/EntitlementsManagerStorage.sol +34 -0
- package/src/spaces/facets/entitlements/IEntitlementsManager.sol +67 -0
- package/src/spaces/facets/entitlements/extensions/EntitlementDataQueryable.sol +153 -0
- package/src/spaces/facets/entitlements/extensions/IEntitlementDataQueryable.sol +32 -0
- package/src/spaces/facets/executor/ExecutorBase.sol +564 -0
- package/src/spaces/facets/executor/ExecutorFacet.sol +178 -0
- package/src/spaces/facets/executor/ExecutorStorage.sol +99 -0
- package/src/spaces/facets/executor/GroupLib.sol +128 -0
- package/src/spaces/facets/executor/IExecutor.sol +287 -0
- package/src/spaces/facets/executor/hooks/HookBase.sol +172 -0
- package/src/spaces/facets/executor/hooks/HookLib.sol +38 -0
- package/src/spaces/facets/executor/hooks/IHookBase.sol +48 -0
- package/src/spaces/facets/gated/EntitlementGated.sol +59 -0
- package/src/spaces/facets/gated/EntitlementGatedBase.sol +324 -0
- package/src/spaces/facets/gated/EntitlementGatedStorage.sol +29 -0
- package/src/spaces/facets/gated/IEntitlementGated.sol +55 -0
- package/src/spaces/facets/guardian/GuardianBase.sol +80 -0
- package/src/spaces/facets/guardian/GuardianFacet.sol +43 -0
- package/src/spaces/facets/guardian/GuardianStorage.sol +27 -0
- package/src/spaces/facets/guardian/IGuardian.sol +54 -0
- package/src/spaces/facets/membership/IMembership.sol +216 -0
- package/src/spaces/facets/membership/MembershipBase.sol +272 -0
- package/src/spaces/facets/membership/MembershipFacet.sol +191 -0
- package/src/spaces/facets/membership/MembershipStorage.sol +40 -0
- package/src/spaces/facets/membership/join/MembershipJoin.sol +547 -0
- package/src/spaces/facets/membership/metadata/IMembershipMetadata.sol +9 -0
- package/src/spaces/facets/membership/metadata/MembershipMetadata.sol +32 -0
- package/src/spaces/facets/membership/pricing/IMembershipPricing.sol +18 -0
- package/src/spaces/facets/membership/pricing/fixed/FixedPricing.sol +29 -0
- package/src/spaces/facets/membership/pricing/fixed/FixedPricingStorage.sol +27 -0
- package/src/spaces/facets/membership/pricing/tiered/TieredLogPricingOracleV2.sol +148 -0
- package/src/spaces/facets/membership/pricing/tiered/TieredLogPricingOracleV3.sol +137 -0
- package/src/spaces/facets/membership/token/MembershipToken.sol +25 -0
- package/src/spaces/facets/owner/ISpaceOwner.sol +85 -0
- package/src/spaces/facets/owner/SpaceOwner.sol +174 -0
- package/src/spaces/facets/owner/SpaceOwnerBase.sol +121 -0
- package/src/spaces/facets/owner/SpaceOwnerStorage.sol +41 -0
- package/src/spaces/facets/owner/SpaceOwnerUriBase.sol +54 -0
- package/src/spaces/facets/points/PointsBase.sol +35 -0
- package/src/spaces/facets/prepay/IPrepay.sol +43 -0
- package/src/spaces/facets/prepay/PrepayBase.sol +27 -0
- package/src/spaces/facets/prepay/PrepayFacet.sol +59 -0
- package/src/spaces/facets/prepay/PrepayStorage.sol +26 -0
- package/src/spaces/facets/proxy/ISpaceProxyInitializer.sol +21 -0
- package/src/spaces/facets/proxy/SpaceProxy.sol +15 -0
- package/src/spaces/facets/proxy/SpaceProxyInitializer.sol +55 -0
- package/src/spaces/facets/referrals/IReferrals.sol +98 -0
- package/src/spaces/facets/referrals/ReferralsBase.sol +81 -0
- package/src/spaces/facets/referrals/ReferralsFacet.sol +65 -0
- package/src/spaces/facets/referrals/ReferralsStorage.sol +36 -0
- package/src/spaces/facets/review/IReview.sol +50 -0
- package/src/spaces/facets/review/ReviewFacet.sol +105 -0
- package/src/spaces/facets/review/ReviewStorage.sol +29 -0
- package/src/spaces/facets/roles/IRoles.sol +197 -0
- package/src/spaces/facets/roles/Roles.sol +123 -0
- package/src/spaces/facets/roles/RolesBase.sol +420 -0
- package/src/spaces/facets/roles/RolesStorage.sol +132 -0
- package/src/spaces/facets/swap/ISwapFacet.sol +91 -0
- package/src/spaces/facets/swap/SwapFacet.sol +290 -0
- package/src/spaces/facets/swap/SwapFacetStorage.sol +24 -0
- package/src/spaces/facets/tipping/ITipping.sol +80 -0
- package/src/spaces/facets/tipping/TippingBase.sol +73 -0
- package/src/spaces/facets/tipping/TippingFacet.sol +123 -0
- package/src/spaces/facets/treasury/ITreasury.sol +64 -0
- package/src/spaces/facets/treasury/Treasury.sol +82 -0
- package/src/spaces/facets/xchain/SpaceEntitlementGated.sol +62 -0
- package/src/tokens/Member.sol +246 -0
- package/src/tokens/lock/ILock.sol +42 -0
- package/src/tokens/lock/LockBase.sol +64 -0
- package/src/tokens/lock/LockFacet.sol +44 -0
- package/src/tokens/lock/LockStorage.sol +26 -0
- package/src/tokens/mainnet/claimer/AuthorizedClaimerStorage.sol +26 -0
- package/src/tokens/mainnet/claimer/AuthorizedClaimers.sol +84 -0
- package/src/tokens/mainnet/claimer/IAuthorizedClaimers.sol +36 -0
- package/src/tokens/mainnet/delegation/ProxyBatchDelegation.sol +86 -0
- package/src/tokens/migration/ITokenMigration.sol +35 -0
- package/src/tokens/migration/TokenMigrationFacet.sol +86 -0
- package/src/tokens/migration/TokenMigrationStorage.sol +27 -0
- package/src/tokens/towns/base/IERC7802.sol +30 -0
- package/src/tokens/towns/base/IOptimismMintableERC20.sol +31 -0
- package/src/tokens/towns/base/ISemver.sol +13 -0
- package/src/tokens/towns/base/Towns.sol +283 -0
- package/src/tokens/towns/base/TownsDeployer.sol +32 -0
- package/src/tokens/towns/base/TownsLib.sol +31 -0
- package/src/tokens/towns/base/versions/TownsV2.sol +15 -0
- package/src/tokens/towns/mainnet/ITowns.sol +56 -0
- package/src/tokens/towns/mainnet/Towns.sol +220 -0
- package/src/tokens/towns/mainnet/libs/TokenInflationLib.sol +89 -0
- package/src/tokens/towns/multichain/Towns.sol +19 -0
- package/src/tokens/towns/multichain/wTowns.sol +18 -0
- package/src/utils/Airdrop.sol +156 -0
- package/src/utils/airdrop/merkle/IMerkleAirdrop.sol +55 -0
- package/src/utils/airdrop/merkle/MerkleAirdrop.sol +118 -0
- package/src/utils/airdrop/merkle/MerkleAirdropStorage.sol +29 -0
- package/src/utils/interfaces/AggregatorV3Interface.sol +37 -0
- package/src/utils/interfaces/IMulticall.sol +10 -0
- package/src/utils/interfaces/IWETH.sol +10 -0
- package/src/utils/libraries/BasisPoints.sol +24 -0
- package/src/utils/libraries/Create2Utils.sol +74 -0
- package/src/utils/libraries/CurrencyTransfer.sol +99 -0
- package/src/utils/libraries/CustomRevert.sol +49 -0
- package/src/utils/libraries/Factory.sol +66 -0
- package/src/utils/libraries/StringSet.sol +190 -0
- package/src/utils/libraries/Validator.sol +31 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
import {IFeatureManagerFacetBase} from "./IFeatureManagerFacet.sol";
|
|
7
|
+
import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol";
|
|
8
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
9
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
10
|
+
|
|
11
|
+
// libraries
|
|
12
|
+
|
|
13
|
+
import {CustomRevert} from "../../../utils/libraries/CustomRevert.sol";
|
|
14
|
+
import {FeatureCondition, FeatureConditionLib} from "./FeatureConditionLib.sol";
|
|
15
|
+
import {EnumerableSetLib} from "solady/utils/EnumerableSetLib.sol";
|
|
16
|
+
|
|
17
|
+
/// @title FeatureManager
|
|
18
|
+
library FeatureManagerLib {
|
|
19
|
+
using EnumerableSetLib for EnumerableSetLib.Bytes32Set;
|
|
20
|
+
using FeatureConditionLib for FeatureCondition;
|
|
21
|
+
|
|
22
|
+
// keccak256(abi.encode(uint256(keccak256("factory.facets.feature.manager.storage")) - 1)) & ~bytes32(uint256(0xff))
|
|
23
|
+
bytes32 constant DEFAULT_STORAGE_SLOT =
|
|
24
|
+
0x20c456a8ea15fcf7965033c954321ffd9dc82a2c65f686a77e2a67da65c29000;
|
|
25
|
+
|
|
26
|
+
/// @notice Storage layout for the FeatureManager
|
|
27
|
+
/// @dev Maps feature IDs to their activation conditions
|
|
28
|
+
/// @custom:storage-location erc7201:towns.storage.FeatureManager
|
|
29
|
+
struct Layout {
|
|
30
|
+
// Feature IDs
|
|
31
|
+
EnumerableSetLib.Bytes32Set featureIds;
|
|
32
|
+
// Feature ID => Condition
|
|
33
|
+
mapping(bytes32 featureId => FeatureCondition condition) conditions;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// @notice Sets the condition for a specific feature
|
|
37
|
+
/// @dev Validates token, threshold, and total supply to ensure proper configuration
|
|
38
|
+
/// @param self The storage layout pointer
|
|
39
|
+
/// @param featureId The unique identifier for the feature
|
|
40
|
+
/// @param condition The condition parameters for feature activation
|
|
41
|
+
/// @custom:error InvalidToken Thrown when token is address(0) or doesn't support IVotes
|
|
42
|
+
/// @custom:error InvalidTotalSupply Thrown when token total supply is 0
|
|
43
|
+
/// @custom:error InvalidThreshold Thrown when threshold exceeds total supply
|
|
44
|
+
function setFeatureCondition(
|
|
45
|
+
Layout storage self,
|
|
46
|
+
bytes32 featureId,
|
|
47
|
+
FeatureCondition calldata condition
|
|
48
|
+
) internal {
|
|
49
|
+
if (condition.token == address(0)) {
|
|
50
|
+
CustomRevert.revertWith(IFeatureManagerFacetBase.InvalidToken.selector);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_validateGetVotes(condition);
|
|
54
|
+
|
|
55
|
+
// Check totalSupply directly
|
|
56
|
+
try IERC20(condition.token).totalSupply() returns (uint256 totalSupply) {
|
|
57
|
+
if (totalSupply == 0) {
|
|
58
|
+
CustomRevert.revertWith(IFeatureManagerFacetBase.InvalidTotalSupply.selector);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (condition.threshold > totalSupply) {
|
|
62
|
+
CustomRevert.revertWith(IFeatureManagerFacetBase.InvalidThreshold.selector);
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
CustomRevert.revertWith(IFeatureManagerFacetBase.InvalidToken.selector);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
self.featureIds.add(featureId);
|
|
69
|
+
self.conditions[featureId] = condition;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// @notice Retrieves the condition for a specific feature
|
|
73
|
+
/// @dev Returns the complete condition struct with all parameters
|
|
74
|
+
/// @param self The storage layout pointer
|
|
75
|
+
/// @param featureId The unique identifier for the feature
|
|
76
|
+
/// @return Condition memory The complete condition configuration for the feature
|
|
77
|
+
function getFeatureCondition(
|
|
78
|
+
Layout storage self,
|
|
79
|
+
bytes32 featureId
|
|
80
|
+
) internal view returns (FeatureCondition memory) {
|
|
81
|
+
return self.conditions[featureId];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// @notice Retrieves all feature conditions
|
|
85
|
+
/// @dev Returns an array of all feature conditions
|
|
86
|
+
/// @param self The storage layout pointer
|
|
87
|
+
/// @return Condition[] An array of all feature conditions
|
|
88
|
+
function getFeatureConditions(
|
|
89
|
+
Layout storage self
|
|
90
|
+
) internal view returns (FeatureCondition[] memory) {
|
|
91
|
+
uint256 featureCount = self.featureIds.length();
|
|
92
|
+
|
|
93
|
+
FeatureCondition[] memory conditions = new FeatureCondition[](featureCount);
|
|
94
|
+
for (uint256 i; i < featureCount; ++i) {
|
|
95
|
+
conditions[i] = self.conditions[self.featureIds.at(i)];
|
|
96
|
+
}
|
|
97
|
+
return conditions;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// @notice Retrieves all feature conditions for a specific space
|
|
101
|
+
/// @dev Returns an array of all feature conditions that are active for the space
|
|
102
|
+
/// @param self The storage layout pointer
|
|
103
|
+
/// @param space The address of the space to check conditions for
|
|
104
|
+
/// @return Condition[] An array of all feature conditions that are active for the space
|
|
105
|
+
function getFeatureConditionsForSpace(
|
|
106
|
+
Layout storage self,
|
|
107
|
+
address space
|
|
108
|
+
) internal view returns (FeatureCondition[] memory) {
|
|
109
|
+
uint256 featureCount = self.featureIds.length();
|
|
110
|
+
|
|
111
|
+
FeatureCondition[] memory conditions = new FeatureCondition[](featureCount);
|
|
112
|
+
uint256 index;
|
|
113
|
+
|
|
114
|
+
for (uint256 i; i < featureCount; ++i) {
|
|
115
|
+
FeatureCondition storage condition = self.conditions[self.featureIds.at(i)];
|
|
116
|
+
uint256 votes = condition.getVotes(space);
|
|
117
|
+
|
|
118
|
+
if (condition.meetsThreshold(votes)) {
|
|
119
|
+
conditions[index++] = condition;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
assembly ("memory-safe") {
|
|
124
|
+
mstore(conditions, index)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return conditions;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// @notice Disables a feature by setting its active flag to false
|
|
131
|
+
/// @dev This does not delete the condition, only deactivates it
|
|
132
|
+
/// @param self The storage layout pointer
|
|
133
|
+
/// @param featureId The unique identifier for the feature to disable
|
|
134
|
+
function disableFeatureCondition(Layout storage self, bytes32 featureId) internal {
|
|
135
|
+
FeatureCondition storage condition = self.conditions[featureId];
|
|
136
|
+
if (!condition.active) {
|
|
137
|
+
CustomRevert.revertWith(IFeatureManagerFacetBase.FeatureNotActive.selector);
|
|
138
|
+
}
|
|
139
|
+
condition.active = false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function _validateGetVotes(FeatureCondition calldata condition) internal view {
|
|
143
|
+
// Check IVotes support by attempting to call getVotes
|
|
144
|
+
try IVotes(condition.token).getVotes(address(this)) returns (uint256) {
|
|
145
|
+
// If we get here, getVotes is supported
|
|
146
|
+
return;
|
|
147
|
+
} catch {
|
|
148
|
+
CustomRevert.revertWith(IFeatureManagerFacetBase.InvalidInterface.selector);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// @notice Retrieves the layout for the FeatureManager at the default storage slot
|
|
153
|
+
/// @dev This is accessed by the facet contract
|
|
154
|
+
/// @return $ The layout storage pointer
|
|
155
|
+
function getLayout() internal pure returns (Layout storage $) {
|
|
156
|
+
return getLayout(DEFAULT_STORAGE_SLOT);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/// @notice Retrieves the layout for the FeatureManager at a custom storage slot
|
|
160
|
+
/// @dev This function is used to access the storage layout for a given slot
|
|
161
|
+
/// @param slot The storage slot to retrieve the layout for
|
|
162
|
+
/// @return $ The layout storage pointer
|
|
163
|
+
function getLayout(bytes32 slot) internal pure returns (Layout storage $) {
|
|
164
|
+
assembly {
|
|
165
|
+
$.slot := slot
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
import {FeatureCondition} from "./FeatureConditionLib.sol";
|
|
8
|
+
|
|
9
|
+
// contracts
|
|
10
|
+
|
|
11
|
+
/// @title IFeatureManagerFacetBase
|
|
12
|
+
/// @notice Base interface for the FeatureManager facet defining errors and events
|
|
13
|
+
/// @dev Used by the FeatureManager facet and any other facets that need to access feature conditions
|
|
14
|
+
interface IFeatureManagerFacetBase {
|
|
15
|
+
/// @notice Error thrown when a threshold exceeds the token's total supply
|
|
16
|
+
error InvalidThreshold();
|
|
17
|
+
|
|
18
|
+
/// @notice Error thrown when a token has zero total supply
|
|
19
|
+
error InvalidTotalSupply();
|
|
20
|
+
|
|
21
|
+
/// @notice Error thrown when an invalid token address is provided (zero address or non-IVotes token)
|
|
22
|
+
error InvalidToken();
|
|
23
|
+
|
|
24
|
+
/// @notice Error thrown when an invalid token interface is provided
|
|
25
|
+
error InvalidInterface();
|
|
26
|
+
|
|
27
|
+
/// @notice Error thrown when a feature condition is not active
|
|
28
|
+
error FeatureNotActive();
|
|
29
|
+
|
|
30
|
+
/// @notice Emitted when a feature condition is set or updated
|
|
31
|
+
/// @param featureId The unique identifier for the feature whose condition was set
|
|
32
|
+
/// @param condition The condition parameters that were set for the feature
|
|
33
|
+
event FeatureConditionSet(bytes32 indexed featureId, FeatureCondition condition);
|
|
34
|
+
|
|
35
|
+
/// @notice Emitted when a feature condition is disabled
|
|
36
|
+
/// @param featureId The unique identifier for the feature whose condition was disabled
|
|
37
|
+
event FeatureConditionDisabled(bytes32 indexed featureId);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface IFeatureManagerFacet is IFeatureManagerFacetBase {
|
|
41
|
+
/// @notice Sets the condition for a feature
|
|
42
|
+
/// @param featureId The unique identifier for the feature
|
|
43
|
+
/// @param condition The condition struct containing token, threshold, active status, and extra data
|
|
44
|
+
/// @dev Only callable by the contract owner
|
|
45
|
+
function setFeatureCondition(bytes32 featureId, FeatureCondition memory condition) external;
|
|
46
|
+
|
|
47
|
+
/// @notice Gets the condition for a feature
|
|
48
|
+
/// @param featureId The unique identifier for the feature
|
|
49
|
+
/// @return The condition struct for the specified feature
|
|
50
|
+
function getFeatureCondition(bytes32 featureId) external view returns (FeatureCondition memory);
|
|
51
|
+
|
|
52
|
+
/// @notice Retrieves all feature conditions
|
|
53
|
+
/// @return An array of all feature conditions
|
|
54
|
+
function getFeatureConditions() external view returns (FeatureCondition[] memory);
|
|
55
|
+
|
|
56
|
+
/// @notice Retrieves all feature conditions for a specific space
|
|
57
|
+
/// @param space The address of the space to check conditions for
|
|
58
|
+
/// @return An array of all feature conditions that are active for the space
|
|
59
|
+
function getFeatureConditionsForSpace(
|
|
60
|
+
address space
|
|
61
|
+
) external view returns (FeatureCondition[] memory);
|
|
62
|
+
|
|
63
|
+
/// @notice Disables a feature condition
|
|
64
|
+
/// @param featureId The unique identifier for the feature
|
|
65
|
+
/// @dev Only callable by the contract owner
|
|
66
|
+
function disableFeatureCondition(bytes32 featureId) external;
|
|
67
|
+
|
|
68
|
+
/// @notice Checks if a space meets the condition for a feature
|
|
69
|
+
/// @param featureId The unique identifier for the feature
|
|
70
|
+
/// @param space The address of the space to check
|
|
71
|
+
/// @return True if the space meets the threshold for the feature, false otherwise
|
|
72
|
+
function checkFeatureCondition(bytes32 featureId, address space) external view returns (bool);
|
|
73
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
|
|
8
|
+
// contracts
|
|
9
|
+
|
|
10
|
+
interface IPartnerRegistryBase {
|
|
11
|
+
struct Partner {
|
|
12
|
+
address account;
|
|
13
|
+
address recipient;
|
|
14
|
+
uint256 fee;
|
|
15
|
+
bool active;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Errors
|
|
19
|
+
error PartnerRegistry__PartnerAlreadyRegistered(address account);
|
|
20
|
+
error PartnerRegistry__RegistryFeeNotPaid(uint256 fee);
|
|
21
|
+
error PartnerRegistry__PartnerNotRegistered(address account);
|
|
22
|
+
error PartnerRegistry__NotPartnerAccount(address account);
|
|
23
|
+
error PartnerRegistry__PartnerNotActive(address account);
|
|
24
|
+
error PartnerRegistry__InvalidPartnerFee(uint256 fee);
|
|
25
|
+
error PartnerRegistry__InvalidRecipient();
|
|
26
|
+
|
|
27
|
+
// Events
|
|
28
|
+
event PartnerRegistered(address indexed account);
|
|
29
|
+
event PartnerUpdated(address indexed account);
|
|
30
|
+
event PartnerRemoved(address indexed account);
|
|
31
|
+
event MaxPartnerFeeSet(uint256 fee);
|
|
32
|
+
event RegistryFeeSet(uint256 fee);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface IPartnerRegistry is IPartnerRegistryBase {
|
|
36
|
+
function registerPartner(Partner memory partner) external payable;
|
|
37
|
+
|
|
38
|
+
function partnerInfo(address account) external view returns (Partner memory);
|
|
39
|
+
|
|
40
|
+
function partnerFee(address account) external view returns (uint256 fee);
|
|
41
|
+
|
|
42
|
+
function updatePartner(Partner memory partner) external;
|
|
43
|
+
|
|
44
|
+
function removePartner(address account) external;
|
|
45
|
+
|
|
46
|
+
// =============================================================
|
|
47
|
+
// Admin
|
|
48
|
+
// =============================================================
|
|
49
|
+
function maxPartnerFee() external view returns (uint256 fee);
|
|
50
|
+
|
|
51
|
+
function setMaxPartnerFee(uint256 fee) external;
|
|
52
|
+
|
|
53
|
+
function registryFee() external view returns (uint256 fee);
|
|
54
|
+
|
|
55
|
+
function setRegistryFee(uint256 fee) external;
|
|
56
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IPartnerRegistry} from "./IPartnerRegistry.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
|
|
9
|
+
// contracts
|
|
10
|
+
import {PartnerRegistryBase} from "./PartnerRegistryBase.sol";
|
|
11
|
+
import {Facet} from "@towns-protocol/diamond/src/facets/Facet.sol";
|
|
12
|
+
import {OwnableBase} from "@towns-protocol/diamond/src/facets/ownable/OwnableBase.sol";
|
|
13
|
+
|
|
14
|
+
contract PartnerRegistry is PartnerRegistryBase, OwnableBase, IPartnerRegistry, Facet {
|
|
15
|
+
function __PartnerRegistry_init() external onlyInitializing {
|
|
16
|
+
_addInterface(type(IPartnerRegistry).interfaceId);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function registerPartner(Partner calldata partner) external payable {
|
|
20
|
+
_registerPartner(partner);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function partnerInfo(address account) external view returns (Partner memory) {
|
|
24
|
+
return _partner(account);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function partnerFee(address account) external view returns (uint256 fee) {
|
|
28
|
+
return _partnerFee(account);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function updatePartner(Partner calldata partner) external {
|
|
32
|
+
_updatePartner(partner);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function removePartner(address account) external onlyOwner {
|
|
36
|
+
_removePartner(account);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// =============================================================
|
|
40
|
+
// ADMIN
|
|
41
|
+
// =============================================================
|
|
42
|
+
function maxPartnerFee() external view returns (uint256 fee) {
|
|
43
|
+
return _maxPartnerFee();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function setMaxPartnerFee(uint256 fee) external onlyOwner {
|
|
47
|
+
_setMaxPartnerFee(fee);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function registryFee() external view returns (uint256 fee) {
|
|
51
|
+
return _registryFee();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function setRegistryFee(uint256 fee) external onlyOwner {
|
|
55
|
+
_setRegistryFee(fee);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IPartnerRegistryBase} from "./IPartnerRegistry.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
|
|
9
|
+
import {PartnerRegistryStorage} from "./PartnerRegistryStorage.sol";
|
|
10
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
11
|
+
|
|
12
|
+
// contracts
|
|
13
|
+
|
|
14
|
+
abstract contract PartnerRegistryBase is IPartnerRegistryBase {
|
|
15
|
+
using EnumerableSet for EnumerableSet.AddressSet;
|
|
16
|
+
|
|
17
|
+
function __PartnerRegistryBase_init(uint256 registryFee, uint256 maxPartnerFee) internal {
|
|
18
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
19
|
+
|
|
20
|
+
ds.partnerSettings = PartnerRegistryStorage.PartnerSettings({
|
|
21
|
+
registryFee: registryFee,
|
|
22
|
+
maxPartnerFee: maxPartnerFee
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _registerPartner(Partner memory partner) internal {
|
|
27
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
28
|
+
|
|
29
|
+
PartnerRegistryStorage.PartnerSettings memory settings = ds.partnerSettings;
|
|
30
|
+
|
|
31
|
+
if (msg.value != settings.registryFee) {
|
|
32
|
+
revert PartnerRegistry__RegistryFeeNotPaid(settings.registryFee);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (partner.fee > settings.maxPartnerFee) {
|
|
36
|
+
revert PartnerRegistry__InvalidPartnerFee(partner.fee);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!ds.partners.add(partner.account)) {
|
|
40
|
+
revert PartnerRegistry__PartnerAlreadyRegistered(partner.account);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ds.partnerByAccount[partner.account] = PartnerRegistryStorage.Partner({
|
|
44
|
+
recipient: partner.recipient,
|
|
45
|
+
fee: partner.fee,
|
|
46
|
+
createdAt: block.timestamp,
|
|
47
|
+
active: partner.active
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
emit PartnerRegistered(partner.account);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function _updatePartner(Partner memory partner) internal {
|
|
54
|
+
if (partner.account != msg.sender) {
|
|
55
|
+
revert PartnerRegistry__NotPartnerAccount(msg.sender);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (partner.recipient == address(0)) {
|
|
59
|
+
revert PartnerRegistry__InvalidRecipient();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
63
|
+
|
|
64
|
+
if (!ds.partners.contains(partner.account)) {
|
|
65
|
+
revert PartnerRegistry__PartnerNotRegistered(partner.account);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
PartnerRegistryStorage.PartnerSettings memory settings = ds.partnerSettings;
|
|
69
|
+
|
|
70
|
+
if (partner.fee > settings.maxPartnerFee) {
|
|
71
|
+
revert PartnerRegistry__InvalidPartnerFee(partner.fee);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
ds.partnerByAccount[partner.account].recipient = partner.recipient;
|
|
75
|
+
ds.partnerByAccount[partner.account].fee = partner.fee;
|
|
76
|
+
ds.partnerByAccount[partner.account].active = partner.active;
|
|
77
|
+
|
|
78
|
+
emit PartnerUpdated(partner.account);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function _removePartner(address account) internal {
|
|
82
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
83
|
+
|
|
84
|
+
if (!ds.partners.remove(account)) {
|
|
85
|
+
revert PartnerRegistry__PartnerNotRegistered(account);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
delete ds.partnerByAccount[account];
|
|
89
|
+
|
|
90
|
+
emit PartnerRemoved(account);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function _partner(address account) internal view returns (Partner memory partner) {
|
|
94
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
95
|
+
|
|
96
|
+
partner = Partner({
|
|
97
|
+
account: account,
|
|
98
|
+
recipient: ds.partnerByAccount[account].recipient,
|
|
99
|
+
fee: ds.partnerByAccount[account].fee,
|
|
100
|
+
active: ds.partnerByAccount[account].active
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _partnerFee(address account) internal view returns (uint256 fee) {
|
|
105
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
106
|
+
fee = ds.partnerByAccount[account].fee;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function _maxPartnerFee() internal view returns (uint256 fee) {
|
|
110
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
111
|
+
fee = ds.partnerSettings.maxPartnerFee;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _setMaxPartnerFee(uint256 fee) internal {
|
|
115
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
116
|
+
ds.partnerSettings.maxPartnerFee = fee;
|
|
117
|
+
|
|
118
|
+
emit MaxPartnerFeeSet(fee);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function _registryFee() internal view returns (uint256 fee) {
|
|
122
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
123
|
+
fee = ds.partnerSettings.registryFee;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function _setRegistryFee(uint256 fee) internal {
|
|
127
|
+
PartnerRegistryStorage.Layout storage ds = PartnerRegistryStorage.layout();
|
|
128
|
+
ds.partnerSettings.registryFee = fee;
|
|
129
|
+
|
|
130
|
+
emit RegistryFeeSet(fee);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
8
|
+
|
|
9
|
+
// contracts
|
|
10
|
+
|
|
11
|
+
library PartnerRegistryStorage {
|
|
12
|
+
// keccak256(abi.encode(uint256(keccak256("spaces.facets.partner.registry.storage")) - 1)) &
|
|
13
|
+
// ~bytes32(uint256(0xff))
|
|
14
|
+
bytes32 internal constant STORAGE_SLOT =
|
|
15
|
+
0x7b5ecdde71ed61c776cb15819e7e4ea6887ef4293a4dfb12ecb38ffd92c3f400;
|
|
16
|
+
|
|
17
|
+
struct Partner {
|
|
18
|
+
address recipient;
|
|
19
|
+
uint256 fee; // fee in basis points
|
|
20
|
+
uint256 createdAt;
|
|
21
|
+
bool active;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
struct PartnerSettings {
|
|
25
|
+
uint256 registryFee; // fee in ether
|
|
26
|
+
uint256 maxPartnerFee; // fee in basis points
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
struct Layout {
|
|
30
|
+
EnumerableSet.AddressSet partners;
|
|
31
|
+
PartnerSettings partnerSettings;
|
|
32
|
+
mapping(address account => Partner) partnerByAccount;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function layout() internal pure returns (Layout storage ds) {
|
|
36
|
+
assembly {
|
|
37
|
+
ds.slot := STORAGE_SLOT
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
|
|
8
|
+
// contracts
|
|
9
|
+
|
|
10
|
+
interface IPlatformRequirementsBase {
|
|
11
|
+
// Errors
|
|
12
|
+
error Platform__InvalidFeeRecipient();
|
|
13
|
+
error Platform__InvalidMembershipBps();
|
|
14
|
+
error Platform__InvalidMembershipMintLimit();
|
|
15
|
+
error Platform__InvalidMembershipDuration();
|
|
16
|
+
error Platform__InvalidMembershipMinPrice();
|
|
17
|
+
error Platform__InvalidSwapFeeBps();
|
|
18
|
+
|
|
19
|
+
// Events
|
|
20
|
+
event PlatformFeeRecipientSet(address indexed recipient);
|
|
21
|
+
event PlatformMembershipBpsSet(uint16 bps);
|
|
22
|
+
event PlatformMembershipFeeSet(uint256 fee);
|
|
23
|
+
event PlatformMembershipMintLimitSet(uint256 limit);
|
|
24
|
+
event PlatformMembershipDurationSet(uint256 duration);
|
|
25
|
+
event PlatformMembershipMinPriceSet(uint256 minPrice);
|
|
26
|
+
event PlatformSwapFeesSet(uint16 protocolBps, uint16 posterBps);
|
|
27
|
+
event RouterWhitelistUpdated(address indexed router, bool whitelisted);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface IPlatformRequirements is IPlatformRequirementsBase {
|
|
31
|
+
/**
|
|
32
|
+
* @notice Set the fee recipient address
|
|
33
|
+
* @dev This is the address that will receive the platform fees
|
|
34
|
+
* @param recipient The address of the fee recipient
|
|
35
|
+
*/
|
|
36
|
+
function setFeeRecipient(address recipient) external;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @notice Get the fee recipient address
|
|
40
|
+
* @return The address of the fee recipient
|
|
41
|
+
*/
|
|
42
|
+
function getFeeRecipient() external view returns (address);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @notice Set the membership basis points
|
|
46
|
+
* @param bps The membership basis points
|
|
47
|
+
*/
|
|
48
|
+
function setMembershipBps(uint16 bps) external;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @notice Get the membership basis points
|
|
52
|
+
* @dev This is the basis points that will be charged for a membership
|
|
53
|
+
* @return The membership basis points
|
|
54
|
+
*/
|
|
55
|
+
function getMembershipBps() external view returns (uint16);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @notice Set the membership flat fee
|
|
59
|
+
* @param fee The membership fee
|
|
60
|
+
*/
|
|
61
|
+
function setMembershipFee(uint256 fee) external;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @notice Get the membership flat fee
|
|
65
|
+
* @dev This is the flat fee that will be charged for a membership
|
|
66
|
+
* @return The membership fee
|
|
67
|
+
*/
|
|
68
|
+
function getMembershipFee() external view returns (uint256);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @notice Set the membership mint limit
|
|
72
|
+
* @param limit The membership mint limit
|
|
73
|
+
*/
|
|
74
|
+
function setMembershipMintLimit(uint256 limit) external;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @notice Get the membership mint limit
|
|
78
|
+
* @dev This is the maximum number of free memberships that can be minted per space
|
|
79
|
+
* @return The membership mint limit
|
|
80
|
+
*/
|
|
81
|
+
function getMembershipMintLimit() external view returns (uint256);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @notice Set the membership duration
|
|
85
|
+
* @param duration The membership duration
|
|
86
|
+
*/
|
|
87
|
+
function setMembershipDuration(uint64 duration) external;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @notice Get the membership duration
|
|
91
|
+
* @dev This is the duration of a membership in seconds
|
|
92
|
+
* @return The membership duration
|
|
93
|
+
*/
|
|
94
|
+
function getMembershipDuration() external view returns (uint64);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @notice Get the minimum price for a membership
|
|
98
|
+
* @dev This is the minimum price that can be set for a membership
|
|
99
|
+
* @return The minimum price for a membership
|
|
100
|
+
*/
|
|
101
|
+
function getMembershipMinPrice() external view returns (uint256);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @notice Set the minimum price for a membership
|
|
105
|
+
* @param minPrice The minimum price for a membership
|
|
106
|
+
*/
|
|
107
|
+
function setMembershipMinPrice(uint256 minPrice) external;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @notice Get the denominator
|
|
111
|
+
* @dev This is the denominator used for calculating fees
|
|
112
|
+
* @return The denominator
|
|
113
|
+
*/
|
|
114
|
+
function getDenominator() external pure returns (uint256);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @notice Get the swap fees in basis points
|
|
118
|
+
* @return protocolBps Basis points for protocol fee
|
|
119
|
+
* @return posterBps Basis points for poster fee
|
|
120
|
+
*/
|
|
121
|
+
function getSwapFees() external view returns (uint16 protocolBps, uint16 posterBps);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @notice Set the swap fees in basis points
|
|
125
|
+
* @param protocolBps Basis points for protocol fee
|
|
126
|
+
* @param posterBps Basis points for poster fee
|
|
127
|
+
*/
|
|
128
|
+
function setSwapFees(uint16 protocolBps, uint16 posterBps) external;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @notice Check if a router is whitelisted
|
|
132
|
+
* @param router Address of the router to check
|
|
133
|
+
* @return bool True if router is whitelisted
|
|
134
|
+
*/
|
|
135
|
+
function isRouterWhitelisted(address router) external view returns (bool);
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @notice Add or remove a router from whitelist
|
|
139
|
+
* @param router Address of the router
|
|
140
|
+
* @param whitelisted True to whitelist, false to remove
|
|
141
|
+
*/
|
|
142
|
+
function setRouterWhitelisted(address router, bool whitelisted) external;
|
|
143
|
+
}
|