packages feed

web3 0.8.1.0 → 0.8.2.0

raw patch · 7 files changed

+37/−11 lines, 7 files

Files

CHANGELOG.md view
@@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## [0.8.2.0] 2018-11-07+### Changed+- Gas estimation runs when gas limit is not set before+ ## [0.8.1.0] 2018-10-29 ### Added - Support vinyl-0.10 in `MultiFilter` module@@ -15,6 +19,7 @@ - Experimental support for solidity compiler (disabled by default)  - Support for Ethereum mainnet ENS resolver - Contract typeclass with api/bytecode getters+- Gas estimation for sending transactions - Contract typeclass TH generator - Function for creating contracts - Event single/multi filters
src/Network/Ethereum/Account/Default.hs view
@@ -53,8 +53,11 @@                 params = c { callData = Just $ BA.convert dat                            , callFrom = listToMaybe accounts } -            gasLimit <- Eth.estimateGas params-            let params' = params { callGas = Just gasLimit }+            params' <- case callGas params of+                Just _  -> return params+                Nothing -> do+                    gasLimit <- Eth.estimateGas params+                    return $ params { callGas = Just gasLimit }              getReceipt =<< Eth.sendTransaction params' 
src/Network/Ethereum/Account/Internal.hs view
@@ -63,12 +63,12 @@ value = lens (fromWei . _value) $ \a b -> a { _value = toWei b }  -- | Transaction gas limit lens-gasLimit :: Lens' (CallParam p) (Maybe Integer)-gasLimit = lens _gasLimit $ \a b -> a { _gasLimit = b }+gasLimit :: Lens' (CallParam p) Integer+gasLimit = lens (fromMaybe def . _gasLimit) $ \a b -> a { _gasLimit = Just b }  -- | Transaction gas price lens-gasPrice :: Unit gasprice => Lens' (CallParam p) (Maybe gasprice)-gasPrice = lens (fmap fromWei . _gasPrice) $ \a b -> a { _gasPrice = toWei <$> b }+gasPrice :: Unit gasprice => Lens' (CallParam p) gasprice+gasPrice = lens (fromWei . fromMaybe def . _gasPrice) $ \a b -> a { _gasPrice = Just (toWei b) }  -- | Call execution block lens block :: Lens' (CallParam p) DefaultBlock
src/Network/Ethereum/Account/Personal.hs view
@@ -63,8 +63,11 @@                 params = c { callFrom = Just $ personalAddress _account                            , callData = Just $ BA.convert dat } -            gasLimit <- Eth.estimateGas params-            let params' = params { callGas = Just gasLimit }+            params' <- case callGas params of+                Just _  -> return params+                Nothing -> do+                    gasLimit <- Eth.estimateGas params+                    return $ params { callGas = Just gasLimit }              getReceipt =<< Personal.sendTransaction params' (personalPassphrase _account) 
src/Network/Ethereum/Account/PrivateKey.hs view
@@ -75,8 +75,11 @@                        , callNonce = Just nonce                        , callData  = Just $ convert dat } -        gasLimit <- lift $ Eth.estimateGas params-        let params' = params { callGas = Just gasLimit }+        params' <- case callGas params of+            Just _  -> return params+            Nothing -> do+                gasLimit <- lift $ Eth.estimateGas params+                return $ params { callGas = Just gasLimit }          let signed = signTransaction params' (privateKeyChain _account) (privateKey _account)         lift $ getReceipt =<< Eth.sendRawTransaction signed
test/Network/Ethereum/Web3/Test/SimpleStorageSpec.hs view
@@ -8,6 +8,7 @@ {-# LANGUAGE NamedFieldPuns        #-} {-# LANGUAGE OverloadedStrings     #-} {-# LANGUAGE QuasiQuotes           #-}+{-# LANGUAGE RecordWildCards       #-} {-# LANGUAGE ScopedTypeVariables   #-} {-# LANGUAGE TemplateHaskell       #-} @@ -34,6 +35,7 @@ import           Data.Default                     (def) import           Data.List                        (sort) import           Data.Monoid                      ((<>))+import           Lens.Micro                       ((.~)) import           Test.Hspec  import qualified Network.Ethereum.Api.Eth         as Eth@@ -77,6 +79,16 @@          v <- contract storage count         v `shouldBe` theValue++    it "can set transaction gas limit" $ \storage -> do+        TxReceipt{..} <- contract storage $ withParam (gasLimit .~ 500000) $ setCount theValue+        Just Transaction{..} <- web3 $ Eth.getTransactionByHash receiptTransactionHash+        txGas `shouldBe` 500000++    it "can estimate transaction gas limit" $ \storage -> do+        TxReceipt{..} <- contract storage $ setCount theValue+        Just Transaction{..} <- web3 $ Eth.getTransactionByHash receiptTransactionHash+        txGas `shouldBe` 42822  events :: SpecWith Address events = do
web3.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: web3-version: 0.8.1.0+version: 0.8.2.0 license: BSD3 license-file: LICENSE copyright: (c) Alexander Krupenkin 2016