@@ -237,6 +237,7 @@ proc installEthApiHandlers*(vp: VerifiedRpcProxy) =
237
237
await vp.rpcClient.eth_getTransactionByHash(txHash)
238
238
except CatchableError as e:
239
239
raise newException(ValueError, e.msg)
240
+
240
241
if tx.hash != txHash:
241
242
raise newException(
242
243
ValueError,
@@ -271,10 +272,93 @@ proc installEthApiHandlers*(vp: VerifiedRpcProxy) =
271
272
raise newException(ValueError, " receipt couldn't be verified" )
272
273
273
274
vp.proxy.rpc(" eth_getLogs" ) do (filterOptions: FilterOptions) -> seq [LogObject]:
274
- (await vp.getLogs(filterOptions)).valueOr:
275
+ let
276
+ logObjs =
277
+ try :
278
+ await vp.rpcClient.eth_getLogs(filterOptions)
279
+ except CatchableError as e:
280
+ raise newException(ValueError, e.msg)
281
+
282
+ boundsCheck = verifyFilterBoundaries(filterOptions, logObjs).valueOr:
283
+ raise newException(ValueError, error)
284
+
285
+ if not boundsCheck:
286
+ raise newException(ValueError, " Logs out of filter block range" )
287
+
288
+ let verifiedLogs = (await vp.verifyLogs(logObjs)).valueOr:
289
+ raise newException(ValueError, error)
290
+
291
+ return verifiedLogs
292
+
293
+ vp.proxy.rpc(" eth_newFilter" ) do (filterOptions: FilterOptions) -> int :
294
+ let
295
+ hexId =
296
+ try :
297
+ await vp.rpcClient.eth_newFilter(filterOptions)
298
+ except CatchableError as e:
299
+ raise newException(ValueError, e.msg)
300
+ id = fromHex[int ](hexId)
301
+
302
+ vp.filterStore[id] = filterOptions
303
+ return id
304
+
305
+ vp.proxy.rpc(" eth_uninstallFilter" ) do (filterId: int ) -> bool :
306
+ let status =
307
+ try :
308
+ await vp.rpcClient.eth_uninstallFilter(" 0x" & toHex(filterId))
309
+ except CatchableError as e:
310
+ raise newException(ValueError, e.msg)
311
+
312
+ if status and filterId in vp.filterStore:
313
+ vp.filterStore.del(filterId)
314
+
315
+ return status
316
+
317
+ vp.proxy.rpc(" eth_getFilterLogs" ) do (filterId: int ) -> seq [LogObject]:
318
+ if filterId notin vp.filterStore:
319
+ raise newException(ValueError, " Filter doesn't exist" )
320
+
321
+ let
322
+ logObjs =
323
+ try :
324
+ # use locally stored filter and get logs
325
+ await vp.rpcClient.eth_getLogs(vp.filterStore[filterId])
326
+ except CatchableError as e:
327
+ raise newException(ValueError, e.msg)
328
+
329
+ boundsCheck = verifyFilterBoundaries(vp.filterStore[filterId], logObjs) .valueOr:
330
+ raise newException(ValueError, error)
331
+
332
+ if not boundsCheck:
333
+ raise newException(ValueError, " Logs out of filter block range" )
334
+
335
+ let verifiedLogs = (await vp.verifyLogs(logObjs)).valueOr:
275
336
raise newException(ValueError, error)
276
337
277
- # TODO :
338
+ return verifiedLogs
339
+
340
+ vp.proxy.rpc(" eth_getFilterChanges" ) do (filterId: int ) -> seq [LogObject]:
341
+ if filterId notin vp.filterStore:
342
+ raise newException(ValueError, " Filter doesn't exist" )
343
+
344
+ let
345
+ logObjs =
346
+ try :
347
+ await vp.rpcClient.eth_getFilterChanges(" 0x" & toHex(filterId))
348
+ except CatchableError as e:
349
+ raise newException(ValueError, e.msg)
350
+
351
+ boundsCheck = verifyFilterBoundaries(vp.filterStore[filterId], logObjs) .valueOr:
352
+ raise newException(ValueError, error)
353
+
354
+ if not boundsCheck:
355
+ raise newException(ValueError, " Logs out of filter block range" )
356
+
357
+ let verifiedLogs = (await vp.verifyLogs(logObjs)).valueOr:
358
+ raise newException(ValueError, error)
359
+
360
+ return verifiedLogs
361
+
278
362
# Following methods are forwarded directly to the web3 provider and therefore
279
363
# are not validated in any way.
280
364
vp.proxy.registerProxyMethod(" net_version" )
0 commit comments