module Network.Ethereum.Web3.Provider where
import Control.Concurrent (ThreadId, forkIO)
import Control.Exception (try)
import Control.Monad.IO.Class (MonadIO (..))
import Network.Ethereum.Web3.Types
class Provider a where
rpcUri :: Web3 a String
data DefaultProvider
instance Provider DefaultProvider where
rpcUri = return "http://localhost:8545"
runWeb3' :: MonadIO m => Web3 a b -> m (Either Web3Error b)
runWeb3' = liftIO . try . unWeb3
runWeb3 :: MonadIO m => Web3 DefaultProvider b -> m (Either Web3Error b)
runWeb3 = runWeb3'
forkWeb3 :: Web3 a () -> Web3 a ThreadId
forkWeb3 = Web3 . forkIO . unWeb3