Skip to content

Commit

Permalink
migrate gitcoin from web3js 0.2 to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Usman committed Oct 18, 2018
1 parent 13bc312 commit f64c17f
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions app/assets/v2/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,29 +824,34 @@ var listen_for_web3_changes = function() {
document.listen_for_web3_iterations += 1;
}

if (typeof web3 == 'undefined') {
currentNetwork();
trigger_form_hooks();
} else if (typeof web3 == 'undefined' || typeof web3.eth == 'undefined' || typeof web3.eth.coinbase == 'undefined' || !web3.eth.coinbase) {
currentNetwork('locked');
trigger_form_hooks();
} else {
web3.eth.getBalance(web3.eth.coinbase, function(errors, result) {
if (typeof result != 'undefined') {
document.balance = result.toNumber();
}
});

web3.version.getNetwork(function(error, netId) {
if (error) {
currentNetwork();
} else {
var network = getNetwork(netId);

currentNetwork(network);
trigger_form_hooks();
}
});
if (typeof web3 !== 'undefined') {
if (typeof web3.currentProvider.isMetaMask == 'undefined') {
currentNetwork();
trigger_form_hooks();
} else {
web3.eth.getAccounts(function(error, accounts) {
if (accounts.length == 0) {
currentNetwork('locked');
trigger_form_hooks();
} else {
web3.eth.net.getNetworkType().then(function(callback, error) {
if (error) {
currentNetwork();
} else {
currentNetwork(callback);
trigger_form_hooks();
}
});
}
});
}
/*else {
web3.eth.getBalance(web3.eth.coinbase, function(errors, result) {
if (typeof result != 'undefined') {
document.balance = result.toNumber();
}
});
*/
}
};

Expand Down

0 comments on commit f64c17f

Please sign in to comment.