示例#1
0
 def response_change(self, request, obj):
     from django.shortcuts import redirect
     if "_reject_kudos" in request.POST:
         from marketing.mails import notify_kudos_rejected
         notify_kudos_rejected(obj)
         self.message_user(request, f"Notified user of rejection")
         return redirect(
             '/_administrationkudos/tokenrequest/?approved=f&rejection_reason='
         )
     if "_change_owner" in request.POST or request.POST.get(
             '_change_owner_mint_kudos', False):
         obj.to_address = '0x6239FF1040E412491557a7a02b2CBcC5aE85dc8F'
         obj.save()
         self.message_user(request, f"Changed owner to gitcoin")
     if "_mint_kudos" in request.POST or request.POST.get(
             '_change_owner_mint_kudos', False):
         from kudos.tasks import mint_token_request
         try:
             obj.rejection_reason = 'n/a'
             obj.save()
             mint_token_request(obj.id, num_sync=1)
             self.message_user(request, f"Mint/sync submitted to chain")
         except Exception as e:
             self.message_user(request, str(e))
         return redirect(
             '/_administrationkudos/tokenrequest/?approved=f&rejection_reason='
         )
     if "_do_sync_kudos" in request.POST:
         from kudos.management.commands.mint_all_kudos import sync_latest
         num_sync = int(request.POST.get('num_sync', 5))
         for i in range(0, num_sync):
             sync_latest(i, network=obj.network)
         self.message_user(request, f"Sync'c Kudos")
         return redirect('/kudos/marketplace')
     return redirect(obj.admin_url)
示例#2
0
def mint_token_request(self, token_req_id, send_notif_email=True, retry=False):
    """
    :param self:
    :param token_req_id:
    :return:
    """
    with redis.lock("tasks:all_kudos_requests", timeout=LOCK_TIMEOUT):
        with redis.lock("tasks:token_req_id:%s" % token_req_id,
                        timeout=LOCK_TIMEOUT):
            from kudos.management.commands.mint_all_kudos import sync_latest
            from gas.utils import recommend_min_gas_price_to_confirm_in_time
            from dashboard.utils import has_tx_mined
            obj = TokenRequest.objects.get(pk=token_req_id)
            multiplier = 1
            gas_price = int(
                float(recommend_min_gas_price_to_confirm_in_time(1)) *
                multiplier)
            if gas_price > delay_if_gas_prices_gt_mint and self.request.retries < self.max_retries:
                self.retry(countdown=120)
                return
            if obj.gas_price_overide:
                gas_price = obj.gas_price_overide
            tx_id = obj.mint(gas_price)
            if tx_id:
                while not has_tx_mined(tx_id, obj.network):
                    time.sleep(1)
                for i in range(0, 5):
                    sync_latest(i, network=obj.network)
                if send_notif_email:
                    notify_kudos_minted(obj)
            else:
                self.retry(countdown=(30 * (self.request.retries + 1)))
示例#3
0
文件: tasks.py 项目: inspireme6/web
def mint_token_request(self, token_req_id, retry=False):
    """
    :param self:
    :param token_req_id:
    :return:
    """
    with redis.lock("tasks:all_kudos_requests", timeout=LOCK_TIMEOUT):
        with redis.lock("tasks:token_req_id:%s" % token_req_id,
                        timeout=LOCK_TIMEOUT):
            from kudos.management.commands.mint_all_kudos import sync_latest
            from gas.utils import recommend_min_gas_price_to_confirm_in_time
            from dashboard.utils import has_tx_mined
            obj = TokenRequest.objects.get(pk=token_req_id)
            multiplier = 1 if not retry else (
                mint_token_request.request.retries + 1)
            gas_price = int(
                float(recommend_min_gas_price_to_confirm_in_time(1)) *
                multiplier)
            tx_id = obj.mint(gas_price)
            if tx_id:
                while not has_tx_mined(tx_id, obj.network):
                    time.sleep(1)
                sync_latest(0)
                sync_latest(1)
                sync_latest(2)
                sync_latest(3)
            else:
                self.retry(30)
示例#4
0
 def response_change(self, request, obj):
     if "_mint_kudos" in request.POST:
         tx_id = obj.mint()
         self.message_user(
             request,
             f"Mint submitted to chain: tx {tx_id}.  Once this tx clears pls 'sync kudos'."
         )
     if "_sync_kudos" in request.POST:
         from kudos.management.commands.mint_all_kudos import sync_latest
         sync_latest(0)
         sync_latest(1)
         sync_latest(2)
         sync_latest(3)
         self.message_user(
             request,
             f"Synced latest 3 kudos from open sea.  If there is a new kudos on chain it will appear in the marketplace"
         )
     return super().response_change(request, obj)
示例#5
0
文件: tasks.py 项目: protofire/web
def mint_token_request(self, token_req_id, retry=False):
    """
    :param self:
    :param token_req_id:
    :return:
    """
    with redis.lock("tasks:token_req_id:%s" % token_req_id,
                    timeout=LOCK_TIMEOUT):
        from kudos.management.commands.mint_all_kudos import sync_latest
        from dashboard.utils import has_tx_mined
        obj = TokenRequest.objects.get(pk=token_req_id)
        tx_id = obj.mint()
        if tx_id:
            while not has_tx_mined(tx_id, obj.network):
                time.sleep(1)
            sync_latest(0)
            sync_latest(1)
            sync_latest(2)
            sync_latest(3)
        else:
            self.retry(30)
示例#6
0
    def response_change(self, request, obj):

        if "_mint_kudos" in request.POST:
            tx_id = obj.mint()
            self.message_user(
                request,
                f"Mint submitted to chain: tx {tx_id}.  Once this tx clears pls 'sync kudos'."
            )
        if "_change_owner" in request.POST:
            obj.to_address = '0x6239FF1040E412491557a7a02b2CBcC5aE85dc8F'
            obj.save()
            self.message_user(request, f"Changed owner to gitcoin")
        if "_sync_kudos" in request.POST:
            from kudos.management.commands.mint_all_kudos import sync_latest
            sync_latest(0)
            sync_latest(1)
            sync_latest(2)
            sync_latest(3)
            self.message_user(
                request,
                f"Synced latest 3 kudos from open sea.  If there is a new kudos on chain it will appear in the marketplace"
            )
        return super().response_change(request, obj)
示例#7
0
# note: only use this if the admin is failling

token_req_id = 2235

import time

from dashboard.utils import has_tx_mined
from gas.utils import recommend_min_gas_price_to_confirm_in_time
from kudos.management.commands.mint_all_kudos import sync_latest
from kudos.models import TokenRequest
from marketing.mails import notify_kudos_minted

obj = TokenRequest.objects.get(pk=token_req_id)
multiplier = 1
gas_price = int(
    float(recommend_min_gas_price_to_confirm_in_time(1)) * multiplier)
tx_id = obj.mint(gas_price)
while not has_tx_mined(tx_id, obj.network):
    time.sleep(1)
for i in range(0, 9):
    sync_latest(i, obj.network)
notify_kudos_minted(obj)
# note: only use this if the admin is failling

token_req_id = 314

import time

from dashboard.utils import has_tx_mined
from gas.utils import recommend_min_gas_price_to_confirm_in_time
from kudos.management.commands.mint_all_kudos import sync_latest
from kudos.models import TokenRequest
from marketing.mails import notify_kudos_minted

obj = TokenRequest.objects.get(pk=token_req_id)
multiplier = 1
gas_price = int(float(recommend_min_gas_price_to_confirm_in_time(1)) * multiplier)
tx_id = obj.mint(gas_price)
while not has_tx_mined(tx_id, obj.network):
    time.sleep(1)
sync_latest(0)
sync_latest(1)
sync_latest(2)
sync_latest(3)
notify_kudos_minted(obj)