Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
danlipert committed Apr 2, 2020
2 parents 850bd78 + 6652c0a commit ab2b029
Show file tree
Hide file tree
Showing 16 changed files with 14,423 additions and 25 deletions.
11,546 changes: 11,546 additions & 0 deletions app/assets/v2/images/avatar3d/chappie2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,768 changes: 2,768 additions & 0 deletions app/assets/v2/images/avatar3d/walle3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions app/avatar/views_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ def get_avatar_attrs(theme, key):
'tone_maps': [],
'path': 'assets/v2/images/avatar3d/walle2.svg',
},
'walle3': {
'preview_viewbox': {
'background': '0 0 350 350',
},
'hair_tones': [],
'skin_tones': [],
'tone_maps': [],
'path': 'assets/v2/images/avatar3d/walle3.svg',
},
'chappie': {
'preview_viewbox': {
'background': '0 0 350 350',
Expand All @@ -432,6 +441,15 @@ def get_avatar_attrs(theme, key):
'tone_maps': [],
'path': 'assets/v2/images/avatar3d/chappie.svg',
},
'chappie2': {
'preview_viewbox': {
'background': '0 0 350 350',
},
'hair_tones': [],
'skin_tones': [],
'tone_maps': [],
'path': 'assets/v2/images/avatar3d/chappie2.svg',
},
'megaman2': {
'preview_viewbox': {
'Background': '0 0 350 350',
Expand Down
2 changes: 1 addition & 1 deletion app/chat/management/commands/sync_users_to_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ def handle(self, *args, **options):

except ConnectionError as exec:
logger.error(str(exec))
self.retry(30)
self.retry(countdown=30)
except Exception as e:
logger.error(str(e))
8 changes: 4 additions & 4 deletions app/chat/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def create_channel(self, options, bounty_id=None, retry: bool = True) -> None:
except ConnectionError as exc:
logger.info(str(exc))
logger.info("Retrying connection")
self.retry(30)
self.retry(countdown=30)
except Exception as e:
print("we got an exception when creating a channel")
logger.error(str(e))
Expand Down Expand Up @@ -308,7 +308,7 @@ def add_to_channel(self, channel_details, chat_user_ids: list, retry: bool = Tru
except ConnectionError as exc:
logger.info(str(exc))
logger.info("Retrying connection")
self.retry(30)
self.retry(countdown=30)
except Exception as e:
logger.error(str(e))

Expand Down Expand Up @@ -342,7 +342,7 @@ def create_user(self, options, params, profile_handle='', retry: bool = True):
except ConnectionError as exc:
logger.info(str(exc))
logger.info("Retrying connection")
self.retry(30)
self.retry(countdown=30)
except Exception as e:
logger.error(str(e))
return None
Expand Down Expand Up @@ -382,6 +382,6 @@ def patch_chat_user(self, query_opts, update_opts, retry: bool = True) -> None:

logger.info(str(exc))
logger.info("Retrying connection")
self.retry(30)
self.retry(countdown=30)
except Exception as e:
logger.error(str(e))
2 changes: 1 addition & 1 deletion app/dashboard/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def bounty_emails(self, emails, msg, profile_handle, invite_url=None, kudos_invi
except ConnectionError as exc:
logger.info(str(exc))
logger.info("Retrying connection")
self.retry(30)
self.retry(countdown=30)
except Exception as e:
logger.error(str(e))

Expand Down
2 changes: 1 addition & 1 deletion app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
round_end = timezone.datetime(2020, 4, 7, 17, 0)
round_types = ['media', 'tech', 'health']

kudos_reward_pks = [12580, 12584, 12572, 125868, 12552, 12556, 12557, 125677, 12550, 12427, 12392, 12307, 12343, 12156, 12164]
kudos_reward_pks = [12580, 12584, 12572, 125868, 12552, 12556, 12557, 125677, 12550, 12392, 12307, 12343, 12156, 12164]

if not clr_active:
clr_matching_banners_style = 'results'
Expand Down
18 changes: 18 additions & 0 deletions app/kudos/migrations/0012_tokenrequest_bounty_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2020-04-01 20:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('kudos', '0011_auto_20191106_0237'),
]

operations = [
migrations.AddField(
model_name='tokenrequest',
name='bounty_url',
field=models.CharField(blank=True, default='', max_length=255),
),
]
4 changes: 2 additions & 2 deletions app/kudos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ class TokenRequest(SuperModel):
artist = models.CharField(max_length=255)
platform = models.CharField(max_length=255)
to_address = models.CharField(max_length=255)
bounty_url = models.CharField(max_length=255, blank=True, default='')
artwork_url = models.CharField(max_length=255)
numClonesAllowed = models.IntegerField(default=18)
metadata = JSONField(null=True, default=dict, blank=True)
Expand All @@ -665,15 +666,14 @@ def mint(self, gas_price_gwei=None):
'description': self.description,
'priceFinney': self.priceFinney,
'artist': self.artist,
'platform': self.name,
'platform': self.platform,
'numClonesAllowed': self.numClonesAllowed,
'tags': self.tags,
'artwork_url': self.artwork_url,
}
kudos_contract = KudosContract(network=self.network)
gas_price_gwei = recommend_min_gas_price_to_confirm_in_time(1) * 2 if not gas_price_gwei else None
tx_id = mint_kudos(kudos_contract, kudos, account, private_key, gas_price_gwei, mint_to=None, live=True, dont_wait_for_kudos_id_return_tx_hash_instead=True)
tx_id = mint_kudos(kudos_contract, kudos, account, private_key, gas_price_gwei, mint_to=self.to_address, live=True, dont_wait_for_kudos_id_return_tx_hash_instead=True)
self.processed = True
self.approved = True
self.save()
Expand Down
43 changes: 32 additions & 11 deletions app/kudos/tasks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import time

from django.conf import settings

from app.redis_service import RedisService
from celery import app
from celery.utils.log import get_task_logger
from dashboard.utils import get_web3
from hexbytes import HexBytes
from kudos.models import KudosTransfer, TokenRequest
from kudos.utils import kudos_abi
from marketing.mails import notify_kudos_minted
from web3 import Web3

logger = get_task_logger(__name__)

Expand All @@ -28,10 +33,10 @@ def mint_token_request(self, token_req_id, retry=False):
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 min((mint_token_request.request.retries + 1), 10)
multiplier = 1
gas_price = int(float(recommend_min_gas_price_to_confirm_in_time(1)) * multiplier)
if gas_price > delay_if_gas_prices_gt:
self.retry(120)
self.retry(countdown=120)
return
tx_id = obj.mint(gas_price)
if tx_id:
Expand All @@ -41,37 +46,53 @@ def mint_token_request(self, token_req_id, retry=False):
sync_latest(1)
sync_latest(2)
sync_latest(3)
notify_kudos_minted(obj)
else:
self.retry(30)
self.retry(countdown=(30 * (self.request.retries + 1)))


@app.shared_task(bind=True, max_retries=3)
def redeem_bulk_kudos(self, kt_id, signed_rawTransaction, retry=False):
@app.shared_task(bind=True, max_retries=10)
def redeem_bulk_kudos(self, kt_id, retry=False):
"""
:param self:
:param kt_id:
:param signed_rawTransaction:
:return:
"""
with redis.lock("tasks:all_kudos_requests", timeout=LOCK_TIMEOUT):
with redis.lock("tasks:redeem_bulk_kudos:%s" % kt_id, timeout=LOCK_TIMEOUT):
from dashboard.utils import has_tx_mined
from gas.utils import recommend_min_gas_price_to_confirm_in_time
try:
obj = TokenRequest.objects.get(pk=token_req_id)
multiplier = 1 if not retry else min((mint_token_request.request.retries + 1), 10)
multiplier = 1
gas_price = int(float(recommend_min_gas_price_to_confirm_in_time(1)) * multiplier)
if gas_price > delay_if_gas_prices_gt:
self.retry(120)
self.retry(countdown=120)
return

obj = KudosTransfer.objects.get(pk=kt_id)
w3 = get_web3(obj.network)
obj.txid = w3.eth.sendRawTransaction(HexBytes(signed_rawTransaction)).hex()
token = obj.kudos_token_cloned_from
if token.owner_address.lower() != '0x6239FF1040E412491557a7a02b2CBcC5aE85dc8F'.lower():
raise Exception("kudos isnt owned by Gitcoin; cowardly refusing to spend Gitcoin's ETH minting it")
kudos_owner_address = settings.KUDOS_OWNER_ACCOUNT
kudos_owner_address = Web3.toChecksumAddress(kudos_owner_address)
kudos_contract_address = Web3.toChecksumAddress(settings.KUDOS_CONTRACT_MAINNET)
contract = w3.eth.contract(Web3.toChecksumAddress(kudos_contract_address), abi=kudos_abi())
nonce = w3.eth.getTransactionCount(kudos_owner_address)
tx = contract.functions.clone(Web3.toChecksumAddress(obj.receive_address), token.token_id, 1).buildTransaction({
'nonce': nonce,
'gas': 500000,
'gasPrice': gas_price,
'value': int(token.price_finney / 1000.0 * 10**18),
})
private_key = settings.KUDOS_PRIVATE_KEY
signed = w3.eth.account.signTransaction(tx, private_key)
obj.txid = w3.eth.sendRawTransaction(signed.rawTransaction).hex()
obj.receive_txid = obj.txid
obj.save()
while not has_tx_mined(obj.txid, obj.network):
time.sleep(1)
pass
except Exception as e:
self.retry(30)
print(e)
self.retry(countdown=(30 * (self.request.retries + 1)))
2 changes: 1 addition & 1 deletion app/kudos/templates/kudos_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</div>
<div id="kudos-image" class="sticky-top w-100">
{% include 'shared/kudos_levitate.html' %}
<img src="{{ kudos.static_image }}" alt="{{ kudos.ui_name }}" class="w-100">
<img src="{{ kudos.preview_img_url }}" alt="{{ kudos.ui_name }}" class="w-100">
</div>
</div>
<div class="col-md-6 col-lg-5 kudos-details">
Expand Down
6 changes: 4 additions & 2 deletions app/kudos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from dashboard.views import record_user_action
from gas.utils import recommend_min_gas_price_to_confirm_in_time
from git.utils import get_emails_by_category, get_emails_master, get_github_primary_email
from kudos.tasks import redeem_bulk_kudos
from kudos.utils import kudos_abi
from marketing.mails import new_kudos_request
from ratelimit.decorators import ratelimit
Expand Down Expand Up @@ -738,6 +739,7 @@ def redeem_bulk_coupon(coupon, profile, address, ip_address, save_addr=False):
receive_txid=txid,
tx_status='pending',
receive_tx_status='pending',
receive_address=address,
)

# save to DB
Expand Down Expand Up @@ -765,8 +767,7 @@ def redeem_bulk_coupon(coupon, profile, address, ip_address, save_addr=False):
maybe_market_kudos_to_email(kudos_transfer)

if retry_later:
from kudos.tasks import redeem_bulk_kudos
redeem_bulk_kudos.delay(kudos_transfer.id, signed.rawTransaction.hex())
redeem_bulk_kudos.delay(kudos_transfer.id)

return True, None, kudos_transfer

Expand Down Expand Up @@ -857,6 +858,7 @@ def newkudos(request):
description=request.POST['description'],
priceFinney=request.POST['priceFinney'],
artist=request.POST['artist'],
bounty_url=request.POST['bounty_url'],
platform=request.POST['platform'],
numClonesAllowed=request.POST['numClonesAllowed'],
tags=request.POST['tags'].split(","),
Expand Down
21 changes: 21 additions & 0 deletions app/marketing/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,27 @@ def notify_deadbeat_quest(quest):
translation.activate(cur_language)


def notify_kudos_minted(token_request):
to_email = token_request.profile.email
from_email = '[email protected]'
cur_language = translation.get_language()
try:
setup_lang(to_email)
subject = _("Kudos has been minted")
body = f"Your kudos '{token_request.name}' has been minted and should be available on https://gitcoin.co/kudos/marketplace soon."
if not should_suppress_notification_email(to_email, 'faucet'):
send_mail(
from_email,
to_email,
subject,
body,
from_name=_("No Reply from Gitcoin.co"),
categories=['admin', func_name()],
)
finally:
translation.activate(cur_language)


def notify_deadbeat_grants(grants):
to_email = '[email protected]'
from_email = to_email
Expand Down
4 changes: 4 additions & 0 deletions app/retail/templates/newkudos.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ <h5>
<label class="form__label" for="to_address">{% trans "Owner Address" %}</label>
<input type="text" name="to_address" class="form__input" placeholder='0x0...abc109' value="0x6239FF1040E412491557a7a02b2CBcC5aE85dc8F" required>
</div>
<div class="form-group">
<label class="form__label" for="bounty_url">{% trans "Are you submitting this kudos for a bounty? If so what is the bounty URL?" %}</label>
<input type="text" name="bounty_url" class="form__input" placeholder='https://gitcoin.co/issue/....' value="" >
</div>
<div class="terms_container pt-2">
{% if is_staff %}
<div class="form__checkbox">
Expand Down
2 changes: 1 addition & 1 deletion docs/CREATING_CELERY_TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def bounty_emails(self, emails, msg, profile_handle, invite_url=None, kudos_invi
except ConnectionError as exc:
print(exc)
self.retry(30)
self.retry(countdown=30)
```


Expand Down
2 changes: 1 addition & 1 deletion scripts/debug/grants_contributioin_ips.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.utils import timezone

from grants.models import *

pk= 600

grant = Grant.objects.get(pk=pk)
Expand All @@ -15,4 +16,3 @@
for key, val in last_ips.items():
if val > 1:
print(key, "created", val, "accounts")

0 comments on commit ab2b029

Please sign in to comment.