{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
module Network.Ethereum.Web3.Eth where
import Data.Text (Text)
import Network.Ethereum.ABI.Prim.Address (Address)
import Network.Ethereum.ABI.Prim.Bytes (Bytes, BytesN)
import Network.Ethereum.Web3.Provider (Web3)
import Network.Ethereum.Web3.Types (Block, Call, Change,
DefaultBlock, Filter, Hash,
Quantity, SyncingState,
Transaction, TxReceipt)
import Network.JsonRpc.TinyClient (remote)
protocolVersion :: Web3 Text
{-# INLINE protocolVersion #-}
protocolVersion = remote "eth_protocolVersion"
syncing :: Web3 SyncingState
{-# INLINE syncing #-}
syncing = remote "eth_syncing"
coinbase :: Web3 Address
{-# INLINE coinbase #-}
coinbase = remote "eth_coinbase"
mining :: Web3 Bool
{-# INLINE mining #-}
mining = remote "eth_mining"
hashrate :: Web3 Quantity
{-# INLINE hashrate #-}
hashrate = remote "eth_hashrate"
getStorageAt :: Address -> Quantity -> DefaultBlock -> Web3 (BytesN 32)
{-# INLINE getStorageAt #-}
getStorageAt = remote "eth_getStorageAt"
getTransactionCount :: Address -> DefaultBlock -> Web3 Quantity
{-# INLINE getTransactionCount #-}
getTransactionCount = remote "eth_getTransactionCount"
getBlockTransactionCountByHash :: Hash -> Web3 Quantity
{-# INLINE getBlockTransactionCountByHash #-}
getBlockTransactionCountByHash = remote "eth_getBlockTransactionCountByHash"
getBlockTransactionCountByNumber :: Quantity -> Web3 Quantity
{-# INLINE getBlockTransactionCountByNumber #-}
getBlockTransactionCountByNumber = remote "eth_getBlockTransactionCountByNumber"
getUncleCountByBlockHash :: Hash -> Web3 Quantity
{-# INLINE getUncleCountByBlockHash #-}
getUncleCountByBlockHash = remote "eth_getUncleCountByBlockHash"
getUncleCountByBlockNumber :: Quantity -> Web3 Quantity
{-# INLINE getUncleCountByBlockNumber #-}
getUncleCountByBlockNumber = remote "eth_getUncleCountByBlockNumber"
getCode :: Address -> DefaultBlock -> Web3 Bytes
{-# INLINE getCode #-}
getCode = remote "eth_getCode"
sign :: Address -> Bytes -> Web3 Bytes
{-# INLINE sign #-}
sign = remote "eth_sign"
sendTransaction :: Call -> Web3 Hash
{-# INLINE sendTransaction #-}
sendTransaction = remote "eth_sendTransaction"
sendRawTransaction :: Bytes -> Web3 Hash
{-# INLINE sendRawTransaction #-}
sendRawTransaction = remote "eth_sendRawTransaction"
getBalance :: Address -> DefaultBlock -> Web3 Quantity
{-# INLINE getBalance #-}
getBalance = remote "eth_getBalance"
newFilter :: Filter e -> Web3 Quantity
{-# INLINE newFilter #-}
newFilter = remote "eth_newFilter"
getFilterChanges :: Quantity -> Web3 [Change]
{-# INLINE getFilterChanges #-}
getFilterChanges = remote "eth_getFilterChanges"
uninstallFilter :: Quantity -> Web3 Bool
{-# INLINE uninstallFilter #-}
uninstallFilter = remote "eth_uninstallFilter"
getLogs :: Filter e -> Web3 [Change]
{-# INLINE getLogs #-}
getLogs = remote "eth_getLogs"
call :: Call -> DefaultBlock -> Web3 Bytes
{-# INLINE call #-}
call = remote "eth_call"
estimateGas :: Call -> Web3 Quantity
{-# INLINE estimateGas #-}
estimateGas = remote "eth_estimateGas"
getBlockByHash :: Hash -> Web3 Block
{-# INLINE getBlockByHash #-}
getBlockByHash = flip (remote "eth_getBlockByHash") True
getBlockByNumber :: Quantity -> Web3 Block
{-# INLINE getBlockByNumber #-}
getBlockByNumber = flip (remote "eth_getBlockByNumber") True
getTransactionByHash :: Hash -> Web3 (Maybe Transaction)
{-# INLINE getTransactionByHash #-}
getTransactionByHash = remote "eth_getTransactionByHash"
getTransactionByBlockHashAndIndex :: Hash -> Quantity -> Web3 (Maybe Transaction)
{-# INLINE getTransactionByBlockHashAndIndex #-}
getTransactionByBlockHashAndIndex = remote "eth_getTransactionByBlockHashAndIndex"
getTransactionByBlockNumberAndIndex :: DefaultBlock -> Quantity -> Web3 (Maybe Transaction)
{-# INLINE getTransactionByBlockNumberAndIndex #-}
getTransactionByBlockNumberAndIndex = remote "eth_getTransactionByBlockNumberAndIndex"
getTransactionReceipt :: Hash -> Web3 (Maybe TxReceipt)
{-# INLINE getTransactionReceipt #-}
getTransactionReceipt = remote "eth_getTransactionReceipt"
accounts :: Web3 [Address]
{-# INLINE accounts #-}
accounts = remote "eth_accounts"
newBlockFilter :: Web3 Quantity
{-# INLINE newBlockFilter #-}
newBlockFilter = remote "eth_newBlockFilter"
getBlockFilterChanges :: Quantity -> Web3 [Hash]
{-# INLINE getBlockFilterChanges #-}
getBlockFilterChanges = remote "eth_getFilterChanges"
blockNumber :: Web3 Quantity
{-# INLINE blockNumber #-}
blockNumber = remote "eth_blockNumber"
gasPrice :: Web3 Quantity
{-# INLINE gasPrice #-}
gasPrice = remote "eth_gasPrice"
getUncleByBlockHashAndIndex :: Hash -> Quantity -> Web3 Block
{-# INLINE getUncleByBlockHashAndIndex #-}
getUncleByBlockHashAndIndex = remote "eth_getUncleByBlockHashAndIndex"
getUncleByBlockNumberAndIndex :: DefaultBlock -> Quantity -> Web3 Block
{-# INLINE getUncleByBlockNumberAndIndex #-}
getUncleByBlockNumberAndIndex = remote "eth_getUncleByBlockNumberAndIndex"
newPendingTransactionFilter :: Web3 Quantity
{-# INLINE newPendingTransactionFilter #-}
newPendingTransactionFilter = remote "eth_newPendingTransactionFilter"
getFilterLogs :: Quantity -> Web3 [Change]
{-# INLINE getFilterLogs #-}
getFilterLogs = remote "eth_getFilterLogs"
getWork :: Web3 [Bytes]
{-# INLINE getWork #-}
getWork = remote "eth_getWork"
submitWork :: BytesN 8 -> BytesN 32 -> BytesN 32 -> Web3 Bool
{-# INLINE submitWork #-}
submitWork = remote "eth_submitWork"
submitHashrate :: BytesN 32 -> BytesN 32 -> Web3 Bool
{-# INLINE submitHashrate #-}
submitHashrate = remote "eth_submitHashrate"