diff --git a/lib/core/config.js b/lib/core/config.js index 514fa29e..e00bde46 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -24,6 +24,7 @@ var Config = function(options) { this.events = options.events; this.embarkConfig = {}; this.context = options.context || [constants.contexts.any]; + this.shownNoAccountConfigMsg = false; // flag to ensure "no account config" message is only displayed once to the user self.events.setCommandHandler("config:contractsConfig", (cb) => { cb(self.contractsConfig); @@ -183,13 +184,30 @@ Config.prototype.loadBlockchainConfigFile = function() { if (!configFilePath) { this.blockchainConfig.default = true; } - if (!this.blockchainConfig.account && !this.blockchainConfig.isDev && + if ( + !this.shownNoAccountConfigMsg && + (/rinkeby|testnet|livenet/).test(this.blockchainConfig.networkType) && + !(this.blockchainConfig.account && this.blockchainConfig.account.address && this.blockchainConfig.account.password) && + !this.blockchainConfig.isDev && this.env !== 'development' && this.env !== 'test') { - this.logger.warn( - __('Account settings are needed for this chain.' + - ' Please put a valid address and possibly a password in your blockchain config or use a dev chain.') - ); - } + this.logger.warn(( + '\n=== ' + __('Cannot unlock account - account config missing').bold + ' ===\n' + + __('Geth is configured to sync to a testnet/livenet and needs to unlock an account ' + + 'to allow your dApp to interact with geth, however, the address and password must ' + + 'be specified in your blockchain config. Please update your blockchain config with ' + + 'a valid address and password: \n') + + ` - config/blockchain.js > ${this.env} > account\n\n`.italic + + __('Please also make sure the keystore file for the account is located at: ') + + '\n - Mac: ' + `~/Library/Ethereum/${this.env}/keystore`.italic + + '\n - Linux: ' + `~/.ethereum/${this.env}/keystore`.italic + + '\n - Windows: ' + `%APPDATA%\Ethereum/${this.env}/keystore`.italic) + + __('\n\nAlternatively, you could change ' + + `config/blockchain.js > ${this.env} > networkType`.italic + + __(' to ') + + '"custom"\n'.italic).yellow + ); + this.shownNoAccountConfigMsg = true; + } }; Config.prototype.loadContractsConfigFile = function() {