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

Commit

Permalink
Add TypeDocs for the NFT module (#9155)
Browse files Browse the repository at this point in the history
* Add module typdocs

* Add module typdocs

* Fix comment format

* Add typedocs for nft methods

* Add typedocs for nft methods

* Export constants

* Update typedoc.json to include exports of the NFT module

* Restructure module exports

* Restructure framework exports

* Update imports

* Update example imports

* Update example imports

* Update example imports

* Fix format

* Fix lint error

* Update test imports

* Fix eslint

* Update imports of unit tests

* Update imports of unit tests

* Update imports of unit tests

* Update imports of unit tests

* Update imports of unit tests

* Update imports of unit tests

* Fix logger export

* Update imports in integration tests

* Fix errors

* Fix error

* Update links

* Add typedocs for nft endpoints

* Add typedocs for nft endpoints

* Add typedocs for commands

* Fix snippets

* Add section about cc nft transfers

* Apply suggestions from code review

Co-authored-by: Muhammad Talha <[email protected]>

* Update framework/src/modules/base_module.ts

Co-authored-by: Muhammad Talha <[email protected]>

* Reduce exports

* Update framework/src/engine/consensus/index.ts

Co-authored-by: !shan <[email protected]>

* Apply feedback

* Fix import error

* ✅ Fix unit tests

* Update exports

* Update imports

* Update import

* Update imports

* Update imports

* Fix unit tests

* Fix unit tests

* Remove example

* Update plugin tests

* Update plugin tests

* Fix integration test

* Fix tests

* Fix plugin test

---------

Co-authored-by: Muhammad Talha <[email protected]>
Co-authored-by: !shan <[email protected]>
  • Loading branch information
3 people authored Dec 22, 2023
1 parent 2c17b70 commit 4f83f98
Show file tree
Hide file tree
Showing 220 changed files with 1,695 additions and 1,429 deletions.
6 changes: 3 additions & 3 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, ModuleMetadataJSON } 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,8 +34,8 @@ export abstract class BaseIPCClientCommand extends Command {

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

async finally(): Promise<void> {
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;
}
29 changes: 16 additions & 13 deletions commander/src/bootstrapping/commands/transaction/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import { validator } from '@liskhq/lisk-validator';
import { Command, Flags as flagParser } from '@oclif/core';
import {
Application,
PartialApplicationConfig,
RegisteredSchema,
Types,
blockHeaderSchema,
blockSchema,
transactionSchema,
ModuleMetadataJSON,
Modules,
} from 'lisk-framework';
import { PromiseResolvedType } from '../../../types';
import { deriveKeypair } from '../../../utils/commons';
Expand Down Expand Up @@ -74,7 +73,11 @@ interface Transaction {
signatures: never[];
}

const getParamsObject = async (metadata: ModuleMetadataJSON[], flags: CreateFlags, args: Args) => {
const getParamsObject = async (
metadata: Modules.ModuleMetadataJSON[],
flags: CreateFlags,
args: Args,
) => {
let params: Record<string, unknown>;

const paramsSchema = getParamsSchema(metadata, args.module, args.command);
Expand Down Expand Up @@ -112,8 +115,8 @@ const getKeysFromFlags = async (flags: CreateFlags) => {

const validateAndSignTransaction = (
transaction: Transaction,
schema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
schema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
chainID: string,
privateKey: Buffer,
noSignature: boolean,
Expand Down Expand Up @@ -145,8 +148,8 @@ const validateAndSignTransaction = (
const createTransactionOffline = async (
args: Args,
flags: CreateFlags,
registeredSchema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
registeredSchema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transaction: Transaction,
) => {
const params = await getParamsObject(metadata, flags, args);
Expand All @@ -169,8 +172,8 @@ const createTransactionOnline = async (
args: Args,
flags: CreateFlags,
client: apiClient.APIClient,
registeredSchema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
registeredSchema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transaction: Transaction,
) => {
const nodeInfo = await client.node.getNodeInfo();
Expand Down Expand Up @@ -275,8 +278,8 @@ export abstract class CreateCommand extends Command {
};

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

async run(): Promise<void> {
Expand Down Expand Up @@ -373,5 +376,5 @@ export abstract class CreateCommand extends Command {
}
}

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

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

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

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

async run(): Promise<void> {
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;
}
21 changes: 7 additions & 14 deletions commander/src/utils/genesis_creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
*/
import { Schema } from '@liskhq/lisk-codec';
import { address } from '@liskhq/lisk-cryptography';
import {
genesisInteroperabilitySchema,
MODULE_NAME_INTEROPERABILITY,
posGenesisStoreSchema,
PoSModule,
tokenGenesisStoreSchema,
TokenModule,
} from 'lisk-framework';
import { Modules } from 'lisk-framework';

export const genesisAssetsSchema = {
$id: '/genesis/asset/0',
Expand Down Expand Up @@ -91,7 +84,7 @@ export const generateGenesisBlockDefaultPoSAssets = (input: GenesisBlockDefaultA
);
const genesisAssets = [
{
module: new TokenModule().name,
module: new Modules.Token.TokenModule().name,
data: {
userSubstore: input.keysList.map(a => ({
address: a.address,
Expand All @@ -108,10 +101,10 @@ export const generateGenesisBlockDefaultPoSAssets = (input: GenesisBlockDefaultA
escrowSubstore: [],
supportedTokensSubstore: [],
} as Record<string, unknown>,
schema: tokenGenesisStoreSchema,
schema: Modules.Token.genesisTokenStoreSchema,
},
{
module: new PoSModule().name,
module: new Modules.PoS.PoSModule().name,
data: {
validators: input.keysList.map((v, i) => ({
address: v.address,
Expand All @@ -133,18 +126,18 @@ export const generateGenesisBlockDefaultPoSAssets = (input: GenesisBlockDefaultA
initValidators: input.keysList.slice(0, input.numberOfValidators).map(v => v.address),
},
} as Record<string, unknown>,
schema: posGenesisStoreSchema,
schema: Modules.PoS.genesisStoreSchema,
},
{
module: MODULE_NAME_INTEROPERABILITY,
module: Modules.Interoperability.MODULE_NAME_INTEROPERABILITY,
data: {
ownChainName: '',
ownChainNonce: 0,
chainInfos: [],
terminatedStateAccounts: [],
terminatedOutboxAccounts: [],
},
schema: genesisInteroperabilitySchema,
schema: Modules.Interoperability.genesisInteroperabilitySchema,
},
];

Expand Down
20 changes: 10 additions & 10 deletions commander/src/utils/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import * as liskApiClient from '@liskhq/lisk-api-client';
import * as cryptography from '@liskhq/lisk-cryptography';
import { codec } from '@liskhq/lisk-codec';
import { TransactionJSON } from '@liskhq/lisk-chain';
import { ModuleMetadataJSON, RegisteredSchema } from 'lisk-framework';
import { Modules, Types } from 'lisk-framework';

import { Schema } from '../types';
import { getDefaultPath } from './path';
import { isApplicationRunning } from './application';

export const getParamsSchema = (
metadata: ModuleMetadataJSON[],
metadata: Modules.ModuleMetadataJSON[],
module: string,
command: string,
): Schema => {
Expand All @@ -39,8 +39,8 @@ export const getParamsSchema = (
};

export const decodeTransaction = (
schema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
schema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transactionHexStr: string,
) => {
const transactionBytes = Buffer.from(transactionHexStr, 'hex');
Expand All @@ -59,8 +59,8 @@ export const decodeTransaction = (
};

export const encodeTransaction = (
schema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
schema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transaction: Record<string, unknown>,
apiClient?: liskApiClient.APIClient,
): Buffer => {
Expand All @@ -78,8 +78,8 @@ export const encodeTransaction = (
};

export const encodeTransactionJSON = (
schema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
schema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transaction: Record<string, unknown>,
apiClient?: liskApiClient.APIClient,
): Buffer => {
Expand All @@ -100,8 +100,8 @@ export const encodeTransactionJSON = (
};

export const transactionToJSON = (
schema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
schema: Types.RegisteredSchema,
metadata: Modules.ModuleMetadataJSON[],
transaction: Record<string, unknown>,
apiClient?: liskApiClient.APIClient,
): Record<string, unknown> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import * as fs from 'fs-extra';
import { ed } from '@liskhq/lisk-cryptography';
import { Application, IPCChannel, transactionSchema } from 'lisk-framework';
import { Application, Controller, transactionSchema } from 'lisk-framework';
import * as apiClient from '@liskhq/lisk-api-client';
import { codec } from '@liskhq/lisk-codec';
import { TransactionAttrs } from '@liskhq/lisk-chain';
Expand Down Expand Up @@ -101,8 +101,8 @@ describe('transaction:sign command', () => {
jest.spyOn(appUtils, 'isApplicationRunning').mockReturnValue(true);
jest.spyOn(fs, 'existsSync').mockReturnValue(true);
jest.spyOn(SignCommandExtended.prototype, 'printJSON').mockReturnValue();
jest.spyOn(IPCChannel.prototype, 'startAndListen').mockResolvedValue();
jest.spyOn(IPCChannel.prototype, 'invoke');
jest.spyOn(Controller.IPCChannel.prototype, 'startAndListen').mockResolvedValue();
jest.spyOn(Controller.IPCChannel.prototype, 'invoke');
jest.spyOn(readerUtils, 'getPassphraseFromPrompt').mockResolvedValue(senderPassphrase);
jest
.spyOn(apiClient, 'createIPCClient')
Expand Down
6 changes: 3 additions & 3 deletions examples/interop/pos-mainchain-fast/src/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Application, PartialApplicationConfig, NFTModule } from 'lisk-sdk';
import { Application, Types, Modules } from 'lisk-sdk';
import { TestNftModule } from './modules/testNft/module';
import { registerModules } from './modules';
import { registerPlugins } from './plugins';

export const getApplication = (config: PartialApplicationConfig): Application => {
export const getApplication = (config: Types.PartialApplicationConfig): Application => {
const { app, method } = Application.defaultApplication(config, true);

const nftModule = new NFTModule();
const nftModule = new Modules.NFT.NFTModule();
const testNftModule = new TestNftModule();
const interoperabilityModule = app['_registeredModules'].find(
mod => mod.name === 'interoperability',
Expand Down
Loading

0 comments on commit 4f83f98

Please sign in to comment.