From 328d806cad973b0bc7e3e8821fca35788b9e7dc7 Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Fri, 11 Aug 2023 22:46:58 -0400 Subject: [PATCH 01/13] Update initial changes --- .../models/bpiMessageType.enum.ts | 1 + .../executeVsmCycleCommand.handler.ts | 17 +++---- .../handleWorkstepFailures.command.ts | 3 ++ .../handleWorkstepFailuresCommand.handler.ts | 45 +++++++++++++++++++ .../workstepExecutionFailures.event.ts | 3 ++ .../workstepExecutionFailures.handler.ts | 17 +++++++ .../capabilites/sagas/vsmFailures.sagas.ts | 19 ++++++++ examples/bri-3/src/bri/vsm/vsm.module.ts | 12 ++++- 8 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailures.command.ts create mode 100644 examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts create mode 100644 examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts create mode 100644 examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts create mode 100644 examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts diff --git a/examples/bri-3/src/bri/communication/models/bpiMessageType.enum.ts b/examples/bri-3/src/bri/communication/models/bpiMessageType.enum.ts index 9cc4a9e00..e6c74b6b6 100644 --- a/examples/bri-3/src/bri/communication/models/bpiMessageType.enum.ts +++ b/examples/bri-3/src/bri/communication/models/bpiMessageType.enum.ts @@ -1,4 +1,5 @@ export enum BpiMessageType { Info, Transaction, + Err, } diff --git a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts index 6a695fb39..542787b9d 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts @@ -1,10 +1,10 @@ -import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; -import { LoggingService } from '../../../../shared/logging/logging.service'; +import { CommandHandler, ICommandHandler, EventBus } from '@nestjs/cqrs'; import { TransactionStorageAgent } from '../../../transactions/agents/transactionStorage.agent'; import { TransactionAgent } from '../../../transactions/agents/transactions.agent'; import { TransactionStatus } from '../../../transactions/models/transactionStatus.enum'; import { WorkstepStorageAgent } from '../../../workgroup/worksteps/agents/workstepsStorage.agent'; import { ExecuteVsmCycleCommand } from './executeVsmCycle.command'; +import { WorkstepExecutionFailuresEvent } from '../handleWorkstepFailuresEvents/workstepExecutionFailures.event'; @CommandHandler(ExecuteVsmCycleCommand) export class ExecuteVsmCycleCommandHandler @@ -14,7 +14,7 @@ export class ExecuteVsmCycleCommandHandler private agent: TransactionAgent, private workstepStorageAgent: WorkstepStorageAgent, private txStorageAgent: TransactionStorageAgent, - private readonly logger: LoggingService, + private eventBus: EventBus, ) {} async execute(command: ExecuteVsmCycleCommand) { @@ -29,8 +29,9 @@ export class ExecuteVsmCycleCommandHandler await this.txStorageAgent.updateTransactionStatus(tx); if (!this.agent.validateTransactionForExecution(tx)) { - tx.updateStatusToInvalid(); - await this.txStorageAgent.updateTransactionStatus(tx); + this.eventBus.publish( + new WorkstepExecutionFailuresEvent(tx.id, 'Validation Error'), + ); return; } @@ -45,11 +46,7 @@ export class ExecuteVsmCycleCommandHandler tx.updateStatusToExecuted(); this.txStorageAgent.updateTransactionStatus(tx); } catch (error) { - this.logger.logError( - `Error executing transaction with id ${tx.id}: ${error}`, - ); - tx.updateStatusToAborted(); - this.txStorageAgent.updateTransactionStatus(tx); + this.eventBus.publish(new WorkstepExecutionFailuresEvent(tx.id, error)); return; } }); diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailures.command.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailures.command.ts new file mode 100644 index 000000000..530d1b296 --- /dev/null +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailures.command.ts @@ -0,0 +1,3 @@ +export class HandleWorkstepFailuresCommand { + constructor(public readonly id: string) {} +} diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts new file mode 100644 index 000000000..b71285169 --- /dev/null +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts @@ -0,0 +1,45 @@ +import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; +import { MessagingAgent } from '../../../communication/agents/messaging.agent'; +import { BpiMessage } from '../../../communication/models/bpiMessage'; +import { BpiMessageType } from '../../../communication/models/bpiMessageType.enum'; +import { HandleWorkstepFailuresCommand } from './handleWorkstepFailures.command'; +import { TransactionStorageAgent } from '../../../transactions/agents/transactionStorage.agent'; + +@CommandHandler(HandleWorkstepFailuresCommand) +export class HandleWorkstepFailuresCommandHandler + implements ICommandHandler +{ + constructor( + private readonly messagingAgent: MessagingAgent, + private txStorageAgent: TransactionStorageAgent, + ) {} + + async execute(command: HandleWorkstepFailuresCommand) { + const errPayload = { + errorCode: 'xxx', + errorMessage: 'Execution fails', + }; + + const tx = await this.txStorageAgent.getTransactionById(command.id); + + if (tx != undefined) { + const errorBpiMessage = new BpiMessage( + tx.id, + tx.fromBpiSubjectAccountId, + tx.toBpiSubjectAccountId, + JSON.stringify(errPayload), + tx.signature, + BpiMessageType.Err, + ); + + const initiatorChannel = + tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey; + await this.messagingAgent.publishMessage( + initiatorChannel, + JSON.stringify(errorBpiMessage), + ); + tx.updateStatusToAborted(); + this.txStorageAgent.updateTransactionStatus(tx); + } + } +} diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts new file mode 100644 index 000000000..0ac9ce848 --- /dev/null +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts @@ -0,0 +1,3 @@ +export class WorkstepExecutionFailuresEvent { + constructor(public readonly id: string, public readonly err: string) {} +} diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts new file mode 100644 index 000000000..a91ec4acb --- /dev/null +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts @@ -0,0 +1,17 @@ +import { IEventHandler } from '@nestjs/cqrs'; +import { EventsHandler } from '@nestjs/cqrs/dist/decorators/events-handler.decorator'; +import { WorkstepExecutionFailuresEvent } from './workstepExecutionFailures.event'; +import { LoggingService } from '../../../../shared/logging/logging.service'; + +@EventsHandler(WorkstepExecutionFailuresEvent) +export class WorkstepExecutionFailuresHandler + implements IEventHandler +{ + constructor(private readonly logger: LoggingService) {} + + handle(event: WorkstepExecutionFailuresEvent) { + this.logger.logError( + `Invalid transaction for execution with id ${event.id}: ${event.err}`, + ); + } +} diff --git a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts new file mode 100644 index 000000000..0ccfe5b80 --- /dev/null +++ b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@nestjs/common'; +import { ICommand, ofType, Saga } from '@nestjs/cqrs'; +import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { WorkstepExecutionFailuresEvent } from '../handleWorkstepFailuresEvents/workstepExecutionFailures.event'; +import { HandleWorkstepFailuresCommand } from '../handleWorkstepFailures/handleWorkstepFailures.command'; + +@Injectable() +export class VsmFailureSagas { + @Saga() + handleWorkstepFailures = (events$: Observable): Observable => { + return events$.pipe( + ofType(WorkstepExecutionFailuresEvent), + map((event) => { + return new HandleWorkstepFailuresCommand(event.id); + }), + ); + }; +} diff --git a/examples/bri-3/src/bri/vsm/vsm.module.ts b/examples/bri-3/src/bri/vsm/vsm.module.ts index e7eed1cf9..973aff309 100644 --- a/examples/bri-3/src/bri/vsm/vsm.module.ts +++ b/examples/bri-3/src/bri/vsm/vsm.module.ts @@ -6,8 +6,16 @@ import { TransactionModule } from '../transactions/transactions.module'; import { WorkstepModule } from '../workgroup/worksteps/worksteps.module'; import { VsmTasksSchedulerAgent } from './agents/vsmTaskScheduler.agent'; import { ExecuteVsmCycleCommandHandler } from './capabilites/executeVsmCycle/executeVsmCycleCommand.handler'; +import { MessagingAgent } from '../communication/agents/messaging.agent'; +import { WorkstepExecutionFailuresHandler } from './capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler'; +import { HandleWorkstepFailuresCommandHandler } from './capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler'; +import { VsmFailureSagas } from './capabilites/sagas/vsmFailures.sagas'; -export const CommandHandlers = [ExecuteVsmCycleCommandHandler]; +export const CommandHandlers = [ + ExecuteVsmCycleCommandHandler, + HandleWorkstepFailuresCommandHandler, + WorkstepExecutionFailuresHandler, +]; export const QueryHandlers = []; @@ -18,6 +26,8 @@ export const QueryHandlers = []; TransactionModule, LoggingModule, WorkstepModule, + MessagingAgent, + VsmFailureSagas, ], providers: [VsmTasksSchedulerAgent, ...CommandHandlers, ...QueryHandlers], }) From 67ce8a9676657c96c1c7b38334651e76e3232444 Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Mon, 21 Aug 2023 02:49:29 -0400 Subject: [PATCH 02/13] Move abort transaction & update status back to executeVsmCycleCommand --- .../executeVsmCycle/executeVsmCycleCommand.handler.ts | 8 +++++++- .../handleWorkstepFailuresCommand.handler.ts | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts index 542787b9d..2c7c8a4bf 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts @@ -32,6 +32,8 @@ export class ExecuteVsmCycleCommandHandler this.eventBus.publish( new WorkstepExecutionFailuresEvent(tx.id, 'Validation Error'), ); + tx.updateStatusToAborted(); + this.txStorageAgent.updateTransactionStatus(tx); return; } @@ -46,7 +48,11 @@ export class ExecuteVsmCycleCommandHandler tx.updateStatusToExecuted(); this.txStorageAgent.updateTransactionStatus(tx); } catch (error) { - this.eventBus.publish(new WorkstepExecutionFailuresEvent(tx.id, error)); + this.eventBus.publish( + new WorkstepExecutionFailuresEvent(tx.id, error) + ); + tx.updateStatusToAborted(); + this.txStorageAgent.updateTransactionStatus(tx); return; } }); diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts index b71285169..3db90b9fb 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts @@ -38,8 +38,6 @@ export class HandleWorkstepFailuresCommandHandler initiatorChannel, JSON.stringify(errorBpiMessage), ); - tx.updateStatusToAborted(); - this.txStorageAgent.updateTransactionStatus(tx); } } } From 5bef8c2ac90cfc6dacdbf77606d64de793438c88 Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Mon, 21 Aug 2023 03:19:38 -0400 Subject: [PATCH 03/13] migrate code to event and event handler --- .../executeVsmCycleCommand.handler.ts | 18 +++++++++++-- .../workstepExecutionFailures.event.ts | 11 +++++++- .../workstepExecutionFailures.handler.ts | 27 ++++++++++++++++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts index 2c7c8a4bf..fdf954369 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts @@ -30,7 +30,14 @@ export class ExecuteVsmCycleCommandHandler if (!this.agent.validateTransactionForExecution(tx)) { this.eventBus.publish( - new WorkstepExecutionFailuresEvent(tx.id, 'Validation Error'), + new WorkstepExecutionFailuresEvent( + tx.id, + 'Validation Error', + tx.fromBpiSubjectAccountId, + tx.toBpiSubjectAccountId, + tx.signature, + tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey + ) ); tx.updateStatusToAborted(); this.txStorageAgent.updateTransactionStatus(tx); @@ -49,7 +56,14 @@ export class ExecuteVsmCycleCommandHandler this.txStorageAgent.updateTransactionStatus(tx); } catch (error) { this.eventBus.publish( - new WorkstepExecutionFailuresEvent(tx.id, error) + new WorkstepExecutionFailuresEvent( + tx.id, + error, + tx.fromBpiSubjectAccountId, + tx.toBpiSubjectAccountId, + tx.signature, + tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey + ) ); tx.updateStatusToAborted(); this.txStorageAgent.updateTransactionStatus(tx); diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts index 0ac9ce848..2aab05ea3 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts @@ -1,3 +1,12 @@ +import { BpiSubjectAccount } from "@prisma/client"; + export class WorkstepExecutionFailuresEvent { - constructor(public readonly id: string, public readonly err: string) {} + constructor( + public readonly id: string, + public readonly err: string, + public readonly fromBpiSubjectAccountId: string, + public readonly toBpiSubjectAccountId: string, + public readonly signature: string, + public readonly initiatorChannel: string + ) {} } diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts index a91ec4acb..fb95dff55 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts @@ -2,16 +2,41 @@ import { IEventHandler } from '@nestjs/cqrs'; import { EventsHandler } from '@nestjs/cqrs/dist/decorators/events-handler.decorator'; import { WorkstepExecutionFailuresEvent } from './workstepExecutionFailures.event'; import { LoggingService } from '../../../../shared/logging/logging.service'; +import { BpiMessage } from '../../../communication/models/bpiMessage'; +import { BpiMessageType } from '../../../communication/models/bpiMessageType.enum'; +import { MessagingAgent } from '../../../communication/agents/messaging.agent'; @EventsHandler(WorkstepExecutionFailuresEvent) export class WorkstepExecutionFailuresHandler implements IEventHandler { - constructor(private readonly logger: LoggingService) {} + constructor( + private readonly logger: LoggingService, + private readonly messagingAgent: MessagingAgent, + ) {} handle(event: WorkstepExecutionFailuresEvent) { this.logger.logError( `Invalid transaction for execution with id ${event.id}: ${event.err}`, ); + + const errPayload = { + errorCode: 'xxx', + errorMessage: 'Execution fails', + }; + + const errorBpiMessage = new BpiMessage( + event.id, + event.fromBpiSubjectAccountId, + event.toBpiSubjectAccountId, + JSON.stringify(errPayload), + event.signature, + BpiMessageType.Err, + ); + + this.messagingAgent.publishMessage( + event.initiatorChannel, + JSON.stringify(errorBpiMessage), + ); } } From dede37dfc3cb54062df02b18b4124c29da9564e3 Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Mon, 21 Aug 2023 03:35:28 -0400 Subject: [PATCH 04/13] remove handleWorkstepFailures command and handler --- .../handleWorkstepFailures.command.ts | 3 -- .../handleWorkstepFailuresCommand.handler.ts | 43 ------------------- .../capabilites/sagas/vsmFailures.sagas.ts | 6 +-- examples/bri-3/src/bri/vsm/vsm.module.ts | 2 - 4 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailures.command.ts delete mode 100644 examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailures.command.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailures.command.ts deleted file mode 100644 index 530d1b296..000000000 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailures.command.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class HandleWorkstepFailuresCommand { - constructor(public readonly id: string) {} -} diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts deleted file mode 100644 index 3db90b9fb..000000000 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; -import { MessagingAgent } from '../../../communication/agents/messaging.agent'; -import { BpiMessage } from '../../../communication/models/bpiMessage'; -import { BpiMessageType } from '../../../communication/models/bpiMessageType.enum'; -import { HandleWorkstepFailuresCommand } from './handleWorkstepFailures.command'; -import { TransactionStorageAgent } from '../../../transactions/agents/transactionStorage.agent'; - -@CommandHandler(HandleWorkstepFailuresCommand) -export class HandleWorkstepFailuresCommandHandler - implements ICommandHandler -{ - constructor( - private readonly messagingAgent: MessagingAgent, - private txStorageAgent: TransactionStorageAgent, - ) {} - - async execute(command: HandleWorkstepFailuresCommand) { - const errPayload = { - errorCode: 'xxx', - errorMessage: 'Execution fails', - }; - - const tx = await this.txStorageAgent.getTransactionById(command.id); - - if (tx != undefined) { - const errorBpiMessage = new BpiMessage( - tx.id, - tx.fromBpiSubjectAccountId, - tx.toBpiSubjectAccountId, - JSON.stringify(errPayload), - tx.signature, - BpiMessageType.Err, - ); - - const initiatorChannel = - tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey; - await this.messagingAgent.publishMessage( - initiatorChannel, - JSON.stringify(errorBpiMessage), - ); - } - } -} diff --git a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts index 0ccfe5b80..64ffe95ec 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts @@ -3,17 +3,13 @@ import { ICommand, ofType, Saga } from '@nestjs/cqrs'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { WorkstepExecutionFailuresEvent } from '../handleWorkstepFailuresEvents/workstepExecutionFailures.event'; -import { HandleWorkstepFailuresCommand } from '../handleWorkstepFailures/handleWorkstepFailures.command'; @Injectable() export class VsmFailureSagas { @Saga() handleWorkstepFailures = (events$: Observable): Observable => { return events$.pipe( - ofType(WorkstepExecutionFailuresEvent), - map((event) => { - return new HandleWorkstepFailuresCommand(event.id); - }), + ofType(WorkstepExecutionFailuresEvent) ); }; } diff --git a/examples/bri-3/src/bri/vsm/vsm.module.ts b/examples/bri-3/src/bri/vsm/vsm.module.ts index 973aff309..2975160ea 100644 --- a/examples/bri-3/src/bri/vsm/vsm.module.ts +++ b/examples/bri-3/src/bri/vsm/vsm.module.ts @@ -8,12 +8,10 @@ import { VsmTasksSchedulerAgent } from './agents/vsmTaskScheduler.agent'; import { ExecuteVsmCycleCommandHandler } from './capabilites/executeVsmCycle/executeVsmCycleCommand.handler'; import { MessagingAgent } from '../communication/agents/messaging.agent'; import { WorkstepExecutionFailuresHandler } from './capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler'; -import { HandleWorkstepFailuresCommandHandler } from './capabilites/handleWorkstepFailures/handleWorkstepFailuresCommand.handler'; import { VsmFailureSagas } from './capabilites/sagas/vsmFailures.sagas'; export const CommandHandlers = [ ExecuteVsmCycleCommandHandler, - HandleWorkstepFailuresCommandHandler, WorkstepExecutionFailuresHandler, ]; From 02763726c7640d42779083bb897167813fe1ef47 Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Mon, 21 Aug 2023 04:13:45 -0400 Subject: [PATCH 05/13] clean code and format --- .../executeVsmCycleCommand.handler.ts | 16 ++++++++-------- .../workstepExecutionFailures.event.ts | 2 -- .../workstepExecutionFailures.handler.ts | 2 +- .../vsm/capabilites/sagas/vsmFailures.sagas.ts | 1 - 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts index fdf954369..256ab3a91 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts @@ -31,13 +31,13 @@ export class ExecuteVsmCycleCommandHandler if (!this.agent.validateTransactionForExecution(tx)) { this.eventBus.publish( new WorkstepExecutionFailuresEvent( - tx.id, - 'Validation Error', + tx.id, + 'Validation Error', tx.fromBpiSubjectAccountId, tx.toBpiSubjectAccountId, tx.signature, - tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey - ) + tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey, + ), ); tx.updateStatusToAborted(); this.txStorageAgent.updateTransactionStatus(tx); @@ -57,13 +57,13 @@ export class ExecuteVsmCycleCommandHandler } catch (error) { this.eventBus.publish( new WorkstepExecutionFailuresEvent( - tx.id, - error, + tx.id, + error, tx.fromBpiSubjectAccountId, tx.toBpiSubjectAccountId, tx.signature, - tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey - ) + tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey, + ), ); tx.updateStatusToAborted(); this.txStorageAgent.updateTransactionStatus(tx); diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts index 2aab05ea3..2c4d8fd52 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts @@ -1,5 +1,3 @@ -import { BpiSubjectAccount } from "@prisma/client"; - export class WorkstepExecutionFailuresEvent { constructor( public readonly id: string, diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts index fb95dff55..221a1cd35 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts @@ -13,7 +13,7 @@ export class WorkstepExecutionFailuresHandler constructor( private readonly logger: LoggingService, private readonly messagingAgent: MessagingAgent, - ) {} + ) {} handle(event: WorkstepExecutionFailuresEvent) { this.logger.logError( diff --git a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts index 64ffe95ec..c98b7b30e 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts @@ -1,7 +1,6 @@ import { Injectable } from '@nestjs/common'; import { ICommand, ofType, Saga } from '@nestjs/cqrs'; import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; import { WorkstepExecutionFailuresEvent } from '../handleWorkstepFailuresEvents/workstepExecutionFailures.event'; @Injectable() From 9876598e078f5634450110a1c186512c29cd0d9d Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Mon, 21 Aug 2023 04:43:28 -0400 Subject: [PATCH 06/13] fix vsm module --- .../workstepExecutionFailures.event.ts | 6 +++--- .../bri/vsm/capabilites/sagas/vsmFailures.sagas.ts | 4 +--- examples/bri-3/src/bri/vsm/vsm.module.ts | 11 ++++++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts index 2c4d8fd52..9efca610b 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts @@ -1,10 +1,10 @@ export class WorkstepExecutionFailuresEvent { constructor( - public readonly id: string, + public readonly id: string, public readonly err: string, public readonly fromBpiSubjectAccountId: string, public readonly toBpiSubjectAccountId: string, public readonly signature: string, - public readonly initiatorChannel: string - ) {} + public readonly initiatorChannel: string, + ) {} } diff --git a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts index c98b7b30e..8dcdf5876 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts @@ -7,8 +7,6 @@ import { WorkstepExecutionFailuresEvent } from '../handleWorkstepFailuresEvents/ export class VsmFailureSagas { @Saga() handleWorkstepFailures = (events$: Observable): Observable => { - return events$.pipe( - ofType(WorkstepExecutionFailuresEvent) - ); + return events$.pipe(ofType(WorkstepExecutionFailuresEvent)); }; } diff --git a/examples/bri-3/src/bri/vsm/vsm.module.ts b/examples/bri-3/src/bri/vsm/vsm.module.ts index 2975160ea..7d6b66851 100644 --- a/examples/bri-3/src/bri/vsm/vsm.module.ts +++ b/examples/bri-3/src/bri/vsm/vsm.module.ts @@ -9,6 +9,7 @@ import { ExecuteVsmCycleCommandHandler } from './capabilites/executeVsmCycle/exe import { MessagingAgent } from '../communication/agents/messaging.agent'; import { WorkstepExecutionFailuresHandler } from './capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler'; import { VsmFailureSagas } from './capabilites/sagas/vsmFailures.sagas'; +import { NatsMessagingClient } from '../communication/messagingClients/natsMessagingClient'; export const CommandHandlers = [ ExecuteVsmCycleCommandHandler, @@ -24,9 +25,17 @@ export const QueryHandlers = []; TransactionModule, LoggingModule, WorkstepModule, + ], + providers: [ + VsmTasksSchedulerAgent, + ...CommandHandlers, + ...QueryHandlers, MessagingAgent, VsmFailureSagas, + { + provide: 'IMessagingClient', + useClass: NatsMessagingClient, + }, ], - providers: [VsmTasksSchedulerAgent, ...CommandHandlers, ...QueryHandlers], }) export class VsmModule {} From a2967dde60195c0d0ad982d60a30db9be518bc89 Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Tue, 22 Aug 2023 14:53:43 -0400 Subject: [PATCH 07/13] Pass tx as a parameter --- .../executeVsmCycleCommand.handler.ts | 12 ++---------- .../workstepExecutionFailures.event.ts | 8 +++----- .../workstepExecutionFailures.handler.ts | 12 ++++++------ 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts index 0607e7f59..05bed2e78 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts @@ -31,12 +31,8 @@ export class ExecuteVsmCycleCommandHandler if (!this.agent.validateTransactionForExecution(tx)) { this.eventBus.publish( new WorkstepExecutionFailuresEvent( - tx.id, + tx, 'Validation Error', - tx.fromBpiSubjectAccountId, - tx.toBpiSubjectAccountId, - tx.signature, - tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey, ), ); tx.updateStatusToAborted(); @@ -57,12 +53,8 @@ export class ExecuteVsmCycleCommandHandler } catch (error) { this.eventBus.publish( new WorkstepExecutionFailuresEvent( - tx.id, + tx, error, - tx.fromBpiSubjectAccountId, - tx.toBpiSubjectAccountId, - tx.signature, - tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey, ), ); tx.updateStatusToAborted(); diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts index 9efca610b..99548e118 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts @@ -1,10 +1,8 @@ +import { Transaction } from "src/bri/transactions/models/transaction"; + export class WorkstepExecutionFailuresEvent { constructor( - public readonly id: string, + public readonly tx: Transaction, public readonly err: string, - public readonly fromBpiSubjectAccountId: string, - public readonly toBpiSubjectAccountId: string, - public readonly signature: string, - public readonly initiatorChannel: string, ) {} } diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts index 221a1cd35..b52fd41e5 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts @@ -17,7 +17,7 @@ export class WorkstepExecutionFailuresHandler handle(event: WorkstepExecutionFailuresEvent) { this.logger.logError( - `Invalid transaction for execution with id ${event.id}: ${event.err}`, + `Invalid transaction for execution with id ${event.tx.id}: ${event.err}`, ); const errPayload = { @@ -26,16 +26,16 @@ export class WorkstepExecutionFailuresHandler }; const errorBpiMessage = new BpiMessage( - event.id, - event.fromBpiSubjectAccountId, - event.toBpiSubjectAccountId, + event.tx.id, + event.tx.fromBpiSubjectAccountId, + event.tx.toBpiSubjectAccountId, JSON.stringify(errPayload), - event.signature, + event.tx.signature, BpiMessageType.Err, ); this.messagingAgent.publishMessage( - event.initiatorChannel, + event.tx.fromBpiSubjectAccount.ownerBpiSubject.publicKey, JSON.stringify(errorBpiMessage), ); } From e95cdc54b8d543489fed4eea066607445ea4ffed Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Tue, 22 Aug 2023 14:55:17 -0400 Subject: [PATCH 08/13] Modify the error message --- .../workstepExecutionFailures.handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts index b52fd41e5..f6be762d7 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts @@ -17,7 +17,7 @@ export class WorkstepExecutionFailuresHandler handle(event: WorkstepExecutionFailuresEvent) { this.logger.logError( - `Invalid transaction for execution with id ${event.tx.id}: ${event.err}`, + `Failed execution of transaction with id ${event.tx.id}. Error: ${event.err}`, ); const errPayload = { From d602b6d19397b151d316f6e9707bcc049aedc695 Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Tue, 22 Aug 2023 15:15:34 -0400 Subject: [PATCH 09/13] Make error message consistent --- .../workstepExecutionFailures.handler.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts index f6be762d7..c830f880e 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts @@ -16,13 +16,15 @@ export class WorkstepExecutionFailuresHandler ) {} handle(event: WorkstepExecutionFailuresEvent) { + const message = `Failed execution of transaction with id ${event.tx.id}. Error: ${event.err}` + this.logger.logError( - `Failed execution of transaction with id ${event.tx.id}. Error: ${event.err}`, + message, ); const errPayload = { - errorCode: 'xxx', - errorMessage: 'Execution fails', + errorId: 'xxx', + errorMessage: message, }; const errorBpiMessage = new BpiMessage( From b862fa95fa9487ca9ce09707d6713437f8148b8f Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Tue, 22 Aug 2023 15:18:31 -0400 Subject: [PATCH 10/13] Remove saga --- .../bri/vsm/capabilites/sagas/vsmFailures.sagas.ts | 12 ------------ examples/bri-3/src/bri/vsm/vsm.module.ts | 2 -- 2 files changed, 14 deletions(-) delete mode 100644 examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts diff --git a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts b/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts deleted file mode 100644 index 8dcdf5876..000000000 --- a/examples/bri-3/src/bri/vsm/capabilites/sagas/vsmFailures.sagas.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { ICommand, ofType, Saga } from '@nestjs/cqrs'; -import { Observable } from 'rxjs'; -import { WorkstepExecutionFailuresEvent } from '../handleWorkstepFailuresEvents/workstepExecutionFailures.event'; - -@Injectable() -export class VsmFailureSagas { - @Saga() - handleWorkstepFailures = (events$: Observable): Observable => { - return events$.pipe(ofType(WorkstepExecutionFailuresEvent)); - }; -} diff --git a/examples/bri-3/src/bri/vsm/vsm.module.ts b/examples/bri-3/src/bri/vsm/vsm.module.ts index 7d6b66851..58cca58aa 100644 --- a/examples/bri-3/src/bri/vsm/vsm.module.ts +++ b/examples/bri-3/src/bri/vsm/vsm.module.ts @@ -8,7 +8,6 @@ import { VsmTasksSchedulerAgent } from './agents/vsmTaskScheduler.agent'; import { ExecuteVsmCycleCommandHandler } from './capabilites/executeVsmCycle/executeVsmCycleCommand.handler'; import { MessagingAgent } from '../communication/agents/messaging.agent'; import { WorkstepExecutionFailuresHandler } from './capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler'; -import { VsmFailureSagas } from './capabilites/sagas/vsmFailures.sagas'; import { NatsMessagingClient } from '../communication/messagingClients/natsMessagingClient'; export const CommandHandlers = [ @@ -31,7 +30,6 @@ export const QueryHandlers = []; ...CommandHandlers, ...QueryHandlers, MessagingAgent, - VsmFailureSagas, { provide: 'IMessagingClient', useClass: NatsMessagingClient, From 46714acbbb2934624c38f46e408d7e1c4f146e32 Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Tue, 22 Aug 2023 15:34:51 -0400 Subject: [PATCH 11/13] Run format --- .../executeVsmCycleCommand.handler.ts | 12 ++---------- .../workstepExecutionFailures.event.ts | 7 ++----- .../workstepExecutionFailures.handler.ts | 6 ++---- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts index 05bed2e78..f525b36e0 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts @@ -30,10 +30,7 @@ export class ExecuteVsmCycleCommandHandler if (!this.agent.validateTransactionForExecution(tx)) { this.eventBus.publish( - new WorkstepExecutionFailuresEvent( - tx, - 'Validation Error', - ), + new WorkstepExecutionFailuresEvent(tx, 'Validation Error'), ); tx.updateStatusToAborted(); this.txStorageAgent.updateTransactionStatus(tx); @@ -51,12 +48,7 @@ export class ExecuteVsmCycleCommandHandler tx.updateStatusToExecuted(); this.txStorageAgent.updateTransactionStatus(tx); } catch (error) { - this.eventBus.publish( - new WorkstepExecutionFailuresEvent( - tx, - error, - ), - ); + this.eventBus.publish(new WorkstepExecutionFailuresEvent(tx, error)); tx.updateStatusToAborted(); this.txStorageAgent.updateTransactionStatus(tx); return; diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts index 99548e118..ef3d01d25 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.event.ts @@ -1,8 +1,5 @@ -import { Transaction } from "src/bri/transactions/models/transaction"; +import { Transaction } from 'src/bri/transactions/models/transaction'; export class WorkstepExecutionFailuresEvent { - constructor( - public readonly tx: Transaction, - public readonly err: string, - ) {} + constructor(public readonly tx: Transaction, public readonly err: string) {} } diff --git a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts index c830f880e..02f97c436 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/handleWorkstepFailuresEvents/workstepExecutionFailures.handler.ts @@ -16,11 +16,9 @@ export class WorkstepExecutionFailuresHandler ) {} handle(event: WorkstepExecutionFailuresEvent) { - const message = `Failed execution of transaction with id ${event.tx.id}. Error: ${event.err}` + const message = `Failed execution of transaction with id ${event.tx.id}. Error: ${event.err}`; - this.logger.logError( - message, - ); + this.logger.logError(message); const errPayload = { errorId: 'xxx', From 67bf1a172fe5372db109bdf65c2b47280423a44e Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Tue, 22 Aug 2023 18:14:42 -0400 Subject: [PATCH 12/13] Fix mistake on updateStatus --- .../executeVsmCycle/executeVsmCycleCommand.handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts index f525b36e0..41a1901f2 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts @@ -32,7 +32,7 @@ export class ExecuteVsmCycleCommandHandler this.eventBus.publish( new WorkstepExecutionFailuresEvent(tx, 'Validation Error'), ); - tx.updateStatusToAborted(); + tx.updateStatusToInvalid(); this.txStorageAgent.updateTransactionStatus(tx); return; } From 21dd22fa804294f078a533bd58f66efb203143ac Mon Sep 17 00:00:00 2001 From: Siyuan Fan Date: Tue, 22 Aug 2023 18:22:17 -0400 Subject: [PATCH 13/13] Restore original code in executeVsmCycleCommand --- .../executeVsmCycle/executeVsmCycleCommand.handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts index 41a1901f2..ffed4bc52 100644 --- a/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts +++ b/examples/bri-3/src/bri/vsm/capabilites/executeVsmCycle/executeVsmCycleCommand.handler.ts @@ -33,7 +33,7 @@ export class ExecuteVsmCycleCommandHandler new WorkstepExecutionFailuresEvent(tx, 'Validation Error'), ); tx.updateStatusToInvalid(); - this.txStorageAgent.updateTransactionStatus(tx); + await this.txStorageAgent.updateTransactionStatus(tx); return; }