diff --git a/app/assets/v2/js/pages/bounty_details.js b/app/assets/v2/js/pages/bounty_details.js index 6d5e0a7660b..231e9518aae 100644 --- a/app/assets/v2/js/pages/bounty_details.js +++ b/app/assets/v2/js/pages/bounty_details.js @@ -560,40 +560,40 @@ var showWarningMessage = function(txid) { }; // refresh page if metamask changes -waitforWeb3(function() { - setInterval(function() { - if (document.web3Changed) { - return; - } - reloadCbAddress(); - - if (typeof document.lastWeb3Network == 'undefined') { - document.lastWeb3Network = document.web3network; - return; - } - - if (typeof document.lastCoinbase == 'undefined') { - - web3.eth.getCoinbase(function(error, coinbase) { - if (error) { - console.log('web3.eth.coinbase could not be loaded'); - document.lastCoinbase = null; - return; - } - document.lastCoinbase = coinbase; - }); - return; - } - - if (web3 && (document.lastCoinbase != cb_address) || - (document.lastWeb3Network != document.web3network)) { - _alert(gettext('Detected a web3 change. Refreshing the page. '), 'info'); - document.location.reload(); - document.web3Changed = true; - } - - }, 500); -}); +// waitforWeb3(function() { +// setInterval(function() { +// if (document.web3Changed) { +// return; +// } +// reloadCbAddress(); + +// if (typeof document.lastWeb3Network == 'undefined') { +// document.lastWeb3Network = document.web3network; +// return; +// } + +// if (typeof document.lastCoinbase == 'undefined') { + +// web3.eth.getCoinbase(function(error, coinbase) { +// if (error) { +// console.log('web3.eth.coinbase could not be loaded'); +// document.lastCoinbase = null; +// return; +// } +// document.lastCoinbase = coinbase; +// }); +// return; +// } + +// if (web3 && (document.lastCoinbase != cb_address) || +// (document.lastWeb3Network != document.web3network)) { +// _alert(gettext('Detected a web3 change. Refreshing the page. '), 'info'); +// document.location.reload(); +// document.web3Changed = true; +// } + +// }, 500); +// }); var wait_for_tx_to_mine_and_then_ping_server = function() { console.log('checking for updates'); diff --git a/app/assets/v2/js/pages/fulfill_bounty/index.js b/app/assets/v2/js/pages/fulfill_bounty/index.js index 74afdc285c6..d516d60975a 100644 --- a/app/assets/v2/js/pages/fulfill_bounty/index.js +++ b/app/assets/v2/js/pages/fulfill_bounty/index.js @@ -45,6 +45,6 @@ window.onload = function() { const fetchFromWeb3Wallet = () => { web3.eth.getAccounts(function(_, accounts) { $('#payoutAddress').val(accounts[0]); - $('#payoutAddress').attr('disabled', true); + $('#payoutAddress').attr('readonly', true); }); } diff --git a/app/assets/v2/js/pages/kudos_send.js b/app/assets/v2/js/pages/kudos_send.js index de683957f92..b62f96a7af5 100644 --- a/app/assets/v2/js/pages/kudos_send.js +++ b/app/assets/v2/js/pages/kudos_send.js @@ -446,7 +446,7 @@ function sendKudos(email, github_url, from_name, username, amountInEth, comments if ($('.redemptions select').length) { num_redemptions = $('.redemptions select').val(); } - + web3.eth.getCoinbase(function(_, account) { var formbody = { username: username, @@ -644,7 +644,7 @@ function sendKudos(email, github_url, from_name, username, amountInEth, comments // web3.currentProvider.publicConfigStore.on('update', function(e) { var error; -if (window.ethereum.publicConfigStore) { +if (window.ethereum && window.ethereum.publicConfigStore) { window.ethereum.publicConfigStore.on('update', checkNetwork); } function checkNetwork(e) { diff --git a/app/assets/v2/js/shared.js b/app/assets/v2/js/shared.js index 6639850e14c..90ae78e3930 100644 --- a/app/assets/v2/js/shared.js +++ b/app/assets/v2/js/shared.js @@ -81,6 +81,7 @@ var reloadCbAddress = function() { return; } web3.eth.getCoinbase(function(error, result) { + // console.log(error, result) if (!error) { cb_address = result; } else { @@ -91,6 +92,51 @@ var reloadCbAddress = function() { reloadCbAddress(); +const Web3Modal = window.Web3Modal.default; + +window.Web3Modal.providers.push({ + id: 'injected', + name: 'QRcode', + logo: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='512' height='512' fill='none'%3E%3Cpath fill='url(%23paint0_radial)' fill-rule='evenodd' d='M256 0c141.385 0 256 114.615 256 256S397.385 512 256 512 0 397.385 0 256 114.615 0 256 0z' clip-rule='evenodd'/%3E%3Cpath fill='%23fff' d='M165 243v-78h78v78h-78zm16.25-61.75v45.5h45.5v-45.5h-45.5zM269 165h78v78h-78v-78zm61.75 61.75v-45.5h-45.5v45.5h45.5zM165 347v-78h78v78h-78zm16.25-61.75v45.5h45.5v-45.5h-45.5zm13 13h19.5v19.5h-19.5v-19.5zm0-104h19.5v19.5h-19.5v-19.5zm123.5 19.5h-19.5v-19.5h19.5v19.5zM334 269h13v52h-52v-13h-13v39h-13v-78h39v13h26v-13zm0 65h13v13h-13v-13zm-26 0h13v13h-13v-13z'/%3E%3Cdefs%3E%3CradialGradient id='paint0_radial' cx='0' cy='0' r='1' gradientTransform='translate(9.283 256) scale(502.717)' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%237C89FF'/%3E%3Cstop offset='1' stop-color='%231E34FF'/%3E%3C/radialGradient%3E%3C/defs%3E%3C/svg%3E", + type: 'injected', + check: 'isQRcode', + styled: { + noShadow: true + } +}); + +// Determine if we're on prod or not +const isProd = document.location.href.startsWith('https://gitcoin.co'); +const formaticKey = isProd ? document.contxt['fortmatic_live_key'] : document.contxt['fortmatic_test_key']; +const providerOptions = { + authereum: { + 'package': Authereum + }, + fortmatic: { + 'package': Fortmatic, + options: { + key: formaticKey + } + } +}; +const network = isProd ? 'mainnet' : 'rinkeby'; + +const web3Modal = new Web3Modal({ + network, + cacheProvider: true, + providerOptions +}); + +// const provider = await web3Modal.connect(); +function qrcodeConnect() { + localStorage['WEB3_CONNECT_CACHED_PROVIDER'] = '"injected"'; + web3Modal.toggleModal(); +} + +web3Modal.providers.push({name: 'QRcode', onClick: qrcodeConnect}); +web3Modal.connect().then(function(provider) { + window.web3 = new Web3(provider); +}); var unloading_button = function(button) { button.prop('disabled', false); @@ -1018,60 +1064,6 @@ var actions_page_warn_if_not_on_same_network = function() { attach_change_element_type(); -Web3Modal.providers.push({ - id: 'injected', - name: 'QRcode', - logo: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='512' height='512' fill='none'%3E%3Cpath fill='url(%23paint0_radial)' fill-rule='evenodd' d='M256 0c141.385 0 256 114.615 256 256S397.385 512 256 512 0 397.385 0 256 114.615 0 256 0z' clip-rule='evenodd'/%3E%3Cpath fill='%23fff' d='M165 243v-78h78v78h-78zm16.25-61.75v45.5h45.5v-45.5h-45.5zM269 165h78v78h-78v-78zm61.75 61.75v-45.5h-45.5v45.5h45.5zM165 347v-78h78v78h-78zm16.25-61.75v45.5h45.5v-45.5h-45.5zm13 13h19.5v19.5h-19.5v-19.5zm0-104h19.5v19.5h-19.5v-19.5zm123.5 19.5h-19.5v-19.5h19.5v19.5zM334 269h13v52h-52v-13h-13v39h-13v-78h39v13h26v-13zm0 65h13v13h-13v-13zm-26 0h13v13h-13v-13z'/%3E%3Cdefs%3E%3CradialGradient id='paint0_radial' cx='0' cy='0' r='1' gradientTransform='translate(9.283 256) scale(502.717)' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%237C89FF'/%3E%3Cstop offset='1' stop-color='%231E34FF'/%3E%3C/radialGradient%3E%3C/defs%3E%3C/svg%3E", - type: 'injected', - check: 'isQRcode', - styled: { - noShadow: true - } -}); - - -$(document).ready(function() { - // Don't prompt user if they are not logged in - if (!document.contxt.github_handle) { - return; - } - // const Web3Modal = window.Web3Modal.default; - const Web3Modal = window.Web3Modal.default; - // Determine if we're on prod or not - const isProd = document.location.href.startsWith('https://gitcoin.co'); - const formaticKey = isProd ? document.contxt['fortmatic_live_key'] : document.contxt['fortmatic_test_key']; - const providerOptions = { - authereum: { - 'package': Authereum - }, - fortmatic: { - 'package': Fortmatic, - options: { - key: formaticKey - } - } - }; - const network = isProd ? 'mainnet' : 'rinkeby'; - - window.web3Modal = new Web3Modal({ - network, - cacheProvider: true, - providerOptions - }); - - // const provider = await web3Modal.connect(); - function qrcodeConnect() { - localStorage['WEB3_CONNECT_CACHED_PROVIDER'] = '"injected"'; - web3Modal.toggleModal(); - } - - window.web3Modal.providers.push({name: 'QRcode', onClick: qrcodeConnect}); - web3Modal.connect().then(function(provider) { - window.web3 = new Web3(provider); - }); - -}); - var setUsdAmount = function() { const amount = $('input[name=amount]').val(); const denomination = $('#token option:selected').text(); diff --git a/app/dashboard/templates/profiles/profile.html b/app/dashboard/templates/profiles/profile.html index 5846c03b5c0..cc596ebad9f 100644 --- a/app/dashboard/templates/profiles/profile.html +++ b/app/dashboard/templates/profiles/profile.html @@ -122,6 +122,7 @@ + + +{% if not ignore_inject_web3 %} + {% include 'shared/shared_scripts.html' %} +{% endif %} {% if env == 'prod' %} @@ -65,6 +68,7 @@ + {% if vue %} {% endif %} @@ -73,11 +77,6 @@ {% endif %} -{% if not ignore_inject_web3 %} - {% include 'shared/shared_scripts.html' %} -{% endif %} - - +{% if not ignore_inject_web3 %} + {% include 'shared/shared_scripts.html' %} +{% endif %} {% if env == 'prod' %} @@ -60,9 +63,6 @@ -{% if not ignore_inject_web3 %} - {% include 'shared/shared_scripts.html' %} -{% endif %} + diff --git a/scripts/debug/hackathon_export.py b/scripts/debug/hackathon_export.py index daa6e8f1ba0..d40ffab7f49 100644 --- a/scripts/debug/hackathon_export.py +++ b/scripts/debug/hackathon_export.py @@ -1,5 +1,6 @@ from dashboard.models import Bounty, HackathonEvent + # bounty data export script for electric capital print("hackathon name, start date, end date, bounty_created, bounty url, bounty title, bounty amount, bounty token, contributors, github_issue, fulfiller_name, fulfiller_pr") for bounty in Bounty.objects.current().filter(idx_status='done'):