Skip to content

Commit

Permalink
Merge pull request #602 from near/fix/message-about-wrong-network
Browse files Browse the repository at this point in the history
Account not found error logic changed
  • Loading branch information
vgrichina committed Nov 17, 2020
2 parents 3191fac + 033f24f commit 31c93c4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions utils/inspect-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ const util = require('util');
const checkForAccDoesNotExist = (error, options) => {
if(!String(error).includes('does not exist while viewing')) return false;

const suffixesToNetworks = {near:'mainnet', testnet:'testnet', betanet:'betanet'};

const currentNetwork = config.helperAccount;
console.log(chalk`\n{bold.red Account {bold.white ${options.accountId}} is not found in {bold.white ${currentNetwork}} network.\n}`);
console.log(chalk`\n{bold.red Account {bold.white ${options.accountId}} is not found in {bold.white ${suffixesToNetworks[currentNetwork]}}\n}`);

const accSuffix = String(options.accountId).match('[^.]*$')[0];
if (currentNetwork != accSuffix && (accSuffix == 'betanet' || accSuffix == 'testnet')) {
console.log(chalk`{bold.white Use export NEAR_ENV=${accSuffix} to use ${accSuffix} accounts. \n}`);
const accNetwork = suffixesToNetworks[accSuffix];
if (currentNetwork != accSuffix && accNetwork) {
console.log(chalk`{bold.white Use export NEAR_ENV=${accNetwork} to use ${accNetwork} accounts. \n}`);
}

return true;
Expand Down

0 comments on commit 31c93c4

Please sign in to comment.