File tree Expand file tree Collapse file tree 1 file changed +9
-24
lines changed Expand file tree Collapse file tree 1 file changed +9
-24
lines changed Original file line number Diff line number Diff line change 4
4
class Tokens (Client ):
5
5
def __init__ (self , tokenname = 'TheDAO' , api_key = 'YourApiKeyToken' ):
6
6
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
23
8
24
9
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 ( )
28
13
req = self .connect ()
29
14
return req ['result' ]
30
15
31
16
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 ( )
36
21
req = self .connect ()
37
- return req ['result' ]
22
+ return req ['result' ]
You can’t perform that action at this time.
0 commit comments