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

Commit

Permalink
Merge branch 'release/6.1.0' of https://github.com/LiskHQ/lisk-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Dec 6, 2023
2 parents 57f8f20 + e376657 commit 571a084
Show file tree
Hide file tree
Showing 386 changed files with 30,404 additions and 3,624 deletions.
24 changes: 12 additions & 12 deletions commander/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lisk-commander",
"version": "6.0.1",
"version": "6.1.0-rc.0",
"description": "A command line interface for Lisk",
"author": "Lisk Foundation <[email protected]>, lightcurve GmbH <[email protected]>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -101,16 +101,16 @@
"/docs"
],
"dependencies": {
"@liskhq/lisk-api-client": "^6.0.1",
"@liskhq/lisk-chain": "^0.5.0",
"@liskhq/lisk-client": "^6.0.1",
"@liskhq/lisk-codec": "^0.4.0",
"@liskhq/lisk-cryptography": "^4.0.0",
"@liskhq/lisk-db": "0.3.10",
"@liskhq/lisk-passphrase": "^4.0.0",
"@liskhq/lisk-transactions": "^6.0.0",
"@liskhq/lisk-utils": "^0.4.0",
"@liskhq/lisk-validator": "^0.8.0",
"@liskhq/lisk-api-client": "^6.1.0-rc.0",
"@liskhq/lisk-chain": "^0.6.0-rc.0",
"@liskhq/lisk-client": "^6.1.0-rc.0",
"@liskhq/lisk-codec": "^0.5.0-rc.0",
"@liskhq/lisk-cryptography": "^4.1.0-rc.0",
"@liskhq/lisk-db": "0.3.7",
"@liskhq/lisk-passphrase": "^4.1.0-rc.0",
"@liskhq/lisk-transactions": "^6.1.0-rc.0",
"@liskhq/lisk-utils": "^0.4.0-rc.0",
"@liskhq/lisk-validator": "^0.9.0-rc.0",
"@oclif/core": "1.20.4",
"@oclif/plugin-autocomplete": "1.3.6",
"@oclif/plugin-help": "5.1.19",
Expand All @@ -121,7 +121,7 @@
"cli-table3": "0.6.0",
"fs-extra": "11.1.0",
"inquirer": "8.2.5",
"lisk-framework": "^0.11.1",
"lisk-framework": "^0.12.0-rc.0",
"listr": "0.14.3",
"progress": "2.0.3",
"semver": "7.5.2",
Expand Down
15 changes: 6 additions & 9 deletions commander/src/bootstrapping/commands/config/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { join, resolve } from 'path';
import * as inquirer from 'inquirer';
import { isHexString } from '@liskhq/lisk-validator';
import { defaultConfig } from '../../../utils/config';
import { OWNER_READ_WRITE } from '../../../constants';
import { handleOutputFlag } from '../../../utils/output';

export class CreateCommand extends Command {
static description = 'Creates network configuration file.';
Expand Down Expand Up @@ -81,17 +81,14 @@ export class CreateCommand extends Command {
if (!userResponse.confirm) {
this.error('Operation cancelled, config file already present at the desired location');
} else {
fs.writeJSONSync(resolve(configPath, 'config.json'), defaultConfig, {
spaces: '\t',
mode: OWNER_READ_WRITE,
});
const res = await handleOutputFlag(configPath, defaultConfig, 'config');
this.log(res);
}
} else {
fs.mkdirSync(configPath, { recursive: true });
fs.writeJSONSync(resolve(configPath, 'config.json'), defaultConfig, {
spaces: '\t',
mode: OWNER_READ_WRITE,
});

const res = await handleOutputFlag(configPath, defaultConfig, 'config');
this.log(res);
}
}
}
12 changes: 3 additions & 9 deletions commander/src/bootstrapping/commands/generator/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
*/

import { encrypt } from '@liskhq/lisk-cryptography';
import * as fs from 'fs-extra';
import * as path from 'path';
import { flagsWithParser } from '../../../utils/flags';
import { BaseIPCClientCommand } from '../base_ipc_client';
import { OWNER_READ_WRITE } from '../../../constants';
import { handleOutputFlag } from '../../../utils/output';

interface EncryptedMessageObject {
readonly version: string;
Expand Down Expand Up @@ -86,11 +85,6 @@ export abstract class ExportCommand extends BaseIPCClientCommand {
this.error('APIClient is not initialized.');
}

if (flags.output) {
const { dir } = path.parse(flags.output);
fs.ensureDirSync(dir);
}

const allKeys = await this._client.invoke<GetKeysResponse>('generator_getAllKeys');
const statusResponse = await this._client.invoke<GetStatusResponse>('generator_getStatus');

Expand Down Expand Up @@ -120,7 +114,7 @@ export abstract class ExportCommand extends BaseIPCClientCommand {
};

const filePath = flags.output ? flags.output : path.join(process.cwd(), 'generator_info.json');
fs.writeJSONSync(filePath, output, { spaces: ' ', mode: OWNER_READ_WRITE });
this.log(`Generator info is exported to ${filePath}`);
const res = await handleOutputFlag(filePath, output, 'generator_info');
this.log(res);
}
}
16 changes: 3 additions & 13 deletions commander/src/bootstrapping/commands/hash-onion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
*/

import { Command, Flags as flagParser } from '@oclif/core';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as cryptography from '@liskhq/lisk-cryptography';
import * as validator from '@liskhq/lisk-validator';
import { flagsWithParser } from '../../utils/flags';
import { OWNER_READ_WRITE } from '../../constants';
import { handleOutputFlag } from '../../utils/output';

export class HashOnionCommand extends Command {
static description = 'Create hash onions to be used by the forger.';
Expand Down Expand Up @@ -60,11 +58,6 @@ export class HashOnionCommand extends Command {
throw new Error('Count flag must be an integer and greater than 0.');
}

if (output) {
const { dir } = path.parse(output);
fs.ensureDirSync(dir);
}

const seed = cryptography.utils.generateHashOnionSeed();

const hashBuffers = cryptography.utils.hashOnion(seed, count, distance);
Expand All @@ -73,11 +66,8 @@ export class HashOnionCommand extends Command {
const result = { count, distance, hashes };

if (output) {
if (pretty) {
fs.writeJSONSync(output, result, { spaces: ' ', mode: OWNER_READ_WRITE });
} else {
fs.writeJSONSync(output, result, { mode: OWNER_READ_WRITE });
}
const res = await handleOutputFlag(output, result, 'hash-onion');
this.log(res);
} else {
this.printJSON(result, pretty);
}
Expand Down
17 changes: 8 additions & 9 deletions commander/src/bootstrapping/commands/keys/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
import { codec } from '@liskhq/lisk-codec';
import { bls, address as addressUtil, ed, encrypt, legacy } from '@liskhq/lisk-cryptography';
import { Command, Flags as flagParser } from '@oclif/core';
import * as fs from 'fs-extra';
import * as path from 'path';
import { flagsWithParser } from '../../../utils/flags';
import { getPassphraseFromPrompt, getPasswordFromPrompt } from '../../../utils/reader';
import { OWNER_READ_WRITE, plainGeneratorKeysSchema } from '../../../constants';
import { plainGeneratorKeysSchema } from '../../../constants';
import { handleOutputFlag } from '../../../utils/output';

export class CreateCommand extends Command {
static description = 'Return keys corresponding to the given passphrase.';
Expand All @@ -37,7 +36,10 @@ export class CreateCommand extends Command {
];

static flags = {
output: flagsWithParser.output,
output: flagParser.string({
char: 'o',
description: 'The output directory. Default will set to current working directory.',
}),
passphrase: flagsWithParser.passphrase,
'no-encrypt': flagParser.boolean({
char: 'n',
Expand Down Expand Up @@ -79,10 +81,6 @@ export class CreateCommand extends Command {
},
} = await this.parse(CreateCommand);

if (output) {
const { dir } = path.parse(output);
fs.ensureDirSync(dir);
}
const passphrase = passphraseSource ?? (await getPassphraseFromPrompt('passphrase', true));
let password = '';
if (!noEncrypt) {
Expand Down Expand Up @@ -156,7 +154,8 @@ export class CreateCommand extends Command {
}

if (output) {
fs.writeJSONSync(output, { keys }, { spaces: ' ', mode: OWNER_READ_WRITE });
const res = await handleOutputFlag(output, { keys }, 'keys');
this.log(res);
} else {
this.log(JSON.stringify({ keys }, undefined, ' '));
}
Expand Down
16 changes: 7 additions & 9 deletions commander/src/bootstrapping/commands/keys/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
*
*/
import { encrypt } from '@liskhq/lisk-cryptography';
import * as fs from 'fs-extra';
import * as path from 'path';
import { flagsWithParser } from '../../../utils/flags';
import { BaseIPCClientCommand } from '../base_ipc_client';
import { OWNER_READ_WRITE } from '../../../constants';
import { handleOutputFlag } from '../../../utils/output';

interface EncryptedMessageObject {
readonly version: string;
Expand Down Expand Up @@ -66,22 +64,19 @@ export abstract class ExportCommand extends BaseIPCClientCommand {
...BaseIPCClientCommand.flags,
output: {
...flagsWithParser.output,
required: true,
},
};

async run(): Promise<void> {
const { flags } = await this.parse(ExportCommand);

if (!this._client) {
this.error('APIClient is not initialized.');
}

const { dir } = path.parse(flags.output as string);
fs.ensureDirSync(dir);

const response = await this._client.invoke<GetKeysResponse>('generator_getAllKeys');

const keys = response.keys.map(k => {
const keys = response?.keys.map(k => {
if (k.type === 'encrypted') {
return {
address: k.address,
Expand All @@ -94,6 +89,9 @@ export abstract class ExportCommand extends BaseIPCClientCommand {
};
});

fs.writeJSONSync(flags.output as string, { keys }, { spaces: ' ', mode: OWNER_READ_WRITE });
if (flags.output) {
const res = await handleOutputFlag(flags.output, { keys }, 'keys');
this.log(res);
}
}
}
20 changes: 8 additions & 12 deletions commander/src/bootstrapping/commands/passphrase/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,29 @@
*/

import { Mnemonic } from '@liskhq/lisk-passphrase';
import { Command } from '@oclif/core';
import * as fs from 'fs-extra';
import * as path from 'path';
import { flagsWithParser } from '../../../utils/flags';
import { OWNER_READ_WRITE } from '../../../constants';
import { Command, Flags as flagParser } from '@oclif/core';
import { handleOutputFlag } from '../../../utils/output';

export class CreateCommand extends Command {
static description = 'Returns a randomly generated 24 words mnemonic passphrase.';
static examples = ['passphrase:create', 'passphrase:create --output /mypath/passphrase.json'];
static flags = {
output: flagsWithParser.output,
output: flagParser.string({
char: 'o',
description: 'The output directory. Default will set to current working directory.',
}),
};

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

if (output) {
const { dir } = path.parse(output);
fs.ensureDirSync(dir);
}

const passphrase = Mnemonic.generateMnemonic(256);

if (output) {
fs.writeJSONSync(output, { passphrase }, { spaces: ' ', mode: OWNER_READ_WRITE });
const res = await handleOutputFlag(output, { passphrase }, 'passphrase');
this.log(res);
} else {
this.log(JSON.stringify({ passphrase }, undefined, ' '));
}
Expand Down
17 changes: 7 additions & 10 deletions commander/src/bootstrapping/commands/passphrase/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
*/

import { Command, Flags as flagParser } from '@oclif/core';
import * as fs from 'fs-extra';
import * as path from 'path';
import { encryptPassphrase } from '../../../utils/commons';
import { flagsWithParser } from '../../../utils/flags';
import { getPassphraseFromPrompt, getPasswordFromPrompt } from '../../../utils/reader';
import { OWNER_READ_WRITE } from '../../../constants';
import { handleOutputFlag } from '../../../utils/output';

const outputPublicKeyOptionDescription =
'Includes the public key in the output. This option is provided for the convenience of node operators.';
Expand All @@ -41,7 +39,10 @@ export class EncryptCommand extends Command {
'output-public-key': flagParser.boolean({
description: outputPublicKeyOptionDescription,
}),
output: flagsWithParser.output,
output: flagParser.string({
char: 'o',
description: 'The output directory. Default will set to current working directory.',
}),
};

async run(): Promise<void> {
Expand All @@ -54,17 +55,13 @@ export class EncryptCommand extends Command {
},
} = await this.parse(EncryptCommand);

if (output) {
const { dir } = path.parse(output);
fs.ensureDirSync(dir);
}

const passphrase = passphraseSource ?? (await getPassphraseFromPrompt('passphrase', true));
const password = passwordSource ?? (await getPasswordFromPrompt('password', true));
const result = await encryptPassphrase(passphrase, password, outputPublicKey);

if (output) {
fs.writeJSONSync(output, result, { spaces: ' ', mode: OWNER_READ_WRITE });
const res = await handleOutputFlag(output, result, 'passphrase');
this.log(res);
} else {
this.log(JSON.stringify(result, undefined, ' '));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@
}
},
"dependencies": {
"@liskhq/lisk-framework-dashboard-plugin": "0.3.1",
"@liskhq/lisk-framework-faucet-plugin": "0.3.1",
"@liskhq/lisk-framework-monitor-plugin": "0.4.1",
"@liskhq/lisk-framework-forger-plugin": "0.4.1",
"@liskhq/lisk-framework-report-misbehavior-plugin": "0.4.1",
"@liskhq/lisk-framework-chain-connector-plugin": "0.1.1",
"@liskhq/lisk-framework-dashboard-plugin": "0.4.0-rc.0",
"@liskhq/lisk-framework-faucet-plugin": "0.4.0-rc.0",
"@liskhq/lisk-framework-monitor-plugin": "0.5.0-rc.0",
"@liskhq/lisk-framework-forger-plugin": "0.5.0-rc.0",
"@liskhq/lisk-framework-report-misbehavior-plugin": "0.5.0-rc.0",
"@liskhq/lisk-framework-chain-connector-plugin": "0.2.0-rc.0",
"@oclif/core": "1.20.4",
"@oclif/plugin-autocomplete": "1.3.6",
"@oclif/plugin-help": "5.1.19",
"@oclif/plugin-version": "1.1.3",
"axios": "0.21.2",
"fs-extra": "11.1.0",
"inquirer": "8.2.5",
"lisk-commander": "6.0.1",
"lisk-sdk": "6.0.1",
"lisk-commander": "6.1.0-rc.0",
"lisk-sdk": "6.1.0-rc.0",
"tar": "6.1.11",
"tslib": "2.4.1"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import { Application } from 'lisk-sdk';

// @ts-expect-error app will have typescript error for unsued variable
export const registerModules = (app: Application): void => {};
export const registerModules = (_app: Application): void => {};
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"build:check": "node -e \"require('./dist-node')\""
},
"dependencies": {
"lisk-sdk": "^6.0.1"
"lisk-sdk": "^6.1.0-rc.0"
},
"devDependencies": {
"@types/jest": "26.0.21",
Expand Down
7 changes: 2 additions & 5 deletions commander/src/commands/generate/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ interface CommandCommandArgs {
}

export default class CommandCommand extends BaseBootstrapCommand {
static description = 'Creates an command skeleton for the given module name, name and id.';
static examples = [
'generate:command moduleName commandName commandID',
'generate:command nft transfer 1',
];
static description = 'Creates a command skeleton for the given module name and command name.';
static examples = ['generate:command moduleName commandName', 'generate:command nft transfer'];
static args = [
{
name: 'moduleName',
Expand Down
Loading

0 comments on commit 571a084

Please sign in to comment.