@@ -30,12 +30,12 @@ class BadRequest(ClientException):
3030 """Invalid request passed"""
3131
3232
33- # Assume user puts his API key in the api_key.json file under variable name "key"
33+ # API key must be in the api_key.json file under variable name "key"
3434class Client (object ):
3535 dao_address = '0xbb9bc244d798123fde783fcc1c72d3bb8c189413'
3636
3737 # Constants
38- PREFIX = 'https://api-ropsten.etherscan.io/api?' # TESTNET
38+ PREFIX = 'https://api-ropsten.etherscan.io/api?' # TESTNET
3939 MODULE = 'module='
4040 ACTION = '&action='
4141 CONTRACT_ADDRESS = '&contractaddress='
@@ -101,7 +101,8 @@ def __init__(self, address, api_key=''):
101101 self .url_dict [self .ADDRESS ] = address
102102
103103 def build_url (self ):
104- self .url = self .PREFIX + '' .join ([param + val if val else '' for param , val in self .url_dict .items ()])
104+ self .url = self .PREFIX + '' .join (
105+ [parm + val if val else '' for parm , val in self .url_dict .items ()])
105106
106107 def connect (self ):
107108 # TODO: deal with "unknown exception" error
@@ -119,14 +120,15 @@ def connect(self):
119120 return data
120121 else :
121122 raise EmptyResponse (data .get ('message' , 'no message' ))
122- raise BadRequest ("Problem with connection, status code: %s" % req .status_code )
123+ raise BadRequest (
124+ f"Problem with connection, status code: { req .status_code } " )
123125
124126 def check_and_get_api (self ):
125127 if self .url_dict [self .API_KEY ]: # Check if api_key is empty string
126128 pass
127129 else :
128- self .url_dict [self .API_KEY ] = input ('Please type your EtherScan.io API key: ' )
130+ self .url_dict [self .API_KEY ] = input (
131+ 'Please type your EtherScan.io API key: ' )
129132
130133 def check_keys_api (self , data ):
131- return all (k in data for k in ('jsonrpc' , 'id' , 'result' ))
132-
134+ return all (k in data for k in ('jsonrpc' , 'id' , 'result' ))
0 commit comments