web3 0.7.2.0 → 0.7.3.0
raw patch · 12 files changed
+108/−84 lines, 12 filesdep ~exceptions
Dependency ranges changed: exceptions
Files
- CHANGELOG.md +8/−0
- src/Network/Ethereum/ABI/Prim.hs +30/−0
- src/Network/Ethereum/Contract/Event.hs +3/−3
- src/Network/Ethereum/Contract/TH.hs +27/−33
- src/Network/Ethereum/Web3.hs +7/−17
- src/Network/Ethereum/Web3/Eth.hs +2/−1
- src/Network/Ethereum/Web3/Provider.hs +1/−1
- src/Network/Ethereum/Web3/Types.hs +14/−14
- test-support/inject-contract-addresses.sh +1/−1
- test/Network/Ethereum/Web3/Test/SimpleStorageSpec.hs +2/−2
- unit/Network/Ethereum/Web3/Test/EventSpec.hs +10/−10
- web3.cabal +3/−2
CHANGELOG.md view
@@ -1,6 +1,14 @@ # Changelog All notable changes to this project will be documented in this file. +## [0.7.3.0] 2018-05-22+### Added+- 'Network.Ethereum.ABI.Prim' meta-module as primitive types and instances aggregator.+- Stackage nightly build compatibility.++### Changed+- Potential nullable web3 type ('Change', 'Block', 'Transaction', etc.) fields are encoded as 'Maybe'.+ ## [0.7.2.0] 2018-05-13 ### Added - Generic JSON-RPC API documentation improvements.
+ src/Network/Ethereum/ABI/Prim.hs view
@@ -0,0 +1,30 @@+-- |+-- Module : Network.Ethereum.ABI.Prim+-- Copyright : Alexander Krupenkin 2016-2018+-- License : BSD3+--+-- Maintainer : mail@akru.me+-- Stability : experimental+-- Portability : noportable+--+-- Ethereum ABI encoding primitive types.+--++module Network.Ethereum.ABI.Prim (+ Address+ , Bytes+ , BytesN+ , IntN+ , UIntN+ , ListN+ , Singleton(..)+ ) where++import Network.Ethereum.ABI.Prim.Address (Address)+import Network.Ethereum.ABI.Prim.Bool ()+import Network.Ethereum.ABI.Prim.Bytes (Bytes, BytesN)+import Network.Ethereum.ABI.Prim.Int (IntN, UIntN)+import Network.Ethereum.ABI.Prim.List (ListN)+import Network.Ethereum.ABI.Prim.String ()+import Network.Ethereum.ABI.Prim.Tagged ()+import Network.Ethereum.ABI.Prim.Tuple (Singleton (..))
src/Network/Ethereum/Contract/Event.hs view
@@ -33,7 +33,7 @@ mapping, repeatedly, runT, unfoldPlan, (~>)) import Data.Machine.Plan (PlanT, stop, yield)-import Data.Maybe (listToMaybe)+import Data.Maybe (catMaybes, listToMaybe) import Control.Concurrent.Async (Async) import Network.Ethereum.ABI.Event (DecodeEvent (..))@@ -115,11 +115,11 @@ => (a -> ReaderT Change m EventAction) -> [FilterChange a] -> m [(EventAction, Quantity)]- processChanges handler' changes =+ processChanges handler' changes = fmap catMaybes $ forM changes $ \FilterChange{..} -> do act <- flip runReaderT filterChangeRawChange $ handler' filterChangeEvent- return (act, changeBlockNumber filterChangeRawChange)+ return ((,) act <$> changeBlockNumber filterChangeRawChange) data FilterChange a = FilterChange { filterChangeRawChange :: Change , filterChangeEvent :: a
src/Network/Ethereum/Contract/TH.hs view
@@ -37,42 +37,36 @@ module Network.Ethereum.Contract.TH (abi, abiFrom) where -import Control.Monad (replicateM, (<=<))-import Data.Aeson (eitherDecode)-import Data.Default (Default (..))-import Data.List (group, sort, uncons)-import Data.Monoid ((<>))-import Data.Tagged (Tagged)-import Data.Text (Text)-import qualified Data.Text as T-import qualified Data.Text.Lazy as LT-import qualified Data.Text.Lazy.Encoding as LT-import Generics.SOP (Generic)-import qualified GHC.Generics as GHC (Generic)+import Control.Monad (replicateM, (<=<))+import Data.Aeson (eitherDecode)+import Data.Default (Default (..))+import Data.List (group, sort, uncons)+import Data.Monoid ((<>))+import Data.Tagged (Tagged)+import Data.Text (Text)+import qualified Data.Text as T+import qualified Data.Text.Lazy as LT+import qualified Data.Text.Lazy.Encoding as LT+import Generics.SOP (Generic)+import qualified GHC.Generics as GHC (Generic) import Language.Haskell.TH import Language.Haskell.TH.Quote -import Data.String.Extra (toLowerFirst, toUpperFirst)-import Network.Ethereum.ABI.Class (ABIGet, ABIPut,- ABIType (..))-import Network.Ethereum.ABI.Event (IndexedEvent (..))-import Network.Ethereum.ABI.Json (ContractABI (..),- Declaration (..),- EventArg (..),- FunctionArg (..),- SolidityType (..), eventId,- methodId, parseSolidityType)-import Network.Ethereum.ABI.Prim.Address (Address)-import Network.Ethereum.ABI.Prim.Bytes (Bytes, BytesN)-import Network.Ethereum.ABI.Prim.Int (IntN, UIntN)-import Network.Ethereum.ABI.Prim.List (ListN)-import Network.Ethereum.ABI.Prim.String ()-import Network.Ethereum.ABI.Prim.Tagged ()-import Network.Ethereum.ABI.Prim.Tuple (Singleton (..))-import Network.Ethereum.Contract.Method (Method (..), call, sendTx)-import Network.Ethereum.Web3.Provider (Web3)-import Network.Ethereum.Web3.Types (Call, DefaultBlock (..),- Filter (..), Hash)+import Data.String.Extra (toLowerFirst, toUpperFirst)+import Network.Ethereum.ABI.Class (ABIGet, ABIPut, ABIType (..))+import Network.Ethereum.ABI.Event (IndexedEvent (..))+import Network.Ethereum.ABI.Json (ContractABI (..),+ Declaration (..),+ EventArg (..),+ FunctionArg (..),+ SolidityType (..), eventId,+ methodId, parseSolidityType)+import Network.Ethereum.ABI.Prim (Address, Bytes, BytesN, IntN,+ ListN, Singleton (..), UIntN)+import Network.Ethereum.Contract.Method (Method (..), call, sendTx)+import Network.Ethereum.Web3.Provider (Web3)+import Network.Ethereum.Web3.Types (Call, DefaultBlock (..),+ Filter (..), Hash) -- | Read contract ABI from file abiFrom :: QuasiQuoter
src/Network/Ethereum/Web3.hs view
@@ -33,27 +33,17 @@ , event' -- ** Primitive data types- , Address- , Bytes- , BytesN- , IntN- , UIntN- , ListN+ , module Network.Ethereum.ABI.Prim -- ** Metric unit system , module Network.Ethereum.Unit ) where -import Network.Ethereum.ABI.Prim.Address (Address)-import Network.Ethereum.ABI.Prim.Bool ()-import Network.Ethereum.ABI.Prim.Bytes (Bytes, BytesN)-import Network.Ethereum.ABI.Prim.Int (IntN, UIntN)-import Network.Ethereum.ABI.Prim.List (ListN)-import Network.Ethereum.ABI.Prim.String ()-import Network.Ethereum.Contract.Event (EventAction (..), event,- event')-import Network.Ethereum.Contract.Method (sendTx)+import Network.Ethereum.ABI.Prim+import Network.Ethereum.Contract.Event (EventAction (..), event,+ event')+import Network.Ethereum.Contract.Method (sendTx) import Network.Ethereum.Unit-import Network.Ethereum.Web3.Provider (Web3, runWeb3)-import Network.Ethereum.Web3.Types (Call (..))+import Network.Ethereum.Web3.Provider (Web3, runWeb3)+import Network.Ethereum.Web3.Types (Call (..))
src/Network/Ethereum/Web3/Eth.hs view
@@ -15,6 +15,7 @@ module Network.Ethereum.Web3.Eth where +import Data.Text (Text) import Network.Ethereum.ABI.Prim.Address (Address) import Network.Ethereum.ABI.Prim.Bytes (Bytes, BytesN) import Network.Ethereum.Web3.Provider (Web3)@@ -25,7 +26,7 @@ import Network.JsonRpc.TinyClient (remote) -- | Returns the current ethereum protocol version.-protocolVersion :: Web3 Int+protocolVersion :: Web3 Text {-# INLINE protocolVersion #-} protocolVersion = remote "eth_protocolVersion"
src/Network/Ethereum/Web3/Provider.hs view
@@ -1,8 +1,8 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE CPP #-} -- | -- Module : Network.Ethereum.Web3.Provider
src/Network/Ethereum/Web3/Types.hs view
@@ -118,15 +118,15 @@ -- | Changes pulled by low-level call 'eth_getFilterChanges', 'eth_getLogs', -- and 'eth_getFilterLogs' data Change = Change- { changeLogIndex :: !Quantity+ { changeLogIndex :: !(Maybe Quantity) -- ^ QUANTITY - integer of the log index position in the block. null when its pending log.- , changeTransactionIndex :: !Quantity+ , changeTransactionIndex :: !(Maybe Quantity) -- ^ QUANTITY - integer of the transactions index position log was created from. null when its pending log.- , changeTransactionHash :: !Hash+ , changeTransactionHash :: !(Maybe Hash) -- ^ DATA, 32 Bytes - hash of the transactions this log was created from. null when its pending log.- , changeBlockHash :: !Hash+ , changeBlockHash :: !(Maybe Hash) -- ^ DATA, 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log.- , changeBlockNumber :: !Quantity+ , changeBlockNumber :: !(Maybe Quantity) -- ^ QUANTITY - the block number where this log was in. null when its pending. null when its pending log. , changeAddress :: !Address -- ^ DATA, 20 Bytes - address from which this log originated.@@ -219,10 +219,10 @@ -- ^ DATA, 32 Bytes - hash of the transaction. , receiptTransactionIndex :: !Quantity -- ^ QUANTITY - index of the transaction.- , receiptBlockHash :: !Hash+ , receiptBlockHash :: !(Maybe Hash) -- ^ DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.- , receiptBlockNumber :: !Quantity- -- ^ QUANTITY - block number where this transaction was in.+ , receiptBlockNumber :: !(Maybe Quantity)+ -- ^ QUANTITY - block number where this transaction was in. null when its pending. , receiptCumulativeGasUsed :: !Quantity -- ^ QUANTITY - The total amount of gas used when this transaction was executed in the block. , receiptGasUsed :: !Quantity@@ -246,11 +246,11 @@ -- ^ DATA, 32 Bytes - hash of the transaction. , txNonce :: !Quantity -- ^ QUANTITY - the number of transactions made by the sender prior to this one.- , txBlockHash :: !Hash+ , txBlockHash :: !(Maybe Hash) -- ^ DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.- , txBlockNumber :: !Quantity+ , txBlockNumber :: !(Maybe Quantity) -- ^ QUANTITY - block number where this transaction was in. null when its pending.- , txTransactionIndex :: !Quantity+ , txTransactionIndex :: !(Maybe Quantity) -- ^ QUANTITY - integer of the transactions index position in the block. null when its pending. , txFrom :: !Address -- ^ DATA, 20 Bytes - address of the sender.@@ -271,9 +271,9 @@ -- | Block information. data Block = Block- { blockNumber :: !Quantity+ { blockNumber :: !(Maybe Quantity) -- ^ QUANTITY - the block number. null when its pending block.- , blockHash :: !Hash+ , blockHash :: !(Maybe Hash) -- ^ DATA, 32 Bytes - hash of the block. null when its pending block. , blockParentHash :: !Hash -- ^ DATA, 32 Bytes - hash of the parent block.@@ -281,7 +281,7 @@ -- ^ DATA, 8 Bytes - hash of the generated proof-of-work. null when its pending block. , blockSha3Uncles :: !(BytesN 32) -- ^ DATA, 32 Bytes - SHA3 of the uncles data in the block.- , blockLogsBloom :: !Bytes+ , blockLogsBloom :: !(Maybe Bytes) -- ^ DATA, 256 Bytes - the bloom filter for the logs of the block. null when its pending block. , blockTransactionsRoot :: !(BytesN 32) -- ^ DATA, 32 Bytes - the root of the transaction trie of the block.
test-support/inject-contract-addresses.sh view
@@ -1,4 +1,4 @@-#!/bin/bash+#!/usr/bin/env bash set -ex
test/Network/Ethereum/Web3/Test/SimpleStorageSpec.hs view
@@ -140,7 +140,7 @@ setValues theCall theSets1 wait fiber print "All past transactions succeeded... "- end <- takeMVar blockNumberVar+ Just end <- takeMVar blockNumberVar awaitBlock $ end + 1 -- make past transactions definitively in past var' <- newMVar [] fiber <- runWeb3Configured' $ do@@ -169,7 +169,7 @@ setValues theCall theSets wait fiber print "All values have been set"- end <- takeMVar blockNumberVar+ Just end <- takeMVar blockNumberVar var' <- newMVar [] let fltr' = fltr { filterFromBlock = BlockWithNumber start , filterToBlock = BlockWithNumber end
unit/Network/Ethereum/Web3/Test/EventSpec.hs view
@@ -29,11 +29,11 @@ describe "event tests" $ do it "can decode simple storage" $- let change = Change { changeLogIndex = "0x2"- , changeTransactionIndex = "0x2"- , changeTransactionHash = "0xe8cac6af0ceb3cecbcb2a5639361fc9811b1aa753672cf7c7e8b528df53e0e94"- , changeBlockHash = "0x0c7e1701858232ac210e3bcc8ab3b33cc6b08025692b22abb39059dc41f6a76e"- , changeBlockNumber = 0+ let change = Change { changeLogIndex = Just "0x2"+ , changeTransactionIndex = Just "0x2"+ , changeTransactionHash = Just "0xe8cac6af0ceb3cecbcb2a5639361fc9811b1aa753672cf7c7e8b528df53e0e94"+ , changeBlockHash = Just "0x0c7e1701858232ac210e3bcc8ab3b33cc6b08025692b22abb39059dc41f6a76e"+ , changeBlockNumber = Just 0 , changeAddress = "0x617e5941507aab5d2d8bcb56cb8c6ce2eeb16b21" , changeData = "0x000000000000000000000000000000000000000000000000000000000000000a" , changeTopics = ["0xa32bc18230dd172221ac5c4821a5f1f1a831f27b1396d244cdd891c58f132435"]@@ -41,11 +41,11 @@ in decodeEvent change `shouldBe` Right (NewCount 10) it "can decode erc20" $- let ercchange = Change { changeLogIndex = "0x2"- , changeTransactionIndex = "0x2"- , changeTransactionHash = "0xe8cac6af0ceb3cecbcb2a5639361fc9811b1aa753672cf7c7e8b528df53e0e94"- , changeBlockHash = "0x0c7e1701858232ac210e3bcc8ab3b33cc6b08025692b22abb39059dc41f6a76e"- , changeBlockNumber = 0+ let ercchange = Change { changeLogIndex = Just "0x2"+ , changeTransactionIndex = Just "0x2"+ , changeTransactionHash = Just "0xe8cac6af0ceb3cecbcb2a5639361fc9811b1aa753672cf7c7e8b528df53e0e94"+ , changeBlockHash = Just "0x0c7e1701858232ac210e3bcc8ab3b33cc6b08025692b22abb39059dc41f6a76e"+ , changeBlockNumber = Just 0 , changeAddress = "0x617e5941507aab5d2d8bcb56cb8c6ce2eeb16b21" , changeData = "0x000000000000000000000000000000000000000000000000000000000000000a" , changeTopics = [ "0xb32bc18230dd172221ac5c4821a5f1f1a831f27b1396d244cdd891c58f132435"
web3.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: web3-version: 0.7.2.0+version: 0.7.3.0 license: BSD3 license-file: LICENSE copyright: Alexander Krupenkin@@ -50,6 +50,7 @@ Network.Ethereum.ABI.Event Network.Ethereum.ABI.Event.Internal Network.Ethereum.ABI.Generic+ Network.Ethereum.ABI.Prim Network.Ethereum.ABI.Prim.Int Network.Ethereum.ABI.Prim.Bool Network.Ethereum.ABI.Prim.List@@ -85,7 +86,7 @@ generics-sop >=0.3.2.0 && <0.4, transformers >=0.5.2.0 && <0.6, http-client >=0.5.12.1 && <0.6,- exceptions >=0.8.3 && <0.9,+ exceptions >=0.8.3 && <0.11, bytestring >=0.10.8.2 && <0.11, cryptonite ==0.25.*, basement >=0.0.7 && <0.1,