Skip to content

Commit

Permalink
Merge pull request #217 from UnitapApp/refactor/relocate-chain-configs
Browse files Browse the repository at this point in the history
Refactor/relocate chain configs
  • Loading branch information
ShayanShiravani authored Dec 13, 2023
2 parents f5ca265 + a763c8f commit c2d2780
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 57 deletions.
10 changes: 8 additions & 2 deletions tokenTap/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from web3 import Account, Web3

from authentication.models import NetworkTypes
from core.models import WalletAccount
from faucet.faucet_manager.credit_strategy import RoundCreditStrategy
from faucet.models import GlobalSettings, WalletAccount
from faucet.models import GlobalSettings

from .models import TokenDistributionClaim

Expand All @@ -23,7 +24,12 @@ def create_uint32_random_nonce():
def hash_message(user, token, amount, nonce):
message_hash = Web3().solidity_keccak(
["address", "address", "uint256", "uint32"],
[Web3.to_checksum_address(user), Web3.to_checksum_address(token), amount, nonce],
[
Web3.to_checksum_address(user),
Web3.to_checksum_address(token),
amount,
nonce,
],
)
hashed_message = encode_defunct(hexstr=message_hash.hex())

Expand Down
18 changes: 18 additions & 0 deletions tokenTap/migrations/0024_tokendistribution_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2023-12-11 07:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('tokenTap', '0023_alter_tokendistribution_chain'),
]

operations = [
migrations.AddField(
model_name='tokendistribution',
name='contract',
field=models.CharField(blank=True, max_length=255, null=True),
),
]
1 change: 1 addition & 0 deletions tokenTap/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class TokenDistribution(models.Model):
chain = models.ForeignKey(
Chain, on_delete=models.CASCADE, related_name="token_distribution"
)
contract = models.CharField(max_length=255, null=True, blank=True)

permissions = models.ManyToManyField(Constraint, blank=True)

Expand Down
9 changes: 5 additions & 4 deletions tokenTap/serializers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from rest_framework import serializers

from core.constraints import ConstraintVerification, get_constraint
from core.serializers import UserConstraintBaseSerializer
from faucet.serializers import SmallChainSerializer
from core.serializers import ChainSerializer, UserConstraintBaseSerializer
from tokenTap.models import (
Constraint,
TokenDistribution,
Expand Down Expand Up @@ -32,7 +31,7 @@ def update(self, instance, validated_data):


class TokenDistributionSerializer(serializers.ModelSerializer):
chain = SmallChainSerializer()
chain = ChainSerializer()
permissions = ConstraintSerializer(many=True)

class Meta:
Expand All @@ -50,6 +49,7 @@ class Meta:
"token_address",
"amount",
"chain",
"contract",
"permissions",
"created_at",
"deadline",
Expand All @@ -64,7 +64,7 @@ class Meta:


class SmallTokenDistributionSerializer(serializers.ModelSerializer):
chain = SmallChainSerializer()
chain = ChainSerializer()
permissions = ConstraintSerializer(many=True)

class Meta:
Expand All @@ -81,6 +81,7 @@ class Meta:
"token_address",
"amount",
"chain",
"contract",
"permissions",
"created_at",
"deadline",
Expand Down
Loading

0 comments on commit c2d2780

Please sign in to comment.