(res: hypersync_client::QueryResponse)
| 227 | } |
| 228 | |
| 229 | pub fn convert_response(res: hypersync_client::QueryResponse) -> Result<QueryResponse> { |
| 230 | let blocks = res |
| 231 | .data |
| 232 | .blocks |
| 233 | .iter() |
| 234 | .flat_map(|b| b.iter().map(Block::from)) |
| 235 | .collect::<Vec<_>>(); |
| 236 | |
| 237 | let transactions = res |
| 238 | .data |
| 239 | .transactions |
| 240 | .iter() |
| 241 | .flat_map(|b| b.iter().map(Transaction::from)) |
| 242 | .collect::<Vec<_>>(); |
| 243 | |
| 244 | let logs = res |
| 245 | .data |
| 246 | .logs |
| 247 | .iter() |
| 248 | .flat_map(|b| b.iter().map(Log::from)) |
| 249 | .collect::<Vec<_>>(); |
| 250 | |
| 251 | let traces = res |
| 252 | .data |
| 253 | .traces |
| 254 | .iter() |
| 255 | .flat_map(|b| b.iter().map(Trace::from)) |
| 256 | .collect::<Vec<_>>(); |
| 257 | |
| 258 | Ok(QueryResponse { |
| 259 | archive_height: res |
| 260 | .archive_height |
| 261 | .map(|h| h.try_into()) |
| 262 | .transpose() |
| 263 | .context("convert height")?, |
| 264 | next_block: res.next_block.try_into().context("convert next_block")?, |
| 265 | total_execution_time: res |
| 266 | .total_execution_time |
| 267 | .try_into() |
| 268 | .context("convert total_execution_time")?, |
| 269 | data: QueryResponseData { |
| 270 | blocks, |
| 271 | transactions, |
| 272 | logs, |
| 273 | traces, |
| 274 | }, |
| 275 | rollback_guard: res |
| 276 | .rollback_guard |
| 277 | .map(RollbackGuard::try_convert) |
| 278 | .transpose() |
| 279 | .context("convert rollback guard")?, |
| 280 | }) |
| 281 | } |
| 282 | |
| 283 | pub fn convert_event_response(resp: hypersync_client::EventResponse) -> Result<EventResponse> { |
| 284 | let data = resp |
no outgoing calls
no test coverage detected