mirror of https://github.com/embarklabs/embark.git
fix: only show account warning when Geth will actually start
Before, we checked if the network was a testnet or mainnet and warned if there were no account sconfigured to sync. However, that didn't take into account that we could connect to an external node, hence not starting Geth at all. So to fix that, I moved the condition and message to the Geth module and only log when we start the node and the condition is met.
This commit is contained in:
parent
63831f6110
commit
f502650c17
|
@ -79,8 +79,6 @@ export class Config {
|
|||
|
||||
locale: string;
|
||||
|
||||
shownNoAccountConfigMsg = false; // flag to ensure "no account config" message is only displayed once to the user
|
||||
|
||||
corsParts: string[] = [];
|
||||
|
||||
providerUrl = '';
|
||||
|
@ -420,31 +418,6 @@ export class Config {
|
|||
this.blockchainConfig.isAutoEndpoint = true;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.shownNoAccountConfigMsg &&
|
||||
(/rinkeby|testnet|livenet/).test(this.blockchainConfig.networkType) &&
|
||||
!(this.blockchainConfig.accounts && this.blockchainConfig.accounts.find(acc => acc.password)) &&
|
||||
!this.blockchainConfig.isDev &&
|
||||
this.env !== 'development' && this.env !== 'test') {
|
||||
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;
|
||||
}
|
||||
|
||||
const accountDocsMessage = __('For more info, check the docs: %s', 'https://framework.embarklabs.io/docs/blockchain_accounts_configuration.html'.underline);
|
||||
if (this.blockchainConfig.account) {
|
||||
this.logger.error(__('The `account` config for the blockchain was removed. Please use `accounts` instead.'));
|
||||
|
|
|
@ -19,6 +19,7 @@ class Geth {
|
|||
this.isDev = options.isDev;
|
||||
this.events = embark.events;
|
||||
this.plugins = options.plugins;
|
||||
this.shownNoAccountConfigMsg = false; // flag to ensure "no account config" message is only displayed once to the user
|
||||
|
||||
if (!this.shouldInit()) {
|
||||
return;
|
||||
|
@ -33,6 +34,28 @@ class Geth {
|
|||
launchFn: (readyCb) => {
|
||||
this.events.request('processes:register', 'blockchain', {
|
||||
launchFn: (cb) => {
|
||||
if (!this.shownNoAccountConfigMsg &&
|
||||
(/rinkeby|testnet|livenet/).test(this.blockchainConfig.networkType) &&
|
||||
!(this.blockchainConfig.accounts && this.blockchainConfig.accounts.find(acc => acc.password)) &&
|
||||
!this.blockchainConfig.isDev && this.embark.env !== 'development' && this.embark.env !== 'test') {
|
||||
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.embark.env} > account\n\n`.italic +
|
||||
__('Please also make sure the keystore file for the account is located at: ') +
|
||||
'\n - Mac: ' + `~/Library/Ethereum/${this.embark.env}/keystore`.italic +
|
||||
'\n - Linux: ' + `~/.ethereum/${this.embark.env}/keystore`.italic +
|
||||
'\n - Windows: ' + `%APPDATA%\\Ethereum\\${this.embark.env}\\keystore`.italic) +
|
||||
__('\n\nAlternatively, you could change ' +
|
||||
`config/blockchain.js > ${this.embark.env} > networkType`.italic +
|
||||
__(' to ') +
|
||||
'"custom"\n'.italic).yellow
|
||||
);
|
||||
this.shownNoAccountConfigMsg = true;
|
||||
}
|
||||
this.startBlockchainNode(cb);
|
||||
},
|
||||
stopFn: (cb) => {
|
||||
|
|
Loading…
Reference in New Issue