Skip to content

Commit

Permalink
Merge pull request #6240 from gitcoinco/fix/crosschain
Browse files Browse the repository at this point in the history
fix etc payout flow
  • Loading branch information
thelostone-mc authored Mar 20, 2020
2 parents 3530628 + b9c8312 commit 8b3ff46
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
14 changes: 9 additions & 5 deletions app/assets/v2/js/pages/bounty_details2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions app/dashboard/templates/bounty/details2.html
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ <h5 class="font-body font-weight-semibold">{% trans "SUBMISSIONS" %}</h5>
<span class="font-weight-bold">Hours worked:</span>
[[ fulfillment.fulfiller_metadata.data.payload.fulfiller.hoursWorked ]]
</p>
<modal :id="`payoutModal${fulfillment.pk}`" ref="user-modal">
<modal :id="`payoutModal${fulfillment.pk}`" ref="payout-modal">
<div slot="body">
<div class="text-center">
<p class="alert-warning py-2 font-smaller-4 mb-0" v-if="bounty.amount_paid && bounty.amount_paid > bounty.value_true">
Expand Down Expand Up @@ -382,7 +382,7 @@ <h5 class="font-body font-weight-semibold">{% trans "SUBMISSIONS" %}</h5>
<qrcode :string="`ethereum:${fulfillment.fulfiller_address}`"></qrcode>
<small class="d-block my-3">Scan the QR code above with your ETC Wallet to payout</small>
<button class="d-block mx-auto mb-3 btn btn-outline-gc-blue px-2 font-caption font-weight-semibold"
@click="fulfillmentComplete(fulfillment.pk, inputAmount)"
@click="fulfillmentComplete(fulfillment.pk, inputAmount, $event)"
>
I have Scanned & Paid
</button>
Expand Down
1 change: 1 addition & 0 deletions app/dashboard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5028,6 +5028,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()

Expand Down

0 comments on commit 8b3ff46

Please sign in to comment.