Skip to content

Commit 7850e51

Browse files
committed
Updated Token class
I updated the token class to comply with the new url build design.
1 parent b0d3ecd commit 7850e51

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

etherscan/tokens.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,19 @@
44
class Tokens(Client):
55
def __init__(self, tokenname='TheDAO', api_key='YourApiKeyToken'):
66
Client.__init__(self, address='', api_key=api_key)
7-
self.tokenname = '&tokenname=' + tokenname
8-
9-
def make_url(self, call_type=''):
10-
if call_type == 'tokensupply':
11-
self.url = self.URL_BASES['prefix'] \
12-
+ self.module \
13-
+ self.action \
14-
+ self.tokenname \
15-
+ self.key
16-
elif call_type == 'tokenbalance':
17-
self.url = self.URL_BASES['prefix'] \
18-
+ self.module \
19-
+ self.action \
20-
+ self.tokenname \
21-
+ self.address \
22-
+ self.key
7+
self.url_dict[self.TOKEN_NAME] = tokenname
238

249
def get_total_supply(self):
25-
self.action = self.URL_BASES['action'] + 'tokensupply'
26-
self.module = self.URL_BASES['module'] + 'stats'
27-
self.make_url(call_type='tokensupply')
10+
self.url_dict[self.ACTION] = 'tokensupply'
11+
self.url_dict[self.MODULE] = 'stats'
12+
self.build_url()
2813
req = self.connect()
2914
return req['result']
3015

3116
def get_token_balance(self, address):
32-
self.address = self.URL_BASES['address'] + address
33-
self.module = self.URL_BASES['module'] + 'account'
34-
self.action = self.URL_BASES['action'] + 'tokenbalance'
35-
self.make_url(call_type='tokenbalance')
17+
self.url_dict[self.ADDRESS] = address
18+
self.url_dict[self.MODULE] = 'account'
19+
self.url_dict[self.ACTION] = 'tokenbalance'
20+
self.build_url()
3621
req = self.connect()
37-
return req['result']
22+
return req['result']

0 commit comments

Comments
 (0)