diff --git a/eslint.config.js b/eslint.config.js index 68871f531..af03649fa 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -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', }, }, diff --git a/src/__tests__/integration/token/create-token.integration.test.ts b/src/__tests__/integration/token/create-token.integration.test.ts index 656098a72..3cec483f3 100644 --- a/src/__tests__/integration/token/create-token.integration.test.ts +++ b/src/__tests__/integration/token/create-token.integration.test.ts @@ -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; @@ -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, diff --git a/src/__tests__/integration/token/import-token.integration.test.ts b/src/__tests__/integration/token/import-token.integration.test.ts index f1a10f5cc..880a3b6d4 100644 --- a/src/__tests__/integration/token/import-token.integration.test.ts +++ b/src/__tests__/integration/token/import-token.integration.test.ts @@ -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, @@ -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, diff --git a/src/__tests__/integration/token/list-token.integration.test.ts b/src/__tests__/integration/token/list-token.integration.test.ts index 6a3189351..1e0d0ca9a 100644 --- a/src/__tests__/integration/token/list-token.integration.test.ts +++ b/src/__tests__/integration/token/list-token.integration.test.ts @@ -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; @@ -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, diff --git a/src/__tests__/integration/token/mint-ft.integration.test.ts b/src/__tests__/integration/token/mint-ft.integration.test.ts index 79a6219b7..2ebf8c58a 100644 --- a/src/__tests__/integration/token/mint-ft.integration.test.ts +++ b/src/__tests__/integration/token/mint-ft.integration.test.ts @@ -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; @@ -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, diff --git a/src/__tests__/integration/token/transfer-token.integration.test.ts b/src/__tests__/integration/token/transfer-token.integration.test.ts index 1bb008ed7..7a9ac9707 100644 --- a/src/__tests__/integration/token/transfer-token.integration.test.ts +++ b/src/__tests__/integration/token/transfer-token.integration.test.ts @@ -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; @@ -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, diff --git a/src/core/commands/command.ts b/src/core/commands/command.ts index 1b65ccd07..f57c31322 100644 --- a/src/core/commands/command.ts +++ b/src/core/commands/command.ts @@ -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 { const preNormalizationHookResult = await this.preParamsNormalizationHook(args); @@ -99,7 +105,8 @@ export abstract class BaseTransactionCommand< args: CommandHandlerArgs, ): Promise { return await this.executeHooks( - async (h) => h.preParamsPreparationAndNormalizationHook(args), + async (h) => + h.preParamsPreparationAndNormalizationHook(args, this.commandName), args.hooks, ); } @@ -109,7 +116,7 @@ export abstract class BaseTransactionCommand< params: PreBuildTransactionParams, ): Promise { return await this.executeHooks( - async (h) => h.preBuildTransactionHook(args, params), + async (h) => h.preBuildTransactionHook(args, params, this.commandName), args.hooks, ); } @@ -122,7 +129,7 @@ export abstract class BaseTransactionCommand< >, ): Promise { return await this.executeHooks( - async (h) => h.preSignTransactionHook(args, params), + async (h) => h.preSignTransactionHook(args, params, this.commandName), args.hooks, ); } @@ -136,7 +143,7 @@ export abstract class BaseTransactionCommand< >, ): Promise { return await this.executeHooks( - async (h) => h.preExecuteTransactionHook(args, params), + async (h) => h.preExecuteTransactionHook(args, params, this.commandName), args.hooks, ); } @@ -151,7 +158,7 @@ export abstract class BaseTransactionCommand< >, ): Promise { return await this.executeHooks( - async (h) => h.preOutputPreparationHook(args, params), + async (h) => h.preOutputPreparationHook(args, params, this.commandName), args.hooks, ); } @@ -166,7 +173,7 @@ export abstract class BaseTransactionCommand< >, ): Promise { return await this.executeHooks( - async (h) => h.postOutputPreparationHook(args, params), + async (h) => h.postOutputPreparationHook(args, params, this.commandName), args.hooks, ); } diff --git a/src/core/hooks/abstract-hook.ts b/src/core/hooks/abstract-hook.ts index bc9b48f23..2a6791c03 100644 --- a/src/core/hooks/abstract-hook.ts +++ b/src/core/hooks/abstract-hook.ts @@ -11,8 +11,8 @@ import type { export abstract class AbstractHook { public preParamsPreparationAndNormalizationHook( _args: CommandHandlerArgs, + _commandName: string, ): Promise { - void _args; return Promise.resolve({ breakFlow: false, result: { @@ -24,9 +24,8 @@ export abstract class AbstractHook { public preBuildTransactionHook( _args: CommandHandlerArgs, _params: PreBuildTransactionParams, + _commandName: string, ): Promise { - void _args; - void _params; return Promise.resolve({ breakFlow: false, result: { @@ -38,9 +37,8 @@ export abstract class AbstractHook { public preSignTransactionHook( _args: CommandHandlerArgs, _params: PreSignTransactionParams, + _commandName: string, ): Promise { - void _args; - void _params; return Promise.resolve({ breakFlow: false, result: { @@ -52,9 +50,8 @@ export abstract class AbstractHook { public preExecuteTransactionHook( _args: CommandHandlerArgs, _params: PreExecuteTransactionParams, + _commandName: string, ): Promise { - void _args; - void _params; return Promise.resolve({ breakFlow: false, result: { @@ -66,9 +63,8 @@ export abstract class AbstractHook { public preOutputPreparationHook( _args: CommandHandlerArgs, _params: PreOutputPreparationParams, + _commandName: string, ): Promise { - void _args; - void _params; return Promise.resolve({ breakFlow: false, result: { @@ -80,9 +76,8 @@ export abstract class AbstractHook { public postOutputPreparationHook( _args: CommandHandlerArgs, _params: PostOutputPreparationParams, + _commandName: string, ): Promise { - void _args; - void _params; return Promise.resolve({ breakFlow: false, result: { diff --git a/src/plugins/account/commands/create/handler.ts b/src/plugins/account/commands/create/handler.ts index 82925d29a..036761d43 100644 --- a/src/plugins/account/commands/create/handler.ts +++ b/src/plugins/account/commands/create/handler.ts @@ -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 { @@ -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 { + return new CreateAccountCommand().execute(args); +} diff --git a/src/plugins/account/commands/create/index.ts b/src/plugins/account/commands/create/index.ts index d2d8eea31..01e5f1b77 100644 --- a/src/plugins/account/commands/create/index.ts +++ b/src/plugins/account/commands/create/index.ts @@ -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'; diff --git a/src/plugins/account/manifest.ts b/src/plugins/account/manifest.ts index 840637d4c..254b438fa 100644 --- a/src/plugins/account/manifest.ts +++ b/src/plugins/account/manifest.ts @@ -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', diff --git a/src/plugins/batch/commands/create/handler.ts b/src/plugins/batch/commands/create/handler.ts index 72f3f4215..28871f8f9 100644 --- a/src/plugins/batch/commands/create/handler.ts +++ b/src/plugins/batch/commands/create/handler.ts @@ -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 { const { api, logger } = args; @@ -56,8 +56,8 @@ export class CreateBatchCommand implements Command { } } -export async function createBatch( +export async function batchCreate( args: CommandHandlerArgs, ): Promise { - return new CreateBatchCommand().execute(args); + return new BatchCreateCommand().execute(args); } diff --git a/src/plugins/batch/commands/create/index.ts b/src/plugins/batch/commands/create/index.ts index 822a3fc0c..361178c7a 100644 --- a/src/plugins/batch/commands/create/index.ts +++ b/src/plugins/batch/commands/create/index.ts @@ -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'; diff --git a/src/plugins/batch/commands/delete/handler.ts b/src/plugins/batch/commands/delete/handler.ts index dcb57ab36..ac6f45f17 100644 --- a/src/plugins/batch/commands/delete/handler.ts +++ b/src/plugins/batch/commands/delete/handler.ts @@ -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 { const { api, logger } = args; @@ -65,8 +65,8 @@ export class DeleteBatchCommand implements Command { } } -export async function deleteBatch( +export async function batchDelete( args: CommandHandlerArgs, ): Promise { - return new DeleteBatchCommand().execute(args); + return new BatchDeleteCommand().execute(args); } diff --git a/src/plugins/batch/commands/delete/index.ts b/src/plugins/batch/commands/delete/index.ts index 2c9683b1a..a844de008 100644 --- a/src/plugins/batch/commands/delete/index.ts +++ b/src/plugins/batch/commands/delete/index.ts @@ -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'; diff --git a/src/plugins/batch/commands/execute/handler.ts b/src/plugins/batch/commands/execute/handler.ts index f57ad7d59..48d68c953 100644 --- a/src/plugins/batch/commands/execute/handler.ts +++ b/src/plugins/batch/commands/execute/handler.ts @@ -15,18 +15,23 @@ import { Transaction } from '@hashgraph/sdk'; import { ValidationError } from '@/core'; import { BaseTransactionCommand } from '@/core/commands/command'; import { NotFoundError } from '@/core/errors'; -import { CredentialType } from '@/core/services/kms/kms-types.interface'; import { composeKey } from '@/core/utils/key-composer'; import { ZustandBatchStateHelper } from '@/plugins/batch/zustand-state-helper'; import { ExecuteBatchInputSchema } from './input'; -export class ExecuteBatchCommand extends BaseTransactionCommand< +export const BATCH_EXECUTE_COMMAND_NAME = 'batch_execute'; + +export class BatchExecuteCommand extends BaseTransactionCommand< BatchNormalisedParams, BatchBuildTransactionResult, BatchSignTransactionResult, BatchExecuteTransactionResult > { + constructor() { + super(BATCH_EXECUTE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -43,11 +48,21 @@ export class ExecuteBatchCommand extends BaseTransactionCommand< if (batchData.executed) { throw new ValidationError(`Batch "${name}" has been already executed `); } + const operator = api.network.getOperator(network); + if (!operator) { + throw new NotFoundError(`Operator not found current network ${network}`); + } + const batchKey = api.kms.get(batchData.keyRefId); + if (!batchKey) { + throw new NotFoundError(`Batch key not found ${batchData.keyRefId}`); + } return { name, network, batchId: key, batchData, + batchKey, + operatorKeyRefId: operator.keyRefId, }; } async buildTransaction( @@ -55,20 +70,21 @@ export class ExecuteBatchCommand extends BaseTransactionCommand< normalisedParams: BatchNormalisedParams, ): Promise { const { api } = args; - const innerTransactions = [...normalisedParams.batchData.transactions] - .sort((a, b) => a.order - b.order) - .map((txItem) => { - return Transaction.fromBytes( - Uint8Array.from(Buffer.from(txItem.transactionBytes, 'hex')), - ); - }); - const batchKey = await api.keyResolver.getPublicKey( - { - type: CredentialType.KEY_REFERENCE, - keyReference: normalisedParams.batchData.keyRefId, - rawValue: normalisedParams.batchData.keyRefId, - }, - 'local', + const batchKey = normalisedParams.batchKey; + const operatorKeyRefId = normalisedParams.operatorKeyRefId; + const signingKeys = [batchKey.keyRefId]; + if (operatorKeyRefId != batchKey.keyRefId) { + signingKeys.push(operatorKeyRefId); + } + const innerTransactions = await Promise.all( + [...normalisedParams.batchData.transactions] + .sort((a, b) => a.order - b.order) + .map(async (txItem) => { + const transaction = Transaction.fromBytes( + Uint8Array.from(Buffer.from(txItem.transactionBytes, 'hex')), + ); + return api.txSign.sign(transaction, signingKeys); + }), ); const result = api.batch.createBatchTransaction({ transactions: innerTransactions, @@ -141,8 +157,8 @@ export class ExecuteBatchCommand extends BaseTransactionCommand< } } -export async function executeBatch( +export async function batchExecute( args: CommandHandlerArgs, ): Promise { - return new ExecuteBatchCommand().execute(args); + return new BatchExecuteCommand().execute(args); } diff --git a/src/plugins/batch/commands/execute/index.ts b/src/plugins/batch/commands/execute/index.ts index 01b9749c8..b5ddc0dc2 100644 --- a/src/plugins/batch/commands/execute/index.ts +++ b/src/plugins/batch/commands/execute/index.ts @@ -1,3 +1,7 @@ -export { executeBatch, ExecuteBatchCommand } from './handler'; +export { + BATCH_EXECUTE_COMMAND_NAME, + batchExecute, + BatchExecuteCommand, +} from './handler'; export type { ExecuteBatchOutput } from './output'; export { EXECUTE_BATCH_TEMPLATE, ExecuteBatchOutputSchema } from './output'; diff --git a/src/plugins/batch/commands/execute/types.ts b/src/plugins/batch/commands/execute/types.ts index b42c3b244..31201b256 100644 --- a/src/plugins/batch/commands/execute/types.ts +++ b/src/plugins/batch/commands/execute/types.ts @@ -1,5 +1,6 @@ import type { Transaction } from '@hashgraph/sdk'; import type { SupportedNetwork, TransactionResult } from '@/core'; +import type { KmsCredentialRecord } from '@/core/services/kms/kms-types.interface'; import type { BatchData } from '@/plugins/batch/schema'; export interface BatchNormalisedParams { @@ -7,6 +8,8 @@ export interface BatchNormalisedParams { network: SupportedNetwork; batchId: string; batchData: BatchData; + batchKey: KmsCredentialRecord; + operatorKeyRefId: string; } export interface BatchBuildTransactionResult { diff --git a/src/plugins/batch/commands/list/handler.ts b/src/plugins/batch/commands/list/handler.ts index bed13e855..625617242 100644 --- a/src/plugins/batch/commands/list/handler.ts +++ b/src/plugins/batch/commands/list/handler.ts @@ -12,7 +12,7 @@ import type { ListBatchesOutput } from './output'; import { ZustandBatchStateHelper } from '@/plugins/batch/zustand-state-helper'; -export class ListBatchCommand implements Command { +export class BatchListCommand implements Command { async execute(args: CommandHandlerArgs): Promise { const { api, logger } = args; @@ -38,8 +38,8 @@ export class ListBatchCommand implements Command { } } -export async function listBatch( +export async function batchList( args: CommandHandlerArgs, ): Promise { - return new ListBatchCommand().execute(args); + return new BatchListCommand().execute(args); } diff --git a/src/plugins/batch/commands/list/index.ts b/src/plugins/batch/commands/list/index.ts index 8858d5d4f..43080e9f6 100644 --- a/src/plugins/batch/commands/list/index.ts +++ b/src/plugins/batch/commands/list/index.ts @@ -2,6 +2,6 @@ * List Command Exports * For use by tests and external consumers */ -export { listBatch, ListBatchCommand } from './handler'; +export { batchList, BatchListCommand } from './handler'; export type { ListBatchesOutput } from './output'; export { LIST_BATCHES_TEMPLATE, ListBatchesOutputSchema } from './output'; diff --git a/src/plugins/batch/hooks/batchify/handler.ts b/src/plugins/batch/hooks/batchify/handler.ts index 8c2ba5cb0..acde3eb57 100644 --- a/src/plugins/batch/hooks/batchify/handler.ts +++ b/src/plugins/batch/hooks/batchify/handler.ts @@ -21,7 +21,7 @@ import { } from '@/plugins/batch/hooks/batchify/output'; import { ZustandBatchStateHelper } from '@/plugins/batch/zustand-state-helper'; -export class BatchifyHook extends AbstractHook { +export class BatchBatchifyHook extends AbstractHook { static readonly BATCH_MAXIMUM_SIZE = 50; override preSignTransactionHook( @@ -30,6 +30,7 @@ export class BatchifyHook extends AbstractHook { Record, BatchifySignTransactionResult >, + _commandName: string, ): Promise { const { api, logger } = args; const batchState = new ZustandBatchStateHelper(api.state, logger); @@ -74,13 +75,14 @@ export class BatchifyHook extends AbstractHook { }); } - override async preExecuteTransactionHook( + override preExecuteTransactionHook( args: CommandHandlerArgs, params: PreExecuteTransactionParams< Record, BatchifyBuildTransactionResult, BatchifySignTransactionResult >, + commandName: string, ): Promise { const { api, logger } = args; const batchState = new ZustandBatchStateHelper(api.state, logger); @@ -91,31 +93,26 @@ export class BatchifyHook extends AbstractHook { logger.debug( 'No parameter "batch" found. Transaction will not be added to batch.', ); - return { + return Promise.resolve({ breakFlow: false, result: { message: 'No "batch" parameter found', }, - }; + }); } const key = composeKey(network, batchName); const batch = batchState.getBatch(key); if (!batch) { throw new NotFoundError(`Batch not found for name ${batchName}`); } - if (batch.transactions.length >= BatchifyHook.BATCH_MAXIMUM_SIZE) { + if (batch.transactions.length >= BatchBatchifyHook.BATCH_MAXIMUM_SIZE) { throw new ValidationError( - `Couldn't add new transaction to batch ${batchName} as it will exceed batch transaction maximum size ${BatchifyHook.BATCH_MAXIMUM_SIZE}`, + `Couldn't add new transaction to batch ${batchName} as it will exceed batch transaction maximum size ${BatchBatchifyHook.BATCH_MAXIMUM_SIZE}`, ); } const transaction = params.signTransactionResult.transaction; - const signedTransaction = await api.txSign.sign(transaction, [ - batch.keyRefId, - ]); - const transactionBytes = Buffer.from(signedTransaction.toBytes()).toString( - 'hex', - ); + const transactionBytes = Buffer.from(transaction.toBytes()).toString('hex'); const highestOrder = batch.transactions.length === 0 ? 0 @@ -125,6 +122,8 @@ export class BatchifyHook extends AbstractHook { batch.transactions.push({ transactionBytes, order: nextOrder, + command: commandName, + normalizedParams: params.normalisedParams, }); batchState.saveBatch(key, batch); @@ -132,7 +131,7 @@ export class BatchifyHook extends AbstractHook { `Transaction added to batch '${batchName}' at position ${nextOrder}`, ); - return { + return Promise.resolve({ breakFlow: true, result: { batchName, @@ -140,6 +139,6 @@ export class BatchifyHook extends AbstractHook { }, schema: BatchifyOutputSchema, humanTemplate: BATCHIFY_TEMPLATE, - }; + }); } } diff --git a/src/plugins/batch/hooks/batchify/index.ts b/src/plugins/batch/hooks/batchify/index.ts index dec44adca..3a814a685 100644 --- a/src/plugins/batch/hooks/batchify/index.ts +++ b/src/plugins/batch/hooks/batchify/index.ts @@ -1,3 +1,3 @@ -export { BatchifyHook } from './handler'; +export { BatchBatchifyHook } from './handler'; export type { BatchifyOutput } from './output'; export { BATCHIFY_TEMPLATE, BatchifyOutputSchema } from './output'; diff --git a/src/plugins/batch/index.ts b/src/plugins/batch/index.ts index fcaf640aa..c8f3bd47a 100644 --- a/src/plugins/batch/index.ts +++ b/src/plugins/batch/index.ts @@ -2,8 +2,12 @@ * Batch Plugin * Exports plugin manifest and command handlers */ -export { createBatch, CreateBatchCommand } from './commands/create'; -export { deleteBatch, DeleteBatchCommand } from './commands/delete'; -export { executeBatch, ExecuteBatchCommand } from './commands/execute'; -export { listBatch, ListBatchCommand } from './commands/list'; +export { batchCreate, BatchCreateCommand } from './commands/create'; +export { batchDelete, BatchDeleteCommand } from './commands/delete'; +export { + BATCH_EXECUTE_COMMAND_NAME, + batchExecute, + BatchExecuteCommand, +} from './commands/execute'; +export { batchList, BatchListCommand } from './commands/list'; export { batchPluginManifest } from './manifest'; diff --git a/src/plugins/batch/manifest.ts b/src/plugins/batch/manifest.ts index 2f8b2c28a..26432b3eb 100644 --- a/src/plugins/batch/manifest.ts +++ b/src/plugins/batch/manifest.ts @@ -6,25 +6,25 @@ import type { PluginManifest } from '@/core'; import { OptionType } from '@/core/types/shared.types'; import { + batchList, LIST_BATCHES_TEMPLATE, - listBatch, ListBatchesOutputSchema, } from '@/plugins/batch/commands/list'; -import { BatchifyHook } from '@/plugins/batch/hooks/batchify/handler'; +import { BatchBatchifyHook } from '@/plugins/batch/hooks/batchify/handler'; import { + batchCreate, CREATE_BATCH_TEMPLATE, - createBatch, CreateBatchOutputSchema, } from './commands/create'; import { + batchDelete, DELETE_BATCH_TEMPLATE, - deleteBatch, DeleteBatchOutputSchema, } from './commands/delete'; import { + batchExecute, EXECUTE_BATCH_TEMPLATE, - executeBatch, ExecuteBatchOutputSchema, } from './commands/execute'; @@ -39,11 +39,11 @@ export const batchPluginManifest: PluginManifest = { hooks: [ { name: 'batchify', - hook: new BatchifyHook(), + hook: new BatchBatchifyHook(), options: [ { name: 'batch', - short: 'b', + short: 'B', type: OptionType.STRING, description: 'Name of the batch', }, @@ -81,7 +81,7 @@ export const batchPluginManifest: PluginManifest = { 'Key manager to use: local or local_encrypted (defaults to config setting)', }, ], - handler: createBatch, + handler: batchCreate, output: { schema: CreateBatchOutputSchema, humanTemplate: CREATE_BATCH_TEMPLATE, @@ -101,7 +101,7 @@ export const batchPluginManifest: PluginManifest = { description: 'Name of the batch to execute', }, ], - handler: executeBatch, + handler: batchExecute, output: { schema: ExecuteBatchOutputSchema, humanTemplate: EXECUTE_BATCH_TEMPLATE, @@ -112,7 +112,7 @@ export const batchPluginManifest: PluginManifest = { summary: 'List batches', description: 'List all available batches', options: [], - handler: listBatch, + handler: batchList, output: { schema: ListBatchesOutputSchema, humanTemplate: LIST_BATCHES_TEMPLATE, @@ -140,7 +140,7 @@ export const batchPluginManifest: PluginManifest = { 'Order of transaction to remove. If omitted, deletes the entire batch', }, ], - handler: deleteBatch, + handler: batchDelete, output: { schema: DeleteBatchOutputSchema, humanTemplate: DELETE_BATCH_TEMPLATE, diff --git a/src/plugins/batch/schema.ts b/src/plugins/batch/schema.ts index 6a8fc5685..8ae326b0d 100644 --- a/src/plugins/batch/schema.ts +++ b/src/plugins/batch/schema.ts @@ -8,11 +8,18 @@ import { AliasNameSchema } from '@/core/schemas/common-schemas'; /** Schema for a single batch list item */ export const BatchTransactionItemSchema = z.object({ - transactionBytes: z.string().min(1, 'Transaction raw bytes'), + transactionBytes: z.string().min(1).describe('Transaction raw bytes'), order: z .number() .int() .describe('Order of inner transaction in batch transaction'), + command: z.string().min(1).describe('Name of the command entry point'), + normalizedParams: z + .record(z.string(), z.unknown()) + .default({}) + .describe( + 'Normalized params from the command that produced this transaction', + ), }); // Zod schema for runtime validation diff --git a/src/plugins/contract-erc20/__tests__/unit/allowance.test.ts b/src/plugins/contract-erc20/__tests__/unit/allowance.test.ts index c14180b64..c9ba417b4 100644 --- a/src/plugins/contract-erc20/__tests__/unit/allowance.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/allowance.test.ts @@ -8,7 +8,7 @@ import { NotFoundError, StateError } from '@/core/errors'; import { makeContractErc20CallCommandArgs } from '@/plugins/contract-erc20/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallAllowanceOutputSchema } from '@/plugins/contract-erc20/commands/allowance'; -import { allowance as erc20AllowanceHandler } from '@/plugins/contract-erc20/commands/allowance/handler'; +import { contractErc20Allowance as erc20AllowanceHandler } from '@/plugins/contract-erc20/commands/allowance/handler'; import { ContractErc20CallAllowanceInputSchema } from '@/plugins/contract-erc20/commands/allowance/input'; const CONTRACT_ID = '0.0.1234'; diff --git a/src/plugins/contract-erc20/__tests__/unit/approve.test.ts b/src/plugins/contract-erc20/__tests__/unit/approve.test.ts index 11effb32a..acecca588 100644 --- a/src/plugins/contract-erc20/__tests__/unit/approve.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/approve.test.ts @@ -8,7 +8,7 @@ import { NotFoundError, TransactionError } from '@/core/errors'; import { makeContractErc20ExecuteCommandArgs } from '@/plugins/contract-erc20/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallApproveOutputSchema } from '@/plugins/contract-erc20/commands/approve'; -import { approve as erc20ApproveHandler } from '@/plugins/contract-erc20/commands/approve/handler'; +import { contractErc20Approve as erc20ApproveHandler } from '@/plugins/contract-erc20/commands/approve/handler'; import { ContractErc20CallApproveInputSchema } from '@/plugins/contract-erc20/commands/approve/input'; const mockAddAddress = jest.fn().mockReturnThis(); diff --git a/src/plugins/contract-erc20/__tests__/unit/balance-of.test.ts b/src/plugins/contract-erc20/__tests__/unit/balance-of.test.ts index 2e313b1e0..e56b606fd 100644 --- a/src/plugins/contract-erc20/__tests__/unit/balance-of.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/balance-of.test.ts @@ -8,7 +8,7 @@ import { NotFoundError, StateError } from '@/core/errors'; import { makeContractErc20CallCommandArgs } from '@/plugins/contract-erc20/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallBalanceOfOutputSchema } from '@/plugins/contract-erc20/commands/balance-of'; -import { balanceOf as erc20BalanceOfHandler } from '@/plugins/contract-erc20/commands/balance-of/handler'; +import { contractErc20BalanceOf as erc20BalanceOfHandler } from '@/plugins/contract-erc20/commands/balance-of/handler'; import { ContractErc20CallBalanceOfInputSchema } from '@/plugins/contract-erc20/commands/balance-of/input'; const mockSolidityAddress = '1234567890123456789012345678901234567890'; diff --git a/src/plugins/contract-erc20/__tests__/unit/decimals.test.ts b/src/plugins/contract-erc20/__tests__/unit/decimals.test.ts index 84664cd42..3c5404461 100644 --- a/src/plugins/contract-erc20/__tests__/unit/decimals.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/decimals.test.ts @@ -12,7 +12,7 @@ import { makeLogger, } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallDecimalsOutputSchema } from '@/plugins/contract-erc20/commands/decimals'; -import { decimals as erc20DecimalsHandler } from '@/plugins/contract-erc20/commands/decimals/handler'; +import { contractErc20Decimals as erc20DecimalsHandler } from '@/plugins/contract-erc20/commands/decimals/handler'; import { ContractErc20CallDecimalsInputSchema } from '@/plugins/contract-erc20/commands/decimals/input'; jest.mock('@hashgraph/sdk', () => ({ diff --git a/src/plugins/contract-erc20/__tests__/unit/name.test.ts b/src/plugins/contract-erc20/__tests__/unit/name.test.ts index bbde40f47..2979f1a60 100644 --- a/src/plugins/contract-erc20/__tests__/unit/name.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/name.test.ts @@ -8,7 +8,7 @@ import { StateError } from '@/core/errors'; import { makeContractErc20CallCommandArgs } from '@/plugins/contract-erc20/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallNameOutputSchema } from '@/plugins/contract-erc20/commands/name'; -import { name as erc20NameHandler } from '@/plugins/contract-erc20/commands/name/handler'; +import { contractErc20Name as erc20NameHandler } from '@/plugins/contract-erc20/commands/name/handler'; import { ContractErc20CallNameInputSchema } from '@/plugins/contract-erc20/commands/name/input'; jest.mock('@hashgraph/sdk', () => ({ diff --git a/src/plugins/contract-erc20/__tests__/unit/symbol.test.ts b/src/plugins/contract-erc20/__tests__/unit/symbol.test.ts index 99a315f39..fb32975e1 100644 --- a/src/plugins/contract-erc20/__tests__/unit/symbol.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/symbol.test.ts @@ -8,7 +8,7 @@ import { StateError } from '@/core/errors'; import { makeContractErc20CallCommandArgs } from '@/plugins/contract-erc20/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallSymbolOutputSchema } from '@/plugins/contract-erc20/commands/symbol'; -import { symbol as erc20SymbolHandler } from '@/plugins/contract-erc20/commands/symbol/handler'; +import { contractErc20Symbol as erc20SymbolHandler } from '@/plugins/contract-erc20/commands/symbol/handler'; import { ContractErc20CallSymbolInputSchema } from '@/plugins/contract-erc20/commands/symbol/input'; jest.mock('@hashgraph/sdk', () => ({ diff --git a/src/plugins/contract-erc20/__tests__/unit/total-supply.test.ts b/src/plugins/contract-erc20/__tests__/unit/total-supply.test.ts index 73d18bfdd..390d294c0 100644 --- a/src/plugins/contract-erc20/__tests__/unit/total-supply.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/total-supply.test.ts @@ -8,7 +8,7 @@ import { StateError } from '@/core/errors'; import { makeContractErc20CallCommandArgs } from '@/plugins/contract-erc20/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallTotalSupplyOutputSchema } from '@/plugins/contract-erc20/commands/total-supply'; -import { totalSupply as erc20TotalSupplyHandler } from '@/plugins/contract-erc20/commands/total-supply/handler'; +import { contractErc20TotalSupply as erc20TotalSupplyHandler } from '@/plugins/contract-erc20/commands/total-supply/handler'; import { ContractErc20CallTotalSupplyInputSchema } from '@/plugins/contract-erc20/commands/total-supply/input'; jest.mock('@hashgraph/sdk', () => ({ diff --git a/src/plugins/contract-erc20/__tests__/unit/transfer-from.test.ts b/src/plugins/contract-erc20/__tests__/unit/transfer-from.test.ts index bafbf110c..1443e876d 100644 --- a/src/plugins/contract-erc20/__tests__/unit/transfer-from.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/transfer-from.test.ts @@ -10,7 +10,7 @@ import { makeLogger, } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallTransferFromOutputSchema } from '@/plugins/contract-erc20/commands/transfer-from'; -import { transferFrom as erc20TransferFromHandler } from '@/plugins/contract-erc20/commands/transfer-from/handler'; +import { contractErc20TransferFrom as erc20TransferFromHandler } from '@/plugins/contract-erc20/commands/transfer-from/handler'; import { ContractErc20CallTransferFromInputSchema } from '@/plugins/contract-erc20/commands/transfer-from/input'; const mockAddAddress = jest.fn().mockReturnThis(); diff --git a/src/plugins/contract-erc20/__tests__/unit/transfer.test.ts b/src/plugins/contract-erc20/__tests__/unit/transfer.test.ts index 6135471c7..e0cf54b98 100644 --- a/src/plugins/contract-erc20/__tests__/unit/transfer.test.ts +++ b/src/plugins/contract-erc20/__tests__/unit/transfer.test.ts @@ -8,7 +8,7 @@ import { NotFoundError, TransactionError } from '@/core/errors'; import { makeContractErc20ExecuteCommandArgs } from '@/plugins/contract-erc20/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc20/__tests__/unit/helpers/mocks'; import { ContractErc20CallTransferOutputSchema } from '@/plugins/contract-erc20/commands/transfer'; -import { transfer as erc20TransferHandler } from '@/plugins/contract-erc20/commands/transfer/handler'; +import { contractErc20Transfer as erc20TransferHandler } from '@/plugins/contract-erc20/commands/transfer/handler'; import { ContractErc20CallTransferInputSchema } from '@/plugins/contract-erc20/commands/transfer/input'; const mockAddAddress = jest.fn().mockReturnThis(); diff --git a/src/plugins/contract-erc20/commands/allowance/handler.ts b/src/plugins/contract-erc20/commands/allowance/handler.ts index 5e69c8aa5..ae98a61f2 100644 --- a/src/plugins/contract-erc20/commands/allowance/handler.ts +++ b/src/plugins/contract-erc20/commands/allowance/handler.ts @@ -123,5 +123,8 @@ export class ContractErc20AllowanceCommand implements Command { } } -export const allowance = (args: CommandHandlerArgs) => - new ContractErc20AllowanceCommand().execute(args); +export async function contractErc20Allowance( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20AllowanceCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/allowance/index.ts b/src/plugins/contract-erc20/commands/allowance/index.ts index 7ce1db109..035d690fb 100644 --- a/src/plugins/contract-erc20/commands/allowance/index.ts +++ b/src/plugins/contract-erc20/commands/allowance/index.ts @@ -1,7 +1,10 @@ /** * Contract ERC20 allowance Command Exports */ -export { allowance, ContractErc20AllowanceCommand } from './handler'; +export { + contractErc20Allowance, + ContractErc20AllowanceCommand, +} from './handler'; export type { ContractErc20CallAllowanceOutput } from './output'; export { CONTRACT_ERC20_CALL_ALLOWANCE_CREATE_TEMPLATE, diff --git a/src/plugins/contract-erc20/commands/approve/handler.ts b/src/plugins/contract-erc20/commands/approve/handler.ts index fcb7f8eae..967196bf5 100644 --- a/src/plugins/contract-erc20/commands/approve/handler.ts +++ b/src/plugins/contract-erc20/commands/approve/handler.ts @@ -20,12 +20,18 @@ import { ContractErc20CallApproveInputSchema } from './input'; const ERC_20_FUNCTION_NAME = 'approve'; +export const CONTRACT_ERC20_APPROVE_COMMAND_NAME = 'contract-erc20_approve'; + export class ContractErc20ApproveCommand extends BaseTransactionCommand< ContractErc20ApproveNormalizedParams, ContractErc20ApproveBuildTransactionResult, ContractErc20ApproveSignTransactionResult, ContractErc20ApproveExecuteTransactionResult > { + constructor() { + super(CONTRACT_ERC20_APPROVE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -149,5 +155,8 @@ export class ContractErc20ApproveCommand extends BaseTransactionCommand< } } -export const approve = (args: CommandHandlerArgs) => - new ContractErc20ApproveCommand().execute(args); +export async function contractErc20Approve( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20ApproveCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/approve/index.ts b/src/plugins/contract-erc20/commands/approve/index.ts index 269b3bbdb..6869a6650 100644 --- a/src/plugins/contract-erc20/commands/approve/index.ts +++ b/src/plugins/contract-erc20/commands/approve/index.ts @@ -1,8 +1,8 @@ /** - * Contract function approve Command Exports + * Contract balanceOf Command Exports * For use by tests and external consumers */ -export { approve, ContractErc20ApproveCommand } from './handler'; +export { contractErc20Approve, ContractErc20ApproveCommand } from './handler'; export type { ContractErc20CallApproveOutput } from './output'; export { CONTRACT_ERC20_CALL_APPROVE_TEMPLATE, diff --git a/src/plugins/contract-erc20/commands/balance-of/handler.ts b/src/plugins/contract-erc20/commands/balance-of/handler.ts index 521ed3f8d..b6f424216 100644 --- a/src/plugins/contract-erc20/commands/balance-of/handler.ts +++ b/src/plugins/contract-erc20/commands/balance-of/handler.ts @@ -100,5 +100,8 @@ export class ContractErc20BalanceOfCommand implements Command { } } -export const balanceOf = (args: CommandHandlerArgs) => - new ContractErc20BalanceOfCommand().execute(args); +export async function contractErc20BalanceOf( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20BalanceOfCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/balance-of/index.ts b/src/plugins/contract-erc20/commands/balance-of/index.ts index 13c7781ff..741aafcb7 100644 --- a/src/plugins/contract-erc20/commands/balance-of/index.ts +++ b/src/plugins/contract-erc20/commands/balance-of/index.ts @@ -2,7 +2,10 @@ * Contract balanceOf Command Exports * For use by tests and external consumers */ -export { balanceOf, ContractErc20BalanceOfCommand } from './handler'; +export { + contractErc20BalanceOf, + ContractErc20BalanceOfCommand, +} from './handler'; export type { ContractErc20CallBalanceOfOutput } from './output'; export { CONTRACT_ERC20_CALL_BALANCE_OF_CREATE_TEMPLATE, diff --git a/src/plugins/contract-erc20/commands/decimals/handler.ts b/src/plugins/contract-erc20/commands/decimals/handler.ts index 8a4575bd4..0e51f892a 100644 --- a/src/plugins/contract-erc20/commands/decimals/handler.ts +++ b/src/plugins/contract-erc20/commands/decimals/handler.ts @@ -78,5 +78,8 @@ export class ContractErc20DecimalsCommand implements Command { } } -export const decimals = (args: CommandHandlerArgs) => - new ContractErc20DecimalsCommand().execute(args); +export async function contractErc20Decimals( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20DecimalsCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/decimals/index.ts b/src/plugins/contract-erc20/commands/decimals/index.ts index 881ac5344..61c5c69b7 100644 --- a/src/plugins/contract-erc20/commands/decimals/index.ts +++ b/src/plugins/contract-erc20/commands/decimals/index.ts @@ -2,7 +2,7 @@ * Contract function decimals Command Exports * For use by tests and external consumers */ -export { ContractErc20DecimalsCommand, decimals } from './handler'; +export { contractErc20Decimals, ContractErc20DecimalsCommand } from './handler'; export type { ContractErc20CallDecimalsOutput } from './output'; export { CONTRACT_ERC20_CALL_DECIMALS_TEMPLATE, diff --git a/src/plugins/contract-erc20/commands/name/handler.ts b/src/plugins/contract-erc20/commands/name/handler.ts index 5febca8a7..afaca0435 100644 --- a/src/plugins/contract-erc20/commands/name/handler.ts +++ b/src/plugins/contract-erc20/commands/name/handler.ts @@ -76,5 +76,8 @@ export class ContractErc20NameCommand implements Command { } } -export const name = (args: CommandHandlerArgs) => - new ContractErc20NameCommand().execute(args); +export async function contractErc20Name( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20NameCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/name/index.ts b/src/plugins/contract-erc20/commands/name/index.ts index 180d49cf4..3ac761247 100644 --- a/src/plugins/contract-erc20/commands/name/index.ts +++ b/src/plugins/contract-erc20/commands/name/index.ts @@ -2,7 +2,7 @@ * Contract ERC20 Name Command Exports * For use by tests and external consumers */ -export { ContractErc20NameCommand, name } from './handler'; +export { contractErc20Name, ContractErc20NameCommand } from './handler'; export type { ContractErc20CallNameOutput } from './output'; export { CONTRACT_ERC20_CALL_NAME_CREATE_TEMPLATE, diff --git a/src/plugins/contract-erc20/commands/symbol/handler.ts b/src/plugins/contract-erc20/commands/symbol/handler.ts index c56fb3422..9966952dc 100644 --- a/src/plugins/contract-erc20/commands/symbol/handler.ts +++ b/src/plugins/contract-erc20/commands/symbol/handler.ts @@ -78,5 +78,8 @@ export class ContractErc20SymbolCommand implements Command { } } -export const symbol = (args: CommandHandlerArgs) => - new ContractErc20SymbolCommand().execute(args); +export async function contractErc20Symbol( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20SymbolCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/symbol/index.ts b/src/plugins/contract-erc20/commands/symbol/index.ts index 84be56a39..8ad47671d 100644 --- a/src/plugins/contract-erc20/commands/symbol/index.ts +++ b/src/plugins/contract-erc20/commands/symbol/index.ts @@ -2,7 +2,7 @@ * Contract ERC20 Symbol Command Exports * For use by tests and external consumers */ -export { ContractErc20SymbolCommand, symbol } from './handler'; +export { contractErc20Symbol, ContractErc20SymbolCommand } from './handler'; export type { ContractErc20CallSymbolOutput } from './output'; export { CONTRACT_ERC20_CALL_SYMBOL_CREATE_TEMPLATE, diff --git a/src/plugins/contract-erc20/commands/total-supply/handler.ts b/src/plugins/contract-erc20/commands/total-supply/handler.ts index 7da3b404d..523961846 100644 --- a/src/plugins/contract-erc20/commands/total-supply/handler.ts +++ b/src/plugins/contract-erc20/commands/total-supply/handler.ts @@ -78,5 +78,8 @@ export class ContractErc20TotalSupplyCommand implements Command { } } -export const totalSupply = (args: CommandHandlerArgs) => - new ContractErc20TotalSupplyCommand().execute(args); +export async function contractErc20TotalSupply( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20TotalSupplyCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/total-supply/index.ts b/src/plugins/contract-erc20/commands/total-supply/index.ts index e06bcfa50..9258da157 100644 --- a/src/plugins/contract-erc20/commands/total-supply/index.ts +++ b/src/plugins/contract-erc20/commands/total-supply/index.ts @@ -2,7 +2,10 @@ * Contract totalSupply Command Exports * For use by tests and external consumers */ -export { ContractErc20TotalSupplyCommand, totalSupply } from './handler'; +export { + contractErc20TotalSupply, + ContractErc20TotalSupplyCommand, +} from './handler'; export type { ContractErc20CallTotalSupplyOutput } from './output'; export { CONTRACT_ERC20_CALL_TOTAL_SUPPLY_CREATE_TEMPLATE, diff --git a/src/plugins/contract-erc20/commands/transfer-from/handler.ts b/src/plugins/contract-erc20/commands/transfer-from/handler.ts index 0731924a6..f0690e7a3 100644 --- a/src/plugins/contract-erc20/commands/transfer-from/handler.ts +++ b/src/plugins/contract-erc20/commands/transfer-from/handler.ts @@ -20,12 +20,19 @@ import { ContractErc20CallTransferFromInputSchema } from './input'; const ERC_20_FUNCTION_NAME = 'transferFrom'; +export const CONTRACT_ERC20_TRANSFER_FROM_COMMAND_NAME = + 'contract-erc20_transfer-from'; + export class ContractErc20TransferFromCommand extends BaseTransactionCommand< ContractErc20TransferFromNormalizedParams, ContractErc20TransferFromBuildTransactionResult, ContractErc20TransferFromSignTransactionResult, ContractErc20TransferFromExecuteTransactionResult > { + constructor() { + super(CONTRACT_ERC20_TRANSFER_FROM_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -169,5 +176,8 @@ export class ContractErc20TransferFromCommand extends BaseTransactionCommand< } } -export const transferFrom = (args: CommandHandlerArgs) => - new ContractErc20TransferFromCommand().execute(args); +export async function contractErc20TransferFrom( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20TransferFromCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/transfer-from/index.ts b/src/plugins/contract-erc20/commands/transfer-from/index.ts index 0c64d6a3d..e1af15a53 100644 --- a/src/plugins/contract-erc20/commands/transfer-from/index.ts +++ b/src/plugins/contract-erc20/commands/transfer-from/index.ts @@ -1,8 +1,12 @@ /** - * Contract function transferFrom Command Exports + * Contract function transfer Command Exports * For use by tests and external consumers */ -export { ContractErc20TransferFromCommand, transferFrom } from './handler'; +export { + CONTRACT_ERC20_TRANSFER_FROM_COMMAND_NAME, + contractErc20TransferFrom, + ContractErc20TransferFromCommand, +} from './handler'; export type { ContractErc20CallTransferFromOutput } from './output'; export { CONTRACT_ERC20_CALL_TRANSFER_FROM_TEMPLATE, diff --git a/src/plugins/contract-erc20/commands/transfer/handler.ts b/src/plugins/contract-erc20/commands/transfer/handler.ts index 3c8e654ec..7090cda3c 100644 --- a/src/plugins/contract-erc20/commands/transfer/handler.ts +++ b/src/plugins/contract-erc20/commands/transfer/handler.ts @@ -20,12 +20,18 @@ import { ContractErc20CallTransferInputSchema } from './input'; const ERC_20_FUNCTION_NAME = 'transfer'; +export const CONTRACT_ERC20_TRANSFER_COMMAND_NAME = 'contract-erc20_transfer'; + export class ContractErc20TransferCommand extends BaseTransactionCommand< ContractErc20TransferNormalizedParams, ContractErc20TransferBuildTransactionResult, ContractErc20TransferSignTransactionResult, ContractErc20TransferExecuteTransactionResult > { + constructor() { + super(CONTRACT_ERC20_TRANSFER_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -148,5 +154,8 @@ export class ContractErc20TransferCommand extends BaseTransactionCommand< } } -export const transfer = (args: CommandHandlerArgs) => - new ContractErc20TransferCommand().execute(args); +export async function contractErc20Transfer( + args: CommandHandlerArgs, +): Promise { + return new ContractErc20TransferCommand().execute(args); +} diff --git a/src/plugins/contract-erc20/commands/transfer/index.ts b/src/plugins/contract-erc20/commands/transfer/index.ts index 08a9f2c20..cb7662d9c 100644 --- a/src/plugins/contract-erc20/commands/transfer/index.ts +++ b/src/plugins/contract-erc20/commands/transfer/index.ts @@ -2,7 +2,11 @@ * Contract function transfer Command Exports * For use by tests and external consumers */ -export { ContractErc20TransferCommand, transfer } from './handler'; +export { + CONTRACT_ERC20_TRANSFER_COMMAND_NAME, + contractErc20Transfer, + ContractErc20TransferCommand, +} from './handler'; export type { ContractErc20CallTransferOutput } from './output'; export { CONTRACT_ERC20_CALL_TRANSFER_TEMPLATE, diff --git a/src/plugins/contract-erc20/index.ts b/src/plugins/contract-erc20/index.ts index 1e227674e..9586a153c 100644 --- a/src/plugins/contract-erc20/index.ts +++ b/src/plugins/contract-erc20/index.ts @@ -2,12 +2,12 @@ * Contract ERC-20 Plugin Index * Exports the Contract ERC-20 plugin manifest */ -export { allowance } from './commands/allowance'; -export { approve } from './commands/approve'; -export { balanceOf } from './commands/balance-of'; -export { name } from './commands/name'; -export { symbol } from './commands/symbol'; -export { totalSupply } from './commands/total-supply'; -export { transfer } from './commands/transfer'; -export { transferFrom } from './commands/transfer-from'; +export { contractErc20Allowance } from './commands/allowance'; +export { contractErc20Approve } from './commands/approve'; +export { contractErc20BalanceOf } from './commands/balance-of'; +export { contractErc20Name } from './commands/name'; +export { contractErc20Symbol } from './commands/symbol'; +export { contractErc20TotalSupply } from './commands/total-supply'; +export { contractErc20Transfer } from './commands/transfer'; +export { contractErc20TransferFrom } from './commands/transfer-from'; export { contractErc20PluginManifest } from './manifest'; diff --git a/src/plugins/contract-erc20/manifest.ts b/src/plugins/contract-erc20/manifest.ts index f8dfc6e50..3aa6d01ed 100644 --- a/src/plugins/contract-erc20/manifest.ts +++ b/src/plugins/contract-erc20/manifest.ts @@ -6,49 +6,49 @@ import type { PluginManifest } from '@/core'; import { OptionType } from '@/core/types/shared.types'; import { - allowance, CONTRACT_ERC20_CALL_ALLOWANCE_CREATE_TEMPLATE, + contractErc20Allowance, ContractErc20CallAllowanceOutputSchema, } from '@/plugins/contract-erc20/commands/allowance'; import { - approve, CONTRACT_ERC20_CALL_APPROVE_TEMPLATE, + contractErc20Approve, ContractErc20CallApproveOutputSchema, } from '@/plugins/contract-erc20/commands/approve'; import { - balanceOf, CONTRACT_ERC20_CALL_BALANCE_OF_CREATE_TEMPLATE, + contractErc20BalanceOf, ContractErc20CallBalanceOfOutputSchema, } from '@/plugins/contract-erc20/commands/balance-of'; import { CONTRACT_ERC20_CALL_DECIMALS_TEMPLATE, ContractErc20CallDecimalsOutputSchema, - decimals, + contractErc20Decimals, } from '@/plugins/contract-erc20/commands/decimals'; import { CONTRACT_ERC20_CALL_NAME_CREATE_TEMPLATE, ContractErc20CallNameOutputSchema, - name, + contractErc20Name, } from '@/plugins/contract-erc20/commands/name'; import { CONTRACT_ERC20_CALL_SYMBOL_CREATE_TEMPLATE, ContractErc20CallSymbolOutputSchema, - symbol, + contractErc20Symbol, } from '@/plugins/contract-erc20/commands/symbol'; import { CONTRACT_ERC20_CALL_TOTAL_SUPPLY_CREATE_TEMPLATE, ContractErc20CallTotalSupplyOutputSchema, - totalSupply, + contractErc20TotalSupply, } from '@/plugins/contract-erc20/commands/total-supply'; import { CONTRACT_ERC20_CALL_TRANSFER_TEMPLATE, ContractErc20CallTransferOutputSchema, - transfer, + contractErc20Transfer, } from '@/plugins/contract-erc20/commands/transfer'; import { CONTRACT_ERC20_CALL_TRANSFER_FROM_TEMPLATE, ContractErc20CallTransferFromOutputSchema, - transferFrom, + contractErc20TransferFrom, } from '@/plugins/contract-erc20/commands/transfer-from'; export const contractErc20PluginManifest: PluginManifest = { @@ -70,7 +70,7 @@ export const contractErc20PluginManifest: PluginManifest = { description: 'Smart contract ID represented by alias or contract ID', }, ], - handler: name, + handler: contractErc20Name, output: { schema: ContractErc20CallNameOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_NAME_CREATE_TEMPLATE, @@ -89,7 +89,7 @@ export const contractErc20PluginManifest: PluginManifest = { description: 'Smart contract ID represented by alias or contract ID', }, ], - handler: symbol, + handler: contractErc20Symbol, output: { schema: ContractErc20CallSymbolOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_SYMBOL_CREATE_TEMPLATE, @@ -108,7 +108,7 @@ export const contractErc20PluginManifest: PluginManifest = { description: 'Smart contract ID represented by alias or contract ID', }, ], - handler: decimals, + handler: contractErc20Decimals, output: { schema: ContractErc20CallDecimalsOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_DECIMALS_TEMPLATE, @@ -143,7 +143,7 @@ export const contractErc20PluginManifest: PluginManifest = { 'Spender account represented by alias, account ID or EVM address', }, ], - handler: allowance, + handler: contractErc20Allowance, output: { schema: ContractErc20CallAllowanceOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_ALLOWANCE_CREATE_TEMPLATE, @@ -170,7 +170,7 @@ export const contractErc20PluginManifest: PluginManifest = { 'Account represented by alias, account ID, or EVM address', }, ], - handler: balanceOf, + handler: contractErc20BalanceOf, output: { schema: ContractErc20CallBalanceOfOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_BALANCE_OF_CREATE_TEMPLATE, @@ -214,7 +214,7 @@ export const contractErc20PluginManifest: PluginManifest = { description: 'Gas for function call. Default: 100000', }, ], - handler: transfer, + handler: contractErc20Transfer, output: { schema: ContractErc20CallTransferOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_TRANSFER_TEMPLATE, @@ -266,7 +266,7 @@ export const contractErc20PluginManifest: PluginManifest = { description: 'Gas for function call. Default: 100000', }, ], - handler: transferFrom, + handler: contractErc20TransferFrom, output: { schema: ContractErc20CallTransferFromOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_TRANSFER_FROM_TEMPLATE, @@ -310,7 +310,7 @@ export const contractErc20PluginManifest: PluginManifest = { description: 'Gas for function call. Default: 100000', }, ], - handler: approve, + handler: contractErc20Approve, output: { schema: ContractErc20CallApproveOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_APPROVE_TEMPLATE, @@ -329,7 +329,7 @@ export const contractErc20PluginManifest: PluginManifest = { description: 'Smart contract ID represented by alias or contract ID', }, ], - handler: totalSupply, + handler: contractErc20TotalSupply, output: { schema: ContractErc20CallTotalSupplyOutputSchema, humanTemplate: CONTRACT_ERC20_CALL_TOTAL_SUPPLY_CREATE_TEMPLATE, diff --git a/src/plugins/contract-erc721/__tests__/unit/approve.test.ts b/src/plugins/contract-erc721/__tests__/unit/approve.test.ts index 64ed242fd..4a9bccb04 100644 --- a/src/plugins/contract-erc721/__tests__/unit/approve.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/approve.test.ts @@ -20,7 +20,7 @@ import { } from '@/plugins/contract-erc721/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { - approveFunctionCall, + contractErc721ApproveFunctionCall, ContractErc721CallApproveOutputSchema, } from '@/plugins/contract-erc721/commands/approve'; import { ContractErc721CallApproveInputSchema } from '@/plugins/contract-erc721/commands/approve/input'; @@ -90,7 +90,7 @@ describe('contract-erc721 plugin - approve command (unit)', () => { }, }); - const result = await approveFunctionCall(args); + const result = await contractErc721ApproveFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -135,7 +135,7 @@ describe('contract-erc721 plugin - approve command (unit)', () => { }, }); - const result = await approveFunctionCall(args); + const result = await contractErc721ApproveFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveContract).toHaveBeenCalledWith({ @@ -163,7 +163,7 @@ describe('contract-erc721 plugin - approve command (unit)', () => { }, }); - const result = await approveFunctionCall(args); + const result = await contractErc721ApproveFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveAccount).not.toHaveBeenCalled(); @@ -187,8 +187,10 @@ describe('contract-erc721 plugin - approve command (unit)', () => { receipt: { status: { status: 'FAILURE' } }, }); - await expect(approveFunctionCall(args)).rejects.toThrow(TransactionError); - await expect(approveFunctionCall(args)).rejects.toThrow( + await expect(contractErc721ApproveFunctionCall(args)).rejects.toThrow( + TransactionError, + ); + await expect(contractErc721ApproveFunctionCall(args)).rejects.toThrow( 'Failed to call approve on contract 0.0.1234 (txId: undefined, status: FAILURE)', ); }); @@ -208,7 +210,9 @@ describe('contract-erc721 plugin - approve command (unit)', () => { new Error('network error'), ); - await expect(approveFunctionCall(args)).rejects.toThrow('network error'); + await expect(contractErc721ApproveFunctionCall(args)).rejects.toThrow( + 'network error', + ); }); test('propagates error when contract not found', async () => { @@ -231,7 +235,9 @@ describe('contract-erc721 plugin - approve command (unit)', () => { ), ); - await expect(approveFunctionCall(args)).rejects.toThrow('not found'); + await expect(contractErc721ApproveFunctionCall(args)).rejects.toThrow( + 'not found', + ); }); test('throws NotFoundError when to has no evmAddress', async () => { @@ -254,8 +260,10 @@ describe('contract-erc721 plugin - approve command (unit)', () => { }, ); - await expect(approveFunctionCall(args)).rejects.toThrow(NotFoundError); - await expect(approveFunctionCall(args)).rejects.toThrow( + await expect(contractErc721ApproveFunctionCall(args)).rejects.toThrow( + NotFoundError, + ); + await expect(contractErc721ApproveFunctionCall(args)).rejects.toThrow( "Couldn't resolve EVM address for an account", ); }); diff --git a/src/plugins/contract-erc721/__tests__/unit/balance-of.test.ts b/src/plugins/contract-erc721/__tests__/unit/balance-of.test.ts index b4d0da8ce..a462b0e24 100644 --- a/src/plugins/contract-erc721/__tests__/unit/balance-of.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/balance-of.test.ts @@ -18,7 +18,7 @@ import { } from '@/plugins/contract-erc721/__tests__/unit/helpers/fixtures'; import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { - balanceOfFunctionCall, + contractErc721BalanceOfFunctionCall, ContractErc721CallBalanceOfOutputSchema, } from '@/plugins/contract-erc721/commands/balance-of'; import { ContractErc721CallBalanceOfInputSchema } from '@/plugins/contract-erc721/commands/balance-of/input'; @@ -78,7 +78,7 @@ describe('contract-erc721 plugin - balanceOf command (unit)', () => { }, }); - const result = await balanceOfFunctionCall(args); + const result = await contractErc721BalanceOfFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -125,7 +125,7 @@ describe('contract-erc721 plugin - balanceOf command (unit)', () => { }, ); - const result = await balanceOfFunctionCall(args); + const result = await contractErc721BalanceOfFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -158,7 +158,7 @@ describe('contract-erc721 plugin - balanceOf command (unit)', () => { }, ); - const result = await balanceOfFunctionCall(args); + const result = await contractErc721BalanceOfFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveAccount).toHaveBeenCalledWith({ @@ -189,8 +189,10 @@ describe('contract-erc721 plugin - balanceOf command (unit)', () => { queryResult: [], }); - await expect(balanceOfFunctionCall(args)).rejects.toThrow(StateError); - await expect(balanceOfFunctionCall(args)).rejects.toThrow( + await expect(contractErc721BalanceOfFunctionCall(args)).rejects.toThrow( + StateError, + ); + await expect(contractErc721BalanceOfFunctionCall(args)).rejects.toThrow( `There was a problem with decoding contract ${MOCK_CONTRACT_ID} "balanceOf" function result`, ); }); @@ -208,7 +210,7 @@ describe('contract-erc721 plugin - balanceOf command (unit)', () => { args.api.contractQuery.queryContractFunction as jest.Mock ).mockRejectedValue(new Error('contract query error')); - await expect(balanceOfFunctionCall(args)).rejects.toThrow( + await expect(contractErc721BalanceOfFunctionCall(args)).rejects.toThrow( 'contract query error', ); }); diff --git a/src/plugins/contract-erc721/__tests__/unit/get-approved.test.ts b/src/plugins/contract-erc721/__tests__/unit/get-approved.test.ts index ab412064e..4e61378ed 100644 --- a/src/plugins/contract-erc721/__tests__/unit/get-approved.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/get-approved.test.ts @@ -12,7 +12,7 @@ import { makeContractErc721CallCommandArgs } from '@/plugins/contract-erc721/__t import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallGetApprovedOutputSchema, - getApprovedFunctionCall, + contractErc721GetApprovedFunctionCall, } from '@/plugins/contract-erc721/commands/get-approved'; import { ContractErc721CallGetApprovedInputSchema } from '@/plugins/contract-erc721/commands/get-approved/input'; @@ -57,7 +57,7 @@ describe('contract-erc721 plugin - getApproved command (unit)', () => { }, }); - const result = await getApprovedFunctionCall(args); + const result = await contractErc721GetApprovedFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -105,8 +105,10 @@ describe('contract-erc721 plugin - getApproved command (unit)', () => { queryResult: [], }); - await expect(getApprovedFunctionCall(args)).rejects.toThrow(StateError); - await expect(getApprovedFunctionCall(args)).rejects.toThrow( + await expect(contractErc721GetApprovedFunctionCall(args)).rejects.toThrow( + StateError, + ); + await expect(contractErc721GetApprovedFunctionCall(args)).rejects.toThrow( `There was a problem with decoding contract ${MOCK_CONTRACT_ID} "getApproved" function result`, ); }); @@ -125,7 +127,7 @@ describe('contract-erc721 plugin - getApproved command (unit)', () => { args.api.contractQuery.queryContractFunction as jest.Mock ).mockRejectedValue(new Error('contract query error')); - await expect(getApprovedFunctionCall(args)).rejects.toThrow( + await expect(contractErc721GetApprovedFunctionCall(args)).rejects.toThrow( 'contract query error', ); }); diff --git a/src/plugins/contract-erc721/__tests__/unit/mint.test.ts b/src/plugins/contract-erc721/__tests__/unit/mint.test.ts index 5fd112893..c0ad72618 100644 --- a/src/plugins/contract-erc721/__tests__/unit/mint.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/mint.test.ts @@ -21,7 +21,7 @@ import { import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallMintOutputSchema, - mintFunctionCall, + contractErc721MintFunctionCall, } from '@/plugins/contract-erc721/commands/mint'; import { ContractErc721CallMintInputSchema } from '@/plugins/contract-erc721/commands/mint/input'; @@ -90,7 +90,7 @@ describe('contract-erc721 plugin - mint command (unit)', () => { }, }); - const result = await mintFunctionCall(args); + const result = await contractErc721MintFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -135,7 +135,7 @@ describe('contract-erc721 plugin - mint command (unit)', () => { }, }); - const result = await mintFunctionCall(args); + const result = await contractErc721MintFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveContract).toHaveBeenCalledWith({ @@ -163,7 +163,7 @@ describe('contract-erc721 plugin - mint command (unit)', () => { }, }); - const result = await mintFunctionCall(args); + const result = await contractErc721MintFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveAccount).not.toHaveBeenCalled(); @@ -187,8 +187,10 @@ describe('contract-erc721 plugin - mint command (unit)', () => { receipt: { status: { status: 'FAILURE' } }, }); - await expect(mintFunctionCall(args)).rejects.toThrow(TransactionError); - await expect(mintFunctionCall(args)).rejects.toThrow( + await expect(contractErc721MintFunctionCall(args)).rejects.toThrow( + TransactionError, + ); + await expect(contractErc721MintFunctionCall(args)).rejects.toThrow( 'Failed to call mint on contract 0.0.1234 (txId: undefined, status: FAILURE)', ); }); @@ -208,7 +210,9 @@ describe('contract-erc721 plugin - mint command (unit)', () => { new Error('network error'), ); - await expect(mintFunctionCall(args)).rejects.toThrow('network error'); + await expect(contractErc721MintFunctionCall(args)).rejects.toThrow( + 'network error', + ); }); test('propagates error when contract not found', async () => { @@ -231,7 +235,9 @@ describe('contract-erc721 plugin - mint command (unit)', () => { ), ); - await expect(mintFunctionCall(args)).rejects.toThrow('not found'); + await expect(contractErc721MintFunctionCall(args)).rejects.toThrow( + 'not found', + ); }); test('throws NotFoundError when to has no evmAddress', async () => { @@ -254,8 +260,10 @@ describe('contract-erc721 plugin - mint command (unit)', () => { }, ); - await expect(mintFunctionCall(args)).rejects.toThrow(NotFoundError); - await expect(mintFunctionCall(args)).rejects.toThrow( + await expect(contractErc721MintFunctionCall(args)).rejects.toThrow( + NotFoundError, + ); + await expect(contractErc721MintFunctionCall(args)).rejects.toThrow( "Couldn't resolve EVM address for an account", ); }); diff --git a/src/plugins/contract-erc721/__tests__/unit/name.test.ts b/src/plugins/contract-erc721/__tests__/unit/name.test.ts index ad19afceb..fa7a02df7 100644 --- a/src/plugins/contract-erc721/__tests__/unit/name.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/name.test.ts @@ -11,7 +11,7 @@ import { makeContractErc721CallCommandArgs } from '@/plugins/contract-erc721/__t import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallNameOutputSchema, - nameFunctionCall, + contractErc721NameFunctionCall, } from '@/plugins/contract-erc721/commands/name'; import { ContractErc721CallNameInputSchema } from '@/plugins/contract-erc721/commands/name/input'; @@ -67,7 +67,7 @@ describe('contract-erc721 plugin - name command (unit)', () => { }, }); - const result = await nameFunctionCall(args); + const result = await contractErc721NameFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -104,7 +104,7 @@ describe('contract-erc721 plugin - name command (unit)', () => { }, }); - const result = await nameFunctionCall(args); + const result = await contractErc721NameFunctionCall(args); expect(result.result).toBeDefined(); expect( @@ -139,8 +139,10 @@ describe('contract-erc721 plugin - name command (unit)', () => { queryResult: [], }); - await expect(nameFunctionCall(args)).rejects.toThrow(StateError); - await expect(nameFunctionCall(args)).rejects.toThrow( + await expect(contractErc721NameFunctionCall(args)).rejects.toThrow( + StateError, + ); + await expect(contractErc721NameFunctionCall(args)).rejects.toThrow( `There was a problem with decoding contract ${MOCK_CONTRACT_ID} "name" function result`, ); }); @@ -157,7 +159,7 @@ describe('contract-erc721 plugin - name command (unit)', () => { args.api.contractQuery.queryContractFunction as jest.Mock ).mockRejectedValue(new Error('contract query error')); - await expect(nameFunctionCall(args)).rejects.toThrow( + await expect(contractErc721NameFunctionCall(args)).rejects.toThrow( 'contract query error', ); }); diff --git a/src/plugins/contract-erc721/__tests__/unit/owner-of.test.ts b/src/plugins/contract-erc721/__tests__/unit/owner-of.test.ts index ba8f09a43..24e995bf9 100644 --- a/src/plugins/contract-erc721/__tests__/unit/owner-of.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/owner-of.test.ts @@ -17,7 +17,7 @@ import { makeContractErc721CallCommandArgs } from '@/plugins/contract-erc721/__t import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallOwnerOfOutputSchema, - ownerOfFunctionCall, + contractErc721OwnerOfFunctionCall, } from '@/plugins/contract-erc721/commands/owner-of'; import { ContractErc721CallOwnerOfInputSchema } from '@/plugins/contract-erc721/commands/owner-of/input'; @@ -81,7 +81,7 @@ describe('contract-erc721 plugin - ownerOf command (unit)', () => { }, }); - const result = await ownerOfFunctionCall(args); + const result = await contractErc721OwnerOfFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -122,7 +122,7 @@ describe('contract-erc721 plugin - ownerOf command (unit)', () => { }, }); - const result = await ownerOfFunctionCall(args); + const result = await contractErc721OwnerOfFunctionCall(args); expect(result.result).toBeDefined(); expect( @@ -158,8 +158,10 @@ describe('contract-erc721 plugin - ownerOf command (unit)', () => { queryResult: [], }); - await expect(ownerOfFunctionCall(args)).rejects.toThrow(StateError); - await expect(ownerOfFunctionCall(args)).rejects.toThrow( + await expect(contractErc721OwnerOfFunctionCall(args)).rejects.toThrow( + StateError, + ); + await expect(contractErc721OwnerOfFunctionCall(args)).rejects.toThrow( `There was a problem with decoding contract ${MOCK_CONTRACT_ID} "ownerOf" function result`, ); }); @@ -177,7 +179,7 @@ describe('contract-erc721 plugin - ownerOf command (unit)', () => { args.api.contractQuery.queryContractFunction as jest.Mock ).mockRejectedValue(new Error('contract query error')); - await expect(ownerOfFunctionCall(args)).rejects.toThrow( + await expect(contractErc721OwnerOfFunctionCall(args)).rejects.toThrow( 'contract query error', ); }); diff --git a/src/plugins/contract-erc721/__tests__/unit/safe-transfer-from.test.ts b/src/plugins/contract-erc721/__tests__/unit/safe-transfer-from.test.ts index af400f2c9..ae5ddcb01 100644 --- a/src/plugins/contract-erc721/__tests__/unit/safe-transfer-from.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/safe-transfer-from.test.ts @@ -20,7 +20,7 @@ import { import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallSafeTransferFromOutputSchema, - safeTransferFromFunctionCall, + contractErc721SafeTransferFromFunctionCall, } from '@/plugins/contract-erc721/commands/safe-transfer-from'; import { ContractErc721CallSafeTransferFromInputSchema } from '@/plugins/contract-erc721/commands/safe-transfer-from/input'; @@ -92,7 +92,7 @@ describe('contract-erc721 plugin - safeTransferFrom command (unit)', () => { }, }); - const result = await safeTransferFromFunctionCall(args); + const result = await contractErc721SafeTransferFromFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -137,7 +137,7 @@ describe('contract-erc721 plugin - safeTransferFrom command (unit)', () => { }, }); - const result = await safeTransferFromFunctionCall(args); + const result = await contractErc721SafeTransferFromFunctionCall(args); expect(result.result).toBeDefined(); expect(mockAddBytes).toHaveBeenCalledWith(expect.any(Buffer)); @@ -161,7 +161,7 @@ describe('contract-erc721 plugin - safeTransferFrom command (unit)', () => { }, }); - const result = await safeTransferFromFunctionCall(args); + const result = await contractErc721SafeTransferFromFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveAccount).not.toHaveBeenCalled(); @@ -187,10 +187,12 @@ describe('contract-erc721 plugin - safeTransferFrom command (unit)', () => { receipt: { status: { status: 'FAILURE' } }, }); - await expect(safeTransferFromFunctionCall(args)).rejects.toThrow( - TransactionError, - ); - await expect(safeTransferFromFunctionCall(args)).rejects.toThrow( + await expect( + contractErc721SafeTransferFromFunctionCall(args), + ).rejects.toThrow(TransactionError); + await expect( + contractErc721SafeTransferFromFunctionCall(args), + ).rejects.toThrow( 'Failed to call safeTransferFrom on contract 0.0.1234 (txId: undefined, status: FAILURE)', ); }); @@ -211,9 +213,9 @@ describe('contract-erc721 plugin - safeTransferFrom command (unit)', () => { new Error('network error'), ); - await expect(safeTransferFromFunctionCall(args)).rejects.toThrow( - 'network error', - ); + await expect( + contractErc721SafeTransferFromFunctionCall(args), + ).rejects.toThrow('network error'); }); test('propagates error when contract not found', async () => { @@ -237,9 +239,9 @@ describe('contract-erc721 plugin - safeTransferFrom command (unit)', () => { ), ); - await expect(safeTransferFromFunctionCall(args)).rejects.toThrow( - 'not found', - ); + await expect( + contractErc721SafeTransferFromFunctionCall(args), + ).rejects.toThrow('not found'); }); test('throws NotFoundError when from has no evmAddress', async () => { @@ -267,7 +269,7 @@ describe('contract-erc721 plugin - safeTransferFrom command (unit)', () => { evmAddress: MOCK_EVM_ADDRESS, }); - const promise = safeTransferFromFunctionCall(args); + const promise = contractErc721SafeTransferFromFunctionCall(args); await expect(promise).rejects.toThrow(NotFoundError); await expect(promise).rejects.toThrow( "Couldn't resolve EVM address for an account", @@ -299,7 +301,7 @@ describe('contract-erc721 plugin - safeTransferFrom command (unit)', () => { evmAddress: undefined, }); - const promise = safeTransferFromFunctionCall(args); + const promise = contractErc721SafeTransferFromFunctionCall(args); await expect(promise).rejects.toThrow(NotFoundError); await expect(promise).rejects.toThrow( "Couldn't resolve EVM address for an account", diff --git a/src/plugins/contract-erc721/__tests__/unit/set-approval-for-all.test.ts b/src/plugins/contract-erc721/__tests__/unit/set-approval-for-all.test.ts index d3d11118b..0cc064979 100644 --- a/src/plugins/contract-erc721/__tests__/unit/set-approval-for-all.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/set-approval-for-all.test.ts @@ -21,7 +21,7 @@ import { import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallSetApprovalForAllOutputSchema, - setApprovalForAllFunctionCall, + contractErc721SetApprovalForAllFunctionCall, } from '@/plugins/contract-erc721/commands/set-approval-for-all'; import { ContractErc721CallSetApprovalForAllInputSchema } from '@/plugins/contract-erc721/commands/set-approval-for-all/input'; @@ -90,7 +90,7 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { }, }); - const result = await setApprovalForAllFunctionCall(args); + const result = await contractErc721SetApprovalForAllFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -135,7 +135,7 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { }, }); - const result = await setApprovalForAllFunctionCall(args); + const result = await contractErc721SetApprovalForAllFunctionCall(args); expect(result.result).toBeDefined(); expect(mockAddBool).toHaveBeenCalledWith(false); @@ -154,7 +154,7 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { }, }); - const result = await setApprovalForAllFunctionCall(args); + const result = await contractErc721SetApprovalForAllFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveAccount).not.toHaveBeenCalled(); @@ -173,7 +173,7 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { }, }); - const result = await setApprovalForAllFunctionCall(args); + const result = await contractErc721SetApprovalForAllFunctionCall(args); expect(result.result).toBeDefined(); expect(mockAddBool).toHaveBeenCalledWith(true); }); @@ -190,7 +190,7 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { }, }); - const result = await setApprovalForAllFunctionCall(args); + const result = await contractErc721SetApprovalForAllFunctionCall(args); expect(result.result).toBeDefined(); expect(mockAddBool).toHaveBeenCalledWith(true); }); @@ -207,7 +207,7 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { }, }); - const result = await setApprovalForAllFunctionCall(args); + const result = await contractErc721SetApprovalForAllFunctionCall(args); expect(result.result).toBeDefined(); expect(mockAddBool).toHaveBeenCalledWith(false); }); @@ -228,10 +228,12 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { receipt: { status: { status: 'FAILURE' } }, }); - await expect(setApprovalForAllFunctionCall(args)).rejects.toThrow( - TransactionError, - ); - await expect(setApprovalForAllFunctionCall(args)).rejects.toThrow( + await expect( + contractErc721SetApprovalForAllFunctionCall(args), + ).rejects.toThrow(TransactionError); + await expect( + contractErc721SetApprovalForAllFunctionCall(args), + ).rejects.toThrow( 'Failed to call setApprovalForAll on contract 0.0.1234 (txId: undefined, status: FAILURE)', ); }); @@ -251,9 +253,9 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { new Error('network error'), ); - await expect(setApprovalForAllFunctionCall(args)).rejects.toThrow( - 'network error', - ); + await expect( + contractErc721SetApprovalForAllFunctionCall(args), + ).rejects.toThrow('network error'); }); test('propagates error when contract not found', async () => { @@ -276,9 +278,9 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { ), ); - await expect(setApprovalForAllFunctionCall(args)).rejects.toThrow( - 'not found', - ); + await expect( + contractErc721SetApprovalForAllFunctionCall(args), + ).rejects.toThrow('not found'); }); test('throws NotFoundError when operator has no evmAddress', async () => { @@ -301,12 +303,12 @@ describe('contract-erc721 plugin - setApprovalForAll command (unit)', () => { }, ); - await expect(setApprovalForAllFunctionCall(args)).rejects.toThrow( - NotFoundError, - ); - await expect(setApprovalForAllFunctionCall(args)).rejects.toThrow( - "Couldn't resolve EVM address for an account", - ); + await expect( + contractErc721SetApprovalForAllFunctionCall(args), + ).rejects.toThrow(NotFoundError); + await expect( + contractErc721SetApprovalForAllFunctionCall(args), + ).rejects.toThrow("Couldn't resolve EVM address for an account"); }); test('schema validation fails when contract is missing', () => { diff --git a/src/plugins/contract-erc721/__tests__/unit/symbol.test.ts b/src/plugins/contract-erc721/__tests__/unit/symbol.test.ts index 46120c7ff..4b42fe4c1 100644 --- a/src/plugins/contract-erc721/__tests__/unit/symbol.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/symbol.test.ts @@ -11,7 +11,7 @@ import { makeContractErc721CallCommandArgs } from '@/plugins/contract-erc721/__t import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallSymbolOutputSchema, - symbolFunctionCall, + contractErc721SymbolFunctionCall, } from '@/plugins/contract-erc721/commands/symbol'; import { ContractErc721CallSymbolInputSchema } from '@/plugins/contract-erc721/commands/symbol/input'; @@ -67,7 +67,7 @@ describe('contract-erc721 plugin - symbol command (unit)', () => { }, }); - const result = await symbolFunctionCall(args); + const result = await contractErc721SymbolFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -104,7 +104,7 @@ describe('contract-erc721 plugin - symbol command (unit)', () => { }, }); - const result = await symbolFunctionCall(args); + const result = await contractErc721SymbolFunctionCall(args); expect(result.result).toBeDefined(); expect( @@ -139,8 +139,10 @@ describe('contract-erc721 plugin - symbol command (unit)', () => { queryResult: [], }); - await expect(symbolFunctionCall(args)).rejects.toThrow(StateError); - await expect(symbolFunctionCall(args)).rejects.toThrow( + await expect(contractErc721SymbolFunctionCall(args)).rejects.toThrow( + StateError, + ); + await expect(contractErc721SymbolFunctionCall(args)).rejects.toThrow( `There was a problem with decoding contract ${MOCK_CONTRACT_ID} "symbol" function result`, ); }); @@ -157,7 +159,7 @@ describe('contract-erc721 plugin - symbol command (unit)', () => { args.api.contractQuery.queryContractFunction as jest.Mock ).mockRejectedValue(new Error('contract query error')); - await expect(symbolFunctionCall(args)).rejects.toThrow( + await expect(contractErc721SymbolFunctionCall(args)).rejects.toThrow( 'contract query error', ); }); diff --git a/src/plugins/contract-erc721/__tests__/unit/token-uri.test.ts b/src/plugins/contract-erc721/__tests__/unit/token-uri.test.ts index 8fde095c4..4f5541e92 100644 --- a/src/plugins/contract-erc721/__tests__/unit/token-uri.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/token-uri.test.ts @@ -11,7 +11,7 @@ import { makeContractErc721CallCommandArgs } from '@/plugins/contract-erc721/__t import { makeApiMocks } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallTokenUriOutputSchema, - tokenUriFunctionCall, + contractErc721TokenUriFunctionCall, } from '@/plugins/contract-erc721/commands/token-uri'; import { ContractErc721CallTokenUriInputSchema } from '@/plugins/contract-erc721/commands/token-uri/input'; @@ -69,7 +69,7 @@ describe('contract-erc721 plugin - tokenURI command (unit)', () => { }, }); - const result = await tokenUriFunctionCall(args); + const result = await contractErc721TokenUriFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -109,7 +109,7 @@ describe('contract-erc721 plugin - tokenURI command (unit)', () => { }, }); - const result = await tokenUriFunctionCall(args); + const result = await contractErc721TokenUriFunctionCall(args); expect(result.result).toBeDefined(); expect( @@ -145,8 +145,10 @@ describe('contract-erc721 plugin - tokenURI command (unit)', () => { queryResult: [], }); - await expect(tokenUriFunctionCall(args)).rejects.toThrow(StateError); - await expect(tokenUriFunctionCall(args)).rejects.toThrow( + await expect(contractErc721TokenUriFunctionCall(args)).rejects.toThrow( + StateError, + ); + await expect(contractErc721TokenUriFunctionCall(args)).rejects.toThrow( `There was a problem with decoding contract ${MOCK_CONTRACT_ID} "tokenURI" function result`, ); }); @@ -164,7 +166,7 @@ describe('contract-erc721 plugin - tokenURI command (unit)', () => { args.api.contractQuery.queryContractFunction as jest.Mock ).mockRejectedValue(new Error('contract query error')); - await expect(tokenUriFunctionCall(args)).rejects.toThrow( + await expect(contractErc721TokenUriFunctionCall(args)).rejects.toThrow( 'contract query error', ); }); diff --git a/src/plugins/contract-erc721/__tests__/unit/transfer-from.test.ts b/src/plugins/contract-erc721/__tests__/unit/transfer-from.test.ts index b83d1d316..5f2148192 100644 --- a/src/plugins/contract-erc721/__tests__/unit/transfer-from.test.ts +++ b/src/plugins/contract-erc721/__tests__/unit/transfer-from.test.ts @@ -25,7 +25,7 @@ import { } from '@/plugins/contract-erc721/__tests__/unit/helpers/mocks'; import { ContractErc721CallTransferFromOutputSchema, - transferFromFunctionCall, + contractErc721TransferFromFunctionCall, } from '@/plugins/contract-erc721/commands/transfer-from'; import { ContractErc721CallTransferFromInputSchema } from '@/plugins/contract-erc721/commands/transfer-from/input'; @@ -95,7 +95,7 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { }, }); - const result = await transferFromFunctionCall(args); + const result = await contractErc721TransferFromFunctionCall(args); expect(result.result).toBeDefined(); const output = assertOutput( @@ -147,7 +147,7 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { }, }); - const result = await transferFromFunctionCall(args); + const result = await contractErc721TransferFromFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveContract).toHaveBeenCalledWith({ @@ -181,7 +181,7 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { }, }); - const result = await transferFromFunctionCall(args); + const result = await contractErc721TransferFromFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveAccount).not.toHaveBeenCalledWith( @@ -204,7 +204,7 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { }, }); - const result = await transferFromFunctionCall(args); + const result = await contractErc721TransferFromFunctionCall(args); expect(result.result).toBeDefined(); expect(args.api.identityResolution.resolveAccount).not.toHaveBeenCalledWith( @@ -230,10 +230,10 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { receipt: { status: { status: 'FAILURE' } }, }); - await expect(transferFromFunctionCall(args)).rejects.toThrow( + await expect(contractErc721TransferFromFunctionCall(args)).rejects.toThrow( TransactionError, ); - await expect(transferFromFunctionCall(args)).rejects.toThrow( + await expect(contractErc721TransferFromFunctionCall(args)).rejects.toThrow( 'Failed to call transferFrom on contract 0.0.1234 (txId: undefined, status: FAILURE)', ); }); @@ -254,7 +254,7 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { new Error('network error'), ); - await expect(transferFromFunctionCall(args)).rejects.toThrow( + await expect(contractErc721TransferFromFunctionCall(args)).rejects.toThrow( 'network error', ); }); @@ -280,7 +280,9 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { ), ); - await expect(transferFromFunctionCall(args)).rejects.toThrow('not found'); + await expect(contractErc721TransferFromFunctionCall(args)).rejects.toThrow( + 'not found', + ); }); test('throws NotFoundError when resolveAccount for from has no evmAddress', async () => { @@ -308,7 +310,7 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { evmAddress: MOCK_EVM_ADDRESS, }); - const promise = transferFromFunctionCall(args); + const promise = contractErc721TransferFromFunctionCall(args); await expect(promise).rejects.toThrow(NotFoundError); await expect(promise).rejects.toThrow( "Couldn't resolve EVM address for an account", @@ -341,7 +343,7 @@ describe('contract-erc721 plugin - transferFrom command (unit)', () => { evmAddress: undefined, }); - const promise = transferFromFunctionCall(args); + const promise = contractErc721TransferFromFunctionCall(args); await expect(promise).rejects.toThrow(NotFoundError); await expect(promise).rejects.toThrow( "Couldn't resolve EVM address for an account", diff --git a/src/plugins/contract-erc721/commands/approve/handler.ts b/src/plugins/contract-erc721/commands/approve/handler.ts index 9496014d6..264934431 100644 --- a/src/plugins/contract-erc721/commands/approve/handler.ts +++ b/src/plugins/contract-erc721/commands/approve/handler.ts @@ -17,12 +17,18 @@ import { ContractErc721CallApproveInputSchema } from './input'; const ERC_721_FUNCTION_NAME = 'approve'; -export class ApproveCommand extends BaseTransactionCommand< +export const CONTRACT_ERC721_APPROVE_COMMAND_NAME = 'contract-erc721_approve'; + +export class ContractErc721ApproveCommand extends BaseTransactionCommand< ApproveNormalisedParams, ApproveBuildTransactionResult, ApproveSignTransactionResult, ApproveExecuteTransactionResult > { + constructor() { + super(CONTRACT_ERC721_APPROVE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -150,8 +156,8 @@ export class ApproveCommand extends BaseTransactionCommand< } } -export async function approveFunctionCall( +export async function contractErc721ApproveFunctionCall( args: CommandHandlerArgs, ): Promise { - return new ApproveCommand().execute(args); + return new ContractErc721ApproveCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/approve/index.ts b/src/plugins/contract-erc721/commands/approve/index.ts index 77a195029..e5b860c3b 100644 --- a/src/plugins/contract-erc721/commands/approve/index.ts +++ b/src/plugins/contract-erc721/commands/approve/index.ts @@ -1,7 +1,11 @@ /** * Contract function approve Command Exports */ -export { ApproveCommand, approveFunctionCall } from './handler'; +export { + CONTRACT_ERC721_APPROVE_COMMAND_NAME, + ContractErc721ApproveCommand, + contractErc721ApproveFunctionCall, +} from './handler'; export type { ContractErc721CallApproveOutput } from './output'; export { CONTRACT_ERC721_CALL_APPROVE_TEMPLATE, diff --git a/src/plugins/contract-erc721/commands/balance-of/handler.ts b/src/plugins/contract-erc721/commands/balance-of/handler.ts index 2bea88998..58d0b74c3 100644 --- a/src/plugins/contract-erc721/commands/balance-of/handler.ts +++ b/src/plugins/contract-erc721/commands/balance-of/handler.ts @@ -13,7 +13,7 @@ import { ERC721_ABI } from '@/plugins/contract-erc721/shared/erc721-abi'; const ERC_721_FUNCTION_NAME = 'balanceOf'; -export class BalanceOfCommand implements Command { +export class ContractErc721BalanceOfCommand implements Command { async execute(args: CommandHandlerArgs): Promise { const { api } = args; @@ -79,8 +79,8 @@ export class BalanceOfCommand implements Command { } } -export async function balanceOfFunctionCall( +export async function contractErc721BalanceOfFunctionCall( args: CommandHandlerArgs, ): Promise { - return new BalanceOfCommand().execute(args); + return new ContractErc721BalanceOfCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/balance-of/index.ts b/src/plugins/contract-erc721/commands/balance-of/index.ts index 7621939a1..8fef3e5f0 100644 --- a/src/plugins/contract-erc721/commands/balance-of/index.ts +++ b/src/plugins/contract-erc721/commands/balance-of/index.ts @@ -2,7 +2,10 @@ * Contract balanceOf Command Exports * For use by tests and external consumers */ -export { BalanceOfCommand, balanceOfFunctionCall } from './handler'; +export { + ContractErc721BalanceOfCommand, + contractErc721BalanceOfFunctionCall, +} from './handler'; export type { ContractErc721CallBalanceOfOutput } from './output'; export { CONTRACT_ERC721_CALL_BALANCE_OF_CREATE_TEMPLATE, diff --git a/src/plugins/contract-erc721/commands/get-approved/handler.ts b/src/plugins/contract-erc721/commands/get-approved/handler.ts index 92972189a..389ee5416 100644 --- a/src/plugins/contract-erc721/commands/get-approved/handler.ts +++ b/src/plugins/contract-erc721/commands/get-approved/handler.ts @@ -12,7 +12,7 @@ import { ERC721_ABI } from '@/plugins/contract-erc721/shared/erc721-abi'; const ERC_721_FUNCTION_NAME = 'getApproved'; -export class GetApprovedCommand implements Command { +export class ContractErc721GetApprovedCommand implements Command { async execute(args: CommandHandlerArgs): Promise { const { api } = args; @@ -68,8 +68,8 @@ export class GetApprovedCommand implements Command { } } -export async function getApprovedFunctionCall( +export async function contractErc721GetApprovedFunctionCall( args: CommandHandlerArgs, ): Promise { - return new GetApprovedCommand().execute(args); + return new ContractErc721GetApprovedCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/get-approved/index.ts b/src/plugins/contract-erc721/commands/get-approved/index.ts index 97a398a44..8880ab68e 100644 --- a/src/plugins/contract-erc721/commands/get-approved/index.ts +++ b/src/plugins/contract-erc721/commands/get-approved/index.ts @@ -2,7 +2,10 @@ * Contract getApproved Command Exports * For use by tests and external consumers */ -export { GetApprovedCommand, getApprovedFunctionCall } from './handler'; +export { + ContractErc721GetApprovedCommand, + contractErc721GetApprovedFunctionCall, +} from './handler'; export type { ContractErc721CallGetApprovedOutput } from './output'; export { CONTRACT_ERC721_CALL_GET_APPROVED_TEMPLATE, diff --git a/src/plugins/contract-erc721/commands/is-approved-for-all/handler.ts b/src/plugins/contract-erc721/commands/is-approved-for-all/handler.ts index f8ef8f90a..eb7e44622 100644 --- a/src/plugins/contract-erc721/commands/is-approved-for-all/handler.ts +++ b/src/plugins/contract-erc721/commands/is-approved-for-all/handler.ts @@ -13,7 +13,7 @@ import { ERC721_ABI } from '@/plugins/contract-erc721/shared/erc721-abi'; const ERC_721_FUNCTION_NAME = 'isApprovedForAll'; -export class IsApprovedForAllCommand implements Command { +export class ContractErc721IsApprovedForAllCommand implements Command { async execute(args: CommandHandlerArgs): Promise { const { api } = args; @@ -106,5 +106,5 @@ export class IsApprovedForAllCommand implements Command { export async function isApprovedForAllFunctionCall( args: CommandHandlerArgs, ): Promise { - return new IsApprovedForAllCommand().execute(args); + return new ContractErc721IsApprovedForAllCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/is-approved-for-all/index.ts b/src/plugins/contract-erc721/commands/is-approved-for-all/index.ts index da0571ac0..6535d5e72 100644 --- a/src/plugins/contract-erc721/commands/is-approved-for-all/index.ts +++ b/src/plugins/contract-erc721/commands/is-approved-for-all/index.ts @@ -3,7 +3,7 @@ * For use by tests and external consumers */ export { - IsApprovedForAllCommand, + ContractErc721IsApprovedForAllCommand, isApprovedForAllFunctionCall, } from './handler'; export type { ContractErc721CallIsApprovedForAllOutput } from './output'; diff --git a/src/plugins/contract-erc721/commands/mint/handler.ts b/src/plugins/contract-erc721/commands/mint/handler.ts index c887d240c..98d66655d 100644 --- a/src/plugins/contract-erc721/commands/mint/handler.ts +++ b/src/plugins/contract-erc721/commands/mint/handler.ts @@ -17,12 +17,18 @@ import { ContractErc721CallMintInputSchema } from './input'; const ERC_721_FUNCTION_NAME = 'mint'; -export class MintCommand extends BaseTransactionCommand< +export const CONTRACT_ERC721_MINT_COMMAND_NAME = 'contract-erc721_mint'; + +export class ContractErc721MintCommand extends BaseTransactionCommand< MintNormalisedParams, MintBuildTransactionResult, MintSignTransactionResult, MintExecuteTransactionResult > { + constructor() { + super(CONTRACT_ERC721_MINT_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -150,8 +156,8 @@ export class MintCommand extends BaseTransactionCommand< } } -export async function mintFunctionCall( +export async function contractErc721MintFunctionCall( args: CommandHandlerArgs, ): Promise { - return new MintCommand().execute(args); + return new ContractErc721MintCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/mint/index.ts b/src/plugins/contract-erc721/commands/mint/index.ts index 1d93bdf63..15ac9511e 100644 --- a/src/plugins/contract-erc721/commands/mint/index.ts +++ b/src/plugins/contract-erc721/commands/mint/index.ts @@ -1,7 +1,11 @@ /** * Contract function mint Command Exports */ -export { MintCommand, mintFunctionCall } from './handler'; +export { + CONTRACT_ERC721_MINT_COMMAND_NAME, + ContractErc721MintCommand, + contractErc721MintFunctionCall, +} from './handler'; export type { ContractErc721CallMintOutput } from './output'; export { CONTRACT_ERC721_CALL_MINT_TEMPLATE, diff --git a/src/plugins/contract-erc721/commands/name/handler.ts b/src/plugins/contract-erc721/commands/name/handler.ts index e0beeae7e..ba14a005e 100644 --- a/src/plugins/contract-erc721/commands/name/handler.ts +++ b/src/plugins/contract-erc721/commands/name/handler.ts @@ -12,7 +12,7 @@ import { ERC721_ABI } from '@/plugins/contract-erc721/shared/erc721-abi'; const ERC_721_FUNCTION_NAME = 'name'; -export class NameCommand implements Command { +export class ContractErc721NameCommand implements Command { async execute(args: CommandHandlerArgs): Promise { const { api } = args; @@ -58,8 +58,8 @@ export class NameCommand implements Command { } } -export async function nameFunctionCall( +export async function contractErc721NameFunctionCall( args: CommandHandlerArgs, ): Promise { - return new NameCommand().execute(args); + return new ContractErc721NameCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/name/index.ts b/src/plugins/contract-erc721/commands/name/index.ts index e319d97f2..adaa48aab 100644 --- a/src/plugins/contract-erc721/commands/name/index.ts +++ b/src/plugins/contract-erc721/commands/name/index.ts @@ -2,7 +2,10 @@ * Contract name Command Exports * For use by tests and external consumers */ -export { NameCommand, nameFunctionCall } from './handler'; +export { + ContractErc721NameCommand, + contractErc721NameFunctionCall, +} from './handler'; export type { ContractErc721CallNameOutput } from './output'; export { CONTRACT_ERC721_CALL_NAME_TEMPLATE, diff --git a/src/plugins/contract-erc721/commands/owner-of/handler.ts b/src/plugins/contract-erc721/commands/owner-of/handler.ts index 2da3db601..f087bbe7a 100644 --- a/src/plugins/contract-erc721/commands/owner-of/handler.ts +++ b/src/plugins/contract-erc721/commands/owner-of/handler.ts @@ -12,7 +12,7 @@ import { ERC721_ABI } from '@/plugins/contract-erc721/shared/erc721-abi'; const ERC_721_FUNCTION_NAME = 'ownerOf'; -export class OwnerOfCommand implements Command { +export class ContractErc721OwnerOfCommand implements Command { async execute(args: CommandHandlerArgs): Promise { const { api } = args; @@ -61,8 +61,8 @@ export class OwnerOfCommand implements Command { } } -export async function ownerOfFunctionCall( +export async function contractErc721OwnerOfFunctionCall( args: CommandHandlerArgs, ): Promise { - return new OwnerOfCommand().execute(args); + return new ContractErc721OwnerOfCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/owner-of/index.ts b/src/plugins/contract-erc721/commands/owner-of/index.ts index 7d2cb944c..29eda4f58 100644 --- a/src/plugins/contract-erc721/commands/owner-of/index.ts +++ b/src/plugins/contract-erc721/commands/owner-of/index.ts @@ -2,7 +2,10 @@ * Contract ownerOf Command Exports * For use by tests and external consumers */ -export { OwnerOfCommand, ownerOfFunctionCall } from './handler'; +export { + ContractErc721OwnerOfCommand, + contractErc721OwnerOfFunctionCall, +} from './handler'; export type { ContractErc721CallOwnerOfOutput } from './output'; export { CONTRACT_ERC721_CALL_OWNER_OF_TEMPLATE, diff --git a/src/plugins/contract-erc721/commands/safe-transfer-from/handler.ts b/src/plugins/contract-erc721/commands/safe-transfer-from/handler.ts index bb17361ea..c565b2a6f 100644 --- a/src/plugins/contract-erc721/commands/safe-transfer-from/handler.ts +++ b/src/plugins/contract-erc721/commands/safe-transfer-from/handler.ts @@ -17,12 +17,19 @@ import { ContractErc721CallSafeTransferFromInputSchema } from './input'; const ERC_721_FUNCTION_NAME = 'safeTransferFrom'; -export class SafeTransferFromCommand extends BaseTransactionCommand< +export const CONTRACT_ERC721_SAFE_TRANSFER_FROM_COMMAND_NAME = + 'contract-erc721_safe-transfer-from'; + +export class ContractErc721SafeTransferFromCommand extends BaseTransactionCommand< SafeTransferFromNormalisedParams, SafeTransferFromBuildTransactionResult, SafeTransferFromSignTransactionResult, SafeTransferFromExecuteTransactionResult > { + constructor() { + super(CONTRACT_ERC721_SAFE_TRANSFER_FROM_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -182,8 +189,8 @@ export class SafeTransferFromCommand extends BaseTransactionCommand< } } -export async function safeTransferFromFunctionCall( +export async function contractErc721SafeTransferFromFunctionCall( args: CommandHandlerArgs, ): Promise { - return new SafeTransferFromCommand().execute(args); + return new ContractErc721SafeTransferFromCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/safe-transfer-from/index.ts b/src/plugins/contract-erc721/commands/safe-transfer-from/index.ts index a484a2bc1..f0e1d2cb5 100644 --- a/src/plugins/contract-erc721/commands/safe-transfer-from/index.ts +++ b/src/plugins/contract-erc721/commands/safe-transfer-from/index.ts @@ -3,8 +3,9 @@ * For use by tests and external consumers */ export { - SafeTransferFromCommand, - safeTransferFromFunctionCall, + CONTRACT_ERC721_SAFE_TRANSFER_FROM_COMMAND_NAME, + ContractErc721SafeTransferFromCommand, + contractErc721SafeTransferFromFunctionCall, } from './handler'; export type { ContractErc721CallSafeTransferFromOutput } from './output'; export { diff --git a/src/plugins/contract-erc721/commands/set-approval-for-all/handler.ts b/src/plugins/contract-erc721/commands/set-approval-for-all/handler.ts index 21c232f16..1e43c6ec4 100644 --- a/src/plugins/contract-erc721/commands/set-approval-for-all/handler.ts +++ b/src/plugins/contract-erc721/commands/set-approval-for-all/handler.ts @@ -17,12 +17,19 @@ import { ContractErc721CallSetApprovalForAllInputSchema } from './input'; const ERC_721_FUNCTION_NAME = 'setApprovalForAll'; -export class SetApprovalForAllCommand extends BaseTransactionCommand< +export const CONTRACT_ERC721_SET_APPROVAL_FOR_ALL_COMMAND_NAME = + 'contract-erc721_set-approval-for-all'; + +export class ContractErc721SetApprovalForAllCommand extends BaseTransactionCommand< SetApprovalForAllNormalisedParams, SetApprovalForAllBuildTransactionResult, SetApprovalForAllSignTransactionResult, SetApprovalForAllExecuteTransactionResult > { + constructor() { + super(CONTRACT_ERC721_SET_APPROVAL_FOR_ALL_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -152,8 +159,8 @@ export class SetApprovalForAllCommand extends BaseTransactionCommand< } } -export async function setApprovalForAllFunctionCall( +export async function contractErc721SetApprovalForAllFunctionCall( args: CommandHandlerArgs, ): Promise { - return new SetApprovalForAllCommand().execute(args); + return new ContractErc721SetApprovalForAllCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/set-approval-for-all/index.ts b/src/plugins/contract-erc721/commands/set-approval-for-all/index.ts index a87e625ac..080a5b78a 100644 --- a/src/plugins/contract-erc721/commands/set-approval-for-all/index.ts +++ b/src/plugins/contract-erc721/commands/set-approval-for-all/index.ts @@ -2,8 +2,9 @@ * Contract function setApprovalForAll Command Exports */ export { - SetApprovalForAllCommand, - setApprovalForAllFunctionCall, + CONTRACT_ERC721_SET_APPROVAL_FOR_ALL_COMMAND_NAME, + ContractErc721SetApprovalForAllCommand, + contractErc721SetApprovalForAllFunctionCall, } from './handler'; export type { ContractErc721CallSetApprovalForAllOutput } from './output'; export { diff --git a/src/plugins/contract-erc721/commands/symbol/handler.ts b/src/plugins/contract-erc721/commands/symbol/handler.ts index e9cf0a2a7..db8702985 100644 --- a/src/plugins/contract-erc721/commands/symbol/handler.ts +++ b/src/plugins/contract-erc721/commands/symbol/handler.ts @@ -12,7 +12,7 @@ import { ERC721_ABI } from '@/plugins/contract-erc721/shared/erc721-abi'; const ERC_721_FUNCTION_NAME = 'symbol'; -export class SymbolCommand implements Command { +export class ContractErc721SymbolCommand implements Command { async execute(args: CommandHandlerArgs): Promise { const { api } = args; @@ -56,8 +56,8 @@ export class SymbolCommand implements Command { } } -export async function symbolFunctionCall( +export async function contractErc721SymbolFunctionCall( args: CommandHandlerArgs, ): Promise { - return new SymbolCommand().execute(args); + return new ContractErc721SymbolCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/symbol/index.ts b/src/plugins/contract-erc721/commands/symbol/index.ts index 0b13b3e2a..d2d82dfbc 100644 --- a/src/plugins/contract-erc721/commands/symbol/index.ts +++ b/src/plugins/contract-erc721/commands/symbol/index.ts @@ -2,7 +2,10 @@ * Contract symbol Command Exports * For use by tests and external consumers */ -export { SymbolCommand, symbolFunctionCall } from './handler'; +export { + ContractErc721SymbolCommand, + contractErc721SymbolFunctionCall, +} from './handler'; export type { ContractErc721CallSymbolOutput } from './output'; export { CONTRACT_ERC721_CALL_SYMBOL_TEMPLATE, diff --git a/src/plugins/contract-erc721/commands/token-uri/handler.ts b/src/plugins/contract-erc721/commands/token-uri/handler.ts index 4b10f03ac..c8963dc9f 100644 --- a/src/plugins/contract-erc721/commands/token-uri/handler.ts +++ b/src/plugins/contract-erc721/commands/token-uri/handler.ts @@ -12,7 +12,7 @@ import { ERC721_ABI } from '@/plugins/contract-erc721/shared/erc721-abi'; const ERC_721_FUNCTION_NAME = 'tokenURI'; -export class TokenUriCommand implements Command { +export class ContractErc721TokenUriCommand implements Command { async execute(args: CommandHandlerArgs): Promise { const { api } = args; @@ -60,8 +60,8 @@ export class TokenUriCommand implements Command { } } -export async function tokenUriFunctionCall( +export async function contractErc721TokenUriFunctionCall( args: CommandHandlerArgs, ): Promise { - return new TokenUriCommand().execute(args); + return new ContractErc721TokenUriCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/token-uri/index.ts b/src/plugins/contract-erc721/commands/token-uri/index.ts index 05cd4b9ad..cea1823c6 100644 --- a/src/plugins/contract-erc721/commands/token-uri/index.ts +++ b/src/plugins/contract-erc721/commands/token-uri/index.ts @@ -2,7 +2,10 @@ * Contract tokenURI Command Exports * For use by tests and external consumers */ -export { TokenUriCommand, tokenUriFunctionCall } from './handler'; +export { + ContractErc721TokenUriCommand, + contractErc721TokenUriFunctionCall, +} from './handler'; export type { ContractErc721CallTokenUriOutput } from './output'; export { CONTRACT_ERC721_CALL_TOKEN_URI_TEMPLATE, diff --git a/src/plugins/contract-erc721/commands/transfer-from/handler.ts b/src/plugins/contract-erc721/commands/transfer-from/handler.ts index b3edaaccf..543e60403 100644 --- a/src/plugins/contract-erc721/commands/transfer-from/handler.ts +++ b/src/plugins/contract-erc721/commands/transfer-from/handler.ts @@ -17,12 +17,19 @@ import { ContractErc721CallTransferFromInputSchema } from './input'; const ERC_721_FUNCTION_NAME = 'transferFrom'; -export class TransferFromCommand extends BaseTransactionCommand< +export const CONTRACT_ERC721_TRANSFER_FROM_COMMAND_NAME = + 'contract-erc721_transfer-from'; + +export class ContractErc721TransferFromCommand extends BaseTransactionCommand< TransferFromNormalisedParams, TransferFromBuildTransactionResult, TransferFromSignTransactionResult, TransferFromExecuteTransactionResult > { + constructor() { + super(CONTRACT_ERC721_TRANSFER_FROM_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -174,8 +181,8 @@ export class TransferFromCommand extends BaseTransactionCommand< } } -export async function transferFromFunctionCall( +export async function contractErc721TransferFromFunctionCall( args: CommandHandlerArgs, ): Promise { - return new TransferFromCommand().execute(args); + return new ContractErc721TransferFromCommand().execute(args); } diff --git a/src/plugins/contract-erc721/commands/transfer-from/index.ts b/src/plugins/contract-erc721/commands/transfer-from/index.ts index e59088565..4a343b112 100644 --- a/src/plugins/contract-erc721/commands/transfer-from/index.ts +++ b/src/plugins/contract-erc721/commands/transfer-from/index.ts @@ -2,7 +2,11 @@ * Contract function transferFrom Command Exports * For use by tests and external consumers */ -export { TransferFromCommand, transferFromFunctionCall } from './handler'; +export { + CONTRACT_ERC721_TRANSFER_FROM_COMMAND_NAME, + ContractErc721TransferFromCommand, + contractErc721TransferFromFunctionCall, +} from './handler'; export type { ContractErc721CallTransferFromOutput } from './output'; export { CONTRACT_ERC721_CALL_TRANSFER_FROM_TEMPLATE, diff --git a/src/plugins/contract-erc721/index.ts b/src/plugins/contract-erc721/index.ts index 83e715c51..2b7913e2c 100644 --- a/src/plugins/contract-erc721/index.ts +++ b/src/plugins/contract-erc721/index.ts @@ -2,15 +2,15 @@ * Contract ERC-721 Plugin Index * Exports the contract-erc721 plugin manifest */ -export { approveFunctionCall } from './commands/approve'; -export { balanceOfFunctionCall } from './commands/balance-of'; -export { getApprovedFunctionCall } from './commands/get-approved'; +export { contractErc721ApproveFunctionCall } from './commands/approve'; +export { contractErc721BalanceOfFunctionCall } from './commands/balance-of'; +export { contractErc721GetApprovedFunctionCall } from './commands/get-approved'; export { isApprovedForAllFunctionCall } from './commands/is-approved-for-all'; -export { mintFunctionCall } from './commands/mint'; -export { nameFunctionCall } from './commands/name'; -export { ownerOfFunctionCall } from './commands/owner-of'; -export { safeTransferFromFunctionCall } from './commands/safe-transfer-from'; -export { setApprovalForAllFunctionCall } from './commands/set-approval-for-all'; -export { symbolFunctionCall } from './commands/symbol'; -export { tokenUriFunctionCall } from './commands/token-uri'; +export { contractErc721MintFunctionCall } from './commands/mint'; +export { contractErc721NameFunctionCall } from './commands/name'; +export { contractErc721OwnerOfFunctionCall } from './commands/owner-of'; +export { contractErc721SafeTransferFromFunctionCall } from './commands/safe-transfer-from'; +export { contractErc721SetApprovalForAllFunctionCall } from './commands/set-approval-for-all'; +export { contractErc721SymbolFunctionCall } from './commands/symbol'; +export { contractErc721TokenUriFunctionCall } from './commands/token-uri'; export { contractErc721PluginManifest } from './manifest'; diff --git a/src/plugins/contract-erc721/manifest.ts b/src/plugins/contract-erc721/manifest.ts index b4753f88c..6392bed28 100644 --- a/src/plugins/contract-erc721/manifest.ts +++ b/src/plugins/contract-erc721/manifest.ts @@ -6,19 +6,19 @@ import type { PluginManifest } from '@/core'; import { OptionType } from '@/core/types/shared.types'; import { - approveFunctionCall, CONTRACT_ERC721_CALL_APPROVE_TEMPLATE, + contractErc721ApproveFunctionCall, ContractErc721CallApproveOutputSchema, } from '@/plugins/contract-erc721/commands/approve'; import { - balanceOfFunctionCall, CONTRACT_ERC721_CALL_BALANCE_OF_CREATE_TEMPLATE, + contractErc721BalanceOfFunctionCall, ContractErc721CallBalanceOfOutputSchema, } from '@/plugins/contract-erc721/commands/balance-of'; import { CONTRACT_ERC721_CALL_GET_APPROVED_TEMPLATE, ContractErc721CallGetApprovedOutputSchema, - getApprovedFunctionCall, + contractErc721GetApprovedFunctionCall, } from '@/plugins/contract-erc721/commands/get-approved'; import { CONTRACT_ERC721_CALL_IS_APPROVED_FOR_ALL_TEMPLATE, @@ -28,42 +28,42 @@ import { import { CONTRACT_ERC721_CALL_MINT_TEMPLATE, ContractErc721CallMintOutputSchema, - mintFunctionCall, + contractErc721MintFunctionCall, } from '@/plugins/contract-erc721/commands/mint'; import { CONTRACT_ERC721_CALL_NAME_TEMPLATE, ContractErc721CallNameOutputSchema, - nameFunctionCall, + contractErc721NameFunctionCall, } from '@/plugins/contract-erc721/commands/name'; import { CONTRACT_ERC721_CALL_OWNER_OF_TEMPLATE, ContractErc721CallOwnerOfOutputSchema, - ownerOfFunctionCall, + contractErc721OwnerOfFunctionCall, } from '@/plugins/contract-erc721/commands/owner-of'; import { CONTRACT_ERC721_CALL_SAFE_TRANSFER_FROM_TEMPLATE, ContractErc721CallSafeTransferFromOutputSchema, - safeTransferFromFunctionCall, + contractErc721SafeTransferFromFunctionCall, } from '@/plugins/contract-erc721/commands/safe-transfer-from'; import { CONTRACT_ERC721_CALL_SET_APPROVAL_FOR_ALL_TEMPLATE, ContractErc721CallSetApprovalForAllOutputSchema, - setApprovalForAllFunctionCall, + contractErc721SetApprovalForAllFunctionCall, } from '@/plugins/contract-erc721/commands/set-approval-for-all'; import { CONTRACT_ERC721_CALL_SYMBOL_TEMPLATE, ContractErc721CallSymbolOutputSchema, - symbolFunctionCall, + contractErc721SymbolFunctionCall, } from '@/plugins/contract-erc721/commands/symbol'; import { CONTRACT_ERC721_CALL_TOKEN_URI_TEMPLATE, ContractErc721CallTokenUriOutputSchema, - tokenUriFunctionCall, + contractErc721TokenUriFunctionCall, } from '@/plugins/contract-erc721/commands/token-uri'; import { CONTRACT_ERC721_CALL_TRANSFER_FROM_TEMPLATE, ContractErc721CallTransferFromOutputSchema, - transferFromFunctionCall, + contractErc721TransferFromFunctionCall, } from '@/plugins/contract-erc721/commands/transfer-from'; export const contractErc721PluginManifest: PluginManifest = { @@ -93,7 +93,7 @@ export const contractErc721PluginManifest: PluginManifest = { 'Account represented by alias, account ID, or EVM address', }, ], - handler: balanceOfFunctionCall, + handler: contractErc721BalanceOfFunctionCall, output: { schema: ContractErc721CallBalanceOfOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_BALANCE_OF_CREATE_TEMPLATE, @@ -138,7 +138,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Gas for function call. Default: 100000', }, ], - handler: approveFunctionCall, + handler: contractErc721ApproveFunctionCall, output: { schema: ContractErc721CallApproveOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_APPROVE_TEMPLATE, @@ -183,7 +183,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Gas for function call. Default: 100000', }, ], - handler: setApprovalForAllFunctionCall, + handler: contractErc721SetApprovalForAllFunctionCall, output: { schema: ContractErc721CallSetApprovalForAllOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_SET_APPROVAL_FOR_ALL_TEMPLATE, @@ -247,7 +247,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Token ID (uint256) to query owner of', }, ], - handler: ownerOfFunctionCall, + handler: contractErc721OwnerOfFunctionCall, output: { schema: ContractErc721CallOwnerOfOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_OWNER_OF_TEMPLATE, @@ -274,7 +274,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Token ID (uint256) to query approved address for', }, ], - handler: getApprovedFunctionCall, + handler: contractErc721GetApprovedFunctionCall, output: { schema: ContractErc721CallGetApprovedOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_GET_APPROVED_TEMPLATE, @@ -301,7 +301,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Token ID (uint256) to query URI for', }, ], - handler: tokenUriFunctionCall, + handler: contractErc721TokenUriFunctionCall, output: { schema: ContractErc721CallTokenUriOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_TOKEN_URI_TEMPLATE, @@ -321,7 +321,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Smart contract ID represented by alias or contract ID', }, ], - handler: nameFunctionCall, + handler: contractErc721NameFunctionCall, output: { schema: ContractErc721CallNameOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_NAME_TEMPLATE, @@ -341,7 +341,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Smart contract ID represented by alias or contract ID', }, ], - handler: symbolFunctionCall, + handler: contractErc721SymbolFunctionCall, output: { schema: ContractErc721CallSymbolOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_SYMBOL_TEMPLATE, @@ -401,7 +401,7 @@ export const contractErc721PluginManifest: PluginManifest = { 'Optional arbitrary data for safeTransferFrom(address,address,uint256,bytes)', }, ], - handler: safeTransferFromFunctionCall, + handler: contractErc721SafeTransferFromFunctionCall, output: { schema: ContractErc721CallSafeTransferFromOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_SAFE_TRANSFER_FROM_TEMPLATE, @@ -445,7 +445,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Gas for function call. Default: 100000', }, ], - handler: mintFunctionCall, + handler: contractErc721MintFunctionCall, output: { schema: ContractErc721CallMintOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_MINT_TEMPLATE, @@ -497,7 +497,7 @@ export const contractErc721PluginManifest: PluginManifest = { description: 'Gas for function call. Default: 100000', }, ], - handler: transferFromFunctionCall, + handler: contractErc721TransferFromFunctionCall, output: { schema: ContractErc721CallTransferFromOutputSchema, humanTemplate: CONTRACT_ERC721_CALL_TRANSFER_FROM_TEMPLATE, diff --git a/src/plugins/contract/commands/create/handler.ts b/src/plugins/contract/commands/create/handler.ts index d15359de2..41c40a3c3 100644 --- a/src/plugins/contract/commands/create/handler.ts +++ b/src/plugins/contract/commands/create/handler.ts @@ -32,12 +32,18 @@ import { ZustandContractStateHelper } from '@/plugins/contract/zustand-state-hel import { ContractCreateSchema } from './input'; +export const CONTRACT_CREATE_COMMAND_NAME = 'contract_create'; + export class CreateContractCommand extends BaseTransactionCommand< ContractCreateNormalisedParams, ContractCreateBuildTransactionResult, ContractCreateSignTransactionResult, ContractCreateExecuteTransactionResult > { + constructor() { + super(CONTRACT_CREATE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { diff --git a/src/plugins/contract/commands/create/index.ts b/src/plugins/contract/commands/create/index.ts index e32e8356c..12c3bad4b 100644 --- a/src/plugins/contract/commands/create/index.ts +++ b/src/plugins/contract/commands/create/index.ts @@ -1,6 +1,10 @@ /** * Contract Create Command Exports */ -export { createContract, CreateContractCommand } from './handler'; +export { + CONTRACT_CREATE_COMMAND_NAME, + createContract, + CreateContractCommand, +} from './handler'; export type { ContractCreateOutput } from './output'; export { CONTRACT_CREATE_TEMPLATE, ContractCreateOutputSchema } from './output'; diff --git a/src/plugins/hbar/commands/transfer/handler.ts b/src/plugins/hbar/commands/transfer/handler.ts index e9341605f..3b119814f 100644 --- a/src/plugins/hbar/commands/transfer/handler.ts +++ b/src/plugins/hbar/commands/transfer/handler.ts @@ -15,8 +15,13 @@ import { processBalanceInput } from '@/core/utils/process-balance-input'; import { TransferInputSchema } from './input'; -export const transferHbar = (args: CommandHandlerArgs) => - new TransferCommand().execute(args); +export const HBAR_TRANSFER_COMMAND_NAME = 'hbar_transfer'; + +export async function transferHbar( + args: CommandHandlerArgs, +): Promise { + return new TransferCommand().execute(args); +} export class TransferCommand extends BaseTransactionCommand< TransferNormalisedParams, @@ -24,6 +29,10 @@ export class TransferCommand extends BaseTransactionCommand< TransferSignTransactionResult, TransferExecuteTransactionResult > { + constructor() { + super(HBAR_TRANSFER_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { diff --git a/src/plugins/hbar/commands/transfer/index.ts b/src/plugins/hbar/commands/transfer/index.ts index 568225cc1..df705ceef 100644 --- a/src/plugins/hbar/commands/transfer/index.ts +++ b/src/plugins/hbar/commands/transfer/index.ts @@ -1,3 +1,7 @@ -export { TransferCommand, transferHbar } from './handler'; +export { + HBAR_TRANSFER_COMMAND_NAME, + TransferCommand, + transferHbar, +} from './handler'; export type { TransferOutput } from './output'; export { TRANSFER_TEMPLATE, TransferOutputSchema } from './output'; diff --git a/src/plugins/hbar/manifest.ts b/src/plugins/hbar/manifest.ts index 9d6e33803..25ca8ba3d 100644 --- a/src/plugins/hbar/manifest.ts +++ b/src/plugins/hbar/manifest.ts @@ -18,6 +18,7 @@ export const hbarPluginManifest: PluginManifest = { name: 'transfer', summary: 'Transfer tinybars between accounts', description: 'Transfer HBAR (tinybars) from one account to another', + registeredHooks: ['batchify'], options: [ { name: 'amount', diff --git a/src/plugins/test/commands/foo/handler.ts b/src/plugins/test/commands/foo/handler.ts index bc92e34ee..45aed1650 100644 --- a/src/plugins/test/commands/foo/handler.ts +++ b/src/plugins/test/commands/foo/handler.ts @@ -9,12 +9,18 @@ import type { FooTestOutput } from './output'; import { BaseTransactionCommand } from '@/core/commands/command'; import { FooTestInputSchema } from '@/plugins/test/commands/foo/input'; -export class FooTestCommand extends BaseTransactionCommand< +export const TEST_FOO_COMMAND_NAME = 'test_foo'; + +export class TestFooCommand extends BaseTransactionCommand< FooNormalizedParams, FooBuildTransactionResult, FooSignTransactionResult, void > { + constructor() { + super(TEST_FOO_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -75,11 +81,11 @@ export class FooTestCommand extends BaseTransactionCommand< export async function fooTestOptions( args: CommandHandlerArgs, ): Promise { - return new FooTestCommand().execute(args); + return new TestFooCommand().execute(args); } -export async function fooTest( +export async function testFoo( args: CommandHandlerArgs, ): Promise { - return new FooTestCommand().execute(args); + return new TestFooCommand().execute(args); } diff --git a/src/plugins/test/commands/foo/index.ts b/src/plugins/test/commands/foo/index.ts index 1fd95b0ed..c589abea7 100644 --- a/src/plugins/test/commands/foo/index.ts +++ b/src/plugins/test/commands/foo/index.ts @@ -1,6 +1,6 @@ /** * Foo Command Exports */ -export { fooTest, fooTestOptions } from './handler'; +export { fooTestOptions, TEST_FOO_COMMAND_NAME, testFoo } from './handler'; export type { FooTestOutput } from './output'; export { FOO_TEST_TEMPLATE, FooTestOutputSchema } from './output'; diff --git a/src/plugins/test/index.ts b/src/plugins/test/index.ts index 924c14742..0120cfd33 100644 --- a/src/plugins/test/index.ts +++ b/src/plugins/test/index.ts @@ -2,6 +2,6 @@ * Test Plugin Index * Exports the test plugin manifest */ -export { fooTestOptions } from './commands/foo'; +export { fooTestOptions, TEST_FOO_COMMAND_NAME } from './commands/foo'; export { createMemo } from './commands/memo'; export { testPluginManifest } from './manifest'; diff --git a/src/plugins/token/__tests__/unit/create.test.ts b/src/plugins/token/__tests__/unit/create.test.ts index 4927e12df..98d55cc4d 100644 --- a/src/plugins/token/__tests__/unit/create.test.ts +++ b/src/plugins/token/__tests__/unit/create.test.ts @@ -7,8 +7,8 @@ import { AliasType } from '@/core/services/alias/alias-service.interface'; import { HederaTokenType } from '@/core/shared/constants'; import { SupplyType } from '@/core/types/shared.types'; import { + createFt, CreateFungibleTokenOutputSchema, - createToken, } from '@/plugins/token/commands/create-ft'; import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; @@ -96,7 +96,7 @@ describe('createTokenHandler', () => { const args = makeTokenCreateCommandArgs({ api, logger }); // Act - const result = await createToken(args); + const result = await createFt(args); // Assert // Note: importPrivateKey is NOT called because treasury is resolved from alias @@ -143,7 +143,7 @@ describe('createTokenHandler', () => { }; // Act - const result = await createToken(args); + const result = await createFt(args); // Assert // keyResolver.resolveKeyOrAliasWithFallback is called which internally uses getOperator @@ -189,7 +189,7 @@ describe('createTokenHandler', () => { }; // Act & Assert - Error is thrown before try-catch block in handler - await expect(createToken(args)).rejects.toThrow('No operator set'); + await expect(createFt(args)).rejects.toThrow('No operator set'); }); }); @@ -247,7 +247,7 @@ describe('createTokenHandler', () => { }; // Act & Assert - await expect(createToken(args)).rejects.toThrow(StateError); + await expect(createFt(args)).rejects.toThrow(StateError); expect(mockSaveToken).not.toHaveBeenCalled(); }); @@ -281,7 +281,7 @@ describe('createTokenHandler', () => { }; // Act & Assert - await expect(createToken(args)).rejects.toThrow('Service error'); + await expect(createFt(args)).rejects.toThrow('Service error'); }); test('should handle initial supply limit exceeded', async () => { const { api } = makeApiMocks({}); @@ -298,7 +298,7 @@ describe('createTokenHandler', () => { config: api.config, logger, }; - await expect(createToken(args)).rejects.toThrow( + await expect(createFt(args)).rejects.toThrow( 'Maximum balance for token exceeded. Token balance cannot be greater than 9223372036854775807', ); }); @@ -367,7 +367,7 @@ describe('createTokenHandler', () => { }; // Act - await createToken(args); + await createFt(args); // Assert expect(MockedHelper).toHaveBeenCalledWith(api.state, logger); diff --git a/src/plugins/token/__tests__/unit/error-handling.test.ts b/src/plugins/token/__tests__/unit/error-handling.test.ts index 9e4dcf742..8a1de96ba 100644 --- a/src/plugins/token/__tests__/unit/error-handling.test.ts +++ b/src/plugins/token/__tests__/unit/error-handling.test.ts @@ -11,7 +11,7 @@ import { import { AliasType } from '@/core/services/alias/alias-service.interface'; import { transferFt } from '@/plugins/token'; import { associateToken } from '@/plugins/token/commands/associate'; -import { createToken } from '@/plugins/token/commands/create-ft'; +import { createFt } from '@/plugins/token/commands/create-ft'; import { createTokenFromFile } from '@/plugins/token/commands/create-ft-from-file'; import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; @@ -93,7 +93,7 @@ describe('Token Plugin Error Handling', () => { }; // Act & Assert - await expect(createToken(args)).rejects.toThrow('Network timeout'); + await expect(createFt(args)).rejects.toThrow('Network timeout'); }); test('should handle network connectivity issues during association', async () => { @@ -203,7 +203,7 @@ describe('Token Plugin Error Handling', () => { }; // Act & Assert - Error is thrown before try-catch block in handler - await expect(createToken(args)).rejects.toThrow( + await expect(createFt(args)).rejects.toThrow( 'Invalid private key format', ); }); @@ -248,7 +248,7 @@ describe('Token Plugin Error Handling', () => { }; // Act & Assert - await expect(createToken(args)).rejects.toThrow(); + await expect(createFt(args)).rejects.toThrow(); }); test('should handle insufficient permissions', async () => { @@ -449,7 +449,7 @@ describe('Token Plugin Error Handling', () => { }; // Act & Assert - await expect(createToken(args)).rejects.toThrow(); + await expect(createFt(args)).rejects.toThrow(); }); }); @@ -560,7 +560,7 @@ describe('Token Plugin Error Handling', () => { }; // Act & Assert - await expect(createToken(args)).rejects.toThrow(); + await expect(createFt(args)).rejects.toThrow(); }); }); @@ -590,7 +590,7 @@ describe('Token Plugin Error Handling', () => { }; // Act & Assert - await expect(createToken(args)).rejects.toThrow(); + await expect(createFt(args)).rejects.toThrow(); }); test('should handle service throttling', async () => { @@ -680,7 +680,7 @@ describe('Token Plugin Error Handling', () => { }; // Act & Assert - await expect(createToken(args)).rejects.toThrow(StateError); + await expect(createFt(args)).rejects.toThrow(StateError); }); test('should handle unexpected API responses', async () => { @@ -708,7 +708,7 @@ describe('Token Plugin Error Handling', () => { logger, }; - const result = await createToken(args); + const result = await createFt(args); expect(result.result).toBeDefined(); }); }); diff --git a/src/plugins/token/__tests__/unit/handler-output-validation.test.ts b/src/plugins/token/__tests__/unit/handler-output-validation.test.ts index 5737aa648..a4eeae412 100644 --- a/src/plugins/token/__tests__/unit/handler-output-validation.test.ts +++ b/src/plugins/token/__tests__/unit/handler-output-validation.test.ts @@ -10,8 +10,8 @@ import { AssociateTokenOutputSchema, } from '@/plugins/token/commands/associate'; import { + createFt, CreateFungibleTokenOutputSchema, - createToken, } from '@/plugins/token/commands/create-ft'; import { listTokens, @@ -88,7 +88,7 @@ describe('Handler Output Validation - Token Plugin', () => { supplyType: SupplyType.INFINITE, }; - const result = await createToken({ + const result = await createFt({ api, logger: makeLogger(), state: api.state, diff --git a/src/plugins/token/__tests__/unit/plugin-structure.test.ts b/src/plugins/token/__tests__/unit/plugin-structure.test.ts index ca02d4208..5aecc97c9 100644 --- a/src/plugins/token/__tests__/unit/plugin-structure.test.ts +++ b/src/plugins/token/__tests__/unit/plugin-structure.test.ts @@ -4,7 +4,7 @@ */ import { associateToken, - createToken, + createFt, createTokenFromFile, transferFt, } from '@/plugins/token/index'; @@ -29,14 +29,14 @@ describe('Token Plugin Structure', () => { test('command handlers should be exported', () => { expect(transferFt).toBeDefined(); - expect(createToken).toBeDefined(); + expect(createFt).toBeDefined(); expect(associateToken).toBeDefined(); expect(createTokenFromFile).toBeDefined(); }); test('command handlers should be functions', () => { expect(typeof transferFt).toBe('function'); - expect(typeof createToken).toBe('function'); + expect(typeof createFt).toBe('function'); expect(typeof associateToken).toBe('function'); expect(typeof createTokenFromFile).toBe('function'); }); diff --git a/src/plugins/token/__tests__/unit/token-lifecycle.test.ts b/src/plugins/token/__tests__/unit/token-lifecycle.test.ts index 6e580428e..b9afa93eb 100644 --- a/src/plugins/token/__tests__/unit/token-lifecycle.test.ts +++ b/src/plugins/token/__tests__/unit/token-lifecycle.test.ts @@ -9,7 +9,7 @@ import { AliasType } from '@/core/services/alias/alias-service.interface'; import { HederaTokenType } from '@/core/shared/constants'; import { SupplyType } from '@/core/types/shared.types'; import { associateToken } from '@/plugins/token/commands/associate'; -import { createToken } from '@/plugins/token/commands/create-ft'; +import { createFt } from '@/plugins/token/commands/create-ft'; import { transferFt } from '@/plugins/token/commands/transfer-ft'; import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; @@ -121,7 +121,7 @@ describe('Token Lifecycle Integration', () => { config: makeConfigMock() as ConfigService, }; - const createResult = await createToken(createArgs); + const createResult = await createFt(createArgs); expect(createResult.result).toBeDefined(); // Step 2: Associate Token @@ -261,7 +261,7 @@ describe('Token Lifecycle Integration', () => { config: makeConfigMock() as ConfigService, }; - const createResult = await createToken(createArgs); + const createResult = await createFt(createArgs); expect(createResult.result).toBeDefined(); // Step 2: Associate Token (success) @@ -366,7 +366,7 @@ describe('Token Lifecycle Integration', () => { config: makeConfigMock() as ConfigService, }; - const createResult = await createToken(createArgs); + const createResult = await createFt(createArgs); expect(createResult.result).toBeDefined(); // Step 2: Associate with first user @@ -453,7 +453,7 @@ describe('Token Lifecycle Integration', () => { config: makeConfigMock() as ConfigService, }; - await expect(createToken(createArgs)).rejects.toThrow(); + await expect(createFt(createArgs)).rejects.toThrow(); const associateArgs: CommandHandlerArgs = { args: { diff --git a/src/plugins/token/commands/associate/handler.ts b/src/plugins/token/commands/associate/handler.ts index 007621195..e8ca8279c 100644 --- a/src/plugins/token/commands/associate/handler.ts +++ b/src/plugins/token/commands/associate/handler.ts @@ -18,6 +18,8 @@ import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; import { AssociateTokenInputSchema } from './input'; +export const TOKEN_ASSOCIATE_COMMAND_NAME = 'token_associate'; + function isTokenAlreadyAssociatedError(error: unknown): boolean { if (!(error instanceof TransactionError)) { return false; @@ -36,6 +38,10 @@ export class AssociateTokenCommand extends BaseTransactionCommand< AssociateSignTransactionResult, AssociateExecuteTransactionResult > { + constructor() { + super(TOKEN_ASSOCIATE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -193,7 +199,8 @@ export class AssociateTokenCommand extends BaseTransactionCommand< } } -export const associate = (args: CommandHandlerArgs) => - new AssociateTokenCommand().execute(args); - -export const associateToken = associate; +export async function associateToken( + args: CommandHandlerArgs, +): Promise { + return new AssociateTokenCommand().execute(args); +} diff --git a/src/plugins/token/commands/associate/index.ts b/src/plugins/token/commands/associate/index.ts index 6c25e5831..06902d380 100644 --- a/src/plugins/token/commands/associate/index.ts +++ b/src/plugins/token/commands/associate/index.ts @@ -2,6 +2,10 @@ * Associate Token Command Exports * For use by tests and external consumers */ -export { associate, associateToken, AssociateTokenCommand } from './handler'; +export { + associateToken, + AssociateTokenCommand, + TOKEN_ASSOCIATE_COMMAND_NAME, +} from './handler'; export type { AssociateTokenOutput } from './output'; export { ASSOCIATE_TOKEN_TEMPLATE, AssociateTokenOutputSchema } from './output'; diff --git a/src/plugins/token/commands/create-ft-from-file/handler.ts b/src/plugins/token/commands/create-ft-from-file/handler.ts index 783efca6a..a15e3c23d 100644 --- a/src/plugins/token/commands/create-ft-from-file/handler.ts +++ b/src/plugins/token/commands/create-ft-from-file/handler.ts @@ -29,12 +29,19 @@ import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; import { CreateFungibleTokenFromFileInputSchema } from './input'; +export const TOKEN_CREATE_FT_FROM_FILE_COMMAND_NAME = + 'token_create-ft-from-file'; + export class CreateFtFromFileCommand extends BaseTransactionCommand< CreateFtFromFileNormalizedParams, CreateFtFromFileBuildTransactionResult, CreateFtFromFileSignTransactionResult, CreateFtFromFileExecuteTransactionResult > { + constructor() { + super(TOKEN_CREATE_FT_FROM_FILE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -283,7 +290,8 @@ export class CreateFtFromFileCommand extends BaseTransactionCommand< } } -export const createFtFromFile = (args: CommandHandlerArgs) => - new CreateFtFromFileCommand().execute(args); - -export const createTokenFromFile = createFtFromFile; +export async function createTokenFromFile( + args: CommandHandlerArgs, +): Promise { + return new CreateFtFromFileCommand().execute(args); +} diff --git a/src/plugins/token/commands/create-ft-from-file/index.ts b/src/plugins/token/commands/create-ft-from-file/index.ts index cbd7a55dc..5ec4bb170 100644 --- a/src/plugins/token/commands/create-ft-from-file/index.ts +++ b/src/plugins/token/commands/create-ft-from-file/index.ts @@ -3,9 +3,9 @@ * For use by tests and external consumers */ export { - createFtFromFile, CreateFtFromFileCommand, createTokenFromFile, + TOKEN_CREATE_FT_FROM_FILE_COMMAND_NAME, } from './handler'; export type { CreateFungibleTokenFromFileOutput } from './output'; export { diff --git a/src/plugins/token/commands/create-ft/handler.ts b/src/plugins/token/commands/create-ft/handler.ts index f1a26166b..0c89b36ec 100644 --- a/src/plugins/token/commands/create-ft/handler.ts +++ b/src/plugins/token/commands/create-ft/handler.ts @@ -26,12 +26,18 @@ import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; import { CreateFungibleTokenInputSchema } from './input'; +export const TOKEN_CREATE_FT_COMMAND_NAME = 'token_create-ft'; + export class CreateFtCommand extends BaseTransactionCommand< CreateFtNormalizedParams, CreateFtBuildTransactionResult, CreateFtSignTransactionResult, CreateFtExecuteTransactionResult > { + constructor() { + super(TOKEN_CREATE_FT_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -232,7 +238,8 @@ export class CreateFtCommand extends BaseTransactionCommand< } } -export const createFt = (args: CommandHandlerArgs) => - new CreateFtCommand().execute(args); - -export const createToken = createFt; +export async function createFt( + args: CommandHandlerArgs, +): Promise { + return new CreateFtCommand().execute(args); +} diff --git a/src/plugins/token/commands/create-ft/index.ts b/src/plugins/token/commands/create-ft/index.ts index 317f30982..398db61f5 100644 --- a/src/plugins/token/commands/create-ft/index.ts +++ b/src/plugins/token/commands/create-ft/index.ts @@ -2,7 +2,11 @@ * Create Token Command Exports * For use by tests and external consumers */ -export { createFt, CreateFtCommand, createToken } from './handler'; +export { + createFt, + CreateFtCommand, + TOKEN_CREATE_FT_COMMAND_NAME, +} from './handler'; export type { CreateFungibleTokenOutput } from './output'; export { CREATE_FUNGIBLE_TOKEN_TEMPLATE, diff --git a/src/plugins/token/commands/create-nft-from-file/handler.ts b/src/plugins/token/commands/create-nft-from-file/handler.ts index 3baf3aa5b..19e26e04f 100644 --- a/src/plugins/token/commands/create-nft-from-file/handler.ts +++ b/src/plugins/token/commands/create-nft-from-file/handler.ts @@ -28,12 +28,19 @@ import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; import { CreateNftFromFileInputSchema } from './input'; +export const TOKEN_CREATE_NFT_FROM_FILE_COMMAND_NAME = + 'token_create-nft-from-file'; + export class CreateNftFromFileCommand extends BaseTransactionCommand< CreateNftFromFileNormalizedParams, CreateNftFromFileBuildTransactionResult, CreateNftFromFileSignTransactionResult, CreateNftFromFileExecuteTransactionResult > { + constructor() { + super(TOKEN_CREATE_NFT_FROM_FILE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -261,5 +268,8 @@ export class CreateNftFromFileCommand extends BaseTransactionCommand< } } -export const createNftFromFile = (args: CommandHandlerArgs) => - new CreateNftFromFileCommand().execute(args); +export async function createNftFromFile( + args: CommandHandlerArgs, +): Promise { + return new CreateNftFromFileCommand().execute(args); +} diff --git a/src/plugins/token/commands/create-nft-from-file/index.ts b/src/plugins/token/commands/create-nft-from-file/index.ts index 547765ac1..ed37d79dc 100644 --- a/src/plugins/token/commands/create-nft-from-file/index.ts +++ b/src/plugins/token/commands/create-nft-from-file/index.ts @@ -1,4 +1,8 @@ -export { createNftFromFile, CreateNftFromFileCommand } from './handler'; +export { + createNftFromFile, + CreateNftFromFileCommand, + TOKEN_CREATE_NFT_FROM_FILE_COMMAND_NAME, +} from './handler'; export type { CreateNftFromFileOutput } from './output'; export { CREATE_NFT_FROM_FILE_TEMPLATE, diff --git a/src/plugins/token/commands/create-nft/handler.ts b/src/plugins/token/commands/create-nft/handler.ts index 20766f234..1bac0d38a 100644 --- a/src/plugins/token/commands/create-nft/handler.ts +++ b/src/plugins/token/commands/create-nft/handler.ts @@ -24,12 +24,18 @@ import { } from '@/plugins/token/utils/token-data-builders'; import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; +export const TOKEN_CREATE_NFT_COMMAND_NAME = 'token_create-nft'; + export class CreateNftCommand extends BaseTransactionCommand< CreateNftNormalizedParams, CreateNftBuildTransactionResult, CreateNftSignTransactionResult, CreateNftExecuteTransactionResult > { + constructor() { + super(TOKEN_CREATE_NFT_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -216,5 +222,8 @@ export class CreateNftCommand extends BaseTransactionCommand< } } -export const createNft = (args: CommandHandlerArgs) => - new CreateNftCommand().execute(args); +export async function createNft( + args: CommandHandlerArgs, +): Promise { + return new CreateNftCommand().execute(args); +} diff --git a/src/plugins/token/commands/create-nft/index.ts b/src/plugins/token/commands/create-nft/index.ts index 28c0d23d2..eec843c32 100644 --- a/src/plugins/token/commands/create-nft/index.ts +++ b/src/plugins/token/commands/create-nft/index.ts @@ -2,6 +2,10 @@ * Create Token Command Exports * For use by tests and external consumers */ -export { createNft, CreateNftCommand } from './handler'; +export { + createNft, + CreateNftCommand, + TOKEN_CREATE_NFT_COMMAND_NAME, +} from './handler'; export type { CreateNftOutput } from './output'; export { CREATE_NFT_TEMPLATE, CreateNftOutputSchema } from './output'; diff --git a/src/plugins/token/commands/delete/handler.ts b/src/plugins/token/commands/delete/handler.ts index 11f5bf04a..697274427 100644 --- a/src/plugins/token/commands/delete/handler.ts +++ b/src/plugins/token/commands/delete/handler.ts @@ -67,7 +67,8 @@ export class DeleteTokenCommand implements Command { } } -export const deleteTokenFlow = (args: CommandHandlerArgs) => - new DeleteTokenCommand().execute(args); - -export const deleteToken = deleteTokenFlow; +export async function deleteToken( + args: CommandHandlerArgs, +): Promise { + return new DeleteTokenCommand().execute(args); +} diff --git a/src/plugins/token/commands/delete/index.ts b/src/plugins/token/commands/delete/index.ts index 790afe3ab..1ade116c3 100644 --- a/src/plugins/token/commands/delete/index.ts +++ b/src/plugins/token/commands/delete/index.ts @@ -2,6 +2,6 @@ * Delete Token Command Exports * For use by tests and external consumers */ -export { deleteToken, DeleteTokenCommand, deleteTokenFlow } from './handler'; +export { deleteToken, DeleteTokenCommand } from './handler'; export type { DeleteTokenOutput } from './output'; export { DELETE_TOKEN_TEMPLATE, DeleteTokenOutputSchema } from './output'; diff --git a/src/plugins/token/commands/import/handler.ts b/src/plugins/token/commands/import/handler.ts index 3cd56e66c..a9e97a62f 100644 --- a/src/plugins/token/commands/import/handler.ts +++ b/src/plugins/token/commands/import/handler.ts @@ -96,7 +96,8 @@ export class ImportTokenCommand implements Command { } } -export const importTokenFlow = (args: CommandHandlerArgs) => - new ImportTokenCommand().execute(args); - -export const importToken = importTokenFlow; +export async function importToken( + args: CommandHandlerArgs, +): Promise { + return new ImportTokenCommand().execute(args); +} diff --git a/src/plugins/token/commands/import/index.ts b/src/plugins/token/commands/import/index.ts index c49767060..9fa9872aa 100644 --- a/src/plugins/token/commands/import/index.ts +++ b/src/plugins/token/commands/import/index.ts @@ -1,4 +1,4 @@ -export { importToken, ImportTokenCommand, importTokenFlow } from './handler'; +export { importToken, ImportTokenCommand } from './handler'; export { ImportTokenInputSchema } from './input'; export type { ImportTokenOutput } from './output'; export { IMPORT_TOKEN_TEMPLATE, ImportTokenOutputSchema } from './output'; diff --git a/src/plugins/token/commands/list/handler.ts b/src/plugins/token/commands/list/handler.ts index 8e31a9b44..8e258c789 100644 --- a/src/plugins/token/commands/list/handler.ts +++ b/src/plugins/token/commands/list/handler.ts @@ -79,7 +79,8 @@ export class ListTokensCommand implements Command { } } -export const listTokensFlow = (args: CommandHandlerArgs) => - new ListTokensCommand().execute(args); - -export const listTokens = listTokensFlow; +export async function listTokens( + args: CommandHandlerArgs, +): Promise { + return new ListTokensCommand().execute(args); +} diff --git a/src/plugins/token/commands/list/index.ts b/src/plugins/token/commands/list/index.ts index 3f53fa70d..d733e9924 100644 --- a/src/plugins/token/commands/list/index.ts +++ b/src/plugins/token/commands/list/index.ts @@ -2,6 +2,6 @@ * List Tokens Command Exports * For use by tests and external consumers */ -export { listTokens, ListTokensCommand, listTokensFlow } from './handler'; +export { listTokens, ListTokensCommand } from './handler'; export type { ListTokensOutput, TokenListItem } from './output'; export { LIST_TOKENS_TEMPLATE, ListTokensOutputSchema } from './output'; diff --git a/src/plugins/token/commands/mint-ft/handler.ts b/src/plugins/token/commands/mint-ft/handler.ts index 9f5eb2a4e..e5d89adc6 100644 --- a/src/plugins/token/commands/mint-ft/handler.ts +++ b/src/plugins/token/commands/mint-ft/handler.ts @@ -22,12 +22,18 @@ import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; import { MintFtInputSchema } from './input'; -export class MintFtCommand extends BaseTransactionCommand< +export const TOKEN_MINT_FT_COMMAND_NAME = 'token_mint-ft'; + +export class TokenMintFtCommand extends BaseTransactionCommand< MintFtNormalizedParams, MintFtBuildTransactionResult, MintFtSignTransactionResult, MintFtExecuteTransactionResult > { + constructor() { + super(TOKEN_MINT_FT_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -193,5 +199,5 @@ export class MintFtCommand extends BaseTransactionCommand< } export async function mintFt(args: CommandHandlerArgs): Promise { - return new MintFtCommand().execute(args); + return new TokenMintFtCommand().execute(args); } diff --git a/src/plugins/token/commands/mint-ft/index.ts b/src/plugins/token/commands/mint-ft/index.ts index bc7fc35cc..b4dbacfdf 100644 --- a/src/plugins/token/commands/mint-ft/index.ts +++ b/src/plugins/token/commands/mint-ft/index.ts @@ -2,6 +2,10 @@ * Mint FT Command Exports * For use by tests and external consumers */ -export { mintFt, MintFtCommand } from './handler'; +export { + mintFt, + TOKEN_MINT_FT_COMMAND_NAME, + TokenMintFtCommand, +} from './handler'; export type { MintFtOutput } from './output'; export { MINT_FT_TEMPLATE, MintFtOutputSchema } from './output'; diff --git a/src/plugins/token/commands/mint-nft/handler.ts b/src/plugins/token/commands/mint-nft/handler.ts index 6428c44af..2c0c1e30b 100644 --- a/src/plugins/token/commands/mint-nft/handler.ts +++ b/src/plugins/token/commands/mint-nft/handler.ts @@ -22,12 +22,18 @@ import { MintNftInputSchema } from './input'; const MAX_METADATA_BYTES = 100; +export const TOKEN_MINT_NFT_COMMAND_NAME = 'token_mint-nft'; + export class MintNftCommand extends BaseTransactionCommand< MintNftNormalizedParams, MintNftBuildTransactionResult, MintNftSignTransactionResult, MintNftExecuteTransactionResult > { + constructor() { + super(TOKEN_MINT_NFT_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -174,5 +180,8 @@ export class MintNftCommand extends BaseTransactionCommand< } } -export const mintNft = (args: CommandHandlerArgs) => - new MintNftCommand().execute(args); +export async function mintNft( + args: CommandHandlerArgs, +): Promise { + return new MintNftCommand().execute(args); +} diff --git a/src/plugins/token/commands/mint-nft/index.ts b/src/plugins/token/commands/mint-nft/index.ts index f4d91873e..92ba55c91 100644 --- a/src/plugins/token/commands/mint-nft/index.ts +++ b/src/plugins/token/commands/mint-nft/index.ts @@ -1,4 +1,8 @@ -export { mintNft, MintNftCommand } from './handler'; +export { + mintNft, + MintNftCommand, + TOKEN_MINT_NFT_COMMAND_NAME, +} from './handler'; export { type MintNftInput, MintNftInputSchema } from './input'; export { MINT_NFT_TEMPLATE, diff --git a/src/plugins/token/commands/transfer-ft/handler.ts b/src/plugins/token/commands/transfer-ft/handler.ts index 8fc8331f3..ba9c534ad 100644 --- a/src/plugins/token/commands/transfer-ft/handler.ts +++ b/src/plugins/token/commands/transfer-ft/handler.ts @@ -20,12 +20,18 @@ import { ZustandTokenStateHelper } from '@/plugins/token/zustand-state-helper'; import { TransferFungibleTokenInputSchema } from './input'; +export const TOKEN_TRANSFER_FT_COMMAND_NAME = 'token_transfer-ft'; + export class TransferFtCommand extends BaseTransactionCommand< TransferFtNormalizedParams, TransferFtBuildTransactionResult, TransferFtSignTransactionResult, TransferFtExecuteTransactionResult > { + constructor() { + super(TOKEN_TRANSFER_FT_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { diff --git a/src/plugins/token/commands/transfer-ft/index.ts b/src/plugins/token/commands/transfer-ft/index.ts index 85833fd95..14b4aeef9 100644 --- a/src/plugins/token/commands/transfer-ft/index.ts +++ b/src/plugins/token/commands/transfer-ft/index.ts @@ -2,7 +2,11 @@ * Transfer Token Command Exports * For use by tests and external consumers */ -export { transferFt, TransferFtCommand } from './handler'; +export { + TOKEN_TRANSFER_FT_COMMAND_NAME, + transferFt, + TransferFtCommand, +} from './handler'; export type { TransferFungibleTokenOutput } from './output'; export { TRANSFER_FUNGIBLE_TOKEN_TEMPLATE, diff --git a/src/plugins/token/commands/transfer-nft/handler.ts b/src/plugins/token/commands/transfer-nft/handler.ts index 2038875ed..102ad6f98 100644 --- a/src/plugins/token/commands/transfer-nft/handler.ts +++ b/src/plugins/token/commands/transfer-nft/handler.ts @@ -21,12 +21,18 @@ import { import { TransferNftInputSchema } from './input'; +export const TOKEN_TRANSFER_NFT_COMMAND_NAME = 'token_transfer-nft'; + export class TransferNftCommand extends BaseTransactionCommand< TransferNftNormalizedParams, TransferNftBuildTransactionResult, TransferNftSignTransactionResult, TransferNftExecuteTransactionResult > { + constructor() { + super(TOKEN_TRANSFER_NFT_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -174,5 +180,8 @@ export class TransferNftCommand extends BaseTransactionCommand< } } -export const transferNft = (args: CommandHandlerArgs) => - new TransferNftCommand().execute(args); +export async function transferNft( + args: CommandHandlerArgs, +): Promise { + return new TransferNftCommand().execute(args); +} diff --git a/src/plugins/token/commands/transfer-nft/index.ts b/src/plugins/token/commands/transfer-nft/index.ts index 6c48d027f..5ac2dbe4b 100644 --- a/src/plugins/token/commands/transfer-nft/index.ts +++ b/src/plugins/token/commands/transfer-nft/index.ts @@ -1,3 +1,7 @@ -export { transferNft, TransferNftCommand } from './handler'; +export { + TOKEN_TRANSFER_NFT_COMMAND_NAME, + transferNft, + TransferNftCommand, +} from './handler'; export type { TransferNftOutput } from './output'; export { TRANSFER_NFT_TEMPLATE, TransferNftOutputSchema } from './output'; diff --git a/src/plugins/token/commands/view/handler.ts b/src/plugins/token/commands/view/handler.ts index b9a9a4a4c..be43fd19f 100644 --- a/src/plugins/token/commands/view/handler.ts +++ b/src/plugins/token/commands/view/handler.ts @@ -53,7 +53,8 @@ export class ViewTokenCommand implements Command { } } -export const viewTokenFlow = (args: CommandHandlerArgs) => - new ViewTokenCommand().execute(args); - -export const viewToken = viewTokenFlow; +export async function viewToken( + args: CommandHandlerArgs, +): Promise { + return new ViewTokenCommand().execute(args); +} diff --git a/src/plugins/token/commands/view/index.ts b/src/plugins/token/commands/view/index.ts index 553362a89..4e36f1635 100644 --- a/src/plugins/token/commands/view/index.ts +++ b/src/plugins/token/commands/view/index.ts @@ -1,6 +1,6 @@ /** * View Token Command Exports */ -export { viewToken, ViewTokenCommand, viewTokenFlow } from './handler'; +export { viewToken, ViewTokenCommand } from './handler'; export type { ViewTokenOutput } from './output'; export { VIEW_TOKEN_TEMPLATE, ViewTokenOutputSchema } from './output'; diff --git a/src/plugins/token/index.ts b/src/plugins/token/index.ts index bd4e4f977..e661536be 100644 --- a/src/plugins/token/index.ts +++ b/src/plugins/token/index.ts @@ -6,12 +6,16 @@ export { tokenPluginManifest } from './manifest'; // Export command handlers and schemas export { associateToken } from './commands/associate'; -export { createToken } from './commands/create-ft'; +export { createFt } from './commands/create-ft'; export { createTokenFromFile } from './commands/create-ft-from-file'; +export { createNft } from './commands/create-nft'; export { deleteToken } from './commands/delete'; export { importToken } from './commands/import'; export { listTokens } from './commands/list'; -export { mintFt } from './commands/mint-ft'; +export { mintFt, TOKEN_MINT_FT_COMMAND_NAME } from './commands/mint-ft'; export { mintNft } from './commands/mint-nft'; -export { transferFt } from './commands/transfer-ft'; +export { + TOKEN_TRANSFER_FT_COMMAND_NAME, + transferFt, +} from './commands/transfer-ft'; export { transferNft } from './commands/transfer-nft'; diff --git a/src/plugins/token/manifest.ts b/src/plugins/token/manifest.ts index 020ff5fcf..1678a2ce9 100644 --- a/src/plugins/token/manifest.ts +++ b/src/plugins/token/manifest.ts @@ -13,8 +13,8 @@ import { } from '@/plugins/token/commands/create-nft'; import { - associate, ASSOCIATE_TOKEN_TEMPLATE, + associateToken, AssociateTokenOutputSchema, } from './commands/associate'; import { @@ -24,8 +24,8 @@ import { } from './commands/create-ft'; import { CREATE_FUNGIBLE_TOKEN_FROM_FILE_TEMPLATE, - createFtFromFile, CreateFungibleTokenFromFileOutputSchema, + createTokenFromFile, } from './commands/create-ft-from-file'; import { CREATE_NFT_FROM_FILE_TEMPLATE, @@ -34,17 +34,17 @@ import { } from './commands/create-nft-from-file'; import { DELETE_TOKEN_TEMPLATE, - deleteTokenFlow, + deleteToken, DeleteTokenOutputSchema, } from './commands/delete'; import { IMPORT_TOKEN_TEMPLATE, - importTokenFlow, + importToken, ImportTokenOutputSchema, } from './commands/import'; import { LIST_TOKENS_TEMPLATE, - listTokensFlow, + listTokens, ListTokensOutputSchema, } from './commands/list'; import { @@ -69,7 +69,7 @@ import { } from './commands/transfer-nft'; import { VIEW_TOKEN_TEMPLATE, - viewTokenFlow, + viewToken, ViewTokenOutputSchema, } from './commands/view'; @@ -127,6 +127,7 @@ export const tokenPluginManifest: PluginManifest = { name: 'mint-nft', summary: 'Mint NFT', description: 'Mint a new NFT to an existing NFT collection.', + registeredHooks: ['batchify'], options: [ { name: 'token', @@ -220,6 +221,7 @@ export const tokenPluginManifest: PluginManifest = { name: 'transfer-nft', summary: 'Transfer a non-fungible token', description: 'Transfer one or more NFTs from one account to another', + registeredHooks: ['batchify'], options: [ { name: 'token', @@ -270,6 +272,7 @@ export const tokenPluginManifest: PluginManifest = { name: 'create-ft', summary: 'Create a new fungible token', description: 'Create a new fungible token with specified properties', + registeredHooks: ['batchify'], options: [ { name: 'token-name', @@ -377,6 +380,7 @@ export const tokenPluginManifest: PluginManifest = { name: 'create-nft', summary: 'Create a new non-fungible token', description: 'Create a new non-fungible token with specified properties', + registeredHooks: ['batchify'], options: [ { name: 'token-name', @@ -465,6 +469,7 @@ export const tokenPluginManifest: PluginManifest = { name: 'associate', summary: 'Associate a token with an account', description: 'Associate a token with an account to enable transfers', + registeredHooks: ['batchify'], options: [ { name: 'token', @@ -490,7 +495,7 @@ export const tokenPluginManifest: PluginManifest = { 'Key manager to use: local or local_encrypted (defaults to config setting)', }, ], - handler: associate, + handler: associateToken, output: { schema: AssociateTokenOutputSchema, humanTemplate: ASSOCIATE_TOKEN_TEMPLATE, @@ -501,6 +506,7 @@ export const tokenPluginManifest: PluginManifest = { summary: 'Create a new fungible token from a file', description: 'Create a new fungible token from a JSON file definition with advanced features', + registeredHooks: ['batchify'], options: [ { name: 'file', @@ -519,7 +525,7 @@ export const tokenPluginManifest: PluginManifest = { 'Key manager to use: local or local_encrypted (defaults to config setting)', }, ], - handler: createFtFromFile, + handler: createTokenFromFile, output: { schema: CreateFungibleTokenFromFileOutputSchema, humanTemplate: CREATE_FUNGIBLE_TOKEN_FROM_FILE_TEMPLATE, @@ -530,6 +536,7 @@ export const tokenPluginManifest: PluginManifest = { summary: 'Create a new NFT token from a file', description: 'Create a new non-fungible token from a JSON file definition with advanced features', + registeredHooks: ['batchify'], options: [ { name: 'file', @@ -569,7 +576,7 @@ export const tokenPluginManifest: PluginManifest = { description: 'Show token key information (admin, supply, wipe, etc.)', }, ], - handler: listTokensFlow, + handler: listTokens, output: { schema: ListTokensOutputSchema, humanTemplate: LIST_TOKENS_TEMPLATE, @@ -596,7 +603,7 @@ export const tokenPluginManifest: PluginManifest = { description: 'Serial number of a specific NFT instance', }, ], - handler: viewTokenFlow, + handler: viewToken, output: { schema: ViewTokenOutputSchema, humanTemplate: VIEW_TOKEN_TEMPLATE, @@ -616,7 +623,7 @@ export const tokenPluginManifest: PluginManifest = { description: 'Token identifier: either a token alias or token-id', }, ], - handler: deleteTokenFlow, + handler: deleteToken, output: { schema: DeleteTokenOutputSchema, humanTemplate: DELETE_TOKEN_TEMPLATE, @@ -643,7 +650,7 @@ export const tokenPluginManifest: PluginManifest = { description: 'Name/alias for the token', }, ], - handler: importTokenFlow, + handler: importToken, output: { schema: ImportTokenOutputSchema, humanTemplate: IMPORT_TOKEN_TEMPLATE, diff --git a/src/plugins/topic/commands/create/handler.ts b/src/plugins/topic/commands/create/handler.ts index ef405a1e1..e7ad1995f 100644 --- a/src/plugins/topic/commands/create/handler.ts +++ b/src/plugins/topic/commands/create/handler.ts @@ -18,12 +18,18 @@ import { ZustandTopicStateHelper } from '@/plugins/topic/zustand-state-helper'; import { CreateTopicInputSchema } from './input'; +export const TOPIC_CREATE_COMMAND_NAME = 'topic_create'; + export class CreateTopicCommand extends BaseTransactionCommand< CreateTopicNormalisedParams, CreateTopicBuildTransactionResult, CreateTopicSignTransactionResult, CreateTopicExecuteTransactionResult > { + constructor() { + super(TOPIC_CREATE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -181,6 +187,8 @@ export class CreateTopicCommand extends BaseTransactionCommand< } } -const createTopicCommand = new CreateTopicCommand(); - -export const createTopic = createTopicCommand.execute.bind(createTopicCommand); +export async function createTopic( + args: CommandHandlerArgs, +): Promise { + return new CreateTopicCommand().execute(args); +} diff --git a/src/plugins/topic/commands/create/index.ts b/src/plugins/topic/commands/create/index.ts index a6b4beb61..5aec9fd14 100644 --- a/src/plugins/topic/commands/create/index.ts +++ b/src/plugins/topic/commands/create/index.ts @@ -2,6 +2,10 @@ * Create Topic Command Exports * For use by manifest, tests, and external consumers */ -export { createTopic, CreateTopicCommand } from './handler'; +export { + createTopic, + CreateTopicCommand, + TOPIC_CREATE_COMMAND_NAME, +} from './handler'; export type { CreateTopicOutput } from './output'; export { CREATE_TOPIC_TEMPLATE, CreateTopicOutputSchema } from './output'; diff --git a/src/plugins/topic/commands/delete/handler.ts b/src/plugins/topic/commands/delete/handler.ts index f266eb724..8a2c0d3b2 100644 --- a/src/plugins/topic/commands/delete/handler.ts +++ b/src/plugins/topic/commands/delete/handler.ts @@ -82,6 +82,8 @@ export class DeleteTopicCommand implements Command { } } -const deleteTopicCommand = new DeleteTopicCommand(); - -export const deleteTopic = deleteTopicCommand.execute.bind(deleteTopicCommand); +export async function deleteTopic( + args: CommandHandlerArgs, +): Promise { + return new DeleteTopicCommand().execute(args); +} diff --git a/src/plugins/topic/commands/find-message/handler.ts b/src/plugins/topic/commands/find-message/handler.ts index c23e2ac0f..13633de49 100644 --- a/src/plugins/topic/commands/find-message/handler.ts +++ b/src/plugins/topic/commands/find-message/handler.ts @@ -47,6 +47,8 @@ export class FindMessageCommand implements Command { } } -const findMessageCommand = new FindMessageCommand(); - -export const findMessage = findMessageCommand.execute.bind(findMessageCommand); +export async function findMessage( + args: CommandHandlerArgs, +): Promise { + return new FindMessageCommand().execute(args); +} diff --git a/src/plugins/topic/commands/import/handler.ts b/src/plugins/topic/commands/import/handler.ts index 7ab92ade8..3ad71a8ba 100644 --- a/src/plugins/topic/commands/import/handler.ts +++ b/src/plugins/topic/commands/import/handler.ts @@ -80,6 +80,8 @@ export class ImportTopicCommand implements Command { } } -const importTopicCommand = new ImportTopicCommand(); - -export const importTopic = importTopicCommand.execute.bind(importTopicCommand); +export async function importTopic( + args: CommandHandlerArgs, +): Promise { + return new ImportTopicCommand().execute(args); +} diff --git a/src/plugins/topic/commands/list/handler.ts b/src/plugins/topic/commands/list/handler.ts index d863655cd..ffeb4ef11 100644 --- a/src/plugins/topic/commands/list/handler.ts +++ b/src/plugins/topic/commands/list/handler.ts @@ -62,6 +62,8 @@ export class ListTopicsCommand implements Command { } } -const listTopicsCommand = new ListTopicsCommand(); - -export const listTopics = listTopicsCommand.execute.bind(listTopicsCommand); +export async function listTopics( + args: CommandHandlerArgs, +): Promise { + return new ListTopicsCommand().execute(args); +} diff --git a/src/plugins/topic/commands/submit-message/handler.ts b/src/plugins/topic/commands/submit-message/handler.ts index 8e7e6d66e..cb6d7cceb 100644 --- a/src/plugins/topic/commands/submit-message/handler.ts +++ b/src/plugins/topic/commands/submit-message/handler.ts @@ -20,12 +20,18 @@ import { ZustandTopicStateHelper } from '@/plugins/topic/zustand-state-helper'; import { SubmitMessageInputSchema } from './input'; +export const TOPIC_SUBMIT_MESSAGE_COMMAND_NAME = 'topic_submit-message'; + export class SubmitMessageCommand extends BaseTransactionCommand< SubmitMessageNormalisedParams, SubmitMessageBuildTransactionResult, SubmitMessageSignTransactionResult, SubmitMessageExecuteTransactionResult > { + constructor() { + super(TOPIC_SUBMIT_MESSAGE_COMMAND_NAME); + } + async normalizeParams( args: CommandHandlerArgs, ): Promise { @@ -167,7 +173,8 @@ export class SubmitMessageCommand extends BaseTransactionCommand< } } -const submitMessageCommand = new SubmitMessageCommand(); - -export const submitMessage = - submitMessageCommand.execute.bind(submitMessageCommand); +export async function submitMessage( + args: CommandHandlerArgs, +): Promise { + return new SubmitMessageCommand().execute(args); +} diff --git a/src/plugins/topic/commands/submit-message/index.ts b/src/plugins/topic/commands/submit-message/index.ts index 9f0c12c92..56eb0a473 100644 --- a/src/plugins/topic/commands/submit-message/index.ts +++ b/src/plugins/topic/commands/submit-message/index.ts @@ -2,6 +2,10 @@ * Submit Message Command Exports * For use by manifest, tests, and external consumers */ -export { submitMessage, SubmitMessageCommand } from './handler'; +export { + submitMessage, + SubmitMessageCommand, + TOPIC_SUBMIT_MESSAGE_COMMAND_NAME, +} from './handler'; export type { SubmitMessageOutput } from './output'; export { SUBMIT_MESSAGE_TEMPLATE, SubmitMessageOutputSchema } from './output'; diff --git a/src/plugins/topic/manifest.ts b/src/plugins/topic/manifest.ts index 8fb7f0496..8e15f956a 100644 --- a/src/plugins/topic/manifest.ts +++ b/src/plugins/topic/manifest.ts @@ -51,6 +51,7 @@ export const topicPluginManifest: PluginManifest = { summary: 'Create a new Hedera topic', description: 'Create a new Hedera Consensus Service topic with optional memo and keys', + registeredHooks: ['batchify'], options: [ { name: 'memo', @@ -140,6 +141,7 @@ export const topicPluginManifest: PluginManifest = { name: 'submit-message', summary: 'Submit a message to a topic', description: 'Submit a message to a Hedera Consensus Service topic', + registeredHooks: ['batchify'], options: [ { name: 'topic',