2022-10-08 13:52:49 +03:00
|
|
|
from django.db.models.signals import pre_save, post_save
|
|
|
|
from django.dispatch import receiver
|
|
|
|
|
2022-10-09 04:33:12 +03:00
|
|
|
from conf import settings
|
2022-10-08 13:52:49 +03:00
|
|
|
from users.models import User
|
2022-10-09 04:33:12 +03:00
|
|
|
from utils.blockchain import create_wallet, send_matic
|
2022-10-08 13:52:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
@receiver(post_save, sender=User)
|
|
|
|
def process_user(sender, instance, created, **kwargs):
|
|
|
|
if created:
|
|
|
|
instance.set_password(instance.password)
|
2022-10-09 00:42:30 +03:00
|
|
|
|
|
|
|
wallet = create_wallet()
|
2022-10-09 04:33:12 +03:00
|
|
|
send_matic(settings.MAIN_WALLET, wallet.publicKey, 0.1)
|
2022-10-09 00:42:30 +03:00
|
|
|
|
|
|
|
instance.wallet_public_key = wallet.publicKey
|
|
|
|
instance.wallet_private_key = wallet.privateKey
|
2022-10-08 13:52:49 +03:00
|
|
|
instance.save()
|