Skip to content

Commit

Permalink
Merge branch 'master' into purge
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc authored May 14, 2020
2 parents 3b7753f + 144365c commit fc15b1e
Show file tree
Hide file tree
Showing 13 changed files with 387 additions and 103 deletions.
68 changes: 34 additions & 34 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/pages/fulfill_bounty/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
4 changes: 2 additions & 2 deletions app/assets/v2/js/pages/kudos_send.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
100 changes: 46 additions & 54 deletions app/assets/v2/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ var reloadCbAddress = function() {
return;
}
web3.eth.getCoinbase(function(error, result) {
// console.log(error, result)
if (!error) {
cb_address = result;
} else {
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions app/dashboard/templates/profiles/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<script src="{% static "v2/js/lib/jitsi.js" %}"></script>
<script src="{% static "v2/js/activity.js" %}"></script>
<script src="{% static "v2/js/3box.min.js" %}"></script>
<script src="{% static "v2/js/user_card.js" %}"></script>
<script>
{% if profile.preferred_payout_address %}
document.hasPreferredPayoutAddress = true;
Expand Down
Loading

0 comments on commit fc15b1e

Please sign in to comment.