-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prizetap: add optimism donation constraint
- Loading branch information
1 parent
1f07489
commit 3b92067
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from core.constraints import * | ||
from .models import DonationReceipt, Chain, ClaimReceipt | ||
|
||
class DonationConstraint(ConstraintVerification): | ||
_param_keys = [ | ||
ConstraintParam.CHAIN | ||
] | ||
|
||
def is_observed(self, *args, **kwargs): | ||
chain_pk = self._param_values[ConstraintParam.CHAIN] | ||
return DonationReceipt.objects\ | ||
.filter(chain__pk=chain_pk)\ | ||
.filter(user_profile = self.user_profile)\ | ||
.filter(status=ClaimReceipt.PROCESSED_FOR_TOKENTAP)\ | ||
.exists() | ||
|
||
class OptimismDonationConstraint(DonationConstraint): | ||
_param_keys = [] | ||
|
||
def is_observed(self, *args, **kwargs): | ||
try: | ||
chain = Chain.objects.get(chain_id=10) | ||
except: | ||
return False | ||
self._param_values[ConstraintParam.CHAIN] = chain.pk | ||
return super().is_observed(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.0.4 on 2023-10-07 08:33 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('prizetap', '0029_constraint_icon_url'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='constraint', | ||
name='name', | ||
field=models.CharField(choices=[('BrightIDMeetVerification', 'BrightIDMeetVerification'), ('BrightIDAuraVerification', 'BrightIDAuraVerification'), ('HaveUnitapPass', 'HaveUnitapPass'), ('NotHaveUnitapPass', 'NotHaveUnitapPass'), ('OptimismDonationConstraint', 'OptimismDonationConstraint')], max_length=255, unique=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters