@@ -167,30 +167,36 @@ export class GoldRushDecoder {
167
167
) => {
168
168
const covalent_client = new CovalentClient ( covalent_api_key ) ;
169
169
const events : EventType [ ] = [ ] ;
170
- const logs = ( tx . log_events ?? [ ] ) . reverse ( ) ;
171
170
if ( tx . value ) {
172
171
const nativeEvent = this . native_decoder ( tx ) ;
173
172
events . push ( nativeEvent ) ;
174
173
}
175
- for ( const log of logs ) {
176
- const {
177
- raw_log_topics : [ topic0_hash ] ,
178
- sender_address : contract_address ,
179
- // !ERROR: add factory_contract_address in the log_event(s)
180
- // factory_contract_address,
181
- } = log ;
182
- const decoding_index =
183
- // !ERROR: add factory_contract_address in the log_event(s)
184
- // factory_contract_address ||
185
- this . decoders [ chain_name ] ?. [ contract_address ] ?. [ topic0_hash ] ;
186
- const fallback_index = this . fallbacks [ topic0_hash ] ;
187
- if ( decoding_index !== undefined || fallback_index !== undefined ) {
188
- const logEvent = await this . decoding_functions [
189
- decoding_index ?? fallback_index
190
- ] ( log , tx , chain_name , covalent_client ) ;
191
- events . push ( logEvent ) ;
192
- }
193
- }
194
- return events ;
174
+ const decodedEvents = await Promise . all (
175
+ ( tx . log_events ?? [ ] ) . map ( ( log ) => {
176
+ const {
177
+ raw_log_topics : [ topic0_hash ] ,
178
+ sender_address : contract_address ,
179
+ // !ERROR: add factory_contract_address in the log_event(s)
180
+ // factory_contract_address,
181
+ } = log ;
182
+ const decoding_index =
183
+ // !ERROR: add factory_contract_address in the log_event(s)
184
+ // factory_contract_address ||
185
+ this . decoders [ chain_name ] ?. [ contract_address ] ?. [
186
+ topic0_hash
187
+ ] ;
188
+ const fallback_index = this . fallbacks [ topic0_hash ] ;
189
+ if (
190
+ decoding_index !== undefined ||
191
+ fallback_index !== undefined
192
+ ) {
193
+ return this . decoding_functions [
194
+ decoding_index ?? fallback_index
195
+ ] ( log , tx , chain_name , covalent_client ) ;
196
+ }
197
+ return null ;
198
+ } )
199
+ ) ;
200
+ return events . concat ( decodedEvents . filter ( Boolean ) as EventType [ ] ) ;
195
201
} ;
196
202
}
0 commit comments