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

catch infura/metamask errors before they alert sentry #5113

Merged
merged 3 commits into from
Sep 4, 2019
Merged
Changes from 1 commit
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
51 changes: 32 additions & 19 deletions app/assets/v2/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,30 +923,43 @@ var listen_for_web3_changes = async function() {
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) {
} else if (typeof web3.eth == 'undefined') {
currentNetwork('locked');
trigger_form_hooks();
} else {
is_metamask_unlocked = true;
web3.eth.getBalance(web3.eth.coinbase, function(errors, result) {
if (errors) {
return;
}
if (typeof result != 'undefined' && result !== null) {
document.balance = result.toNumber();
}
});
var cb;
try {
// invoke infura synchronous call, if it fails metamask is locked
cb = web3.eth.coinbase;
} catch (error) {
// catch error so sentry doesn't alert on metamask call failure
console.log('web3.eth.coinbase could not be loaded');
}
if (typeof cb == 'undefined' || !cb) {
currentNetwork('locked');
trigger_form_hooks();
} else {
is_metamask_unlocked = true;
web3.eth.getBalance(web3.eth.coinbase, function(errors, result) {
if (errors) {
return;
}
if (typeof result != 'undefined' && result !== null) {
document.balance = result.toNumber();
}
});

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

currentNetwork(network);
trigger_form_hooks();
}
});
currentNetwork(network);
trigger_form_hooks();
}
});
}
}
}

Expand Down