Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/UnitapApp/unitap-backend
Browse files Browse the repository at this point in the history
…into fix/weekly_round
  • Loading branch information
Mohamad Bastin committed Dec 16, 2023
2 parents 13726d0 + 159ea0c commit 008004f
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 121 deletions.
128 changes: 64 additions & 64 deletions core/migrations/0005_auto_20231203_0832.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,68 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunSQL("""
INSERT INTO core_walletaccount (
id,
name,
private_key,
network_type
)
SELECT
id,
name,
private_key,
network_type
FROM
faucet_walletaccount;
INSERT INTO core_chain (
id,
chain_name,
symbol,
chain_id,
rpc_url,
decimals,
explorer_url,
logo_url,
native_currency_name,
poa,
rpc_url_private,
wallet_id,
modal_url,
max_gas_price,
gas_multiplier,
chain_type,
is_testnet,
is_active,
enough_fee_multiplier,
explorer_api_key,
explorer_api_url
)
SELECT
id,
chain_name,
symbol,
chain_id,
rpc_url,
decimals,
explorer_url,
logo_url,
native_currency_name,
poa,
rpc_url_private,
wallet_id,
modal_url,
max_gas_price,
gas_multiplier,
chain_type,
is_testnet,
is_active,
enough_fee_multiplier,
explorer_api_key,
explorer_api_url
FROM
faucet_chain;
SELECT setval(pg_get_serial_sequence('"core_walletaccount"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "core_walletaccount";
SELECT setval(pg_get_serial_sequence('"core_chain"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "core_chain";
""", reverse_sql="")
# migrations.RunSQL("""
# INSERT INTO core_walletaccount (
# id,
# name,
# private_key,
# network_type
# )
# SELECT
# id,
# name,
# private_key,
# network_type
# FROM
# faucet_walletaccount;
# INSERT INTO core_chain (
# id,
# chain_name,
# symbol,
# chain_id,
# rpc_url,
# decimals,
# explorer_url,
# logo_url,
# native_currency_name,
# poa,
# rpc_url_private,
# wallet_id,
# modal_url,
# max_gas_price,
# gas_multiplier,
# chain_type,
# is_testnet,
# is_active,
# enough_fee_multiplier,
# explorer_api_key,
# explorer_api_url
# )
# SELECT
# id,
# chain_name,
# symbol,
# chain_id,
# rpc_url,
# decimals,
# explorer_url,
# logo_url,
# native_currency_name,
# poa,
# rpc_url_private,
# wallet_id,
# modal_url,
# max_gas_price,
# gas_multiplier,
# chain_type,
# is_testnet,
# is_active,
# enough_fee_multiplier,
# explorer_api_key,
# explorer_api_url
# FROM
# faucet_chain;
# SELECT setval(pg_get_serial_sequence('"core_walletaccount"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "core_walletaccount";
# SELECT setval(pg_get_serial_sequence('"core_chain"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "core_chain";
# """, reverse_sql="")
]
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 008004f

Please sign in to comment.