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

Commit

Permalink
Update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschakki committed Dec 21, 2023
1 parent 300473f commit 55a70f4
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 128 deletions.
4 changes: 2 additions & 2 deletions commander/src/bootstrapping/commands/base_ipc_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import * as apiClient from '@liskhq/lisk-api-client';
import { Command } from '@oclif/core';
import { RegisteredSchema, Modules } from 'lisk-framework';
import { Types, Modules } from 'lisk-framework';
import { PromiseResolvedType } from '../../types';
import { isApplicationRunning } from '../../utils/application';
import { flagsWithParser } from '../../utils/flags';
Expand All @@ -34,7 +34,7 @@ export abstract class BaseIPCClientCommand extends Command {

protected baseIPCClientFlags!: BaseIPCClientFlags;
protected _client!: PromiseResolvedType<ReturnType<typeof apiClient.createIPCClient>> | undefined;
protected _schema!: RegisteredSchema;
protected _schema!: Types.RegisteredSchema;
protected _metadata!: Modules.ModuleMetadataJSON[];
protected _dataPath!: string;

Expand Down
8 changes: 4 additions & 4 deletions commander/src/bootstrapping/commands/config/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import * as utils from '@liskhq/lisk-utils';
import { Command } from '@oclif/core';
import * as fs from 'fs-extra';
import { ApplicationConfig } from 'lisk-framework';
import { Types } from 'lisk-framework';
import { flagsWithParser } from '../../../utils/flags';
import { getConfigFilesPath, getDefaultPath } from '../../../utils/path';

Expand Down Expand Up @@ -46,11 +46,11 @@ export class ShowCommand extends Command {
this.error(`Folder in ${dataPath} does not contain valid config`);
}
// Get config from network config or config specified
let config = (await fs.readJSON(configFilePath)) as ApplicationConfig;
let config = (await fs.readJSON(configFilePath)) as Types.ApplicationConfig;

if (flags.config) {
const customConfig = (await fs.readJSON(flags.config)) as ApplicationConfig;
config = utils.objects.mergeDeep({}, config, customConfig) as ApplicationConfig;
const customConfig = (await fs.readJSON(flags.config)) as Types.ApplicationConfig;
config = utils.objects.mergeDeep({}, config, customConfig) as Types.ApplicationConfig;
}

config.system.dataPath = dataPath;
Expand Down
4 changes: 2 additions & 2 deletions commander/src/bootstrapping/commands/genesis-block/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { Application, PartialApplicationConfig } from 'lisk-framework';
import { Application, Types } from 'lisk-framework';
import { objects } from '@liskhq/lisk-utils';
import { Command, Flags as flagParser } from '@oclif/core';
import * as fs from 'fs-extra';
Expand Down Expand Up @@ -141,6 +141,6 @@ export abstract class BaseGenesisBlockCommand extends Command {
this.log(`Genesis block files saved at: ${configPath}`);
}

abstract getApplication(config: PartialApplicationConfig): Application;
abstract getApplication(config: Types.PartialApplicationConfig): Application;
abstract getApplicationConfigDir(): string;
}
8 changes: 4 additions & 4 deletions commander/src/bootstrapping/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { Command, Flags as flagParser } from '@oclif/core';
import * as fs from 'fs-extra';
import { utils as cryptoUtils } from '@liskhq/lisk-cryptography';
import { ApplicationConfig, Application, PartialApplicationConfig } from 'lisk-framework';
import { Types, Application } from 'lisk-framework';
import * as utils from '@liskhq/lisk-utils';
import { flagsWithParser } from '../../utils/flags';

Expand Down Expand Up @@ -152,8 +152,8 @@ export abstract class StartCommand extends Command {
let config = await fs.readJSON(configFilePath);

if (flags.config) {
const customConfig: ApplicationConfig = await fs.readJSON(flags.config);
config = utils.objects.mergeDeep({}, config, customConfig) as ApplicationConfig;
const customConfig: Types.ApplicationConfig = await fs.readJSON(flags.config);
config = utils.objects.mergeDeep({}, config, customConfig) as Types.ApplicationConfig;
}
config.system.version = this.config.pjson.version;
config.system.dataPath = dataPath;
Expand Down Expand Up @@ -220,7 +220,7 @@ export abstract class StartCommand extends Command {
}
}

abstract getApplication(config: PartialApplicationConfig): Promise<Application>;
abstract getApplication(config: Types.PartialApplicationConfig): Promise<Application>;

abstract getApplicationConfigDir(): string;
}
13 changes: 6 additions & 7 deletions commander/src/bootstrapping/commands/transaction/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { validator } from '@liskhq/lisk-validator';
import { Command, Flags as flagParser } from '@oclif/core';
import {
Application,
PartialApplicationConfig,
RegisteredSchema,
Types,
blockHeaderSchema,
blockSchema,
transactionSchema,
Expand Down Expand Up @@ -116,7 +115,7 @@ const getKeysFromFlags = async (flags: CreateFlags) => {

const validateAndSignTransaction = (
transaction: Transaction,
schema: RegisteredSchema,
schema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
chainID: string,
privateKey: Buffer,
Expand Down Expand Up @@ -149,7 +148,7 @@ const validateAndSignTransaction = (
const createTransactionOffline = async (
args: Args,
flags: CreateFlags,
registeredSchema: RegisteredSchema,
registeredSchema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transaction: Transaction,
) => {
Expand All @@ -173,7 +172,7 @@ const createTransactionOnline = async (
args: Args,
flags: CreateFlags,
client: apiClient.APIClient,
registeredSchema: RegisteredSchema,
registeredSchema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transaction: Transaction,
) => {
Expand Down Expand Up @@ -279,7 +278,7 @@ export abstract class CreateCommand extends Command {
};

protected _client!: PromiseResolvedType<ReturnType<typeof apiClient.createIPCClient>> | undefined;
protected _schema!: RegisteredSchema;
protected _schema!: Types.RegisteredSchema;
protected _metadata!: Modules.ModuleMetadataJSON[];
protected _dataPath!: string;

Expand Down Expand Up @@ -377,5 +376,5 @@ export abstract class CreateCommand extends Command {
}
}

abstract getApplication(config: PartialApplicationConfig): Application;
abstract getApplication(config: Types.PartialApplicationConfig): Application;
}
13 changes: 6 additions & 7 deletions commander/src/bootstrapping/commands/transaction/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {
blockHeaderSchema,
blockSchema,
Modules,
PartialApplicationConfig,
RegisteredSchema,
Types,
transactionSchema,
} from 'lisk-framework';
import * as transactions from '@liskhq/lisk-transactions';
Expand Down Expand Up @@ -57,7 +56,7 @@ interface SignFlags {

const signTransaction = async (
flags: SignFlags,
registeredSchema: RegisteredSchema,
registeredSchema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transactionHexStr: string,
chainID: string | undefined,
Expand Down Expand Up @@ -105,7 +104,7 @@ const signTransaction = async (

const signTransactionOffline = async (
flags: SignFlags,
registeredSchema: RegisteredSchema,
registeredSchema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transactionHexStr: string,
): Promise<Record<string, unknown>> => {
Expand All @@ -132,7 +131,7 @@ const signTransactionOffline = async (
const signTransactionOnline = async (
flags: SignFlags,
client: apiClient.APIClient,
registeredSchema: RegisteredSchema,
registeredSchema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transactionHexStr: string,
) => {
Expand Down Expand Up @@ -190,7 +189,7 @@ export abstract class SignCommand extends Command {
];

protected _client: PromiseResolvedType<ReturnType<typeof apiClient.createIPCClient>> | undefined;
protected _schema!: RegisteredSchema;
protected _schema!: Types.RegisteredSchema;
protected _metadata!: Modules.ModuleMetadataJSON[];
protected _dataPath!: string;

Expand Down Expand Up @@ -261,5 +260,5 @@ export abstract class SignCommand extends Command {
}
}

abstract getApplication(config: PartialApplicationConfig): Application;
abstract getApplication(config: Types.PartialApplicationConfig): Application;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

import {
Engine,
BasePlugin,
PluginInitContext,
Plugins,
apiClient,
db as liskDB,
codec,
chain,
Modules,
JSONObject,
Types,
Schema,
Transaction,
cryptography,
Expand Down Expand Up @@ -81,7 +80,7 @@ type ModulesMetadata = [

type FinalizedHeightInfo = { inboxSize: number; lastCertificateHeight: number };

export class ChainConnectorPlugin extends BasePlugin<ChainConnectorPluginConfig> {
export class ChainConnectorPlugin extends Plugins.BasePlugin<ChainConnectorPluginConfig> {
public endpoint = new Endpoint();
public configSchema = configSchema;

Expand All @@ -106,7 +105,7 @@ export class ChainConnectorPlugin extends BasePlugin<ChainConnectorPluginConfig>
}

// eslint-disable-next-line @typescript-eslint/require-await
public async init(context: PluginInitContext): Promise<void> {
public async init(context: Plugins.PluginInitContext): Promise<void> {
await super.init(context);
this._ccuFrequency = this.config.ccuFrequency ?? CCU_FREQUENCY;
if (this.config.maxCCUSize > CCU_TOTAL_CCM_SIZE) {
Expand Down Expand Up @@ -539,7 +538,7 @@ export class ChainConnectorPlugin extends BasePlugin<ChainConnectorPluginConfig>
}

// Check for events if any and store them
const events = await this._sendingChainClient.invoke<JSONObject<chain.EventAttr[]>>(
const events = await this._sendingChainClient.invoke<Types.JSONObject<chain.EventAttr[]>>(
'chain_getEvents',
{ height: newBlockHeader.height },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*/

import {
BasePluginEndpoint,
PluginEndpointContext,
chain,
BlockHeaderJSON,
validator as liskValidator,
} from 'lisk-sdk';
import { Plugins, Types, chain, BlockHeaderJSON, validator as liskValidator } from 'lisk-sdk';
import { ChainConnectorStore } from './db';
import {
AggregateCommitJSON,
Expand All @@ -35,7 +29,7 @@ import { authorizeRequestSchema } from './schemas';
// eslint-disable-next-line prefer-destructuring
const validator: liskValidator.LiskValidator = liskValidator.validator;

export class Endpoint extends BasePluginEndpoint {
export class Endpoint extends Plugins.BasePluginEndpoint {
private _chainConnectorStore!: ChainConnectorStore;
private _config!: ChainConnectorPluginConfig;

Expand All @@ -45,34 +39,36 @@ export class Endpoint extends BasePluginEndpoint {
}

// eslint-disable-next-line @typescript-eslint/require-await
public async getSentCCUs(_context: PluginEndpointContext): Promise<SentCCUsJSON> {
public async getSentCCUs(_context: Types.PluginEndpointContext): Promise<SentCCUsJSON> {
const sentCCUs = await this._chainConnectorStore.getListOfCCUs();
return sentCCUs.map(transaction => new chain.Transaction(transaction).toJSON());
}

public async getAggregateCommits(
_context: PluginEndpointContext,
_context: Types.PluginEndpointContext,
): Promise<AggregateCommitJSON[]> {
const aggregateCommits = await this._chainConnectorStore.getAggregateCommits();
return aggregateCommits.map(aggregateCommit => aggregateCommitToJSON(aggregateCommit));
}

public async getBlockHeaders(_context: PluginEndpointContext): Promise<BlockHeaderJSON[]> {
public async getBlockHeaders(_context: Types.PluginEndpointContext): Promise<BlockHeaderJSON[]> {
const blockHeaders = await this._chainConnectorStore.getBlockHeaders();

return blockHeaders.map(blockHeader => new chain.BlockHeader(blockHeader).toJSON());
}

public async getCrossChainMessages(
_context: PluginEndpointContext,
_context: Types.PluginEndpointContext,
): Promise<CCMsFromEventsJSON[]> {
const ccmsAndInclusionProofs = await this._chainConnectorStore.getCrossChainMessages();
return ccmsAndInclusionProofs.map(ccmsAndInclusionProof =>
ccmsFromEventsToJSON(ccmsAndInclusionProof),
);
}

public async getLastSentCCM(_context: PluginEndpointContext): Promise<LastSentCCMWithHeightJSON> {
public async getLastSentCCM(
_context: Types.PluginEndpointContext,
): Promise<LastSentCCMWithHeightJSON> {
const lastSentCCM = await this._chainConnectorStore.getLastSentCCM();
if (!lastSentCCM) {
throw new Error('No CCM was sent so far.');
Expand All @@ -89,14 +85,14 @@ export class Endpoint extends BasePluginEndpoint {
}

public async getValidatorsInfoFromPreimage(
_context: PluginEndpointContext,
_context: Types.PluginEndpointContext,
): Promise<ValidatorsDataJSON[]> {
const validatorsHashPreimage = await this._chainConnectorStore.getValidatorsHashPreimage();
return validatorsHashPreimagetoJSON(validatorsHashPreimage);
}

// eslint-disable-next-line @typescript-eslint/require-await
public async authorize(context: PluginEndpointContext): Promise<{ result: string }> {
public async authorize(context: Types.PluginEndpointContext): Promise<{ result: string }> {
validator.validate<{ enable: boolean; password: string }>(
authorizeRequestSchema,
context.params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
* Removal or modification of this copyright notice is prohibited.
*/

import { BasePlugin } from 'lisk-sdk';
import { Plugins } from 'lisk-sdk';
import * as express from 'express';
import { join } from 'path';
import { Server } from 'http';
import { configSchema } from './schemas';
import { DashboardPluginConfig } from './types';

export class DashboardPlugin extends BasePlugin<DashboardPluginConfig> {
export class DashboardPlugin extends Plugins.BasePlugin<DashboardPluginConfig> {
public configSchema = configSchema;

private _server!: Server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,30 @@
*/

import axios from 'axios';
import {
BasePluginEndpoint,
PluginEndpointContext,
validator as liskValidator,
cryptography,
transactions,
BasePlugin,
} from 'lisk-sdk';
import { Plugins, Types, validator as liskValidator, cryptography, transactions } from 'lisk-sdk';
import { authorizeParamsSchema, fundParamsSchema } from './schemas';
import { FaucetPluginConfig, State } from './types';

// disabled for type annotation
// eslint-disable-next-line prefer-destructuring
const validator: liskValidator.LiskValidator = liskValidator.validator;

export class Endpoint extends BasePluginEndpoint {
export class Endpoint extends Plugins.BasePluginEndpoint {
private _state: State = { publicKey: undefined, privateKey: undefined, address: undefined };
private _client!: BasePlugin['apiClient'];
private _client!: Plugins.BasePlugin['apiClient'];
private _config!: FaucetPluginConfig;

public init(state: State, apiClient: BasePlugin['apiClient'], config: FaucetPluginConfig) {
public init(
state: State,
apiClient: Plugins.BasePlugin['apiClient'],
config: FaucetPluginConfig,
) {
this._state = state;
this._client = apiClient;
this._config = config;
}
// eslint-disable-next-line @typescript-eslint/require-await
public async authorize(context: PluginEndpointContext): Promise<{ result: string }> {
public async authorize(context: Types.PluginEndpointContext): Promise<{ result: string }> {
validator.validate<{ enable: boolean; password: string }>(
authorizeParamsSchema,
context.params,
Expand Down Expand Up @@ -76,7 +73,7 @@ export class Endpoint extends BasePluginEndpoint {
}
}

public async fundTokens(context: PluginEndpointContext): Promise<{ result: string }> {
public async fundTokens(context: Types.PluginEndpointContext): Promise<{ result: string }> {
validator.validate(fundParamsSchema, context.params);
const { address, token } = context.params;

Expand Down
Loading

0 comments on commit 55a70f4

Please sign in to comment.