@@ -158,43 +158,46 @@ export class GoldRushDecoder {
158
158
) => {
159
159
const covalent_client = new CovalentClient ( covalent_api_key ) ;
160
160
const events : EventType [ ] = [ ] ;
161
- const logs = ( tx . log_events ?? [ ] ) . reverse ( ) ;
162
161
if ( tx . value ) {
163
162
const nativeEvent = this . native_decoder ( tx ) ;
164
163
events . push ( nativeEvent ) ;
165
164
}
166
- for ( const log of logs ) {
167
- const {
168
- raw_log_topics : [ topic0_hash ] ,
169
- sender_address,
170
- sender_factory_address,
171
- } = log ;
172
- const decoding_index =
173
- this . decoders [ chain_name ] ?. [ sender_address ] ?. [ topic0_hash ] ??
174
- this . decoders [ chain_name ] ?. [ sender_factory_address ] ?. [
175
- topic0_hash
176
- ] ;
177
- const fallback_index = this . fallbacks [ topic0_hash ] ;
178
- let logEvent : EventType | null = null ;
179
- if ( decoding_index !== undefined ) {
180
- logEvent = await this . decoding_functions [ decoding_index ] (
181
- log ,
182
- tx ,
183
- chain_name ,
184
- covalent_client
185
- ) ;
186
- } else if ( fallback_index !== undefined ) {
187
- logEvent = await this . fallback_functions [ fallback_index ] (
188
- log ,
189
- tx ,
190
- chain_name ,
191
- covalent_client
192
- ) ;
193
- }
194
- if ( logEvent ) {
195
- events . push ( logEvent ) ;
196
- }
197
- }
198
- return events ;
165
+
166
+ const decodedEvents = await Promise . all (
167
+ ( tx . log_events ?? [ ] ) . map ( ( log ) => {
168
+ const {
169
+ raw_log_topics : [ topic0_hash ] ,
170
+ sender_address,
171
+ sender_factory_address,
172
+ } = log ;
173
+ const decoding_index =
174
+ this . decoders [ chain_name ] ?. [ sender_address ] ?. [
175
+ topic0_hash
176
+ ] ??
177
+ this . decoders [ chain_name ] ?. [ sender_factory_address ] ?. [
178
+ topic0_hash
179
+ ] ;
180
+ const fallback_index = this . fallbacks [ topic0_hash ] ;
181
+
182
+ if ( decoding_index !== undefined ) {
183
+ return this . decoding_functions [ decoding_index ] (
184
+ log ,
185
+ tx ,
186
+ chain_name ,
187
+ covalent_client
188
+ ) ;
189
+ } else if ( fallback_index !== undefined ) {
190
+ return this . fallback_functions [ fallback_index ] (
191
+ log ,
192
+ tx ,
193
+ chain_name ,
194
+ covalent_client
195
+ ) ;
196
+ }
197
+ return null ;
198
+ } )
199
+ ) ;
200
+
201
+ return events . concat ( decodedEvents . filter ( Boolean ) as EventType [ ] ) ;
199
202
} ;
200
203
}
0 commit comments