feat(@embarkjs): Add console warning if using metamask and geth

Add console warning to inform user they may experience stuck transactions due to a known bug with geth caused by use with metamask. Embark can work around these struck transactions using regular transactions, however they must be enabled first.

The console warning includes a URL to the cockpit with the query string parameter included that enables the regular transactions.

Coincides with https://github.com/embark-framework/embark/pull/1220
This commit is contained in:
emizzle 2018-12-21 19:03:33 +11:00
parent 00ec6bc4f5
commit 930789f12a
1 changed files with 8 additions and 4 deletions

View File

@ -77,11 +77,15 @@ Blockchain.connect = function(connectionList, opts, doneCb) {
} }
}, function(_err, _connected) { }, function(_err, _connected) {
self.blockchainConnector.getAccounts((err, accounts) => { self.blockchainConnector.getAccounts((err, accounts) => {
if (opts.warnAboutMetamask) { const currentProv = self.blockchainConnector.getCurrentProvider();
const currentProv = self.blockchainConnector.getCurrentProvider(); if (opts.warnAboutMetamask && currentProv && currentProv.isMetaMask) {
if (currentProv && currentProv.isMetaMask) { // if we are using metamask, ask embark to turn on dev_funds
console.warn("%cNote: Embark has detected you are in the development environment and using Metamask, please make sure Metamask is connected to your local node", "font-size: 2em"); // embark will only do this if geth is our client and we are in
// dev mode
if(opts.blockchainClient === 'geth') {
console.warn("%cNote: There is a known issue with Geth that may cause transactions to get stuck when using Metamask. Please log in to the cockpit (http://localhost:8000/embark?enableRegularTxs=true) to enable a workaround. Once logged in, the workaround will automatically be enabled.", "font-size: 2em");
} }
console.warn("%cNote: Embark has detected you are in the development environment and using Metamask, please make sure Metamask is connected to your local node", "font-size: 2em");
} }
if (accounts) { if (accounts) {
self.blockchainConnector.setDefaultAccount(accounts[0]); self.blockchainConnector.setDefaultAccount(accounts[0]);