Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
💅 Apply format
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Dec 10, 2018
1 parent bc67147 commit 0ce6f1e
Show file tree
Hide file tree
Showing 23 changed files with 154 additions and 120 deletions.
4 changes: 2 additions & 2 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default abstract class BaseCommand extends Command {

async init(): Promise<void> {
// Typing problem where constructor is not allow as Input<any> but it requires to be the type
const { flags } = this.parse((// tslint:disable-next-line no-any
this.constructor as unknown) as flagParser.Input<any>);
const { flags } = this.parse(// tslint:disable-next-line no-any
(this.constructor as unknown) as flagParser.Input<any>);
this.printFlags = flags;

process.stdout.on('error', handleEPIPE);
Expand Down
4 changes: 1 addition & 3 deletions src/commands/account/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export default class GetCommand extends BaseCommand {
async run(): Promise<void> {
const { args } = this.parse(GetCommand);
const { addresses: addressesStr }: Args = args;
const addresses = addressesStr
.split(',')
.filter(Boolean);
const addresses = addressesStr.split(',').filter(Boolean);
const req = addresses.map((address: string) => ({
query: {
limit: 1,
Expand Down
4 changes: 3 additions & 1 deletion src/commands/delegate/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export default class GetCommand extends BaseCommand {
async run(): Promise<void> {
const { args } = this.parse(GetCommand);
const { usernames: usernamesStr }: Args = args;
const usernames: ReadonlyArray<string> = usernamesStr.split(',').filter(Boolean);
const usernames: ReadonlyArray<string> = usernamesStr
.split(',')
.filter(Boolean);
const req = usernames.map(username => ({
query: {
limit: 1,
Expand Down
6 changes: 5 additions & 1 deletion src/commands/delegate/voters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const DEFAULT_LIMIT = 10;
const DEFAULT_OFFSET = 0;
const DEFAULT_SORT = 'balance:desc';

const processFlagInputs = (limitStr: string, offsetStr: string, sortStr: string): QueryParameters => {
const processFlagInputs = (
limitStr: string,
offsetStr: string,
sortStr: string,
): QueryParameters => {
const limit = parseInt(limitStr, 10);
const offset = parseInt(offsetStr, 10);
const sort = sortStr ? sortStr.trim() : undefined;
Expand Down
18 changes: 10 additions & 8 deletions src/commands/node/forging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ interface Args {
const STATUS_ENABLE = 'enable';
const STATUS_DISABLE = 'disable';

const processInput = (client: APIClient, status: string, publicKey: string, password?: string) => {
const processInput = (
client: APIClient,
status: string,
publicKey: string,
password?: string,
) => {
if (!password) {
throw new ValidationError('No password was provided.');
}
Expand All @@ -42,8 +47,7 @@ const processInput = (client: APIClient, status: string, publicKey: string, pass
forging: status === STATUS_ENABLE,
})
.then(response => response.data);
}

};

export default class ForgingCommand extends BaseCommand {
static args = [
Expand Down Expand Up @@ -75,10 +79,9 @@ export default class ForgingCommand extends BaseCommand {
};

async run(): Promise<void> {
const {
args,
flags: { password: passwordSource },
} = this.parse(ForgingCommand);
const { args, flags: { password: passwordSource } } = this.parse(
ForgingCommand,
);

const { status, publicKey }: Args = args;
transactions.utils.validatePublicKey(publicKey);
Expand All @@ -94,4 +97,3 @@ export default class ForgingCommand extends BaseCommand {
this.print(result);
}
}

3 changes: 0 additions & 3 deletions src/commands/node/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,3 @@ export default class GetCommand extends BaseCommand {
this.print(fullInfo);
}
}



1 change: 0 additions & 1 deletion src/commands/signature/broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ export default class BroadcastCommand extends BaseCommand {
this.print(response.data);
}
}

9 changes: 4 additions & 5 deletions src/commands/signature/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ export default class CreateCommand extends BaseCommand {
};

async run(): Promise<void> {
const {
args,
flags: { passphrase: passphraseSource },
} = this.parse(CreateCommand);
const { args, flags: { passphrase: passphraseSource } } = this.parse(
CreateCommand,
);

const { transaction }: Args = args;
const transactionInput = transaction || (await getTransactionInput());
Expand Down Expand Up @@ -95,4 +94,4 @@ export default class CreateCommand extends BaseCommand {

this.print(result);
}
}
}
1 change: 0 additions & 1 deletion src/commands/transaction/broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@ export default class BroadcastCommand extends BaseCommand {
this.print(response.data);
}
}

14 changes: 9 additions & 5 deletions src/commands/transaction/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const typeNumberMap: TypeNumberMap = {
};

const options = Object.entries(typeNumberMap).reduce(
(accumulated: string[], [key, value]: [string, string]) => [...accumulated, key, value],
(accumulated: string[], [key, value]: [string, string]) => [
...accumulated,
key,
value,
],
[],
);

Expand All @@ -53,7 +57,10 @@ const typeClassMap: TypeClassMap = {
multisignature: MultisignatureCommand,
};

const resolveFlags = (accumulated: ReadonlyArray<string>, [key, value]: [string, string | boolean | undefined]) => {
const resolveFlags = (
accumulated: ReadonlyArray<string>,
[key, value]: [string, string | boolean | undefined],
) => {
if (key === 'type') {
return accumulated;
}
Expand Down Expand Up @@ -104,6 +111,3 @@ export default class CreateCommand extends BaseCommand {
await typeClassMap[commandType].run([...argv, ...resolvedFlags]);
}
}



12 changes: 9 additions & 3 deletions src/commands/transaction/create/delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ import { registerDelegate } from '@liskhq/lisk-transactions';
import { flags as flagParser } from '@oclif/command';
import BaseCommand from '../../../base';
import { flags as commonFlags } from '../../../utils/flags';
import { getInputsFromSources, InputFromSourceOutput } from '../../../utils/input';
import {
getInputsFromSources,
InputFromSourceOutput,
} from '../../../utils/input';

interface Args {
readonly username: string;
}

const processInputs = (username: string) => ({ passphrase, secondPassphrase }: InputFromSourceOutput) =>
const processInputs = (username: string) => ({
passphrase,
secondPassphrase,
}: InputFromSourceOutput) =>
registerDelegate({
passphrase,
secondPassphrase,
Expand Down Expand Up @@ -90,4 +96,4 @@ export default class DelegateCommand extends BaseCommand {
const result = processFunction(inputs);
this.print(result);
}
}
}
21 changes: 14 additions & 7 deletions src/commands/transaction/create/multisignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,30 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { registerMultisignature, utils as transactionUtils } from '@liskhq/lisk-transactions';
import {
registerMultisignature,
utils as transactionUtils,
} from '@liskhq/lisk-transactions';
import { flags as flagParser } from '@oclif/command';
import BaseCommand from '../../../base';
import { flags as commonFlags } from '../../../utils/flags';
import { validateLifetime, validateMinimum } from '../../../utils/helpers';
import { getInputsFromSources, InputFromSourceOutput } from '../../../utils/input';
import {
getInputsFromSources,
InputFromSourceOutput,
} from '../../../utils/input';

interface Args {
readonly keysgroup: string;
readonly lifetime: string;
readonly minimum: string;
}

const processInputs = (lifetime: number, minimum: number, keysgroup: ReadonlyArray<string>) => ({
passphrase,
secondPassphrase,
}: InputFromSourceOutput) =>
const processInputs = (
lifetime: number,
minimum: number,
keysgroup: ReadonlyArray<string>,
) => ({ passphrase, secondPassphrase }: InputFromSourceOutput) =>
registerMultisignature({
passphrase,
secondPassphrase,
Expand Down Expand Up @@ -129,4 +136,4 @@ export default class MultisignatureCommand extends BaseCommand {
const result = processFunction(inputs);
this.print(result);
}
}
}
15 changes: 10 additions & 5 deletions src/commands/transaction/create/second-passphrase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ import { flags as flagParser } from '@oclif/command';
import BaseCommand from '../../../base';
import { ValidationError } from '../../../utils/error';
import { flags as commonFlags } from '../../../utils/flags';
import { getInputsFromSources, InputFromSourceOutput } from '../../../utils/input';
import {
getInputsFromSources,
InputFromSourceOutput,
} from '../../../utils/input';

export const processInputs = () => ({ passphrase, secondPassphrase }: InputFromSourceOutput) => {
export const processInputs = () => ({
passphrase,
secondPassphrase,
}: InputFromSourceOutput) => {
if (!secondPassphrase) {
throw new ValidationError('No second passphrase was provided.');
}
Expand All @@ -29,8 +35,7 @@ export const processInputs = () => ({ passphrase, secondPassphrase }: InputFromS
passphrase,
secondPassphrase,
});
}

};

export default class SecondPassphraseCommand extends BaseCommand {
static description = `
Expand Down Expand Up @@ -78,4 +83,4 @@ export default class SecondPassphraseCommand extends BaseCommand {
const result = processFunction(inputs);
this.print(result);
}
}
}
11 changes: 6 additions & 5 deletions src/commands/transaction/create/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { transfer, utils as transactionUtils } from '@liskhq/lisk-transactions';
import { flags as flagParser } from '@oclif/command';
import BaseCommand from '../../../base';
import { AlphabetLowercase, flags as commonFlags } from '../../../utils/flags';
import { getInputsFromSources, InputFromSourceOutput } from '../../../utils/input';
import {
getInputsFromSources,
InputFromSourceOutput,
} from '../../../utils/input';

interface Args {
readonly address: string;
Expand Down Expand Up @@ -62,9 +65,7 @@ export default class TransferCommand extends BaseCommand {
Creates a transaction which will transfer the specified amount to an address if broadcast to the network.
`;

static examples = [
'transaction:create:transfer 100 13356260975429434553L',
];
static examples = ['transaction:create:transfer 100 13356260975429434553L'];

static flags = {
...BaseCommand.flags,
Expand Down Expand Up @@ -121,4 +122,4 @@ export default class TransferCommand extends BaseCommand {
const result = processFunction(inputs);
this.print(result);
}
}
}
19 changes: 14 additions & 5 deletions src/commands/transaction/create/vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { castVotes, utils as transactionUtils } from '@liskhq/lisk-transactions';
import {
castVotes,
utils as transactionUtils,
} from '@liskhq/lisk-transactions';
import { flags as flagParser } from '@oclif/command';
import BaseCommand from '../../../base';
import { ValidationError } from '../../../utils/error';
import { flags as commonFlags } from '../../../utils/flags';
import { getInputsFromSources, InputFromSourceOutput } from '../../../utils/input';
import {
getInputsFromSources,
InputFromSourceOutput,
} from '../../../utils/input';
import { getData } from '../../../utils/input/utils';

const processInputs = (votes: ReadonlyArray<string>, unvotes: ReadonlyArray<string>) => ({ passphrase, secondPassphrase }: InputFromSourceOutput) =>
const processInputs = (
votes: ReadonlyArray<string>,
unvotes: ReadonlyArray<string>,
) => ({ passphrase, secondPassphrase }: InputFromSourceOutput) =>
castVotes({
passphrase,
votes,
Expand Down Expand Up @@ -118,7 +127,7 @@ export default class VoteCommand extends BaseCommand {
repeatPrompt: true,
},
secondPassphrase: !secondPassphraseSource
? undefined
? undefined
: {
source: secondPassphraseSource,
repeatPrompt: true,
Expand All @@ -128,4 +137,4 @@ export default class VoteCommand extends BaseCommand {
const result = processFunction(inputs);
this.print(result);
}
}
}
11 changes: 8 additions & 3 deletions src/commands/transaction/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export default class GetCommand extends BaseCommand {
{
name: 'ids',
required: false,
description: 'Comma-separated transaction ID(s) to get information about.',
description:
'Comma-separated transaction ID(s) to get information about.',
},
];

Expand Down Expand Up @@ -236,7 +237,11 @@ export default class GetCommand extends BaseCommand {
message: 'No transactions found.',
},
};
const senderAddressResult = await query(client, 'transactions', reqSenderId);
const senderAddressResult = await query(
client,
'transactions',
reqSenderId,
);
this.print(senderAddressResult);

return;
Expand All @@ -256,4 +261,4 @@ export default class GetCommand extends BaseCommand {

this.print(defaultResults);
}
}
}
2 changes: 1 addition & 1 deletion src/commands/transaction/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ export default class SignCommand extends BaseCommand {

this.print(result);
}
}
}
4 changes: 2 additions & 2 deletions src/commands/transaction/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class VerifyCommand extends BaseCommand {
args,
flags: { 'second-public-key': secondPublicKeySource },
} = this.parse(VerifyCommand);

const { transaction }: Args = args;
const transactionInput = transaction || (await getTransactionInput());
const transactionObject = parseTransactionString(transactionInput);
Expand All @@ -94,4 +94,4 @@ export default class VerifyCommand extends BaseCommand {
);
this.print({ verified });
}
}
}
Loading

0 comments on commit 0ce6f1e

Please sign in to comment.