From 7e74cd3bb714d47fc8df5238066dcba547ce9395 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 18 Apr 2018 00:29:25 +0200 Subject: [PATCH] Update parsing of event logs to assume up-to-date RPC API spec. --- lib/ethereum.hoon | 24 +++++++++++++----------- sur/ethereum.hoon | 4 +++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/ethereum.hoon b/lib/ethereum.hoon index 75e1838d90..e2ba0fcee4 100644 --- a/lib/ethereum.hoon +++ b/lib/ethereum.hoon @@ -146,21 +146,23 @@ ?> ?=(%s -.j) (hex-to-num p.j) :: -++ parse-eth-get-filter-changes-res +++ parse-event-logs + (ar:dejs:format parse-event-log) +:: +++ parse-event-log =, dejs:format - |= j=json - =- ((ar -) j) - |= cha=json - ^- filter-change - =- ((ot -) cha) - :~ =- [type+(cu - so)] - |= m=@t - ?. =(m 'mined') ~ - =- `((ot -) cha) ::TODO not sure if elegant or hacky. + |= log=json + ^- event-log + =- ((ot -) log) + :~ =- ['logIndex'^(cu - (mu so))] + |= li=(unit @t) + ?~ li ~ + =- `((ot -) log) ::TODO not sure if elegant or hacky. :~ 'logIndex'^(cu hex-to-num so) 'transactionIndex'^(cu hex-to-num so) - 'blockHash'^(cu hex-to-num so) + 'transactionHash'^(cu hex-to-num so) 'blockNumber'^(cu hex-to-num so) + 'blockHash'^(cu hex-to-num so) == :: address+(cu hex-to-num so) diff --git a/sur/ethereum.hoon b/sur/ethereum.hoon index eed89da96a..35fcd40292 100644 --- a/sur/ethereum.hoon +++ b/sur/ethereum.hoon @@ -48,12 +48,14 @@ == :: ++ filter-change +++ event-log $: :: null for pending logs $= mined %- unit $: log-index=@ud transaction-index=@ud - block-hash=@ux + transaction-hash=@ux block-number=@ud + block-hash=@ux == :: address=@ux