Skip to content

Commit

Permalink
make fix, and some nice little tweaks for ERC20 quest rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Nov 29, 2020
1 parent deccb7e commit 7c0d392
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/assets/onepager/js/receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ $(document).ready(function() {
gasLimit = new web3.utils.BN(gasLimit);
var send_amount = holderBalance.sub(gasLimit.mul(gas_price_wei)).sub(buffer);

if (document.override_send_amount) {
if (document.override_send_amount && (document.override_send_amount * 10 ** 18) < send_amount) {
send_amount = document.override_send_amount * 10 ** 18; // TODO: decimals
}

Expand Down
1 change: 1 addition & 0 deletions app/assets/v2/js/pages/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $(document).ready(function() {
}
let url = '/kudos/sync/?pk=' + $(this).data('id');
let $target = $(this).parents('.flip-card__extra-data').find('.block_explorer_link');

$.get(url, function(response) {
let block_ex_url = response['url'];
let txid = response['txid'];
Expand Down
7 changes: 6 additions & 1 deletion app/quests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ def get_base_quest_view_params(user, quest):
profile = user.profile if user.is_authenticated else None
attempts = quest.attempts.filter(profile=profile) if profile else QuestAttempt.objects.none()
is_owner = quest.creator.pk == user.profile.pk if user.is_authenticated else False
title = "Play the *" + quest.title + "* Gitcoin Quest"
if quest.kudos_reward:
title += f" and win a *{quest.kudos_reward.humanized_name}* Kudos"
if quest.reward_tip:
title = f"[WIN {quest.reward_tip.value_true} {quest.reward_tip.tokenName}] " + title
params = {
'quest': quest,
'hide_col': True,
Expand All @@ -105,7 +110,7 @@ def get_base_quest_view_params(user, quest):
'is_owner': is_owner,
'is_owner_or_staff': is_owner or user.is_staff,
'body_class': 'quest_battle',
'title': "Play the *" + quest.title + (f"* Gitcoin Quest and win a *{quest.kudos_reward.humanized_name}* Kudos" if quest.kudos_reward else ""),
'title': title,
'avatar_url': quest.avatar_url_png,
'card_desc': quest.description,
'seconds_per_question': quest.game_schema.get('seconds_per_question', 30),
Expand Down
2 changes: 2 additions & 0 deletions app/quests/templates/quests/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ <h4>
<div class=hidden>
{% include 'shared/add_kudos.html' with name='reward2' filter_by_address="0x6239FF1040E412491557a7a02b2CBcC5aE85dc8F" %}
</div>
{% elif package.reward_tip %}
Tip Reward, N/A
{% else %}
{% include 'shared/add_kudos.html' with name='reward' filter_by_address="0x6239FF1040E412491557a7a02b2CBcC5aE85dc8F" %}
{% endif %}
Expand Down
6 changes: 4 additions & 2 deletions app/quests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ def editquest(request, pk=None):
counter += 1

validation_pass = True
reward = None
try:
enemy = Token.objects.get(pk=package.get('enemy'))
reward = Token.objects.get(pk=package.get('reward'))
if package.get('reward'):
reward = Token.objects.get(pk=package.get('reward'))
except Exception as e:
messages.error(request, 'Unable to find Kudos')
validation_pass = False
Expand Down Expand Up @@ -195,7 +197,7 @@ def editquest(request, pk=None):
package['reading_material_url'] = quest.game_schema.get('prep_materials', [{}])[0].get('url')
package['reading_material_name'] = quest.game_schema.get('prep_materials', [{}])[0].get('title')
package['video_enabled'] = quest.video
package['reward'] = quest.kudos_reward.pk
package['reward'] = quest.kudos_reward.pk if quest.kudos_reward else None
package['enemy'] = quest.game_metadata.get('enemy', {}).get('id')
package['points'] = quest.value
package['minutes'] = quest.cooldown_minutes
Expand Down

0 comments on commit 7c0d392

Please sign in to comment.