Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
Merge 85def8a into 12497b3
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarcia360 committed May 26, 2020
2 parents 12497b3 + 85def8a commit b231524
Show file tree
Hide file tree
Showing 47 changed files with 294 additions and 252 deletions.
6 changes: 3 additions & 3 deletions src/commands/account/aggregatebonded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { command, metadata } from 'clime';

import { AccountTransactionsCommand, AccountTransactionsOptions } from '../../interfaces/account.transactions.command';
import { AddressResolver } from '../../resolvers/address.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';
import { TransactionView } from '../../views/transactions/details/transaction.view';

@command({
Expand All @@ -45,12 +45,12 @@ export default class extends AccountTransactionsCommand {
});

if (!transactions.length) {
console.log("There aren't aggregate bonded transaction");
console.log(FormatterService.error("There aren't aggregate bonded transaction"));
}
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/account/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*
*/
import chalk from 'chalk';
import { command, metadata, option } from 'clime';
import { MnemonicPassPhrase } from 'symbol-hd-wallets';
import { Account } from 'symbol-sdk';
Expand All @@ -36,6 +35,7 @@ import { ProfileNameResolver } from '../../resolvers/profile.resolver';
import { SaveResolver } from '../../resolvers/save.resolver';
import { URLResolver } from '../../resolvers/url.resolver';
import { DerivationService } from '../../services/derivation.service';
import { FormatterService } from '../../services/formatter.service';

export class CommandOptions extends CreateProfileOptions {
@option({
Expand Down Expand Up @@ -110,6 +110,6 @@ export default class extends CreateProfileCommand {
}

console.log(AccountCredentialsTable.createFromProfile(profile, password).toString());
console.log(chalk.green('\nStored ' + name + ' profile'));
console.log(FormatterService.success('Stored ' + name + ' profile'));
}
}
6 changes: 3 additions & 3 deletions src/commands/account/incoming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { command, metadata } from 'clime';

import { AccountTransactionsCommand, AccountTransactionsOptions } from '../../interfaces/account.transactions.command';
import { AddressResolver } from '../../resolvers/address.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';
import { TransactionView } from '../../views/transactions/details/transaction.view';

@command({
Expand All @@ -45,12 +45,12 @@ export default class extends AccountTransactionsCommand {
});

if (!transactions.length) {
console.log("There aren't incoming transaction");
console.log(FormatterService.error("There aren't incoming transaction"));
}
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
30 changes: 13 additions & 17 deletions src/commands/account/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*
*/
import chalk from 'chalk';
import * as Table from 'cli-table3';
import { HorizontalTable } from 'cli-table3';
import { command, metadata, option } from 'clime';
Expand All @@ -26,7 +25,7 @@ import { AccountInfo, MosaicAmountView, MosaicService, MultisigAccountInfo, Publ
import { ProfileCommand } from '../../interfaces/profile.command';
import { ProfileOptions } from '../../interfaces/profile.options';
import { AddressResolver } from '../../resolvers/address.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';

export class CommandOptions extends ProfileOptions {
@option({
Expand Down Expand Up @@ -55,8 +54,8 @@ export class AccountInfoTable {

toString(): string {
let text = '';
text += '\n' + chalk.green('Account Information') + '\n';
text += this.table.toString();
text += '\n' + FormatterService.title('Account Information');
text += '\n' + this.table.toString();
return text;
}
}
Expand Down Expand Up @@ -86,8 +85,8 @@ export class BalanceInfoTable {
toString(): string {
let text = '';
if (this.table) {
text += '\n' + chalk.green('Balance Information') + '\n';
text += this.table.toString();
text += '\n' + FormatterService.title('Balance Information');
text += '\n' + this.table.toString();
}
return text;
}
Expand Down Expand Up @@ -131,14 +130,14 @@ export class MultisigInfoTable {
toString(): string {
let text = '';
if (this.multisigTable) {
text += chalk.green('\n' + 'Multisig Account Information') + '\n';
text += FormatterService.title('Multisig Account Information');
text += this.multisigTable.toString();
text += chalk.green('\n' + 'Cosignatories') + '\n';
text += this.cosignatoriesTable.toString();
text += FormatterService.title('Cosignatories');
text += '\n' + this.cosignatoriesTable.toString();
}
if (this.cosignatoryOfTable) {
text += chalk.green('\n' + 'Is cosignatory of') + '\n';
text += this.cosignatoryOfTable.toString();
text += FormatterService.title('Is cosignatory of');
text += '\n' + this.cosignatoryOfTable.toString();
}
return text;
}
Expand Down Expand Up @@ -185,12 +184,9 @@ export default class extends ProfileCommand {
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
if (err instanceof Object && 'message' in err && JSON.parse(err.message).statusCode === 404) {
console.log(
chalk.blue('Info'),
'The account has to receive at least ' + 'one transaction to be recorded on the network.',
);
console.log(FormatterService.error(err));
if (err instanceof Object) {
console.log(FormatterService.info('The account has to receive at least one transaction to be recorded on the network'));
}
},
);
Expand Down
6 changes: 3 additions & 3 deletions src/commands/account/outgoing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { command, metadata } from 'clime';

import { AccountTransactionsCommand, AccountTransactionsOptions } from '../../interfaces/account.transactions.command';
import { AddressResolver } from '../../resolvers/address.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';
import { TransactionView } from '../../views/transactions/details/transaction.view';

@command({
Expand All @@ -45,12 +45,12 @@ export default class extends AccountTransactionsCommand {
});

if (!transactions.length) {
console.log("There aren't outgoing transaction");
console.log(FormatterService.error("There aren't outgoing transaction"));
}
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/account/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { command, metadata } from 'clime';

import { AccountTransactionsCommand, AccountTransactionsOptions } from '../../interfaces/account.transactions.command';
import { AddressResolver } from '../../resolvers/address.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';
import { TransactionView } from '../../views/transactions/details/transaction.view';

@command({
Expand All @@ -42,7 +42,7 @@ export default class extends AccountTransactionsCommand {
this.spinner.stop(true);

if (!transactions.length) {
console.log("There aren't transactions");
console.log(FormatterService.error("There aren't transactions"));
}

transactions.forEach((transaction) => {
Expand All @@ -51,7 +51,7 @@ export default class extends AccountTransactionsCommand {
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/account/unconfirmed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { command, metadata } from 'clime';

import { AccountTransactionsCommand, AccountTransactionsOptions } from '../../interfaces/account.transactions.command';
import { AddressResolver } from '../../resolvers/address.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';
import { TransactionView } from '../../views/transactions/details/transaction.view';

@command({
Expand All @@ -45,12 +45,12 @@ export default class extends AccountTransactionsCommand {
});

if (!transactions.length) {
console.log("There aren't unconfirmed transactions");
console.log(FormatterService.error("There aren't unconfirmed transactions"));
}
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
9 changes: 4 additions & 5 deletions src/commands/block/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
*/

import chalk from 'chalk';
import * as Table from 'cli-table3';
import { HorizontalTable } from 'cli-table3';
import { command, metadata, option } from 'clime';
Expand All @@ -25,7 +24,7 @@ import { BlockInfo, NetworkType } from 'symbol-sdk';
import { ProfileCommand } from '../../interfaces/profile.command';
import { ProfileOptions } from '../../interfaces/profile.options';
import { HeightResolver } from '../../resolvers/height.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';

export class CommandOptions extends ProfileOptions {
@option({
Expand Down Expand Up @@ -67,8 +66,8 @@ export class BlockHeaderTable {

toString(): string {
let text = '';
text += '\n' + chalk.green('Block Header') + '\n';
text += this.table.toString();
text += '\n' + FormatterService.title('Block Header');
text += '\n' + this.table.toString();
return text;
}
}
Expand All @@ -95,7 +94,7 @@ export default class extends ProfileCommand {
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/block/receipts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { command, metadata, option } from 'clime';
import { ProfileCommand } from '../../interfaces/profile.command';
import { ProfileOptions } from '../../interfaces/profile.options';
import { HeightResolver } from '../../resolvers/height.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';
import { StatementsView } from '../../views/statements/statements.view';

export class CommandOptions extends ProfileOptions {
Expand Down Expand Up @@ -53,7 +53,7 @@ export default class extends ProfileCommand {
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/block/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { command, metadata, option } from 'clime';

import { AccountTransactionsCommand, AccountTransactionsOptions } from '../../interfaces/account.transactions.command';
import { HeightResolver } from '../../resolvers/height.resolver';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';
import { TransactionView } from '../../views/transactions/details/transaction.view';

export class CommandOptions extends AccountTransactionsOptions {
Expand Down Expand Up @@ -50,16 +50,16 @@ export default class extends AccountTransactionsCommand {
this.spinner.stop(true);

if (!transactions.length) {
console.log("There aren't transactions");
console.log(FormatterService.error('The block ' + height.toString() + ' does not have transactions'));
}

console.log(FormatterService.title('Transactions'));
transactions.forEach((transaction) => {
new TransactionView(transaction).print();
});
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/chain/height.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { command, metadata } from 'clime';

import { ProfileCommand } from '../../interfaces/profile.command';
import { ProfileOptions } from '../../interfaces/profile.options';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';

@command({
description: 'Get the current height of the chain',
Expand All @@ -42,7 +42,7 @@ export default class extends ProfileCommand {
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
9 changes: 4 additions & 5 deletions src/commands/chain/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
* limitations under the License.
*
*/
import chalk from 'chalk';
import * as Table from 'cli-table3';
import { HorizontalTable } from 'cli-table3';
import { command, metadata } from 'clime';
import { BlockchainScore } from 'symbol-sdk';

import { ProfileCommand } from '../../interfaces/profile.command';
import { ProfileOptions } from '../../interfaces/profile.options';
import { HttpErrorHandler } from '../../services/httpErrorHandler.service';
import { FormatterService } from '../../services/formatter.service';

export class ChainScoreTable {
private readonly table: HorizontalTable;
Expand All @@ -37,8 +36,8 @@ export class ChainScoreTable {

toString(): string {
let text = '';
text += '\n' + chalk.green('Storage Information') + '\n';
text += this.table.toString();
text += FormatterService.title('Storage Information');
text += '\n' + this.table.toString();
return text;
}
}
Expand All @@ -64,7 +63,7 @@ export default class extends ProfileCommand {
},
(err) => {
this.spinner.stop(true);
console.log(HttpErrorHandler.handleError(err));
console.log(FormatterService.error(err));
},
);
}
Expand Down
Loading

0 comments on commit b231524

Please sign in to comment.