@@ -92,13 +92,22 @@ export const handleChannels = async (
9292 const transactionID = transaction [ transactionType ] . GrpHdr . MsgId ;
9393
9494 const spanTransactionHistory = apm . startSpan ( 'db.get.transactionCfg' ) ;
95- const transactionConfiguration = ( await databaseManager . getTransactionConfig ( ) ) as unknown [ ] ;
96- spanTransactionHistory ?. end ( ) ;
9795
98- const transactionConfigMessages = transactionConfiguration [ 0 ] as TransactionConfiguration [ ] ;
99- const requiredConfigMessage = transactionConfigMessages
100- . find ( ( tc ) => tc . messages . find ( ( msg ) => msg . id === message . id && msg . cfg === message . cfg && msg . txTp === transaction . TxTp ) )
101- ?. messages . find ( ( msg ) => msg . id === message . id && msg . cfg === message . cfg && msg . txTp === transaction . TxTp ) ;
96+ if ( ! networkMap . messages [ 0 ] ?. id || ! networkMap . messages [ 0 ] ?. cfg ) {
97+ loggerService . error ( `Network map is missing configured messages.` ) ;
98+ throw new Error ( 'Network map is missing configured messages.' ) ;
99+ }
100+
101+ const transactionConfiguration = ( await databaseManager . getTransactionConfig (
102+ networkMap . messages [ 0 ] ?. id ,
103+ networkMap . messages [ 0 ] ?. cfg ,
104+ ) ) as unknown [ ] [ ] ;
105+
106+ if ( ! transactionConfiguration ?. [ 0 ] ?. [ 0 ] ) {
107+ loggerService . error ( `Transaction Configuration could not be retrieved` ) ;
108+ throw new Error ( 'Transaction Configuration could not be retrieved' ) ;
109+ }
110+ spanTransactionHistory ?. end ( ) ;
102111
103112 // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
104113 const cacheKey = `tadp_${ transactionID } _${ message . id } _${ message . cfg } ` ;
@@ -124,22 +133,23 @@ export const handleChannels = async (
124133 }
125134
126135 let review = false ;
127- if ( requiredConfigMessage )
128- for ( const configuredChannel of requiredConfigMessage . channels ) {
129- if ( configuredChannel ) {
130- const channelRes = channelResults . find ( ( c ) => c . id === configuredChannel . id && c . cfg === configuredChannel . cfg ) ;
131- for ( const typology of configuredChannel . typologies ) {
132- const typologyResult = channelRes ?. typologyResult . find ( ( t ) => t . id === typology . id && t . cfg === typology . cfg ) ;
133- if ( ! typologyResult ) continue ;
134-
135- if ( typologyResult . result >= typology . threshold ) {
136- review = true ;
137- typologyResult . review = true ;
138- }
139- typologyResult . threshold = typology . threshold ;
136+
137+ const currentConfiguration = transactionConfiguration [ 0 ] [ 0 ] as TransactionConfiguration ;
138+ for ( const configuredChannel of currentConfiguration . channels ) {
139+ if ( configuredChannel ) {
140+ const channelRes = channelResults . find ( ( c ) => c . id === configuredChannel . id && c . cfg === configuredChannel . cfg ) ;
141+ for ( const typology of configuredChannel . typologies ) {
142+ const typologyResult = channelRes ?. typologyResult . find ( ( t ) => t . id === typology . id && t . cfg === typology . cfg ) ;
143+ if ( ! typologyResult ) continue ;
144+
145+ if ( typologyResult . result >= typology . threshold ) {
146+ review = true ;
147+ typologyResult . review = true ;
140148 }
149+ typologyResult . threshold = typology . threshold ;
141150 }
142151 }
152+ }
143153
144154 let reviewMessage : string ;
145155 if ( review ) {
0 commit comments