Commit 0b05930
authored
use contract api as a fallback for decoding if signature based fails (#170)
### TL;DR
Improved transaction and log decoding logic by adding fallback mechanisms and validation checks.
### What changed?
- Extracted decoding logic into separate functions `decodeLogsIfNeeded` and `decodeTransactionsIfNeeded`
- Added validation to check if ABI decoding was successful by verifying name and signature fields
- Implemented fallback to contract service decoding when ABI decoding fails
- Simplified the main handler logic by consolidating decoding paths
### How to test?
1. Test log decoding with valid ABI:
- Send request with `decode=true` and valid event ABI
- Verify logs are decoded correctly
2. Test transaction decoding with invalid ABI:
- Send request with `decode=true` and invalid function ABI
- Verify fallback to contract service decoding
3. Test with decoding disabled:
- Send request with `decode=false`
- Verify raw logs/transactions are returned
### Why make this change?
The previous implementation didn't handle ABI decoding failures gracefully. This change ensures more reliable decoding by validating the results and falling back to the contract service when needed, improving the overall robustness of the API.File tree
2 files changed
+53
-26
lines changed- internal/handlers
2 files changed
+53
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
189 | 185 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 186 | + | |
196 | 187 | | |
| 188 | + | |
197 | 189 | | |
198 | 190 | | |
199 | 191 | | |
200 | 192 | | |
201 | 193 | | |
202 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
203 | 217 | | |
204 | 218 | | |
205 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
182 | 178 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 179 | + | |
189 | 180 | | |
190 | 181 | | |
191 | 182 | | |
192 | 183 | | |
193 | 184 | | |
194 | 185 | | |
195 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
196 | 209 | | |
197 | 210 | | |
198 | 211 | | |
| |||
0 commit comments