Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: purge std bounty creation + use web3 modal for payout #6940

Merged
merged 21 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/app/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ FEE_ADDRESS_PRIVATE_KEY=
GIPHY_KEY=
YOUTUBE_API_KEY=
VIEW_BLOCK_API_KEY=
ETHERSCAN_API_KEY=
FORTMATIC_LIVE_KEY=
FORTMATIC_TEST_KEY=

Expand Down
1 change: 1 addition & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#social integrations
GIPHY_KEY = env('GIPHY_KEY', default='LtaY19ToaBSckiLU4QjW0kV9nIP75NFy')
YOUTUBE_API_KEY = env('YOUTUBE_API_KEY', default='YOUR-SupEr-SecRet-YOUTUBE-KeY')
ETHERSCAN_API_KEY = env('ETHERSCAN_API_KEY', default='YOUR-ETHERSCAN-KEY')
VIEW_BLOCK_API_KEY = env('VIEW_BLOCK_API_KEY', default='YOUR-VIEW-BLOCK-KEY')
FORTMATIC_LIVE_KEY = env('FORTMATIC_LIVE_KEY', default='YOUR-SupEr-SecRet-LiVe-FoRtMaTiC-KeY')
FORTMATIC_TEST_KEY = env('FORTMATIC_TEST_KEY', default='YOUR-SupEr-SecRet-TeSt-FoRtMaTiC-KeY')
Expand Down
3 changes: 3 additions & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@
path('revenue/attestations/new', revenue.views.new_attestation, name='revenue_new_attestation'),

# Hackathons / special events
path('hackathon/<str:hackathon>/new/', dashboard.views.new_hackathon_bounty, name='new_hackathon_bounty'),
path('hackathon/<str:hackathon>/new', dashboard.views.new_hackathon_bounty, name='new_hackathon_bounty2'),
path('hackathon/<str:hackathon>/', dashboard.views.hackathon, name='hackathon'),
path('hackathon/<str:hackathon>', dashboard.views.hackathon, name='hackathon2'),
path('hackathon/<str:hackathon>/onboard/', dashboard.views.hackathon_onboard, name='hackathon_onboard2'),
Expand Down Expand Up @@ -376,6 +378,7 @@
re_path(r'^dynamic/viz/graph/(.*)?$', dataviz.d3_views.viz_graph, name='viz_graph'),
re_path(r'^dynamic/viz/sscatterplot/(.*)?$', dataviz.d3_views.viz_scatterplot_stripped, name='viz_sscatterplot'),
path('dynamic/js/tokens_dynamic.js', retail.views.tokens, name='tokens'),
url('^api/v1/tokens', retail.views.json_tokens, name='json_tokens'),

# sync methods
url(r'^sync/web3/?', dashboard.views.sync_web3, name='sync_web3'),
Expand Down
1 change: 1 addition & 0 deletions app/assets/v2/images/chains/celo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/v2/images/chains/ethereum-classic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/v2/images/chains/ethereum.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/v2/images/chains/paypal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/v2/images/chains/zilliqa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions app/assets/v2/js/pages/bounty_detail/web3_modal.js
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);
});
}
});
}
33 changes: 30 additions & 3 deletions app/assets/v2/js/pages/bounty_details2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ?' :
Expand Down Expand Up @@ -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';
}
}
},
Expand Down Expand Up @@ -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() {
Expand Down
Loading