{-# 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 :: a -> t m (Maybe Address)
new = (TxReceipt -> Maybe Address)
-> t m TxReceipt -> t m (Maybe Address)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TxReceipt -> Maybe Address
receiptContractAddress (t m TxReceipt -> t m (Maybe Address))
-> (a -> t m TxReceipt) -> a -> t m (Maybe Address)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> a -> t m TxReceipt
forall p (t :: (* -> *) -> * -> *) (m :: * -> *) args.
(Account p t, JsonRpc m, Method args, Monad (t m)) =>
Integer -> args -> t m TxReceipt
safeSend Integer
safeConfirmations