diff --git a/src/base.ts b/src/base.ts index 150b6434..5ec5faf7 100644 --- a/src/base.ts +++ b/src/base.ts @@ -63,8 +63,8 @@ export default abstract class BaseCommand extends Command { async init(): Promise { // Typing problem where constructor is not allow as Input but it requires to be the type - const { flags } = this.parse((// tslint:disable-next-line no-any - this.constructor as unknown) as flagParser.Input); + const { flags } = this.parse(// tslint:disable-next-line no-any + (this.constructor as unknown) as flagParser.Input); this.printFlags = flags; process.stdout.on('error', handleEPIPE); diff --git a/src/commands/account/get.ts b/src/commands/account/get.ts index e904650b..08e61109 100644 --- a/src/commands/account/get.ts +++ b/src/commands/account/get.ts @@ -46,9 +46,7 @@ export default class GetCommand extends BaseCommand { async run(): Promise { 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, diff --git a/src/commands/delegate/get.ts b/src/commands/delegate/get.ts index c9e4d23f..2504c39b 100644 --- a/src/commands/delegate/get.ts +++ b/src/commands/delegate/get.ts @@ -46,7 +46,9 @@ export default class GetCommand extends BaseCommand { async run(): Promise { const { args } = this.parse(GetCommand); const { usernames: usernamesStr }: Args = args; - const usernames: ReadonlyArray = usernamesStr.split(',').filter(Boolean); + const usernames: ReadonlyArray = usernamesStr + .split(',') + .filter(Boolean); const req = usernames.map(username => ({ query: { limit: 1, diff --git a/src/commands/delegate/voters.ts b/src/commands/delegate/voters.ts index b28375f7..d7dcc124 100644 --- a/src/commands/delegate/voters.ts +++ b/src/commands/delegate/voters.ts @@ -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; diff --git a/src/commands/node/forging.ts b/src/commands/node/forging.ts index 3de1968c..b75c65e8 100644 --- a/src/commands/node/forging.ts +++ b/src/commands/node/forging.ts @@ -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.'); } @@ -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 = [ @@ -75,10 +79,9 @@ export default class ForgingCommand extends BaseCommand { }; async run(): Promise { - 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); @@ -94,4 +97,3 @@ export default class ForgingCommand extends BaseCommand { this.print(result); } } - diff --git a/src/commands/node/get.ts b/src/commands/node/get.ts index f49f040b..95cbca63 100644 --- a/src/commands/node/get.ts +++ b/src/commands/node/get.ts @@ -62,6 +62,3 @@ export default class GetCommand extends BaseCommand { this.print(fullInfo); } } - - - diff --git a/src/commands/signature/broadcast.ts b/src/commands/signature/broadcast.ts index 7d4314fb..f51b06c9 100644 --- a/src/commands/signature/broadcast.ts +++ b/src/commands/signature/broadcast.ts @@ -76,4 +76,3 @@ export default class BroadcastCommand extends BaseCommand { this.print(response.data); } } - diff --git a/src/commands/signature/create.ts b/src/commands/signature/create.ts index ebe73d68..09d06289 100644 --- a/src/commands/signature/create.ts +++ b/src/commands/signature/create.ts @@ -62,10 +62,9 @@ export default class CreateCommand extends BaseCommand { }; async run(): Promise { - 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()); @@ -95,4 +94,4 @@ export default class CreateCommand extends BaseCommand { this.print(result); } -} \ No newline at end of file +} diff --git a/src/commands/transaction/broadcast.ts b/src/commands/transaction/broadcast.ts index 9984f80f..107fc8a9 100644 --- a/src/commands/transaction/broadcast.ts +++ b/src/commands/transaction/broadcast.ts @@ -64,4 +64,3 @@ export default class BroadcastCommand extends BaseCommand { this.print(response.data); } } - diff --git a/src/commands/transaction/create.ts b/src/commands/transaction/create.ts index dcc7df02..aca0cfce 100644 --- a/src/commands/transaction/create.ts +++ b/src/commands/transaction/create.ts @@ -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, + ], [], ); @@ -53,7 +57,10 @@ const typeClassMap: TypeClassMap = { multisignature: MultisignatureCommand, }; -const resolveFlags = (accumulated: ReadonlyArray, [key, value]: [string, string | boolean | undefined]) => { +const resolveFlags = ( + accumulated: ReadonlyArray, + [key, value]: [string, string | boolean | undefined], +) => { if (key === 'type') { return accumulated; } @@ -104,6 +111,3 @@ export default class CreateCommand extends BaseCommand { await typeClassMap[commandType].run([...argv, ...resolvedFlags]); } } - - - diff --git a/src/commands/transaction/create/delegate.ts b/src/commands/transaction/create/delegate.ts index ae5591e8..e32601c1 100644 --- a/src/commands/transaction/create/delegate.ts +++ b/src/commands/transaction/create/delegate.ts @@ -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, @@ -90,4 +96,4 @@ export default class DelegateCommand extends BaseCommand { const result = processFunction(inputs); this.print(result); } -} \ No newline at end of file +} diff --git a/src/commands/transaction/create/multisignature.ts b/src/commands/transaction/create/multisignature.ts index 089fe618..90081dbb 100644 --- a/src/commands/transaction/create/multisignature.ts +++ b/src/commands/transaction/create/multisignature.ts @@ -13,12 +13,18 @@ * 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; @@ -26,10 +32,11 @@ interface Args { readonly minimum: string; } -const processInputs = (lifetime: number, minimum: number, keysgroup: ReadonlyArray) => ({ - passphrase, - secondPassphrase, -}: InputFromSourceOutput) => +const processInputs = ( + lifetime: number, + minimum: number, + keysgroup: ReadonlyArray, +) => ({ passphrase, secondPassphrase }: InputFromSourceOutput) => registerMultisignature({ passphrase, secondPassphrase, @@ -129,4 +136,4 @@ export default class MultisignatureCommand extends BaseCommand { const result = processFunction(inputs); this.print(result); } -} \ No newline at end of file +} diff --git a/src/commands/transaction/create/second-passphrase.ts b/src/commands/transaction/create/second-passphrase.ts index b615bee2..bf0d0c91 100644 --- a/src/commands/transaction/create/second-passphrase.ts +++ b/src/commands/transaction/create/second-passphrase.ts @@ -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.'); } @@ -29,8 +35,7 @@ export const processInputs = () => ({ passphrase, secondPassphrase }: InputFromS passphrase, secondPassphrase, }); -} - +}; export default class SecondPassphraseCommand extends BaseCommand { static description = ` @@ -78,4 +83,4 @@ export default class SecondPassphraseCommand extends BaseCommand { const result = processFunction(inputs); this.print(result); } -} \ No newline at end of file +} diff --git a/src/commands/transaction/create/transfer.ts b/src/commands/transaction/create/transfer.ts index f9f2c48b..81bd4c88 100644 --- a/src/commands/transaction/create/transfer.ts +++ b/src/commands/transaction/create/transfer.ts @@ -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; @@ -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, @@ -121,4 +122,4 @@ export default class TransferCommand extends BaseCommand { const result = processFunction(inputs); this.print(result); } -} \ No newline at end of file +} diff --git a/src/commands/transaction/create/vote.ts b/src/commands/transaction/create/vote.ts index 2ae49965..0397fdef 100644 --- a/src/commands/transaction/create/vote.ts +++ b/src/commands/transaction/create/vote.ts @@ -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, unvotes: ReadonlyArray) => ({ passphrase, secondPassphrase }: InputFromSourceOutput) => +const processInputs = ( + votes: ReadonlyArray, + unvotes: ReadonlyArray, +) => ({ passphrase, secondPassphrase }: InputFromSourceOutput) => castVotes({ passphrase, votes, @@ -118,7 +127,7 @@ export default class VoteCommand extends BaseCommand { repeatPrompt: true, }, secondPassphrase: !secondPassphraseSource - ? undefined + ? undefined : { source: secondPassphraseSource, repeatPrompt: true, @@ -128,4 +137,4 @@ export default class VoteCommand extends BaseCommand { const result = processFunction(inputs); this.print(result); } -} \ No newline at end of file +} diff --git a/src/commands/transaction/get.ts b/src/commands/transaction/get.ts index 7108499e..78a3d1ff 100644 --- a/src/commands/transaction/get.ts +++ b/src/commands/transaction/get.ts @@ -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.', }, ]; @@ -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; @@ -256,4 +261,4 @@ export default class GetCommand extends BaseCommand { this.print(defaultResults); } -} \ No newline at end of file +} diff --git a/src/commands/transaction/sign.ts b/src/commands/transaction/sign.ts index eca42602..317e1974 100644 --- a/src/commands/transaction/sign.ts +++ b/src/commands/transaction/sign.ts @@ -100,4 +100,4 @@ export default class SignCommand extends BaseCommand { this.print(result); } -} \ No newline at end of file +} diff --git a/src/commands/transaction/verify.ts b/src/commands/transaction/verify.ts index 3919333b..f9ad58b6 100644 --- a/src/commands/transaction/verify.ts +++ b/src/commands/transaction/verify.ts @@ -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); @@ -94,4 +94,4 @@ export default class VerifyCommand extends BaseCommand { ); this.print({ verified }); } -} \ No newline at end of file +} diff --git a/src/utils/query.ts b/src/utils/query.ts index 16e57e13..e0447586 100644 --- a/src/utils/query.ts +++ b/src/utils/query.ts @@ -87,14 +87,17 @@ export const query = async ( handleResponse(endpoint, res, parameters.placeholder), ); -export const queryNodeTransaction = - async (client: NodeResource, txnState: string, parameters: ReadonlyArray): Promise => - Promise.all( - parameters.map(async (param: QueryParameter) => - client - .getTransactions(txnState, param.query) - .then(res => - handleResponse('node/transactions', res, param.placeholder), - ), - ), - ); +export const queryNodeTransaction = async ( + client: NodeResource, + txnState: string, + parameters: ReadonlyArray, +): Promise => + Promise.all( + parameters.map(async (param: QueryParameter) => + client + .getTransactions(txnState, param.query) + .then(res => + handleResponse('node/transactions', res, param.placeholder), + ), + ), + ); diff --git a/test/commands/signature/create.test.ts b/test/commands/signature/create.test.ts index 5a27bf5d..59cb21c1 100644 --- a/test/commands/signature/create.test.ts +++ b/test/commands/signature/create.test.ts @@ -133,12 +133,14 @@ describe('signature:create', () => { .it( 'should take transaction from arg and passphrase from flag to create', () => { - expect(inputUtilsModule.getInputsFromSources).to.be.calledWithExactly({ - passphrase: { - source: 'pass:123', - repeatPrompt: true, + expect(inputUtilsModule.getInputsFromSources).to.be.calledWithExactly( + { + passphrase: { + source: 'pass:123', + repeatPrompt: true, + }, }, - }); + ); expect(transactions.createSignatureObject).to.be.calledWithExactly( defaultTransaction, defaultInputs.passphrase, @@ -183,12 +185,14 @@ describe('signature:create', () => { .it( 'should take transaction from stdin and create signature object', () => { - expect(inputUtilsModule.getInputsFromSources).to.be.calledWithExactly({ - passphrase: { - source: undefined, - repeatPrompt: true, + expect(inputUtilsModule.getInputsFromSources).to.be.calledWithExactly( + { + passphrase: { + source: undefined, + repeatPrompt: true, + }, }, - }); + ); expect(transactions.createSignatureObject).to.be.calledWithExactly( defaultTransaction, defaultInputs.passphrase, @@ -211,12 +215,14 @@ describe('signature:create', () => { .it( 'should take transaction from stdin and sign with passphrase from flag', () => { - expect(inputUtilsModule.getInputsFromSources).to.be.calledWithExactly({ - passphrase: { - source: 'pass:123', - repeatPrompt: true, + expect(inputUtilsModule.getInputsFromSources).to.be.calledWithExactly( + { + passphrase: { + source: 'pass:123', + repeatPrompt: true, + }, }, - }); + ); expect(transactions.createSignatureObject).to.be.calledWithExactly( defaultTransaction, defaultInputs.passphrase, diff --git a/test/commands/transaction/create/vote.test.ts b/test/commands/transaction/create/vote.test.ts index 0111f91e..2358ae24 100644 --- a/test/commands/transaction/create/vote.test.ts +++ b/test/commands/transaction/create/vote.test.ts @@ -63,7 +63,11 @@ describe('transaction:create:vote', () => { sandbox.stub().returns(defaultTransaction), ) .stub(transactions, 'utils', transactionUtilStub) - .stub(inputModule, 'getData', sandbox.stub().resolves(fileVotes.join(','))) + .stub( + inputModule, + 'getData', + sandbox.stub().resolves(fileVotes.join(',')), + ) .stub( inputUtils, 'getInputsFromSources', diff --git a/test/commands/transaction/get.test.ts b/test/commands/transaction/get.test.ts index 38437bfe..3c53909e 100644 --- a/test/commands/transaction/get.test.ts +++ b/test/commands/transaction/get.test.ts @@ -360,7 +360,11 @@ describe('transaction:get', () => { describe('transaction:get transactions --state=unprocessed', () => { setupTest() - .stub(apiUtils, 'getAPIClient', sandbox.stub().returns(apiClientStubNode)) + .stub( + apiUtils, + 'getAPIClient', + sandbox.stub().returns(apiClientStubNode), + ) .stub( queryHandler, 'queryNodeTransaction', @@ -523,7 +527,11 @@ describe('transaction:get', () => { }; setupTest() - .stub(apiUtils, 'getAPIClient', sandbox.stub().returns(localClientStub)) + .stub( + apiUtils, + 'getAPIClient', + sandbox.stub().returns(localClientStub), + ) .stub( queryHandler, 'queryNodeTransaction', diff --git a/test/utils/query.ts b/test/utils/query.ts index 44d3eacb..f11f1b97 100644 --- a/test/utils/query.ts +++ b/test/utils/query.ts @@ -57,11 +57,7 @@ describe('query utils', () => { get: sandbox.stub().resolves(response), }, } as any; - queryResult = query( - apiClient, - defaultEndpoint, - defaultParameters, - ); + queryResult = query(apiClient, defaultEndpoint, defaultParameters); return Promise.resolve(); }); @@ -91,11 +87,7 @@ describe('query utils', () => { }); it('should call API client and should reject with an error', () => { - queryResult = query( - apiClient, - defaultEndpoint, - defaultParameters, - ); + queryResult = query(apiClient, defaultEndpoint, defaultParameters); expect(apiClient.accounts.get).to.be.calledWithExactly( defaultParameters.query, ); @@ -114,11 +106,7 @@ describe('query utils', () => { ...defaultParameters, placeholder, }; - queryResult = query( - apiClient, - defaultEndpoint, - paramWithPlaceholder, - ); + queryResult = query(apiClient, defaultEndpoint, paramWithPlaceholder); expect(apiClient.accounts.get).to.be.calledWithExactly( defaultParameters.query, ); @@ -142,11 +130,7 @@ describe('query utils', () => { get: sandbox.stub().resolves(response), }, } as any; - queryResult = query( - apiClient, - defaultEndpoint, - defaultParameters, - ); + queryResult = query(apiClient, defaultEndpoint, defaultParameters); return Promise.resolve(); }); @@ -203,11 +187,7 @@ describe('query utils', () => { get: sandbox.stub().resolves(response), }, } as any; - queryResult = query( - apiClient, - defaultEndpoint, - defaultParameters, - ); + queryResult = query(apiClient, defaultEndpoint, defaultParameters); return Promise.resolve(); }); @@ -233,11 +213,7 @@ describe('query utils', () => { get: sandbox.stub().resolves(response), }, } as any; - query( - apiClient, - defaultEndpoint, - defaultArrayParameters, - ); + query(apiClient, defaultEndpoint, defaultArrayParameters); return Promise.resolve(); });