From 9435209db42cdc23d4238d57dadd108e93262a54 Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Mon, 16 Sep 2024 20:56:39 +0330 Subject: [PATCH 1/2] fixed arguments issue --- core/constraints/arbitrum.py | 9 --------- core/constraints/ens.py | 3 --- core/constraints/farcaster.py | 21 --------------------- core/constraints/general.py | 12 ------------ core/constraints/gitcoin_passport.py | 9 --------- core/constraints/lens.py | 21 --------------------- core/constraints/muon_node.py | 4 ++-- core/constraints/octant.py | 3 --- core/constraints/optimism.py | 6 ------ core/constraints/twitter.py | 17 +---------------- 10 files changed, 3 insertions(+), 102 deletions(-) diff --git a/core/constraints/arbitrum.py b/core/constraints/arbitrum.py index bc802223..c9c17142 100644 --- a/core/constraints/arbitrum.py +++ b/core/constraints/arbitrum.py @@ -14,9 +14,6 @@ class BridgeEthToArb(ConstraintVerification): app_name = ConstraintApp.ARBITRUM.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: try: return self.has_bridged( @@ -107,9 +104,6 @@ class DelegateArb(ConstraintVerification): ] ARB_TOKEN_CONTRACT = "0x912CE59144191C1204E64559FE8253a0e49E6548" - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from core.models import Chain @@ -146,6 +140,3 @@ class DidDelegateArbToAddress(DelegateArb): ConstraintParam.ADDRESS, ConstraintParam.MINIMUM, ) - - def __init__(self, user_profile) -> None: - super().__init__(user_profile) diff --git a/core/constraints/ens.py b/core/constraints/ens.py index cd160929..bb26c57e 100644 --- a/core/constraints/ens.py +++ b/core/constraints/ens.py @@ -5,9 +5,6 @@ class HasENSVerification(ConstraintVerification): _param_keys = [] app_name = ConstraintApp.ENS.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import ENSConnection diff --git a/core/constraints/farcaster.py b/core/constraints/farcaster.py index 0dd88ebd..fe811fd2 100644 --- a/core/constraints/farcaster.py +++ b/core/constraints/farcaster.py @@ -12,9 +12,6 @@ class HasFarcasterProfile(ConstraintVerification): _param_keys = [] app_name = ConstraintApp.FARCASTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import FarcasterConnection @@ -30,9 +27,6 @@ class IsFollowingFarcasterUser(ConstraintVerification): _param_keys = [ConstraintParam.FARCASTER_FID] app_name = ConstraintApp.FARCASTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import FarcasterConnection @@ -74,9 +68,6 @@ class DidLikedFarcasterCast(ConstraintVerification): _param_keys = [ConstraintParam.FARCASTER_CAST_HASH] app_name = ConstraintApp.FARCASTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import FarcasterConnection @@ -98,9 +89,6 @@ class DidRecastFarcasterCast(ConstraintVerification): _param_keys = [ConstraintParam.FARCASTER_CAST_HASH] app_name = ConstraintApp.FARCASTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import FarcasterConnection @@ -122,9 +110,6 @@ class HasMinimumFarcasterFollower(ConstraintVerification): _param_keys = [ConstraintParam.MINIMUM] app_name = ConstraintApp.FARCASTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import FarcasterConnection @@ -148,9 +133,6 @@ class IsFollowingFarcasterChannel(ConstraintVerification): _param_keys = [ConstraintParam.FARCASTER_CHANNEL_ID] app_name = ConstraintApp.FARCASTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import FarcasterConnection @@ -173,9 +155,6 @@ class IsFollowingFarcasterBatch(ConstraintVerification): _param_keys = [ConstraintParam.FARCASTER_FIDS] app_name = ConstraintApp.FARCASTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def get_info(self, *args, **kwargs) -> dict: from authentication.models import FarcasterConnection diff --git a/core/constraints/general.py b/core/constraints/general.py index 959c22f6..249c07f2 100644 --- a/core/constraints/general.py +++ b/core/constraints/general.py @@ -15,9 +15,6 @@ class HasNFTVerification(ConstraintVerification): ConstraintParam.MINIMUM, ] - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs): from core.models import Chain @@ -49,9 +46,6 @@ class ABCTokenVerification(ConstraintVerification, ABC): ConstraintParam.MINIMUM, ] - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - @abstractmethod def get_amount( self, user_address: str, token_address: str, token_client: TokenClient @@ -88,9 +82,6 @@ def is_observed(self, *args, **kwargs): class HasTokenVerification(ABCTokenVerification): - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def get_amount( self, user_address: str, token_address: None | str, token_client: TokenClient ) -> int: @@ -117,9 +108,6 @@ def get_amount( class AllowListVerification(ConstraintVerification): _param_keys = [ConstraintParam.CSV_FILE] - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs): file_path = self.param_values[ConstraintParam.CSV_FILE.name] self.allow_list = [] diff --git a/core/constraints/gitcoin_passport.py b/core/constraints/gitcoin_passport.py index 0c452460..89d72b60 100644 --- a/core/constraints/gitcoin_passport.py +++ b/core/constraints/gitcoin_passport.py @@ -15,9 +15,6 @@ class HasGitcoinPassportProfile(ConstraintVerification): _param_keys = [] app_name = ConstraintApp.GITCOIN_PASSPORT.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import GitcoinPassportConnection @@ -37,9 +34,6 @@ class HasMinimumHumanityScore(ConstraintVerification): _param_keys = [ConstraintParam.MINIMUM] app_name = ConstraintApp.GITCOIN_PASSPORT.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import GitcoinPassportConnection @@ -72,9 +66,6 @@ class HasDonatedOnGitcoin(ConstraintVerification): app_name = ConstraintApp.GITCOIN_PASSPORT.value _graph_url = "https://grants-stack-indexer-v2.gitcoin.co" - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: try: return self.has_donated( diff --git a/core/constraints/lens.py b/core/constraints/lens.py index 28a2e6e3..4c017c14 100644 --- a/core/constraints/lens.py +++ b/core/constraints/lens.py @@ -12,9 +12,6 @@ class HasLensProfile(ConstraintVerification): _param_keys = [] app_name = ConstraintApp.LENS.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import LensConnection @@ -31,9 +28,6 @@ class IsFollowingLensUser(ConstraintVerification): _param_keys = [ConstraintParam.LENS_PROFILE_ID] app_name = ConstraintApp.LENS.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import LensConnection @@ -51,9 +45,6 @@ class BeFollowedByLensUser(ConstraintVerification): _param_keys = [ConstraintParam.LENS_PROFILE_ID] app_name = ConstraintApp.LENS.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import LensConnection @@ -73,9 +64,6 @@ class DidMirrorOnLensPublication(ConstraintVerification): _param_keys = [ConstraintParam.LENS_PUBLICATION_ID] app_name = ConstraintApp.LENS.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import LensConnection @@ -97,9 +85,6 @@ class DidCollectLensPublication(ConstraintVerification): _param_keys = [ConstraintParam.LENS_PUBLICATION_ID] app_name = ConstraintApp.LENS.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import LensConnection @@ -122,9 +107,6 @@ class HasMinimumLensFollower(ConstraintVerification): _param_keys = [ConstraintParam.MINIMUM] app_name = ConstraintApp.LENS.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import LensConnection @@ -148,9 +130,6 @@ class HasMinimumLensPost(ConstraintVerification): _param_keys = [ConstraintParam.MINIMUM] app_name = ConstraintApp.LENS.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import LensConnection diff --git a/core/constraints/muon_node.py b/core/constraints/muon_node.py index 4ac8d0d9..ccea9d5c 100644 --- a/core/constraints/muon_node.py +++ b/core/constraints/muon_node.py @@ -51,10 +51,10 @@ class HasMuonNode(ConstraintVerification): CHAIN_ID = 56 CONTRACT_ADDR = "0x6eA3096eB0fAf5c1DEb970DCd29A6b10a48DaD83" - def __init__(self, user_profile) -> None: + def __init__(self, user_profile, *, obj=None) -> None: from core.models import Chain - super().__init__(user_profile) + super().__init__(user_profile, obj=obj) self.chain = Chain.objects.get(chain_id=HasMuonNode.CHAIN_ID) self.web3_utils = Web3Utils(self.chain.rpc_url_private, self.chain.poa) self.web3_utils.set_contract(HasMuonNode.CONTRACT_ADDR, MUON_NODE_MANAGER_ABI) diff --git a/core/constraints/octant.py b/core/constraints/octant.py index 15b1af78..00599dc3 100644 --- a/core/constraints/octant.py +++ b/core/constraints/octant.py @@ -17,9 +17,6 @@ class GLMStakingVerification(ConstraintVerification): ] GLM_CONTRACT_ADDRESS = "0x879133Fd79b7F48CE1c368b0fCA9ea168eaF117c" - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs): from core.models import Chain diff --git a/core/constraints/optimism.py b/core/constraints/optimism.py index fe4a1c1f..be182a08 100644 --- a/core/constraints/optimism.py +++ b/core/constraints/optimism.py @@ -35,9 +35,6 @@ class DelegateOP(ConstraintVerification): ] OP_TOKEN_CONTRACT = "0x4200000000000000000000000000000000000042" - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from core.models import Chain @@ -74,6 +71,3 @@ class DidDelegateOPToAddress(ConstraintVerification): ConstraintParam.MINIMUM, ConstraintParam.ADDRESS, ) - - def __init__(self, user_profile) -> None: - super().__init__(user_profile) diff --git a/core/constraints/twitter.py b/core/constraints/twitter.py index 6211800e..28cd3dd0 100644 --- a/core/constraints/twitter.py +++ b/core/constraints/twitter.py @@ -116,13 +116,10 @@ def is_observed(self, *args, **kwargs) -> bool: return False -class IsFollowinTwitterUser(ConstraintVerification): +class IsFollowingTwitterUser(ConstraintVerification): _param_keys = [ConstraintParam.TWITTER_USERNAME] app_name = ConstraintApp.TWITTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import TwitterConnection @@ -146,9 +143,6 @@ class BeFollowedByTwitterUser(ConstraintVerification): _param_keys = [ConstraintParam.TWITTER_USERNAME] app_name = ConstraintApp.TWITTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import TwitterConnection @@ -174,9 +168,6 @@ class DidRetweetTweet(ConstraintVerification): _param_keys = [ConstraintParam.TWEET_ID] app_name = ConstraintApp.TWITTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import TwitterConnection @@ -196,9 +187,6 @@ class DidQuoteTweet(ConstraintVerification): _param_keys = [ConstraintParam.TWEET_ID] app_name = ConstraintApp.TWITTER.value - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def is_observed(self, *args, **kwargs) -> bool: from authentication.models import TwitterConnection @@ -218,9 +206,6 @@ class IsFollowingTwitterBatch(ConstraintVerification): app_name = ConstraintApp.TWITTER.value _param_keys = [ConstraintParam.TWITTER_IDS] - def __init__(self, user_profile) -> None: - super().__init__(user_profile) - def get_info(self, *args, **kwargs) -> None | dict: from authentication.models import TwitterConnection From 5b1ef4e4620bfc12492a8c1820011cfc60ab377c Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Mon, 16 Sep 2024 17:39:36 +0000 Subject: [PATCH 2/2] fixed typo name --- core/constraints/__init__.py | 2 +- core/models.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/constraints/__init__.py b/core/constraints/__init__.py index 74decfe9..4c6b0f83 100644 --- a/core/constraints/__init__.py +++ b/core/constraints/__init__.py @@ -62,7 +62,7 @@ HasTwitter, HasVoteOnATweet, IsFollowingTwitterBatch, - IsFollowinTwitterUser, + IsFollowingTwitterUser, ) from core.constraints.zora import DidMintZoraNFT diff --git a/core/models.py b/core/models.py index dea31cb8..744534f8 100644 --- a/core/models.py +++ b/core/models.py @@ -53,7 +53,7 @@ IsFollowingFarcasterUser, IsFollowingLensUser, IsFollowingTwitterBatch, - IsFollowinTwitterUser, + IsFollowingTwitterUser, ) from .utils import SolanaWeb3Utils, Web3Utils @@ -146,7 +146,7 @@ class Type(models.TextChoices): HasGitcoinPassportProfile, IsFollowingFarcasterChannel, BridgeEthToArb, - IsFollowinTwitterUser, + IsFollowingTwitterUser, BeFollowedByTwitterUser, DidRetweetTweet, DidQuoteTweet,