-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: purge std bounty creation + use web3 modal for payout (#6940)
* feat: update detail2 to payout ETH bounties * new prize hackathon form (#6540) * add new prize hackathon FE * fix token change * functions placeholders for send data * lint fixes Co-authored-by: Aditya Anand M C <[email protected]> * add token chain * pick chain * listen network * lint and hoisting * feat: add sync_eth to fetch txn status * send data * fix data send * submit bounty * add celo and optimizations * form validation * more validation and wallet * add server poll for pending txn * close modal once txnid is recorded * use hackathon sponsor objects to determine who can post to hack bounty * Revert "use hackathon sponsor objects to determine who can post to hack bounty" This reverts commit 3a6a7fd. * celo and paypal under staff flag Co-authored-by: Octavio Amuchástegui <[email protected]> Co-authored-by: Dan Lipert <[email protected]>
- Loading branch information
1 parent
b1b2c8f
commit be08828
Showing
26 changed files
with
1,201 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const payWithWeb3 = (fulfillment_id, fulfiller_address, vm, modal) => { | ||
|
||
const amount = vm.fulfillment_context.amount; | ||
const token_name = vm.bounty.token_name; | ||
|
||
web3.eth.sendTransaction({ | ||
to: fulfiller_address, | ||
from: selectedAccount, | ||
value: web3.utils.toWei(String(amount)), | ||
gasPrice: web3.utils.toHex(5 * Math.pow(10, 9)), | ||
gas: web3.utils.toHex(318730), | ||
gasLimit: web3.utils.toHex(318730) | ||
}, | ||
function(error, result) { | ||
if (error) { | ||
_alert({ message: gettext('Unable to payout bounty. Please try again.') }, 'error'); | ||
console.log(error); | ||
} else { | ||
|
||
const payload = { | ||
payout_type: 'web3_modal', | ||
tenant: 'ETH', | ||
amount: amount, | ||
token_name: token_name, | ||
funder_address: selectedAccount, | ||
payout_tx_id: result, | ||
payout_status: 'done' | ||
}; | ||
|
||
modal.closeModal(); | ||
const apiUrlBounty = `/api/v1/bounty/payout/${fulfillment_id}`; | ||
|
||
fetchData(apiUrlBounty, 'POST', payload).then(response => { | ||
if (200 <= response.status && response.status <= 204) { | ||
console.log('success', response); | ||
|
||
vm.fetchBounty(); | ||
_alert('Payment Successful'); | ||
|
||
} 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) { | ||
_alert('Unable to make payout bounty. Please try again later', 'error'); | ||
console.log(error); | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ Vue.mixin({ | |
projectModal(vm.bounty.pk); | ||
} | ||
vm.staffOptions(); | ||
vm.fetchIfPendingFulfillments(); | ||
}).catch(function(error) { | ||
vm.loadingState = 'error'; | ||
_alert('Error fetching bounties. Please contact [email protected]', 'error'); | ||
|
@@ -279,15 +280,15 @@ Vue.mixin({ | |
const decimals = tokenNameToDetails('mainnet', token_name).decimals; | ||
const amount = vm.fulfillment_context.amount; | ||
const payout_tx_id = vm.fulfillment_context.payout_tx_id ? vm.fulfillment_context.payout_tx_id : null; | ||
const bounty_owner_address = vm.bounty.bounty_owner_address; | ||
const funder_address = vm.bounty.bounty_owner_address; | ||
const tenant = vm.getTenant(token_name); | ||
|
||
const payload = { | ||
payout_type: 'qr', | ||
tenant: tenant, | ||
amount: amount * 10 ** decimals, | ||
token_name: token_name, | ||
bounty_owner_address: bounty_owner_address, | ||
funder_address: funder_address, | ||
payout_tx_id: payout_tx_id | ||
}; | ||
|
||
|
@@ -328,6 +329,12 @@ Vue.mixin({ | |
payWithPYPL(fulfillment_id, fulfiller_identifier, ele, vm, modal); | ||
}); | ||
}, | ||
payWithWeb3Step: function(fulfillment_id, fulfiller_address) { | ||
let vm = this; | ||
const modal = this.$refs['payout-modal'][0]; | ||
|
||
payWithWeb3(fulfillment_id, fulfiller_address, vm, modal); | ||
}, | ||
closeBounty: function() { | ||
|
||
let vm = this; | ||
|
@@ -416,6 +423,23 @@ Vue.mixin({ | |
); | ||
|
||
}, | ||
fetchIfPendingFulfillments: function() { | ||
let vm = this; | ||
|
||
const pendingFulfillments = vm.bounty.fulfillments.filter(fulfillment => | ||
fulfillment.payout_status == 'pending' | ||
); | ||
|
||
if (pendingFulfillments.length > 0) { | ||
if (!vm.pollInterval) { | ||
vm.pollInterval = setInterval(vm.fetchBounty, 60000); | ||
} | ||
} else { | ||
clearInterval(vm.pollInterval); | ||
vm.pollInterval = null; | ||
} | ||
return; | ||
}, | ||
stopWork: function(isOwner) { | ||
let text = isOwner ? | ||
'Are you sure you would like to stop this user from working on this bounty ?' : | ||
|
@@ -478,6 +502,8 @@ Vue.mixin({ | |
vm.fulfillment_context.active_step = 'payout_amount'; | ||
} else if (fulfillment.payout_type == 'qr') { | ||
vm.fulfillment_context.active_step = 'check_wallet_owner'; | ||
} else if (fulfillment.payout_type == 'web3_modal') { | ||
vm.fulfillment_context.active_step = 'payout_amount'; | ||
} | ||
} | ||
}, | ||
|
@@ -528,7 +554,8 @@ if (document.getElementById('gc-bounty-detail')) { | |
decimals: 18, | ||
inputBountyOwnerAddress: bounty.bounty_owner_address, | ||
contxt: document.contxt, | ||
quickLinks: [] | ||
quickLinks: [], | ||
pollInterval: null | ||
}; | ||
}, | ||
mounted() { | ||
|
Oops, something went wrong.