ethio: handles a result member in an error response
When using a Ganache for running a local Ethereum node, an error RPC
response can contain a 'result' member with the hash of the transaction,
even though that goes against the JSON-RPC spec
++ parse-one-response
|= =json
^- (unit response:rpc)
+ ?. &(?=([%o *] json) (~(has by p.json) 'error'))
=/ res=(unit [@t ^json])
%. json
=, dejs-soft:format
(ot id+so result+some ~)
- ?^ res `[%result u.res]
+ ?~ res ~
+ `[%result u.res]
~| parse-one-response=json
- :+ ~ %error %- need
+ =/ error=(unit [id=@t ^json code=@ta mssg=@t])
%. json
=, dejs-soft:format
- (ot id+so error+(ot code+no message+so ~) ~)
+ :: A 'result' member is present in the error
+ :: response when using ganache, even though
+ :: that goes against the JSON-RPC spec
+ ::
+ (ot id+so result+some error+(ot code+no message+so ~) ~)
+ ?~ error ~
+ =* err u.error
+ `[%error id.err code.err mssg.err]
--
::
:: +read-contract: calls a read function on a contract, produces result hex
