From b9c831218131f9d07f346bdb3956166edc681a08 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Mon, 16 Mar 2020 15:14:48 -0300 Subject: [PATCH] fix etc payout flow --- app/assets/v2/js/pages/bounty_details2.js | 14 +++++++++----- app/dashboard/templates/bounty/details2.html | 4 ++-- app/dashboard/utils.py | 1 + app/dashboard/views.py | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/assets/v2/js/pages/bounty_details2.js b/app/assets/v2/js/pages/bounty_details2.js index d6d8094db31..d0503d29548 100644 --- a/app/assets/v2/js/pages/bounty_details2.js +++ b/app/assets/v2/js/pages/bounty_details2.js @@ -169,28 +169,32 @@ Vue.mixin({ }); } }, - fulfillmentComplete: function(fulfillment_id, amount) { - + fulfillmentComplete: function(fulfillment_id, amount, event) { let vm = this; - const token_name = vm.bounty.token_name; const decimals = tokenNameToDetails('mainnet', token_name).decimals; - const payload = { amount: amount * 10 ** decimals, token_name: token_name, bounty_owner_address: vm.bounty.bounty_owner_address }; - const apiUrlBounty = `/api/v1/bounty/payout/${fulfillment_id}`; + event.target.disabled = true; + fetchData(apiUrlBounty, 'POST', payload).then(response => { + event.target.disabled = false; if (200 <= response.status && response.status <= 204) { console.log('success', response); + vm.fetchBounty(); + this.$refs["payout-modal"][0].closeModal(); } else { _alert('Unable to make payout bounty. Please try again later', 'error'); console.error(`error: bounty payment failed with status: ${response.status} and message: ${response.message}`); } + }).catch(function(error) { + event.target.disabled = false; + _alert('Unable to make payout bounty. Please try again later', 'error'); }); }, closeBounty: function() { diff --git a/app/dashboard/templates/bounty/details2.html b/app/dashboard/templates/bounty/details2.html index 4a79cabfa17..bfc96079abc 100644 --- a/app/dashboard/templates/bounty/details2.html +++ b/app/dashboard/templates/bounty/details2.html @@ -353,7 +353,7 @@
{% trans "SUBMISSIONS" %}
Hours worked: [[ fulfillment.fulfiller_metadata.data.payload.fulfiller.hoursWorked ]]

- +

@@ -382,7 +382,7 @@

{% trans "SUBMISSIONS" %}
Scan the QR code above with your ETC Wallet to payout diff --git a/app/dashboard/utils.py b/app/dashboard/utils.py index 0eeed64081a..13afbc66c13 100644 --- a/app/dashboard/utils.py +++ b/app/dashboard/utils.py @@ -493,6 +493,7 @@ def search_for_etc_bounty_payout(fulfillment, network='mainnet'): if blockscout_response['message'] and blockscout_response['result']: for txn in blockscout_response['result']: if ( + txn['from'] == funderAddress.lower() and txn['to'] == payeeAddress.lower() and float(txn['value']) >= float(amount) and not etc_txn_already_used(txn) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 7c1a078a5d3..34aae72de3e 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -5016,6 +5016,7 @@ def payout_bounty_v1(request, fulfillment_id): return JsonResponse(response) fulfillment.payout_amount = amount + fulfillment.payout_status = 'pending' fulfillment.token_name = token_name fulfillment.save()