Skip to content

Commit 8e4a7e8

Browse files
committed
Updated files to comply with the alternative url building method
1 parent 472421d commit 8e4a7e8

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

etherscan/contracts.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,10 @@
44
class Contract(Client):
55
def __init__(self, address=Client.dao_address, api_key='YourApiKeyToken'):
66
Client.__init__(self, address=address, api_key=api_key)
7-
self.module = self.URL_BASES['module'] + 'contract'
8-
9-
def make_url(self, call_type=''):
10-
if call_type == 'getabi':
11-
self.url = self.URL_BASES['prefix'] \
12-
+ self.module \
13-
+ self.action \
14-
+ self.address \
15-
+ self.key
7+
self.url_dict[self.MODULE] = 'contract'
168

179
def get_abi(self):
18-
self.action = self.URL_BASES['action'] + 'getabi'
19-
self.make_url(call_type='getabi')
10+
self.url_dict[self.ACTION] = 'getabi'
11+
self.build_url()
2012
req = self.connect()
21-
return req['result']
13+
return req['result']

etherscan/stats.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44
class Stats(Client):
55
def __init__(self, api_key='YourApiKeyToken'):
66
Client.__init__(self, address='', api_key=api_key)
7-
self.module = self.URL_BASES['module'] + 'stats'
8-
9-
def make_url(self, call_type=''):
10-
if call_type == 'stats':
11-
self.url = self.URL_BASES['prefix'] \
12-
+ self.module \
13-
+ self.action \
14-
+ self.key
7+
self.url_dict[self.MODULE] = 'stats'
158

169
def get_total_ether_supply(self):
17-
self.action = self.URL_BASES['action'] + 'ethsupply'
18-
self.make_url(call_type='stats')
10+
self.url_dict[self.ACTION] = 'ethsupply'
11+
self.build_url()
1912
req = self.connect()
2013
return req['result']
2114

2215
def get_ether_last_price(self):
23-
self.action = self.URL_BASES['action'] + 'ethprice'
24-
self.make_url(call_type='stats')
16+
self.url_dict[self.ACTION] = 'ethprice'
17+
self.build_url()
2518
req = self.connect()
2619
return req['result']

etherscan/tokens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def get_token_balance(self, address):
1919
self.url_dict[self.ACTION] = 'tokenbalance'
2020
self.build_url()
2121
req = self.connect()
22-
return req['result']
22+
return req['result']

0 commit comments

Comments
 (0)