f-o-a-m / purescript-web3

a purescript library for the web3 api
Apache License 2.0
127 stars 24 forks source link

Handling the RPC requests with odd results #26

Closed XertroV closed 6 years ago

XertroV commented 6 years ago

I'm working on trying to implement the eth_getSyncing RPC call currently.

Having some ~trouble~ fun trying to figure out how to handle the response.

Return value:

Object|Boolean - A sync object as follows, when the node is currently syncing or false:
  * startingBlock: Number - The block number where the sync started.
  * currentBlock: Number - The block number where at which block the node currently synced to already.
  * highestBlock: Number - The estimated block number to sync to.

Currently I don't think I can do it just with unsafeCoerceWeb3 and remote, since JSON decoding is done deeper than that and I can't pass in a custom decoder.

Going to keep playing with it, though any pointers would be greatly appreciated. I don't think any methods currently implemented handle these sorts of cases.

Will paste up code or a PR if I solve the issue. Preferably I don't want to resort to the FFI and Web3.js.

Current plan is for eth_getSyncing to return a Maybe { startingBlock :: Int, currentBlock :: Int, highestBlock :: Int }

XertroV commented 6 years ago

Note: have implemented this based on the NullOrUndefined implementation.