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

Add TypeDocs for the NFT module #9155

Merged
merged 58 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b5511ef
Add module typdocs
Tschakki Nov 24, 2023
a277f26
Add module typdocs
Tschakki Nov 24, 2023
b63cb7c
Fix comment format
Tschakki Nov 24, 2023
80806ab
Add typedocs for nft methods
Tschakki Nov 27, 2023
214f927
Add typedocs for nft methods
Tschakki Nov 27, 2023
924d47e
Export constants
Tschakki Nov 27, 2023
6987b66
Update typedoc.json to include exports of the NFT module
Tschakki Nov 27, 2023
b1f6d2e
Restructure module exports
Tschakki Nov 30, 2023
af860b4
Restructure framework exports
Tschakki Nov 30, 2023
2cc3096
Update imports
Tschakki Dec 1, 2023
41af9da
Update example imports
Tschakki Dec 1, 2023
d05ed7b
Update example imports
Tschakki Dec 1, 2023
9f90fb9
Update example imports
Tschakki Dec 1, 2023
6c6e355
Fix format
Tschakki Dec 4, 2023
a5a1832
Fix lint error
Tschakki Dec 4, 2023
9a32aff
Update test imports
Tschakki Dec 4, 2023
084a2f1
Fix eslint
Tschakki Dec 4, 2023
2268223
Update imports of unit tests
Tschakki Dec 5, 2023
a295ad0
Update imports of unit tests
Tschakki Dec 5, 2023
e04639f
Update imports of unit tests
Tschakki Dec 5, 2023
7050d79
Update imports of unit tests
Tschakki Dec 5, 2023
4061b9d
Update imports of unit tests
Tschakki Dec 5, 2023
34041f4
Update imports of unit tests
Tschakki Dec 5, 2023
220e1e3
Fix logger export
Tschakki Dec 7, 2023
fa3ff09
Update imports in integration tests
Tschakki Dec 7, 2023
0203b0a
Fix conflicts
Tschakki Dec 7, 2023
89d0538
Fix errors
Tschakki Dec 7, 2023
39d1d32
Fix error
Tschakki Dec 7, 2023
e6eaff6
Update links
Tschakki Dec 7, 2023
251c921
Add typedocs for nft endpoints
Tschakki Dec 7, 2023
3d08f48
Add typedocs for nft endpoints
Tschakki Dec 7, 2023
b31234a
Add typedocs for commands
Tschakki Dec 7, 2023
3647376
Fix snippets
Tschakki Dec 7, 2023
cdd15de
Add section about cc nft transfers
Tschakki Dec 7, 2023
4cad911
Apply suggestions from code review
Tschakki Dec 8, 2023
48292e4
Update framework/src/modules/base_module.ts
Tschakki Dec 8, 2023
4f40de7
Reduce exports
Tschakki Dec 18, 2023
54f8ef5
Update framework/src/engine/consensus/index.ts
Tschakki Dec 18, 2023
ae01f0e
Apply feedback
Tschakki Dec 19, 2023
430b90f
Merge branch '9154-nft-module-typedocs' of github.com:LiskHQ/lisk-sdk…
Tschakki Dec 19, 2023
6eca9a7
Merge branch 'development' into 9154-nft-module-typedocs
ishantiw Dec 19, 2023
f832993
Fix import error
Tschakki Dec 19, 2023
bc45385
Merge branch '9154-nft-module-typedocs' of github.com:LiskHQ/lisk-sdk…
Tschakki Dec 19, 2023
2205d42
✅ Fix unit tests
ishantiw Dec 19, 2023
c45cf2f
Update exports
Tschakki Dec 21, 2023
300473f
Merge branch '9154-nft-module-typedocs' of github.com:LiskHQ/lisk-sdk…
Tschakki Dec 21, 2023
55a70f4
Update imports
Tschakki Dec 21, 2023
85d8b8d
Update import
Tschakki Dec 21, 2023
d5a7a8a
Update imports
Tschakki Dec 21, 2023
4382237
Update imports
Tschakki Dec 21, 2023
235f6b7
Fix unit tests
Tschakki Dec 21, 2023
d1a33a0
Fix unit tests
Tschakki Dec 21, 2023
480ab5c
Remove example
Tschakki Dec 21, 2023
7942968
Update plugin tests
Tschakki Dec 21, 2023
f197e7f
Update plugin tests
Tschakki Dec 22, 2023
924d5cd
Fix integration test
Tschakki Dec 22, 2023
4d4c57f
Fix tests
Tschakki Dec 22, 2023
3e7b2bb
Fix plugin test
Tschakki Dec 22, 2023
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
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, ModuleMetadataJSON } from 'lisk-framework';
import { RegisteredSchema, Modules } from 'lisk-framework';
import { PromiseResolvedType } from '../../types';
import { isApplicationRunning } from '../../utils/application';
import { flagsWithParser } from '../../utils/flags';
Expand All @@ -35,7 +35,7 @@ export abstract class BaseIPCClientCommand extends Command {
protected baseIPCClientFlags!: BaseIPCClientFlags;
protected _client!: PromiseResolvedType<ReturnType<typeof apiClient.createIPCClient>> | undefined;
protected _schema!: RegisteredSchema;
protected _metadata!: ModuleMetadataJSON[];
protected _metadata!: Modules.ModuleMetadataJSON[];
protected _dataPath!: string;

async finally(): Promise<void> {
Expand Down
16 changes: 10 additions & 6 deletions commander/src/bootstrapping/commands/transaction/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
blockHeaderSchema,
blockSchema,
transactionSchema,
ModuleMetadataJSON,
Modules,
} from 'lisk-framework';
import { PromiseResolvedType } from '../../../types';
import { deriveKeypair } from '../../../utils/commons';
Expand Down Expand Up @@ -74,7 +74,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 @@ -113,7 +117,7 @@ const getKeysFromFlags = async (flags: CreateFlags) => {
const validateAndSignTransaction = (
transaction: Transaction,
schema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
metadata: Modules.ModuleMetadataJSON[],
chainID: string,
privateKey: Buffer,
noSignature: boolean,
Expand Down Expand Up @@ -146,7 +150,7 @@ const createTransactionOffline = async (
args: Args,
flags: CreateFlags,
registeredSchema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
metadata: Modules.ModuleMetadataJSON[],
transaction: Transaction,
) => {
const params = await getParamsObject(metadata, flags, args);
Expand All @@ -170,7 +174,7 @@ const createTransactionOnline = async (
flags: CreateFlags,
client: apiClient.APIClient,
registeredSchema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
metadata: Modules.ModuleMetadataJSON[],
transaction: Transaction,
) => {
const nodeInfo = await client.node.getNodeInfo();
Expand Down Expand Up @@ -276,7 +280,7 @@ export abstract class CreateCommand extends Command {

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

async run(): Promise<void> {
Expand Down
10 changes: 5 additions & 5 deletions commander/src/bootstrapping/commands/transaction/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Application,
blockHeaderSchema,
blockSchema,
ModuleMetadataJSON,
Modules,
PartialApplicationConfig,
RegisteredSchema,
transactionSchema,
Expand Down Expand Up @@ -58,7 +58,7 @@ interface SignFlags {
const signTransaction = async (
flags: SignFlags,
registeredSchema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
metadata: Modules.ModuleMetadataJSON[],
transactionHexStr: string,
chainID: string | undefined,
keys: Keys,
Expand Down Expand Up @@ -106,7 +106,7 @@ const signTransaction = async (
const signTransactionOffline = async (
flags: SignFlags,
registeredSchema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
metadata: Modules.ModuleMetadataJSON[],
transactionHexStr: string,
): Promise<Record<string, unknown>> => {
const mandatoryKeys = flags['mandatory-keys'];
Expand All @@ -133,7 +133,7 @@ const signTransactionOnline = async (
flags: SignFlags,
client: apiClient.APIClient,
registeredSchema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
metadata: Modules.ModuleMetadataJSON[],
transactionHexStr: string,
) => {
const transactionObject = decodeTransaction(registeredSchema, metadata, transactionHexStr);
Expand Down Expand Up @@ -191,7 +191,7 @@ export abstract class SignCommand extends Command {

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

async run(): Promise<void> {
Expand Down
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
12 changes: 6 additions & 6 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, RegisteredSchema } 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 @@ -40,7 +40,7 @@ export const getParamsSchema = (

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

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

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

export const transactionToJSON = (
schema: RegisteredSchema,
metadata: ModuleMetadataJSON[],
metadata: Modules.ModuleMetadataJSON[],
transaction: Record<string, unknown>,
apiClient?: liskApiClient.APIClient,
): Record<string, unknown> => {
Expand Down
4 changes: 2 additions & 2 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, PartialApplicationConfig, Modules } from 'lisk-sdk';
import { TestNftModule } from './modules/testNft/module';
import { registerModules } from './modules';
import { registerPlugins } from './plugins';

export const getApplication = (config: 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
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
* Removal or modification of this copyright notice is prohibited.
*/

import { BaseCommand, CommandExecuteContext, NFTMethod } from 'lisk-sdk';
import { StateMachine, Modules } from 'lisk-sdk';
import { destroyNftParamsSchema } from '../schema';

interface Params {
address: Buffer;
nftID: Buffer;
}

export class DestroyNftCommand extends BaseCommand {
private _nftMethod!: NFTMethod;
export class DestroyNftCommand extends Modules.BaseCommand {
private _nftMethod!: Modules.NFT.NFTMethod;
public schema = destroyNftParamsSchema;

public init(args: { nftMethod: NFTMethod }): void {
public init(args: { nftMethod: Modules.NFT.NFTMethod }): void {
this._nftMethod = args.nftMethod;
}

public async execute(context: CommandExecuteContext<Params>): Promise<void> {
public async execute(context: StateMachine.CommandExecuteContext<Params>): Promise<void> {
const { params } = context;

await this._nftMethod.destroy(context.getMethodContext(), params.address, params.nftID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*/

import { BaseCommand, CommandExecuteContext, NFTMethod } from 'lisk-sdk';
import { StateMachine, Modules } from 'lisk-sdk';
import { NFTAttributes } from '../types';
import { mintNftParamsSchema } from '../schema';

Expand All @@ -22,15 +22,15 @@ interface Params {
attributesArray: NFTAttributes[];
}

export class MintNftCommand extends BaseCommand {
private _nftMethod!: NFTMethod;
export class MintNftCommand extends Modules.BaseCommand {
private _nftMethod!: Modules.NFT.NFTMethod;
public schema = mintNftParamsSchema;

public init(args: { nftMethod: NFTMethod }): void {
public init(args: { nftMethod: Modules.NFT.NFTMethod }): void {
this._nftMethod = args.nftMethod;
}

public async execute(context: CommandExecuteContext<Params>): Promise<void> {
public async execute(context: StateMachine.CommandExecuteContext<Params>): Promise<void> {
const { params } = context;

await this._nftMethod.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
* Removal or modification of this copyright notice is prohibited.
*/

import { BaseEndpoint } from 'lisk-sdk';
import { Modules } from 'lisk-sdk';

export class TestNftEndpoint extends BaseEndpoint {}
export class TestNftEndpoint extends Modules.BaseEndpoint {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
* Removal or modification of this copyright notice is prohibited.
*/

import { BaseMethod } from 'lisk-sdk';
import { Modules } from 'lisk-sdk';

export class TestNftMethod extends BaseMethod {}
export class TestNftMethod extends Modules.BaseMethod {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
* Removal or modification of this copyright notice is prohibited.
*/

import { BaseModule, ModuleInitArgs, ModuleMetadata, NFTMethod } from 'lisk-sdk';
import { Modules } from 'lisk-sdk';
import { TestNftEndpoint } from './endpoint';
import { TestNftMethod } from './method';
import { MintNftCommand } from './commands/mint_nft';
import { DestroyNftCommand } from './commands/destroy_nft';

export class TestNftModule extends BaseModule {
export class TestNftModule extends Modules.BaseModule {
public endpoint = new TestNftEndpoint(this.stores, this.offchainStores);
public method = new TestNftMethod(this.stores, this.events);
public mintNftCommand = new MintNftCommand(this.stores, this.events);
public destroyNftCommand = new DestroyNftCommand(this.stores, this.events);
public commands = [this.mintNftCommand, this.destroyNftCommand];

private _nftMethod!: NFTMethod;
private _nftMethod!: Modules.NFT.NFTMethod;

public addDependencies(nftMethod: NFTMethod) {
public addDependencies(nftMethod: Modules.NFT.NFTMethod) {
this._nftMethod = nftMethod;
}

public metadata(): ModuleMetadata {
public metadata(): Modules.ModuleMetadata {
return {
...this.baseMetadata(),
endpoints: [],
Expand All @@ -45,7 +45,7 @@ export class TestNftModule extends BaseModule {
}

// eslint-disable-next-line @typescript-eslint/require-await
public async init(_args: ModuleInitArgs) {
public async init(_args: Modules.ModuleInitArgs) {
this.mintNftCommand.init({
nftMethod: this._nftMethod,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/interop/pos-sidechain-example-one/src/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Application, PartialApplicationConfig, NFTModule } from 'lisk-sdk';
import { Application, PartialApplicationConfig, Modules } from 'lisk-sdk';
import { TestNftModule } from './modules/testNft/module';
import { registerModules } from './modules';
import { registerPlugins } from './plugins';
Expand All @@ -7,7 +7,7 @@ import { HelloModule } from './modules/hello/module';
export const getApplication = (config: PartialApplicationConfig): Application => {
const { app, method } = Application.defaultApplication(config, false);

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
Loading