{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Network.Ethereum.Contract where
import Data.Proxy (Proxy)
import Data.Text (Text)
import Data.ByteArray.HexString (HexString)
import Data.Solidity.Prim.Address (Address)
import Network.Ethereum.Account.Class (Account)
import Network.Ethereum.Account.Safe (safeConfirmations, safeSend)
import Network.Ethereum.Api.Types (receiptContractAddress)
import Network.Ethereum.Contract.Method (Method)
import Network.JsonRpc.TinyClient (JsonRpc)
class Contract a where
abi :: Proxy a -> Text
bytecode :: Proxy a -> HexString
new :: (Account p t, JsonRpc m, Method a, Monad (t m))
=> a
-> t m (Maybe Address)
new = fmap receiptContractAddress . safeSend safeConfirmations