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

Update copyright and warranty commands to typescript #682

Merged
merged 7 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
279 changes: 164 additions & 115 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"lint:fix": "npm run lint -- --fix",
"test": "if [ -z $JENKINS_HOME ]; then npm run test:local; else npm run test:ci; fi",
"test:local": "TS_NODE_PROJECT=./test/tsconfig.json nyc mocha test/{,/**/,/**/**/,/**/**/**/}/*.ts",
"test:ci": "NODE_ENV=test nyc --exclude \"**/node_modules/** coverage/**\" mocha test",
"test:ci": "npm run test:local",
"test:watch": "npm run test:local -- --watch",
"test:watch:min": "npm run test:watch -- --reporter=min",
"cover": "if [ -z $JENKINS_HOME ]; then npm run cover:local; else npm run cover:ci; fi",
Expand Down Expand Up @@ -108,9 +108,9 @@
"@liskhq/lisk-cryptography": "2.0.0",
"@liskhq/lisk-passphrase": "2.0.0",
"@liskhq/lisk-transactions": "2.0.0",
"@oclif/command": "1.5.0",
"@oclif/config": "1.7.4",
"@oclif/errors": "1.2.0",
"@oclif/command": "1.5.6",
"@oclif/config": "1.9.0",
"@oclif/errors": "1.2.2",
"@oclif/plugin-help": "2.1.1",
"bip39": "2.5.0",
"chalk": "2.4.1",
Expand All @@ -122,8 +122,8 @@
"tslib": "1.9.3"
},
"devDependencies": {
"@oclif/dev-cli": "1.18.0",
"@oclif/test": "1.2.0",
"@oclif/dev-cli": "1.19.5",
"@oclif/test": "1.2.2",
"@types/bip39": "2.4.0",
"@types/chai": "4.1.5",
"@types/chai-as-promised": "7.1.0",
Expand All @@ -139,12 +139,13 @@
"@types/strip-ansi": "3.0.0",
"chai": "4.1.2",
"chai-as-promised": "7.1.1",
"coveralls": "3.0.0",
"coveralls": "3.0.2",
"husky": "0.14.3",
"lint-staged": "5.0.0",
"mocha": "4.0.1",
"nyc": "11.3.0",
"prettier": "1.9.2",
"rxjs-compat": "6.3.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for husky, without this it seems like it's not working.
I have no idea why it doesn't work though...

"sinon": "4.1.2",
"sinon-chai": "2.14.0",
"source-map-support": "0.5.9",
Expand Down
6 changes: 4 additions & 2 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ 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
22 changes: 11 additions & 11 deletions src/commands/copyright.js → src/commands/copyright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
`.trim();

export default class CopyrightCommand extends BaseCommand {
async run() {
this.print({ copyright });
}
}
static description = `
Displays copyright notice.
`;

CopyrightCommand.flags = {
...BaseCommand.flags,
};
static examples = ['copyright'];

CopyrightCommand.description = `
Displays copyright notice.
`;
static flags = {
...BaseCommand.flags,
};

CopyrightCommand.examples = ['copyright'];
async run(): Promise<void> {
this.print({ copyright });
}
}
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 = async (
client: APIClient,
status: string,
publicKey: string,
password?: string,
): Promise<unknown> => {
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],
): ReadonlyArray<string> => {
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);
}
}
}
Loading