From 3ce4b92d0fd0341c07f82f0e9198d3eb5d122703 Mon Sep 17 00:00:00 2001
From: clauspeterhuebner
Date: Thu, 19 Feb 2026 02:30:53 +0100
Subject: [PATCH] linting
---
core/src/command/BaseCommand.ts | 29 ++--
core/src/command/Command.ts | 6 +-
core/src/command/CommandExecutor.ts | 60 +++----
core/src/command/CommandFactory.ts | 55 ++++---
core/src/command/CommandTypes.ts | 6 +-
core/src/command/commands/SendEmailCommand.ts | 151 ++++++++++--------
core/src/command/initCommands.ts | 12 +-
core/src/emails/sendEmailVariants.ts | 2 +-
.../federation/client/1_0/CommandClient.ts | 4 +-
.../federation/client/CommandClientFactory.ts | 4 +-
core/src/graphql/logic/processCommand.ts | 6 +-
.../src/graphql/logic/processXComSendCoins.ts | 9 +-
core/src/graphql/model/CommandResult.ts | 10 +-
core/src/index.ts | 6 +-
.../api/1_0/resolver/CommandResolver.ts | 14 +-
federation/src/graphql/api/1_1/schema.ts | 10 +-
federation/src/index.ts | 3 +-
.../jwt/payloadtypes/CommandJwtPayloadType.ts | 13 +-
18 files changed, 219 insertions(+), 181 deletions(-)
diff --git a/core/src/command/BaseCommand.ts b/core/src/command/BaseCommand.ts
index 6f32fa41d..1184bf32b 100644
--- a/core/src/command/BaseCommand.ts
+++ b/core/src/command/BaseCommand.ts
@@ -1,28 +1,30 @@
-import { getLogger } from 'log4js';
-import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const';
-import { Command } from './Command';
+import { getLogger } from 'log4js'
+import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const'
+import { Command } from './Command'
const createLogger = (method: string) =>
getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.command.BaseCommand.${method}`)
export abstract class BaseCommand implements Command {
- protected abstract requiredFields: string[];
+ protected abstract requiredFields: string[]
protected constructor(protected readonly params: any[]) {
// this.validateRequiredFields();
}
- abstract execute(): Promise;
+ abstract execute(): Promise
private validateRequiredFields(): void {
const methodLogger = createLogger(`validateRequiredFields`)
- if(!this.requiredFields || this.requiredFields.length === 0) {
+ if (!this.requiredFields || this.requiredFields.length === 0) {
methodLogger.debug(`validateRequiredFields() no required fields`)
- return;
+ return
}
- methodLogger.debug(`validateRequiredFields() requiredFields=${JSON.stringify(this.requiredFields)}`)
- const commandArgs = JSON.parse(this.params[0])
+ methodLogger.debug(
+ `validateRequiredFields() requiredFields=${JSON.stringify(this.requiredFields)}`,
+ )
/*
+ const commandArgs = JSON.parse(this.params[0])
const missingFields = this.requiredFields.filter(field =>
commandArgs.{ field } === undefined || commandArgs.{ field } === null || commandArgs.{ field } === ''
);
@@ -34,10 +36,12 @@ export abstract class BaseCommand implements Command {
}
*/
}
-
+
validate(): boolean {
const methodLogger = createLogger(`validate`)
- methodLogger.debug(`validate() requiredFields=${JSON.stringify(this.requiredFields)} params=${JSON.stringify(this.params)}`)
+ methodLogger.debug(
+ `validate() requiredFields=${JSON.stringify(this.requiredFields)} params=${JSON.stringify(this.params)}`,
+ )
/*
const isValid = this.requiredFields.every(field =>
this.params[field] !== undefined &&
@@ -46,7 +50,6 @@ export abstract class BaseCommand implements Command {
);
methodLogger.debug(`validate() isValid=${isValid}`)
*/
- return true;
+ return true
}
-
}
diff --git a/core/src/command/Command.ts b/core/src/command/Command.ts
index abd498474..45afe5b49 100644
--- a/core/src/command/Command.ts
+++ b/core/src/command/Command.ts
@@ -1,4 +1,4 @@
-export interface Command {
- execute(): Promise;
- validate?(): boolean;
+export interface Command<_T = any> {
+ execute(): Promise
+ validate?(): boolean
}
diff --git a/core/src/command/CommandExecutor.ts b/core/src/command/CommandExecutor.ts
index 3a7193bac..97b67c77a 100644
--- a/core/src/command/CommandExecutor.ts
+++ b/core/src/command/CommandExecutor.ts
@@ -1,12 +1,13 @@
// core/src/command/CommandExecutor.ts
-import { CommandJwtPayloadType } from 'shared';
-import { interpretEncryptedTransferArgs } from '../graphql/logic/interpretEncryptedTransferArgs';
-import { EncryptedTransferArgs } from '../graphql/model/EncryptedTransferArgs';
-import { Command } from './Command';
-import { getLogger } from 'log4js';
-import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const';
-import { CommandFactory } from './CommandFactory';
-import { CommandResult } from '../graphql/model/CommandResult';
+
+import { getLogger } from 'log4js'
+import { CommandJwtPayloadType } from 'shared'
+import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const'
+import { interpretEncryptedTransferArgs } from '../graphql/logic/interpretEncryptedTransferArgs'
+import { CommandResult } from '../graphql/model/CommandResult'
+import { EncryptedTransferArgs } from '../graphql/model/EncryptedTransferArgs'
+import { Command } from './Command'
+import { CommandFactory } from './CommandFactory'
const createLogger = (method: string) =>
getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.command.CommandExecutor.${method}`)
@@ -19,28 +20,28 @@ export class CommandExecutor {
if (command.validate && !command.validate()) {
const errmsg = `Command validation failed for command=${command.constructor.name}`
methodLogger.error(errmsg)
- return { success: false, error: errmsg };
+ return { success: false, error: errmsg }
}
methodLogger.debug(`executeCommand() executing command=${command.constructor.name}`)
- const result = await command.execute();
+ const result = await command.execute()
methodLogger.debug(`executeCommand() executed result=${result}`)
- return { success: true, data: result };
+ return { success: true, data: result }
} catch (error) {
methodLogger.error(`executeCommand() error=${error}`)
- return {
- success: false,
- error: error instanceof Error ? error.message : 'Unknown error occurred'
- };
+ return {
+ success: false,
+ error: error instanceof Error ? error.message : 'Unknown error occurred',
+ }
}
}
- async executeEncryptedCommand(
- encryptedArgs: EncryptedTransferArgs
- ): Promise {
+ async executeEncryptedCommand<_T>(encryptedArgs: EncryptedTransferArgs): Promise {
const methodLogger = createLogger(`executeEncryptedCommand`)
try {
// Decrypt the command data
- const commandArgs = (await interpretEncryptedTransferArgs(encryptedArgs)) as CommandJwtPayloadType
+ const commandArgs = (await interpretEncryptedTransferArgs(
+ encryptedArgs,
+ )) as CommandJwtPayloadType
if (!commandArgs) {
const errmsg = `invalid commandArgs payload of requesting community with publicKey=${encryptedArgs.publicKey}`
methodLogger.error(errmsg)
@@ -49,25 +50,28 @@ export class CommandExecutor {
if (methodLogger.isDebugEnabled()) {
methodLogger.debug(`executeEncryptedCommand() commandArgs=${JSON.stringify(commandArgs)}`)
}
- const command = CommandFactory.getInstance().createCommand(commandArgs.commandName, commandArgs.commandArgs);
+ const command = CommandFactory.getInstance().createCommand(
+ commandArgs.commandName,
+ commandArgs.commandArgs,
+ )
if (methodLogger.isDebugEnabled()) {
methodLogger.debug(`executeEncryptedCommand() command=${JSON.stringify(command)}`)
}
-
+
// Execute the command
- const result = await this.executeCommand(command);
+ const result = await this.executeCommand(command)
if (methodLogger.isDebugEnabled()) {
methodLogger.debug(`executeCommand() result=${JSON.stringify(result)}`)
}
-
+
return result
} catch (error) {
methodLogger.error(`executeEncryptedCommand() error=${error}`)
- const errorResult: CommandResult = {
- success: false,
- error: error instanceof Error ? error.message : 'Failed to process command'
- };
- return errorResult;
+ const errorResult: CommandResult = {
+ success: false,
+ error: error instanceof Error ? error.message : 'Failed to process command',
+ }
+ return errorResult
}
}
}
diff --git a/core/src/command/CommandFactory.ts b/core/src/command/CommandFactory.ts
index 5c5374778..4a4e7d806 100644
--- a/core/src/command/CommandFactory.ts
+++ b/core/src/command/CommandFactory.ts
@@ -1,25 +1,25 @@
-import { ICommandConstructor } from './CommandTypes';
-import { BaseCommand } from './BaseCommand';
-import { getLogger } from 'log4js';
-import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const';
+import { getLogger } from 'log4js'
+import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const'
+import { BaseCommand } from './BaseCommand'
+import { Command } from './Command'
+import { ICommandConstructor } from './CommandTypes'
// import { ICommandConstructor } from './CommandTypes';
-import { SendEmailCommand } from './commands/SendEmailCommand';
-import { Command } from './Command';
+import { SendEmailCommand } from './commands/SendEmailCommand'
const createLogger = (method: string) =>
getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.command.CommandFactory.${method}`)
export class CommandFactory {
- private static instance: CommandFactory;
- private commands: Map = new Map();
+ private static instance: CommandFactory
+ private commands: Map = new Map()
private constructor() {}
static getInstance(): CommandFactory {
if (!CommandFactory.instance) {
- CommandFactory.instance = new CommandFactory();
+ CommandFactory.instance = new CommandFactory()
}
- return CommandFactory.instance;
+ return CommandFactory.instance
}
registerCommand(name: string, commandClass: ICommandConstructor): void {
@@ -27,7 +27,7 @@ export class CommandFactory {
if (methodLogger.isDebugEnabled()) {
methodLogger.debug(`registerCommand() name=${name}, commandClass=${commandClass.name}`)
}
- this.commands.set(name, commandClass);
+ this.commands.set(name, commandClass)
if (methodLogger.isDebugEnabled()) {
methodLogger.debug(`registerCommand() commands=${JSON.stringify(this.commands.entries())}`)
}
@@ -38,14 +38,16 @@ export class CommandFactory {
if (methodLogger.isDebugEnabled()) {
methodLogger.debug(`createCommand() name=${name} params=${JSON.stringify(params)}`)
}
- const CommandClass = this.commands.get(name);
+ const CommandClass = this.commands.get(name)
if (methodLogger.isDebugEnabled()) {
- methodLogger.debug(`createCommand() name=${name} commandClass=${CommandClass ? CommandClass.name : 'null'}`)
+ methodLogger.debug(
+ `createCommand() name=${name} commandClass=${CommandClass ? CommandClass.name : 'null'}`,
+ )
}
if (CommandClass === undefined) {
- const errmsg = `Command ${name} not found`;
- methodLogger.error(errmsg);
- throw new Error(errmsg);
+ const errmsg = `Command ${name} not found`
+ methodLogger.error(errmsg)
+ throw new Error(errmsg)
}
/*
try {
@@ -60,16 +62,17 @@ export class CommandFactory {
throw new Error(errmsg);
}
*/
- let command: BaseCommand;
- switch(CommandClass.name) {
- case 'SendEmailCommand':
- command = new SendEmailCommand(params);
- break;
- default:
- const errmsg = `Command ${name} not found`;
- methodLogger.error(errmsg);
- throw new Error(errmsg);
- }
+ let command: BaseCommand
+ switch (CommandClass.name) {
+ case 'SendEmailCommand':
+ command = new SendEmailCommand(params)
+ break
+ default: {
+ const errmsg = `Command ${name} not found`
+ methodLogger.error(errmsg)
+ throw new Error(errmsg)
+ }
+ }
if (methodLogger.isDebugEnabled()) {
methodLogger.debug(`createCommand() created command=${JSON.stringify(command)}`)
}
diff --git a/core/src/command/CommandTypes.ts b/core/src/command/CommandTypes.ts
index 9a6ebefc1..c5cf309cf 100644
--- a/core/src/command/CommandTypes.ts
+++ b/core/src/command/CommandTypes.ts
@@ -1,5 +1,5 @@
-import { Command } from "./Command";
+import { Command } from './Command'
export interface ICommandConstructor {
- new (params: any): Command;
-}
\ No newline at end of file
+ new (params: any): Command
+}
diff --git a/core/src/command/commands/SendEmailCommand.ts b/core/src/command/commands/SendEmailCommand.ts
index 0fd748610..ebf08ce73 100644
--- a/core/src/command/commands/SendEmailCommand.ts
+++ b/core/src/command/commands/SendEmailCommand.ts
@@ -1,70 +1,91 @@
-import { BaseCommand } from '../BaseCommand';
-import { sendTransactionReceivedEmail } from '../../emails/sendEmailVariants';
-import { findUserByUuids } from 'database';
-import { LOG4JS_BASE_CATEGORY_NAME } from '../../config/const';
-import { getLogger } from 'log4js';
-import Decimal from 'decimal.js-light';
+import { findUserByUuids } from 'database'
+import Decimal from 'decimal.js-light'
+import { getLogger } from 'log4js'
+import { LOG4JS_BASE_CATEGORY_NAME } from '../../config/const'
+import { sendTransactionReceivedEmail } from '../../emails/sendEmailVariants'
+import { BaseCommand } from '../BaseCommand'
const createLogger = (method: string) =>
getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.command.commands.SendEmailCommand.${method}`)
export interface SendEmailCommandParams {
- mailType: string;
- senderComUuid: string;
- senderGradidoId: string;
- receiverComUuid: string;
- receiverGradidoId: string;
- memo?: string;
- amount?: string;
+ mailType: string
+ senderComUuid: string
+ senderGradidoId: string
+ receiverComUuid: string
+ receiverGradidoId: string
+ memo?: string
+ amount?: string
}
-export class SendEmailCommand extends BaseCommand | boolean | null | Error> {
- static readonly SEND_MAIL_COMMAND = 'SEND_MAIL_COMMAND';
- protected requiredFields: string[] = ['mailType', 'senderComUuid', 'senderGradidoId', 'receiverComUuid', 'receiverGradidoId'];
- protected sendEmailCommandParams: SendEmailCommandParams;
+export class SendEmailCommand extends BaseCommand<
+ Record | boolean | null | Error
+> {
+ static readonly SEND_MAIL_COMMAND = 'SEND_MAIL_COMMAND'
+ protected requiredFields: string[] = [
+ 'mailType',
+ 'senderComUuid',
+ 'senderGradidoId',
+ 'receiverComUuid',
+ 'receiverGradidoId',
+ ]
+ protected sendEmailCommandParams: SendEmailCommandParams
constructor(params: any[]) {
const methodLogger = createLogger(`constructor`)
methodLogger.debug(`constructor() params=${JSON.stringify(params)}`)
- super(params);
- this.sendEmailCommandParams = JSON.parse(params[0]) as SendEmailCommandParams;
+ super(params)
+ this.sendEmailCommandParams = JSON.parse(params[0]) as SendEmailCommandParams
}
validate(): boolean {
- const baseValid = super.validate();
+ const baseValid = super.validate()
if (!baseValid) {
- return false;
+ return false
}
// Additional validations
- return true;
+ return true
}
async execute(): Promise {
const methodLogger = createLogger(`execute`)
- methodLogger.debug(`execute() sendEmailCommandParams=${JSON.stringify(this.sendEmailCommandParams)}`)
- let result: string;
+ methodLogger.debug(
+ `execute() sendEmailCommandParams=${JSON.stringify(this.sendEmailCommandParams)}`,
+ )
+ let result: string
if (!this.validate()) {
- throw new Error('Invalid command parameters');
+ throw new Error('Invalid command parameters')
}
// find sender user
- methodLogger.debug(`find sender user: ${this.sendEmailCommandParams.senderComUuid} ${this.sendEmailCommandParams.senderGradidoId}`)
- const senderUser = await findUserByUuids(this.sendEmailCommandParams.senderComUuid, this.sendEmailCommandParams.senderGradidoId, true);
+ methodLogger.debug(
+ `find sender user: ${this.sendEmailCommandParams.senderComUuid} ${this.sendEmailCommandParams.senderGradidoId}`,
+ )
+ const senderUser = await findUserByUuids(
+ this.sendEmailCommandParams.senderComUuid,
+ this.sendEmailCommandParams.senderGradidoId,
+ true,
+ )
methodLogger.debug(`senderUser=${JSON.stringify(senderUser)}`)
if (!senderUser) {
- const errmsg = `Sender user not found: ${this.sendEmailCommandParams.senderComUuid} ${this.sendEmailCommandParams.senderGradidoId}`;
- methodLogger.error(errmsg);
- throw new Error(errmsg);
+ const errmsg = `Sender user not found: ${this.sendEmailCommandParams.senderComUuid} ${this.sendEmailCommandParams.senderGradidoId}`
+ methodLogger.error(errmsg)
+ throw new Error(errmsg)
}
-
- methodLogger.debug(`find recipient user: ${this.sendEmailCommandParams.receiverComUuid} ${this.sendEmailCommandParams.receiverGradidoId}`)
- const recipientUser = await findUserByUuids(this.sendEmailCommandParams.receiverComUuid, this.sendEmailCommandParams.receiverGradidoId);
+
+ methodLogger.debug(
+ `find recipient user: ${this.sendEmailCommandParams.receiverComUuid} ${this.sendEmailCommandParams.receiverGradidoId}`,
+ )
+ const recipientUser = await findUserByUuids(
+ this.sendEmailCommandParams.receiverComUuid,
+ this.sendEmailCommandParams.receiverGradidoId,
+ )
methodLogger.debug(`recipientUser=${JSON.stringify(recipientUser)}`)
if (!recipientUser) {
- const errmsg = `Recipient user not found: ${this.sendEmailCommandParams.receiverComUuid} ${this.sendEmailCommandParams.receiverGradidoId}`;
- methodLogger.error(errmsg);
- throw new Error(errmsg);
+ const errmsg = `Recipient user not found: ${this.sendEmailCommandParams.receiverComUuid} ${this.sendEmailCommandParams.receiverGradidoId}`
+ methodLogger.error(errmsg)
+ throw new Error(errmsg)
}
-
+
const emailParams = {
firstName: recipientUser.firstName,
lastName: recipientUser.lastName,
@@ -75,23 +96,24 @@ export class SendEmailCommand extends BaseCommand | bool
senderEmail: senderUser.emailId !== null ? senderUser.emailContact.email : null,
memo: this.sendEmailCommandParams.memo || '',
transactionAmount: new Decimal(this.sendEmailCommandParams.amount || 0).abs(),
- };
- methodLogger.debug(`emailParams=${JSON.stringify(emailParams)}`)
- switch(this.sendEmailCommandParams.mailType) {
- case 'sendTransactionReceivedEmail':
- const emailResult = await sendTransactionReceivedEmail(emailParams);
- result = this.getEmailResult(emailResult);
- break;
- default:
- throw new Error(`Unknown mail type: ${this.sendEmailCommandParams.mailType}`);
}
-
+ methodLogger.debug(`emailParams=${JSON.stringify(emailParams)}`)
+ switch (this.sendEmailCommandParams.mailType) {
+ case 'sendTransactionReceivedEmail': {
+ const emailResult = await sendTransactionReceivedEmail(emailParams)
+ result = this.getEmailResult(emailResult)
+ break
+ }
+ default:
+ throw new Error(`Unknown mail type: ${this.sendEmailCommandParams.mailType}`)
+ }
+
try {
// Example: const result = await emailService.sendEmail(this.params);
- return result;
+ return result
} catch (error) {
- methodLogger.error('Error executing SendEmailCommand:', error);
- throw error;
+ methodLogger.error('Error executing SendEmailCommand:', error)
+ throw error
}
}
@@ -100,29 +122,24 @@ export class SendEmailCommand extends BaseCommand | bool
if (methodLogger.isDebugEnabled()) {
methodLogger.debug(`result=${JSON.stringify(result)}`)
}
- let emailResult: string;
- if(result === null) {
+ let emailResult: string
+ if (result === null) {
emailResult = `result is null`
- }
- else if(typeof result === 'boolean') {
+ } else if (typeof result === 'boolean') {
emailResult = `result is ${result}`
- }
- else if(result instanceof Error) {
+ } else if (result instanceof Error) {
emailResult = `error-message is ${result.message}`
- }
- else if(typeof result === 'object') {
+ } else if (typeof result === 'object') {
// {"accepted":["stage5@gradido.net"],"rejected":[],"ehlo":["PIPELINING","SIZE 25600000","ETRN","AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN","ENHANCEDSTATUSCODES","8BITMIME","DSN","CHUNKING"],"envelopeTime":23,"messageTime":135,"messageSize":37478,"response":"250 2.0.0 Ok: queued as C45C2100BD7","envelope":{"from":"stage5@gradido.net","to":["stage5@gradido.net"]},"messageId":""
- const accepted = (result as Record).accepted;
- const messageSize = (result as Record).messageSize;
- const response = (result as Record).response;
- const envelope = JSON.stringify((result as Record).envelope);
+ const accepted = (result as Record).accepted
+ const messageSize = (result as Record).messageSize
+ const response = (result as Record).response
+ const envelope = JSON.stringify((result as Record).envelope)
emailResult = `accepted=${accepted}, messageSize=${messageSize}, response=${response}, envelope=${envelope}`
- }
- else {
+ } else {
emailResult = `result is unknown type`
}
- return emailResult;
+ return emailResult
}
-
-}
\ No newline at end of file
+}
diff --git a/core/src/command/initCommands.ts b/core/src/command/initCommands.ts
index 631335d26..5144f43c7 100644
--- a/core/src/command/initCommands.ts
+++ b/core/src/command/initCommands.ts
@@ -1,11 +1,11 @@
-import { CommandFactory } from './CommandFactory';
-import { SendEmailCommand } from './commands/SendEmailCommand';
+import { CommandFactory } from './CommandFactory'
+import { SendEmailCommand } from './commands/SendEmailCommand'
// Import other commands...
export function initializeCommands(): void {
- const factory = CommandFactory.getInstance();
-
+ const factory = CommandFactory.getInstance()
+
// Register all commands
- factory.registerCommand(SendEmailCommand.SEND_MAIL_COMMAND, SendEmailCommand);
+ factory.registerCommand(SendEmailCommand.SEND_MAIL_COMMAND, SendEmailCommand)
// Register other commands...
- }
+}
diff --git a/core/src/emails/sendEmailVariants.ts b/core/src/emails/sendEmailVariants.ts
index 973a5549e..85c001ea3 100644
--- a/core/src/emails/sendEmailVariants.ts
+++ b/core/src/emails/sendEmailVariants.ts
@@ -186,7 +186,7 @@ export const sendTransactionReceivedEmail = (
locals: {
...data,
transactionAmount: decimalSeparatorByLanguage(data.transactionAmount, data.language),
- ...data.senderEmail !== null ? getEmailCommonLocales() : {locale: data.language},
+ ...(data.senderEmail !== null ? getEmailCommonLocales() : { locale: data.language }),
},
})
}
diff --git a/core/src/federation/client/1_0/CommandClient.ts b/core/src/federation/client/1_0/CommandClient.ts
index 817fb7bd7..4a0000bc0 100644
--- a/core/src/federation/client/1_0/CommandClient.ts
+++ b/core/src/federation/client/1_0/CommandClient.ts
@@ -1,10 +1,10 @@
-import { EncryptedTransferArgs } from '../../../graphql/model/EncryptedTransferArgs'
import { FederatedCommunity as DbFederatedCommunity } from 'database'
import { GraphQLClient } from 'graphql-request'
import { getLogger } from 'log4js'
import { LOG4JS_BASE_CATEGORY_NAME } from '../../../config/const'
-import { sendCommand as sendCommandQuery} from './query/sendCommand'
+import { EncryptedTransferArgs } from '../../../graphql/model/EncryptedTransferArgs'
import { ensureUrlEndsWithSlash } from '../../../util/utilities'
+import { sendCommand as sendCommandQuery } from './query/sendCommand'
const logger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.federation.client.1_0.CommandClient`)
diff --git a/core/src/federation/client/CommandClientFactory.ts b/core/src/federation/client/CommandClientFactory.ts
index a03fb493a..3211b4ad8 100644
--- a/core/src/federation/client/CommandClientFactory.ts
+++ b/core/src/federation/client/CommandClientFactory.ts
@@ -39,9 +39,7 @@ export class CommandClientFactory {
* just one instance of each subclass around.
*/
public static getInstance(dbCom: DbFederatedCommunity): CommandClient | null {
- const instance = CommandClientFactory.instanceArray.find(
- (instance) => instance.id === dbCom.id,
- )
+ const instance = CommandClientFactory.instanceArray.find((instance) => instance.id === dbCom.id)
if (instance) {
return instance.client
}
diff --git a/core/src/graphql/logic/processCommand.ts b/core/src/graphql/logic/processCommand.ts
index 355f71892..673d0f56b 100644
--- a/core/src/graphql/logic/processCommand.ts
+++ b/core/src/graphql/logic/processCommand.ts
@@ -4,7 +4,11 @@ import { LOG4JS_BASE_CATEGORY_NAME } from '../../config/const'
const createLogger = (method: string) =>
getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.graphql.resolver.logic.processCommand.${method}`)
-export async function processCommand(commandClass: string, commandMethod: string, commandArgs: string[]) {
+export async function processCommand(
+ commandClass: string,
+ commandMethod: string,
+ commandArgs: string[],
+) {
const methodLogger = createLogger(`processCommand`)
methodLogger.info('processing a command...')
}
diff --git a/core/src/graphql/logic/processXComSendCoins.ts b/core/src/graphql/logic/processXComSendCoins.ts
index 9a4ba4fd0..b48bacde8 100644
--- a/core/src/graphql/logic/processXComSendCoins.ts
+++ b/core/src/graphql/logic/processXComSendCoins.ts
@@ -24,14 +24,16 @@ import {
verifyAndDecrypt,
} from 'shared'
import { randombytes_random } from 'sodium-native'
+import { SendEmailCommand } from '../../command/commands/SendEmailCommand'
import { CONFIG as CONFIG_CORE } from '../../config'
import { LOG4JS_BASE_CATEGORY_NAME } from '../../config/const'
import { sendTransactionLinkRedeemedEmail, sendTransactionReceivedEmail } from '../../emails'
+import { CommandClient as V1_0_CommandClient } from '../../federation/client/1_0/CommandClient'
import { SendCoinsResultLoggingView } from '../../federation/client/1_0/logging/SendCoinsResultLogging.view'
import { SendCoinsResult } from '../../federation/client/1_0/model/SendCoinsResult'
import { SendCoinsClient as V1_0_SendCoinsClient } from '../../federation/client/1_0/SendCoinsClient'
-import { SendCoinsClientFactory } from '../../federation/client/SendCoinsClientFactory'
import { CommandClientFactory } from '../../federation/client/CommandClientFactory'
+import { SendCoinsClientFactory } from '../../federation/client/SendCoinsClientFactory'
import { TransactionTypeId } from '../../graphql/enum/TransactionTypeId'
import { EncryptedTransferArgs } from '../../graphql/model/EncryptedTransferArgs'
import { calculateSenderBalance } from '../../util/calculateSenderBalance'
@@ -39,8 +41,6 @@ import { fullName } from '../../util/utilities'
import { settlePendingSenderTransaction } from './settlePendingSenderTransaction'
import { storeForeignUser } from './storeForeignUser'
import { storeLinkAsRedeemed } from './storeLinkAsRedeemed'
-import { CommandClient as V1_0_CommandClient } from '../../federation/client/1_0/CommandClient'
-import { SendEmailCommand } from '../../command/commands/SendEmailCommand'
const createLogger = (method: string) =>
getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.graphql.resolver.util.processXComSendCoins.${method}`)
@@ -533,7 +533,8 @@ export async function processXComCommittingSendCoins(
memo: pendingTx.memo,
amount: pendingTx.amount,
}),
- ])
+ ],
+ )
const jws = await encryptAndSign(
payload,
senderCom.privateJwtKey!,
diff --git a/core/src/graphql/model/CommandResult.ts b/core/src/graphql/model/CommandResult.ts
index 38b7e2dd4..76962d5f4 100644
--- a/core/src/graphql/model/CommandResult.ts
+++ b/core/src/graphql/model/CommandResult.ts
@@ -3,11 +3,11 @@ import { Field, ObjectType } from 'type-graphql'
@ObjectType()
export class CommandResult {
@Field(() => Boolean)
- success: boolean;
-
+ success: boolean
+
@Field(() => String, { nullable: true })
- data?: any;
-
+ data?: any
+
@Field(() => String, { nullable: true })
- error?: string;
+ error?: string
}
diff --git a/core/src/index.ts b/core/src/index.ts
index 3bbfdc578..4ea5e3815 100644
--- a/core/src/index.ts
+++ b/core/src/index.ts
@@ -1,8 +1,9 @@
-export * from './config/index'
export * from './command/CommandExecutor'
export * from './command/CommandFactory'
export * from './command/initCommands'
+export * from './config/index'
export * from './emails'
+export { CommandClient as V1_0_CommandClient } from './federation/client/1_0/CommandClient'
export * from './federation/client/1_0/logging/SendCoinsArgsLogging.view'
export * from './federation/client/1_0/logging/SendCoinsResultLogging.view'
export * from './federation/client/1_0/model/SendCoinsArgs'
@@ -11,9 +12,8 @@ export * from './federation/client/1_0/query/revertSendCoins'
export * from './federation/client/1_0/query/revertSettledSendCoins'
export * from './federation/client/1_0/query/settleSendCoins'
export * from './federation/client/1_0/query/voteForSendCoins'
-export { CommandClient as V1_0_CommandClient } from './federation/client/1_0/CommandClient'
-export { CommandClient as V1_1_CommandClient } from './federation/client/1_1/CommandClient'
export { SendCoinsClient as V1_0_SendCoinsClient } from './federation/client/1_0/SendCoinsClient'
+export { CommandClient as V1_1_CommandClient } from './federation/client/1_1/CommandClient'
export { SendCoinsClient as V1_1_SendCoinsClient } from './federation/client/1_1/SendCoinsClient'
export * from './federation/client/CommandClientFactory'
export * from './federation/client/SendCoinsClientFactory'
diff --git a/federation/src/graphql/api/1_0/resolver/CommandResolver.ts b/federation/src/graphql/api/1_0/resolver/CommandResolver.ts
index 559ae4963..8200b5488 100644
--- a/federation/src/graphql/api/1_0/resolver/CommandResolver.ts
+++ b/federation/src/graphql/api/1_0/resolver/CommandResolver.ts
@@ -1,19 +1,17 @@
-import { Resolver, Mutation, Arg, Ctx } from 'type-graphql';
-import { CommandExecutor } from 'core';
-import { CommandResult } from 'core';
-import { EncryptedTransferArgs } from 'core';
+import { CommandExecutor, CommandResult, EncryptedTransferArgs } from 'core'
+import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'
@Resolver()
export class CommandResolver {
- private commandExecutor = new CommandExecutor();
+ private commandExecutor = new CommandExecutor()
@Mutation(() => CommandResult)
async sendCommand(
@Arg('encryptedArgs', () => EncryptedTransferArgs) encryptedArgs: any,
- @Ctx() context: any
+ @Ctx() context: any,
): Promise {
// Convert to EncryptedTransferArgs if needed
- const result = await this.commandExecutor.executeEncryptedCommand(encryptedArgs);
- return result as unknown as CommandResult;
+ const result = await this.commandExecutor.executeEncryptedCommand(encryptedArgs)
+ return result as unknown as CommandResult
}
}
diff --git a/federation/src/graphql/api/1_1/schema.ts b/federation/src/graphql/api/1_1/schema.ts
index 891c83dc9..484fdf535 100644
--- a/federation/src/graphql/api/1_1/schema.ts
+++ b/federation/src/graphql/api/1_1/schema.ts
@@ -1,10 +1,16 @@
import { NonEmptyArray } from 'type-graphql'
import { AuthenticationResolver } from '../1_0/resolver/AuthenticationResolver'
+import { CommandResolver } from '../1_0/resolver/CommandResolver'
import { PublicCommunityInfoResolver } from '../1_0/resolver/PublicCommunityInfoResolver'
import { SendCoinsResolver } from '../1_0/resolver/SendCoinsResolver'
import { PublicKeyResolver } from './resolver/PublicKeyResolver'
-import { CommandResolver } from '../1_0/resolver/CommandResolver'
export const getApiResolvers = (): NonEmptyArray => {
- return [AuthenticationResolver, CommandResolver, PublicCommunityInfoResolver, PublicKeyResolver, SendCoinsResolver]
+ return [
+ AuthenticationResolver,
+ CommandResolver,
+ PublicCommunityInfoResolver,
+ PublicKeyResolver,
+ SendCoinsResolver,
+ ]
}
diff --git a/federation/src/index.ts b/federation/src/index.ts
index 5dea4703f..1303aa631 100644
--- a/federation/src/index.ts
+++ b/federation/src/index.ts
@@ -1,13 +1,13 @@
import 'source-map-support/register'
import { defaultCategory, initLogger } from 'config-schema'
+import { initializeCommands } from 'core'
import { getLogger } from 'log4js'
import { onShutdown, printServerCrashAsciiArt, ShutdownReason } from 'shared'
// config
import { CONFIG } from './config'
import { LOG4JS_BASE_CATEGORY_NAME } from './config/const'
import { createServer } from './server/createServer'
-import { initializeCommands } from 'core'
async function main() {
const startTime = new Date()
@@ -47,7 +47,6 @@ async function main() {
})
initializeCommands()
-
}
main().catch((e) => {
diff --git a/shared/src/jwt/payloadtypes/CommandJwtPayloadType.ts b/shared/src/jwt/payloadtypes/CommandJwtPayloadType.ts
index f41832466..ab724c771 100644
--- a/shared/src/jwt/payloadtypes/CommandJwtPayloadType.ts
+++ b/shared/src/jwt/payloadtypes/CommandJwtPayloadType.ts
@@ -3,11 +3,16 @@ import { JwtPayloadType } from './JwtPayloadType'
export class CommandJwtPayloadType extends JwtPayloadType {
static COMMAND_TYPE = 'command'
- commandName: string
- commandClass: string
- commandArgs: string[]
+ commandName: string
+ commandClass: string
+ commandArgs: string[]
- constructor(handshakeID: string, commandName: string, commandClass: string, commandArgs: string[]) {
+ constructor(
+ handshakeID: string,
+ commandName: string,
+ commandClass: string,
+ commandArgs: string[],
+ ) {
super(handshakeID)
this.tokentype = CommandJwtPayloadType.COMMAND_TYPE
this.commandName = commandName