'''Common provider class with basic features.'''

from pypeerassets.exceptions import UnsupportedNetwork
from pypeerassets.pa_constants import PAParams, param_query
from pypeerassets.networks import NetworkParams, net_query
import requests


class Provider:

    @staticmethod
    def _netname(name: str) -> dict:
        '''resolute network name,
        required because some providers use shortnames and other use longnames.'''

        try:
            long = net_query(name).network_name
            short = net_query(name).network_shortname
        except AttributeError:
            raise UnsupportedNetwork('''This blockchain network is not supported by the pypeerassets, check networks.py for list of supported networks.''')

        return {'long': long,
                'short': short}

    @property
    def network(self) -> str:
        '''return network full name'''

        return self._netname(self.net)['long']

    @property
    def pa_parameters(self) -> PAParams:
        '''load network PeerAssets parameters.'''

        return param_query(self.network)

    @property
    def network_properties(self) -> NetworkParams:
        '''network parameters [min_fee, denomination, ...]'''

        return net_query(self.network)

    @property
    def is_testnet(self) -> bool:
        """testnet or not?"""

        if "testnet" in self.network:
            return True
        else:
            return False

    @classmethod
    def sendrawtransaction(cls, rawtxn: str) -> dict:
        '''sendrawtransaction remote API
        : rawtxn - must be submitted as string'''

        if cls.is_testnet:
            url = 'http://talk.peercoin.net:5555/pushapi/testnet/sendrawtransaction/'
        else:
            url = 'http://talk.peercoin.net:5555/pushapi/sendrawtransaction/'

        resp = requests.get(url + rawtxn)
        return resp.content.decode()

@@ -43,16 +43,52 @@
 es.'''%0A%0A
+from abc import ABC, abstractmethod%0A
 from pyp
@@ -285,16 +285,21 @@
 Provider
+(ABC)
 :%0A%0A    @
@@ -1909,8 +1909,1183 @@
 ecode()%0A
+%0A    @abstractmethod%0A    def getblockhash(self, blocknum: int) -%3E str:%0A        '''get blockhash using blocknum query'''%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def getblockcount(self) -%3E int:%0A        '''get block count'''%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def getblock(self) -%3E dict:%0A        '''query block using %3Cblockhash%3E as key.'''%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def getdifficulty(self) -%3E float:%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def getbalance(self, address: str) -%3E float:%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def getreceivedbyaddress(self, address: str) -%3E float:%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def listunspent(self, address: str) -%3E list:%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def select_inputs(self, address: str, amount: int) -%3E dict:%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def getrawtransaction(self, txid: str, decrypt=1) -%3E dict:%0A        raise NotImplementedError%0A%0A    @abstractmethod%0A    def listtransactions(self, address: str) -%3E list:%0A        raise NotImplementedError%0A

rework Provider as metaclass.