@@ -30,12 +30,12 @@ class BadRequest(ClientException):
30
30
"""Invalid request passed"""
31
31
32
32
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"
34
34
class Client (object ):
35
35
dao_address = '0xbb9bc244d798123fde783fcc1c72d3bb8c189413'
36
36
37
37
# Constants
38
- PREFIX = 'https://api-ropsten.etherscan.io/api?' # TESTNET
38
+ PREFIX = 'https://api-ropsten.etherscan.io/api?' # TESTNET
39
39
MODULE = 'module='
40
40
ACTION = '&action='
41
41
CONTRACT_ADDRESS = '&contractaddress='
@@ -101,7 +101,8 @@ def __init__(self, address, api_key=''):
101
101
self .url_dict [self .ADDRESS ] = address
102
102
103
103
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 ()])
105
106
106
107
def connect (self ):
107
108
# TODO: deal with "unknown exception" error
@@ -119,14 +120,15 @@ def connect(self):
119
120
return data
120
121
else :
121
122
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 } " )
123
125
124
126
def check_and_get_api (self ):
125
127
if self .url_dict [self .API_KEY ]: # Check if api_key is empty string
126
128
pass
127
129
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: ' )
129
132
130
133
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