@@ -19,7 +19,7 @@ class ethplorerController {
19
19
protected $ db ;
20
20
protected $ command ;
21
21
protected $ params = array ();
22
- protected $ apiCommands = array ('getTxInfo ' , 'getTokenHistory ' , 'getAddressInfo ' , 'getTokenInfo ' , 'getAddressHistory ' );
22
+ protected $ apiCommands = array ('getTxInfo ' , 'getTokenHistory ' , 'getAddressInfo ' , 'getTokenInfo ' , 'getAddressHistory ' , ' getTopTokens ' );
23
23
protected $ defaults ;
24
24
25
25
public function __construct ($ es ){
@@ -87,8 +87,8 @@ public function run(){
87
87
if (!$ key || !$ this ->db ->checkAPIkey ($ key )){
88
88
$ this ->sendError (1 , 'Invalid API key ' );
89
89
}
90
- $ this ->defaults = $ this ->db ->getAPIKeyDefaults ($ key , $ this -> getCommand () );
91
- $ result = call_user_func (array ($ this , $ this -> getCommand () ));
90
+ $ this ->defaults = $ this ->db ->getAPIKeyDefaults ($ key , $ command );
91
+ $ result = call_user_func (array ($ this , $ command ));
92
92
}
93
93
return $ result ;
94
94
}
@@ -262,6 +262,21 @@ public function getAddressHistory(){
262
262
return $ this ->_getHistory (TRUE );
263
263
}
264
264
265
+ /**
266
+ * /getTopTokens method implementation.
267
+ *
268
+ * @undocumented
269
+ * @return array
270
+ */
271
+ public function getTopTokens (){
272
+ $ maxLimit = is_array ($ this ->defaults ) && isset ($ this ->defaults ['maxLimit ' ]) ? $ this ->defaults ['maxLimit ' ] : 50 ;
273
+ $ maxPeriod = is_array ($ this ->defaults ) && isset ($ this ->defaults ['maxPeriod ' ]) ? $ this ->defaults ['maxPeriod ' ] : 90 ;
274
+ $ limit = min (abs ((int )$ this ->getRequest ('limit ' , 10 )), $ maxLimit );
275
+ $ period = min (abs ((int )$ this ->getRequest ('limit ' , 10 )), $ maxPeriod );
276
+ $ result = array ('tokens ' => $ this ->db ->getTopTokens ($ limit , $ period ));
277
+ $ this ->sendResult ($ result );
278
+ }
279
+
265
280
/**
266
281
*
267
282
* Common method to get token and address operation history.
0 commit comments