web3-ethereum 1.0.0.0 → 1.0.1.0
raw patch · 27 files changed
+190/−103 lines, 27 filesdep +aeson-casingdep ~OneTupledep ~aesondep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: aeson-casing
Dependency ranges changed: OneTuple, aeson, base, bytestring, hspec, hspec-discover, memory, microlens-aeson, mtl, template-haskell, text, transformers, vinyl
API changes (from Hackage documentation)
+ Network.Ethereum.Account: timeout :: Lens' (CallParam p) (Maybe Int)
+ Network.Ethereum.Account.Internal: [_timeout] :: CallParam p -> Maybe Int
+ Network.Ethereum.Account.Internal: getReceipt' :: JsonRpc m => HexString -> m TxReceipt
+ Network.Ethereum.Account.Internal: timeout :: Lens' (CallParam p) (Maybe Int)
+ Network.Ethereum.Ens.PublicResolver: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.PublicResolver.ABIChanged
+ Network.Ethereum.Ens.PublicResolver: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.PublicResolver.AddrChanged
+ Network.Ethereum.Ens.PublicResolver: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.PublicResolver.ContentChanged
+ Network.Ethereum.Ens.PublicResolver: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.PublicResolver.NameChanged
+ Network.Ethereum.Ens.PublicResolver: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.PublicResolver.PubkeyChanged
+ Network.Ethereum.Ens.Registry: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.Registry.NewOwner
+ Network.Ethereum.Ens.Registry: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.Registry.NewResolver
+ Network.Ethereum.Ens.Registry: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.Registry.NewTTL
+ Network.Ethereum.Ens.Registry: instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Ens.Registry.Transfer
- Network.Ethereum.Account: send :: (Account a t, JsonRpc m, Method args) => args -> t m TxReceipt
+ Network.Ethereum.Account: send :: (Account a t, JsonRpc m, Method args) => args -> t m (Either HexString TxReceipt)
- Network.Ethereum.Account.Class: send :: (Account a t, JsonRpc m, Method args) => args -> t m TxReceipt
+ Network.Ethereum.Account.Class: send :: (Account a t, JsonRpc m, Method args) => args -> t m (Either HexString TxReceipt)
- Network.Ethereum.Account.Internal: CallParam :: Maybe Address -> Integer -> Maybe Integer -> Maybe Integer -> DefaultBlock -> p -> CallParam p
+ Network.Ethereum.Account.Internal: CallParam :: Maybe Address -> Integer -> Maybe Integer -> Maybe Integer -> DefaultBlock -> p -> Maybe Int -> CallParam p
- Network.Ethereum.Account.Internal: getReceipt :: JsonRpc m => HexString -> m TxReceipt
+ Network.Ethereum.Account.Internal: getReceipt :: JsonRpc m => Maybe Int -> HexString -> m (Either HexString TxReceipt)
- Network.Ethereum.Account.Safe: safeSend :: (Account p t, JsonRpc m, Method args, Monad (t m)) => Integer -> args -> t m TxReceipt
+ Network.Ethereum.Account.Safe: safeSend :: (Account p t, JsonRpc m, Method args, Monad (t m)) => Integer -> args -> t m (Either HexString TxReceipt)
- Network.Ethereum.Contract: new :: (Account p t, JsonRpc m, Method a, Monad (t m)) => a -> t m (Maybe Address)
+ Network.Ethereum.Contract: new :: (Account p t, JsonRpc m, Method a, Monad (t m)) => a -> t m (Either HexString (Maybe Address))
- Network.Ethereum.Contract.Event.MultiFilter: [:&] :: forall u (a :: u -> Type) (r :: u) (rs :: [u]). !a r -> !Rec a rs -> Rec a (r : rs)
+ Network.Ethereum.Contract.Event.MultiFilter: [:&] :: forall {u} (a :: u -> Type) (r :: u) (rs :: [u]). !a r -> !Rec a rs -> Rec a (r ': rs)
- Network.Ethereum.Contract.Event.MultiFilter: [:?] :: Filter e -> MultiFilter es -> MultiFilter (e : es)
+ Network.Ethereum.Contract.Event.MultiFilter: [:?] :: Filter e -> MultiFilter es -> MultiFilter (e ': es)
- Network.Ethereum.Contract.Event.MultiFilter: [RNil] :: forall u (a :: u -> Type). Rec a ('[] :: [u])
+ Network.Ethereum.Contract.Event.MultiFilter: [RNil] :: forall {u} (a :: u -> Type). Rec a ('[] :: [u])
- Network.Ethereum.Contract.Event.MultiFilter: data Rec (a :: u -> Type) (b :: [u])
+ Network.Ethereum.Contract.Event.MultiFilter: data () => Rec (a :: u -> Type) (b :: [u])
- Network.Ethereum.Contract.Event.MultiFilter: newtype Handler b a
+ Network.Ethereum.Contract.Event.MultiFilter: newtype () => Handler b a
- Network.Ethereum.Ens.PublicResolver: aBI :: (JsonRpc m_a14cR, Account a_a14cP t_a14cQ, Functor (t_a14cQ m_a14cR)) => BytesN 32 -> UIntN 256 -> t_a14cQ m_a14cR (UIntN 256, Bytes)
+ Network.Ethereum.Ens.PublicResolver: aBI :: (JsonRpc m_aYjF, Account a_aYjD t_aYjE, Functor (t_aYjE m_aYjF)) => BytesN 32 -> UIntN 256 -> t_aYjE m_aYjF (UIntN 256, Bytes)
- Network.Ethereum.Ens.PublicResolver: addr :: (JsonRpc m_a14cV, Account a_a14cT t_a14cU, Functor (t_a14cU m_a14cV)) => BytesN 32 -> t_a14cU m_a14cV Address
+ Network.Ethereum.Ens.PublicResolver: addr :: (JsonRpc m_aYjJ, Account a_aYjH t_aYjI, Functor (t_aYjI m_aYjJ)) => BytesN 32 -> t_aYjI m_aYjJ Address
- Network.Ethereum.Ens.PublicResolver: content :: (JsonRpc m_a14cZ, Account a_a14cX t_a14cY, Functor (t_a14cY m_a14cZ)) => BytesN 32 -> t_a14cY m_a14cZ (BytesN 32)
+ Network.Ethereum.Ens.PublicResolver: content :: (JsonRpc m_aYjN, Account a_aYjL t_aYjM, Functor (t_aYjM m_aYjN)) => BytesN 32 -> t_aYjM m_aYjN (BytesN 32)
- Network.Ethereum.Ens.PublicResolver: name :: (JsonRpc m_a14d3, Account a_a14d1 t_a14d2, Functor (t_a14d2 m_a14d3)) => BytesN 32 -> t_a14d2 m_a14d3 Text
+ Network.Ethereum.Ens.PublicResolver: name :: (JsonRpc m_aYjR, Account a_aYjP t_aYjQ, Functor (t_aYjQ m_aYjR)) => BytesN 32 -> t_aYjQ m_aYjR Text
- Network.Ethereum.Ens.PublicResolver: pubkey :: (JsonRpc m_a14d7, Account a_a14d5 t_a14d6, Functor (t_a14d6 m_a14d7)) => BytesN 32 -> t_a14d6 m_a14d7 (BytesN 32, BytesN 32)
+ Network.Ethereum.Ens.PublicResolver: pubkey :: (JsonRpc m_aYjV, Account a_aYjT t_aYjU, Functor (t_aYjU m_aYjV)) => BytesN 32 -> t_aYjU m_aYjV (BytesN 32, BytesN 32)
- Network.Ethereum.Ens.PublicResolver: setABI :: (JsonRpc m_a14dd, Account a_a14db t_a14dc, Functor (t_a14dc m_a14dd)) => BytesN 32 -> UIntN 256 -> Bytes -> t_a14dc m_a14dd TxReceipt
+ Network.Ethereum.Ens.PublicResolver: setABI :: (JsonRpc m_aYk1, Account a_aYjZ t_aYk0, Functor (t_aYk0 m_aYk1)) => BytesN 32 -> UIntN 256 -> Bytes -> t_aYk0 m_aYk1 (Either HexString TxReceipt)
- Network.Ethereum.Ens.PublicResolver: setAddr :: (JsonRpc m_a14di, Account a_a14dg t_a14dh, Functor (t_a14dh m_a14di)) => BytesN 32 -> Address -> t_a14dh m_a14di TxReceipt
+ Network.Ethereum.Ens.PublicResolver: setAddr :: (JsonRpc m_aYk6, Account a_aYk4 t_aYk5, Functor (t_aYk5 m_aYk6)) => BytesN 32 -> Address -> t_aYk5 m_aYk6 (Either HexString TxReceipt)
- Network.Ethereum.Ens.PublicResolver: setContent :: (JsonRpc m_a14dn, Account a_a14dl t_a14dm, Functor (t_a14dm m_a14dn)) => BytesN 32 -> BytesN 32 -> t_a14dm m_a14dn TxReceipt
+ Network.Ethereum.Ens.PublicResolver: setContent :: (JsonRpc m_aYkb, Account a_aYk9 t_aYka, Functor (t_aYka m_aYkb)) => BytesN 32 -> BytesN 32 -> t_aYka m_aYkb (Either HexString TxReceipt)
- Network.Ethereum.Ens.PublicResolver: setName :: (JsonRpc m_a14ds, Account a_a14dq t_a14dr, Functor (t_a14dr m_a14ds)) => BytesN 32 -> Text -> t_a14dr m_a14ds TxReceipt
+ Network.Ethereum.Ens.PublicResolver: setName :: (JsonRpc m_aYkg, Account a_aYke t_aYkf, Functor (t_aYkf m_aYkg)) => BytesN 32 -> Text -> t_aYkf m_aYkg (Either HexString TxReceipt)
- Network.Ethereum.Ens.PublicResolver: setPubkey :: (JsonRpc m_a14dy, Account a_a14dw t_a14dx, Functor (t_a14dx m_a14dy)) => BytesN 32 -> BytesN 32 -> BytesN 32 -> t_a14dx m_a14dy TxReceipt
+ Network.Ethereum.Ens.PublicResolver: setPubkey :: (JsonRpc m_aYkm, Account a_aYkk t_aYkl, Functor (t_aYkl m_aYkm)) => BytesN 32 -> BytesN 32 -> BytesN 32 -> t_aYkl m_aYkm (Either HexString TxReceipt)
- Network.Ethereum.Ens.PublicResolver: supportsInterface :: (JsonRpc m_a14dC, Account a_a14dA t_a14dB, Functor (t_a14dB m_a14dC)) => BytesN 4 -> t_a14dB m_a14dC Bool
+ Network.Ethereum.Ens.PublicResolver: supportsInterface :: (JsonRpc m_aYkq, Account a_aYko t_aYkp, Functor (t_aYkp m_aYkq)) => BytesN 4 -> t_aYkp m_aYkq Bool
- Network.Ethereum.Ens.Registry: owner :: (JsonRpc m_aRq9, Account a_aRq7 t_aRq8, Functor (t_aRq8 m_aRq9)) => BytesN 32 -> t_aRq8 m_aRq9 Address
+ Network.Ethereum.Ens.Registry: owner :: (JsonRpc m_aVlL, Account a_aVlJ t_aVlK, Functor (t_aVlK m_aVlL)) => BytesN 32 -> t_aVlK m_aVlL Address
- Network.Ethereum.Ens.Registry: resolver :: (JsonRpc m_aRqd, Account a_aRqb t_aRqc, Functor (t_aRqc m_aRqd)) => BytesN 32 -> t_aRqc m_aRqd Address
+ Network.Ethereum.Ens.Registry: resolver :: (JsonRpc m_aVlP, Account a_aVlN t_aVlO, Functor (t_aVlO m_aVlP)) => BytesN 32 -> t_aVlO m_aVlP Address
- Network.Ethereum.Ens.Registry: setOwner :: (JsonRpc m_aRqi, Account a_aRqg t_aRqh, Functor (t_aRqh m_aRqi)) => BytesN 32 -> Address -> t_aRqh m_aRqi TxReceipt
+ Network.Ethereum.Ens.Registry: setOwner :: (JsonRpc m_aVlU, Account a_aVlS t_aVlT, Functor (t_aVlT m_aVlU)) => BytesN 32 -> Address -> t_aVlT m_aVlU (Either HexString TxReceipt)
- Network.Ethereum.Ens.Registry: setResolver :: (JsonRpc m_aRqn, Account a_aRql t_aRqm, Functor (t_aRqm m_aRqn)) => BytesN 32 -> Address -> t_aRqm m_aRqn TxReceipt
+ Network.Ethereum.Ens.Registry: setResolver :: (JsonRpc m_aVlZ, Account a_aVlX t_aVlY, Functor (t_aVlY m_aVlZ)) => BytesN 32 -> Address -> t_aVlY m_aVlZ (Either HexString TxReceipt)
- Network.Ethereum.Ens.Registry: setSubnodeOwner :: (JsonRpc m_aRqt, Account a_aRqr t_aRqs, Functor (t_aRqs m_aRqt)) => BytesN 32 -> BytesN 32 -> Address -> t_aRqs m_aRqt TxReceipt
+ Network.Ethereum.Ens.Registry: setSubnodeOwner :: (JsonRpc m_aVm5, Account a_aVm3 t_aVm4, Functor (t_aVm4 m_aVm5)) => BytesN 32 -> BytesN 32 -> Address -> t_aVm4 m_aVm5 (Either HexString TxReceipt)
- Network.Ethereum.Ens.Registry: setTTL :: (JsonRpc m_aRqy, Account a_aRqw t_aRqx, Functor (t_aRqx m_aRqy)) => BytesN 32 -> UIntN 64 -> t_aRqx m_aRqy TxReceipt
+ Network.Ethereum.Ens.Registry: setTTL :: (JsonRpc m_aVma, Account a_aVm8 t_aVm9, Functor (t_aVm9 m_aVma)) => BytesN 32 -> UIntN 64 -> t_aVm9 m_aVma (Either HexString TxReceipt)
- Network.Ethereum.Ens.Registry: ttl :: (JsonRpc m_aRqC, Account a_aRqA t_aRqB, Functor (t_aRqB m_aRqC)) => BytesN 32 -> t_aRqB m_aRqC (UIntN 64)
+ Network.Ethereum.Ens.Registry: ttl :: (JsonRpc m_aVme, Account a_aVmc t_aVmd, Functor (t_aVmd m_aVme)) => BytesN 32 -> t_aVmd m_aVme (UIntN 64)
Files
- src/Network/Ethereum.hs +1/−1
- src/Network/Ethereum/Account.hs +6/−4
- src/Network/Ethereum/Account/Class.hs +4/−3
- src/Network/Ethereum/Account/Default.hs +3/−2
- src/Network/Ethereum/Account/Internal.hs +25/−9
- src/Network/Ethereum/Account/LocalKey.hs +2/−2
- src/Network/Ethereum/Account/Personal.hs +3/−3
- src/Network/Ethereum/Account/Safe.hs +10/−4
- src/Network/Ethereum/Api/Eth.hs +3/−2
- src/Network/Ethereum/Api/Net.hs +1/−1
- src/Network/Ethereum/Api/Types.hs +4/−3
- src/Network/Ethereum/Api/Web3.hs +1/−1
- src/Network/Ethereum/Chain.hs +1/−1
- src/Network/Ethereum/Contract.hs +10/−4
- src/Network/Ethereum/Contract/Event.hs +1/−1
- src/Network/Ethereum/Contract/Method.hs +1/−1
- src/Network/Ethereum/Contract/TH.hs +18/−8
- src/Network/Ethereum/Ens.hs +1/−1
- src/Network/Ethereum/Ens/PublicResolver.hs +1/−1
- src/Network/Ethereum/Ens/Registry.hs +1/−1
- src/Network/Ethereum/Transaction.hs +1/−1
- src/Network/Ethereum/Unit.hs +1/−1
- tests/Network/Ethereum/Test/EventSpec.hs +10/−0
- tests/Network/Ethereum/Test/MethodDumpSpec.hs +10/−0
- tests/Network/Ethereum/Test/THSpec.hs +12/−1
- tests/Network/Ethereum/Test/TransactionSpec.hs +11/−0
- web3-ethereum.cabal +48/−47
src/Network/Ethereum.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Network.Ethereum--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Account.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Network.Ethereum.Account--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -8,7 +8,8 @@ -- Portability : unportable -- -- In Etereun there are two types of accounts:--- * Externally owned account (EOAs): an account controlled by a private key, and if you own the private key associated with the EOA you have the ability to send ether and messages from it.+-- * Externally owned account (EOAs): an account controlled by a private key, and if you own+-- the private key associated with the EOA you have the ability to send ether and messages from it. -- * Contract: an account that has its own code, and is controlled by code. -- -- This module exports different kinds of EOAs: default, node managed and local. Node managed accounts@@ -40,14 +41,15 @@ , gasPrice , block , account+ , timeout ) where import Network.Ethereum.Account.Class (Account (..)) import Network.Ethereum.Account.Default (DefaultAccount) import Network.Ethereum.Account.Internal (account, block, gasLimit,- gasPrice, to, value,- withParam)+ gasPrice, timeout, to,+ value, withParam) import Network.Ethereum.Account.LocalKey (LocalKey (..), LocalKeyAccount) import Network.Ethereum.Account.Personal (Personal (..),
src/Network/Ethereum/Account/Class.hs view
@@ -3,7 +3,7 @@ -- | -- Module : Network.Ethereum.Account.Class--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -17,6 +17,7 @@ import Control.Monad.Trans (MonadTrans) +import Data.ByteArray.HexString (HexString) import Data.Solidity.Abi (AbiGet) import Network.Ethereum.Api.Types (TxReceipt) import Network.Ethereum.Contract.Method (Method)@@ -43,8 +44,8 @@ send :: (JsonRpc m, Method args) => args -- ^ Contract method arguments- -> t m TxReceipt- -- ^ Receipt of sended transaction+ -> t m (Either HexString TxReceipt)+ -- ^ Receipt of the sent transaction, or transaction hash in case of a timeout -- | Call constant method of contract, like a 'read' command call :: (JsonRpc m, Method args, AbiGet result)
src/Network/Ethereum/Account/Default.hs view
@@ -5,7 +5,7 @@ -- | -- Module : Network.Ethereum.Account.Default--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -45,6 +45,7 @@ send (args :: a) = do c <- getCall+ timeout <- _timeout <$> get lift $ do accounts <- Eth.accounts let dat = selector (Proxy :: Proxy a) <> encode args@@ -57,7 +58,7 @@ gasLimit <- Eth.estimateGas params return $ params { callGas = Just gasLimit } - getReceipt =<< Eth.sendTransaction params'+ getReceipt timeout =<< Eth.sendTransaction params' call (args :: a) = do c <- getCall
src/Network/Ethereum/Account/Internal.hs view
@@ -5,7 +5,7 @@ -- | -- Module : Network.Ethereum.Account.Internal--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -23,6 +23,7 @@ withStateT) import Control.Monad.Trans (MonadTrans (..)) import Data.Default (Default (..))+import Data.Either (fromRight) import Data.Maybe (fromMaybe) import Lens.Micro (Lens', lens) @@ -52,6 +53,8 @@ -- ^ Call block number , _account :: p -- ^ Account params to sign transaction+ , _timeout :: Maybe Int+ -- ^ Transaction timeout in microseconds } deriving Eq -- | Transaction recipient lens@@ -78,6 +81,10 @@ account :: Lens' (CallParam p) p account = lens _account $ \a b -> a { _account = b } +-- | Transaction timeout lens+timeout :: Lens' (CallParam p) (Maybe Int)+timeout = lens _timeout $ \a b -> a { _timeout = b }+ -- | Monad transformer for sending parametrized transactions from account newtype AccountT p m a = AccountT { runAccountT :: StateT (CallParam p) m a }@@ -104,7 +111,7 @@ defaultCallParam :: a -> CallParam a {-# INLINE defaultCallParam #-}-defaultCallParam = CallParam def 0 Nothing Nothing Latest+defaultCallParam acc = CallParam def 0 Nothing Nothing Latest acc Nothing getCall :: MonadState (CallParam p) m => m Call getCall = do@@ -115,16 +122,25 @@ , callGasPrice = fromInteger <$> _gasPrice } -getReceipt :: JsonRpc m => HexString -> m TxReceipt-getReceipt tx = do+getReceipt :: JsonRpc m => Maybe Int -> HexString -> m (Either HexString TxReceipt)+getReceipt mbtimeout tx = do mbreceipt <- Eth.getTransactionReceipt tx case mbreceipt of- Just receipt -> return receipt- Nothing -> do+ Just receipt -> return $ Right receipt+ Nothing -> case mbtimeout of+ Just us+ | us > 0 -> retry $ Just $ us - 100000+ | otherwise -> return $ Left tx+ Nothing -> retry Nothing+ where+ retry mbtimeout' = do liftIO $ threadDelay 100000- -- TODO: avoid inifinite loop- getReceipt tx+ getReceipt mbtimeout' tx +getReceipt' :: JsonRpc m => HexString -> m TxReceipt+getReceipt' = fmap (fromRight undefined) . getReceipt Nothing+ updateReceipt :: JsonRpc m => TxReceipt -> m TxReceipt {-# INLINE updateReceipt #-}-updateReceipt = getReceipt . receiptTransactionHash+-- No timeout, because we update the receipt of an already processed transaction.+updateReceipt = getReceipt' . receiptTransactionHash
src/Network/Ethereum/Account/LocalKey.hs view
@@ -5,7 +5,7 @@ -- | -- Module : Network.Ethereum.Account.LocalKey--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- Roy Blankman 2018 -- License : Apache-2.0 --@@ -82,7 +82,7 @@ let packer = encodeTransaction params' (localKeyChainId _account) signed = signTransaction packer (localKeyPrivate _account)- lift $ getReceipt =<< Eth.sendRawTransaction signed+ lift $ getReceipt _timeout =<< Eth.sendRawTransaction signed call (args :: a) = do CallParam{..} <- get
src/Network/Ethereum/Account/Personal.hs view
@@ -6,7 +6,7 @@ -- | -- Module : Network.Ethereum.Account.Personal--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -70,12 +70,12 @@ gasLimit <- Eth.estimateGas params return $ params { callGas = Just gasLimit } - getReceipt =<< Personal.sendTransaction params' (personalPassphrase _account)+ getReceipt _timeout =<< Personal.sendTransaction params' (personalPassphrase _account) call (args :: a) = do s <- get case s of- CallParam _ _ _ _ block (Personal address _) -> do+ CallParam _ _ _ _ block (Personal address _) _ -> do c <- getCall let dat = selector (Proxy :: Proxy a) <> encode args params = c { callFrom = Just address, callData = Just $ BA.convert dat }
src/Network/Ethereum/Account/Safe.hs view
@@ -2,7 +2,7 @@ -- | -- Module : Network.Ethereum.Account.Safe--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -17,6 +17,7 @@ import Control.Concurrent (threadDelay) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans (lift)+import Data.ByteArray.HexString (HexString) import Network.Ethereum.Account.Class (Account (send)) import Network.Ethereum.Account.Internal (updateReceipt)@@ -32,10 +33,15 @@ -- ^ Confirmation in blocks -> args -- ^ Contract method arguments- -> t m TxReceipt- -- ^ Receipt of sended transaction-safeSend b a = lift . waiting =<< send a+ -> t m (Either HexString TxReceipt)+ -- ^ Receipt of the sent transaction, or transaction data in case of a timeout+safeSend b a = lift . withReceipt waiting =<< send a where+ withReceipt f receiptOrTx =+ case receiptOrTx of+ Left tx -> return $ Left tx+ Right receipt -> Right <$> f receipt+ waiting receipt = case receiptBlockNumber receipt of Nothing -> do
src/Network/Ethereum/Api/Eth.hs view
@@ -3,7 +3,7 @@ -- | -- Module : Network.Ethereum.Web3.Eth--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -20,7 +20,8 @@ import Data.Text (Text) import Network.Ethereum.Api.Types (Block, BlockT, Call, Change, DefaultBlock, Filter, Quantity,- SyncingState, Transaction, TxReceipt)+ SyncingState, Transaction,+ TxReceipt) import Network.JsonRpc.TinyClient (JsonRpc (..)) -- | Returns the current ethereum protocol version.
src/Network/Ethereum/Api/Net.hs view
@@ -3,7 +3,7 @@ -- | -- Module : Network.Ethereum.Api.Net--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Api/Types.hs view
@@ -6,7 +6,7 @@ -- | -- Module : Network.Ethereum.Api.Types--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -18,7 +18,8 @@ module Network.Ethereum.Api.Types where -import Data.Aeson (FromJSON (..), Options (fieldLabelModifier, omitNothingFields),+import Data.Aeson (FromJSON (..),+ Options (fieldLabelModifier, omitNothingFields), ToJSON (..), Value (Bool, String), defaultOptions, object, (.=)) import Data.Aeson.TH (deriveJSON)@@ -32,7 +33,7 @@ import qualified Data.Text.Lazy.Builder.Int as B (hexadecimal) import qualified Data.Text.Read as R (decimal, hexadecimal) import GHC.Generics (Generic)-import Lens.Micro (over, _head)+import Lens.Micro (_head, over) -- | Should be viewed as type to representing QUANTITY in Web3 JSON RPC docs --
src/Network/Ethereum/Api/Web3.hs view
@@ -3,7 +3,7 @@ -- | -- Module : Network.Ethereum.Api.Web3--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Chain.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Network.Ethereum.Chain--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Contract.hs view
@@ -5,7 +5,7 @@ -- | -- Module : Network.Ethereum.Contract--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -43,6 +43,12 @@ new :: (Account p t, JsonRpc m, Method a, Monad (t m)) => a -- ^ Contract constructor- -> t m (Maybe Address)- -- ^ Address of deployed contract when transaction success-new = fmap receiptContractAddress . safeSend safeConfirmations+ -> t m (Either HexString (Maybe Address))+ -- ^ Address of deployed contract when transaction success;+ -- transaction hash in case of a timeout+new = fmap (mapRight receiptContractAddress) . safeSend safeConfirmations+ where+ mapRight f e =+ case e of+ Left x -> Left x+ Right y -> Right $ f y
src/Network/Ethereum/Contract/Event.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Network.Ethereum.Contract.Event--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Contract/Method.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Network.Ethereum.Contract.Method--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Contract/TH.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE BangPatterns #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}@@ -6,7 +7,7 @@ -- | -- Module : Network.Ethereum.Contract.TH--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me@@ -45,8 +46,10 @@ import Control.Applicative ((<|>)) import Control.Monad (replicateM, (<=<))-import qualified Data.Aeson as Aeson (encode)+import qualified Data.Aeson as Aeson+import Data.Aeson.Casing (aesonDrop, camelCase) import Data.ByteArray (convert)+import Data.ByteArray.HexString (HexString) import Data.Char (toLower, toUpper) import qualified Data.Char as Char import Data.Default (Default (..))@@ -61,8 +64,8 @@ import qualified GHC.Generics as GHC (Generic) import Language.Haskell.TH import Language.Haskell.TH.Quote-import Lens.Micro (over, (^?), _head)-import Lens.Micro.Aeson (key, _JSON, _String)+import Lens.Micro (_head, over, (^?))+import Lens.Micro.Aeson (_JSON, _String, key) import Data.Solidity.Abi (AbiGet, AbiPut, AbiType (..)) import Data.Solidity.Event (IndexedEvent (..))@@ -72,8 +75,7 @@ Declaration (..), EventArg (..), FunctionArg (..),- SolidityType (..),- eventId,+ SolidityType (..), eventId, methodId, parseSolidityEventArgType, parseSolidityFunctionArgType)@@ -175,11 +177,12 @@ Just [x] -> [t|$t $m $(typeFuncQ x)|] Just xs -> let outs = fmap typeFuncQ xs in [t|$t $m $(foldl appT (tupleT (length xs)) outs)|]+ receiptT = [t|$t $m (Either HexString TxReceipt)|] sequence [ sigD name $ [t| (JsonRpc $m, Account $a $t, Functor ($t $m)) =>- $(arrowing $ inputT ++ [if c then outputT else [t|$t $m TxReceipt|]])+ $(arrowing $ inputT ++ [if c then outputT else receiptT]) |] , if c then funD' name (varP <$> vars) $ case result of@@ -205,6 +208,7 @@ , instanceD' nonIndexedName (conT ''AbiGet) [] , dataD' allName (recC allName (map (\(n, a) -> (\(b,t) -> return (n,b,t)) <=< toBang <=< typeEventQ $ a) allArgs)) derivingD , instanceD' allName (conT ''Generic) []+ , instanceD' allName (conT ''Aeson.ToJSON) [funD' 'Aeson.toJSON [] [| Aeson.genericToJSON $ aesonDrop nameL (init' . camelCase) |] ] , instanceD (cxt []) (pure $ ConT ''IndexedEvent `AppT` ConT indexedName `AppT` ConT nonIndexedName `AppT` ConT allName) [funD' 'isAnonymous [] [|const anonymous|]]@@ -214,6 +218,7 @@ ] where name = if toLower (T.head uncheckedName) == Char.toUpper (T.head uncheckedName) then "EvT" <> uncheckedName else uncheckedName+ !nameL = length (T.unpack name) topics = [Just (T.unpack $ eventId ev)] <> replicate (length indexedArgs) Nothing toBang ty = bangType (bang sourceNoUnpack sourceStrict) (return ty) tag (n, ty) = AppT (AppT (ConT ''Tagged) (LitT $ NumTyLit n)) <$> typeEventQ ty@@ -249,6 +254,11 @@ mkDecl _ = return [] +-- | Best-effort name recovery from ADT to original 'eveArgName' on inputs.+init' :: String -> String+init' [] = []+init' xs = if Char.isDigit (last xs) then xs else init xs+ mkContractDecl :: Text -> Text -> Text -> Declaration -> DecsQ mkContractDecl name a b (DConstructor inputs) = sequence [ dataD' dataName (normalC dataName bangInput) derivingD@@ -339,7 +349,7 @@ Just (ContractAbi decs) -> do funEvDecs <- concat <$> mapM mkDecl (escape decs) case constructorSpec str of- Nothing -> return funEvDecs+ Nothing -> return funEvDecs Just (a, b, c, d) -> (funEvDecs ++) <$> mkContractDecl a b c d -- | Abi information string
src/Network/Ethereum/Ens.hs view
@@ -4,7 +4,7 @@ -- | -- Module : Network.Ethereum.Ens--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Ens/PublicResolver.hs view
@@ -8,7 +8,7 @@ -- | -- Module : Network.Ethereum.Ens.PublicResolver--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Ens/Registry.hs view
@@ -8,7 +8,7 @@ -- | -- Module : Network.Ethereum.Ens.Registry--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
src/Network/Ethereum/Transaction.hs view
@@ -3,7 +3,7 @@ -- | -- Module : Network.Ethereum.Transaction--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- Roy Blankman 2018 -- License : Apache-2.0 --
src/Network/Ethereum/Unit.hs view
@@ -5,7 +5,7 @@ -- | -- Module : Network.Ethereum.Unit--- Copyright : Aleksandr Krupenkin 2016-2021+-- Copyright : Aleksandr Krupenkin 2016-2024 -- License : Apache-2.0 -- -- Maintainer : mail@akru.me
tests/Network/Ethereum/Test/EventSpec.hs view
@@ -3,6 +3,16 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} +-- |+-- Module : Network.Ethereum.Test.EventSpec+-- Copyright : Aleksandr Krupenkin 2016-2024+-- License : Apache-2.0+--+-- Maintainer : mail@akru.me+-- Stability : experimental+-- Portability : unportable+--+ module Network.Ethereum.Test.EventSpec where import Data.Tagged (Tagged)
tests/Network/Ethereum/Test/MethodDumpSpec.hs view
@@ -1,5 +1,15 @@ {-# LANGUAGE QuasiQuotes #-} +-- |+-- Module : Network.Ethereum.Test.MethodDumpSpec+-- Copyright : Aleksandr Krupenkin 2016-2024+-- License : Apache-2.0+--+-- Maintainer : mail@akru.me+-- Stability : experimental+-- Portability : unportable+--+ module Network.Ethereum.Test.MethodDumpSpec where import Network.Ethereum.Contract.TH
tests/Network/Ethereum/Test/THSpec.hs view
@@ -4,9 +4,20 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-}++-- |+-- Module : Network.Ethereum.Test.THSpec+-- Copyright : Aleksandr Krupenkin 2016-2024+-- License : Apache-2.0+--+-- Maintainer : mail@akru.me+-- Stability : experimental+-- Portability : unportable+--+ module Network.Ethereum.Test.THSpec where -import Data.Tuple.OneTuple (OneTuple(..))+import Data.Tuple.OneTuple import Network.Ethereum.Contract.TH import Test.Hspec
tests/Network/Ethereum/Test/TransactionSpec.hs view
@@ -1,4 +1,15 @@ {-# LANGUAGE OverloadedStrings #-}++-- |+-- Module : Network.Ethereum.Test.TransactionSpec+-- Copyright : Aleksandr Krupenkin 2016-2024+-- License : Apache-2.0+--+-- Maintainer : mail@akru.me+-- Stability : experimental+-- Portability : unportable+--+ module Network.Ethereum.Test.TransactionSpec where import Crypto.Ecdsa.Utils (importKey)
web3-ethereum.cabal view
@@ -1,9 +1,9 @@ cabal-version: 1.12 name: web3-ethereum-version: 1.0.0.0+version: 1.0.1.0 license: Apache-2.0 license-file: LICENSE-copyright: (c) Aleksandr Krupenkin 2016-2021+copyright: (c) Aleksandr Krupenkin 2016-2024 maintainer: mail@akru.me author: Aleksandr Krupenkin homepage: https://github.com/airalab/hs-web3#readme@@ -50,38 +50,39 @@ other-modules: Paths_web3_ethereum default-language: Haskell2010 ghc-options:- -funbox-strict-fields -Wduplicate-exports -Whi-shadowing- -Widentities -Woverlapping-patterns -Wpartial-type-signatures+ -funbox-strict-fields -Wduplicate-exports -Widentities+ -Woverlapping-patterns -Wpartial-type-signatures -Wunrecognised-pragmas -Wtyped-holes -Wincomplete-patterns -Wincomplete-uni-patterns -Wmissing-fields -Wmissing-methods- -Wmissing-exported-signatures -Wmissing-monadfail-instances- -Wmissing-signatures -Wname-shadowing -Wunused-binds- -Wunused-top-binds -Wunused-local-binds -Wunused-pattern-binds- -Wunused-imports -Wunused-matches -Wunused-foralls -Wtabs+ -Wmissing-exported-signatures -Wmissing-signatures -Wname-shadowing+ -Wunused-binds -Wunused-top-binds -Wunused-local-binds+ -Wunused-pattern-binds -Wunused-imports -Wunused-matches+ -Wunused-foralls -Wtabs build-depends:- OneTuple >0.2 && <0.3,- aeson >1.2 && <1.6,- base >4.11 && <4.15,- bytestring >0.10 && <0.11,+ OneTuple >0.2 && <0.5,+ aeson >1.2 && <2.2,+ aeson-casing >=0.2 && <0.3,+ base >4.11 && <4.19,+ bytestring >0.10 && <0.12, data-default >0.7 && <0.8, exceptions >0.8 && <0.11, generics-sop >0.3 && <0.6,- jsonrpc-tinyclient ==1.0.*,+ jsonrpc-tinyclient >=1.0 && <1.1, machines >0.6 && <0.8,- memory >0.14 && <0.16,- memory-hexstring ==1.0.*,+ memory >0.14 && <0.19,+ memory-hexstring >=1.0 && <1.1, microlens >0.4 && <0.5,- microlens-aeson >2.2 && <2.4,- mtl >2.2 && <2.3,+ microlens-aeson >2.2 && <2.6,+ mtl >2.2 && <2.4, relapse >=1.0 && <2.0, tagged >0.8 && <0.9,- template-haskell >2.11 && <2.17,- text >1.2 && <1.3,- transformers >0.5 && <0.6,- vinyl >0.5 && <0.14,- web3-crypto ==1.0.*,- web3-solidity ==1.0.*+ template-haskell >2.11 && <2.21,+ text >1.2 && <2.1,+ transformers >0.5 && <0.7,+ vinyl >0.5 && <0.15,+ web3-crypto >=1.0 && <1.1,+ web3-solidity >=1.0 && <1.1 test-suite tests type: exitcode-stdio-1.0@@ -122,40 +123,40 @@ default-language: Haskell2010 ghc-options:- -funbox-strict-fields -Wduplicate-exports -Whi-shadowing- -Widentities -Woverlapping-patterns -Wpartial-type-signatures+ -funbox-strict-fields -Wduplicate-exports -Widentities+ -Woverlapping-patterns -Wpartial-type-signatures -Wunrecognised-pragmas -Wtyped-holes -Wincomplete-patterns -Wincomplete-uni-patterns -Wmissing-fields -Wmissing-methods- -Wmissing-exported-signatures -Wmissing-monadfail-instances- -Wmissing-signatures -Wname-shadowing -Wunused-binds- -Wunused-top-binds -Wunused-local-binds -Wunused-pattern-binds- -Wunused-imports -Wunused-matches -Wunused-foralls -Wtabs -threaded- -rtsopts -with-rtsopts=-N+ -Wmissing-exported-signatures -Wmissing-signatures -Wname-shadowing+ -Wunused-binds -Wunused-top-binds -Wunused-local-binds+ -Wunused-pattern-binds -Wunused-imports -Wunused-matches+ -Wunused-foralls -Wtabs -threaded -rtsopts -with-rtsopts=-N build-depends:- OneTuple >0.2 && <0.3,- aeson >1.2 && <1.6,- base >4.11 && <4.15,- bytestring >0.10 && <0.11,+ OneTuple >0.2 && <0.5,+ aeson >1.2 && <2.2,+ aeson-casing >=0.2 && <0.3,+ base >4.11 && <4.19,+ bytestring >0.10 && <0.12, data-default >0.7 && <0.8, exceptions >0.8 && <0.11, generics-sop >0.3 && <0.6,- hspec >=2.4.4 && <2.8,+ hspec >=2.4.4 && <2.12, hspec-contrib >=0.4.0 && <0.6,- hspec-discover >=2.4.4 && <2.8,+ hspec-discover >=2.4.4 && <2.12, hspec-expectations >=0.8.2 && <0.9,- jsonrpc-tinyclient ==1.0.*,+ jsonrpc-tinyclient >=1.0 && <1.1, machines >0.6 && <0.8,- memory >0.14 && <0.16,- memory-hexstring ==1.0.*,+ memory >0.14 && <0.19,+ memory-hexstring >=1.0 && <1.1, microlens >0.4 && <0.5,- microlens-aeson >2.2 && <2.4,- mtl >2.2 && <2.3,+ microlens-aeson >2.2 && <2.6,+ mtl >2.2 && <2.4, relapse >=1.0 && <2.0, tagged >0.8 && <0.9,- template-haskell >2.11 && <2.17,- text >1.2 && <1.3,- transformers >0.5 && <0.6,- vinyl >0.5 && <0.14,- web3-crypto ==1.0.*,- web3-solidity ==1.0.*+ template-haskell >2.11 && <2.21,+ text >1.2 && <2.1,+ transformers >0.5 && <0.7,+ vinyl >0.5 && <0.15,+ web3-crypto >=1.0 && <1.1,+ web3-solidity >=1.0 && <1.1