diff --git a/app/assets/onepager/js/send.js b/app/assets/onepager/js/send.js index ac62a610d08..babaf9857d4 100644 --- a/app/assets/onepager/js/send.js +++ b/app/assets/onepager/js/send.js @@ -1,8 +1,5 @@ /* eslint-disable no-console */ var get_gas_price = function() { - if ($('#gasPrice').length) { - return $('#gasPrice').val() * Math.pow(10, 9); - } if (typeof defaultGasPrice != 'undefined') { return defaultGasPrice; } diff --git a/app/assets/v2/css/base.css b/app/assets/v2/css/base.css index d688048840d..d1b5e448d44 100644 --- a/app/assets/v2/css/base.css +++ b/app/assets/v2/css/base.css @@ -246,48 +246,6 @@ p a { float:right; } -#gas-section .gas-image { - height: 4.5rem; -} - -#gas-section .font-body { - margin: 0; -} - -#gas-section .recommended-prices { - cursor: pointer; - text-align: center; -} - -#gas-section .gas-dark-bg { - background-color: #FAFAFA; -} - -#gas-section .gas-rates .active { - font-weight: 600; - background-color: #0ECF7C; -} - -#gas-section #metamask_context { - display: none; -} - -#gas-section #accordion-set-own-limit { - cursor: pointer; - border-bottom: 1px solid rgba(0,0,0,.1); - border-top: 1px solid rgba(0,0,0,.1); -} - -#gas-section #accordion-set-own-limit i { - float: right; -} - -#gas-section #default-recommended-gas, -#gas-section .message { - display: none; - text-align: center; -} - .btn-warning, .btn-success, .btn-info { @@ -685,52 +643,6 @@ input[type=text].loading { color: #000; } -.metamask_recc { - width: 45%; - display: inline-block; -} - -#metamask_label img { - position: relative; - top: -2px; -} - -#metamask_context .red_warning { - background-color: #fbe0d6; - color: #fb9470; - padding: 5px 10px; - border-radius: 2px; - margin-bottom: 15px; - display: block; -} - -#metamask_context .red_warning a { - color: #fb9470 !important; - font-weight: bold; - text-decoration: underline; -} - -#metamask_context ul { - font-size: 0.85rem; - margin-top: 0.5rem; - padding-left: 1rem; -} - -#metamask_context li a { - color: #0D0764; -} - -#metamask_context .warning { - text-align: center; - background-color: #ff9800; - border-radius: 5px; -} - -#metamask_context .warning a { - color: black; - font-weight: bold; -} - .bottom_notification a { color: currentColor; text-decoration: underline; diff --git a/app/assets/v2/css/grants/fund.css b/app/assets/v2/css/grants/fund.css index 87eaa6076c7..1ab59505af2 100644 --- a/app/assets/v2/css/grants/fund.css +++ b/app/assets/v2/css/grants/fund.css @@ -70,10 +70,6 @@ bottom: 2px; } -#accordion-set-own-limit { - font-size: 12px; -} - #gitcoin-grant-section .custom { width: 4.25rem; position: relative; diff --git a/app/assets/v2/js/grants/cancel_subscription.js b/app/assets/v2/js/grants/cancel_subscription.js index 234d5f34adc..bd47571b804 100644 --- a/app/assets/v2/js/grants/cancel_subscription.js +++ b/app/assets/v2/js/grants/cancel_subscription.js @@ -33,11 +33,9 @@ $(document).ready(() => { let realTokenAmount = Number(data.amount_per_period * 10 ** decimals); let amountSTR = realTokenAmount.toLocaleString('fullwide', { useGrouping: false }); - let realGasPrice = $('#gasPrice').val() * Math.pow(10, 9); - web3.eth.getAccounts(function(err, accounts) { - deployedToken.methods.approve(data.contract_address, web3.utils.toTwosComplement(0)).send({from: accounts[0], gasPrice: realGasPrice}) + deployedToken.methods.approve(data.contract_address, web3.utils.toTwosComplement(0)).send({from: accounts[0]}) .on('transactionHash', function(transactionHash) { $('#sub_end_approve_tx_id').val(transactionHash); const linkURL = get_etherscan_url(transactionHash); @@ -56,7 +54,6 @@ $(document).ready(() => { data.token_address, // testing token web3.utils.toTwosComplement(amountSTR), // data.amount_per_period web3.utils.toTwosComplement(data.real_period_seconds), // data.period_seconds - web3.utils.toTwosComplement(realGasPrice), // data.gas_price web3.utils.toTwosComplement(nonce), // nonce data.signature // contributor_signature ]; @@ -66,7 +63,6 @@ $(document).ready(() => { ...parts ).send({ from: accounts[0], - gasPrice: realGasPrice, gas: web3.utils.toHex(gas_amount(document.location.href)), gasLimit: web3.utils.toHex(gas_amount(document.location.href)) }) diff --git a/app/assets/v2/js/grants/detail.js b/app/assets/v2/js/grants/detail.js index 8e690101310..cf2d52d854f 100644 --- a/app/assets/v2/js/grants/detail.js +++ b/app/assets/v2/js/grants/detail.js @@ -201,8 +201,7 @@ $(document).ready(function() { deployedSubscription.methods.endContract() .send({ from: accounts[0], - gas: 3000000, - gasPrice: web3.utils.toHex($('#gasPrice').val() * Math.pow(10, 9)) + gas: 3000000 }).on('transactionHash', function(transactionHash) { grant_cancel_tx_id = $('#grant_cancel_tx_id').val(); const linkURL = get_etherscan_url(transactionHash); diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 2fe84f40785..1cc9819873a 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -22,8 +22,6 @@ var set_form_disabled = function(is_disabled) { $(document).ready(function() { - // _alert({ message: gettext('Note: Brave users seem to have issues while contributing to Grants while using both Brave Wallet and MetaMask. We recommend disabling one. For more info, see this issue') }, 'warning'); - // set defaults var set_defaults = function() { var lookups = { @@ -281,8 +279,7 @@ $(document).ready(function() { web3.eth.sendTransaction({ from: accounts[0], to: to_address, - value: to_addr_amount, - gasPrice: parseInt(web3.utils.toHex($('#gasPrice').val() * Math.pow(10, 9))) + value: to_addr_amount }, function(err, txid) { indicateMetamaskPopup(1); if (err) { @@ -339,8 +336,7 @@ $(document).ready(function() { web3.eth.sendTransaction({ from: accounts[0], to: gitcoinDonationAddress, - value: gitcoin_amount, - gasPrice: parseInt(web3.utils.toHex($('#gasPrice').val() * Math.pow(10, 9))) + value: gitcoin_amount }, success_callback); } }); @@ -408,7 +404,6 @@ $(document).ready(function() { web3.utils.toTwosComplement(approvalSTR) ).send({ from: accounts[0], - gasPrice: web3.utils.toHex(parseInt($('#gasPrice').val() * Math.pow(10, 9))), gas: web3.utils.toHex(gas_amount(document.location.href)), gasLimit: web3.utils.toHex(gas_amount(document.location.href)) }).on('error', function(error) { @@ -506,7 +501,6 @@ const subscribeToGrant = (transactionHash) => { 'frequency_unit': $('#frequency_unit').val(), 'token_address': selected_token, 'token_symbol': $('#token_symbol').val(), - 'gas_price': $('#gas_price').val(), 'sub_new_approve_tx_id': transactionHash, 'num_tx_approved': $('#period').val(), 'network': $('#network').val(), @@ -652,8 +646,7 @@ const splitPayment = (account, toFirst, toSecond, valueFirst, valueSecond) => { indicateMetamaskPopup(); deployedSplitter.methods.splitTransfer(toFirst, toSecond, valueFirst, valueSecond, tokenAddress).send({ from: account, - gas: web3.utils.toHex(100000), - gasPrice: parseInt(web3.utils.toHex($('#gasPrice').val() * Math.pow(10, 9))) + gas: web3.utils.toHex(100000) }).on('error', function(error) { console.log('1', error); indicateMetamaskPopup(1); diff --git a/app/assets/v2/js/grants/new.js b/app/assets/v2/js/grants/new.js index ab5df13e0f1..c8f6747749c 100644 --- a/app/assets/v2/js/grants/new.js +++ b/app/assets/v2/js/grants/new.js @@ -149,21 +149,6 @@ const init = () => { // trusted relayer web3.utils.toChecksumAddress(data.trusted_relayer) ]; - } else if ($('#contract_version').val() == 0) { - args = [ - // admin_address - web3.utils.toChecksumAddress(data.admin_address), - // required token - web3.utils.toChecksumAddress(data.denomination), - // required tokenAmount - web3.utils.toTwosComplement(0), - // data.frequency - web3.utils.toTwosComplement(0), - // data.gas_price - web3.utils.toTwosComplement(0), - // contract version - web3.utils.toTwosComplement(0) - ]; } web3.eth.getAccounts(function(err, accounts) { @@ -174,7 +159,6 @@ const init = () => { arguments: args }).send({ from: accounts[0], - gasPrice: web3.utils.toHex($('#gasPrice').val() * Math.pow(10, 9)), gas: web3.utils.toHex(gas_amount(document.location.href)), gasLimit: web3.utils.toHex(gas_amount(document.location.href)) }).on('error', function(error) { diff --git a/app/assets/v2/js/pages/bulk_payout.js b/app/assets/v2/js/pages/bulk_payout.js index 5fa7c5359de..8a42d85ce38 100644 --- a/app/assets/v2/js/pages/bulk_payout.js +++ b/app/assets/v2/js/pages/bulk_payout.js @@ -108,14 +108,13 @@ $(document).ready(function($) { }); } }; + var bounty = web3.eth.contract(bounty_abi).at(bounty_address()); - var gas_dict = { gasPrice: web3.toHex($('#gasPrice').val() * Math.pow(10, 9)) }; indicateMetamaskPopup(); web3.eth.getAccounts(function(_, accounts) { bounty.killBounty( $('#standard_bounties_id').val(), - gas_dict, {from: accounts[0]}, callback ); diff --git a/app/assets/v2/js/pages/cancel_bounty/ETH.js b/app/assets/v2/js/pages/cancel_bounty/ETH.js index dec9d91e5be..b449546f8af 100644 --- a/app/assets/v2/js/pages/cancel_bounty/ETH.js +++ b/app/assets/v2/js/pages/cancel_bounty/ETH.js @@ -114,10 +114,7 @@ const ethCancelBounty = data => { web3.eth.getAccounts(function(_, accounts) { bounty.killBounty( bountyId, - { - from: accounts[0], - gasPrice: web3.toHex($('#gasPrice').val() * Math.pow(10, 9)) - }, + { from: accounts[0] }, final_callback ); }); diff --git a/app/assets/v2/js/pages/create_bounty/ETH.js b/app/assets/v2/js/pages/create_bounty/ETH.js index 4ef55cc6ed3..d10b367cb1f 100644 --- a/app/assets/v2/js/pages/create_bounty/ETH.js +++ b/app/assets/v2/js/pages/create_bounty/ETH.js @@ -220,7 +220,6 @@ const ethCreateBounty = async (data) => { { from: account, value: eth_amount, - gasPrice: web3.toHex($('#gasPrice').val() * Math.pow(10, 9)), gas: web3.toHex(318730), gasLimit: web3.toHex(318730) }, @@ -232,7 +231,6 @@ const ethCreateBounty = async (data) => { handleTokenAuth().then(() => { const fee = Number((Number(data.amount) * FEE_PERCENTAGE).toFixed(4)); const to_address = '0x00De4B13153673BCAE2616b67bf822500d325Fc3'; - const gas_price = web3.toHex($('#gasPrice').val() * Math.pow(10, 9)); indicateMetamaskPopup(); if (FEE_PERCENTAGE == 0) { @@ -243,7 +241,6 @@ const ethCreateBounty = async (data) => { to: to_address, from: account, value: web3.toWei(fee, 'ether'), - gasPrice: gas_price }, function(error, txnId) { indicateMetamaskPopup(true); if (error) { @@ -262,7 +259,7 @@ const ethCreateBounty = async (data) => { const amountInWei = fee * 1.0 * Math.pow(10, token.decimals); const token_contract = web3.eth.contract(token_abi).at(tokenAddress); - token_contract.transfer(to_address, amountInWei, { gasPrice: gas_price }, + token_contract.transfer(to_address, amountInWei, function(error, txnId) { indicateMetamaskPopup(true); if (error) { @@ -305,7 +302,6 @@ const ethCreateBounty = async (data) => { to: '0x00De4B13153673BCAE2616b67bf822500d325Fc3', from: web3.account, value: web3.toWei(ethFeaturedPrice, 'ether'), - gasPrice: web3.toHex($('#gasPrice').val() * Math.pow(10, 9)), gas: web3.toHex(318730), gasLimit: web3.toHex(318730) }, diff --git a/app/assets/v2/js/pages/fulfill_bounty/ETH.js b/app/assets/v2/js/pages/fulfill_bounty/ETH.js index 1573ff7fba5..0156f5c3395 100644 --- a/app/assets/v2/js/pages/fulfill_bounty/ETH.js +++ b/app/assets/v2/js/pages/fulfill_bounty/ETH.js @@ -134,10 +134,7 @@ const ethFulfillBounty = data => { bounty.fulfillBounty( bountyId, document.ipfsDataHash, - { - from: accounts[0], - gasPrice: web3.toHex($('#gasPrice').val() * Math.pow(10, 9)) - }, + { from: accounts[0] }, web3Callback ); }); diff --git a/app/assets/v2/js/pages/increase_bounty.js b/app/assets/v2/js/pages/increase_bounty.js index 378362a7706..94cc8f87eaf 100644 --- a/app/assets/v2/js/pages/increase_bounty.js +++ b/app/assets/v2/js/pages/increase_bounty.js @@ -220,8 +220,7 @@ $(document).ready(async function() { { from: account, value: ethAmount, - gas: web3.toHex(652690), - gasPrice: web3.toHex($('#gasPrice').val() * Math.pow(10, 9)) + gas: web3.toHex(652690) }, web3Callback ); @@ -231,7 +230,6 @@ $(document).ready(async function() { if (act_as_funder) { const to_address = '0x00De4B13153673BCAE2616b67bf822500d325Fc3'; - const gas_price = web3.toHex($('#gasPrice').val() * Math.pow(10, 9)); const fee = (Number($('#summary-bounty-amount').html()) * FEE_PERCENTAGE).toFixed(4); indicateMetamaskPopup(); @@ -242,8 +240,7 @@ $(document).ready(async function() { web3.eth.sendTransaction({ to: to_address, from: account, - value: web3.toWei(fee, 'ether'), - gasPrice: gas_price + value: web3.toWei(fee, 'ether') }, function(error, txnId) { indicateMetamaskPopup(true); if (error) { @@ -257,7 +254,7 @@ $(document).ready(async function() { const amountInWei = fee * 1.0 * Math.pow(10, token.decimals); const token_contract = web3.eth.contract(token_abi).at(tokenAddress); - token_contract.transfer(to_address, amountInWei, { gasPrice: gas_price }, function(error, txnId) { + token_contract.transfer(to_address, amountInWei, function(error, txnId) { indicateMetamaskPopup(true); if (error) { _alert({ message: gettext('Unable to pay bounty fee. Please try again.') }, 'error'); diff --git a/app/assets/v2/js/pages/kudos_send.js b/app/assets/v2/js/pages/kudos_send.js index 3e3a5be496f..de683957f92 100644 --- a/app/assets/v2/js/pages/kudos_send.js +++ b/app/assets/v2/js/pages/kudos_send.js @@ -1,9 +1,6 @@ /* eslint-disable no-console */ var get_gas_price = function() { - if ($('#gasPrice').length) { - return $('#gasPrice').val() * Math.pow(10, 9); - } if (typeof defaultGasPrice != 'undefined') { return defaultGasPrice; } diff --git a/app/assets/v2/js/pages/process_bounty.js b/app/assets/v2/js/pages/process_bounty.js index e22f2306920..35e44c6834a 100644 --- a/app/assets/v2/js/pages/process_bounty.js +++ b/app/assets/v2/js/pages/process_bounty.js @@ -268,7 +268,7 @@ window.onload = function() { // just sent payout var send_payout = function() { web3.eth.getAccounts(function(_, accounts) { - bounty.acceptFulfillment(bountyId, fulfillmentId, {gasPrice: web3.toHex($('#gasPrice').val() * Math.pow(10, 9)), from: accounts[0]}, final_callback); + bounty.acceptFulfillment(bountyId, fulfillmentId, {from: accounts[0]}, final_callback); }); }; diff --git a/app/assets/v2/js/pages/shared_bounty_mutation_estimate_gas.js b/app/assets/v2/js/pages/shared_bounty_mutation_estimate_gas.js index f164965c03e..ad22812ebdc 100644 --- a/app/assets/v2/js/pages/shared_bounty_mutation_estimate_gas.js +++ b/app/assets/v2/js/pages/shared_bounty_mutation_estimate_gas.js @@ -1,8 +1,5 @@ -// Wait until page is loaded, then run the function - var gas_amount = function(page_url) { - var gasLimitEstimate = 0; - // new new funding page + let gasLimitEstimate = 0; if (page_url.indexOf('issue/fulfill') != -1) { gasLimitEstimate = 207103; @@ -40,41 +37,38 @@ var gas_amount = function(page_url) { return gasLimitEstimate; }; -jQuery(document).ready(function() { - - var gasLimitEstimate = gas_amount(document.location.href); - - var estimateGas = function(success_callback, failure_callback, final_callback) { - // TODO: could do a web3 .estimateGas() - success_callback(gasLimitEstimate, gasLimitEstimate, ''); - final_callback(); - }; - // updates recommended metamask settings - var updateInlineGasEstimate = function() { - var success_callback = function(gas, gasLimit, _) { - jQuery('#gasLimit').val(parseInt(gas)); - update_metamask_conf_time_and_cost_estimate(); - }; - var failure_callback = function(errors) { - jQuery('#gasLimit').val('Unknown'); - update_metamask_conf_time_and_cost_estimate(); - }; - var final_callback = function() { - // … - }; - estimateGas(success_callback, failure_callback, final_callback); - }; - - // only check for updating gas estimates IFF we're on a page where - // update_metamask_conf_time_and_cost_estimate() is defined - if (typeof update_metamask_conf_time_and_cost_estimate != 'undefined') { - setTimeout(function() { - updateInlineGasEstimate(); - }, 500); - jQuery('input').change(updateInlineGasEstimate); - jQuery('#gasPrice').keyup(update_metamask_conf_time_and_cost_estimate); - } +// jQuery(document).ready(function() { +// var gasLimitEstimate = gas_amount(document.location.href); +// var estimateGas = function(success_callback, failure_callback, final_callback) { +// // TODO: could do a web3 .estimateGas() +// success_callback(gasLimitEstimate, gasLimitEstimate, ''); +// final_callback(); +// }; +// // updates recommended metamask settings +// var updateInlineGasEstimate = function() { +// var success_callback = function(gas, gasLimit, _) { +// jQuery('#gasLimit').val(parseInt(gas)); +// update_metamask_conf_time_and_cost_estimate(); +// }; +// var failure_callback = function(errors) { +// jQuery('#gasLimit').val('Unknown'); +// update_metamask_conf_time_and_cost_estimate(); +// }; +// var final_callback = function() { +// // … +// }; +// estimateGas(success_callback, failure_callback, final_callback); +// }; -}); +// // only check for updating gas estimates IFF we're on a page where +// // update_metamask_conf_time_and_cost_estimate() is defined +// if (typeof update_metamask_conf_time_and_cost_estimate != 'undefined') { +// setTimeout(function() { +// updateInlineGasEstimate(); +// }, 500); +// jQuery('input').change(updateInlineGasEstimate); +// jQuery('#gasPrice').keyup(update_metamask_conf_time_and_cost_estimate); +// } +// }); diff --git a/app/assets/v2/js/pages/wallet_estimate.js b/app/assets/v2/js/pages/wallet_estimate.js deleted file mode 100644 index 863b4817f9e..00000000000 --- a/app/assets/v2/js/pages/wallet_estimate.js +++ /dev/null @@ -1,133 +0,0 @@ -window.addEventListener('load', function() { - try { - if (web3 && web3.currentProvider.isTrust) { - $('#trust_label').show(); - } else { - $('#metamask_label').show(); - } - } catch (ignore) { - console.log('%c error: web3 not defined. ensure metamask is installed & unlocked', 'color: red'); - } - setTimeout(prefill_recommended_prices, 1000); - - $(document).on('click', '#accordion-set-own-limit', function() { - $('#metamask_context').toggle(); - $('#gas-section .recommended-prices').removeClass('active'); - if ($('#accordion-set-own-limit i').hasClass('fa-angle-down')) { - $('#accordion-set-own-limit i').removeClass('fa-angle-down').addClass('fa-angle-up'); - } else { - $('#accordion-set-own-limit i').removeClass('fa-angle-up').addClass('fa-angle-down'); - } - }); - - $(document).on('click', '#gas-section .recommended-prices', function() { - var gasLimit = parseInt($('#gasLimit').val()); - var usdAmount = $(this).data('amount-usd'); - var ethAmount = Math.round(1000000 * usdAmount / document.eth_usd_conv_rate) / 1000000; - var gasPrice = $(this).data('amount'); - - $('#gas-section .recommended-prices').removeClass('active'); - $(this).addClass('active'); - $('#gas-usd').html('$' + usdAmount); - $('#gas-eth').html(ethAmount + 'ETH'); - gasPrice = Math.round(gasPrice * 10) / 10.0; - if (gasPrice < 0.1) { - gasPrice = 0.1; - } - $('#gasPrice').val(gasPrice); - update_metamask_conf_time_and_cost_estimate(); - }); -}); - -function gasToUSD(gasPrice) { - var gasLimit = parseInt($('#gasLimit').val()); - var ethAmount = Math.round(1000 * gasLimit * gasPrice / Math.pow(10, 9)) / 1000; - var usdAmount = Math.round(10 * ethAmount * document.eth_usd_conv_rate) / 10; - - return usdAmount; -} - -function get_recommended_prices() { - var slow_price_index = Math.round(document.conf_time_spread.length / 9); - var avg_price_index = Math.round(document.conf_time_spread.length / 3); - var fast_price_index = Math.round(document.conf_time_spread.length / 9 * 5); - - var slow_price_range = []; - - for (var i = 0; i < document.conf_time_spread.length; i++) { - if (gasPrice <= parseFloat(next_ele[0]) && gasPrice > parseFloat(this_ele[0])) { - confTime = Math.round(10 * next_ele[1]) / 10; - } - } - - var recommendations = { - 'slow': { - 'amount': gasToUSD(document.conf_time_spread[slow_price_index][0]), - 'time': document.conf_time_spread[slow_price_index][1] - }, - 'avg': { - 'amount': gasToUSD(document.conf_time_spread[avg_price_index][0]), - 'time': document.conf_time_spread[avg_price_index][1] - }, - 'fast': { - 'amount': gasToUSD(document.conf_time_spread[fast_price_index][0]), - 'time': document.conf_time_spread[fast_price_index][1] - } - }; - - return recommendations; -} - -function prefill_recommended_prices() { - var slow_data = get_updated_metamask_conf_time_and_cost(parseFloat($('#slow-recommended-gas').data('amount'))); - var avg_data = get_updated_metamask_conf_time_and_cost(parseFloat($('#average-recommended-gas').data('amount'))); - var fast_data = get_updated_metamask_conf_time_and_cost(parseFloat($('#fast-recommended-gas').data('amount'))); - - if (fast_data && fast_data['time'] == 'unknown') { - $('#default-recommended-gas').show(); - $('#default-recommended-gas').html('The confirmation time is unknown.
However we recommend a gas price of $' + parseFloat(fast_data['usd']).toFixed(2)); - $('#default-recommended-gas').data('amount-usd', parseFloat(fast_data['usd']).toFixed(2)); - $('#gasPriceRecommended').val($('#average-recommended-gas').data('amount')); - $('#slow-recommended-gas').hide(); - $('#average-recommended-gas').hide(); - $('#fast-recommended-gas').hide(); - let new_gas_price = Math.round($('#average-recommended-gas').data('amount') * 10) / 10; - - $('#gasPrice').val(new_gas_price); - $('#gas-usd').html('$' + parseFloat(fast_data['usd']).toFixed(2)); - $('#gas-eth').html(avg_data['eth'] + 'ETH'); - } else if (slow_data && slow_data['time'] < 20 && parseFloat($('#slow-recommended-gas').data('amount')) < 2) { - $('#slow-recommended-gas').hide(); - $('#default-recommended-gas').hide(); - $('#average-recommended-gas').hide(); - $('#fast-recommended-gas').show(); - $('.gas-rates .message').html('Good news! The network is pretty fast right now').show(); - $('#fast-recommended-gas').html('Fast $' + parseFloat(fast_data['usd']).toFixed(2) + ' ~' + fast_data['time'] + ' minutes').addClass('active'); - $('#fast-recommended-gas').data('amount-usd', parseFloat(fast_data['usd']).toFixed(2)); - $('#fast-recommended-gas').parent().removeClass('justify-content-between').addClass('justify-content-around'); - let new_gas_price = Math.round($('#average-recommended-gas').data('amount') * 10) / 10; - - $('#gasPrice').val(new_gas_price); - $('#gas-usd').html('$' + parseFloat(fast_data['usd']).toFixed(2)); - $('#gas-eth').html(fast_data['eth'] + 'ETH'); - } else { - $('#fast-recommended-gas').parent().addClass('justify-content-between').removeClass('justify-content-around'); - let new_gas_price = Math.round($('#average-recommended-gas').data('amount') * 10) / 10; - - $('#gasPrice').val(new_gas_price); - $('#gas-usd').html('$' + parseFloat(avg_data['usd']).toFixed(2)); - $('#gas-eth').html(avg_data['eth'] + 'ETH'); - } - - // Slow recommendation prefills - $('#slow-recommended-gas').html('Slow $' + parseFloat(slow_data['usd']).toFixed(2) + ' ~' + slow_data['time'] + ' minutes'); - $('#slow-recommended-gas').data('amount-usd', parseFloat(slow_data['usd']).toFixed(2)); - - // Avg recommendation prefills - $('#average-recommended-gas').html('Average $' + parseFloat(avg_data['usd']).toFixed(2) + ' ~' + avg_data['time'] + ' minutes'); - $('#average-recommended-gas').data('amount-usd', parseFloat(avg_data['usd']).toFixed(2)); - - // Fast recommendation prefills - $('#fast-recommended-gas').html('Fast $' + parseFloat(fast_data['usd']).toFixed(2) + ' ~' + fast_data['time'] + ' minutes'); - $('#fast-recommended-gas').data('amount-usd', parseFloat(fast_data['usd']).toFixed(2)); -} diff --git a/app/assets/v2/js/shared.js b/app/assets/v2/js/shared.js index 00b7866fe88..6639850e14c 100644 --- a/app/assets/v2/js/shared.js +++ b/app/assets/v2/js/shared.js @@ -91,65 +91,6 @@ var reloadCbAddress = function() { reloadCbAddress(); -var update_metamask_conf_time_and_cost_estimate = function() { - var confTime = 'unknown'; - var ethAmount = 'unknown'; - var usdAmount = 'unknown'; - - var gasLimit = parseInt($('#gasLimit').val()); - var gasPrice = parseFloat($('#gasPrice').val()); - - if (gasPrice) { - var eth_amount_unrounded = gasLimit * gasPrice / Math.pow(10, 9); - - ethAmount = Math.round(1000000 * eth_amount_unrounded) / 1000000; - usdAmount = Math.round(1000 * eth_amount_unrounded * document.eth_usd_conv_rate) / 1000; - } - - if (typeof document.conf_time_spread == 'undefined') return; - - for (var i = 0; i < document.conf_time_spread.length - 1; i++) { - var this_ele = (document.conf_time_spread[i]); - var next_ele = (document.conf_time_spread[i + 1]); - - if (gasPrice <= parseFloat(next_ele[0]) && gasPrice > parseFloat(this_ele[0])) { - confTime = Math.round(10 * next_ele[1]) / 10; - } - } - - $('#ethAmount').html(ethAmount); - $('#usdAmount').html(usdAmount); - $('#confTime').html(confTime); -}; - -var get_updated_metamask_conf_time_and_cost = function(gasPrice) { - - var confTime = 'unknown'; - var ethAmount = 'unknown'; - var usdAmount = 'unknown'; - - var gasLimit = parseInt($('#gasLimit').val()); - - if (gasPrice) { - var eth_amount_unrounded = gasLimit * gasPrice / Math.pow(10, 9); - - ethAmount = Math.round(1000000 * eth_amount_unrounded) / 1000000; - usdAmount = Math.round(100 * eth_amount_unrounded * document.eth_usd_conv_rate) / 100; - } - - if (typeof document.conf_time_spread == 'undefined') return; - - for (var i = 0; i < document.conf_time_spread.length - 1; i++) { - var this_ele = (document.conf_time_spread[i]); - var next_ele = (document.conf_time_spread[i + 1]); - - if (gasPrice <= parseFloat(next_ele[0]) && gasPrice > parseFloat(this_ele[0])) { - confTime = Math.round(10 * next_ele[1]) / 10; - } - } - - return {'eth': ethAmount, 'usd': usdAmount, 'time': confTime}; -}; var unloading_button = function(button) { button.prop('disabled', false); diff --git a/app/dashboard/templates/bounty/cancel.html b/app/dashboard/templates/bounty/cancel.html index 5d77346f92e..b01a3d4ab6b 100644 --- a/app/dashboard/templates/bounty/cancel.html +++ b/app/dashboard/templates/bounty/cancel.html @@ -139,12 +139,6 @@
{% trans "Reason" %}
{% include 'shared/bounty_actions_hidden_vars.html' %} - {% if is_bounties_network %} -
- {% include 'shared/wallet_estimate.html' %} -
- {% endif %} -
@@ -178,7 +172,6 @@
{% trans "Reason" %}
{% if is_bounties_network %} - diff --git a/app/dashboard/templates/bounty/fulfill.html b/app/dashboard/templates/bounty/fulfill.html index 3ccf5228bdf..284f2a80b29 100644 --- a/app/dashboard/templates/bounty/fulfill.html +++ b/app/dashboard/templates/bounty/fulfill.html @@ -117,11 +117,9 @@

{% trans "Submit Work" %}

{% include 'shared/rating.html' with counterparty='contributor' id='str' data='true' label="Rate this funder"%} + {% if is_bounties_network %} -
- {% include 'shared/bounty_actions_hidden_vars.html' %} - {% include 'shared/wallet_estimate.html' %} -
+ {% include 'shared/bounty_actions_hidden_vars.html' %} {% endif %}
@@ -179,7 +177,6 @@

{% trans "Submit Work" %}

{% if is_bounties_network %} - diff --git a/app/dashboard/templates/bounty/fund.html b/app/dashboard/templates/bounty/fund.html index 329c73fddb8..cb201bf459f 100644 --- a/app/dashboard/templates/bounty/fund.html +++ b/app/dashboard/templates/bounty/fund.html @@ -241,12 +241,9 @@
Gitcoin Core, will be able to take my funds or change this information.{% endblocktrans %}
-
-
{% trans "Gas Settings" %}
-
- {% include 'shared/bounty_actions_hidden_vars.html' %} - {% include 'shared/wallet_estimate.html' %} -
+ +
+ {% include 'shared/bounty_actions_hidden_vars.html' %}
@@ -349,7 +346,6 @@

- diff --git a/app/dashboard/templates/bounty/increase.html b/app/dashboard/templates/bounty/increase.html index eb74f1c237e..f01ded7ee99 100644 --- a/app/dashboard/templates/bounty/increase.html +++ b/app/dashboard/templates/bounty/increase.html @@ -83,9 +83,6 @@

{% trans "Increase Bounty" %}

-
- {% include 'shared/wallet_estimate.html' %} -
{% if FEE_PERCENTAGE != 0 %}
{% trans "No Surprises" %}
@@ -181,7 +178,6 @@
{% trans "Total"%}
{% endif %} - diff --git a/app/dashboard/templates/bulk_payout_bounty.html b/app/dashboard/templates/bulk_payout_bounty.html index ae3b1dc4abd..21b298f3e96 100644 --- a/app/dashboard/templates/bulk_payout_bounty.html +++ b/app/dashboard/templates/bulk_payout_bounty.html @@ -227,10 +227,8 @@
{% trans 'Payout Prev
-
- {% include 'shared/bounty_actions_hidden_vars.html' %} - {% include 'shared/wallet_estimate.html' %} -
+ {% include 'shared/bounty_actions_hidden_vars.html' %} +
@@ -257,7 +255,6 @@
{% trans 'Payout Prev {% include 'shared/footer.html' %} - diff --git a/app/dashboard/templates/process_bounty.html b/app/dashboard/templates/process_bounty.html index 5d0eac8d84f..ccdb4c040d2 100644 --- a/app/dashboard/templates/process_bounty.html +++ b/app/dashboard/templates/process_bounty.html @@ -110,10 +110,7 @@

Suggested Kudos

{% include 'shared/add_kudos.html' with name='kudos-search' keywords=bounty.keywords %} -
- {% include 'shared/bounty_actions_hidden_vars.html' %} - {% include 'shared/wallet_estimate.html' %} -
+ {% include 'shared/bounty_actions_hidden_vars.html' %}
@@ -172,7 +169,6 @@

Suggested Kudos

$('[data-toggle="popover"]').popover() $('[data-toggle="tooltip"]').bootstrapTooltip(); - diff --git a/app/dashboard/templates/shared/wallet_estimate.html b/app/dashboard/templates/shared/wallet_estimate.html deleted file mode 100644 index dfdea9a809f..00000000000 --- a/app/dashboard/templates/shared/wallet_estimate.html +++ /dev/null @@ -1,78 +0,0 @@ -{% comment %} - Copyright (C) 2020 Gitcoin Core - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -{% endcomment %} -{% load i18n static %} - -
- Set my own gas price -
-
- {% if recommend_gas_price > 30 %} -
{% trans "Warning: the ethereum network is quite congested at the moment." %} [{% trans "Stats" %}]
- {% endif %} - {% include 'shared/gas_advisories.html' %} - - -
- - -
-
- - -
- -
- \ No newline at end of file diff --git a/app/grants/templates/grants/cancel.html b/app/grants/templates/grants/cancel.html index 8f55c1aadc2..f17ea088658 100644 --- a/app/grants/templates/grants/cancel.html +++ b/app/grants/templates/grants/cancel.html @@ -70,12 +70,6 @@

Cancel Contribution for {{ grant.title }}

{% csrf_token %} -
-
{% trans "Gas Settings" %}
-
- {% include 'shared/wallet_estimate.html' %} -
-
@@ -107,7 +101,6 @@
{% trans "Gas Settings" %}
{% include 'shared/footer.html' %} {% include 'grants/shared/shared_scripts.html' %} - diff --git a/app/grants/templates/grants/detail/info.html b/app/grants/templates/grants/detail/info.html index dfe46b5e851..c3bc7fd2c7c 100644 --- a/app/grants/templates/grants/detail/info.html +++ b/app/grants/templates/grants/detail/info.html @@ -336,12 +336,6 @@

{% trans "Are you sure you want to cancel this grant?" %}
  • {% trans "Once cancelled, it is " %}{% trans "not possible to restart the grant, " %}{% trans "as the smart contract will be destroyed." %}
  • {% trans "To relaunch the grant, you need to create a new grant." %}

    -
    -
    {% trans "Gas Settings" %}
    -
    - {% include 'shared/wallet_estimate.html' %} -
    -
    -
    -
    -
    -
    {% trans "Gas Settings" %}
    -
    - {% include 'shared/wallet_estimate.html' %} -
    -
    -
    -
    -

    Summary

    @@ -413,7 +402,6 @@
    {% trans "Gas Settings" %}
    - diff --git a/app/grants/templates/grants/new.html b/app/grants/templates/grants/new.html index c522e612981..c284d595210 100644 --- a/app/grants/templates/grants/new.html +++ b/app/grants/templates/grants/new.html @@ -156,12 +156,6 @@
    Contract Deployment

    - Because subscription support is so important to provide recurring income to Gitcoin Grantees, Each Grant is an EIP 1337 compatible smart contract! Gitcoin's implementation of EIP 1337 has been audited by smart contract auditors to enable trustless & secure on-chain subscriptions - Learn More Here

    -
    -
    {% trans "Gas Settings" %}
    -
    - {% include 'shared/wallet_estimate.html' %} -
    -
    @@ -192,7 +186,6 @@
    {% trans "Gas Settings" %}
    {% include 'grants/shared/shared_scripts.html' %} - diff --git a/app/grants/templates/grants/newv0.html b/app/grants/templates/grants/newv0.html deleted file mode 100644 index 640a0edbdca..00000000000 --- a/app/grants/templates/grants/newv0.html +++ /dev/null @@ -1,163 +0,0 @@ -{% comment %} - Copyright (C) 2020 Gitcoin Core - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -{% endcomment %} -{% load static i18n %} - - - - {% include 'shared/head.html' with slim=1 %} - {% include 'shared/cards.html' %} - - - - - - - - {% include 'shared/tag_manager_2.html' %} -
    - {% include 'shared/top_nav.html' with class='d-md-flex' %} - {% include 'grants/nav.html' %} -
    -
    - {% include 'shared/no_metamask_error.html' %} - {% include 'shared/zero_balance_error.html' %} - {% include 'shared/unlock_metamask.html' %} - {% include 'shared/connect_metamask.html' %} -
    -
    -
    - - {% include 'grants/shared/waiting_state.html' %} - -
    -
    -
    - -
    -
    - -

    {% trans "Create a Grant" %}

    -

    - {% trans "We're excited to learn about your project." %} -
    - {% trans "Gitcoin Grants can help you accelerate your journey to funding." %} -
    - {% trans "Complete the form below to get started." %} -

    -
    -
    - - {% csrf_token %} -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - - -
    - - -
    - -
    - - {% trans "Drag & Drop or Browse" %} - -
    -
    - -
    -
    {% trans "Gas Settings" %}
    -
    - {% include 'shared/wallet_estimate.html' %} -
    -
    - - - -
    - - - - - - - - - -
    - -
    -
    -
    -
    -
    - - {% include 'shared/current_profile.html' %} - {% include 'shared/bottom_notification.html' %} - {% include 'shared/analytics.html' %} - {% include 'shared/footer_scripts.html' %} - {% include 'shared/footer.html' %} - {% include 'grants/shared/shared_scripts.html' %} - - - - - - - - - - - - - - - - - diff --git a/app/grants/urls.py b/app/grants/urls.py index da8d3493c35..4d6fba24de9 100644 --- a/app/grants/urls.py +++ b/app/grants/urls.py @@ -20,9 +20,8 @@ from django.urls import path, re_path from grants.views import ( - flag, grant_categories, grant_details, grant_fund, grant_new, grant_new_v0, grants, grants_addr_as_json, - grants_stats_view, invoice, leaderboard, new_matching_partner, predict_clr_v1, profile, quickstart, - subscription_cancel, + flag, grant_categories, grant_details, grant_fund, grant_new, grants, grants_addr_as_json, grants_stats_view, + invoice, leaderboard, new_matching_partner, predict_clr_v1, profile, quickstart, subscription_cancel, ) app_name = 'grants' @@ -34,7 +33,6 @@ path('/', grant_details, name='details'), path('//', grant_details, name='details2'), re_path(r'^new', grant_new, name='new'), - re_path(r'^old', grant_new_v0, name='old'), re_path(r'^categories', grant_categories, name='grant_categories'), path('//fund', grant_fund, name='fund'), path( diff --git a/app/grants/views.py b/app/grants/views.py index 5524d1dae9d..2ddf37f3740 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -681,88 +681,6 @@ def grant_new(request): } return TemplateResponse(request, 'grants/new.html', params) -@login_required -def grant_new_v0(request): - """Create a v0 version of a grant contract.""" - profile = get_profile(request) - - if request.method == 'POST': - if 'title' in request.POST: - logo = request.FILES.get('input_image', None) - receipt = json.loads(request.POST.get('receipt', '{}')) - team_members = request.POST.getlist('team_members[]') - - grant_kwargs = { - 'title': request.POST.get('title', ''), - 'description': request.POST.get('description', ''), - 'reference_url': request.POST.get('reference_url', ''), - 'admin_address': request.POST.get('admin_address', ''), - 'contract_owner_address': request.POST.get('contract_owner_address', ''), - 'token_address': request.POST.get('token_address', ''), - 'token_symbol': request.POST.get('token_symbol', ''), - 'contract_version': request.POST.get('contract_version', ''), - 'deploy_tx_id': request.POST.get('transaction_hash', ''), - 'network': request.POST.get('network', 'mainnet'), - 'metadata': receipt, - 'admin_profile': profile, - 'logo': logo, - } - grant = Grant.objects.create(**grant_kwargs) - - team_members = (team_members[0].split(',')) - team_members.append(profile.id) - team_members = list(set(team_members)) - - for i in range(0, len(team_members)): - team_members[i] = int(team_members[i]) - - grant.team_members.add(*team_members) - grant.save() - - return JsonResponse({ - 'success': True, - }) - - if 'contract_address' in request.POST: - tx_hash = request.POST.get('transaction_hash', '') - if not tx_hash: - return JsonResponse({ - 'success': False, - 'info': 'no tx hash', - 'url': None, - }) - - grant = Grant.objects.filter(deploy_tx_id=tx_hash).first() - grant.contract_address = request.POST.get('contract_address', '') - print(tx_hash, grant.contract_address) - grant.save() - record_grant_activity_helper('new_grant', grant, profile) - new_grant(grant, profile) - return JsonResponse({ - 'success': True, - 'url': reverse('grants:details', args=(grant.pk, grant.slug)) - }) - - - params = { - 'active': 'new_grant', - 'title': _('New Grant'), - 'card_desc': _('Provide sustainable funding for Open Source with Gitcoin Grants'), - 'profile': profile, - 'grant': {}, - 'keywords': get_keywords(), - 'recommend_gas_price': recommend_min_gas_price_to_confirm_in_time(4), - 'recommend_gas_price_slow': recommend_min_gas_price_to_confirm_in_time(120), - 'recommend_gas_price_avg': recommend_min_gas_price_to_confirm_in_time(15), - 'recommend_gas_price_fast': recommend_min_gas_price_to_confirm_in_time(1), - 'eth_usd_conv_rate': eth_usd_conv_rate(), - 'conf_time_spread': conf_time_spread(), - 'gas_advisories': gas_advisories(), - 'trusted_relayer': settings.GRANTS_OWNER_ACCOUNT - } - - return TemplateResponse(request, 'grants/newv0.html', params) - @login_required def grant_fund(request, grant_id, grant_slug): @@ -869,7 +787,7 @@ def grant_fund(request, grant_id, grant_slug): comment = request.POST.get('comment') if comment and activity: profile = request.user.profile - if subscription.negative: + if subscription and subscription.negative: profile = Profile.objects.filter(handle='gitcoinbot').first() comment = f"Comment from contributor: {comment}" comment = Comment.objects.create( @@ -1090,7 +1008,7 @@ def record_subscription_activity_helper(activity_type, subscription, profile): profile (dashboard.models.Profile): The current user's profile. """ - if subscription.negative: + if subscription and subscription.negative: profile = Profile.objects.filter(handle='gitcoinbot').first() activity_type = 'negative_contribution' try: diff --git a/app/marketing/mails.py b/app/marketing/mails.py index 10f6402c310..2911c6923c5 100644 --- a/app/marketing/mails.py +++ b/app/marketing/mails.py @@ -202,7 +202,7 @@ def new_grant(grant, profile): def new_supporter(grant, subscription): - if subscription.negative: + if subscription and subscription.negative: return from_email = settings.CONTACT_EMAIL to_email = grant.admin_profile.email @@ -221,7 +221,7 @@ def new_supporter(grant, subscription): def thank_you_for_supporting(grant, subscription): - if subscription.negative: + if subscription and subscription.negative: return from_email = settings.CONTACT_EMAIL to_email = subscription.contributor_profile.email @@ -240,7 +240,7 @@ def thank_you_for_supporting(grant, subscription): def support_cancellation(grant, subscription): - if subscription.negative: + if subscription and subscription.negative: return from_email = settings.CONTACT_EMAIL to_email = subscription.contributor_profile.email @@ -257,7 +257,7 @@ def support_cancellation(grant, subscription): def grant_cancellation(grant, subscription): - if subscription.negative: + if subscription and subscription.negative: return from_email = settings.CONTACT_EMAIL to_email = grant.admin_profile.email @@ -274,7 +274,7 @@ def grant_cancellation(grant, subscription): def subscription_terminated(grant, subscription): - if subscription.negative: + if subscription and subscription.negative: return from_email = settings.CONTACT_EMAIL to_email = subscription.contributor_profile.email @@ -291,7 +291,7 @@ def subscription_terminated(grant, subscription): def successful_contribution(grant, subscription, contribution): - if subscription.negative: + if subscription and subscription.negative: return from_email = settings.CONTACT_EMAIL to_email = subscription.contributor_profile.email @@ -828,7 +828,7 @@ def warn_account_out_of_eth(account, balance, denomination): def warn_subscription_failed(subscription): - if subscription.negative: + if subscription and subscription.negative: return to_email = settings.PERSONAL_CONTACT_EMAIL from_email = settings.SERVER_EMAIL