Skip to content

Commit

Permalink
WIP EthRpcAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
larskuhtz committed Nov 20, 2024
1 parent 684d231 commit 2d728bd
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/Chainweb/PayloadProvider/EVM/EthRpcAPI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@
module Chainweb.PayloadProvider.EVM.EthRpcAPI
( mkRpcCtx
) where

import Chainweb.PayloadProvider.EVM.Header
import Chainweb.PayloadProvider.EVM.JsonRPC
import Chainweb.PayloadProvider.EVM.Utils
import Ethereum.Misc
import Data.Void

import Network.HTTP.Client qualified as HTTP
import Network.URI.Static (uri)
import Control.Applicative

import Ethereum.Header
import GHC.Generics
import Data.Aeson
import Control.Applicative
import Data.ByteString qualified as B
import Data.Void

import Ethereum.Misc
import Ethereum.Transaction (Transaction)
import Ethereum.Utils
import qualified Data.ByteString as B

import GHC.Generics

import Network.HTTP.Client qualified as HTTP
import Network.URI.Static (uri)

-- -------------------------------------------------------------------------- --
-- Errors
Expand Down Expand Up @@ -63,15 +67,15 @@ instance JsonRpcMethod "eth_chainId" where
--
instance JsonRpcMethod "eth_getBlockByNumber" where
type MethodRequest "eth_getBlockByNumber" = (DefaultBlockParameter, Bool)
type MethodResponse "eth_getBlockByNumber" = Maybe ConsensusHeader
type MethodResponse "eth_getBlockByNumber" = Maybe Header
type ServerErrors "eth_getBlockByNumber" = Int
type ApplicationErrors "eth_getBlockByNumber" = Int
responseTimeoutMs = Nothing
methodErrors = []

instance JsonRpcMethod "eth_getBlockByHash" where
type MethodRequest "eth_getBlockByHash" = (BlockHash, Bool)
type MethodResponse "eth_getBlockByHash" = Maybe ConsensusHeader
type MethodResponse "eth_getBlockByHash" = Maybe Header
type ServerErrors "eth_getBlockByHash" = Int
type ApplicationErrors "eth_getBlockByHash" = Int
responseTimeoutMs = Nothing
Expand Down Expand Up @@ -118,7 +122,7 @@ instance ToJSON SyncingStatus where
instance FromJSON SyncingStatus where
parseJSON v = notSyncing v <|> syncStatus v
where
notSyncing = withBool "SyncingStatus" $ \b -> if b
notSyncing = withBool "SyncingStatus" $ \b -> if not b
then return SyncingStatusFalse
else fail "expected 'false' or object"
syncStatus = withObject "SyncingStatus" $ \o -> SyncingStatus
Expand Down

0 comments on commit 2d728bd

Please sign in to comment.