Added Polkadot API reference docs

This commit is contained in:
Alexander Krupenkin 2020-05-24 05:34:37 +03:00
parent 68a36dab18
commit 1f85772f00
No known key found for this signature in database
GPG Key ID: 8858C018FBC3725E
4 changed files with 54 additions and 3 deletions

View File

@ -76,7 +76,7 @@ Currently implemented the following Ethereum APIs in modules:
``personal_*`` `Network.Ethereum.Api.Personal <http://hackage.haskell.org/package/web3/docs/Network-Ethereum-Api-Personal.html>`_ ``personal_*`` `Network.Ethereum.Api.Personal <http://hackage.haskell.org/package/web3/docs/Network-Ethereum-Api-Personal.html>`_
=============== ================ =============== ================
All modules use descriptive types according to official Ethereum specification. It placed at `Network.Ethereum.Api.Types <http://hackage.haskell.org/package/web3-0.8.1.0/docs/Network-Ethereum-Api-Types.html>`_. All modules use descriptive types according to official Ethereum specification. It placed at `Network.Ethereum.Api.Types <http://hackage.haskell.org/package/web3/docs/Network-Ethereum-Api-Types.html>`_.
.. note:: .. note::

View File

@ -8,6 +8,7 @@ Haskell Web3 Documentation
getting_started getting_started
ethereum_node_api ethereum_node_api
polkadot_node_api
ethereum_accounts ethereum_accounts
smart_contracts smart_contracts
ipfs_client_api ipfs_client_api

View File

@ -0,0 +1,50 @@
Polkadot node API
=================
As same as Ethereum nodes Polkadot node exports HTTP/WebSockets `JSON-RPC` API. For connection with node **hs-web3** use internal tiny JSON-RPC client.
Lets try to call Polkadot node with ``runWeb3'`` function using ``ghci``.
.. code-block:: haskell
> import Network.Web3.Provider
> import qualified Network.Polkadot.Api.System as System
> runWeb3' (WsProvider "127.0.0.1" 9944) $ System.name
Right "Parity Polkadot"
It can be useful to define function with Polkadot node endpoint location.
.. code-block:: haskell
myNode :: Web3 a -> Either Web3Error a
myNode = runWeb3' (Wsprovider "127.0.0.1" 9944)
API Reference
~~~~~~~~~~~~~
Currently implemented the following Polkadot APIs in modules:
================== ================
Method prefix Implementation
================== ================
``account_*`` `Network.Polkadot.Api.Account <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Account.html>`_
``author_*`` `Network.Polkadot.Api.Author <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Author.html>`_
``babe_*`` `Network.Polkadot.Api.Babe <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Babe.html>`_
``chain_*`` `Network.Polkadot.Api.Chain <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Chain.html>`_
``childstate_*`` `Network.Polkadot.Api.Childstate <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Childstate.html>`_
``contracts_*`` `Network.Polkadot.Api.Contracts <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Contracts.html>`_
``engine_*`` `Network.Polkadot.Api.Engine <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Engine.html>`_
``grandpa_*`` `Network.Polkadot.Api.Grandpa <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Grandpa.html>`_
``offchain_*`` `Network.Polkadot.Api.Offchain <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Offchain.html>`_
``payment_*`` `Network.Polkadot.Api.Payment <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Payment.html>`_
``rpc_*`` `Network.Polkadot.Api.Rpc <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Rpc.html>`_
``state_*`` `Network.Polkadot.Api.State <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-State.html>`_
``system_*`` `Network.Polkadot.Api.System <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-System.html>`_
================== ================
All modules use descriptive types located at `Network.Polkadot.Api.Types <http://hackage.haskell.org/package/web3/docs/Network-Polkadot-Api-Types.html>`_.
.. note::
See classic API reference at `Hackage web3 page <http://hackage.haskell.org/package/web3>`_.

View File

@ -15,11 +15,11 @@
module Network.Polkadot.Api.Rpc where module Network.Polkadot.Api.Rpc where
import Data.Text (Text) import Data.Aeson (Value)
import Network.JsonRpc.TinyClient (JsonRpc (..)) import Network.JsonRpc.TinyClient (JsonRpc (..))
-- | Retrieves the list of RPC methods that are exposed by the node. -- | Retrieves the list of RPC methods that are exposed by the node.
methods :: JsonRpc m => m [Text] methods :: JsonRpc m => m Value
{-# INLINE methods #-} {-# INLINE methods #-}
methods = remote "rpc_methods" methods = remote "rpc_methods"