@@ -198,28 +198,48 @@ export async function getTransactionLogs(fastify: FastifyInstance) {
198
198
) ;
199
199
}
200
200
201
- const contract = getContract ( {
202
- address : transactionReceipt . to ,
203
- chain,
204
- client : thirdwebClient ,
205
- } ) ;
201
+ const contracts = new Set < string > ( ) ;
202
+ contracts . add ( transactionReceipt . to ) ;
203
+ for ( const log of transactionReceipt . logs ) {
204
+ if ( log . address ) {
205
+ contracts . add ( log . address ) ;
206
+ }
207
+ }
206
208
207
- const abi : AbiEvent . AbiEvent [ ] = await resolveContractAbi ( contract ) ;
208
- const eventSignatures = abi . filter ( ( item ) => item . type === "event" ) ;
209
- if ( eventSignatures . length === 0 ) {
209
+ const eventSignaturePromises = Array . from ( contracts ) . map (
210
+ async ( address ) => {
211
+ const contract = getContract ( {
212
+ address,
213
+ chain,
214
+ client : thirdwebClient ,
215
+ } ) ;
216
+
217
+ const abi : AbiEvent . AbiEvent [ ] = await resolveContractAbi ( contract ) ;
218
+ const eventSignatures = abi . filter ( ( item ) => item . type === "event" ) ;
219
+ return eventSignatures ;
220
+ } ,
221
+ ) ;
222
+
223
+ const combinedEventSignatures : AbiEvent . AbiEvent [ ] = (
224
+ await Promise . all ( eventSignaturePromises )
225
+ ) . flat ( ) ;
226
+
227
+ if ( combinedEventSignatures . length === 0 ) {
210
228
throw createCustomError (
211
229
"No events found in contract or could not resolve contract ABI" ,
212
230
StatusCodes . BAD_REQUEST ,
213
231
"NO_EVENTS_FOUND" ,
214
232
) ;
215
233
}
216
234
217
- const preparedEvents = eventSignatures . map ( ( signature ) =>
235
+ const preparedEvents = combinedEventSignatures . map ( ( signature ) =>
218
236
prepareEvent ( { signature } ) ,
219
237
) ;
238
+
220
239
const parsedLogs = parseEventLogs ( {
221
240
events : preparedEvents ,
222
241
logs : transactionReceipt . logs ,
242
+ strict : false ,
223
243
} ) ;
224
244
225
245
reply . status ( StatusCodes . OK ) . send ( {
0 commit comments