@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,178 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IExecutor} from "./IExecutor.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
import {CustomRevert} from "../../../utils/libraries/CustomRevert.sol";
|
|
9
|
+
|
|
10
|
+
// contracts
|
|
11
|
+
import {Facet} from "@towns-protocol/diamond/src/facets/Facet.sol";
|
|
12
|
+
import {OwnableBase} from "@towns-protocol/diamond/src/facets/ownable/OwnableBase.sol";
|
|
13
|
+
import {ExecutorBase} from "./ExecutorBase.sol";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @title Executor
|
|
17
|
+
* @notice Facet that enables permissioned calls from a Space
|
|
18
|
+
* @dev This contract is used for implementation reference purposes
|
|
19
|
+
*/
|
|
20
|
+
contract ExecutorFacet is OwnableBase, ExecutorBase, IExecutor, Facet {
|
|
21
|
+
using CustomRevert for bytes4;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @notice Validates if the target address is allowed for calls
|
|
25
|
+
* @dev Prevents calls to critical system contracts
|
|
26
|
+
* @param target The contract address to check
|
|
27
|
+
*/
|
|
28
|
+
modifier onlyAuthorized(address target) {
|
|
29
|
+
_checkAuthorized(target);
|
|
30
|
+
_;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// @inheritdoc IExecutor
|
|
34
|
+
function grantAccess(
|
|
35
|
+
bytes32 groupId,
|
|
36
|
+
address account,
|
|
37
|
+
uint32 delay
|
|
38
|
+
) external onlyOwner returns (bool newMember) {
|
|
39
|
+
_setGroupStatus(groupId, true);
|
|
40
|
+
return _grantGroupAccess(groupId, account, _getGroupGrantDelay(groupId), delay);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// @inheritdoc IExecutor
|
|
44
|
+
function grantAccessWithExpiration(
|
|
45
|
+
bytes32 groupId,
|
|
46
|
+
address account,
|
|
47
|
+
uint32 delay,
|
|
48
|
+
uint48 expiration
|
|
49
|
+
) external onlyOwner returns (bool newMember) {
|
|
50
|
+
_setGroupStatus(groupId, true, expiration);
|
|
51
|
+
return _grantGroupAccess(groupId, account, _getGroupGrantDelay(groupId), delay);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// @inheritdoc IExecutor
|
|
55
|
+
function revokeAccess(bytes32 groupId, address account) external onlyOwner {
|
|
56
|
+
_revokeGroupAccess(groupId, account);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/// @inheritdoc IExecutor
|
|
60
|
+
function renounceAccess(bytes32 groupId, address account) external {
|
|
61
|
+
_renounceGroupAccess(groupId, account);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// @inheritdoc IExecutor
|
|
65
|
+
function setGuardian(bytes32 groupId, bytes32 guardian) external onlyOwner {
|
|
66
|
+
_setGroupGuardian(groupId, guardian);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// @inheritdoc IExecutor
|
|
70
|
+
function setGroupDelay(bytes32 groupId, uint32 delay) external onlyOwner {
|
|
71
|
+
_setGroupGrantDelay(groupId, delay, 0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// @inheritdoc IExecutor
|
|
75
|
+
function setGroupExpiration(bytes32 groupId, uint48 expiration) external onlyOwner {
|
|
76
|
+
_setGroupExpiration(groupId, expiration);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// @inheritdoc IExecutor
|
|
80
|
+
function setTargetFunctionGroup(
|
|
81
|
+
address target,
|
|
82
|
+
bytes4 selector,
|
|
83
|
+
bytes32 groupId
|
|
84
|
+
) external onlyAuthorized(target) onlyOwner {
|
|
85
|
+
_setTargetFunctionGroup(target, selector, groupId);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// @inheritdoc IExecutor
|
|
89
|
+
function setTargetDisabled(
|
|
90
|
+
address target,
|
|
91
|
+
bool disabled
|
|
92
|
+
) external onlyAuthorized(target) onlyOwner {
|
|
93
|
+
_setTargetDisabled(target, disabled);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// @inheritdoc IExecutor
|
|
97
|
+
function scheduleOperation(
|
|
98
|
+
address target,
|
|
99
|
+
bytes calldata data,
|
|
100
|
+
uint48 when
|
|
101
|
+
) external payable returns (bytes32 operationId, uint32 nonce) {
|
|
102
|
+
return _scheduleExecution(target, data, when);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// @inheritdoc IExecutor
|
|
106
|
+
function execute(
|
|
107
|
+
address target,
|
|
108
|
+
uint256 value,
|
|
109
|
+
bytes calldata data
|
|
110
|
+
) external payable onlyAuthorized(target) returns (uint32 nonce) {
|
|
111
|
+
(, nonce) = _execute(target, value, data);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/// @inheritdoc IExecutor
|
|
115
|
+
function cancel(
|
|
116
|
+
address caller,
|
|
117
|
+
address target,
|
|
118
|
+
bytes calldata data
|
|
119
|
+
) external returns (uint32 nonce) {
|
|
120
|
+
return _cancel(caller, target, data);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// @inheritdoc IExecutor
|
|
124
|
+
function hasAccess(
|
|
125
|
+
bytes32 groupId,
|
|
126
|
+
address account
|
|
127
|
+
) external view returns (bool isMember, uint32 executionDelay, bool active) {
|
|
128
|
+
return _hasGroupAccess(groupId, account);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// @inheritdoc IExecutor
|
|
132
|
+
function getAccess(
|
|
133
|
+
bytes32 groupId,
|
|
134
|
+
address account
|
|
135
|
+
)
|
|
136
|
+
external
|
|
137
|
+
view
|
|
138
|
+
returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect)
|
|
139
|
+
{
|
|
140
|
+
return _getAccess(groupId, account);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// @inheritdoc IExecutor
|
|
144
|
+
function getGroupDelay(bytes32 groupId) external view returns (uint32) {
|
|
145
|
+
return _getGroupGrantDelay(groupId);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// @inheritdoc IExecutor
|
|
149
|
+
function getScheduleTimepoint(bytes32 id) external view returns (uint48) {
|
|
150
|
+
return _getScheduleTimepoint(id);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// @inheritdoc IExecutor
|
|
154
|
+
function onExecution(address target) external view returns (bool) {
|
|
155
|
+
return _isTargetExecuting(target);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/// @inheritdoc IExecutor
|
|
159
|
+
function hashOperation(
|
|
160
|
+
address caller,
|
|
161
|
+
address target,
|
|
162
|
+
bytes calldata data
|
|
163
|
+
) external pure returns (bytes32) {
|
|
164
|
+
return _hashOperation(caller, target, data);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
168
|
+
/* Internal */
|
|
169
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
170
|
+
|
|
171
|
+
/// @dev Internal function to get the owner
|
|
172
|
+
function _getOwner() internal view virtual override returns (address) {
|
|
173
|
+
return _owner();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/// @dev Internal function to check if a target is authorized
|
|
177
|
+
function _checkAuthorized(address target) internal virtual {}
|
|
178
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// types
|
|
7
|
+
|
|
8
|
+
// libraries
|
|
9
|
+
|
|
10
|
+
// types
|
|
11
|
+
import {Group, Schedule, Target} from "./IExecutor.sol";
|
|
12
|
+
import {HookConfig} from "./hooks/IHookBase.sol";
|
|
13
|
+
import {GroupLib} from "./GroupLib.sol";
|
|
14
|
+
|
|
15
|
+
// contracts
|
|
16
|
+
|
|
17
|
+
library ExecutorStorage {
|
|
18
|
+
using GroupLib for Group;
|
|
19
|
+
|
|
20
|
+
// keccak256(abi.encode(uint256(keccak256("spaces.facets.executor.storage")) - 1)) & ~bytes32(uint256(0xff))
|
|
21
|
+
bytes32 internal constant STORAGE_SLOT =
|
|
22
|
+
0xb7e2813a9de15ce5ee4c1718778708cd70fd7ee3d196d203c0f40369a8d4a600;
|
|
23
|
+
|
|
24
|
+
// keccak256(abi.encode(uint256(keccak256("spaces.facets.executor.transient.storage")) - 1)) & ~bytes32(uint256(0xff))
|
|
25
|
+
bytes32 internal constant TRANSIENT_STORAGE_SLOT =
|
|
26
|
+
0x50b382cc42d5e85c7df990b4496d41f5c12a6bb29194f1db29e58a2d7a053600;
|
|
27
|
+
|
|
28
|
+
struct Layout {
|
|
29
|
+
// Execution ID
|
|
30
|
+
bytes32 executionId;
|
|
31
|
+
// Target => Target Details
|
|
32
|
+
mapping(address target => Target targetDetails) targets;
|
|
33
|
+
// Group ID => Group
|
|
34
|
+
mapping(bytes32 groupId => Group group) groups;
|
|
35
|
+
// Schedule ID => Schedule
|
|
36
|
+
mapping(bytes32 scheduleId => Schedule schedule) schedules;
|
|
37
|
+
// Hook Config ID => Hook Config
|
|
38
|
+
mapping(bytes32 configId => HookConfig config) hooks;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getLayout() internal pure returns (Layout storage l) {
|
|
42
|
+
assembly {
|
|
43
|
+
l.slot := STORAGE_SLOT
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
48
|
+
/* Group Access */
|
|
49
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
50
|
+
function getGroup(bytes32 groupId) internal view returns (Group storage) {
|
|
51
|
+
return getLayout().groups[groupId];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function hasGroupAccess(
|
|
55
|
+
bytes32 groupId,
|
|
56
|
+
address account
|
|
57
|
+
) internal view returns (bool isMember, uint32 executionDelay, bool active) {
|
|
58
|
+
Group storage group = getGroup(groupId);
|
|
59
|
+
(isMember, executionDelay) = group.hasAccess(account);
|
|
60
|
+
|
|
61
|
+
// Check both active status and expiration
|
|
62
|
+
active = group.active && (group.expiration == 0 || group.expiration > block.timestamp);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
66
|
+
/* Transient Execution Id */
|
|
67
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
68
|
+
|
|
69
|
+
function getTransientExecutionId() internal view returns (bytes32 id) {
|
|
70
|
+
assembly {
|
|
71
|
+
id := tload(TRANSIENT_STORAGE_SLOT)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function setTransientExecutionId(bytes32 id) internal {
|
|
76
|
+
assembly {
|
|
77
|
+
tstore(TRANSIENT_STORAGE_SLOT, id)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function getTargetExecutionId(address target) internal view returns (bytes32 id) {
|
|
82
|
+
assembly {
|
|
83
|
+
id := tload(target)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function setTargetExecutionId(address target, bytes32 id) internal {
|
|
88
|
+
assembly {
|
|
89
|
+
tstore(target, id)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function clearTransientStorage(address target) internal {
|
|
94
|
+
assembly {
|
|
95
|
+
tstore(TRANSIENT_STORAGE_SLOT, 0)
|
|
96
|
+
tstore(target, 0)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
|
|
6
|
+
// libraries
|
|
7
|
+
import {Group, Access} from "./IExecutor.sol";
|
|
8
|
+
|
|
9
|
+
// contracts
|
|
10
|
+
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";
|
|
11
|
+
|
|
12
|
+
library GroupLib {
|
|
13
|
+
using Time for Time.Delay;
|
|
14
|
+
using Time for uint32;
|
|
15
|
+
|
|
16
|
+
/// @notice Sets the status of a group.
|
|
17
|
+
/// @param status The status to set.
|
|
18
|
+
function setStatus(Group storage self, bool status) internal {
|
|
19
|
+
self.active = status;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// @notice Sets the expiration of a group.
|
|
23
|
+
/// @param expiration The expiration of the group.
|
|
24
|
+
function setExpiration(Group storage self, uint48 expiration) internal {
|
|
25
|
+
self.expiration = expiration;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// @notice Sets the guardian for a group.
|
|
29
|
+
/// @param guardian The guardian role ID.
|
|
30
|
+
function setGuardian(Group storage self, bytes32 guardian) internal {
|
|
31
|
+
self.guardian = guardian;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// @notice Sets the grant delay for a group.
|
|
35
|
+
/// @param grantDelay The new grant delay.
|
|
36
|
+
/// @param minSetback The minimum setback for the delay.
|
|
37
|
+
function setGrantDelay(Group storage self, uint32 grantDelay, uint32 minSetback) internal {
|
|
38
|
+
(self.grantDelay, ) = self.grantDelay.withUpdate(grantDelay, minSetback);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// @notice Grants access to a group for an account.
|
|
42
|
+
/// @param account The account to grant access to.
|
|
43
|
+
/// @param executionDelay The delay for execution.
|
|
44
|
+
function grantAccess(
|
|
45
|
+
Group storage self,
|
|
46
|
+
address account,
|
|
47
|
+
uint32 grantDelay,
|
|
48
|
+
uint32 executionDelay
|
|
49
|
+
) internal returns (bool newMember, uint48 lastAccess) {
|
|
50
|
+
newMember = self.members[account].lastAccess == 0;
|
|
51
|
+
|
|
52
|
+
if (newMember) {
|
|
53
|
+
lastAccess = Time.timestamp() + grantDelay;
|
|
54
|
+
self.members[account] = Access({
|
|
55
|
+
lastAccess: lastAccess,
|
|
56
|
+
delay: executionDelay.toDelay()
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
// just update the access delay
|
|
60
|
+
(self.members[account].delay, lastAccess) = self.members[account].delay.withUpdate(
|
|
61
|
+
executionDelay,
|
|
62
|
+
0
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// @notice Revokes group access from an account.
|
|
68
|
+
/// @param account The account to revoke access from.
|
|
69
|
+
/// @return revoked True if access was revoked, false otherwise.
|
|
70
|
+
function revokeAccess(Group storage self, address account) internal returns (bool revoked) {
|
|
71
|
+
Access storage access = self.members[account];
|
|
72
|
+
|
|
73
|
+
if (access.lastAccess == 0) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
self.module = address(0);
|
|
78
|
+
self.active = false;
|
|
79
|
+
|
|
80
|
+
// delete the access
|
|
81
|
+
delete self.members[account];
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getAccess(
|
|
86
|
+
Group storage self,
|
|
87
|
+
address account
|
|
88
|
+
)
|
|
89
|
+
internal
|
|
90
|
+
view
|
|
91
|
+
returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect)
|
|
92
|
+
{
|
|
93
|
+
Access storage access = self.members[account];
|
|
94
|
+
since = access.lastAccess;
|
|
95
|
+
(currentDelay, pendingDelay, effect) = access.delay.getFull();
|
|
96
|
+
return (since, currentDelay, pendingDelay, effect);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/// @notice Checks if an account has access to a group.
|
|
100
|
+
/// @param group The group to check.
|
|
101
|
+
/// @param account The account to check.
|
|
102
|
+
/// @return isMember True if the account is a member.
|
|
103
|
+
/// @return executionDelay The execution delay for the account.
|
|
104
|
+
function hasAccess(
|
|
105
|
+
Group storage group,
|
|
106
|
+
address account
|
|
107
|
+
) internal view returns (bool isMember, uint32 executionDelay) {
|
|
108
|
+
Access storage access = group.members[account];
|
|
109
|
+
uint48 since = access.lastAccess;
|
|
110
|
+
(executionDelay, , ) = access.delay.getFull();
|
|
111
|
+
|
|
112
|
+
// Check if member has valid access time
|
|
113
|
+
isMember = since != 0 && since <= Time.timestamp();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/// @notice Gets the guardian for a group.
|
|
117
|
+
/// @return The guardian role ID.
|
|
118
|
+
function getGuardian(Group storage self) internal view returns (bytes32) {
|
|
119
|
+
return self.guardian;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// @notice Gets the grant delay for a group.
|
|
123
|
+
/// @param group The group to check.
|
|
124
|
+
/// @return The grant delay for the group.
|
|
125
|
+
function getGrantDelay(Group storage group) internal view returns (uint32) {
|
|
126
|
+
return group.grantDelay.get();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";
|
|
5
|
+
|
|
6
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
7
|
+
/* STRUCTS */
|
|
8
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
9
|
+
|
|
10
|
+
/// @notice Structure that stores the details for a target contract
|
|
11
|
+
/// @param allowedGroups Mapping of allowed groups for this target
|
|
12
|
+
/// @param disabledFunctions Mapping of disabled functions for this target
|
|
13
|
+
/// @param disabled Whether the target is disabled
|
|
14
|
+
/// @param executionId Execution ID for the target
|
|
15
|
+
struct Target {
|
|
16
|
+
mapping(bytes4 selector => bytes32 groupId) allowedGroups;
|
|
17
|
+
mapping(bytes4 selector => bool disabled) disabledFunctions;
|
|
18
|
+
bool disabled;
|
|
19
|
+
bytes32 executionId;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// @notice Structure that stores the details for an access
|
|
23
|
+
/// @param lastAccess Timepoint at which the user gets the permission
|
|
24
|
+
/// @param delay Delay for execution. Only applies to execute() calls
|
|
25
|
+
struct Access {
|
|
26
|
+
uint48 lastAccess;
|
|
27
|
+
Time.Delay delay;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/// @notice Structure that stores the details for a group
|
|
31
|
+
/// @param module Address of the module that created the group
|
|
32
|
+
/// @param members Mapping of members of the group
|
|
33
|
+
/// @param guardian Guardian Role ID who can cancel operations targeting functions that need this group
|
|
34
|
+
/// @param grantDelay Delay in which the group takes effect after being granted
|
|
35
|
+
/// @param active Whether the group is active
|
|
36
|
+
/// @param expiration Timepoint at which the group becomes inactive
|
|
37
|
+
struct Group {
|
|
38
|
+
address module;
|
|
39
|
+
mapping(address user => Access access) members;
|
|
40
|
+
bytes32 guardian;
|
|
41
|
+
Time.Delay grantDelay;
|
|
42
|
+
bool active;
|
|
43
|
+
uint48 expiration;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// @notice Structure that stores the details for a scheduled operation
|
|
47
|
+
/// @param timepoint Moment at which the operation can be executed
|
|
48
|
+
/// @param nonce Operation nonce to allow third-party contracts to identify the operation
|
|
49
|
+
struct Schedule {
|
|
50
|
+
uint48 timepoint;
|
|
51
|
+
uint32 nonce;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface IExecutorBase {
|
|
55
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
56
|
+
/* ERRORS */
|
|
57
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
58
|
+
error CallerAlreadyRegistered();
|
|
59
|
+
error CallerNotRegistered();
|
|
60
|
+
error ExecutionAlreadyRegistered();
|
|
61
|
+
error ExecutionNotRegistered();
|
|
62
|
+
error ExecutorCallFailed();
|
|
63
|
+
error ExecutionNotFound();
|
|
64
|
+
error UnauthorizedCall();
|
|
65
|
+
error AlreadyScheduled();
|
|
66
|
+
error NotScheduled();
|
|
67
|
+
error NotReady();
|
|
68
|
+
error Expired();
|
|
69
|
+
error UnauthorizedCancel();
|
|
70
|
+
error UnauthorizedRenounce();
|
|
71
|
+
error UnauthorizedTarget();
|
|
72
|
+
error ExecutionFunctionAlreadySet();
|
|
73
|
+
error NullModule();
|
|
74
|
+
error ExecutionHookAlreadySet();
|
|
75
|
+
error ModuleInstallCallbackFailed();
|
|
76
|
+
error InvalidDataLength();
|
|
77
|
+
error InvalidExpiration();
|
|
78
|
+
|
|
79
|
+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
|
|
80
|
+
/* EVENTS */
|
|
81
|
+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
|
|
82
|
+
|
|
83
|
+
event GroupAccessGranted(
|
|
84
|
+
bytes32 indexed groupId,
|
|
85
|
+
address indexed account,
|
|
86
|
+
uint32 delay,
|
|
87
|
+
uint48 since,
|
|
88
|
+
bool newMember
|
|
89
|
+
);
|
|
90
|
+
event GroupAccessRevoked(bytes32 indexed groupId, address indexed account, bool revoked);
|
|
91
|
+
event GroupGuardianSet(bytes32 indexed groupId, bytes32 guardian);
|
|
92
|
+
event GroupGrantDelaySet(bytes32 indexed groupId, uint32 delay);
|
|
93
|
+
event TargetFunctionGroupSet(
|
|
94
|
+
address indexed target,
|
|
95
|
+
bytes4 indexed selector,
|
|
96
|
+
bytes32 indexed groupId
|
|
97
|
+
);
|
|
98
|
+
event TargetFunctionDelaySet(address indexed target, uint32 newDelay, uint32 minSetback);
|
|
99
|
+
event TargetFunctionDisabledSet(address indexed target, bytes4 indexed selector, bool disabled);
|
|
100
|
+
event TargetDisabledSet(address indexed target, bool disabled);
|
|
101
|
+
event OperationScheduled(bytes32 indexed operationId, uint48 timepoint, uint32 nonce);
|
|
102
|
+
event OperationExecuted(bytes32 indexed operationId, uint32 nonce);
|
|
103
|
+
event OperationCanceled(bytes32 indexed operationId, uint32 nonce);
|
|
104
|
+
event GroupStatusSet(bytes32 indexed groupId, bool active);
|
|
105
|
+
event GroupExpirationSet(bytes32 indexed groupId, uint48 expiration);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface IExecutor is IExecutorBase {
|
|
109
|
+
/**
|
|
110
|
+
* @notice Grants access to a group for an account with a delay
|
|
111
|
+
* @param groupId The group ID
|
|
112
|
+
* @param account The account to grant access to
|
|
113
|
+
* @param delay The delay for the access to be effective
|
|
114
|
+
* @return newMember Whether the account is a new member of the group
|
|
115
|
+
*/
|
|
116
|
+
function grantAccess(
|
|
117
|
+
bytes32 groupId,
|
|
118
|
+
address account,
|
|
119
|
+
uint32 delay
|
|
120
|
+
) external returns (bool newMember);
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @notice Grants access to a group for an account with a delay and expiration
|
|
124
|
+
* @param groupId The group ID
|
|
125
|
+
* @param account The account to grant access to
|
|
126
|
+
* @param delay The delay for the access to be effective
|
|
127
|
+
* @param expiration The expiration timepoint for the access
|
|
128
|
+
* @return newMember Whether the account is a new member of the group
|
|
129
|
+
*/
|
|
130
|
+
function grantAccessWithExpiration(
|
|
131
|
+
bytes32 groupId,
|
|
132
|
+
address account,
|
|
133
|
+
uint32 delay,
|
|
134
|
+
uint48 expiration
|
|
135
|
+
) external returns (bool newMember);
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @notice Revokes access to a group for an account
|
|
139
|
+
* @param groupId The group ID
|
|
140
|
+
* @param account The account to revoke access from
|
|
141
|
+
*/
|
|
142
|
+
function revokeAccess(bytes32 groupId, address account) external;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @notice Renounces access to a group for an account
|
|
146
|
+
* @param groupId The group ID
|
|
147
|
+
* @param account The account to renounce access from
|
|
148
|
+
*/
|
|
149
|
+
function renounceAccess(bytes32 groupId, address account) external;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @notice Sets the guardian role for a group
|
|
153
|
+
* @param groupId The group ID
|
|
154
|
+
* @param guardian The guardian role ID
|
|
155
|
+
*/
|
|
156
|
+
function setGuardian(bytes32 groupId, bytes32 guardian) external;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @notice Sets the grant delay for a group
|
|
160
|
+
* @param groupId The group ID
|
|
161
|
+
* @param delay The delay for granting access
|
|
162
|
+
*/
|
|
163
|
+
function setGroupDelay(bytes32 groupId, uint32 delay) external;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @notice Sets the expiration for a group
|
|
167
|
+
* @param groupId The group ID
|
|
168
|
+
* @param expiration The expiration timestamp
|
|
169
|
+
*/
|
|
170
|
+
function setGroupExpiration(bytes32 groupId, uint48 expiration) external;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @notice Sets the group ID for a target function
|
|
174
|
+
* @param target The target contract address
|
|
175
|
+
* @param selector The function selector
|
|
176
|
+
* @param groupId The group ID
|
|
177
|
+
*/
|
|
178
|
+
function setTargetFunctionGroup(address target, bytes4 selector, bytes32 groupId) external;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @notice Disables or enables a target contract
|
|
182
|
+
* @param target The target contract address
|
|
183
|
+
* @param disabled Whether the target should be disabled
|
|
184
|
+
*/
|
|
185
|
+
function setTargetDisabled(address target, bool disabled) external;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @notice Schedules an operation for future execution
|
|
189
|
+
* @param target The target contract address
|
|
190
|
+
* @param data The calldata for the operation
|
|
191
|
+
* @param when The timestamp when the operation can be executed
|
|
192
|
+
* @return operationId The unique identifier for the operation
|
|
193
|
+
* @return nonce The operation nonce
|
|
194
|
+
*/
|
|
195
|
+
function scheduleOperation(
|
|
196
|
+
address target,
|
|
197
|
+
bytes calldata data,
|
|
198
|
+
uint48 when
|
|
199
|
+
) external payable returns (bytes32 operationId, uint32 nonce);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @notice Executes an operation immediately or after delay
|
|
203
|
+
* @param target The target contract address
|
|
204
|
+
* @param value The value for the operation
|
|
205
|
+
* @param data The calldata for the operation
|
|
206
|
+
* @return nonce The operation nonce if scheduled, 0 if immediate
|
|
207
|
+
*/
|
|
208
|
+
function execute(
|
|
209
|
+
address target,
|
|
210
|
+
uint256 value,
|
|
211
|
+
bytes calldata data
|
|
212
|
+
) external payable returns (uint32 nonce);
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @notice Cancels a scheduled operation
|
|
216
|
+
* @param caller The account that scheduled the operation
|
|
217
|
+
* @param target The target contract address
|
|
218
|
+
* @param data The calldata for the operation
|
|
219
|
+
* @return nonce The operation nonce
|
|
220
|
+
*/
|
|
221
|
+
function cancel(
|
|
222
|
+
address caller,
|
|
223
|
+
address target,
|
|
224
|
+
bytes calldata data
|
|
225
|
+
) external returns (uint32 nonce);
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @notice Checks if an account has access to a group
|
|
229
|
+
* @param groupId The group ID
|
|
230
|
+
* @param account The account to check access for
|
|
231
|
+
* @return isMember Whether the account is a member of the group
|
|
232
|
+
* @return executionDelay The delay for the access to be effective
|
|
233
|
+
* @return active Whether the group is active
|
|
234
|
+
*/
|
|
235
|
+
function hasAccess(
|
|
236
|
+
bytes32 groupId,
|
|
237
|
+
address account
|
|
238
|
+
) external view returns (bool isMember, uint32 executionDelay, bool active);
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @notice Gets the access information for an account in a group
|
|
242
|
+
* @param groupId The group ID
|
|
243
|
+
* @param account The account to get access information for
|
|
244
|
+
* @return since The timestamp when the access was granted
|
|
245
|
+
* @return currentDelay The current delay for the access
|
|
246
|
+
* @return pendingDelay The pending delay for the access
|
|
247
|
+
* @return effect The effect of the access
|
|
248
|
+
*/
|
|
249
|
+
function getAccess(
|
|
250
|
+
bytes32 groupId,
|
|
251
|
+
address account
|
|
252
|
+
) external view returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @notice Gets the grant delay for a group
|
|
256
|
+
* @param groupId The group ID
|
|
257
|
+
* @return The grant delay
|
|
258
|
+
*/
|
|
259
|
+
function getGroupDelay(bytes32 groupId) external view returns (uint32);
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @notice Gets the scheduled timepoint for an operation
|
|
263
|
+
* @param id The operation ID
|
|
264
|
+
* @return The scheduled timepoint, or 0 if not scheduled or expired
|
|
265
|
+
*/
|
|
266
|
+
function getScheduleTimepoint(bytes32 id) external view returns (uint48);
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @notice Checks if a target is currently executing
|
|
270
|
+
* @param target The target contract address
|
|
271
|
+
* @return True if the target is currently executing
|
|
272
|
+
*/
|
|
273
|
+
function onExecution(address target) external view returns (bool);
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @notice Hashes an operation
|
|
277
|
+
* @param caller The caller address
|
|
278
|
+
* @param target The target contract address
|
|
279
|
+
* @param data The calldata for the operation
|
|
280
|
+
* @return The hash of the operation
|
|
281
|
+
*/
|
|
282
|
+
function hashOperation(
|
|
283
|
+
address caller,
|
|
284
|
+
address target,
|
|
285
|
+
bytes calldata data
|
|
286
|
+
) external pure returns (bytes32);
|
|
287
|
+
}
|