@@ -204,6 +204,7 @@ proc installEthApiHandlers*(vp: VerifiedRpcProxy) =
204
204
await vp.rpcClient.eth_getTransactionByHash(txHash)
205
205
except CatchableError as e:
206
206
raise newException(ValueError, e.msg)
207
+
207
208
if tx.hash != txHash:
208
209
raise newException(
209
210
ValueError,
@@ -238,10 +239,93 @@ proc installEthApiHandlers*(vp: VerifiedRpcProxy) =
238
239
raise newException(ValueError, " receipt couldn't be verified" )
239
240
240
241
vp.proxy.rpc(" eth_getLogs" ) do (filterOptions: FilterOptions) -> seq [LogObject]:
241
- (await vp.getLogs(filterOptions)).valueOr:
242
+ let
243
+ logObjs =
244
+ try :
245
+ await vp.rpcClient.eth_getLogs(filterOptions)
246
+ except CatchableError as e:
247
+ raise newException(ValueError, e.msg)
248
+
249
+ boundsCheck = verifyFilterBoundaries(filterOptions, logObjs).valueOr:
250
+ raise newException(ValueError, error)
251
+
252
+ if not boundsCheck:
253
+ raise newException(ValueError, " Logs out of filter block range" )
254
+
255
+ let verifiedLogs = (await vp.verifyLogs(logObjs)).valueOr:
256
+ raise newException(ValueError, error)
257
+
258
+ return verifiedLogs
259
+
260
+ vp.proxy.rpc(" eth_newFilter" ) do (filterOptions: FilterOptions) -> int :
261
+ let
262
+ hexId =
263
+ try :
264
+ await vp.rpcClient.eth_newFilter(filterOptions)
265
+ except CatchableError as e:
266
+ raise newException(ValueError, e.msg)
267
+ id = fromHex[int ](hexId)
268
+
269
+ vp.filterStore[id] = filterOptions
270
+ return id
271
+
272
+ vp.proxy.rpc(" eth_uninstallFilter" ) do (filterId: int ) -> bool :
273
+ let status =
274
+ try :
275
+ await vp.rpcClient.eth_uninstallFilter(" 0x" & toHex(filterId))
276
+ except CatchableError as e:
277
+ raise newException(ValueError, e.msg)
278
+
279
+ if status and filterId in vp.filterStore:
280
+ vp.filterStore.del(filterId)
281
+
282
+ return status
283
+
284
+ vp.proxy.rpc(" eth_getFilterLogs" ) do (filterId: int ) -> seq [LogObject]:
285
+ if filterId notin vp.filterStore:
286
+ raise newException(ValueError, " Filter doesn't exist" )
287
+
288
+ let
289
+ logObjs =
290
+ try :
291
+ # use locally stored filter and get logs
292
+ await vp.rpcClient.eth_getLogs(vp.filterStore[filterId])
293
+ except CatchableError as e:
294
+ raise newException(ValueError, e.msg)
295
+
296
+ boundsCheck = verifyFilterBoundaries(vp.filterStore[filterId], logObjs) .valueOr:
297
+ raise newException(ValueError, error)
298
+
299
+ if not boundsCheck:
300
+ raise newException(ValueError, " Logs out of filter block range" )
301
+
302
+ let verifiedLogs = (await vp.verifyLogs(logObjs)).valueOr:
242
303
raise newException(ValueError, error)
243
304
244
- # TODO :
305
+ return verifiedLogs
306
+
307
+ vp.proxy.rpc(" eth_getFilterChanges" ) do (filterId: int ) -> seq [LogObject]:
308
+ if filterId notin vp.filterStore:
309
+ raise newException(ValueError, " Filter doesn't exist" )
310
+
311
+ let
312
+ logObjs =
313
+ try :
314
+ await vp.rpcClient.eth_getFilterChanges(" 0x" & toHex(filterId))
315
+ except CatchableError as e:
316
+ raise newException(ValueError, e.msg)
317
+
318
+ boundsCheck = verifyFilterBoundaries(vp.filterStore[filterId], logObjs) .valueOr:
319
+ raise newException(ValueError, error)
320
+
321
+ if not boundsCheck:
322
+ raise newException(ValueError, " Logs out of filter block range" )
323
+
324
+ let verifiedLogs = (await vp.verifyLogs(logObjs)).valueOr:
325
+ raise newException(ValueError, error)
326
+
327
+ return verifiedLogs
328
+
245
329
# Following methods are forwarded directly to the web3 provider and therefore
246
330
# are not validated in any way.
247
331
vp.proxy.registerProxyMethod(" net_version" )
0 commit comments