packages feed

web3 0.3.3.0 → 0.3.4.0

raw patch · 5 files changed

+97/−5 lines, 5 filesdep ~base

Dependency ranges changed: base

Files

src/Network/Ethereum/Unit.hs view
@@ -63,7 +63,7 @@ import GHC.Read  -- | Ethereum value unit-class (UnitSpec a, Fractional a) => Unit a where+class (Read a, Show a, UnitSpec a, Fractional a) => Unit a where     -- | Make a value from integer wei     fromWei :: Integer -> a     -- | Convert a value to integer wei
src/Network/Ethereum/Web3/Api.hs view
@@ -57,3 +57,15 @@ -- | Returns a list of addresses owned by client. eth_accounts :: Web3 [Address] eth_accounts = remote "eth_accounts"++eth_newBlockFilter :: Web3 Text+eth_newBlockFilter = remote "eth_newBlockFilter"++-- | Polling method for a block filter, which returns an array of block hashes+-- occurred since last poll.+eth_getBlockFilterChanges :: Text -> Web3 [Text]+eth_getBlockFilterChanges = remote "eth_getFilterChanges"++-- | Returns information about a block by hash.+eth_getBlockByHash :: Text -> Web3 Block+eth_getBlockByHash = flip (remote "eth_getBlockByHash") True
src/Network/Ethereum/Web3/Bytes.hs view
@@ -32,7 +32,7 @@  -- | Fixed length byte array newtype BytesN (n :: Nat) = BytesN { unBytesN :: Bytes }-  deriving (Show, Eq, Ord)+  deriving (Eq, Ord)  update :: BytesN a -> Bytes -> BytesN a update _ a = BytesN a@@ -45,6 +45,9 @@         bytesString <- T.take (len * 2) <$> P.take 64         return (update result (bytesDecode bytesString)) +instance KnownNat n => Show (BytesN n) where+    show = show . BS16.encode . BA.convert . unBytesN+ bytesBuilder :: Bytes -> B.Builder bytesBuilder = alignL . B.fromText . T.decodeUtf8              . BS16.encode . BA.convert@@ -54,7 +57,7 @@  -- | Dynamic length byte array newtype BytesD = BytesD { unBytesD :: Bytes }-  deriving (Show, Eq, Ord)+  deriving (Eq, Ord)  instance ABIEncoding BytesD where     toDataBuilder (BytesD bytes) = int256HexBuilder (BA.length bytes)@@ -64,3 +67,6 @@         if (len :: Integer) > fromIntegral (maxBound :: Int)         then fail "Bytes length over bound!"         else (BytesD . bytesDecode) <$> P.take (fromIntegral len * 2)++instance Show BytesD where+    show = show . BS16.encode . BA.convert . unBytesD
src/Network/Ethereum/Web3/Types.hs view
@@ -131,3 +131,77 @@ -- TODO: Wrap -- | Transaction hash text string type TxHash = Text++-- | Transaction information+data Transaction = Transaction+  { txHash              :: TxHash+  -- ^ DATA, 32 Bytes - hash of the transaction.+  , txNonce             :: Text+  -- ^ QUANTITY - the number of transactions made by the sender prior to this one.+  , txBlockHash         :: Text+  -- ^ DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.+  , txBlockNumber       :: Text+  -- ^ QUANTITY - block number where this transaction was in. null when its pending.+  , txTransactionIndex  :: Text+  -- ^ QUANTITY - integer of the transactions index position in the block. null when its pending.+  , txFrom              :: Address+  -- ^ DATA, 20 Bytes - address of the sender.+  , txTo                :: Maybe Address+  -- ^ DATA, 20 Bytes - address of the receiver. null when its a contract creation transaction.+  , txValue             :: Text+  -- ^ QUANTITY - value transferred in Wei.+  , txGasPrice          :: Text+  -- ^ QUANTITY - gas price provided by the sender in Wei.+  , txGas               :: Text+  -- ^ QUANTITY - gas provided by the sender.+  , txInput             :: Text+  -- ^ DATA - the data send along with the transaction.+  } deriving Show++$(deriveJSON (defaultOptions+    { fieldLabelModifier = toLowerFirst . drop 2 }) ''Transaction)++-- | Block information+data Block = Block+  { blockNumber         :: Text+  -- ^ QUANTITY - the block number. null when its pending block.+  , blockHash           :: Text+  -- ^ DATA, 32 Bytes - hash of the block. null when its pending block.+  , blockParentHash     :: Text+  -- ^ DATA, 32 Bytes - hash of the parent block.+  , blockNonce          :: Maybe Text+  -- ^ DATA, 8 Bytes - hash of the generated proof-of-work. null when its pending block.+  , blockSha3Uncles     :: Text+  -- ^ DATA, 32 Bytes - SHA3 of the uncles data in the block.+  , blockLogsBloom      :: Text+  -- ^ DATA, 256 Bytes - the bloom filter for the logs of the block. null when its pending block.+  , blockTransactionsRoot :: Text+  -- ^ DATA, 32 Bytes - the root of the transaction trie of the block.+  , blockStateRoot      :: Text+  -- ^ DATA, 32 Bytes - the root of the final state trie of the block.+  , blockReceiptRoot    :: Maybe Text+  -- ^ DATA, 32 Bytes - the root of the receipts trie of the block.+  , blockMiner          :: Address+  -- ^ DATA, 20 Bytes - the address of the beneficiary to whom the mining rewards were given.+  , blockDifficulty     :: Text+  -- ^ QUANTITY - integer of the difficulty for this block.+  , blockTotalDifficulty :: Text+  -- ^ QUANTITY - integer of the total difficulty of the chain until this block.+  , blockExtraData      :: Text+  -- ^ DATA - the "extra data" field of this block.+  , blockSize           :: Text+  -- ^ QUANTITY - integer the size of this block in bytes.+  , blockGasLimit       :: Text+  -- ^ QUANTITY - the maximum gas allowed in this block.+  , blockGasUsed        :: Text+  -- ^ QUANTITY - the total used gas by all transactions in this block.+  , blockTimestamp      :: Text+  -- ^ QUANTITY - the unix timestamp for when the block was collated.+  , blockTransactions   :: [Transaction]+  -- ^ Array of transaction objects.+  , blockUncles         :: [Text]+  -- ^ Array - Array of uncle hashes.+  } deriving Show++$(deriveJSON (defaultOptions+    { fieldLabelModifier = toLowerFirst . drop 5 }) ''Block)
web3.cabal view
@@ -1,5 +1,5 @@ name:                web3-version:             0.3.3.0+version:             0.3.4.0 synopsis:            Ethereum API for Haskell description:         Web3 is a Haskell client library for Ethereum homepage:            https://github.com/airalab/hs-web3#readme@@ -36,7 +36,7 @@   other-modules:       Network.Ethereum.Web3.JsonRpc                      , Network.Ethereum.Web3.Internal                      , Network.Ethereum.Web3.EncodingUtils-  build-depends:       base >4.8 && <4.10+  build-depends:       base >4.8 && <4.11                      , data-default-class                      , base16-bytestring                      , template-haskell