Skip to content
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
9 changes: 9 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ module.exports = [
{ allowSameFolder: true, rootDir: 'src', prefix: '@' },
],

// Allow underscore-prefixed params/vars for intentionally unused values
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],

'prettier/prettier': 'error',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
getAccountBalance,
viewAccount,
} from '@/plugins/account';
import { createToken } from '@/plugins/token';
import { createFt } from '@/plugins/token';

describe('Create Token Integration Tests', () => {
let coreApi: CoreApi;
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Create Token Integration Tests', () => {
adminKey: 'account-create-token',
name: 'test-token',
};
const createTokenResult = await createToken({
const createTokenResult = await createFt({
args: createTokenArgs,
api: coreApi,
state: coreApi.state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { setDefaultOperatorForNetwork } from '@/__tests__/utils/network-and-oper
import { createCoreApi } from '@/core';
import { SupplyType } from '@/core/types/shared.types';
import {
createToken,
createFt,
deleteToken,
importToken,
listTokens,
Expand All @@ -38,7 +38,7 @@ describe('Import Token Integration Tests', () => {
supplyType: SupplyType.INFINITE,
name: `token-import-${Date.now()}`,
};
const createTokenResult = await createToken({
const createTokenResult = await createFt({
args: createTokenArgs,
api: coreApi,
state: coreApi.state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { STATE_STORAGE_FILE_PATH } from '@/__tests__/test-constants';
import { setDefaultOperatorForNetwork } from '@/__tests__/utils/network-and-operator-setup';
import { createCoreApi } from '@/core';
import { SupplyType } from '@/core/types/shared.types';
import { createToken, listTokens } from '@/plugins/token';
import { createFt, listTokens } from '@/plugins/token';

describe('List Token Integration Tests', () => {
let coreApi: CoreApi;
Expand All @@ -28,7 +28,7 @@ describe('List Token Integration Tests', () => {
supplyType: SupplyType.INFINITE,
name: 'test-token-list',
};
const createTokenResult = await createToken({
const createTokenResult = await createFt({
args: createTokenArgs,
api: coreApi,
state: coreApi.state,
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/integration/token/mint-ft.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getAccountBalance,
viewAccount,
} from '@/plugins/account';
import { createToken, mintFt } from '@/plugins/token';
import { createFt, mintFt } from '@/plugins/token';

describe('Mint FT Integration Tests', () => {
let coreApi: CoreApi;
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('Mint FT Integration Tests', () => {
supplyKey: `${process.env.OPERATOR_ID}:${process.env.OPERATOR_KEY}`,
name: 'test-token-mint',
};
const createTokenResult = await createToken({
const createTokenResult = await createFt({
args: createTokenArgs,
api: coreApi,
state: coreApi.state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
getAccountBalance,
viewAccount,
} from '@/plugins/account';
import { associateToken, createToken, transferFt } from '@/plugins/token';
import { associateToken, createFt, transferFt } from '@/plugins/token';

describe('Transfer Token Integration Tests', () => {
let coreApi: CoreApi;
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Transfer Token Integration Tests', () => {
supplyType: SupplyType.INFINITE,
name: 'test-token-transfer',
};
const createTokenResult = await createToken({
const createTokenResult = await createFt({
args: createTokenArgs,
api: coreApi,
state: coreApi.state,
Expand Down
19 changes: 13 additions & 6 deletions src/core/commands/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export abstract class BaseTransactionCommand<
TSignTransactionResult = unknown,
TExecuteTransactionResult = unknown,
> implements Command {
private commandName: string;

constructor(commandName: string) {
this.commandName = commandName;
}

async execute(args: CommandHandlerArgs): Promise<CommandResult> {
const preNormalizationHookResult =
await this.preParamsNormalizationHook(args);
Expand Down Expand Up @@ -99,7 +105,8 @@ export abstract class BaseTransactionCommand<
args: CommandHandlerArgs,
): Promise<HookResult> {
return await this.executeHooks(
async (h) => h.preParamsPreparationAndNormalizationHook(args),
async (h) =>
h.preParamsPreparationAndNormalizationHook(args, this.commandName),
args.hooks,
);
}
Expand All @@ -109,7 +116,7 @@ export abstract class BaseTransactionCommand<
params: PreBuildTransactionParams<TNormalisedParams>,
): Promise<HookResult> {
return await this.executeHooks(
async (h) => h.preBuildTransactionHook(args, params),
async (h) => h.preBuildTransactionHook(args, params, this.commandName),
args.hooks,
);
}
Expand All @@ -122,7 +129,7 @@ export abstract class BaseTransactionCommand<
>,
): Promise<HookResult> {
return await this.executeHooks(
async (h) => h.preSignTransactionHook(args, params),
async (h) => h.preSignTransactionHook(args, params, this.commandName),
args.hooks,
);
}
Expand All @@ -136,7 +143,7 @@ export abstract class BaseTransactionCommand<
>,
): Promise<HookResult> {
return await this.executeHooks(
async (h) => h.preExecuteTransactionHook(args, params),
async (h) => h.preExecuteTransactionHook(args, params, this.commandName),
args.hooks,
);
}
Expand All @@ -151,7 +158,7 @@ export abstract class BaseTransactionCommand<
>,
): Promise<HookResult> {
return await this.executeHooks(
async (h) => h.preOutputPreparationHook(args, params),
async (h) => h.preOutputPreparationHook(args, params, this.commandName),
args.hooks,
);
}
Expand All @@ -166,7 +173,7 @@ export abstract class BaseTransactionCommand<
>,
): Promise<HookResult> {
return await this.executeHooks(
async (h) => h.postOutputPreparationHook(args, params),
async (h) => h.postOutputPreparationHook(args, params, this.commandName),
args.hooks,
);
}
Expand Down
17 changes: 6 additions & 11 deletions src/core/hooks/abstract-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type {
export abstract class AbstractHook {
public preParamsPreparationAndNormalizationHook(
_args: CommandHandlerArgs,
_commandName: string,
): Promise<HookResult> {
void _args;
return Promise.resolve({
breakFlow: false,
result: {
Expand All @@ -24,9 +24,8 @@ export abstract class AbstractHook {
public preBuildTransactionHook(
_args: CommandHandlerArgs,
_params: PreBuildTransactionParams,
_commandName: string,
): Promise<HookResult> {
void _args;
void _params;
return Promise.resolve({
breakFlow: false,
result: {
Expand All @@ -38,9 +37,8 @@ export abstract class AbstractHook {
public preSignTransactionHook(
_args: CommandHandlerArgs,
_params: PreSignTransactionParams,
_commandName: string,
): Promise<HookResult> {
void _args;
void _params;
return Promise.resolve({
breakFlow: false,
result: {
Expand All @@ -52,9 +50,8 @@ export abstract class AbstractHook {
public preExecuteTransactionHook(
_args: CommandHandlerArgs,
_params: PreExecuteTransactionParams,
_commandName: string,
): Promise<HookResult> {
void _args;
void _params;
return Promise.resolve({
breakFlow: false,
result: {
Expand All @@ -66,9 +63,8 @@ export abstract class AbstractHook {
public preOutputPreparationHook(
_args: CommandHandlerArgs,
_params: PreOutputPreparationParams,
_commandName: string,
): Promise<HookResult> {
void _args;
void _params;
return Promise.resolve({
breakFlow: false,
result: {
Expand All @@ -80,9 +76,8 @@ export abstract class AbstractHook {
public postOutputPreparationHook(
_args: CommandHandlerArgs,
_params: PostOutputPreparationParams,
_commandName: string,
): Promise<HookResult> {
void _args;
void _params;
return Promise.resolve({
breakFlow: false,
result: {
Expand Down
13 changes: 11 additions & 2 deletions src/plugins/account/commands/create/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ import { ZustandAccountStateHelper } from '@/plugins/account/zustand-state-helpe

import { CreateAccountInputSchema } from './input';

export const ACCOUNT_CREATE_COMMAND_NAME = 'account_create';

export class CreateAccountCommand extends BaseTransactionCommand<
CreateNormalisedParams,
CreateBuildTransactionResult,
CreateSignTransactionResult,
CreateExecuteTransactionResult
> {
constructor() {
super(ACCOUNT_CREATE_COMMAND_NAME);
}

async normalizeParams(
args: CommandHandlerArgs,
): Promise<CreateNormalisedParams> {
Expand Down Expand Up @@ -198,5 +204,8 @@ export class CreateAccountCommand extends BaseTransactionCommand<
}
}

export const createAccount = (args: CommandHandlerArgs) =>
new CreateAccountCommand().execute(args);
export async function createAccount(
args: CommandHandlerArgs,
): Promise<CommandResult> {
return new CreateAccountCommand().execute(args);
}
6 changes: 5 additions & 1 deletion src/plugins/account/commands/create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
* Create Command Exports
* For use by tests and external consumers
*/
export { createAccount, CreateAccountCommand } from './handler';
export {
ACCOUNT_CREATE_COMMAND_NAME,
createAccount,
CreateAccountCommand,
} from './handler';
export type { CreateAccountOutput } from './output';
export { CREATE_ACCOUNT_TEMPLATE, CreateAccountOutputSchema } from './output';
1 change: 1 addition & 0 deletions src/plugins/account/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const accountPluginManifest: PluginManifest = {
summary: 'Create a new Hedera account',
description:
'Create a new Hedera account with specified balance and settings',
registeredHooks: ['batchify'],
options: [
{
name: 'balance',
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/batch/commands/create/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ZustandBatchStateHelper } from '@/plugins/batch/zustand-state-helper';

import { CreateBatchInputSchema } from './input';

export class CreateBatchCommand implements Command {
export class BatchCreateCommand implements Command {
async execute(args: CommandHandlerArgs): Promise<CommandResult> {
const { api, logger } = args;

Expand Down Expand Up @@ -56,8 +56,8 @@ export class CreateBatchCommand implements Command {
}
}

export async function createBatch(
export async function batchCreate(
args: CommandHandlerArgs,
): Promise<CommandResult> {
return new CreateBatchCommand().execute(args);
return new BatchCreateCommand().execute(args);
}
2 changes: 1 addition & 1 deletion src/plugins/batch/commands/create/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { createBatch, CreateBatchCommand } from './handler';
export { batchCreate, BatchCreateCommand } from './handler';
export type { CreateBatchOutput } from './output';
export { CREATE_BATCH_TEMPLATE, CreateBatchOutputSchema } from './output';
6 changes: 3 additions & 3 deletions src/plugins/batch/commands/delete/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ZustandBatchStateHelper } from '@/plugins/batch/zustand-state-helper';

import { DeleteBatchInputSchema } from './input';

export class DeleteBatchCommand implements Command {
export class BatchDeleteCommand implements Command {
async execute(args: CommandHandlerArgs): Promise<CommandResult> {
const { api, logger } = args;

Expand Down Expand Up @@ -65,8 +65,8 @@ export class DeleteBatchCommand implements Command {
}
}

export async function deleteBatch(
export async function batchDelete(
args: CommandHandlerArgs,
): Promise<CommandResult> {
return new DeleteBatchCommand().execute(args);
return new BatchDeleteCommand().execute(args);
}
2 changes: 1 addition & 1 deletion src/plugins/batch/commands/delete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
* Delete Command Exports
* For use by tests and external consumers
*/
export { deleteBatch, DeleteBatchCommand } from './handler';
export { batchDelete, BatchDeleteCommand } from './handler';
export type { DeleteBatchOutput } from './output';
export { DELETE_BATCH_TEMPLATE, DeleteBatchOutputSchema } from './output';
Loading
Loading